@sentry/scraps 0.2.0 → 0.4.0

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 (114) hide show
  1. package/dist/button/buttonBar.js +7 -1
  2. package/dist/dragHandle/dragHandle.d.ts +34 -0
  3. package/dist/dragHandle/dragHandle.js +115 -0
  4. package/dist/dragHandle/index.d.ts +4 -0
  5. package/dist/dragHandle/index.js +4 -0
  6. package/dist/dragHandle/setDocumentDragging.d.ts +9 -0
  7. package/dist/dragHandle/setDocumentDragging.js +6 -0
  8. package/dist/dragHandle/useDragMove.d.ts +244 -0
  9. package/dist/dragHandle/useDragMove.js +66 -0
  10. package/dist/dragHandle/useDragSeparator.d.ts +256 -0
  11. package/dist/dragHandle/useDragSeparator.js +36 -0
  12. package/dist/formPresentation/autoSaveContext.d.ts +23 -0
  13. package/dist/formPresentation/autoSaveContext.js +13 -0
  14. package/dist/formPresentation/base.d.ts +11 -0
  15. package/dist/formPresentation/base.js +37 -0
  16. package/dist/formPresentation/displayField.d.ts +17 -0
  17. package/dist/formPresentation/displayField.js +69 -0
  18. package/dist/formPresentation/fieldIds.d.ts +3 -0
  19. package/dist/formPresentation/fieldIds.js +14 -0
  20. package/dist/formPresentation/fieldLayout.d.ts +23 -0
  21. package/dist/formPresentation/fieldLayout.js +76 -0
  22. package/dist/formPresentation/formContext.d.ts +4 -0
  23. package/dist/formPresentation/formContext.js +6 -0
  24. package/dist/formPresentation/groupContext.d.ts +24 -0
  25. package/dist/formPresentation/groupContext.js +22 -0
  26. package/dist/formPresentation/icons.d.ts +11 -0
  27. package/dist/formPresentation/icons.js +61 -0
  28. package/dist/formPresentation/index.d.ts +8 -0
  29. package/dist/formPresentation/index.js +8 -0
  30. package/dist/formPresentation/meta.d.ts +18 -0
  31. package/dist/formPresentation/meta.js +88 -0
  32. package/dist/formPresentation/useStackedLayout.d.ts +1 -0
  33. package/dist/formPresentation/useStackedLayout.js +9 -0
  34. package/dist/input/index.d.ts +8 -0
  35. package/dist/input/index.js +6 -0
  36. package/dist/input/input.d.ts +19 -0
  37. package/dist/input/input.js +14 -0
  38. package/dist/input/inputGroup.d.ts +29 -0
  39. package/dist/input/inputGroup.js +167 -0
  40. package/dist/input/inputStyles.d.ts +13 -0
  41. package/dist/input/inputStyles.js +52 -0
  42. package/dist/input/numberDragInput.d.ts +20 -0
  43. package/dist/input/numberDragInput.js +97 -0
  44. package/dist/input/numberInput.d.ts +10 -0
  45. package/dist/input/numberInput.js +94 -0
  46. package/dist/input/otpInput.d.ts +28 -0
  47. package/dist/input/otpInput.js +81 -0
  48. package/dist/input/useAutosizeInput.d.ts +17 -0
  49. package/dist/input/useAutosizeInput.js +56 -0
  50. package/dist/layout/styles.d.ts +1 -1
  51. package/dist/menu/controlContext.d.ts +32 -0
  52. package/dist/menu/controlContext.js +7 -0
  53. package/dist/menu/dropdownButton.d.ts +18 -0
  54. package/dist/menu/dropdownButton.js +66 -0
  55. package/dist/menu/index.d.ts +7 -0
  56. package/dist/menu/index.js +3 -0
  57. package/dist/menu/menu.d.ts +159 -0
  58. package/dist/menu/menu.js +464 -0
  59. package/dist/menu/selectTypes.d.ts +96 -0
  60. package/dist/menu/selectTypes.js +0 -0
  61. package/dist/menu/selectValue.d.ts +13 -0
  62. package/dist/menu/selectValue.js +0 -0
  63. package/dist/overlayPositioning.d.ts +10 -1
  64. package/dist/overlayPositioning.js +15 -2
  65. package/dist/overlayTrigger.d.ts +22 -0
  66. package/dist/overlayTrigger.js +30 -0
  67. package/dist/slot/knownContexts.d.ts +1 -1
  68. package/dist/spinner/index.d.ts +1 -0
  69. package/dist/spinner/index.js +1 -0
  70. package/dist/spinner/spinner.d.ts +14 -0
  71. package/dist/spinner/spinner.js +126 -0
  72. package/dist/splitPanel/index.d.ts +1 -0
  73. package/dist/splitPanel/index.js +1 -0
  74. package/dist/splitPanel/splitPanel.d.ts +36 -0
  75. package/dist/splitPanel/splitPanel.js +144 -0
  76. package/dist/table/index.d.ts +3 -0
  77. package/dist/table/index.js +3 -0
  78. package/dist/table/sortableHeaderCell.d.ts +36 -0
  79. package/dist/table/sortableHeaderCell.js +99 -0
  80. package/dist/table/styles.d.ts +46 -0
  81. package/dist/table/styles.js +93 -0
  82. package/dist/table/table.d.ts +64 -0
  83. package/dist/table/table.js +228 -0
  84. package/dist/table/useColumnResize.d.ts +27 -0
  85. package/dist/table/useColumnResize.js +62 -0
  86. package/dist/table/useObservedColumnSize.d.ts +12 -0
  87. package/dist/table/useObservedColumnSize.js +74 -0
  88. package/dist/text/heading.d.ts +1 -1
  89. package/dist/text/text.d.ts +7 -0
  90. package/dist/text/text.js +1 -1
  91. package/dist/textarea/index.d.ts +1 -0
  92. package/dist/textarea/index.js +1 -0
  93. package/dist/textarea/textarea.d.ts +22 -0
  94. package/dist/textarea/textarea.js +77 -0
  95. package/dist/toast/index.d.ts +5 -0
  96. package/dist/toast/index.js +4 -0
  97. package/dist/toast/toast.d.ts +10 -0
  98. package/dist/toast/toast.js +182 -0
  99. package/dist/toast/toastApi.d.ts +10 -0
  100. package/dist/toast/toastApi.js +53 -0
  101. package/dist/toast/toaster.d.ts +4 -0
  102. package/dist/toast/toaster.js +42 -0
  103. package/dist/toast/types.d.ts +17 -0
  104. package/dist/toast/types.js +2 -0
  105. package/dist/toggleCard/index.d.ts +1 -0
  106. package/dist/toggleCard/index.js +1 -0
  107. package/dist/toggleCard/toggleCard.d.ts +32 -0
  108. package/dist/toggleCard/toggleCard.js +301 -0
  109. package/dist/useDimensions.d.ts +12 -0
  110. package/dist/useDimensions.js +31 -0
  111. package/dist/useOverlay.js +2 -1
  112. package/dist/useResizableDrawer.d.ts +72 -0
  113. package/dist/useResizableDrawer.js +136 -0
  114. package/package.json +60 -1
