layerchart 2.0.0-next.38 → 2.0.0-next.39
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.
- package/dist/components/AnnotationLine.svelte +15 -2
- package/dist/components/AnnotationPoint.svelte +13 -2
- package/dist/components/AnnotationRange.svelte +16 -2
- package/dist/components/Arc.svelte +3 -3
- package/dist/components/Area.svelte +10 -2
- package/dist/components/Axis.svelte +43 -26
- package/dist/components/Bar.svelte +6 -5
- package/dist/components/Bar.svelte.d.ts +2 -2
- package/dist/components/Bars.svelte +3 -3
- package/dist/components/Blur.svelte +2 -3
- package/dist/components/BrushContext.svelte +44 -44
- package/dist/components/Calendar.svelte +21 -4
- package/dist/components/Chart.svelte +1 -2
- package/dist/components/ChartClipPath.svelte +1 -1
- package/dist/components/Circle.svelte +44 -3
- package/dist/components/CircleClipPath.svelte +8 -1
- package/dist/components/ClipPath.svelte +1 -2
- package/dist/components/ColorRamp.svelte +1 -1
- package/dist/components/ComputedStyles.svelte +9 -2
- package/dist/components/Connector.svelte +1 -1
- package/dist/components/Ellipse.svelte +44 -3
- package/dist/components/Frame.svelte +1 -1
- package/dist/components/GeoCircle.svelte +1 -1
- package/dist/components/GeoEdgeFade.svelte +1 -1
- package/dist/components/GeoPath.svelte +18 -3
- package/dist/components/GeoPoint.svelte +3 -3
- package/dist/components/GeoSpline.svelte +1 -1
- package/dist/components/GeoTile.svelte +1 -1
- package/dist/components/Graticule.svelte +5 -5
- package/dist/components/Grid.svelte +57 -60
- package/dist/components/Group.svelte +11 -6
- package/dist/components/Highlight.svelte +46 -22
- package/dist/components/Highlight.svelte.d.ts +4 -0
- package/dist/components/Hull.svelte +11 -4
- package/dist/components/Labels.svelte +21 -11
- package/dist/components/Legend.svelte +133 -67
- package/dist/components/Legend.svelte.d.ts +7 -3
- package/dist/components/Line.svelte +40 -3
- package/dist/components/LinearGradient.svelte +35 -4
- package/dist/components/Link.svelte +1 -1
- package/dist/components/Marker.svelte +37 -26
- package/dist/components/MonthPath.svelte +14 -3
- package/dist/components/MotionPath.svelte +1 -1
- package/dist/components/Pattern.svelte +5 -5
- package/dist/components/Pie.svelte +1 -2
- package/dist/components/Points.svelte +1 -1
- package/dist/components/Polygon.svelte +27 -3
- package/dist/components/RadialGradient.svelte +3 -3
- package/dist/components/Rect.svelte +55 -5
- package/dist/components/Rect.svelte.d.ts +2 -2
- package/dist/components/RectClipPath.svelte +4 -3
- package/dist/components/RectClipPath.svelte.d.ts +2 -2
- package/dist/components/Rule.svelte +30 -23
- package/dist/components/Spline.svelte +29 -10
- package/dist/components/Text.svelte +59 -13
- package/dist/components/TileImage.svelte +19 -4
- package/dist/components/TransformContext.svelte +9 -3
- package/dist/components/TransformControls.svelte +72 -17
- package/dist/components/Voronoi.svelte +12 -13
- package/dist/components/charts/ArcChart.svelte +40 -69
- package/dist/components/charts/AreaChart.svelte +19 -42
- package/dist/components/charts/BarChart.svelte +7 -18
- package/dist/components/charts/DefaultTooltip.svelte +2 -2
- package/dist/components/charts/DefaultTooltip.svelte.d.ts +1 -1
- package/dist/components/charts/LineChart.svelte +61 -66
- package/dist/components/charts/LineChart.svelte.d.ts +11 -5
- package/dist/components/charts/PieChart.svelte +41 -69
- package/dist/components/charts/ScatterChart.svelte +8 -19
- package/dist/components/charts/utils.svelte.d.ts +1 -19
- package/dist/components/charts/utils.svelte.js +7 -39
- package/dist/components/layout/Canvas.svelte +29 -20
- package/dist/components/layout/Html.svelte +15 -9
- package/dist/components/layout/Svg.svelte +19 -11
- package/dist/components/layout/WebGL.svelte +26 -6
- package/dist/components/layout/WebGL.svelte.d.ts +5 -2
- package/dist/components/tooltip/Tooltip.svelte +60 -29
- package/dist/components/tooltip/TooltipContext.svelte +73 -36
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +7 -0
- package/dist/components/tooltip/TooltipHeader.svelte +27 -14
- package/dist/components/tooltip/TooltipItem.svelte +41 -33
- package/dist/components/tooltip/TooltipList.svelte +12 -10
- package/dist/components/tooltip/TooltipSeparator.svelte +18 -10
- package/dist/states/series.svelte.d.ts +30 -0
- package/dist/states/series.svelte.js +54 -0
- package/dist/styles/daisyui-5.css +6 -0
- package/dist/styles/shadcn-svelte.css +11 -0
- package/dist/styles/skeleton-3.css +15 -0
- package/dist/utils/attributes.d.ts +3 -13
- package/dist/utils/attributes.js +4 -18
- package/dist/utils/common.d.ts +9 -0
- package/dist/utils/common.js +18 -1
- package/dist/utils/common.test.js +26 -1
- package/dist/utils/math.d.ts +17 -0
- package/dist/utils/math.js +17 -0
- package/dist/utils/types.d.ts +15 -2
- package/package.json +5 -1
|
@@ -30,10 +30,9 @@
|
|
|
30
30
|
</script>
|
|
31
31
|
|
|
32
32
|
<script lang="ts">
|
|
33
|
-
import { timeWeek,
|
|
33
|
+
import { timeWeek, timeYear } from 'd3-time';
|
|
34
34
|
import { cls } from '@layerstack/tailwind';
|
|
35
35
|
import { endOfInterval } from '@layerstack/utils';
|
|
36
|
-
import { layerClass } from '../utils/attributes.js';
|
|
37
36
|
import Spline, { type SplinePropsWithoutHTML } from './Spline.svelte';
|
|
38
37
|
|
|
39
38
|
let {
|
|
@@ -75,6 +74,18 @@
|
|
|
75
74
|
bind:pathRef
|
|
76
75
|
{pathData}
|
|
77
76
|
fill="none"
|
|
78
|
-
class={cls(
|
|
77
|
+
class={cls('lc-month-path', className)}
|
|
79
78
|
{...restProps}
|
|
80
79
|
/>
|
|
80
|
+
|
|
81
|
+
<style>
|
|
82
|
+
@layer components {
|
|
83
|
+
:global(:where(.lc-month-path)) {
|
|
84
|
+
--stroke-color: color-mix(
|
|
85
|
+
in oklab,
|
|
86
|
+
var(--color-surface-content, currentColor) 20%,
|
|
87
|
+
transparent
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
</style>
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
const lineDefs = Array.isArray(linesProp) ? linesProp : linesProp === true ? [{}] : [linesProp];
|
|
155
155
|
for (const line of lineDefs) {
|
|
156
156
|
// const spacing = Math.abs(line.spacing);
|
|
157
|
-
const stroke = line.color ?? 'var(--color-surface-content)';
|
|
157
|
+
const stroke = line.color ?? 'var(--color-surface-content, currentColor)';
|
|
158
158
|
const strokeWidth = line.width ?? 1;
|
|
159
159
|
const opacity = line.opacity ?? 1;
|
|
160
160
|
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
cx: size / 4,
|
|
218
218
|
cy: size / 4,
|
|
219
219
|
r: circle.radius ?? 1,
|
|
220
|
-
fill: circle.color ?? 'var(--color-surface-content)',
|
|
220
|
+
fill: circle.color ?? 'var(--color-surface-content, currentColor)',
|
|
221
221
|
opacity: circle.opacity ?? 1,
|
|
222
222
|
},
|
|
223
223
|
{
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
cx: (size * 3) / 4,
|
|
226
226
|
cy: (size * 3) / 4,
|
|
227
227
|
r: circle.radius ?? 1,
|
|
228
|
-
fill: circle.color ?? 'var(--color-surface-content)',
|
|
228
|
+
fill: circle.color ?? 'var(--color-surface-content, currentColor)',
|
|
229
229
|
opacity: circle.opacity ?? 1,
|
|
230
230
|
}
|
|
231
231
|
);
|
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
cx: size / 2,
|
|
236
236
|
cy: size / 2,
|
|
237
237
|
r: circle.radius ?? 1,
|
|
238
|
-
fill: circle.color ?? 'var(--color-surface-content)',
|
|
238
|
+
fill: circle.color ?? 'var(--color-surface-content, currentColor)',
|
|
239
239
|
opacity: circle.opacity ?? 1,
|
|
240
240
|
});
|
|
241
241
|
}
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
{width}
|
|
266
266
|
{height}
|
|
267
267
|
patternUnits="userSpaceOnUse"
|
|
268
|
-
{...extractLayerProps(restProps, 'pattern')}
|
|
268
|
+
{...extractLayerProps(restProps, 'lc-pattern')}
|
|
269
269
|
>
|
|
270
270
|
{#if patternContent}
|
|
271
271
|
{@render patternContent?.()}
|
|
@@ -81,7 +81,6 @@
|
|
|
81
81
|
import type { TooltipContextValue } from './tooltip/TooltipContext.svelte';
|
|
82
82
|
import { getChartContext } from './Chart.svelte';
|
|
83
83
|
import type { Snippet } from 'svelte';
|
|
84
|
-
import { layerClass } from '../utils/attributes.js';
|
|
85
84
|
|
|
86
85
|
/*
|
|
87
86
|
TODO:
|
|
@@ -140,7 +139,7 @@
|
|
|
140
139
|
{:else}
|
|
141
140
|
{#each arcs as arc}
|
|
142
141
|
<Arc
|
|
143
|
-
class=
|
|
142
|
+
class="lc-pie-arc"
|
|
144
143
|
startAngle={arc.startAngle}
|
|
145
144
|
endAngle={arc.endAngle}
|
|
146
145
|
padAngle={arc.padAngle}
|
|
@@ -144,7 +144,6 @@
|
|
|
144
144
|
import { registerCanvasComponent } from './layout/Canvas.svelte';
|
|
145
145
|
import { renderPathData, type ComputedStylesOptions } from '../utils/canvas.js';
|
|
146
146
|
import { createKey } from '../utils/key.svelte.js';
|
|
147
|
-
import { layerClass } from '../utils/attributes.js';
|
|
148
147
|
import { polygon } from '../utils/shape.js';
|
|
149
148
|
import { roundedPolygonPath } from '../utils/path.js';
|
|
150
149
|
|
|
@@ -234,7 +233,7 @@
|
|
|
234
233
|
? merge({ styles: { strokeWidth } }, styleOverrides)
|
|
235
234
|
: {
|
|
236
235
|
styles: { fill, fillOpacity, stroke, strokeWidth, opacity },
|
|
237
|
-
classes: cls(
|
|
236
|
+
classes: cls('lc-polygon', className),
|
|
238
237
|
}
|
|
239
238
|
);
|
|
240
239
|
}
|
|
@@ -278,8 +277,33 @@
|
|
|
278
277
|
{stroke}
|
|
279
278
|
stroke-width={strokeWidth}
|
|
280
279
|
{opacity}
|
|
281
|
-
class={cls(
|
|
280
|
+
class={cls('lc-polygon', className)}
|
|
282
281
|
{...restProps}
|
|
283
282
|
bind:this={ref}
|
|
284
283
|
/>
|
|
285
284
|
{/if}
|
|
285
|
+
|
|
286
|
+
<style>
|
|
287
|
+
@layer base {
|
|
288
|
+
:global(:where(.lc-polygon)) {
|
|
289
|
+
--fill-color: var(--color-surface-content, currentColor);
|
|
290
|
+
--stroke-color: initial;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/* Svg | Canvas layers */
|
|
294
|
+
:global(:where(.lc-layout-svg .lc-polygon, svg.lc-polygon):not([fill])) {
|
|
295
|
+
fill: var(--fill-color);
|
|
296
|
+
}
|
|
297
|
+
:global(:where(.lc-layout-svg .lc-polygon, svg.lc-polygon):not([stroke])) {
|
|
298
|
+
stroke: var(--stroke-color);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* Html layers */
|
|
302
|
+
:global(:where(.lc-layout-html .lc-polygon):not([background-color])) {
|
|
303
|
+
background-color: var(--fill-color);
|
|
304
|
+
}
|
|
305
|
+
:global(:where(.lc-layout-html .lc-polygon):not([border-color])) {
|
|
306
|
+
border-color: var(--stroke-color);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
</style>
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
import { parsePercent } from '../utils/math.js';
|
|
90
90
|
import { getChartContext } from './Chart.svelte';
|
|
91
91
|
import { createId } from '../utils/createId.js';
|
|
92
|
-
import { extractLayerProps
|
|
92
|
+
import { extractLayerProps } from '../utils/attributes.js';
|
|
93
93
|
import { cls } from '@layerstack/tailwind';
|
|
94
94
|
|
|
95
95
|
const uid = $props.id();
|
|
@@ -167,12 +167,12 @@
|
|
|
167
167
|
{spreadMethod}
|
|
168
168
|
gradientTransform={transform}
|
|
169
169
|
gradientUnits={units}
|
|
170
|
-
{...extractLayerProps({ ...restProps, class: className }, 'radial-gradient')}
|
|
170
|
+
{...extractLayerProps({ ...restProps, class: className }, 'lc-radial-gradient')}
|
|
171
171
|
>
|
|
172
172
|
{#if stopsContent}
|
|
173
173
|
{@render stopsContent()}
|
|
174
174
|
{:else if stops}
|
|
175
|
-
{@const stopClass = cls(
|
|
175
|
+
{@const stopClass = cls('lc-radial-gradient-stop', className)}
|
|
176
176
|
{#each stops as stop, i}
|
|
177
177
|
{#if Array.isArray(stop)}
|
|
178
178
|
<stop offset={stop[0]} stop-color={stop[1]} class={stopClass} />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { CommonStyleProps, Without } from '../utils/types.js';
|
|
2
|
+
import type { CommonEvents, CommonStyleProps, Without } from '../utils/types.js';
|
|
3
3
|
import type { SVGAttributes } from 'svelte/elements';
|
|
4
4
|
import { createMotion, parseMotionProp, type MotionProp } from '../utils/motion.svelte.js';
|
|
5
5
|
import { renderRect, type ComputedStylesOptions } from '../utils/canvas.js';
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
} & CommonStyleProps;
|
|
40
40
|
|
|
41
41
|
export type RectProps = RectPropsWithoutHTML &
|
|
42
|
-
Without<SVGAttributes<SVGRectElement>, RectPropsWithoutHTML
|
|
42
|
+
Without<SVGAttributes<SVGRectElement>, RectPropsWithoutHTML> &
|
|
43
|
+
CommonEvents;
|
|
43
44
|
</script>
|
|
44
45
|
|
|
45
46
|
<script lang="ts">
|
|
@@ -49,7 +50,6 @@
|
|
|
49
50
|
import { getRenderContext } from './Chart.svelte';
|
|
50
51
|
import { registerCanvasComponent } from './layout/Canvas.svelte';
|
|
51
52
|
import { createKey } from '../utils/key.svelte.js';
|
|
52
|
-
import { layerClass } from '../utils/attributes.js';
|
|
53
53
|
|
|
54
54
|
let {
|
|
55
55
|
height,
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
? merge({ styles: { strokeWidth } }, styleOverrides)
|
|
108
108
|
: {
|
|
109
109
|
styles: { fill, fillOpacity, stroke, strokeWidth, opacity },
|
|
110
|
-
classes: className,
|
|
110
|
+
classes: cls('lc-rect', className),
|
|
111
111
|
}
|
|
112
112
|
);
|
|
113
113
|
}
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
{stroke}
|
|
156
156
|
stroke-width={strokeWidth}
|
|
157
157
|
{opacity}
|
|
158
|
-
class={cls(
|
|
158
|
+
class={cls('lc-rect', className)}
|
|
159
159
|
{...restProps}
|
|
160
160
|
{onclick}
|
|
161
161
|
{ondblclick}
|
|
@@ -166,4 +166,54 @@
|
|
|
166
166
|
{onpointerout}
|
|
167
167
|
bind:this={ref}
|
|
168
168
|
/>
|
|
169
|
+
{:else if renderCtx === 'html'}
|
|
170
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
171
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
172
|
+
<div
|
|
173
|
+
style:position="absolute"
|
|
174
|
+
style:left="{motionX.current}px"
|
|
175
|
+
style:top="{motionY.current}px"
|
|
176
|
+
style:width="{motionWidth.current}px"
|
|
177
|
+
style:height="{motionHeight.current}px"
|
|
178
|
+
style:background={fill}
|
|
179
|
+
style:background-opacity={opacity}
|
|
180
|
+
style:border-width="{strokeWidth}px"
|
|
181
|
+
style:border-style="solid"
|
|
182
|
+
style:border-color={stroke}
|
|
183
|
+
style:border-radius="{restProps.rx}px"
|
|
184
|
+
class={cls('lc-rect', className)}
|
|
185
|
+
{...restProps as any}
|
|
186
|
+
{onclick}
|
|
187
|
+
{ondblclick}
|
|
188
|
+
{onpointerenter}
|
|
189
|
+
{onpointermove}
|
|
190
|
+
{onpointerleave}
|
|
191
|
+
{onpointerover}
|
|
192
|
+
{onpointerout}
|
|
193
|
+
></div>
|
|
169
194
|
{/if}
|
|
195
|
+
|
|
196
|
+
<style>
|
|
197
|
+
@layer base {
|
|
198
|
+
:global(:where(.lc-rect)) {
|
|
199
|
+
--fill-color: var(--color-surface-content, currentColor);
|
|
200
|
+
--stroke-color: initial;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* Svg | Canvas layers */
|
|
204
|
+
:global(:where(.lc-layout-svg .lc-rect, svg.lc-rect):not([fill])) {
|
|
205
|
+
fill: var(--fill-color);
|
|
206
|
+
}
|
|
207
|
+
:global(:where(.lc-layout-svg .lc-rect, svg.lc-rect):not([stroke])) {
|
|
208
|
+
stroke: var(--stroke-color);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* Html layers */
|
|
212
|
+
:global(:where(.lc-layout-html .lc-rect):not([background])) {
|
|
213
|
+
background: var(--fill-color);
|
|
214
|
+
}
|
|
215
|
+
:global(:where(.lc-layout-html .lc-rect):not([border-color])) {
|
|
216
|
+
border-color: var(--stroke-color);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommonStyleProps, Without } from '../utils/types.js';
|
|
1
|
+
import type { CommonEvents, CommonStyleProps, Without } from '../utils/types.js';
|
|
2
2
|
import type { SVGAttributes } from 'svelte/elements';
|
|
3
3
|
import { type MotionProp } from '../utils/motion.svelte.js';
|
|
4
4
|
export type RectPropsWithoutHTML = {
|
|
@@ -30,7 +30,7 @@ export type RectPropsWithoutHTML = {
|
|
|
30
30
|
ref?: SVGRectElement;
|
|
31
31
|
motion?: MotionProp<'x' | 'y' | 'width' | 'height'>;
|
|
32
32
|
} & CommonStyleProps;
|
|
33
|
-
export type RectProps = RectPropsWithoutHTML & Without<SVGAttributes<SVGRectElement>, RectPropsWithoutHTML
|
|
33
|
+
export type RectProps = RectPropsWithoutHTML & Without<SVGAttributes<SVGRectElement>, RectPropsWithoutHTML> & CommonEvents;
|
|
34
34
|
declare const Rect: import("svelte").Component<RectProps, {}, "ref">;
|
|
35
35
|
type Rect = ReturnType<typeof Rect>;
|
|
36
36
|
export default Rect;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import Rect, { type RectPropsWithoutHTML } from './Rect.svelte';
|
|
3
|
-
import type { Without } from '../utils/types.js';
|
|
3
|
+
import type { CommonEvents, Without } from '../utils/types.js';
|
|
4
4
|
import type { SVGAttributes } from 'svelte/elements';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
6
6
|
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
Without<RectPropsWithoutHTML, BaseRectClipPathPropsWithoutHTML>;
|
|
59
59
|
|
|
60
60
|
export type RectClipPathProps = RectClipPathPropsWithoutHTML &
|
|
61
|
-
Without<SVGAttributes<SVGElement>, RectClipPathPropsWithoutHTML
|
|
61
|
+
Without<SVGAttributes<SVGElement>, RectClipPathPropsWithoutHTML> &
|
|
62
|
+
CommonEvents;
|
|
62
63
|
</script>
|
|
63
64
|
|
|
64
65
|
<script lang="ts">
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
|
|
82
83
|
<ClipPath {id} {disabled}>
|
|
83
84
|
{#snippet clip()}
|
|
84
|
-
<Rect {x} {y} {...extractLayerProps(restProps, 'clip-path-rect')} />
|
|
85
|
+
<Rect {x} {y} {...extractLayerProps(restProps, 'lc-clip-path-rect')} />
|
|
85
86
|
{/snippet}
|
|
86
87
|
{#snippet children({ url })}
|
|
87
88
|
{@render childrenProp?.({ id, url })}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RectPropsWithoutHTML } from './Rect.svelte';
|
|
2
|
-
import type { Without } from '../utils/types.js';
|
|
2
|
+
import type { CommonEvents, Without } from '../utils/types.js';
|
|
3
3
|
import type { SVGAttributes } from 'svelte/elements';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
export type BaseRectClipPathPropsWithoutHTML = {
|
|
@@ -48,7 +48,7 @@ export type BaseRectClipPathPropsWithoutHTML = {
|
|
|
48
48
|
motion?: MotionProp<'x' | 'y' | 'width' | 'height'>;
|
|
49
49
|
};
|
|
50
50
|
export type RectClipPathPropsWithoutHTML = BaseRectClipPathPropsWithoutHTML & Without<RectPropsWithoutHTML, BaseRectClipPathPropsWithoutHTML>;
|
|
51
|
-
export type RectClipPathProps = RectClipPathPropsWithoutHTML & Without<SVGAttributes<SVGElement>, RectClipPathPropsWithoutHTML
|
|
51
|
+
export type RectClipPathProps = RectClipPathPropsWithoutHTML & Without<SVGAttributes<SVGElement>, RectClipPathPropsWithoutHTML> & CommonEvents;
|
|
52
52
|
import type { MotionProp } from '../utils/motion.svelte.js';
|
|
53
53
|
declare const RectClipPath: import("svelte").Component<RectClipPathProps, {}, "">;
|
|
54
54
|
type RectClipPath = ReturnType<typeof RectClipPath>;
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
import Line, { type LinePropsWithoutHTML } from './Line.svelte';
|
|
62
62
|
import { getChartContext } from './Chart.svelte';
|
|
63
63
|
import { accessor, chartDataArray, type Accessor } from '../utils/common.js';
|
|
64
|
-
import { layerClass } from '../utils/attributes.js';
|
|
65
64
|
import { isScaleBand, isScaleNumeric } from '../utils/scales.svelte.js';
|
|
66
65
|
|
|
67
66
|
let {
|
|
@@ -188,9 +187,9 @@
|
|
|
188
187
|
// $inspect({ lines });
|
|
189
188
|
</script>
|
|
190
189
|
|
|
191
|
-
<Group class=
|
|
190
|
+
<Group class="lc-rule-g">
|
|
192
191
|
{#each lines as line}
|
|
193
|
-
{@const stroke = line.stroke}
|
|
192
|
+
{@const stroke = line.stroke ?? strokeProp}
|
|
194
193
|
|
|
195
194
|
{#if ctx.radial}
|
|
196
195
|
{#if line.axis === 'x'}
|
|
@@ -203,23 +202,10 @@
|
|
|
203
202
|
{x2}
|
|
204
203
|
{y2}
|
|
205
204
|
{stroke}
|
|
206
|
-
class={cls(
|
|
207
|
-
layerClass('rule-x-radial-line'),
|
|
208
|
-
!stroke && 'stroke-surface-content/10',
|
|
209
|
-
className
|
|
210
|
-
)}
|
|
205
|
+
class={cls('lc-rule-x-radial-line', className)}
|
|
211
206
|
/>
|
|
212
207
|
{:else if line.axis === 'y'}
|
|
213
|
-
<Circle
|
|
214
|
-
r={line.y1}
|
|
215
|
-
{stroke}
|
|
216
|
-
class={cls(
|
|
217
|
-
layerClass('rule-y-radial-circle'),
|
|
218
|
-
!stroke && 'stroke-surface-content/50',
|
|
219
|
-
'fill-none',
|
|
220
|
-
className
|
|
221
|
-
)}
|
|
222
|
-
/>
|
|
208
|
+
<Circle r={line.y1} {stroke} class={cls('lc-rule-y-radial-circle', className)} />
|
|
223
209
|
{/if}
|
|
224
210
|
{:else}
|
|
225
211
|
<Line
|
|
@@ -229,12 +215,33 @@
|
|
|
229
215
|
x2={line.x2}
|
|
230
216
|
y2={line.y2}
|
|
231
217
|
{stroke}
|
|
232
|
-
class={cls(
|
|
233
|
-
layerClass(line.axis === 'x' ? 'rule-x-line' : 'rule-y-line'),
|
|
234
|
-
!stroke && 'stroke-surface-content/50',
|
|
235
|
-
className
|
|
236
|
-
)}
|
|
218
|
+
class={cls(line.axis === 'x' ? 'lc-rule-x-line' : 'lc-rule-y-line', className)}
|
|
237
219
|
/>
|
|
238
220
|
{/if}
|
|
239
221
|
{/each}
|
|
240
222
|
</Group>
|
|
223
|
+
|
|
224
|
+
<style>
|
|
225
|
+
@layer components {
|
|
226
|
+
/* TODO: better way to handle this without affecting other components? */
|
|
227
|
+
/* Could add a layer between "components" and "base" but would require more setup (and not alignw with TW layers) */
|
|
228
|
+
:global(
|
|
229
|
+
:where(
|
|
230
|
+
.lc-rule-x-line,
|
|
231
|
+
.lc-rule-y-line,
|
|
232
|
+
.lc-rule-x-radial-line,
|
|
233
|
+
.lc-rule-y-radial-circle
|
|
234
|
+
):not([class*='lc-axis'], [class*='lc-grid'])
|
|
235
|
+
) {
|
|
236
|
+
--stroke-color: color-mix(
|
|
237
|
+
in oklab,
|
|
238
|
+
var(--color-surface-content, currentColor) 50%,
|
|
239
|
+
transparent
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
:global(:where(.lc-rule-y-radial-circle)) {
|
|
244
|
+
--fill-color: none;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
</style>
|
|
@@ -132,7 +132,6 @@
|
|
|
132
132
|
import { getChartContext } from './Chart.svelte';
|
|
133
133
|
import { createKey } from '../utils/key.svelte.js';
|
|
134
134
|
import { createId } from '../utils/createId.js';
|
|
135
|
-
import { layerClass } from '../utils/attributes.js';
|
|
136
135
|
|
|
137
136
|
const ctx = getChartContext();
|
|
138
137
|
|
|
@@ -274,7 +273,7 @@
|
|
|
274
273
|
? merge({ styles: { strokeWidth } }, styleOverrides)
|
|
275
274
|
: {
|
|
276
275
|
styles: { fill, fillOpacity, stroke, strokeWidth, opacity },
|
|
277
|
-
classes: className,
|
|
276
|
+
classes: cls('lc-spline-path', className),
|
|
278
277
|
}
|
|
279
278
|
);
|
|
280
279
|
}
|
|
@@ -362,12 +361,7 @@
|
|
|
362
361
|
<path
|
|
363
362
|
d={tweenedState.current}
|
|
364
363
|
{...restProps}
|
|
365
|
-
class={cls(
|
|
366
|
-
layerClass('spline-path'),
|
|
367
|
-
!fill && 'fill-none',
|
|
368
|
-
!stroke && 'stroke-surface-content',
|
|
369
|
-
className
|
|
370
|
-
)}
|
|
364
|
+
class={cls('lc-spline-path', className)}
|
|
371
365
|
{fill}
|
|
372
366
|
fill-opacity={fillOpacity}
|
|
373
367
|
{stroke}
|
|
@@ -384,7 +378,7 @@
|
|
|
384
378
|
<MarkerWrapper id={markerEndId} marker={markerEnd} />
|
|
385
379
|
|
|
386
380
|
{#if startContent && startPoint}
|
|
387
|
-
<Group x={startPoint.x} y={startPoint.y} class=
|
|
381
|
+
<Group x={startPoint.x} y={startPoint.y} class="lc-spline-g-start">
|
|
388
382
|
{@render startContent({
|
|
389
383
|
point: startPoint,
|
|
390
384
|
value: {
|
|
@@ -396,7 +390,7 @@
|
|
|
396
390
|
{/if}
|
|
397
391
|
|
|
398
392
|
{#if endContent && endPoint.current}
|
|
399
|
-
<Group x={endPoint.current.x} y={endPoint.current.y} class=
|
|
393
|
+
<Group x={endPoint.current.x} y={endPoint.current.y} class="lc-spline-g-end">
|
|
400
394
|
{@render endContent({
|
|
401
395
|
point: endPoint.current,
|
|
402
396
|
value: {
|
|
@@ -408,3 +402,28 @@
|
|
|
408
402
|
{/if}
|
|
409
403
|
{/key}
|
|
410
404
|
{/if}
|
|
405
|
+
|
|
406
|
+
<style>
|
|
407
|
+
@layer base {
|
|
408
|
+
:global(:where(.lc-spline-path)) {
|
|
409
|
+
--fill-color: none;
|
|
410
|
+
--stroke-color: var(--color-surface-content, currentColor);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/* Svg | Canvas layers */
|
|
414
|
+
:global(:where(.lc-layout-svg .lc-spline-path, svg.lc-spline-path):not([fill])) {
|
|
415
|
+
fill: var(--fill-color);
|
|
416
|
+
}
|
|
417
|
+
:global(:where(.lc-layout-svg .lc-spline-path, svg.lc-spline-path):not([stroke])) {
|
|
418
|
+
stroke: var(--stroke-color);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/* Html layers */
|
|
422
|
+
:global(:where(.lc-layout-html .lc-spline-path):not([background-color])) {
|
|
423
|
+
background-color: var(--fill-color);
|
|
424
|
+
}
|
|
425
|
+
:global(:where(.lc-layout-html .lc-spline-path):not([border-color])) {
|
|
426
|
+
border-color: var(--stroke-color);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
</style>
|
|
@@ -188,7 +188,6 @@
|
|
|
188
188
|
import { getComputedStyles, renderText, type ComputedStylesOptions } from '../utils/canvas.js';
|
|
189
189
|
|
|
190
190
|
import { createKey } from '../utils/key.svelte.js';
|
|
191
|
-
import { layerClass } from '../utils/attributes.js';
|
|
192
191
|
import { degreesToRadians } from '../utils/math.js';
|
|
193
192
|
import { createId } from '../utils/createId.js';
|
|
194
193
|
|
|
@@ -411,7 +410,7 @@
|
|
|
411
410
|
paintOrder: 'stroke',
|
|
412
411
|
textAnchor,
|
|
413
412
|
},
|
|
414
|
-
classes: cls(
|
|
413
|
+
classes: cls('lc-text', className),
|
|
415
414
|
};
|
|
416
415
|
|
|
417
416
|
const computedStyles = getComputedStyles(ctx.canvas, styles);
|
|
@@ -473,13 +472,7 @@
|
|
|
473
472
|
{#if renderCtx === 'svg'}
|
|
474
473
|
<!-- `overflow: visible` allow contents to be shown outside element -->
|
|
475
474
|
<!-- `paint-order: stroke` supports stroke outlining text -->
|
|
476
|
-
<svg
|
|
477
|
-
x={dx}
|
|
478
|
-
y={dy}
|
|
479
|
-
{...svgProps}
|
|
480
|
-
class={cls(layerClass('text-svg'), 'overflow-visible [paint-order:stroke]', svgProps?.class)}
|
|
481
|
-
bind:this={svgRef}
|
|
482
|
-
>
|
|
475
|
+
<svg x={dx} y={dy} {...svgProps} class={['lc-text-svg', svgProps?.class]} bind:this={svgRef}>
|
|
483
476
|
{#if path}
|
|
484
477
|
<defs>
|
|
485
478
|
{#key path}
|
|
@@ -496,14 +489,14 @@
|
|
|
496
489
|
stroke-width={strokeWidth}
|
|
497
490
|
{opacity}
|
|
498
491
|
transform={transformProp}
|
|
499
|
-
class={
|
|
492
|
+
class={['lc-text', className]}
|
|
500
493
|
>
|
|
501
494
|
<textPath
|
|
502
495
|
style="text-anchor: {textAnchor};"
|
|
503
496
|
dominant-baseline={dominantBaseline}
|
|
504
497
|
href="#{pathId}"
|
|
505
498
|
{startOffset}
|
|
506
|
-
class=
|
|
499
|
+
class="lc-text-path"
|
|
507
500
|
>
|
|
508
501
|
{wordsByLines.map((line) => line.words.join(' ')).join()}
|
|
509
502
|
</textPath>
|
|
@@ -522,13 +515,13 @@
|
|
|
522
515
|
{stroke}
|
|
523
516
|
stroke-width={strokeWidth}
|
|
524
517
|
{opacity}
|
|
525
|
-
class={
|
|
518
|
+
class={['lc-text', className]}
|
|
526
519
|
>
|
|
527
520
|
{#each wordsByLines as line, index}
|
|
528
521
|
<tspan
|
|
529
522
|
x={motionX.current}
|
|
530
523
|
dy={index === 0 ? startDy : getPixelValue(lineHeight)}
|
|
531
|
-
class=
|
|
524
|
+
class="lc-text-tspan"
|
|
532
525
|
>
|
|
533
526
|
{line.words.join(' ')}
|
|
534
527
|
</tspan>
|
|
@@ -536,4 +529,57 @@
|
|
|
536
529
|
</text>
|
|
537
530
|
{/if}
|
|
538
531
|
</svg>
|
|
532
|
+
{:else if renderCtx === 'html'}
|
|
533
|
+
{@const translateX = textAnchor === 'middle' ? '-50%' : textAnchor === 'end' ? '-100%' : '0%'}
|
|
534
|
+
{@const translateY =
|
|
535
|
+
verticalAnchor === 'middle' ? '-50%' : verticalAnchor === 'end' ? '-100%' : '0%'}
|
|
536
|
+
<!-- TODO: How best to handle dx/dy when adjusted for svg style issues? -->
|
|
537
|
+
<!-- style:line-height={lineHeight} -->
|
|
538
|
+
<!-- TODO: How to handle fill-/stroke- vs bg-/text-/border- colors? -->
|
|
539
|
+
<div
|
|
540
|
+
style:position="absolute"
|
|
541
|
+
style:left="{dx + motionX.current}px"
|
|
542
|
+
style:top="{dy + motionY.current}px"
|
|
543
|
+
style:transform="translate({translateX}, {translateY}) rotate({rotate ?? 0}deg)"
|
|
544
|
+
style:transform-origin="{verticalAnchor === 'middle'
|
|
545
|
+
? 'center'
|
|
546
|
+
: verticalAnchor === 'end'
|
|
547
|
+
? 'bottom'
|
|
548
|
+
: 'top'}
|
|
549
|
+
{textAnchor === 'middle' ? 'center' : textAnchor === 'end' ? 'right' : 'left'}"
|
|
550
|
+
class={['lc-text', className]}
|
|
551
|
+
>
|
|
552
|
+
{textValue}
|
|
553
|
+
</div>
|
|
539
554
|
{/if}
|
|
555
|
+
|
|
556
|
+
<style>
|
|
557
|
+
@layer base {
|
|
558
|
+
:global(:where(.lc-text)) {
|
|
559
|
+
--fill-color: var(--color-surface-content, currentColor);
|
|
560
|
+
--stroke-color: initial;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
:global(:where(.lc-text-svg)) {
|
|
564
|
+
overflow: visible;
|
|
565
|
+
paint-order: stroke;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/* Svg | Canvas layers */
|
|
569
|
+
:global(:where(.lc-layout-svg .lc-text, svg.lc-text):not([fill])) {
|
|
570
|
+
color: var(--fill-color);
|
|
571
|
+
fill: currentColor;
|
|
572
|
+
}
|
|
573
|
+
:global(:where(.lc-layout-svg .lc-text, svg.lc-text):not([stroke])) {
|
|
574
|
+
stroke: var(--stroke-color);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/* Html layers */
|
|
578
|
+
:global(:where(.lc-layout-html .lc-text):not([background-color])) {
|
|
579
|
+
color: var(--fill-color);
|
|
580
|
+
}
|
|
581
|
+
:global(:where(.lc-layout-html .lc-text):not([border-color])) {
|
|
582
|
+
border-color: var(--stroke-color);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
</style>
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
y={(y + ty) * scale - 0.5}
|
|
136
136
|
width={scale + 1}
|
|
137
137
|
height={scale + 1}
|
|
138
|
-
{...extractLayerProps(restProps, 'tile-image-lower')}
|
|
138
|
+
{...extractLayerProps(restProps, 'lc-tile-image-lower')}
|
|
139
139
|
/>
|
|
140
140
|
<image
|
|
141
141
|
{href}
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
y={(y + ty) * scale}
|
|
144
144
|
width={scale}
|
|
145
145
|
height={scale}
|
|
146
|
-
{...extractLayerProps(restProps, 'tile-image')}
|
|
146
|
+
{...extractLayerProps(restProps, 'lc-tile-image')}
|
|
147
147
|
/>
|
|
148
148
|
{/key}
|
|
149
149
|
{#if debug}
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
y={(y + ty) * scale}
|
|
153
153
|
width={scale}
|
|
154
154
|
height={scale}
|
|
155
|
-
class="
|
|
155
|
+
class="lc-tile-image-debug-rect"
|
|
156
156
|
/>
|
|
157
157
|
<Text
|
|
158
158
|
x={(x + tx) * scale}
|
|
@@ -161,6 +161,21 @@
|
|
|
161
161
|
dx={2}
|
|
162
162
|
dy={-2}
|
|
163
163
|
value="{x}-{y}-{z}"
|
|
164
|
-
class="
|
|
164
|
+
class="lc-tile-image-debug-text"
|
|
165
165
|
/>
|
|
166
166
|
{/if}
|
|
167
|
+
|
|
168
|
+
<style>
|
|
169
|
+
@layer components {
|
|
170
|
+
:global(:where(.lc-tile-image-debug-rect)) {
|
|
171
|
+
fill: none;
|
|
172
|
+
stroke: var(--color-danger, red);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
:global(:where(.lc-tile-image-debug-text)) {
|
|
176
|
+
--fill-color: var(--color-danger, red);
|
|
177
|
+
font-size: 14px;
|
|
178
|
+
font-weight: 500;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
</style>
|