tldraw 4.4.0-canary.ac3507ffc12d → 4.4.0-canary.afdcafe834b3

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 (47) hide show
  1. package/dist-cjs/index.d.ts +1 -112
  2. package/dist-cjs/index.js +1 -10
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js +1 -6
  5. package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
  6. package/dist-cjs/lib/defaultSideEffects.js +0 -8
  7. package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
  8. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +1 -2
  9. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
  10. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +3 -26
  11. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +3 -3
  12. package/dist-cjs/lib/ui/context/actions.js +0 -3
  13. package/dist-cjs/lib/ui/context/actions.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 +1 -112
  17. package/dist-esm/index.mjs +1 -17
  18. package/dist-esm/index.mjs.map +2 -2
  19. package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs +1 -6
  20. package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
  21. package/dist-esm/lib/defaultSideEffects.mjs +0 -8
  22. package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
  23. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +1 -2
  24. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  25. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +3 -26
  26. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +3 -3
  27. package/dist-esm/lib/ui/context/actions.mjs +0 -3
  28. package/dist-esm/lib/ui/context/actions.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 -15
  33. package/src/lib/bindings/arrow/ArrowBindingUtil.ts +0 -12
  34. package/src/lib/defaultSideEffects.ts +0 -8
  35. package/src/lib/shapes/shared/RichTextLabel.tsx +0 -1
  36. package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +5 -54
  37. package/src/lib/ui/context/actions.tsx +0 -3
  38. package/src/lib/ui/version.ts +3 -3
  39. package/src/lib/ui.css +0 -46
  40. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +2 -2
  41. package/src/test/commands/cameraState.test.ts +0 -109
  42. package/tldraw.css +0 -51
  43. package/dist-cjs/lib/ui/components/primitives/TldrawUiSelect.js +0 -144
  44. package/dist-cjs/lib/ui/components/primitives/TldrawUiSelect.js.map +0 -7
  45. package/dist-esm/lib/ui/components/primitives/TldrawUiSelect.mjs +0 -114
  46. package/dist-esm/lib/ui/components/primitives/TldrawUiSelect.mjs.map +0 -7
  47. package/src/lib/ui/components/primitives/TldrawUiSelect.tsx +0 -211
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tldraw",
3
3
  "description": "A tiny little drawing editor.",
