@lark-apaas/miaoda-inspector 0.1.0-alpha.5 → 0.1.0-alpha.7

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 (37) hide show
  1. package/dist/es/Inspector/Inspector.mjs +4 -22
  2. package/dist/es/Inspector/Overlay.mjs +58 -32
  3. package/dist/es/Inspector/utils/inspect.mjs +80 -1
  4. package/dist/es/MiaodaInspector/MiaodaInspector.mjs +332 -173
  5. package/dist/es/config/ui-config.mjs +138 -136
  6. package/dist/es/index.mjs +2 -0
  7. package/dist/es/types/feature.mjs +0 -0
  8. package/dist/es/types/index.mjs +4 -0
  9. package/dist/es/utils/config-mapper.mjs +1 -3
  10. package/dist/es/utils/element-guards.mjs +36 -0
  11. package/dist/es/utils/index.mjs +1 -6
  12. package/dist/es/utils/style-calculator.mjs +17 -60
  13. package/dist/lib/Inspector/Inspector.js +4 -23
  14. package/dist/lib/Inspector/Overlay.js +57 -28
  15. package/dist/lib/Inspector/utils/inspect.js +90 -1
  16. package/dist/lib/MiaodaInspector/MiaodaInspector.js +337 -183
  17. package/dist/lib/config/ui-config.js +138 -136
  18. package/dist/lib/index.js +2 -0
  19. package/dist/lib/types/feature.js +16 -0
  20. package/dist/lib/types/index.js +3 -0
  21. package/dist/lib/utils/config-mapper.js +1 -3
  22. package/dist/lib/utils/element-guards.js +55 -0
  23. package/dist/lib/utils/style-calculator.js +17 -60
  24. package/dist/types/Inspector/Inspector.d.ts +8 -1
  25. package/dist/types/Inspector/Overlay.d.ts +9 -2
  26. package/dist/types/Inspector/utils/index.d.ts +1 -1
  27. package/dist/types/Inspector/utils/inspect.d.ts +8 -1
  28. package/dist/types/config/ui-config.d.ts +26 -3
  29. package/dist/types/global.d.d.ts +6 -0
  30. package/dist/types/index.d.ts +2 -1
  31. package/dist/types/types/feature.d.ts +6 -0
  32. package/dist/types/types/iframe-events.d.ts +44 -2
  33. package/dist/types/types/index.d.ts +2 -1
  34. package/dist/types/utils/element-guards.d.ts +7 -0
  35. package/dist/types/utils/index.d.ts +1 -0
  36. package/dist/types/utils/origin.d.ts +1 -0
  37. package/package.json +13 -12
@@ -24,21 +24,13 @@ const defaultUIConfig = {
24
24
  type: "select",
25
25
  options: [
26
26
  { value: "font-thin", label: "\u6781\u7EC6\uFF08Thin\uFF09", rawValue: "100" },
27
- {
28
- value: "font-extralight",
29
- label: "\u6781\u8F7B\uFF08Extra Light\uFF09",
30
- rawValue: "200"
31
- },
27
+ { value: "font-extralight", label: "\u6781\u8F7B\uFF08Extra Light\uFF09", rawValue: "200" },
32
28
  { value: "font-light", label: "\u8F7B\uFF08Light\uFF09", rawValue: "300" },
33
29
  { value: "font-normal", label: "\u5E38\u89C4\uFF08Normal\uFF09", rawValue: "400" },
34
30
  { value: "font-medium", label: "\u4E2D\u7C97\uFF08Medium\uFF09", rawValue: "500" },
35
31
  { value: "font-semibold", label: "\u534A\u7C97\uFF08Semi Bold\uFF09", rawValue: "600" },
36
32
  { value: "font-bold", label: "\u7C97\uFF08Bold\uFF09", rawValue: "700" },
37
- {
38
- value: "font-extrabold",
39
- label: "\u6781\u7C97\uFF08Extra Bold\uFF09",
40
- rawValue: "800"
41
- },
33
+ { value: "font-extrabold", label: "\u6781\u7C97\uFF08Extra Bold\uFF09", rawValue: "800" },
42
34
  { value: "font-black", label: "\u9ED1\u4F53\uFF08Black\uFF09", rawValue: "900" }
43
35
  ]
44
36
  },
@@ -118,72 +110,22 @@ const defaultUIConfig = {
118
110
  type: "tailwind",
119
111
  rawValue: "#ffffff"
120
112
  },
