@antv/l7-component 2.9.32-alpha.2 → 2.9.32-alpha.4

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 (114) hide show
  1. package/es/assets/iconfont/iconfont.js +53 -0
  2. package/es/constants/index.d.ts +60 -0
  3. package/es/constants/index.js +60 -0
  4. package/es/control/baseControl/buttonControl.d.ts +59 -0
  5. package/es/control/baseControl/buttonControl.js +191 -0
  6. package/es/control/baseControl/control.d.ts +107 -0
  7. package/es/control/baseControl/control.js +288 -0
  8. package/es/control/baseControl/index.d.ts +4 -0
  9. package/es/control/baseControl/index.js +4 -0
  10. package/es/control/baseControl/popperControl.d.ts +26 -0
  11. package/es/control/baseControl/popperControl.js +131 -0
  12. package/es/control/baseControl/selectControl.d.ts +46 -0
  13. package/es/control/baseControl/selectControl.js +227 -0
  14. package/es/control/exportImage.d.ts +18 -0
  15. package/es/control/exportImage.js +163 -0
  16. package/es/control/fullscreen.d.ts +19 -0
  17. package/es/control/fullscreen.js +151 -0
  18. package/es/control/geoLocate.d.ts +16 -0
  19. package/es/control/geoLocate.js +139 -0
  20. package/es/control/layerControl.d.ts +21 -0
  21. package/es/control/layerControl.js +172 -0
  22. package/es/control/logo.d.ts +13 -0
  23. package/es/control/logo.js +87 -0
  24. package/es/control/mapTheme.d.ts +10 -0
  25. package/es/control/mapTheme.js +135 -0
  26. package/es/control/mouseLocation.d.ts +15 -0
  27. package/es/control/mouseLocation.js +104 -0
  28. package/es/control/scale.d.ts +34 -0
  29. package/es/control/scale.js +172 -0
  30. package/es/control/zoom.d.ts +34 -0
  31. package/es/control/zoom.js +146 -0
  32. package/es/css/button.less +70 -0
  33. package/es/css/control.less +71 -0
  34. package/es/css/index.css +567 -0
  35. package/es/css/index.less +12 -0
  36. package/es/css/l7.less +60 -0
  37. package/es/css/layerPopup.less +8 -0
  38. package/es/css/logo.less +18 -0
  39. package/es/css/mouseLocation.less +9 -0
  40. package/es/css/popper.less +64 -0
  41. package/es/css/popup.less +169 -0
  42. package/es/css/scale.less +34 -0
  43. package/es/css/select.less +86 -0
  44. package/es/css/variables.less +28 -0
  45. package/es/css/zoom.less +21 -0
  46. package/es/images/layers.png +0 -0
  47. package/es/images/layers.svg +1 -0
  48. package/es/images/logo.png +0 -0
  49. package/es/images/quanping.svg +12 -0
  50. package/es/index.d.ts +18 -0
  51. package/es/index.js +59 -0
  52. package/es/interface.d.ts +18 -0
  53. package/es/interface.js +1 -0
  54. package/es/marker-layer.d.ts +53 -0
  55. package/es/marker-layer.js +363 -0
  56. package/es/marker.d.ts +49 -0
  57. package/es/marker.js +434 -0
  58. package/es/popup/layerPopup.d.ts +78 -0
  59. package/es/popup/layerPopup.js +308 -0
  60. package/es/popup/popup.d.ts +147 -0
  61. package/es/popup/popup.js +636 -0
  62. package/es/utils/anchor.d.ts +22 -0
  63. package/es/utils/anchor.js +35 -0
  64. package/es/utils/icon.d.ts +1 -0
  65. package/es/utils/icon.js +9 -0
  66. package/es/utils/popper.d.ts +75 -0
  67. package/es/utils/popper.js +286 -0
  68. package/es/utils/screenfull.d.ts +2 -0
  69. package/es/utils/screenfull.js +157 -0
  70. package/lib/assets/iconfont/iconfont.js +39 -0
  71. package/lib/constants/index.js +90 -0
  72. package/lib/control/baseControl/buttonControl.js +118 -0
  73. package/lib/control/baseControl/control.js +172 -0
  74. package/lib/control/baseControl/index.js +22 -0
  75. package/lib/control/baseControl/popperControl.js +108 -0
  76. package/lib/control/baseControl/selectControl.js +153 -0
  77. package/lib/control/exportImage.js +83 -0
  78. package/lib/control/fullscreen.js +109 -0
  79. package/lib/control/geoLocate.js +78 -0
  80. package/lib/control/layerControl.js +136 -0
  81. package/lib/control/logo.js +74 -0
  82. package/lib/control/mapTheme.js +92 -0
  83. package/lib/control/mouseLocation.js +79 -0
  84. package/lib/control/scale.js +136 -0
  85. package/lib/control/zoom.js +119 -0
  86. package/lib/css/button.less +70 -0
  87. package/lib/css/control.less +71 -0
  88. package/lib/css/index.css +567 -0
  89. package/lib/css/index.less +12 -0
  90. package/lib/css/l7.less +60 -0
  91. package/lib/css/layerPopup.less +8 -0
  92. package/lib/css/logo.less +18 -0
  93. package/lib/css/mouseLocation.less +9 -0
  94. package/lib/css/popper.less +64 -0
  95. package/lib/css/popup.less +169 -0
  96. package/lib/css/scale.less +34 -0
  97. package/lib/css/select.less +86 -0
  98. package/lib/css/variables.less +28 -0
  99. package/lib/css/zoom.less +21 -0
  100. package/lib/images/layers.png +0 -0
  101. package/lib/images/layers.svg +1 -0
  102. package/lib/images/logo.png +0 -0
  103. package/lib/images/quanping.svg +12 -0
  104. package/lib/index.js +51 -0
  105. package/lib/interface.js +17 -0
  106. package/lib/marker-layer.js +263 -0
  107. package/lib/marker.js +307 -0
  108. package/lib/popup/layerPopup.js +200 -0
  109. package/lib/popup/popup.js +388 -0
  110. package/lib/utils/anchor.js +63 -0
  111. package/lib/utils/icon.js +37 -0
  112. package/lib/utils/popper.js +209 -0
  113. package/lib/utils/screenfull.js +160 -0
  114. package/package.json +5 -5
