reburn-ui 0.4.5 → 0.4.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.
@@ -40,14 +40,6 @@
40
40
  let chartRect = $state<DOMRect>();
41
41
  let dots = $state<{ top: number; left: number; color: string }[]>([]);
42
42
 
43
- function calcLeft(x: number, rect: DOMRect) {
44
- return x + rect.left;
45
- }
46
-
47
- function calcTop(y: number, rect: DOMRect) {
48
- return y;
49
- }
50
-
51
43
  // TODO: refactor this
52
44
  function handleMouseMove(event: PointerEvent & { currentTarget: EventTarget & SVGSVGElement }) {
53
45
  const { tooltip, rect } = getTooltipPosition(event);
@@ -67,8 +59,8 @@
67
59
  element = nearestElement;
68
60
 
69
61
  tooltipLine = {
70
- top: calcTop(0, rect),
71
- left: calcLeft(actualX, rect),
62
+ top: 0,
63
+ left: actualX,
72
64
  height: rect.height,
73
65
  };
74
66
 
@@ -77,8 +69,8 @@
77
69
  const left = ctx.xScale(ctx.xAccessor(nearestElement));
78
70
 
79
71
  return {
80
- top: calcTop(top, rect),
81
- left: calcLeft(left, rect),
72
+ top: top,
73
+ left: left,
82
74
  color: getThemeColor(series.color),
83
75
  };
84
76
  });
@@ -141,51 +133,59 @@
141
133
  }
142
134
  </script>
143
135
 
144
- {#if show && chartRect}
145
- <div class="root" bind:this={tooltipRef} style:top="{tooltipY}px" style:left="{tooltipX}px">
146
- {#if children && element}
147
- {@render children(element)}
148
- {:else if element}
149
- <Paper withBorder shadow="md">
150
- <div class="label">{ctx.xFormatLabel(ctx.xAccessor(element as T))}</div>
151
-
152
- <div class="body">
153
- {#each ctx.series as series (series.name)}
154
- <div class="item">
155
- <div class="item-body">
156
- {#if showColor}
157
- <div class="item-color">
158
- <svg>
159
- <circle r={6} fill={getThemeColor(series.color)} width={12} height={12} cx={6} cy={6} />
160
- </svg>
161
- </div>
162
- {/if}
163
-
164
- <div class="item-name">{series.name}</div>
136
+ <div class="container">
137
+ {#if show && chartRect}
138
+ <div class="tooltip" bind:this={tooltipRef} style:top="{tooltipY}px" style:left="{tooltipX}px">
139
+ {#if children && element}
140
+ {@render children(element)}
141
+ {:else if element}
142
+ <Paper withBorder shadow="md">
143
+ <div class="label">{ctx.xFormatLabel(ctx.xAccessor(element as T))}</div>
144
+
145
+ <div class="body">
146
+ {#each ctx.series as series (series.name)}
147
+ <div class="item">
148
+ <div class="item-body">
149
+ {#if showColor}
150
+ <div class="item-color">
151
+ <svg>
152
+ <circle r={6} fill={getThemeColor(series.color)} width={12} height={12} cx={6} cy={6} />
153
+ </svg>
154
+ </div>
155
+ {/if}
156
+
157
+ <div class="item-name">{series.name}</div>
158
+ </div>
159
+
160
+ <ChartTooltipData {series} {element} />
165
161
  </div>
162
+ {/each}
163
+ </div>
164
+ </Paper>
165
+ {/if}
166
+ </div>
167
+
168
+ <div
169
+ class="line"
170
+ style:top="{tooltipLine.top}px"
171
+ style:left="{tooltipLine.left}px"
172
+ style:height="{tooltipLine.height}px"
173
+ bind:this={tooltipLineRef}
174
+ ></div>
175
+
176
+ {#each dots as dot}
177
+ <div class="dot" style:top="{dot.top}px" style:left="{dot.left}px" style:background-color={dot.color}></div>
178
+ {/each}
179
+ {/if}
180
+ </div>
181
+
182
+ <style>.container {
183
+ grid-area: chart;
184
+ pointer-events: none;
185
+ position: relative;
186
+ }
166
187
 
167
- <ChartTooltipData {series} {element} />
168
- </div>
169
- {/each}
170
- </div>
171
- </Paper>
172
- {/if}
173
- </div>
174
-
175
- <div
176
- class="line"
177
- style:top="{tooltipLine.top}px"
178
- style:left="{tooltipLine.left}px"
179
- style:height="{tooltipLine.height}px"
180
- bind:this={tooltipLineRef}
181
- ></div>
182
-
183
- {#each dots as dot}
184
- <div class="dot" style:top="{dot.top}px" style:left="{dot.left}px" style:background-color={dot.color}></div>
185
- {/each}
186
- {/if}
187
-
188
- <style>.root {
188
+ .tooltip {
189
189
  position: absolute;
190
190
  z-index: 10;
191
191
  }
@@ -1,6 +1,7 @@
1
1
  export function getTooltipPosition(event) {
2
2
  const rect = event.currentTarget.getBoundingClientRect();
3
3
  const x = event.clientX - rect.left;
4
- return { tooltip: { x: x, y: rect.top }, rect };
4
+ const y = event.clientY - rect.top;
5
+ return { tooltip: { x: x, y: y }, rect };
5
6
  }
6
7
  // if needed: {mouse: {x: event.clientX, y: event.clientY}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reburn-ui",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -9,10 +9,9 @@
9
9
  "build": "vite build",
10
10
  "preview": "vite preview",
11
11
  "prepare": "svelte-kit sync || echo ''",
12
- "prepack": "bun vite build && bun svelte-kit sync && PREPACK=true bun svelte-package && bun publint",
12
+ "prepack": "bun vite build && bun svelte-kit sync && bun svelte-package && bun publint",
13
13
  "transform-css-files": "bun run scripts/transform-css-files.ts",
14
- "lint": "eslint .",
15
- "postinstall": "bun run transform-css-files"
14
+ "lint": "eslint ."
16
15
  },
17
16
  "files": [
18
17
  "dist",