121
- {
122
- value: "text-neutral-50",
123
- label: "neutral-50",
124
- type: "tailwind",
125
- rawValue: "#f5f6f7"
126
- },
127
- {
128
- value: "text-neutral-100",
129
- label: "neutral-100",
130
- type: "tailwind",
131
- rawValue: "#f2f3f5"
132
- },
133
- {
134
- value: "text-neutral-200",
135
- label: "neutral-200",
136
- type: "tailwind",
137
- rawValue: "#eff0f1"
138
- },
139
- {
140
- value: "text-neutral-300",
141
- label: "neutral-300",
142
- type: "tailwind",
143
- rawValue: "#dee0e3"
144
- },
145
- {
146
- value: "text-neutral-400",
147
- label: "neutral-400",
148
- type: "tailwind",
149
- rawValue: "#d0d3d6"
150
- },
151
- {
152
- value: "text-neutral-500",
153
- label: "neutral-500",
154
- type: "tailwind",
155
- rawValue: "#bbbfc4"
156
- },
157
- {
158
- value: "text-neutral-600",
159
- label: "neutral-600",
160
- type: "tailwind",
161
- rawValue: "#8f959e"
162
- },
113
+ { value: "text-neutral-50", label: "neutral-50", type: "tailwind", rawValue: "#f5f6f7" },
114
+ { value: "text-neutral-100", label: "neutral-100", type: "tailwind", rawValue: "#f2f3f5" },
115
+ { value: "text-neutral-200", label: "neutral-200", type: "tailwind", rawValue: "#eff0f1" },
116
+ { value: "text-neutral-300", label: "neutral-300", type: "tailwind", rawValue: "#dee0e3" },
117
+ { value: "text-neutral-400", label: "neutral-400", type: "tailwind", rawValue: "#d0d3d6" },
118
+ { value: "text-neutral-500", label: "neutral-500", type: "tailwind", rawValue: "#bbbfc4" },
119
+ { value: "text-neutral-600", label: "neutral-600", type: "tailwind", rawValue: "#8f959e" },
163
120
  {
164
121
  value: "text-neutral-650",
165
122
  label: "neutral-650",
166
123
  type: "tailwind",
167
124
  rawValue: "#51565d"
168
125
  },
