tldraw 3.15.0-canary.d8a8ce37d604 → 3.15.0-canary.fc319eb96b77

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 (39) hide show
  1. package/dist-cjs/index.d.ts +5 -0
  2. package/dist-cjs/index.js +2 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/shapes/shared/PathBuilder.js +21 -3
  5. package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
  6. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +2 -1
  7. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
  8. package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js +1 -1
  9. package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js.map +2 -2
  10. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +5 -2
  11. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  12. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +1 -0
  13. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  14. package/dist-cjs/lib/ui/version.js +3 -3
  15. package/dist-cjs/lib/ui/version.js.map +1 -1
  16. package/dist-esm/index.d.mts +5 -0
  17. package/dist-esm/index.mjs +3 -1
  18. package/dist-esm/index.mjs.map +2 -2
  19. package/dist-esm/lib/shapes/shared/PathBuilder.mjs +22 -3
  20. package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
  21. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +2 -1
  22. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
  23. package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs +1 -1
  24. package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs.map +2 -2
  25. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +5 -2
  26. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  27. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +1 -0
  28. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  29. package/dist-esm/lib/ui/version.mjs +3 -3
  30. package/dist-esm/lib/ui/version.mjs.map +1 -1
  31. package/package.json +3 -3
  32. package/src/index.ts +1 -0
  33. package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
  34. package/src/lib/shapes/shared/PathBuilder.tsx +35 -1
  35. package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +1 -0
  36. package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
  37. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +5 -1
  38. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +4 -0
  39. package/src/lib/ui/version.ts +3 -3
@@ -10,6 +10,7 @@ import {
10
10
  Geometry2dFilters,
11
11
  Geometry2dOptions,
12
12
  getPerfectDashProps,
13
+ getVerticesCountForArcLength,
13
14
  Group2d,
14
15
  modulate,
15
16
  PerfectDashTerminal,
@@ -121,6 +122,7 @@ export interface CubicBezierToPathBuilderCommand extends PathBuilderCommandBase
121
122
  type: 'cubic'
122
123
  cp1: VecModel
123
124
  cp2: VecModel
125
+ resolution?: number
124
126
  }
125
127
 
126
128
  /** @internal */
@@ -317,8 +319,17 @@ export class PathBuilder {
317
319
  // Calculate the sweep angle
318
320
  const sweepAngle = endAngle - startAngle
319
321
 
322
+ // Calculate the approximate arc length. General ellipse arc length is expensive - there's
323
+ // no closed form solution, so we have to do iterative numerical approximation. As we only
324
+ // use this to control the resolution of later approximations, let's cheat and just use the
325
+ // circular arc length with the largest radius:
326
+ const approximateArcLength = Math.max(rx1, ry1) * Math.abs(sweepAngle)
327
+
320
328
  // Approximate the arc using cubic bezier curves
321
329
  const numSegments = Math.min(4, Math.ceil(Math.abs(sweepAngle) / (Math.PI / 2)))
330
+ const resolutionPerSegment = Math.ceil(
331
+ getVerticesCountForArcLength(approximateArcLength) / numSegments
332
+ )
322
333
  const anglePerSegment = sweepAngle / numSegments
323
334
 
324
335
  // Helper function to compute point on ellipse
@@ -364,7 +375,16 @@ export class PathBuilder {
364
375
  const cp2y = end.y - handleScale * d2.y
365
376
 
366
377
  const bezierOpts = i === 0 ? opts : { ...opts, mergeWithPrevious: true }
367
- this.cubicBezierTo(end.x, end.y, cp1x, cp1y, cp2x, cp2y, bezierOpts)
378
+ this.cubicBezierToWithResolution(
379
+ end.x,
380
+ end.y,
381
+ cp1x,
382
+ cp1y,
383
+ cp2x,
384
+ cp2y,
385
+ bezierOpts,
386
+ resolutionPerSegment
387
+ )
368
388
  }
369
389
 
370
390
  return this
@@ -378,6 +398,18 @@ export class PathBuilder {
378
398
  cp2X: number,
379
399
  cp2Y: number,
380
400
  opts?: PathBuilderCommandOpts
401
+ ) {
402
+ return this.cubicBezierToWithResolution(x, y, cp1X, cp1Y, cp2X, cp2Y, opts)
403
+ }
404
+ private cubicBezierToWithResolution(
405
+ x: number,
406
+ y: number,
407
+ cp1X: number,
408
+ cp1Y: number,
409
+ cp2X: number,
410
+ cp2Y: number,
411
+ opts?: PathBuilderCommandOpts,
412
+ resolution?: number
381
413
  ) {
382
414
  this.assertHasMoveTo()
383
415
  this.commands.push({
@@ -388,6 +420,7 @@ export class PathBuilder {
388
420
  cp2: { x: cp2X, y: cp2Y },
389
421
  isClose: false,
390
422
  opts,
423
+ resolution,
391
424
  })
392
425
  return this
393
426
  }
@@ -972,6 +1005,7 @@ export class PathBuilderGeometry2d extends Geometry2d {
972
1005
  cp1: Vec.From(command.cp1),
973
1006
  cp2: Vec.From(command.cp2),
974
1007
  end: Vec.From(command),
1008
+ resolution: command.resolution,
975
1009
  })
976
1010
  )