4
- "version": "4.4.0-canary.ac3507ffc12d",
4
+ "version": "4.4.0-canary.afdcafe834b3",
5
5
  "author": {
6
6
  "name": "tldraw Inc.",
7
7
  "email": "hello@tldraw.com"
@@ -62,8 +62,8 @@
62
62
  "@tiptap/pm": "^3.12.1",
63
63
  "@tiptap/react": "^3.12.1",
64
64
  "@tiptap/starter-kit": "^3.12.1",
65
- "@tldraw/editor": "4.4.0-canary.ac3507ffc12d",
66
- "@tldraw/store": "4.4.0-canary.ac3507ffc12d",
65
+ "@tldraw/editor": "4.4.0-canary.afdcafe834b3",
66
+ "@tldraw/store": "4.4.0-canary.afdcafe834b3",
67
67
  "classnames": "^2.5.1",
68
68
  "hotkeys-js": "^3.13.9",
69
69
  "idb": "^7.1.1",
package/src/index.ts CHANGED
@@ -400,7 +400,6 @@ export {
400
400
  TldrawUiDropdownMenuItem,
401
401
  TldrawUiDropdownMenuRoot,
402
402
  TldrawUiDropdownMenuSub,
403
- TldrawUiDropdownMenuSubContent,
404
403
  TldrawUiDropdownMenuSubTrigger,
405
404
  TldrawUiDropdownMenuTrigger,
406
405
  type TLUiDropdownMenuCheckboxItemProps,
@@ -408,7 +407,6 @@ export {
408
407
  type TLUiDropdownMenuGroupProps,
409
408
  type TLUiDropdownMenuItemProps,
410
409
  type TLUiDropdownMenuRootProps,
411
- type TLUiDropdownMenuSubContentProps,
412
410
  type TLUiDropdownMenuSubProps,
413
411
  type TLUiDropdownMenuSubTriggerProps,
414
412
  type TLUiDropdownMenuTriggerProps,
@@ -428,18 +426,6 @@ export {
428
426
  type TLUiPopoverProps,
429
427
  type TLUiPopoverTriggerProps,
430
428
  } from './lib/ui/components/primitives/TldrawUiPopover'
431
- export {
432
- TldrawUiSelect,
433
- TldrawUiSelectContent,
434
- TldrawUiSelectItem,
435
- TldrawUiSelectTrigger,
436
- TldrawUiSelectValue,
437
- type TLUiSelectContentProps,
438
- type TLUiSelectItemProps,
439
- type TLUiSelectProps,
440
- type TLUiSelectTriggerProps,
441
- type TLUiSelectValueProps,
442
- } from './lib/ui/components/primitives/TldrawUiSelect'
443
429
  export { TldrawUiSlider, type TLUiSliderProps } from './lib/ui/components/primitives/TldrawUiSlider'
444
430
  export {
445
431
  TldrawUiToolbar,
@@ -685,7 +671,7 @@ export {
685
671
  type TLUiTranslationContextType,
686
672
  type TLUiTranslationProviderProps,
687
673
  } from './lib/ui/hooks/useTranslation/useTranslation'
688
- export { iconTypes, type TLUiIconType } from './lib/ui/icon-types'
674
+ export { type TLUiIconType } from './lib/ui/icon-types'
689
675
  export { useDefaultHelpers, type TLUiOverrideHelpers, type TLUiOverrides } from './lib/ui/overrides'
690
676
  export { TldrawUi, TldrawUiInFrontOfTheCanvas, type TldrawUiProps } from './lib/ui/TldrawUi'
691
677
  export { containBoxSize, downsizeImage, type BoxWidthHeight } from './lib/utils/assets/assets'
@@ -58,20 +58,8 @@ export class ArrowBindingUtil extends BindingUtil<TLArrowBinding> {
58
58
 
59
59
  // when the arrow itself changes
60
60
  override onAfterChangeFromShape({
61
- shapeBefore,
62
61
  shapeAfter,
63
- reason,
64
62
  }: BindingOnShapeChangeOptions<TLArrowBinding>): void {
65
- // When translating arrows together with their bound shapes, only x/y changes.
66
- // In this case, bindings remain valid and no reparenting is needed.
67
- // This is a significant performance optimization when moving many bound shapes.
68
- if (
69
- reason !== 'ancestry' &&
70
- shapeBefore.parentId === shapeAfter.parentId &&
71
- shapeBefore.index === shapeAfter.index
72
- ) {
73
- return
74
- }
75
63
  arrowDidUpdate(this.editor, shapeAfter as TLArrowShape)
76
64
  }
77
65
 
@@ -1,16 +1,8 @@
1
1
  import { Editor } from '@tldraw/editor'
2
- import { updateHoveredShapeId } from './tools/selection-logic/updateHoveredShapeId'
3
2
 
4
3
  /** @public */
5
4
  export function registerDefaultSideEffects(editor: Editor) {
6
5
  return editor.sideEffects.register({
7
- instance: {
8
- afterChange: (prev, next) => {
9
- if (prev.cameraState !== next.cameraState && next.cameraState === 'idle') {
10
- updateHoveredShapeId(editor)
11
- }
12
- },
13
- },
14
6
  instance_page_state: {
15
7
  afterChange: (prev, next) => {
16
8
  if (prev.croppingShapeId !== next.croppingShapeId) {
@@ -257,7 +257,6 @@ export function RichTextSVG({
257
257
  overflowWrap: 'break-word' as const,
258
258
  whiteSpace: 'pre-wrap',
259
259
  textShadow: showTextOutline ? 'var(--tl-text-outline)' : 'none',
260
- tabSize: 'var(--tl-tab-size, 2)',
261
260
  }
262
261
 
263
262
  return (
@@ -1,27 +1,7 @@
1
- import { Editor, TLShape, TLShapeId, throttle } from '@tldraw/editor'
1
+ import { Editor, TLShape, throttle } from '@tldraw/editor'
2
2
 
3
- /*
4
- Perf optimization: Skip hover updates while panning.
5
-
6
- Hit-testing shapes is expensive in large documents. When panning, we don't need
7
- continuous hover updates - we just need to resume when the camera stops.
8
-
9
- The logic:
10
- 1. Camera idle → update hover normally, unlock
11
- 2. Camera moving + locked → skip entirely (no hit-testing)
12
- 3. Camera moving + no current hover → lock immediately
13
- 4. Camera moving + same shape → keep current hover (no change needed)
14
- 5. Camera moving + different shape → clear hover and lock
15
-
16
- This means: when you start panning over a shape, it stays hovered until
17
- your cursor moves off it, then hover clears and we stop hit-testing until
18
- the camera stops.
19
- */
20
-
21
- // Track per-editor state for hover updates during camera movement
22
- const hoverLockedEditors = new WeakMap<Editor, boolean>()
23
-
24
- function getShapeToHover(editor: Editor): TLShapeId | null {
3
+ function _updateHoveredShapeId(editor: Editor) {
4
+ // todo: consider replacing `get hoveredShapeId` with this; it would mean keeping hoveredShapeId in memory rather than in the store and possibly re-computing it more often than necessary
25
5
  const hitShape = editor.getShapeAtPoint(editor.inputs.getCurrentPagePoint(), {
26
6
  hitInside: false,
27
7
  hitLabels: false,
@@ -29,7 +9,7 @@ function getShapeToHover(editor: Editor): TLShapeId | null {
29
9
  renderingOnly: true,
30
10
  })
31
11
 
32
- if (!hitShape) return null
12
+ if (!hitShape) return editor.setHoveredShape(null)
33
13
 
34
14
  let shapeToHover: TLShape | undefined = undefined
35
15
 
@@ -48,36 +28,7 @@ function getShapeToHover(editor: Editor): TLShapeId | null {
48
28
  }
49
29
  }
50
30
 
51
- return shapeToHover.id
52
- }
53
-
54
- function _updateHoveredShapeId(editor: Editor) {
55
- const cameraMoving = editor.getCameraState() === 'moving'
56
-
57
- if (!cameraMoving) {
58
- hoverLockedEditors.set(editor, false)
59
- const nextHoveredId = getShapeToHover(editor)
60
- return editor.setHoveredShape(nextHoveredId)
61
- }
62
-
63
- if (hoverLockedEditors.get(editor)) {
64
- return
65
- }
66
-
67
- const currentHoveredId = editor.getHoveredShapeId()
68
-
69
- if (!currentHoveredId) {
70
- hoverLockedEditors.set(editor, true)
71
- return
72
- }
73
-
74
- const nextHoveredId = getShapeToHover(editor)
75
- if (nextHoveredId === currentHoveredId) {
76
- return
77
- }
78
-
79
- editor.setHoveredShape(null)
80
- hoverLockedEditors.set(editor, true)
31
+ return editor.setHoveredShape(shapeToHover.id)
81
32
  }
82
33
 
83
34
  /** @internal */
@@ -1459,7 +1459,6 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
1459
1459
  label: 'action.toggle-lock',
1460
1460
  kbd: 'shift+l',
1461
1461
  onSelect(source) {
1462
- if (!canApplySelectionAction()) return
1463
1462
  editor.markHistoryStoppingPoint('locking')
1464
1463
  trackEvent('toggle-lock', { source })
1465
1464
  editor.toggleLock(editor.getSelectedShapeIds())
@@ -1674,7 +1673,6 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
1674
1673
  label: 'a11y.enlarge-shape',
1675
1674
  kbd: 'cmd+alt+shift+=,ctrl+alt+shift+=',
1676
1675
  onSelect: async (source) => {
1677
- if (!canApplySelectionAction()) return
1678
1676
  scaleShapes(1.1)
1679
1677
  trackEvent('enlarge-shapes', { source })
1680
1678
  },
@@ -1684,7 +1682,6 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
1684
1682
  label: 'a11y.shrink-shape',
1685
1683
  kbd: 'cmd+alt+shift+-,ctrl+alt+shift+-',
1686
1684
  onSelect: async (source) => {
1687
- if (!canApplySelectionAction()) return
1688
1685
  scaleShapes(1 / 1.1)
1689
1686
  trackEvent('shrink-shapes', { source })
1690
1687
  },
@@ -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 = '4.4.0-canary.ac3507ffc12d'
4
+ export const version = '4.4.0-canary.afdcafe834b3'
5
5
  export const publishDates = {
6
6
  major: '2025-09-18T14:39:22.803Z',
7
- minor: '2026-02-04T12:47:25.448Z',
8
- patch: '2026-02-04T12:47:25.448Z',
7
+ minor: '2026-02-04T08:49:09.694Z',
8
+ patch: '2026-02-04T08:49:09.694Z',
9
9
  }
package/src/lib/ui.css CHANGED
@@ -523,52 +523,6 @@
523
523
  }
524
524
  }
525
525
 
526
- /* --------------------- Select --------------------- */
527
-
528
- /* Trigger extends .tlui-button with space-between layout */
529
- .tlui-select__trigger {
530
- justify-content: space-between;
531
- gap: var(--tl-space-3);
532
- }
533
-
534
- .tlui-select__trigger[data-state='open']::after {
535
- opacity: 1;
536
- }
537
-
538
- .tlui-select__value {
539
- display: flex;
540
- align-items: center;
541
- gap: var(--tl-space-2);
542
- }
543
-
544
- .tlui-select__chevron {
545
- flex-shrink: 0;
546
- color: var(--tl-color-text-2);
547
- }
548
-
549
- /* Content extends .tlui-menu with Radix-aware sizing */
550
- .tlui-select__content {
551
- min-width: var(--radix-select-trigger-width);
552
- max-height: var(--radix-select-content-available-height);
553
- }
554
-
555
- .tlui-select__viewport {
556
- padding: 4px 0;
557
- }
558
-
559
- /* Item extends .tlui-button__checkbox with left-aligned text */
560
- .tlui-select__item {
561
- justify-content: flex-start;
562
- }
563
-
564
- .tlui-select__item-indicator {
565
- visibility: hidden;
566
- }
567
-
568
- .tlui-select__item[data-state='checked'] .tlui-select__item-indicator {
569
- visibility: visible;
570
- }
571
-
572
526
  /* ----------------------- Kbd ---------------------- */
573
527
 
574
528
  .tlui-kbd {
@@ -94,7 +94,7 @@ exports[`Matches a snapshot > Basic SVG 1`] = `
94
94
  xmlns="http://www.w3.org/1999/xhtml"
95
95
  >
96
96
  <div
97
- style="font-size: 22px; color: rgb(0, 0, 0); line-height: 1.35; text-align: center; width: 0px; word-wrap: break-word; overflow-wrap: break-word; white-space: pre-wrap; text-shadow: var(--tl-text-outline); tab-size: var(--tl-tab-size, 2); position: static; height: 0px; margin: 0px; padding: 0px; border: 0px;"
97
+ style="font-size: 22px; color: rgb(0, 0, 0); line-height: 1.35; text-align: center; width: 0px; word-wrap: break-word; overflow-wrap: break-word; white-space: pre-wrap; text-shadow: var(--tl-text-outline); position: static; height: 0px; margin: 0px; padding: 0px; border: 0px;"
98
98
  >
99
99
  <p
100
100
  dir="auto"
@@ -234,7 +234,7 @@ exports[`Returns all shapes when no ids are provided > All shapes 1`] = `
234
234
  xmlns="http://www.w3.org/1999/xhtml"
235
235
  >
236
236
  <div
237
- style="font-size: 22px; color: rgb(0, 0, 0); line-height: 1.35; text-align: center; width: 0px; word-wrap: break-word; overflow-wrap: break-word; white-space: pre-wrap; text-shadow: var(--tl-text-outline); tab-size: var(--tl-tab-size, 2); position: static; height: 0px; margin: 0px; padding: 0px; border: 0px;"
237
+ style="font-size: 22px; color: rgb(0, 0, 0); line-height: 1.35; text-align: center; width: 0px; word-wrap: break-word; overflow-wrap: break-word; white-space: pre-wrap; text-shadow: var(--tl-text-outline); position: static; height: 0px; margin: 0px; padding: 0px; border: 0px;"
238
238
  >
239
239
  <p
240
240
  dir="auto"
@@ -230,115 +230,6 @@ describe('getDebouncedZoomLevel', () => {
230
230
  })
231
231
  })
232
232
 
233
- describe('hover updates during camera movement', () => {
234
- // Note: These tests verify the hover locking optimization during camera movement.
235
- // Important: pan({ x, y }) moves the camera, which changes how screen coordinates
236
- // map to page coordinates. After pan(10, 10), screen point (150, 150) maps to
237
- // page point (140, 140). Tests account for this by positioning pointer well
238
- // inside shapes so small pans don't move the effective page point outside.
239
-
240
- // Note: Default geo shapes have fill: 'none' (hollow), so hit testing only works on edges.
241
- // For interior points to register hits, shapes must have fill: 'solid'.
242
-
243
- it('keeps hover when camera starts moving and pointer is over same shape', () => {
244
- // Create a solid shape so we can hit anywhere inside it
245
- editor.createShapes([{ type: 'geo', x: 100, y: 100, props: { w: 200, h: 200, fill: 'solid' } }])
246
- const shape = editor.getLastCreatedShape()
247
-
248
- // Move pointer to center of shape (200, 200 is center of 100-300 range)
249
- editor.pointerMove(200, 200)
250
- expect(editor.getHoveredShapeId()).toBe(shape.id)
251
-
252
- // Start panning (camera moves)
253
- // After pan(10,10), screen (200,200) -> page (190,190), still inside shape (100-300)
254
- editor.pan({ x: 10, y: 10 })
255
- expect(editor.getCameraState()).toBe('moving')
256
-
257
- // Trigger a pointer move at the same screen position
258
- // Page point is (190, 190) which is still inside the shape
259
- editor.pointerMove(200, 200)
260
- expect(editor.getHoveredShapeId()).toBe(shape.id)
261
- })
262
-
263
- it('clears and locks hover when pointer moves to empty area while camera is moving', () => {
264
- // Create a solid shape so we can hit anywhere inside it
265
- editor.createShapes([{ type: 'geo', x: 100, y: 100, props: { w: 200, h: 200, fill: 'solid' } }])
266
- const shape = editor.getLastCreatedShape()
267
-
268
- // Move pointer over shape to hover it
269
- editor.pointerMove(200, 200)
270
- expect(editor.getHoveredShapeId()).toBe(shape.id)
271
-
272
- // Start panning
273
- editor.pan({ x: 10, y: 10 })
274
- expect(editor.getCameraState()).toBe('moving')
275
-
276
- // Move pointer to empty area - hover changes to null, so it locks
277
- editor.pointerMove(500, 500)
278
- expect(editor.getHoveredShapeId()).toBe(null)
279
-
280
- // Move pointer back to shape while still moving - should stay locked (no hover)
281
- editor.pointerMove(200, 200)
282
- expect(editor.getHoveredShapeId()).toBe(null)
283
- })
284
-
285
- it('resumes hover updates when camera becomes idle', () => {
286
- // Create a solid shape so we can hit anywhere inside it
287
- editor.createShapes([{ type: 'geo', x: 100, y: 100, props: { w: 200, h: 200, fill: 'solid' } }])
288
- const shape = editor.getLastCreatedShape()
289
-
290
- // Move pointer over shape
291
- editor.pointerMove(200, 200)
292
- expect(editor.getHoveredShapeId()).toBe(shape.id)
293
-
294
- // Start panning and move pointer off shape to trigger lock
295
- editor.pan({ x: 10, y: 10 })
296
- expect(editor.getCameraState()).toBe('moving')
297
- editor.pointerMove(500, 500) // Move to empty area
298
- expect(editor.getHoveredShapeId()).toBe(null)
299
-
300
- // Move pointer back over shape while still moving - still locked
301
- editor.pointerMove(200, 200)
302
- expect(editor.getHoveredShapeId()).toBe(null)
303
-
304
- // Let camera settle
305
- editor.forceTick(5)
306
- expect(editor.getCameraState()).toBe('idle')
307
-
308
- // Move pointer again now that camera is idle - hover should update
309
- // After pan(10,10), screen (200,200) -> page (190,190), still inside shape
310
- editor.pointerMove(200, 200)
311
- expect(editor.getHoveredShapeId()).toBe(shape.id)
312
- })
313
-
314
- it('locks immediately if there is no current hover when camera starts moving', () => {
315
- // Create a solid shape so we can hit anywhere inside it
316
- editor.createShapes([{ type: 'geo', x: 100, y: 100, props: { w: 200, h: 200, fill: 'solid' } }])
317
- const shape = editor.getLastCreatedShape()
318
-
319
- // Pointer is not over any shape
320
- editor.pointerMove(500, 500)
321
- expect(editor.getHoveredShapeId()).toBe(null)
322
-
323
- // Start panning
324
- editor.pan({ x: 10, y: 10 })
325
- expect(editor.getCameraState()).toBe('moving')
326
-
327
- // Move pointer over shape while moving - should be locked since no previous hover
328
- editor.pointerMove(200, 200)
329
- expect(editor.getHoveredShapeId()).toBe(null)
330
-
331
- // Let camera settle
332
- editor.forceTick(5)
333
- expect(editor.getCameraState()).toBe('idle')
334
-
335
- // Move pointer again now that camera is idle - hover should work
336
- // After pan(10,10), screen (200,200) -> page (190,190), still inside shape
337
- editor.pointerMove(200, 200)
338
- expect(editor.getHoveredShapeId()).toBe(shape.id)
339
- })
340
- })
341
-
342
233
  describe('getEfficientZoomLevel', () => {
343
234
  it('returns current zoom level when below shape threshold', () => {
344
235
  // Default threshold is 500 shapes, we have 0
package/tldraw.css CHANGED
@@ -64,7 +64,6 @@
64
64
 
65
65
  /* Misc */
66
66
  --tl-zoom: 1;
67
- --tl-tab-size: 2;
68
67
 
69
68
  /* Cursor SVGs */
70
69
  --tl-cursor-none: none;
@@ -900,10 +899,6 @@ input,
900
899
  /* white-space: break-spaces; */
901
900
  }
902
901
 
903
- .tl-rich-text {
904
- tab-size: var(--tl-tab-size, 2);
905
- }
906
-
907
902
  .tl-rich-text p {
908
903
  margin: 0;
909
904
  /* Depending on the extensions, <p> tags can be empty, without a <br />. */
@@ -2328,52 +2323,6 @@ it from receiving any pointer events or affecting the cursor. */
2328
2323
  }
2329
2324
  }
2330
2325
 
2331
- /* --------------------- Select --------------------- */
2332
-
2333
- /* Trigger extends .tlui-button with space-between layout */
2334
- .tlui-select__trigger {
2335
- justify-content: space-between;
2336
- gap: var(--tl-space-3);
2337
- }
2338
-
2339
- .tlui-select__trigger[data-state='open']::after {
2340
- opacity: 1;
2341
- }
2342
-
2343
- .tlui-select__value {
2344
- display: flex;
2345
- align-items: center;
2346
- gap: var(--tl-space-2);
2347
- }
2348
-
2349
- .tlui-select__chevron {
2350
- flex-shrink: 0;
2351
- color: var(--tl-color-text-2);
2352
- }
2353
-
2354
- /* Content extends .tlui-menu with Radix-aware sizing */
2355
- .tlui-select__content {
2356
- min-width: var(--radix-select-trigger-width);
2357
- max-height: var(--radix-select-content-available-height);
2358
- }
2359
-
2360
- .tlui-select__viewport {
2361
- padding: 4px 0;
2362
- }
2363
-
2364
- /* Item extends .tlui-button__checkbox with left-aligned text */
2365
- .tlui-select__item {
2366
- justify-content: flex-start;
2367
- }
2368
-
2369
- .tlui-select__item-indicator {
2370
- visibility: hidden;
2371
- }
2372
-
2373
- .tlui-select__item[data-state='checked'] .tlui-select__item-indicator {
2374
- visibility: visible;
2375
- }
2376
-
2377
2326
  /* ----------------------- Kbd ---------------------- */
2378
2327
 
2379
2328
  .tlui-kbd {
@@ -1,144 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var TldrawUiSelect_exports = {};
30
- __export(TldrawUiSelect_exports, {
31
- TldrawUiSelect: () => TldrawUiSelect,
32
- TldrawUiSelectContent: () => TldrawUiSelectContent,
33
- TldrawUiSelectItem: () => TldrawUiSelectItem,
34
- TldrawUiSelectTrigger: () => TldrawUiSelectTrigger,
35
- TldrawUiSelectValue: () => TldrawUiSelectValue
36
- });
37
- module.exports = __toCommonJS(TldrawUiSelect_exports);
38
- var import_jsx_runtime = require("react/jsx-runtime");
39
- var import_editor = require("@tldraw/editor");
40
- var import_classnames = __toESM(require("classnames"), 1);
41
- var import_radix_ui = require("radix-ui");
42
- var React = __toESM(require("react"), 1);
43
- var import_useMenuIsOpen = require("../../hooks/useMenuIsOpen");
44
- var import_TldrawUiIcon = require("./TldrawUiIcon");
45
- function TldrawUiSelect({
46
- id,
47
- value,
48
- onValueChange,
49
- onOpenChange,
50
- disabled,
51
- className,
52
- children,
53
- "data-testid": dataTestId,
54
- "aria-label": ariaLabel
55
- }) {
56
- const [open, handleOpenChange] = (0, import_useMenuIsOpen.useMenuIsOpen)(id, onOpenChange);
57
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
- import_radix_ui.Select.Root,
59
- {
60
- value,
61
- onValueChange,
62
- onOpenChange: handleOpenChange,
63
- open,
64
- disabled,
65
- dir: "ltr",
66
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
67
- "div",
68
- {
69
- id,
70
- className: (0, import_classnames.default)("tlui-select", className),
71
- "data-testid": dataTestId,
72
- "aria-label": ariaLabel,
73
- children
74
- }
75
- )
76
- }
77
- );
78
- }
79
- const TldrawUiSelectTrigger = React.forwardRef(
80
- function TldrawUiSelectTrigger2({ children, className }, ref) {
81
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
82
- import_radix_ui.Select.Trigger,
83
- {
84
- ref,
85
- className: (0, import_classnames.default)("tlui-button tlui-select__trigger", className),
86
- children: [
87
- children,
88
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Select.Icon, { className: "tlui-select__chevron", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiIcon.TldrawUiIcon, { icon: "chevron-down", label: "", small: true }) })
89
- ]
90
- }
91
- );
92
- }
93
- );
94
- function TldrawUiSelectValue({ placeholder, icon, children }) {
95
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Select.Value, { placeholder, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "tlui-select__value", children: [
96
- icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiIcon.TldrawUiIcon, { icon, label: "", small: true }),
97
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "tlui-button__label", children })
98
- ] }) });
99
- }
100
- function TldrawUiSelectContent({
101
- children,
102
- side = "bottom",
103
- align = "start",
104
- className
105
- }) {
106
- const container = (0, import_editor.useContainer)();
107
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Select.Portal, { container, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
108
- import_radix_ui.Select.Content,
109
- {
110
- className: (0, import_classnames.default)("tlui-menu tlui-select__content", className),
111
- position: "popper",
112
- side,
113
- align,
114
- sideOffset: 4,
115
- collisionPadding: 4,
116
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Select.Viewport, { className: "tlui-select__viewport", children })
117
- }
118
- ) });
119
- }
120
- function TldrawUiSelectItem({
121
- value,
122
- label,
123
- icon,
124
- disabled,
125
- className
126
- }) {
127
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
128
- import_radix_ui.Select.Item,
129
- {
130
- value,
131
- disabled,
132
- className: (0, import_classnames.default)(
133
- "tlui-button tlui-button__menu tlui-button__checkbox tlui-select__item",
134
- className
135
- ),
136
- children: [
137
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiIcon.TldrawUiIcon, { small: true, icon: "check", label: "", className: "tlui-select__item-indicator" }),
138
- icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiIcon.TldrawUiIcon, { icon, label: "", small: true }),
139
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Select.ItemText, { className: "tlui-button__label", children: label })
140
- ]
141
- }
142
- );
143
- }
144
- //# sourceMappingURL=TldrawUiSelect.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/lib/ui/components/primitives/TldrawUiSelect.tsx"],
4
- "sourcesContent": ["import { useContainer } from '@tldraw/editor'\nimport classNames from 'classnames'\nimport { Select as _Select } from 'radix-ui'\nimport * as React from 'react'\nimport { useMenuIsOpen } from '../../hooks/useMenuIsOpen'\nimport { TLUiIconType } from '../../icon-types'\nimport { TldrawUiIcon } from './TldrawUiIcon'\n\n/* --------------------- Root --------------------- */\n\n/** @public */\nexport interface TLUiSelectProps {\n\tid: string\n\tvalue: string\n\tonValueChange(value: string): void\n\tonOpenChange?(isOpen: boolean): void\n\tdisabled?: boolean\n\tclassName?: string\n\tchildren: React.ReactNode\n\t'data-testid'?: string\n\t'aria-label'?: string\n}\n\n/**\n * A select dropdown component.\n *\n * @example\n * ```tsx\n * <TldrawUiSelect id=\"my-select\" value={value} onValueChange={setValue}>\n * <TldrawUiSelectTrigger>\n * <TldrawUiSelectValue placeholder=\"Select...\" />\n * </TldrawUiSelectTrigger>\n * <TldrawUiSelectContent>\n * <TldrawUiSelectItem value=\"one\" label=\"One\" />\n * <TldrawUiSelectItem value=\"two\" label=\"Two\" />\n * </TldrawUiSelectContent>\n * </TldrawUiSelect>\n * ```\n *\n * @public\n * @react\n */\nexport function TldrawUiSelect({\n\tid,\n\tvalue,\n\tonValueChange,\n\tonOpenChange,\n\tdisabled,\n\tclassName,\n\tchildren,\n\t'data-testid': dataTestId,\n\t'aria-label': ariaLabel,\n}: TLUiSelectProps) {\n\tconst [open, handleOpenChange] = useMenuIsOpen(id, onOpenChange)\n\n\treturn (\n\t\t<_Select.Root\n\t\t\tvalue={value}\n\t\t\tonValueChange={onValueChange}\n\t\t\tonOpenChange={handleOpenChange}\n\t\t\topen={open}\n\t\t\tdisabled={disabled}\n\t\t\tdir=\"ltr\"\n\t\t>\n\t\t\t<div\n\t\t\t\tid={id}\n\t\t\t\tclassName={classNames('tlui-select', className)}\n\t\t\t\tdata-testid={dataTestId}\n\t\t\t\taria-label={ariaLabel}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</_Select.Root>\n\t)\n}\n\n/* --------------------- Trigger --------------------- */\n\n/** @public */\nexport interface TLUiSelectTriggerProps {\n\tchildren: React.ReactNode\n\tclassName?: string\n}\n\n/**\n * The trigger button for the select dropdown.\n *\n * @public\n * @react\n */\nexport const TldrawUiSelectTrigger = React.forwardRef<HTMLButtonElement, TLUiSelectTriggerProps>(\n\tfunction TldrawUiSelectTrigger({ children, className }, ref) {\n\t\treturn (\n\t\t\t<_Select.Trigger\n\t\t\t\tref={ref}\n\t\t\t\tclassName={classNames('tlui-button tlui-select__trigger', className)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t\t<_Select.Icon className=\"tlui-select__chevron\">\n\t\t\t\t\t<TldrawUiIcon icon=\"chevron-down\" label=\"\" small />\n\t\t\t\t</_Select.Icon>\n\t\t\t</_Select.Trigger>\n\t\t)\n\t}\n)\n\n/* --------------------- Value --------------------- */\n\n/** @public */\nexport interface TLUiSelectValueProps {\n\tplaceholder?: string\n\ticon?: TLUiIconType | Exclude<string, TLUiIconType>\n\tchildren?: React.ReactNode\n}\n\n/**\n * Displays the currently selected value in the trigger.\n *\n * @public\n * @react\n */\nexport function TldrawUiSelectValue({ placeholder, icon, children }: TLUiSelectValueProps) {\n\treturn (\n\t\t<_Select.Value placeholder={placeholder}>\n\t\t\t<span className=\"tlui-select__value\">\n\t\t\t\t{icon && <TldrawUiIcon icon={icon} label=\"\" small />}\n\t\t\t\t<span className=\"tlui-button__label\">{children}</span>\n\t\t\t</span>\n\t\t</_Select.Value>\n\t)\n}\n\n/* --------------------- Content --------------------- */\n\n/** @public */\nexport interface TLUiSelectContentProps {\n\tchildren: React.ReactNode\n\tside?: 'top' | 'bottom'\n\talign?: 'start' | 'center' | 'end'\n\tclassName?: string\n}\n\n/**\n * The dropdown content container for select items.\n *\n * @public\n * @react\n */\nexport function TldrawUiSelectContent({\n\tchildren,\n\tside = 'bottom',\n\talign = 'start',\n\tclassName,\n}: TLUiSelectContentProps) {\n\tconst container = useContainer()\n\n\treturn (\n\t\t<_Select.Portal container={container}>\n\t\t\t<_Select.Content\n\t\t\t\tclassName={classNames('tlui-menu tlui-select__content', className)}\n\t\t\t\tposition=\"popper\"\n\t\t\t\tside={side}\n\t\t\t\talign={align}\n\t\t\t\tsideOffset={4}\n\t\t\t\tcollisionPadding={4}\n\t\t\t>\n\t\t\t\t<_Select.Viewport className=\"tlui-select__viewport\">{children}</_Select.Viewport>\n\t\t\t</_Select.Content>\n\t\t</_Select.Portal>\n\t)\n}\n\n/* --------------------- Item --------------------- */\n\n/** @public */\nexport interface TLUiSelectItemProps {\n\tvalue: string\n\tlabel: string\n\ticon?: TLUiIconType | Exclude<string, TLUiIconType>\n\tdisabled?: boolean\n\tclassName?: string\n}\n\n/**\n * An item in the select dropdown. Styled to match TldrawUiMenuCheckboxItem.\n *\n * @public\n * @react\n */\nexport function TldrawUiSelectItem({\n\tvalue,\n\tlabel,\n\ticon,\n\tdisabled,\n\tclassName,\n}: TLUiSelectItemProps) {\n\treturn (\n\t\t<_Select.Item\n\t\t\tvalue={value}\n\t\t\tdisabled={disabled}\n\t\t\tclassName={classNames(\n\t\t\t\t'tlui-button tlui-button__menu tlui-button__checkbox tlui-select__item',\n\t\t\t\tclassName\n\t\t\t)}\n\t\t>\n\t\t\t<TldrawUiIcon small icon=\"check\" label=\"\" className=\"tlui-select__item-indicator\" />\n\t\t\t{icon && <TldrawUiIcon icon={icon} label=\"\" small />}\n\t\t\t<_Select.ItemText className=\"tlui-button__label\">{label}</_Select.ItemText>\n\t\t</_Select.Item>\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgEG;AAhEH,oBAA6B;AAC7B,wBAAuB;AACvB,sBAAkC;AAClC,YAAuB;AACvB,2BAA8B;AAE9B,0BAA6B;AAoCtB,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,cAAc;AACf,GAAoB;AACnB,QAAM,CAAC,MAAM,gBAAgB,QAAI,oCAAc,IAAI,YAAY;AAE/D,SACC;AAAA,IAAC,gBAAAA,OAAQ;AAAA,IAAR;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA,KAAI;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA,eAAW,kBAAAC,SAAW,eAAe,SAAS;AAAA,UAC9C,eAAa;AAAA,UACb,cAAY;AAAA,UAEX;AAAA;AAAA,MACF;AAAA;AAAA,EACD;AAEF;AAgBO,MAAM,wBAAwB,MAAM;AAAA,EAC1C,SAASC,uBAAsB,EAAE,UAAU,UAAU,GAAG,KAAK;AAC5D,WACC;AAAA,MAAC,gBAAAF,OAAQ;AAAA,MAAR;AAAA,QACA;AAAA,QACA,eAAW,kBAAAC,SAAW,oCAAoC,SAAS;AAAA,QAElE;AAAA;AAAA,UACD,4CAAC,gBAAAD,OAAQ,MAAR,EAAa,WAAU,wBACvB,sDAAC,oCAAa,MAAK,gBAAe,OAAM,IAAG,OAAK,MAAC,GAClD;AAAA;AAAA;AAAA,IACD;AAAA,EAEF;AACD;AAiBO,SAAS,oBAAoB,EAAE,aAAa,MAAM,SAAS,GAAyB;AAC1F,SACC,4CAAC,gBAAAA,OAAQ,OAAR,EAAc,aACd,uDAAC,UAAK,WAAU,sBACd;AAAA,YAAQ,4CAAC,oCAAa,MAAY,OAAM,IAAG,OAAK,MAAC;AAAA,IAClD,4CAAC,UAAK,WAAU,sBAAsB,UAAS;AAAA,KAChD,GACD;AAEF;AAkBO,SAAS,sBAAsB;AAAA,EACrC;AAAA,EACA,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AACD,GAA2B;AAC1B,QAAM,gBAAY,4BAAa;AAE/B,SACC,4CAAC,gBAAAA,OAAQ,QAAR,EAAe,WACf;AAAA,IAAC,gBAAAA,OAAQ;AAAA,IAAR;AAAA,MACA,eAAW,kBAAAC,SAAW,kCAAkC,SAAS;AAAA,MACjE,UAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAElB,sDAAC,gBAAAD,OAAQ,UAAR,EAAiB,WAAU,yBAAyB,UAAS;AAAA;AAAA,EAC/D,GACD;AAEF;AAmBO,SAAS,mBAAmB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAwB;AACvB,SACC;AAAA,IAAC,gBAAAA,OAAQ;AAAA,IAAR;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAW,kBAAAC;AAAA,QACV;AAAA,QACA;AAAA,MACD;AAAA,MAEA;AAAA,oDAAC,oCAAa,OAAK,MAAC,MAAK,SAAQ,OAAM,IAAG,WAAU,+BAA8B;AAAA,QACjF,QAAQ,4CAAC,oCAAa,MAAY,OAAM,IAAG,OAAK,MAAC;AAAA,QAClD,4CAAC,gBAAAD,OAAQ,UAAR,EAAiB,WAAU,sBAAsB,iBAAM;AAAA;AAAA;AAAA,EACzD;AAEF;",
6
- "names": ["_Select", "classNames", "TldrawUiSelectTrigger"]
7
- }