@@ -0,0 +1,90 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/constants/index.ts
20
+ var constants_exports = {};
21
+ __export(constants_exports, {
22
+ GaodeMapStyleConfig: () => GaodeMapStyleConfig,
23
+ MapboxMapStyleConfig: () => MapboxMapStyleConfig
24
+ });
25
+ module.exports = __toCommonJS(constants_exports);
26
+ var GaodeMapStyleConfig = {
27
+ normal: {
28
+ text: "\u6807\u51C6",
29
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*-nqiT6Vu948AAAAAAAAAAAAAARQnAQ"
30
+ },
31
+ light: {
32
+ text: "\u6708\u5149\u94F6",
33
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*J_wYQL_PaUEAAAAAAAAAAAAAARQnAQ"
34
+ },
35
+ dark: {
36
+ text: "\u5E7B\u5F71\u9ED1",
37
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*U7M9QI1yat4AAAAAAAAAAAAAARQnAQ"
38
+ },
39
+ fresh: {
40
+ text: "\u8349\u8272\u9752",
41
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*T-oBT4hB5ucAAAAAAAAAAAAAARQnAQ"
42
+ },
43
+ grey: {
44
+ text: "\u96C5\u58EB\u7070",
45
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*OREXQ4vgQRIAAAAAAAAAAAAAARQnAQ"
46
+ },
47
+ graffiti: {
48
+ text: "\u6D82\u9E26",
49
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*4UApTKmeiy4AAAAAAAAAAAAAARQnAQ"
50
+ },
51
+ macaron: {
52
+ text: "\u9A6C\u5361\u9F99",
53
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*0GrCQLtDjNcAAAAAAAAAAAAAARQnAQ"
54
+ },
55
+ darkblue: {
56
+ text: "\u6781\u591C\u84DD",
57
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*uWxqSZQlPkkAAAAAAAAAAAAAARQnAQ"
58
+ },
59
+ wine: {
60
+ text: "\u9171\u7C7D",
61
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*OFPrTbg3an0AAAAAAAAAAAAAARQnAQ"
62
+ }
63
+ };
64
+ var MapboxMapStyleConfig = {
65
+ normal: {
66
+ text: "\u6807\u51C6",
67
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*AnfJTbIBJOkAAAAAAAAAAAAAARQnAQ"
68
+ },
69
+ light: {
70
+ text: "\u4EAE",
71
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*gnuiQIok9qIAAAAAAAAAAAAAARQnAQ"
72
+ },
73
+ dark: {
74
+ text: "\u6697",
75
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*NwG-TbOlBH0AAAAAAAAAAAAAARQnAQ"
76
+ },
77
+ satellite: {
78
+ text: "\u536B\u661F",
79
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*2X5EQLKul3IAAAAAAAAAAAAAARQnAQ"
80
+ },
81
+ outdoors: {
82
+ text: "\u6237\u5916",
83
+ img: "https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*gXFLRIaBUI0AAAAAAAAAAAAAARQnAQ"
84
+ }
85
+ };
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ GaodeMapStyleConfig,
89
+ MapboxMapStyleConfig
90
+ });
@@ -0,0 +1,118 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/control/baseControl/buttonControl.ts
23
+ var buttonControl_exports = {};
24
+ __export(buttonControl_exports, {
25
+ ButtonControl: () => ButtonControl,
26
+ default: () => ButtonControl
27
+ });
28
+ module.exports = __toCommonJS(buttonControl_exports);
29
+ var import_l7_utils = require("@antv/l7-utils");
30
+ var import_control = __toESM(require("./control"));
31
+ var ButtonControl = class extends import_control.default {
32
+ constructor() {
33
+ super(...arguments);
34
+ this.isDisable = false;
35
+ }
36
+ setIsDisable(newIsDisable) {
37
+ var _a, _b;
38
+ this.isDisable = newIsDisable;
39
+ if (newIsDisable) {
40
+ (_a = this.button) == null ? void 0 : _a.setAttribute("disabled", "true");
41
+ } else {
42
+ (_b = this.button) == null ? void 0 : _b.removeAttribute("disabled");
43
+ }
44
+ }
45
+ createButton(className = "") {
46
+ return import_l7_utils.DOM.create("button", `l7-button-control ${className}`);
47
+ }
48
+ onAdd() {
49
+ this.button = this.createButton();
50
+ this.isDisable = false;
51
+ const { title, btnText, btnIcon } = this.controlOption;
52
+ this.setBtnTitle(title);
53
+ this.setBtnText(btnText);
54
+ this.setBtnIcon(btnIcon);
55
+ return this.button;
56
+ }
57
+ onRemove() {
58
+ this.button = this.buttonIcon = this.buttonText = void 0;
59
+ this.isDisable = false;
60
+ }
61
+ setOptions(newOptions) {
62
+ const { title, btnText, btnIcon } = newOptions;
63
+ if (this.checkUpdateOption(newOptions, ["title"])) {
64
+ this.setBtnTitle(title);
65
+ }
66
+ if (this.checkUpdateOption(newOptions, ["btnIcon"])) {
67
+ this.setBtnIcon(btnIcon);
68
+ }
69
+ if (this.checkUpdateOption(newOptions, ["btnText"])) {
70
+ this.setBtnText(btnText);
71
+ }
72
+ super.setOptions(newOptions);
73
+ }
74
+ setBtnTitle(title) {
75
+ var _a;
76
+ (_a = this.button) == null ? void 0 : _a.setAttribute("title", title ?? "");
77
+ }
78
+ setBtnIcon(newIcon) {
79
+ var _a, _b, _c;
80
+ if (this.buttonIcon) {
81
+ import_l7_utils.DOM.remove(this.buttonIcon);
82
+ }
83
+ if (newIcon) {
84
+ const firstChild = (_a = this.button) == null ? void 0 : _a.firstChild;
85
+ if (firstChild) {
86
+ (_b = this.button) == null ? void 0 : _b.insertBefore(newIcon, firstChild);
87
+ } else {
88
+ (_c = this.button) == null ? void 0 : _c.appendChild(newIcon);
89
+ }
90
+ this.buttonIcon = newIcon;
91
+ }
92
+ }
93
+ setBtnText(newText) {
94
+ var _a;
95
+ if (!this.button) {
96
+ return;
97
+ }
98
+ import_l7_utils.DOM.removeClass(this.button, "l7-button-control--row");
99
+ import_l7_utils.DOM.removeClass(this.button, "l7-button-control--column");
100
+ if (newText) {
101
+ let btnText = this.buttonText;
102
+ if (!btnText) {
103
+ btnText = import_l7_utils.DOM.create("div", "l7-button-control__text");
104
+ (_a = this.button) == null ? void 0 : _a.appendChild(btnText);
105
+ this.buttonText = btnText;
106
+ }
107
+ btnText.innerText = newText;
108
+ import_l7_utils.DOM.addClass(this.button, this.controlOption.vertical ? "l7-button-control--column" : "l7-button-control--row");
109
+ } else if (!newText && this.buttonText) {
110
+ import_l7_utils.DOM.remove(this.buttonText);
111
+ this.buttonText = void 0;
112
+ }
113
+ }
114
+ };
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {
117
+ ButtonControl
118
+ });
@@ -0,0 +1,172 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/control/baseControl/control.ts
23
+ var control_exports = {};
24
+ __export(control_exports, {
25
+ Control: () => Control,
26
+ PositionType: () => import_l7_core2.PositionType,
27
+ default: () => Control
28
+ });
29
+ module.exports = __toCommonJS(control_exports);
30
+ var import_l7_core = require("@antv/l7-core");
31
+ var import_l7_utils = require("@antv/l7-utils");
32
+ var import_eventemitter3 = __toESM(require("eventemitter3"));
33
+ var import_l7_core2 = require("@antv/l7-core");
34
+ var _Control = class extends import_eventemitter3.default {
35
+ constructor(option) {
36
+ super();
37
+ _Control.controlCount++;
38
+ this.controlOption = {
39
+ ...this.getDefault(option),
40
+ ...option || {}
41
+ };
42
+ }
43
+ getOptions() {
44
+ return this.controlOption;
45
+ }
46
+ setOptions(newOptions) {
47
+ if ("position" in newOptions) {
48
+ this.setPosition(newOptions.position);
49
+ }
50
+ if ("className" in newOptions) {
51
+ this.setClassName(newOptions.className);
52
+ }
53
+ if ("style" in newOptions) {
54
+ this.setStyle(newOptions.style);
55
+ }
56
+ this.controlOption = {
57
+ ...this.controlOption,
58
+ ...newOptions
59
+ };
60
+ }
61
+ addTo(sceneContainer) {
62
+ this.mapsService = sceneContainer.get(import_l7_core.TYPES.IMapService);
63
+ this.renderService = sceneContainer.get(import_l7_core.TYPES.IRendererService);
64
+ this.layerService = sceneContainer.get(import_l7_core.TYPES.ILayerService);
65
+ this.controlService = sceneContainer.get(import_l7_core.TYPES.IControlService);
66
+ this.configService = sceneContainer.get(import_l7_core.TYPES.IGlobalConfigService);
67
+ this.scene = sceneContainer.get(import_l7_core.TYPES.ISceneService);
68
+ this.sceneContainer = sceneContainer;
69
+ this.isShow = true;
70
+ this.container = this.onAdd();
71
+ import_l7_utils.DOM.addClass(this.container, "l7-control");
72
+ const { className, style } = this.controlOption;
73
+ if (className) {
74
+ this.setClassName(className);
75
+ }
76
+ if (style) {
77
+ this.setStyle(style);
78
+ }
79
+ this.insertContainer();
80
+ this.emit("add", this);
81
+ return this;
82
+ }
83
+ remove() {
84
+ if (!this.mapsService) {
85
+ return this;
86
+ }
87
+ import_l7_utils.DOM.remove(this.container);
88
+ this.onRemove();
89
+ this.emit("remove", this);
90
+ }
91
+ show() {
92
+ const container = this.container;
93
+ import_l7_utils.DOM.removeClass(container, "l7-control--hide");
94
+ this.isShow = true;
95
+ this.emit("show", this);
96
+ }
97
+ hide() {
98
+ const container = this.container;
99
+ import_l7_utils.DOM.addClass(container, "l7-control--hide");
100
+ this.isShow = false;
101
+ this.emit("hide", this);
102
+ }
103
+ getDefault(option) {
104
+ return {
105
+ position: import_l7_core.PositionType.TOPRIGHT,
106
+ name: `${_Control.controlCount}`
107
+ };
108
+ }
109
+ getContainer() {
110
+ return this.container;
111
+ }
112
+ getIsShow() {
113
+ return this.isShow;
114
+ }
115
+ _refocusOnMap(e) {
116
+ if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
117
+ const container = this.mapsService.getContainer();
118
+ if (container !== null) {
119
+ container.focus();
120
+ }
121
+ }
122
+ }
123
+ setPosition(position = import_l7_core.PositionType.TOPLEFT) {
124
+ const controlService = this.controlService;
125
+ if (controlService) {
126
+ controlService.removeControl(this);
127
+ }
128
+ this.controlOption.position = position;
129
+ if (controlService) {
130
+ controlService.addControl(this, this.sceneContainer);
131
+ }
132
+ return this;
133
+ }
134
+ setClassName(className) {
135
+ const container = this.container;
136
+ const { className: oldClassName } = this.controlOption;
137
+ if (oldClassName) {
138
+ import_l7_utils.DOM.removeClass(container, oldClassName);
139
+ }
140
+ if (className) {
141
+ import_l7_utils.DOM.addClass(container, className);
142
+ }
143
+ }
144
+ setStyle(style) {
145
+ const container = this.container;
146
+ if (style) {
147
+ container.setAttribute("style", style);
148
+ } else {
149
+ container.removeAttribute("style");
150
+ }
151
+ }
152
+ insertContainer() {
153
+ const container = this.container;
154
+ const position = this.controlOption.position;
155
+ const corner = this.controlService.controlCorners[position];
156
+ if (position.indexOf("bottom") !== -1) {
157
+ corner.insertBefore(container, corner.firstChild);
158
+ } else {
159
+ corner.appendChild(container);
160
+ }
161
+ }
162
+ checkUpdateOption(option, keys) {
163
+ return keys.some((key) => key in option);
164
+ }
165
+ };
166
+ var Control = _Control;
167
+ Control.controlCount = 0;
168
+ // Annotate the CommonJS export names for ESM import in node:
169
+ 0 && (module.exports = {
170
+ Control,
171
+ PositionType
172
+ });
@@ -0,0 +1,22 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/control/baseControl/index.ts
17
+ var baseControl_exports = {};
18
+ module.exports = __toCommonJS(baseControl_exports);
19
+ __reExport(baseControl_exports, require("./control"), module.exports);
20
+ __reExport(baseControl_exports, require("./buttonControl"), module.exports);
21
+ __reExport(baseControl_exports, require("./popperControl"), module.exports);
22
+ __reExport(baseControl_exports, require("./selectControl"), module.exports);
@@ -0,0 +1,108 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/control/baseControl/popperControl.ts
23
+ var popperControl_exports = {};
24
+ __export(popperControl_exports, {
25
+ PopperControl: () => PopperControl,
26
+ default: () => PopperControl
27
+ });
28
+ module.exports = __toCommonJS(popperControl_exports);
29
+ var import_popper = require("../../utils/popper");
30
+ var import_buttonControl = __toESM(require("./buttonControl"));
31
+ var PopperPlacementMap = {
32
+ topleft: "right-start",
33
+ topcenter: "bottom",
34
+ topright: "left-start",
35
+ bottomleft: "right-end",
36
+ bottomcenter: "top",
37
+ bottomright: "left-end",
38
+ lefttop: "bottom-start",
39
+ leftcenter: "right",
40
+ leftbottom: "top-start",
41
+ righttop: "bottom-end",
42
+ rightcenter: "left",
43
+ rightbottom: "top-end"
44
+ };
45
+ var PopperControl = class extends import_buttonControl.default {
46
+ getPopper() {
47
+ return this.popper;
48
+ }
49
+ hide() {
50
+ this.popper.hide();
51
+ super.hide();
52
+ }
53
+ getDefault(option) {
54
+ const defaultOption = super.getDefault(option);
55
+ const position = (option == null ? void 0 : option.position) ?? defaultOption.position;
56
+ return {
57
+ ...super.getDefault(option),
58
+ popperPlacement: PopperPlacementMap[position],
59
+ popperTrigger: "click"
60
+ };
61
+ }
62
+ onAdd() {
63
+ const button = super.onAdd();
64
+ this.initPopper();
65
+ return button;
66
+ }
67
+ onRemove() {
68
+ this.popper.destroy();
69
+ }
70
+ initPopper() {
71
+ const {
72
+ popperClassName,
73
+ popperPlacement,
74
+ popperTrigger
75
+ } = this.controlOption;
76
+ const popperContainer = this.mapsService.getMapContainer();
77
+ this.popper = new import_popper.Popper(this.button, {
78
+ className: popperClassName,
79
+ placement: popperPlacement,
80
+ trigger: popperTrigger,
81
+ container: popperContainer,
82
+ unique: true
83
+ });
84
+ this.popper.on("show", () => {
85
+ this.emit("popperShow", this);
86
+ }).on("hide", () => {
87
+ this.emit("popperHide", this);
88
+ });
89
+ return this.popper;
90
+ }
91
+ setOptions(option) {
92
+ super.setOptions(option);
93
+ if (this.checkUpdateOption(option, [
94
+ "popperPlacement",
95
+ "popperTrigger",
96
+ "popperClassName"
97
+ ])) {
98
+ const content = this.popper.getContent();
99
+ this.popper.destroy();
100
+ this.initPopper();
101
+ this.popper.setContent(content);
102
+ }
103
+ }
104
+ };
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ PopperControl
108
+ });
@@ -0,0 +1,153 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/control/baseControl/selectControl.ts
20
+ var selectControl_exports = {};
21
+ __export(selectControl_exports, {
22
+ SelectControl: () => SelectControl,
23
+ default: () => SelectControl
24
+ });
25
+ module.exports = __toCommonJS(selectControl_exports);
26
+ var import_l7_utils = require("@antv/l7-utils");
27
+ var import_popperControl = require("./popperControl");
28
+ var SelectControl = class extends import_popperControl.PopperControl {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.selectValue = [];
32
+ this.createNormalOption = (option) => {
33
+ const isSelect = this.selectValue.includes(option.value);
34
+ const optionDOM = import_l7_utils.DOM.create("div", `l7-select-control-item ${isSelect ? "l7-select-control-item-active" /* ActiveOptionClassName */ : ""}`);
35
+ if (this.getIsMultiple()) {
36
+ optionDOM.appendChild(this.createCheckbox(isSelect));
37
+ }
38
+ if (option.icon) {
39
+ optionDOM.appendChild(option.icon);
40
+ }
41
+ const textDOM = import_l7_utils.DOM.create("span");
42
+ textDOM.innerText = option.text;
43
+ optionDOM.appendChild(textDOM);
44
+ return optionDOM;
45
+ };
46
+ this.onItemClick = (item) => {
47
+ if (this.getIsMultiple()) {
48
+ const targetIndex = this.selectValue.findIndex((value) => value === item.value);
49
+ if (targetIndex > -1) {
50
+ this.selectValue.splice(targetIndex, 1);
51
+ } else {
52
+ this.selectValue = [...this.selectValue, item.value];
53
+ }
54
+ } else {
55
+ this.selectValue = [item.value];
56
+ }
57
+ this.setSelectValue(this.selectValue);
58
+ };
59
+ }
60
+ setOptions(option) {
61
+ super.setOptions(option);
62
+ const { options } = option;
63
+ if (options) {
64
+ this.popper.setContent(this.getPopperContent(options));
65
+ }
66
+ }
67
+ onAdd() {
68
+ const button = super.onAdd();
69
+ const { defaultValue } = this.controlOption;
70
+ if (defaultValue) {
71
+ this.selectValue = this.transSelectValue(defaultValue);
72
+ }
73
+ this.popper.setContent(this.getPopperContent(this.controlOption.options));
74
+ return button;
75
+ }
76
+ getSelectValue() {
77
+ return this.getIsMultiple() ? this.selectValue : this.selectValue[0];
78
+ }
79
+ setSelectValue(value, emitEvent = true) {
80
+ const finalValue = this.transSelectValue(value);
81
+ this.optionDOMList.forEach((optionDOM) => {
82
+ const optionValue = optionDOM.getAttribute("data-option-value" /* OptionValueAttrKey */);
83
+ const checkboxDOM = this.getIsMultiple() ? optionDOM.querySelector("input[type=checkbox]") : void 0;
84
+ if (finalValue.includes(optionValue)) {
85
+ import_l7_utils.DOM.addClass(optionDOM, "l7-select-control-item-active" /* ActiveOptionClassName */);
86
+ if (checkboxDOM) {
87
+ import_l7_utils.DOM.setChecked(checkboxDOM, true);
88
+ }
89
+ } else {
90
+ import_l7_utils.DOM.removeClass(optionDOM, "l7-select-control-item-active" /* ActiveOptionClassName */);
91
+ if (checkboxDOM) {
92
+ import_l7_utils.DOM.setChecked(checkboxDOM, false);
93
+ }
94
+ }
95
+ });
96
+ this.selectValue = finalValue;
97
+ if (emitEvent) {
98
+ this.emit("selectChange", this.getIsMultiple() ? finalValue : finalValue[0]);
99
+ }
100
+ }
101
+ getPopperContent(options) {
102
+ const isImageOptions = this.isImageOptions();
103
+ const content = import_l7_utils.DOM.create("div", isImageOptions ? "l7-select-control--image" : "l7-select-control--normal");
104
+ if (this.getIsMultiple()) {
105
+ import_l7_utils.DOM.addClass(content, "l7-select-control--multiple");
106
+ }
107
+ const optionsDOMList = options.map((option, optionIndex) => {
108
+ const optionDOM = isImageOptions ? this.createImageOption(option) : this.createNormalOption(option);
109
+ optionDOM.setAttribute("data-option-value" /* OptionValueAttrKey */, option.value);
110
+ optionDOM.setAttribute("data-option-index" /* OptionIndexAttrKey */, window.String(optionIndex));
111
+ optionDOM.addEventListener("click", this.onItemClick.bind(this, option));
112
+ return optionDOM;
113
+ });
114
+ content.append(...optionsDOMList);
115
+ this.optionDOMList = optionsDOMList;
116
+ return content;
117
+ }
118
+ createImageOption(option) {
119
+ const isSelect = this.selectValue.includes(option.value);
120
+ const optionDOM = import_l7_utils.DOM.create("div", `l7-select-control-item ${isSelect ? "l7-select-control-item-active" /* ActiveOptionClassName */ : ""}`);
121
+ const imgDOM = import_l7_utils.DOM.create("img");
122
+ imgDOM.setAttribute("src", option.img);
123
+ import_l7_utils.DOM.setUnDraggable(imgDOM);
124
+ optionDOM.appendChild(imgDOM);
125
+ const rowDOM = import_l7_utils.DOM.create("div", "l7-select-control-item-row");
126
+ if (this.getIsMultiple()) {
127
+ optionDOM.appendChild(this.createCheckbox(isSelect));
128
+ }
129
+ const textDOM = import_l7_utils.DOM.create("span");
130
+ textDOM.innerText = option.text;
131
+ rowDOM.appendChild(textDOM);
132
+ optionDOM.appendChild(rowDOM);
133
+ return optionDOM;
134
+ }
135
+ createCheckbox(isSelect) {
136
+ const checkboxDOM = import_l7_utils.DOM.create("input");
137
+ checkboxDOM.setAttribute("type", "checkbox");
138
+ if (isSelect) {
139
+ import_l7_utils.DOM.setChecked(checkboxDOM, true);
140
+ }
141
+ return checkboxDOM;
142
+ }
143
+ isImageOptions() {
144
+ return !!this.controlOption.options.find((item) => item.img);
145
+ }
146
+ transSelectValue(value) {
147
+ return Array.isArray(value) ? value : [value];
148
+ }
149
+ };
150
+ // Annotate the CommonJS export names for ESM import in node:
151
+ 0 && (module.exports = {
152
+ SelectControl
153
+ });