977
1011
  break
@@ -451,6 +451,7 @@ export function OpacitySlider() {
451
451
  steps={tldrawSupportedOpacities.length - 1}
452
452
  title={msg('style-panel.opacity')}
453
453
  onHistoryMark={onHistoryMark}
454
+ ariaValueModifier={25}
454
455
  />
455
456
  )
456
457
  }
@@ -65,7 +65,7 @@ export interface TLUiDialogBodyProps {
65
65
  /** @public @react */
66
66
  export function TldrawUiDialogBody({ className, children, style }: TLUiDialogBodyProps) {
67
67
  return (
68
- <div className={classNames('tlui-dialog__body', className)} style={style}>
68
+ <div className={classNames('tlui-dialog__body', className)} style={style} tabIndex={0}>
69
69
  {children}
70
70
  </div>
71
71
  )
@@ -13,6 +13,7 @@ export interface TLUiSliderProps {
13
13
  onValueChange(value: number): void
14
14
  onHistoryMark(id: string): void
15
15
  'data-testid'?: string
16
+ ariaValueModifier?: number
16
17
  }
17
18
 
18
19
  /** @public @react */
@@ -26,6 +27,7 @@ export const TldrawUiSlider = React.forwardRef<HTMLDivElement, TLUiSliderProps>(
26
27
  label,
27
28
  onValueChange,
28
29
  ['data-testid']: testId,
30
+ ariaValueModifier = 1,
29
31
  }: TLUiSliderProps,
30
32
  ref
31
33
  ) {
@@ -81,7 +83,9 @@ export const TldrawUiSlider = React.forwardRef<HTMLDivElement, TLUiSliderProps>(
81
83
  </_Slider.Track>
82
84
  {value !== null && (
83
85
  <_Slider.Thumb
84
- aria-label={msg('style-panel.opacity')}
86
+ aria-valuemin={(min ?? 0) * ariaValueModifier}
87
+ aria-valuenow={value * ariaValueModifier}
88
+ aria-valuemax={steps * ariaValueModifier}
85
89
  className="tlui-slider__thumb"
86
90
  dir="ltr"
87
91
  ref={ref}
@@ -76,6 +76,10 @@ export const TldrawUiToolbarToggleGroup = ({
76
76
  <_Toolbar.ToggleGroup
77
77
  type={type}
78
78
  {...props}
79
+ // TODO: this fixes a bug in Radix until they fix it.
80
+ // https://github.com/radix-ui/primitives/issues/3188
81
+ // https://github.com/radix-ui/primitives/pull/3189
82
+ role="radiogroup"
79
83
  className={classnames('tlui-toolbar-toggle-group', className)}
80
84
  >
81
85
  {children}
@@ -1,9 +1,9 @@
1
1
  // This file is automatically generated by internal/scripts/refresh-assets.ts.
2
2
  // Do not edit manually. Or do, I'm a comment, not a cop.
3
3
 
4
- export const version = '3.15.0-canary.d8a8ce37d604'
4
+ export const version = '3.15.0-canary.fc319eb96b77'
5
5
  export const publishDates = {
6
6
  major: '2024-09-13T14:36:29.063Z',
7
- minor: '2025-07-10T09:51:55.964Z',
8
- patch: '2025-07-10T09:51:55.964Z',
7
+ minor: '2025-07-11T13:41:21.778Z',
8
+ patch: '2025-07-11T13:41:21.778Z',
9
9
  }