169
- {
170
- value: "text-neutral-700",
171
- label: "neutral-700",
172
- type: "tailwind",
173
- rawValue: "#646a73"
174
- },
175
- {
176
- value: "text-neutral-800",
177
- label: "neutral-800",
178
- type: "tailwind",
179
- rawValue: "#373c43"
180
- },
181
- {
182
- value: "text-neutral-900",
183
- label: "neutral-900",
184
- type: "tailwind",
185
- rawValue: "#2b2f36"
186
- },
126
+ { value: "text-neutral-700", label: "neutral-700", type: "tailwind", rawValue: "#646a73" },
127
+ { value: "text-neutral-800", label: "neutral-800", type: "tailwind", rawValue: "#373c43" },
128
+ { value: "text-neutral-900", label: "neutral-900", type: "tailwind", rawValue: "#2b2f36" },
187
129
  {
188
130
  value: "text-neutral-950",
189
131
  label: "neutral-950",
@@ -212,72 +154,22 @@ const defaultUIConfig = {
212
154
  type: "tailwind",
213
155
  rawValue: "#ffffff"
214
156
  },
215
- {
216
- value: "bg-neutral-50",
217
- label: "neutral-50",
218
- type: "tailwind",
219
- rawValue: "#f5f6f7"
220
- },
221
- {
222
- value: "bg-neutral-100",
223
- label: "neutral-100",
224
- type: "tailwind",
225
- rawValue: "#f2f3f5"
226
- },
227
- {
228
- value: "bg-neutral-200",
229
- label: "neutral-200",
230
- type: "tailwind",
231
- rawValue: "#eff0f1"
232
- },
233
- {
234
- value: "bg-neutral-300",
235
- label: "neutral-300",
236
- type: "tailwind",
237
- rawValue: "#dee0e3"
238
- },
239
- {
240
- value: "bg-neutral-400",
241
- label: "neutral-400",
242
- type: "tailwind",
243
- rawValue: "#d0d3d6"
244
- },
245
- {
246
- value: "bg-neutral-500",
247
- label: "neutral-500",
248
- type: "tailwind",
249
- rawValue: "#bbbfc4"
250
- },
251
- {
252
- value: "bg-neutral-600",
253
- label: "neutral-600",
254
- type: "tailwind",
255
- rawValue: "#8f959e"
256
- },
157
+ { value: "bg-neutral-50", label: "neutral-50", type: "tailwind", rawValue: "#f5f6f7" },
158
+ { value: "bg-neutral-100", label: "neutral-100", type: "tailwind", rawValue: "#f2f3f5" },
159
+ { value: "bg-neutral-200", label: "neutral-200", type: "tailwind", rawValue: "#eff0f1" },
160
+ { value: "bg-neutral-300", label: "neutral-300", type: "tailwind", rawValue: "#dee0e3" },
161
+ { value: "bg-neutral-400", label: "neutral-400", type: "tailwind", rawValue: "#d0d3d6" },
162
+ { value: "bg-neutral-500", label: "neutral-500", type: "tailwind", rawValue: "#bbbfc4" },
163
+ { value: "bg-neutral-600", label: "neutral-600", type: "tailwind", rawValue: "#8f959e" },
257
164
  {
258
165
  value: "bg-neutral-650",
259
166
  label: "neutral-650",
260
167
  type: "tailwind",
261
168
  rawValue: "#51565d"
262
169
  },
263
- {
264
- value: "bg-neutral-700",
265
- label: "neutral-700",
266
- type: "tailwind",
267
- rawValue: "#646a73"
268
- },
269
- {
270
- value: "bg-neutral-800",
271
- label: "neutral-800",
272
- type: "tailwind",
273
- rawValue: "#373c43"
274
- },
275
- {
276
- value: "bg-neutral-900",
277
- label: "neutral-900",
278
- type: "tailwind",
279
- rawValue: "#2b2f36"
280
- },
170
+ { value: "bg-neutral-700", label: "neutral-700", type: "tailwind", rawValue: "#646a73" },
171
+ { value: "bg-neutral-800", label: "neutral-800", type: "tailwind", rawValue: "#373c43" },
172
+ { value: "bg-neutral-900", label: "neutral-900", type: "tailwind", rawValue: "#2b2f36" },
281
173
  {
282
174
  value: "bg-neutral-950",
283
175
  label: "neutral-950",
@@ -306,12 +198,7 @@ const defaultUIConfig = {
306
198
  type: "tailwind",
307
199
  rawValue: "#ffffff"
308
200
  },
309
- {
310
- value: "border-neutral-50",
311
- label: "neutral-50",
312
- type: "tailwind",
313
- rawValue: "#f5f6f7"
314
- },
201
+ { value: "border-neutral-50", label: "neutral-50", type: "tailwind", rawValue: "#f5f6f7" },
315
202
  {
316
203
  value: "border-neutral-100",
317
204
  label: "neutral-100",
@@ -560,6 +447,121 @@ const defaultUIConfig = {
560
447
  "cyan-800": "#0f587a",
561
448
  "cyan-900": "#06415c",
562
449
  "cyan-950": "#072b3d"
450
+ },
451
+ components: {
452
+ nativeTag: {
453
+ img: {
454
+ src: {
455
+ type: "image",
456
+ label: "\u56FE\u7247"
457
+ }
458
+ }
459
+ },
460
+ antd: {
461
+ Button: {
462
+ children: {
463
+ label: "\u6587\u6848",
464
+ type: "input"
465
+ },
466
+ icon: {
467
+ label: "\u56FE\u6807",
468
+ type: "icon-picker"
469
+ },
470
+ type: {
471
+ label: "\u7C7B\u578B",
472
+ type: "select",
473
+ options: [
474
+ {
475
+ value: "primary",
476
+ label: "\u4E3B\u8981\u6309\u94AE",
477
+ rawValue: "primary",
478
+ prefix: {
479
+ type: "tag",
480
+ value: "Button",
481
+ style: {
482
+ display: "inline-block",
483
+ backgroundColor: "#1456F0",
484
+ color: "#fff",
485
+ borderRadius: "5px",
486
+ padding: "2px 8px",
487
+ lineHeight: "20px"
488
+ }
489
+ }
490
+ },
491
+ {
492
+ value: "default",
493
+ label: "\u6B21\u8981\u6309\u94AE",
494
+ rawValue: "default",
495
+ prefix: {
496
+ type: "tag",
497
+ value: "Button",
498
+ style: {
499
+ display: "inline-block",
500
+ borderStyle: "solid",
501
+ borderColor: "#1456F0",
502
+ borderWidth: "1px",
503
+ color: "#1456F0",
504
+ borderRadius: "5px",
505
+ padding: "1px 7px",
506
+ lineHeight: "20px"
507
+ }
508
+ }
509
+ },
510
+ {
511
+ value: "text",
512
+ label: "\u6587\u5B57\u6309\u94AE",
513
+ rawValue: "text",
514
+ prefix: {
515
+ type: "tag",
516
+ value: "Button",
517
+ style: {
518
+ display: "inline-block",
519
+ color: "#1F2329",
520
+ padding: "2px 8px",
521
+ lineHeight: "20px"
522
+ }
523
+ }
524
+ },
525
+ {
526
+ value: "link",
527
+ label: "\u94FE\u63A5\u6309\u94AE",
528
+ rawValue: "link",
529
+ prefix: {
530
+ type: "tag",
531
+ value: "Button",
532
+ style: {
533
+ display: "inline-block",
534
+ color: "#1456F0",
535
+ padding: "2px 8px",
536
+ lineHeight: "20px"
537
+ }
538
+ }
539
+ }
540
+ ],
541
+ defaultValue: "default"
542
+ },
543
+ shape: {
544
+ label: "\u5F62\u72B6",
545
+ type: "radioGroup",
546
+ options: [
547
+ { value: "default", label: "\u77E9\u5F62", rawValue: "default" },
548
+ { value: "circle", label: "\u5706\u5F62", rawValue: "circle" },
549
+ { value: "round", label: "\u5706\u89D2", rawValue: "round" }
550
+ ],
551
+ defaultValue: "default"
552
+ },
553
+ size: {
554
+ label: "\u5C3A\u5BF8",
555
+ type: "radioGroup",
556
+ options: [
557
+ { value: "large", label: "\u5927", rawValue: "large" },
558
+ { value: "middle", label: "\u4E2D", rawValue: "middle" },
559
+ { value: "small", label: "\u5C0F", rawValue: "small" }
560
+ ],
561
+ defaultValue: "middle"
562
+ }
563
+ }
564
+ }
563
565
  }
564
566
  };
565
567
  export {
package/dist/es/index.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  import "./chunk-I4E63NIC.mjs";
2
2
  import { MiaodaInspector } from "./MiaodaInspector";
3
+ import { defaultUIConfig } from "./config/ui-config";
3
4
  import { isOutgoingMessage } from "./utils";
4
5
  export {
5
6
  MiaodaInspector,
7
+ defaultUIConfig,
6
8
  isOutgoingMessage
7
9
  };
File without changes
@@ -5,6 +5,7 @@ import {
5
5
  EditTextMessage,
6
6
  EditStyleMessage,
7
7
  EditClassNameMessage,
8
+ EditAttributesMessage,
8
9
  OutgoingMessage,
9
10
  PageMountedMessage,
10
11
  TextUpdateMessage,
@@ -12,11 +13,14 @@ import {
12
13
  IncomingMessage,
13
14
  InspectorInfo
14
15
  } from "./iframe-events";
16
+ import { Feature } from "./feature";
15
17
  export {
16
18
  ClearSelectedMessage,
19
+ EditAttributesMessage,
17
20
  EditClassNameMessage,
18
21
  EditStyleMessage,
19
22
  EditTextMessage,
23
+ Feature,
20
24
  IncomingMessage,
21
25
  InitConfigMessage,
22
26
  InspectorInfo,
@@ -51,9 +51,7 @@ function getStyleCalculationConfig(config, propertyName) {
51
51
  return getColorStyleCalculationConfig(config, propertyName);
52
52
  }
53
53
  if (uiComponent.type !== "select" && uiComponent.type !== "spacing") {
54
- throw new Error(
55
- `Unsupported UI component type: ${uiComponent.type} for property: ${propertyName}`
56
- );
54
+ throw new Error(`Unsupported UI component type: ${uiComponent.type} for property: ${propertyName}`);
57
55
  }
58
56
  const map = {};
59
57
  for (const option of uiComponent.options) {
@@ -0,0 +1,36 @@
1
+ import "../chunk-I4E63NIC.mjs";
2
+ function getCompiledComponentName(element, fallback) {
3
+ return element.getAttribute("data-miaoda-component-name") || fallback;
4
+ }
5
+ function getImportSource(element) {
6
+ return element.getAttribute("data-miaoda-import-source");
7
+ }
8
+ function hasNonEmptyText(element) {
9
+ return typeof element.textContent === "string" && element.textContent.trim().length > 0;
10
+ }
11
+ function isNativeElementName(componentName) {
12
+ return Boolean(componentName && componentName[0] !== componentName[0].toUpperCase());
13
+ }
14
+ function isAntdText(element, componentName) {
15
+ const importSource = getImportSource(element);
16
+ const compiledName = getCompiledComponentName(element, componentName);
17
+ if (importSource !== "antd" || !compiledName) {
18
+ return false;
19
+ }
20
+ const textualNames = /* @__PURE__ */ new Set([
21
+ "Typography.Text",
22
+ "Text",
23
+ "Typography.Title",
24
+ "Title",
25
+ "Typography.Paragraph",
26
+ "Paragraph"
27
+ ]);
28
+ return textualNames.has(compiledName);
29
+ }
30
+ export {
31
+ getCompiledComponentName,
32
+ getImportSource,
33
+ hasNonEmptyText,
34
+ isAntdText,
35
+ isNativeElementName
36
+ };
@@ -1,10 +1,5 @@
1
1
  import "../chunk-I4E63NIC.mjs";
2
- import {
3
- getPreviewParentOrigin,
4
- postMessage,
5
- isIncomingMessage,
6
- isOutgoingMessage
7
- } from "./origin";
2
+ import { getPreviewParentOrigin, postMessage, isIncomingMessage, isOutgoingMessage } from "./origin";
8
3
  import { cx } from "./css";
9
4
  import {
10
5
  calculateFontSizeInfo,
@@ -2,6 +2,7 @@ import {
2
2
  __spreadProps,
3
3
  __spreadValues
4
4
  } from "../chunk-I4E63NIC.mjs";
5
+ import { isAntdText, isNativeElementName } from "./element-guards";
5
6
  function rgbaToHex(rgba) {
6
7
  const match = rgba.match(/rgba?\(([^)]+)\)/);
7
8
  if (!match) return rgba;
@@ -24,7 +25,13 @@ function rgbaToHex(rgba) {
24
25
  return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
25
26
  }
26
27
  function isValidElement(element, componentName, canUseNewInspector) {
27
- return !!(element && componentName && componentName[0] !== componentName[0].toUpperCase() && canUseNewInspector && !(element instanceof SVGElement));
28
+ if (!element || !componentName || !canUseNewInspector || element instanceof SVGElement) {
29
+ return false;
30
+ }
31
+ if (isNativeElementName(componentName)) {
32
+ return true;
33
+ }
34
+ return isAntdText(element, componentName);
28
35
  }
29
36
  function isValidElementWithComponent(element, componentName, canUseNewInspector) {
30
37
  return !!(element && componentName && canUseNewInspector && !(element instanceof SVGElement));
@@ -86,48 +93,16 @@ function calculateStyle(styleName, element, componentName, canUseNewInspector, s
86
93
  return null;
87
94
  }
88
95
  const config = styleConfigs[styleName];
89
- const tailwindPattern = new RegExp(
90
- `\\b${config.tailwindPrefix}-(${Object.keys(config.map).join("|")})\\b`
91
- );
96
+ const tailwindPattern = new RegExp(`\\b${config.tailwindPrefix}-(${Object.keys(config.map).join("|")})\\b`);
92
97
  return calculateStyleProperty(element, __spreadProps(__spreadValues({}, config), {
93
98
  tailwindPattern
94
99
  }));
95
100
  }
96
- const calculateFontSizeInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
97
- "fontSize",
98
- element,
99
- componentName,
100
- canUseNewInspector,
101
- styleConfigs
102
- );
103
- const calculateFontWeightInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
104
- "fontWeight",
105
- element,
106
- componentName,
107
- canUseNewInspector,
108
- styleConfigs
109
- );
110
- const calculateBorderRadiusInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
111
- "borderRadius",
112
- element,
113
- componentName,
114
- canUseNewInspector,
115
- styleConfigs
116
- );
117
- const calculateBorderWidthInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
118
- "borderWidth",
119
- element,
120
- componentName,
121
- canUseNewInspector,
122
- styleConfigs
123
- );
124
- const calculateTextAlignInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
125
- "textAlign",
126
- element,
127
- componentName,
128
- canUseNewInspector,
129
- styleConfigs
130
- );
101
+ const calculateFontSizeInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle("fontSize", element, componentName, canUseNewInspector, styleConfigs);
102
+ const calculateFontWeightInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle("fontWeight", element, componentName, canUseNewInspector, styleConfigs);
103
+ const calculateBorderRadiusInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle("borderRadius", element, componentName, canUseNewInspector, styleConfigs);
104
+ const calculateBorderWidthInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle("borderWidth", element, componentName, canUseNewInspector, styleConfigs);
105
+ const calculateTextAlignInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle("textAlign", element, componentName, canUseNewInspector, styleConfigs);
131
106
  const calculatePaddingInfo = (element, componentName, canUseNewInspector, styleConfigs) => {
132
107
  if (!isValidElementWithComponent(element, componentName, canUseNewInspector)) {
133
108
  return null;
@@ -140,27 +115,9 @@ const calculateMarginInfo = (element, componentName, canUseNewInspector, styleCo
140
115
  }
141
116
  return calculateStyleProperty(element, styleConfigs.margin);
142
117
  };
143
- const calculateColorInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
144
- "color",
145
- element,
146
- componentName,
147
- canUseNewInspector,
148
- styleConfigs
149
- );
150
- const calculateBackgroundColorInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
151
- "backgroundColor",
152
- element,
153
- componentName,
154
- canUseNewInspector,
155
- styleConfigs
156
- );
157
- const calculateBorderColorInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
158
- "borderColor",
159
- element,
160
- componentName,
161
- canUseNewInspector,
162
- styleConfigs
163
- );
118
+ const calculateColorInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle("color", element, componentName, canUseNewInspector, styleConfigs);
119
+ const calculateBackgroundColorInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle("backgroundColor", element, componentName, canUseNewInspector, styleConfigs);
120
+ const calculateBorderColorInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle("borderColor", element, componentName, canUseNewInspector, styleConfigs);
164
121
  export {
165
122
  calculateBackgroundColorInfo,
166
123
  calculateBorderColorInfo,
@@ -39,26 +39,6 @@ var import_hotkeys_js = __toESM(require("hotkeys-js"));
39
39
  var import_hooks = require("./hooks");
40
40
  var import_Overlay = require("./Overlay");
41
41
  var import_utils = require("./utils");
42
- var import_fiber = require("./utils/fiber");
43
- const getParentElement = (element) => {
44
- let parent = element;
45
- while (parent && parent.tagName !== "HTML") {
46
- if (parent.dataset.miaodaComponentName) {
47
- return parent;
48
- }
49
- const fiber = (0, import_fiber.getElementFiberUpward)(parent);
50
- const parentFiber = parent.parentElement ? (0, import_fiber.getElementFiberUpward)(parent.parentElement) : void 0;
51
- const referenceFiber = (0, import_utils.getReferenceFiber)(fiber);
52
- const parentReferenceFiber = parentFiber ? (0, import_utils.getReferenceFiber)(parentFiber) : null;
53
- const currentName = referenceFiber == null ? void 0 : referenceFiber.pendingProps["data-miaoda-component-name"];
54
- const parentName = parentReferenceFiber ? parentReferenceFiber.pendingProps["data-miaoda-component-name"] : null;
55
- if (currentName && currentName !== parentName) {
56
- return parent;
57
- }
58
- parent = parent.parentElement;
59
- }
60
- return;
61
- };
62
42
  const defaultHotkeys = () => {
63
43
  var _a;
64
44
  return ((_a = navigator.platform) == null ? void 0 : _a.startsWith("Mac")) ? ["Ctrl", "Shift", "Command", "C"] : ["Ctrl", "Shift", "Alt", "C"];
@@ -99,7 +79,7 @@ const Inspector = (props) => {
99
79
  const handleHoverElement = (0, import_hooks.useEffectEvent)((element) => {
100
80
  var _a;
101
81
  const overlay = overlayRef.current;
102
- const targetElement = getParentElement(element);
82
+ const targetElement = (0, import_utils.getParentElement)(element);
103
83
  if (!targetElement) {
104
84
  return;
105
85
  }
@@ -116,7 +96,7 @@ const Inspector = (props) => {
116
96
  });
117
97
  });
118
98
  const handleClickElement = (0, import_hooks.useEffectEvent)((element) => {
119
- const targetElement = getParentElement(element);
99
+ const targetElement = (0, import_utils.getParentElement)(element);
120
100
  if (!targetElement) {
121
101
  return;
122
102
  }
@@ -127,7 +107,8 @@ const Inspector = (props) => {
127
107
  fiber,
128
108
  codeInfo,
129
109
  name,
130
- title
110
+ title,
111
+ componentProps: (0, import_utils.extractPropsFromFiber)(fiber)
131
112
  });
132
113
  if (fiber && codeInfo) {
133
114
  onInspectElement == null ? void 0 : onInspectElement({