@@ -27,7 +27,13 @@ const ButtonBar = styled(({ children, orientation = 'horizontal', size, ...props
27
27
  & > button,
28
28
  & > input,
29
29
  & > a {
30
- position: relative;
30
+ /* Dropdown menu wrappers use display: contents, so they never form a
31
+ containing block. Positioning them anyway makes Floating UI clamp the
32
+ menu's max-height to clipping ancestors it can actually escape, such as
33
+ table header cells. */
34
+ &:not([role='presentation']) {
35
+ position: relative;
36
+ }
31
37
 
32
38
  ${(p)=>'vertical' === p.orientation ? css`
33
39
  /* First button is square on the bottom side */
@@ -0,0 +1,34 @@
1
+ import type * as React from 'react';
2
+ export type Orientation = 'horizontal' | 'vertical';
3
+ export type DragHandleVariant = 'solid' | 'ghost';
4
+ export declare const DRAG_HANDLE_SIZE = 1;
5
+ /** The 24x24 CSS pixel minimum that WCAG 2.5.8 asks of a pointer target. */
6
+ export declare const DRAG_SEPARATOR_TARGET_SIZE = 24;
7
+ /**
8
+ * A focusable `separator` is a widget, so it needs a name, or it is announced as a bare
9
+ * value with no subject. Prefer `aria-labelledby` when the handle sits inside an element
10
+ * that is named from its content, such as a table header cell: an `aria-label` there
11
+ * would also become part of that element's own name.
12
+ */
13
+ type DragHandleNameProps = {
14
+ 'aria-label': string;
15
+ 'aria-labelledby'?: never;
16
+ } | {
17
+ 'aria-labelledby': string;
18
+ 'aria-label'?: never;
19
+ };
20
+ export type DragHandleProps = DragHandleNameProps & {
21
+ isSizedFirst: boolean;
22
+ max: number;
23
+ min: number;
24
+ onDoubleClick: React.MouseEventHandler<HTMLElement>;
25
+ onMove: (delta: number) => void;
26
+ orientation: Orientation;
27
+ value: number;
28
+ onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
29
+ onMoveEnd?: () => void;
30
+ onMoveStart?: () => void;
31
+ variant?: DragHandleVariant;
32
+ };
33
+ export declare function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, variant, isSizedFirst, max, min, orientation, value, onDoubleClick, onKeyDown, onMove, onMoveEnd, onMoveStart, }: DragHandleProps): import("@emotion/react/jsx-runtime").JSX.Element;
34
+ export {};
@@ -0,0 +1,115 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { mergeProps } from "@react-aria/utils";
4
+ import { Container } from "../layout/index.js";
5
+ import { useDragSeparator } from "./useDragSeparator.js";
6
+ const DRAG_HANDLE_SIZE = 1;
7
+ const DRAG_SEPARATOR_TARGET_SIZE = 24;
8
+ const targetLength = 'var(--drag-separator-target-length, none)';
9
+ const targetOffset = `calc(50% - ${DRAG_SEPARATOR_TARGET_SIZE / 2}px)`;
10
+ function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, variant = 'solid', isSizedFirst, max, min, orientation, value, onDoubleClick, onKeyDown, onMove, onMoveEnd, onMoveStart }) {
11
+ const { cursor, separatorProps } = useDragSeparator({
12
+ isSizedFirst,
13
+ max,
14
+ min,
15
+ onMove,
16
+ onMoveEnd,
17
+ onMoveStart,
18
+ orientation,
19
+ value
20
+ });
21
+ return /*#__PURE__*/ jsx(Container, {
22
+ position: "relative",
23
+ flexShrink: 0,
24
+ children: (containerProps)=>/*#__PURE__*/ jsx(DragHandleLine, {
25
+ ...mergeProps(separatorProps, containerProps, {
26
+ onDoubleClick,
27
+ onKeyDown
28
+ }),
29
+ $cursor: cursor,
30
+ "aria-label": ariaLabel,
31
+ "aria-labelledby": ariaLabelledby,
32
+ "data-variant": variant
33
+ })
34
+ });
35
+ }
36
+ const DragHandleLine = styled('div')`
37
+ user-select: none;
38
+ touch-action: none;
39
+ pointer-events: none;
40
+
41
+ /* Invisible wider hit area for dragging, and the only part that takes pointer events */
42
+ &::before {
43
+ content: '';
44
+ position: absolute;
45
+ z-index: ${(p)=>p.theme.zIndex.drawer};
46
+ pointer-events: auto;
47
+ cursor: ${(p)=>p.$cursor};
48
+ }
49
+
50
+ /* Accent bar that lights up on hover/drag */
51
+ &::after {
52
+ content: '';
53
+ position: absolute;
54
+ z-index: ${(p)=>p.theme.zIndex.drawer};
55
+ opacity: 0.8;
56
+ background: transparent;
57
+ transition: background ${(p)=>p.theme.motion.smooth.slow};
58
+ }
59
+
60
+ &:hover::after,
61
+ &[data-is-held='true']::after {
62
+ background: ${(p)=>p.theme.tokens.graphics.accent.vibrant};
63
+ }
64
+
65
+ &[data-orientation='horizontal'] {
66
+ width: 0;
67
+ height: auto;
68
+ align-self: stretch;
69
+ border-left: 1px solid ${(p)=>p.theme.tokens.border.primary};
70
+
71
+ &::before {
72
+ inset: 0 auto 0 ${targetOffset};
73
+ width: ${DRAG_SEPARATOR_TARGET_SIZE}px;
74
+ max-height: ${targetLength};
75
+ }
76
+
77
+ &::after {
78
+ inset: 0 auto 0 -2px;
79
+ width: 4px;
80
+ }
81
+ }
82
+
83
+ &[data-orientation='vertical'] {
84
+ width: 100%;
85
+ height: 0;
86
+ border-top: 1px solid ${(p)=>p.theme.tokens.border.primary};
87
+
88
+ &::before {
89
+ inset: ${targetOffset} 0 auto 0;
90
+ height: ${DRAG_SEPARATOR_TARGET_SIZE}px;
91
+ max-width: ${targetLength};
92
+ }
93
+
94
+ &::after {
95
+ inset: -2px 0 auto 0;
96
+ height: 4px;
97
+ }
98
+ }
99
+
100
+ &[data-variant='ghost'] {
101
+ border-color: transparent;
102
+ transition: border-color ${(p)=>p.theme.motion.smooth.slow};
103
+
104
+ &:hover,
105
+ &:focus-visible,
106
+ &[data-is-held='true'] {
107
+ border-color: ${(p)=>p.theme.tokens.border.primary};
108
+ }
109
+ }
110
+
111
+ &:focus-visible {
112
+ outline: 2px solid ${(p)=>p.theme.tokens.focus.default};
113
+ }
114
+ `;
115
+ export { DRAG_HANDLE_SIZE, DRAG_SEPARATOR_TARGET_SIZE, DragHandle };
@@ -0,0 +1,4 @@
1
+ export { DragHandle, type DragHandleProps, type DragHandleVariant, type Orientation, DRAG_HANDLE_SIZE, DRAG_SEPARATOR_TARGET_SIZE, } from './dragHandle.js';
2
+ export { useDragMove } from './useDragMove.js';
3
+ export { useDragSeparator } from './useDragSeparator.js';
4
+ export { setDocumentDragging } from './setDocumentDragging.js';
@@ -0,0 +1,4 @@
1
+ export { DRAG_HANDLE_SIZE, DRAG_SEPARATOR_TARGET_SIZE, DragHandle } from "./dragHandle.js";
2
+ export { useDragMove } from "./useDragMove.js";
3
+ export { useDragSeparator } from "./useDragSeparator.js";
4
+ export { setDocumentDragging } from "./setDocumentDragging.js";
@@ -0,0 +1,9 @@
1
+ import type { CSS } from '../cssTypes.js';
2
+ /**
3
+ * Locks the document for the duration of a drag, or releases it when passed `null`.
4
+ *
5
+ * A drag travels outside the element that started it, so suppressing hover and text
6
+ * selection — and holding the resize cursor — has to happen at the document level.
7
+ * The cursor goes on the root element because pointer events are disabled on `body`.
8
+ */
9
+ export declare function setDocumentDragging(cursor: CSS['cursor'] | null): void;
@@ -0,0 +1,6 @@
1
+ function setDocumentDragging(cursor) {
2
+ document.body.style.pointerEvents = cursor ? 'none' : '';
3
+ document.body.style.userSelect = cursor ? 'none' : '';
4
+ document.documentElement.style.cursor = cursor ?? '';
5
+ }
6
+ export { setDocumentDragging };
@@ -0,0 +1,244 @@
1
+ import type * as React from 'react';
2
+ import type { Orientation } from './dragHandle.js';
3
+ interface UseDragMoveOptions {
4
+ onMove: (delta: number) => void;
5
+ orientation: Orientation;
6
+ onMoveEnd?: () => void;
7
+ onMoveStart?: () => void;
8
+ }
9
+ export declare function useDragMove({ onMove, onMoveEnd, onMoveStart, orientation, }: UseDragMoveOptions): {
10
+ isHeld: boolean;
11
+ moveProps: {
12
+ onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
13
+ id?: string | undefined;
14
+ role?: React.AriaRole | undefined;
15
+ tabIndex?: number | undefined;
16
+ style?: React.CSSProperties | undefined;
17
+ className?: string | undefined;
18
+ "aria-activedescendant"?: string | undefined;
19
+ "aria-atomic"?: (boolean | "true" | "false") | undefined;
20
+ "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
21
+ "aria-braillelabel"?: string | undefined;
22
+ "aria-brailleroledescription"?: string | undefined;
23
+ "aria-busy"?: (boolean | "true" | "false") | undefined;
24
+ "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
25
+ "aria-colcount"?: number | undefined;
26
+ "aria-colindex"?: number | undefined;
27
+ "aria-colindextext"?: string | undefined;
28
+ "aria-colspan"?: number | undefined;
29
+ "aria-controls"?: string | undefined;
30
+ "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
31
+ "aria-describedby"?: string | undefined;
32
+ "aria-description"?: string | undefined;
33
+ "aria-details"?: string | undefined;
34
+ "aria-disabled"?: (boolean | "true" | "false") | undefined;
35
+ "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
36
+ "aria-errormessage"?: string | undefined;
37
+ "aria-expanded"?: (boolean | "true" | "false") | undefined;
38
+ "aria-flowto"?: string | undefined;
39
+ "aria-grabbed"?: (boolean | "true" | "false") | undefined;
40
+ "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
41
+ "aria-hidden"?: (boolean | "true" | "false") | undefined;
42
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
43
+ "aria-keyshortcuts"?: string | undefined;
44
+ "aria-label"?: string | undefined;
45
+ "aria-labelledby"?: string | undefined;
46
+ "aria-level"?: number | undefined;
47
+ "aria-live"?: "off" | "assertive" | "polite" | undefined;
48
+ "aria-modal"?: (boolean | "true" | "false") | undefined;
49
+ "aria-multiline"?: (boolean | "true" | "false") | undefined;
50
+ "aria-multiselectable"?: (boolean | "true" | "false") | undefined;
51
+ "aria-orientation"?: "horizontal" | "vertical" | undefined;
52
+ "aria-owns"?: string | undefined;
53
+ "aria-placeholder"?: string | undefined;
54
+ "aria-posinset"?: number | undefined;
55
+ "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
56
+ "aria-readonly"?: (boolean | "true" | "false") | undefined;
57
+ "aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
58
+ "aria-required"?: (boolean | "true" | "false") | undefined;
59
+ "aria-roledescription"?: string | undefined;
60
+ "aria-rowcount"?: number | undefined;
61
+ "aria-rowindex"?: number | undefined;
62
+ "aria-rowindextext"?: string | undefined;
63
+ "aria-rowspan"?: number | undefined;
64
+ "aria-selected"?: (boolean | "true" | "false") | undefined;
65
+ "aria-setsize"?: number | undefined;
66
+ "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
67
+ "aria-valuemax"?: number | undefined;
68
+ "aria-valuemin"?: number | undefined;
69
+ "aria-valuenow"?: number | undefined;
70
+ "aria-valuetext"?: string | undefined;
71
+ children?: React.ReactNode | undefined;
72
+ dangerouslySetInnerHTML?: {
73
+ __html: string | TrustedHTML;
74
+ } | undefined;
75
+ onCopy?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
76
+ onCopyCapture?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
77
+ onCut?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
78
+ onCutCapture?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
79
+ onPaste?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
80
+ onPasteCapture?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
81
+ onCompositionEnd?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
82
+ onCompositionEndCapture?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
83
+ onCompositionStart?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
84
+ onCompositionStartCapture?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
85
+ onCompositionUpdate?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
86
+ onCompositionUpdateCapture?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
87
+ onFocus?: React.FocusEventHandler<import("@react-types/shared").FocusableElement> | undefined;
88
+ onFocusCapture?: React.FocusEventHandler<import("@react-types/shared").FocusableElement> | undefined;
89
+ onBlur?: React.FocusEventHandler<import("@react-types/shared").FocusableElement> | undefined;
90
+ onBlurCapture?: React.FocusEventHandler<import("@react-types/shared").FocusableElement> | undefined;
91
+ onChange?: React.ChangeEventHandler<import("@react-types/shared").FocusableElement, Element> | undefined;
92
+ onChangeCapture?: React.ChangeEventHandler<import("@react-types/shared").FocusableElement, Element> | undefined;
93
+ onBeforeInput?: React.InputEventHandler<import("@react-types/shared").FocusableElement> | undefined;
94
+ onBeforeInputCapture?: React.InputEventHandler<import("@react-types/shared").FocusableElement> | undefined;
95
+ onInput?: React.InputEventHandler<import("@react-types/shared").FocusableElement> | undefined;
96
+ onInputCapture?: React.InputEventHandler<import("@react-types/shared").FocusableElement> | undefined;
97
+ onReset?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
98
+ onResetCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
99
+ onSubmit?: React.SubmitEventHandler<import("@react-types/shared").FocusableElement> | undefined;
100
+ onSubmitCapture?: React.SubmitEventHandler<import("@react-types/shared").FocusableElement> | undefined;
101
+ onInvalid?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
102
+ onInvalidCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
103
+ onLoad?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
104
+ onLoadCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
105
+ onError?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
106
+ onErrorCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
107
+ onKeyDownCapture?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
108
+ onKeyPress?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
109
+ onKeyPressCapture?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
110
+ onKeyUp?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
111
+ onKeyUpCapture?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
112
+ onAbort?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
113
+ onAbortCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
114
+ onCanPlay?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
115
+ onCanPlayCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
116
+ onCanPlayThrough?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
117
+ onCanPlayThroughCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
118
+ onDurationChange?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
119
+ onDurationChangeCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
120
+ onEmptied?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
121
+ onEmptiedCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
122
+ onEncrypted?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
123
+ onEncryptedCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
124
+ onEnded?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
125
+ onEndedCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
126
+ onLoadedData?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
127
+ onLoadedDataCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
128
+ onLoadedMetadata?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
129
+ onLoadedMetadataCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
130
+ onLoadStart?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
131
+ onLoadStartCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
132
+ onPause?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
133
+ onPauseCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
134
+ onPlay?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
135
+ onPlayCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
136
+ onPlaying?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
137
+ onPlayingCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
138
+ onProgress?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
139
+ onProgressCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
140
+ onRateChange?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
141
+ onRateChangeCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
142
+ onSeeked?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
143
+ onSeekedCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
144
+ onSeeking?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
145
+ onSeekingCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
146
+ onStalled?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
147
+ onStalledCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
148
+ onSuspend?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
149
+ onSuspendCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
150
+ onTimeUpdate?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
151
+ onTimeUpdateCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
152
+ onVolumeChange?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
153
+ onVolumeChangeCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
154
+ onWaiting?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
155
+ onWaitingCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
156
+ onAuxClick?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
157
+ onAuxClickCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
158
+ onClick?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
159
+ onClickCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
160
+ onContextMenu?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
161
+ onContextMenuCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
162
+ onDoubleClick?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
163
+ onDoubleClickCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
164
+ onDrag?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
165
+ onDragCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
166
+ onDragEnd?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
167
+ onDragEndCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
168
+ onDragEnter?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
169
+ onDragEnterCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
170
+ onDragExit?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
171
+ onDragExitCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
172
+ onDragLeave?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
173
+ onDragLeaveCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
174
+ onDragOver?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
175
+ onDragOverCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
176
+ onDragStart?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
177
+ onDragStartCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
178
+ onDrop?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
179
+ onDropCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
180
+ onMouseDown?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
181
+ onMouseDownCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
182
+ onMouseEnter?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
183
+ onMouseLeave?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
184
+ onMouseMove?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
185
+ onMouseMoveCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
186
+ onMouseOut?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
187
+ onMouseOutCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
188
+ onMouseOver?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
189
+ onMouseOverCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
190
+ onMouseUp?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
191
+ onMouseUpCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
192
+ onSelect?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
193
+ onSelectCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
194
+ onTouchCancel?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
195
+ onTouchCancelCapture?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
196
+ onTouchEnd?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
197
+ onTouchEndCapture?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
198
+ onTouchMove?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
199
+ onTouchMoveCapture?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
200
+ onTouchStart?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
201
+ onTouchStartCapture?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
202
+ onPointerDown?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
203
+ onPointerDownCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
204
+ onPointerMove?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
205
+ onPointerMoveCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
206
+ onPointerUp?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
207
+ onPointerUpCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
208
+ onPointerCancel?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
209
+ onPointerCancelCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
210
+ onPointerEnter?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
211
+ onPointerLeave?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
212
+ onPointerOver?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
213
+ onPointerOverCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
214
+ onPointerOut?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
215
+ onPointerOutCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
216
+ onGotPointerCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
217
+ onGotPointerCaptureCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
218
+ onLostPointerCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
219
+ onLostPointerCaptureCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
220
+ onScroll?: React.UIEventHandler<import("@react-types/shared").FocusableElement> | undefined;
221
+ onScrollCapture?: React.UIEventHandler<import("@react-types/shared").FocusableElement> | undefined;
222
+ onScrollEnd?: React.UIEventHandler<import("@react-types/shared").FocusableElement> | undefined;
223
+ onScrollEndCapture?: React.UIEventHandler<import("@react-types/shared").FocusableElement> | undefined;
224
+ onWheel?: React.WheelEventHandler<import("@react-types/shared").FocusableElement> | undefined;
225
+ onWheelCapture?: React.WheelEventHandler<import("@react-types/shared").FocusableElement> | undefined;
226
+ onAnimationStart?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
227
+ onAnimationStartCapture?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
228
+ onAnimationEnd?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
229
+ onAnimationEndCapture?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
230
+ onAnimationIteration?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
231
+ onAnimationIterationCapture?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
232
+ onToggle?: React.ToggleEventHandler<import("@react-types/shared").FocusableElement> | undefined;
233
+ onBeforeToggle?: React.ToggleEventHandler<import("@react-types/shared").FocusableElement> | undefined;
234
+ onTransitionCancel?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
235
+ onTransitionCancelCapture?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
236
+ onTransitionEnd?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
237
+ onTransitionEndCapture?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
238
+ onTransitionRun?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
239
+ onTransitionRunCapture?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
240
+ onTransitionStart?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
241
+ onTransitionStartCapture?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
242
+ };
243
+ };
244
+ export {};
@@ -0,0 +1,66 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { useMove } from "@react-aria/interactions";
3
+ import { setDocumentDragging } from "./setDocumentDragging.js";
4
+ const KEYBOARD_STEP = 10;
5
+ const KEYBOARD_STEP_LARGE = 50;
6
+ const AXIS_KEYS = {
7
+ horizontal: new Set([
8
+ 'ArrowLeft',
9
+ 'ArrowRight',
10
+ 'Left',
11
+ 'Right'
12
+ ]),
13
+ vertical: new Set([
14
+ 'ArrowUp',
15
+ 'ArrowDown',
16
+ 'Up',
17
+ 'Down'
18
+ ])
19
+ };
20
+ function useDragMove({ onMove, onMoveEnd, onMoveStart, orientation }) {
21
+ const [isHeld, setIsHeld] = useState(false);
22
+ const isPointerDragRef = useRef(false);
23
+ const stopDocumentDragging = useCallback(()=>{
24
+ if (isPointerDragRef.current) {
25
+ isPointerDragRef.current = false;
26
+ setDocumentDragging(null);
27
+ }
28
+ }, []);
29
+ useEffect(()=>stopDocumentDragging, [
30
+ stopDocumentDragging
31
+ ]);
32
+ const { moveProps } = useMove({
33
+ onMoveStart: (event)=>{
34
+ setIsHeld(true);
35
+ if ('keyboard' !== event.pointerType) {
36
+ isPointerDragRef.current = true;
37
+ setDocumentDragging('horizontal' === orientation ? 'ew-resize' : 'ns-resize');
38
+ }
39
+ onMoveStart?.();
40
+ },
41
+ onMove: (event)=>{
42
+ const delta = 'horizontal' === orientation ? event.deltaX : event.deltaY;
43
+ if (!delta) return;
44
+ onMove('keyboard' === event.pointerType ? Math.sign(delta) * (event.shiftKey ? KEYBOARD_STEP_LARGE : KEYBOARD_STEP) : delta);
45
+ },
46
+ onMoveEnd: ()=>{
47
+ setIsHeld(false);
48
+ stopDocumentDragging();
49
+ onMoveEnd?.();
50
+ }
51
+ });
52
+ const axisMoveProps = useMemo(()=>({
53
+ ...moveProps,
54
+ onKeyDown: (event)=>{
55
+ if (AXIS_KEYS[orientation].has(event.key)) moveProps.onKeyDown?.(event);
56
+ }
57
+ }), [
58
+ moveProps,
59
+ orientation
60
+ ]);
61
+ return {
62
+ isHeld,
63
+ moveProps: axisMoveProps
64
+ };
65
+ }
66
+ export { useDragMove };