@helpdice/draggable 0.0.0-stage → 0.0.2
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/LICENSE +13 -0
- package/README.md +164 -2
- package/dist/draggable.cjs.js +9925 -0
- package/dist/draggable.cjs.js.map +1 -0
- package/dist/draggable.esm.js +9899 -0
- package/dist/draggable.esm.js.map +1 -0
- package/dist/types/animation.d.ts +31 -0
- package/dist/types/debug/middleware/action-timing-average.d.ts +3 -0
- package/dist/types/debug/middleware/action-timing.d.ts +3 -0
- package/dist/types/debug/middleware/log.d.ts +4 -0
- package/dist/types/debug/middleware/user-timing.d.ts +3 -0
- package/dist/types/debug/timings.d.ts +3 -0
- package/dist/types/dev-warning.d.ts +4 -0
- package/dist/types/empty.d.ts +2 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/invariant.d.ts +4 -0
- package/dist/types/native-with-fallback.d.ts +10 -0
- package/dist/types/screen-reader-message-preset.d.ts +9 -0
- package/dist/types/state/action-creators.d.ts +158 -0
- package/dist/types/state/auto-scroller/auto-scroller-types.d.ts +6 -0
- package/dist/types/state/auto-scroller/can-scroll.d.ts +19 -0
- package/dist/types/state/auto-scroller/fluid-scroller/config.d.ts +11 -0
- package/dist/types/state/auto-scroller/fluid-scroller/did-start-in-scrollable-area.d.ts +0 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-best-scrollable-droppable.d.ts +9 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-droppable-scroll-change.d.ts +11 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-percentage.d.ts +7 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/adjust-for-size-limits.d.ts +8 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/dampen-value-by-time.d.ts +2 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-distance-thresholds.d.ts +8 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-value-from-distance.d.ts +3 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-value.d.ts +9 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/index.d.ts +11 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/min-scroll.d.ts +2 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/index.d.ts +10 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-window-scroll-change.d.ts +11 -0
- package/dist/types/state/auto-scroller/fluid-scroller/index.d.ts +13 -0
- package/dist/types/state/auto-scroller/fluid-scroller/scroll.d.ts +11 -0
- package/dist/types/state/auto-scroller/index.d.ts +11 -0
- package/dist/types/state/auto-scroller/jump-scroller.d.ts +11 -0
- package/dist/types/state/axis.d.ts +3 -0
- package/dist/types/state/calculate-drag-impact/calculate-reorder-impact.d.ts +13 -0
- package/dist/types/state/can-start-drag.d.ts +3 -0
- package/dist/types/state/create-store.d.ts +16 -0
- package/dist/types/state/did-start-after-critical.d.ts +2 -0
- package/dist/types/state/dimension-marshal/dimension-marshal-types.d.ts +23 -0
- package/dist/types/state/dimension-marshal/dimension-marshal.d.ts +4 -0
- package/dist/types/state/dimension-marshal/get-initial-publish.d.ts +10 -0
- package/dist/types/state/dimension-marshal/while-dragging-publisher.d.ts +17 -0
- package/dist/types/state/dimension-structures.d.ts +5 -0
- package/dist/types/state/droppable/get-droppable.d.ts +21 -0
- package/dist/types/state/droppable/is-home-of.d.ts +3 -0
- package/dist/types/state/droppable/scroll-droppable.d.ts +4 -0
- package/dist/types/state/droppable/should-use-placeholder.d.ts +3 -0
- package/dist/types/state/droppable/util/clip.d.ts +3 -0
- package/dist/types/state/droppable/util/get-subject.d.ts +10 -0
- package/dist/types/state/droppable/what-is-dragged-over-from-result.d.ts +3 -0
- package/dist/types/state/droppable/what-is-dragged-over.d.ts +3 -0
- package/dist/types/state/droppable/with-placeholder.d.ts +3 -0
- package/dist/types/state/get-center-from-impact/get-client-border-box-center/get-client-from-page-border-box-center.d.ts +9 -0
- package/dist/types/state/get-center-from-impact/get-client-border-box-center/index.d.ts +12 -0
- package/dist/types/state/get-center-from-impact/get-page-border-box-center/index.d.ts +11 -0
- package/dist/types/state/get-center-from-impact/get-page-border-box-center/when-combining.d.ts +9 -0
- package/dist/types/state/get-center-from-impact/get-page-border-box-center/when-reordering.d.ts +11 -0
- package/dist/types/state/get-center-from-impact/move-relative-to.d.ts +16 -0
- package/dist/types/state/get-combined-item-displacement.d.ts +10 -0
- package/dist/types/state/get-displaced-by.d.ts +4 -0
- package/dist/types/state/get-displacement-groups.d.ts +12 -0
- package/dist/types/state/get-drag-impact/get-combine-impact.d.ts +13 -0
- package/dist/types/state/get-drag-impact/get-reorder-impact.d.ts +13 -0
- package/dist/types/state/get-drag-impact/index.d.ts +13 -0
- package/dist/types/state/get-draggables-inside-droppable.d.ts +3 -0
- package/dist/types/state/get-droppable-over.d.ts +9 -0
- package/dist/types/state/get-frame.d.ts +3 -0
- package/dist/types/state/get-home-location.d.ts +3 -0
- package/dist/types/state/get-impact-location.d.ts +3 -0
- package/dist/types/state/get-is-displaced.d.ts +7 -0
- package/dist/types/state/get-lift-effect.d.ts +13 -0
- package/dist/types/state/get-max-scroll.d.ts +9 -0
- package/dist/types/state/is-movement-allowed.d.ts +2 -0
- package/dist/types/state/is-within.d.ts +2 -0
- package/dist/types/state/middleware/auto-scroll.d.ts +4 -0
- package/dist/types/state/middleware/dimension-marshal-stopper.d.ts +4 -0
- package/dist/types/state/middleware/drop/drop-animation-finish-middleware.d.ts +3 -0
- package/dist/types/state/middleware/drop/drop-animation-flush-on-scroll-middleware.d.ts +3 -0
- package/dist/types/state/middleware/drop/drop-middleware.d.ts +3 -0
- package/dist/types/state/middleware/drop/get-drop-duration.d.ts +9 -0
- package/dist/types/state/middleware/drop/get-drop-impact.d.ts +16 -0
- package/dist/types/state/middleware/drop/get-new-home-client-offset.d.ts +11 -0
- package/dist/types/state/middleware/drop/index.d.ts +1 -0
- package/dist/types/state/middleware/focus.d.ts +4 -0
- package/dist/types/state/middleware/lift.d.ts +4 -0
- package/dist/types/state/middleware/pending-drop.d.ts +3 -0
- package/dist/types/state/middleware/responders/async-marshal.d.ts +9 -0
- package/dist/types/state/middleware/responders/expiring-announce.d.ts +6 -0
- package/dist/types/state/middleware/responders/index.d.ts +1 -0
- package/dist/types/state/middleware/responders/is-equal.d.ts +4 -0
- package/dist/types/state/middleware/responders/publisher.d.ts +17 -0
- package/dist/types/state/middleware/responders/responders-middleware.d.ts +4 -0
- package/dist/types/state/middleware/scroll-listener.d.ts +3 -0
- package/dist/types/state/middleware/style.d.ts +4 -0
- package/dist/types/state/middleware/util/validate-dimensions.d.ts +2 -0
- package/dist/types/state/move-in-direction/index.d.ts +8 -0
- package/dist/types/state/move-in-direction/move-cross-axis/get-best-cross-axis-droppable.d.ts +11 -0
- package/dist/types/state/move-in-direction/move-cross-axis/get-closest-draggable.d.ts +11 -0
- package/dist/types/state/move-in-direction/move-cross-axis/index.d.ts +15 -0
- package/dist/types/state/move-in-direction/move-cross-axis/move-to-new-droppable.d.ts +14 -0
- package/dist/types/state/move-in-direction/move-cross-axis/without-starting-displacement.d.ts +4 -0
- package/dist/types/state/move-in-direction/move-in-direction-types.d.ts +7 -0
- package/dist/types/state/move-in-direction/move-to-next-place/index.d.ts +16 -0
- package/dist/types/state/move-in-direction/move-to-next-place/is-totally-visible-in-new-location.d.ts +12 -0
- package/dist/types/state/move-in-direction/move-to-next-place/move-to-next-combine/index.d.ts +10 -0
- package/dist/types/state/move-in-direction/move-to-next-place/move-to-next-index/from-combine.d.ts +11 -0
- package/dist/types/state/move-in-direction/move-to-next-place/move-to-next-index/from-reorder.d.ts +9 -0
- package/dist/types/state/move-in-direction/move-to-next-place/move-to-next-index/index.d.ts +14 -0
- package/dist/types/state/no-impact.d.ts +6 -0
- package/dist/types/state/patch-dimension-map.d.ts +3 -0
- package/dist/types/state/patch-droppable-map.d.ts +3 -0
- package/dist/types/state/position.d.ts +10 -0
- package/dist/types/state/post-reducer/when-moving/refresh-snap.d.ts +8 -0
- package/dist/types/state/post-reducer/when-moving/update.d.ts +12 -0
- package/dist/types/state/publish-while-dragging-in-virtual/adjust-additions-for-scroll-changes.d.ts +8 -0
- package/dist/types/state/publish-while-dragging-in-virtual/index.d.ts +7 -0
- package/dist/types/state/publish-while-dragging-in-virtual/offset-draggable.d.ts +9 -0
- package/dist/types/state/recompute-placeholders.d.ts +10 -0
- package/dist/types/state/rect.d.ts +2 -0
- package/dist/types/state/reducer.d.ts +5 -0
- package/dist/types/state/registry/create-registry.d.ts +2 -0
- package/dist/types/state/registry/registry-types.d.ts +62 -0
- package/dist/types/state/registry/use-registry.d.ts +2 -0
- package/dist/types/state/remove-draggable-from-list.d.ts +3 -0
- package/dist/types/state/scroll-viewport.d.ts +4 -0
- package/dist/types/state/spacing.d.ts +6 -0
- package/dist/types/state/store-types.d.ts +10 -0
- package/dist/types/state/update-displacement-visibility/recompute.d.ts +10 -0
- package/dist/types/state/update-displacement-visibility/speculatively-increase.d.ts +11 -0
- package/dist/types/state/visibility/is-partially-visible-through-frame.d.ts +3 -0
- package/dist/types/state/visibility/is-position-in-frame.d.ts +2 -0
- package/dist/types/state/visibility/is-totally-visible-through-frame-on-axis.d.ts +4 -0
- package/dist/types/state/visibility/is-totally-visible-through-frame.d.ts +3 -0
- package/dist/types/state/visibility/is-visible.d.ts +13 -0
- package/dist/types/state/with-scroll-change/with-all-displacement.d.ts +4 -0
- package/dist/types/state/with-scroll-change/with-droppable-displacement.d.ts +4 -0
- package/dist/types/state/with-scroll-change/with-droppable-scroll.d.ts +4 -0
- package/dist/types/state/with-scroll-change/with-viewport-displacement.d.ts +4 -0
- package/dist/types/types.d.ts +323 -0
- package/dist/types/view/animate-in-out/animate-in-out.d.ts +24 -0
- package/dist/types/view/animate-in-out/index.d.ts +1 -0
- package/dist/types/view/check-is-valid-inner-ref.d.ts +1 -0
- package/dist/types/view/context/app-context.d.ts +16 -0
- package/dist/types/view/context/droppable-context.d.ts +9 -0
- package/dist/types/view/context/hooks.d.ts +3 -0
- package/dist/types/view/context/store-context.d.ts +4 -0
- package/dist/types/view/data-attributes.d.ts +22 -0
- package/dist/types/view/drag-drop-context/app.d.ts +13 -0
- package/dist/types/view/drag-drop-context/check-doctype.d.ts +2 -0
- package/dist/types/view/drag-drop-context/check-react-version.d.ts +2 -0
- package/dist/types/view/drag-drop-context/drag-drop-context-types.d.ts +5 -0
- package/dist/types/view/drag-drop-context/drag-drop-context.d.ts +12 -0
- package/dist/types/view/drag-drop-context/error-boundary.d.ts +20 -0
- package/dist/types/view/drag-drop-context/index.d.ts +1 -0
- package/dist/types/view/drag-drop-context/use-startup-validation.d.ts +1 -0
- package/dist/types/view/drag-drop-context/use-unique-context-id.d.ts +3 -0
- package/dist/types/view/draggable/connected-draggable.d.ts +5 -0
- package/dist/types/view/draggable/draggable-api.d.ts +3 -0
- package/dist/types/view/draggable/draggable-types.d.ts +106 -0
- package/dist/types/view/draggable/draggable.d.ts +2 -0
- package/dist/types/view/draggable/get-style.d.ts +3 -0
- package/dist/types/view/draggable/index.d.ts +1 -0
- package/dist/types/view/draggable/use-validation.d.ts +4 -0
- package/dist/types/view/droppable/connected-droppable.d.ts +7 -0
- package/dist/types/view/droppable/droppable-types.d.ts +50 -0
- package/dist/types/view/droppable/droppable.d.ts +2 -0
- package/dist/types/view/droppable/index.d.ts +1 -0
- package/dist/types/view/droppable/use-validation.d.ts +8 -0
- package/dist/types/view/event-bindings/bind-events.d.ts +2 -0
- package/dist/types/view/event-bindings/event-types.d.ts +10 -0
- package/dist/types/view/get-body-element.d.ts +2 -0
- package/dist/types/view/get-border-box-center-position.d.ts +3 -0
- package/dist/types/view/get-document-element.d.ts +2 -0
- package/dist/types/view/get-elements/find-drag-handle.d.ts +2 -0
- package/dist/types/view/get-elements/find-draggable.d.ts +2 -0
- package/dist/types/view/is-strict-equal.d.ts +2 -0
- package/dist/types/view/is-type-of-element/is-element.d.ts +1 -0
- package/dist/types/view/is-type-of-element/is-html-element.d.ts +1 -0
- package/dist/types/view/is-type-of-element/is-svg-element.d.ts +1 -0
- package/dist/types/view/key-codes.d.ts +12 -0
- package/dist/types/view/placeholder/index.d.ts +1 -0
- package/dist/types/view/placeholder/placeholder-types.d.ts +14 -0
- package/dist/types/view/placeholder/placeholder.d.ts +28 -0
- package/dist/types/view/scroll-listener.d.ts +12 -0
- package/dist/types/view/throw-if-invalid-inner-ref.d.ts +2 -0
- package/dist/types/view/use-announcer/index.d.ts +1 -0
- package/dist/types/view/use-announcer/use-announcer.d.ts +3 -0
- package/dist/types/view/use-dev-setup-warning.d.ts +1 -0
- package/dist/types/view/use-dev.d.ts +1 -0
- package/dist/types/view/use-draggable-publisher/get-dimension.d.ts +3 -0
- package/dist/types/view/use-draggable-publisher/index.d.ts +1 -0
- package/dist/types/view/use-draggable-publisher/use-draggable-publisher.d.ts +8 -0
- package/dist/types/view/use-droppable-publisher/check-for-nested-scroll-container.d.ts +2 -0
- package/dist/types/view/use-droppable-publisher/get-closest-scrollable.d.ts +2 -0
- package/dist/types/view/use-droppable-publisher/get-dimension.d.ts +15 -0
- package/dist/types/view/use-droppable-publisher/get-env.d.ts +6 -0
- package/dist/types/view/use-droppable-publisher/get-listener-options.d.ts +5 -0
- package/dist/types/view/use-droppable-publisher/get-scroll.d.ts +3 -0
- package/dist/types/view/use-droppable-publisher/index.d.ts +1 -0
- package/dist/types/view/use-droppable-publisher/is-in-fixed-container.d.ts +2 -0
- package/dist/types/view/use-droppable-publisher/use-droppable-publisher.d.ts +13 -0
- package/dist/types/view/use-focus-marshal/focus-marshal-types.d.ts +9 -0
- package/dist/types/view/use-focus-marshal/index.d.ts +1 -0
- package/dist/types/view/use-focus-marshal/use-focus-marshal.d.ts +3 -0
- package/dist/types/view/use-hidden-text-element/index.d.ts +1 -0
- package/dist/types/view/use-hidden-text-element/use-hidden-text-element.d.ts +12 -0
- package/dist/types/view/use-isomorphic-layout-effect.d.ts +3 -0
- package/dist/types/view/use-previous-ref.d.ts +1 -0
- package/dist/types/view/use-required-context.d.ts +2 -0
- package/dist/types/view/use-sensor-marshal/closest.d.ts +1 -0
- package/dist/types/view/use-sensor-marshal/find-closest-draggable-id-from-event.d.ts +2 -0
- package/dist/types/view/use-sensor-marshal/index.d.ts +4 -0
- package/dist/types/view/use-sensor-marshal/is-event-in-interactive-element.d.ts +5 -0
- package/dist/types/view/use-sensor-marshal/lock.d.ts +11 -0
- package/dist/types/view/use-sensor-marshal/sensors/use-keyboard-sensor.d.ts +2 -0
- package/dist/types/view/use-sensor-marshal/sensors/use-mouse-sensor.d.ts +4 -0
- package/dist/types/view/use-sensor-marshal/sensors/use-touch-sensor.d.ts +4 -0
- package/dist/types/view/use-sensor-marshal/sensors/util/prevent-standard-key-events.d.ts +2 -0
- package/dist/types/view/use-sensor-marshal/sensors/util/supported-page-visibility-event-name.d.ts +2 -0
- package/dist/types/view/use-sensor-marshal/use-sensor-marshal.d.ts +12 -0
- package/dist/types/view/use-sensor-marshal/use-validate-sensor-hooks.d.ts +2 -0
- package/dist/types/view/use-style-marshal/get-styles.d.ts +10 -0
- package/dist/types/view/use-style-marshal/index.d.ts +1 -0
- package/dist/types/view/use-style-marshal/style-marshal-types.d.ts +6 -0
- package/dist/types/view/use-style-marshal/use-style-marshal.d.ts +3 -0
- package/dist/types/view/use-unique-id.d.ts +7 -0
- package/dist/types/view/visually-hidden-style.d.ts +2 -0
- package/dist/types/view/window/get-max-window-scroll.d.ts +3 -0
- package/dist/types/view/window/get-viewport.d.ts +3 -0
- package/dist/types/view/window/get-window-from-el.d.ts +2 -0
- package/dist/types/view/window/get-window-scroll.d.ts +3 -0
- package/dist/types/view/window/scroll-window.d.ts +3 -0
- package/package.json +157 -4
- package/src/animation.ts +75 -0
- package/src/debug/middleware/action-timing-average.ts +52 -0
- package/src/debug/middleware/action-timing.ts +16 -0
- package/src/debug/middleware/log.ts +26 -0
- package/src/debug/middleware/user-timing.ts +16 -0
- package/src/debug/timings.ts +87 -0
- package/src/dev-warning.ts +50 -0
- package/src/empty.ts +6 -0
- package/src/index.ts +67 -0
- package/src/invariant.ts +64 -0
- package/src/native-with-fallback.ts +69 -0
- package/src/screen-reader-message-preset.ts +135 -0
- package/src/state/action-creators.ts +358 -0
- package/src/state/auto-scroller/auto-scroller-types.ts +8 -0
- package/src/state/auto-scroller/can-scroll.ts +320 -0
- package/src/state/auto-scroller/fluid-scroller/config.ts +25 -0
- package/src/state/auto-scroller/fluid-scroller/did-start-in-scrollable-area.ts +1 -0
- package/src/state/auto-scroller/fluid-scroller/get-best-scrollable-droppable.ts +77 -0
- package/src/state/auto-scroller/fluid-scroller/get-droppable-scroll-change.ts +39 -0
- package/src/state/auto-scroller/fluid-scroller/get-percentage.ts +25 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/adjust-for-size-limits.ts +30 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/dampen-value-by-time.ts +37 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-distance-thresholds.ts +25 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-value-from-distance.ts +61 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-value.ts +39 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/index.ts +46 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/min-scroll.ts +4 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/index.ts +76 -0
- package/src/state/auto-scroller/fluid-scroller/get-window-scroll-change.ts +31 -0
- package/src/state/auto-scroller/fluid-scroller/index.ts +91 -0
- package/src/state/auto-scroller/fluid-scroller/scroll.ts +72 -0
- package/src/state/auto-scroller/index.ts +56 -0
- package/src/state/auto-scroller/jump-scroller.ts +140 -0
- package/src/state/axis.ts +26 -0
- package/src/state/calculate-drag-impact/calculate-reorder-impact.ts +138 -0
- package/src/state/can-start-drag.ts +29 -0
- package/src/state/create-store.ts +98 -0
- package/src/state/did-start-after-critical.ts +9 -0
- package/src/state/dimension-marshal/dimension-marshal-types.ts +49 -0
- package/src/state/dimension-marshal/dimension-marshal.ts +219 -0
- package/src/state/dimension-marshal/get-initial-publish.ts +66 -0
- package/src/state/dimension-marshal/while-dragging-publisher.ts +146 -0
- package/src/state/dimension-structures.ts +35 -0
- package/src/state/droppable/get-droppable.ts +103 -0
- package/src/state/droppable/is-home-of.ts +7 -0
- package/src/state/droppable/scroll-droppable.ts +53 -0
- package/src/state/droppable/should-use-placeholder.ts +7 -0
- package/src/state/droppable/util/clip.ts +17 -0
- package/src/state/droppable/util/get-subject.ts +63 -0
- package/src/state/droppable/what-is-dragged-over-from-result.ts +16 -0
- package/src/state/droppable/what-is-dragged-over.ts +16 -0
- package/src/state/droppable/with-placeholder.ts +174 -0
- package/src/state/get-center-from-impact/get-client-border-box-center/get-client-from-page-border-box-center.ts +30 -0
- package/src/state/get-center-from-impact/get-client-border-box-center/index.ts +45 -0
- package/src/state/get-center-from-impact/get-page-border-box-center/index.ts +71 -0
- package/src/state/get-center-from-impact/get-page-border-box-center/when-combining.ts +40 -0
- package/src/state/get-center-from-impact/get-page-border-box-center/when-reordering.ts +113 -0
- package/src/state/get-center-from-impact/move-relative-to.ts +68 -0
- package/src/state/get-combined-item-displacement.ts +35 -0
- package/src/state/get-displaced-by.ts +17 -0
- package/src/state/get-displacement-groups.ts +131 -0
- package/src/state/get-drag-impact/get-combine-impact.ts +131 -0
- package/src/state/get-drag-impact/get-reorder-impact.ts +145 -0
- package/src/state/get-drag-impact/index.ts +94 -0
- package/src/state/get-draggables-inside-droppable.ts +31 -0
- package/src/state/get-droppable-over.ts +161 -0
- package/src/state/get-frame.ts +10 -0
- package/src/state/get-home-location.ts +7 -0
- package/src/state/get-impact-location.ts +16 -0
- package/src/state/get-is-displaced.ts +12 -0
- package/src/state/get-lift-effect.ts +84 -0
- package/src/state/get-max-scroll.ts +32 -0
- package/src/state/is-movement-allowed.ts +13 -0
- package/src/state/is-within.ts +9 -0
- package/src/state/middleware/auto-scroll.ts +38 -0
- package/src/state/middleware/dimension-marshal-stopper.ts +20 -0
- package/src/state/middleware/drop/drop-animation-finish-middleware.ts +21 -0
- package/src/state/middleware/drop/drop-animation-flush-on-scroll-middleware.ts +63 -0
- package/src/state/middleware/drop/drop-middleware.ts +146 -0
- package/src/state/middleware/drop/get-drop-duration.ts +48 -0
- package/src/state/middleware/drop/get-drop-impact.ts +79 -0
- package/src/state/middleware/drop/get-new-home-client-offset.ts +55 -0
- package/src/state/middleware/drop/index.ts +2 -0
- package/src/state/middleware/focus.ts +42 -0
- package/src/state/middleware/lift.ts +66 -0
- package/src/state/middleware/pending-drop.ts +37 -0
- package/src/state/middleware/responders/async-marshal.ts +58 -0
- package/src/state/middleware/responders/expiring-announce.ts +44 -0
- package/src/state/middleware/responders/index.ts +2 -0
- package/src/state/middleware/responders/is-equal.ts +57 -0
- package/src/state/middleware/responders/publisher.ts +255 -0
- package/src/state/middleware/responders/responders-middleware.ts +81 -0
- package/src/state/middleware/scroll-listener.ts +31 -0
- package/src/state/middleware/style.ts +22 -0
- package/src/state/middleware/util/validate-dimensions.ts +71 -0
- package/src/state/move-in-direction/index.ts +85 -0
- package/src/state/move-in-direction/move-cross-axis/get-best-cross-axis-droppable.ts +169 -0
- package/src/state/move-in-direction/move-cross-axis/get-closest-draggable.ts +80 -0
- package/src/state/move-in-direction/move-cross-axis/index.ts +110 -0
- package/src/state/move-in-direction/move-cross-axis/move-to-new-droppable.ts +122 -0
- package/src/state/move-in-direction/move-cross-axis/without-starting-displacement.ts +31 -0
- package/src/state/move-in-direction/move-in-direction-types.ts +10 -0
- package/src/state/move-in-direction/move-to-next-place/index.ts +133 -0
- package/src/state/move-in-direction/move-to-next-place/is-totally-visible-in-new-location.ts +53 -0
- package/src/state/move-in-direction/move-to-next-place/move-to-next-combine/index.ts +98 -0
- package/src/state/move-in-direction/move-to-next-place/move-to-next-index/from-combine.ts +53 -0
- package/src/state/move-in-direction/move-to-next-place/move-to-next-index/from-reorder.ts +44 -0
- package/src/state/move-in-direction/move-to-next-place/move-to-next-index/index.ts +87 -0
- package/src/state/no-impact.ts +33 -0
- package/src/state/patch-dimension-map.ts +11 -0
- package/src/state/patch-droppable-map.ts +10 -0
- package/src/state/position.ts +65 -0
- package/src/state/post-reducer/when-moving/refresh-snap.ts +68 -0
- package/src/state/post-reducer/when-moving/update.ts +121 -0
- package/src/state/publish-while-dragging-in-virtual/adjust-additions-for-scroll-changes.ts +59 -0
- package/src/state/publish-while-dragging-in-virtual/index.ts +159 -0
- package/src/state/publish-while-dragging-in-virtual/offset-draggable.ts +36 -0
- package/src/state/recompute-placeholders.ts +101 -0
- package/src/state/rect.ts +7 -0
- package/src/state/reducer.ts +467 -0
- package/src/state/registry/create-registry.ts +162 -0
- package/src/state/registry/registry-types.ts +106 -0
- package/src/state/registry/use-registry.ts +20 -0
- package/src/state/remove-draggable-from-list.ts +13 -0
- package/src/state/scroll-viewport.ts +34 -0
- package/src/state/spacing.ts +45 -0
- package/src/state/store-types.ts +19 -0
- package/src/state/update-displacement-visibility/recompute.ts +55 -0
- package/src/state/update-displacement-visibility/speculatively-increase.ts +112 -0
- package/src/state/visibility/is-partially-visible-through-frame.ts +60 -0
- package/src/state/visibility/is-position-in-frame.ts +12 -0
- package/src/state/visibility/is-totally-visible-through-frame-on-axis.ts +19 -0
- package/src/state/visibility/is-totally-visible-through-frame.ts +18 -0
- package/src/state/visibility/is-visible.ts +102 -0
- package/src/state/with-scroll-change/with-all-displacement.ts +15 -0
- package/src/state/with-scroll-change/with-droppable-displacement.ts +13 -0
- package/src/state/with-scroll-change/with-droppable-scroll.ts +13 -0
- package/src/state/with-scroll-change/with-viewport-displacement.ts +7 -0
- package/src/types/redux-devtools.d.ts +17 -0
- package/src/types.ts +495 -0
- package/src/view/animate-in-out/animate-in-out.tsx +98 -0
- package/src/view/animate-in-out/index.ts +2 -0
- package/src/view/check-is-valid-inner-ref.ts +15 -0
- package/src/view/context/app-context.ts +19 -0
- package/src/view/context/droppable-context.ts +12 -0
- package/src/view/context/hooks.ts +21 -0
- package/src/view/context/store-context.ts +8 -0
- package/src/view/data-attributes.ts +37 -0
- package/src/view/drag-drop-context/app.tsx +300 -0
- package/src/view/drag-drop-context/check-doctype.ts +39 -0
- package/src/view/drag-drop-context/check-react-version.ts +72 -0
- package/src/view/drag-drop-context/drag-drop-context-types.ts +8 -0
- package/src/view/drag-drop-context/drag-drop-context.tsx +60 -0
- package/src/view/drag-drop-context/error-boundary.tsx +89 -0
- package/src/view/drag-drop-context/index.ts +2 -0
- package/src/view/drag-drop-context/use-startup-validation.ts +13 -0
- package/src/view/drag-drop-context/use-unique-context-id.ts +13 -0
- package/src/view/draggable/connected-draggable.tsx +420 -0
- package/src/view/draggable/draggable-api.tsx +48 -0
- package/src/view/draggable/draggable-types.ts +204 -0
- package/src/view/draggable/draggable.tsx +167 -0
- package/src/view/draggable/get-style.ts +109 -0
- package/src/view/draggable/index.ts +2 -0
- package/src/view/draggable/use-validation.ts +70 -0
- package/src/view/droppable/connected-droppable.tsx +597 -0
- package/src/view/droppable/droppable-types.ts +96 -0
- package/src/view/droppable/droppable.tsx +167 -0
- package/src/view/droppable/index.ts +2 -0
- package/src/view/droppable/use-validation.ts +102 -0
- package/src/view/event-bindings/bind-events.ts +39 -0
- package/src/view/event-bindings/event-types.ts +15 -0
- package/src/view/get-body-element.ts +8 -0
- package/src/view/get-border-box-center-position.ts +5 -0
- package/src/view/get-document-element.ts +8 -0
- package/src/view/get-elements/find-drag-handle.ts +38 -0
- package/src/view/get-elements/find-draggable.ts +30 -0
- package/src/view/is-strict-equal.ts +2 -0
- package/src/view/is-type-of-element/is-element.ts +10 -0
- package/src/view/is-type-of-element/is-html-element.ts +10 -0
- package/src/view/is-type-of-element/is-svg-element.ts +22 -0
- package/src/view/key-codes.ts +13 -0
- package/src/view/placeholder/index.ts +2 -0
- package/src/view/placeholder/placeholder-types.ts +16 -0
- package/src/view/placeholder/placeholder.tsx +204 -0
- package/src/view/scroll-listener.ts +74 -0
- package/src/view/throw-if-invalid-inner-ref.ts +15 -0
- package/src/view/use-announcer/index.ts +2 -0
- package/src/view/use-announcer/use-announcer.ts +80 -0
- package/src/view/use-dev-setup-warning.ts +22 -0
- package/src/view/use-dev.ts +9 -0
- package/src/view/use-draggable-publisher/get-dimension.ts +44 -0
- package/src/view/use-draggable-publisher/index.ts +2 -0
- package/src/view/use-draggable-publisher/use-draggable-publisher.ts +87 -0
- package/src/view/use-droppable-publisher/check-for-nested-scroll-container.ts +27 -0
- package/src/view/use-droppable-publisher/get-closest-scrollable.ts +96 -0
- package/src/view/use-droppable-publisher/get-dimension.ts +140 -0
- package/src/view/use-droppable-publisher/get-env.ts +32 -0
- package/src/view/use-droppable-publisher/get-listener-options.ts +12 -0
- package/src/view/use-droppable-publisher/get-scroll.ts +7 -0
- package/src/view/use-droppable-publisher/index.ts +2 -0
- package/src/view/use-droppable-publisher/is-in-fixed-container.ts +21 -0
- package/src/view/use-droppable-publisher/use-droppable-publisher.ts +288 -0
- package/src/view/use-focus-marshal/focus-marshal-types.ts +14 -0
- package/src/view/use-focus-marshal/index.ts +2 -0
- package/src/view/use-focus-marshal/use-focus-marshal.ts +128 -0
- package/src/view/use-hidden-text-element/index.ts +2 -0
- package/src/view/use-hidden-text-element/use-hidden-text-element.ts +62 -0
- package/src/view/use-isomorphic-layout-effect.ts +18 -0
- package/src/view/use-previous-ref.ts +26 -0
- package/src/view/use-required-context.ts +22 -0
- package/src/view/use-sensor-marshal/closest.ts +89 -0
- package/src/view/use-sensor-marshal/find-closest-draggable-id-from-event.ts +50 -0
- package/src/view/use-sensor-marshal/index.ts +5 -0
- package/src/view/use-sensor-marshal/is-event-in-interactive-element.ts +67 -0
- package/src/view/use-sensor-marshal/lock.ts +50 -0
- package/src/view/use-sensor-marshal/sensors/use-keyboard-sensor.ts +243 -0
- package/src/view/use-sensor-marshal/sensors/use-mouse-sensor.ts +391 -0
- package/src/view/use-sensor-marshal/sensors/use-touch-sensor.ts +481 -0
- package/src/view/use-sensor-marshal/sensors/util/prevent-standard-key-events.ts +19 -0
- package/src/view/use-sensor-marshal/sensors/util/supported-page-visibility-event-name.ts +29 -0
- package/src/view/use-sensor-marshal/use-sensor-marshal.ts +504 -0
- package/src/view/use-sensor-marshal/use-validate-sensor-hooks.ts +20 -0
- package/src/view/use-style-marshal/get-styles.ts +173 -0
- package/src/view/use-style-marshal/index.ts +2 -0
- package/src/view/use-style-marshal/style-marshal-types.ts +9 -0
- package/src/view/use-style-marshal/use-style-marshal.ts +126 -0
- package/src/view/use-unique-id.ts +25 -0
- package/src/view/visually-hidden-style.ts +16 -0
- package/src/view/window/get-max-window-scroll.ts +19 -0
- package/src/view/window/get-viewport.ts +49 -0
- package/src/view/window/get-window-from-el.ts +12 -0
- package/src/view/window/get-window-scroll.ts +30 -0
- package/src/view/window/scroll-window.ts +7 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { useCallback, useMemo } from "@helpdice/memoizer";
|
|
4
|
+
import type { Position } from "css-box-model";
|
|
5
|
+
import { invariant } from "../../../invariant";
|
|
6
|
+
import type {
|
|
7
|
+
DraggableId,
|
|
8
|
+
SensorAPI,
|
|
9
|
+
PreDragActions,
|
|
10
|
+
FluidDragActions,
|
|
11
|
+
TimeoutID,
|
|
12
|
+
} from "../../../types";
|
|
13
|
+
import type {
|
|
14
|
+
EventBinding,
|
|
15
|
+
EventOptions,
|
|
16
|
+
} from "../../event-bindings/event-types";
|
|
17
|
+
import bindEvents from "../../event-bindings/bind-events";
|
|
18
|
+
import * as keyCodes from "../../key-codes";
|
|
19
|
+
import supportedPageVisibilityEventName from "./util/supported-page-visibility-event-name";
|
|
20
|
+
import { noop } from "../../../empty";
|
|
21
|
+
import useLayoutEffect from "../../use-isomorphic-layout-effect";
|
|
22
|
+
|
|
23
|
+
type TouchWithForce = Touch & {
|
|
24
|
+
force: number,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//Exact
|
|
28
|
+
type Idle = {
|
|
29
|
+
type: "IDLE",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Exact
|
|
33
|
+
type Pending = {
|
|
34
|
+
type: "PENDING",
|
|
35
|
+
point: Position,
|
|
36
|
+
actions: PreDragActions,
|
|
37
|
+
longPressTimerId: TimeoutID,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Exact
|
|
41
|
+
type Dragging = {
|
|
42
|
+
type: "DRAGGING",
|
|
43
|
+
actions: FluidDragActions,
|
|
44
|
+
hasMoved: boolean,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type Phase = Idle | Pending | Dragging;
|
|
48
|
+
|
|
49
|
+
const idle: Idle = { type: "IDLE" };
|
|
50
|
+
// Decreased from 150 as a work around for an issue for forcepress on iOS
|
|
51
|
+
// https://github.com/atlassian/react-beautiful-dnd/issues/1401
|
|
52
|
+
export const timeForLongPress: number = 120;
|
|
53
|
+
export const forcePressThreshold: number = 0.15;
|
|
54
|
+
|
|
55
|
+
// Exact
|
|
56
|
+
type GetBindingArgs = {
|
|
57
|
+
cancel: () => void,
|
|
58
|
+
completed: () => void,
|
|
59
|
+
getPhase: () => Phase,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
function getWindowBindings({
|
|
63
|
+
cancel,
|
|
64
|
+
getPhase,
|
|
65
|
+
}: GetBindingArgs): EventBinding[] {
|
|
66
|
+
return [
|
|
67
|
+
// If the orientation of the device changes - kill the drag
|
|
68
|
+
// https://davidwalsh.name/orientation-change
|
|
69
|
+
{
|
|
70
|
+
eventName: "orientationchange",
|
|
71
|
+
fn: cancel,
|
|
72
|
+
},
|
|
73
|
+
// some devices fire resize if the orientation changes
|
|
74
|
+
{
|
|
75
|
+
eventName: "resize",
|
|
76
|
+
fn: cancel,
|
|
77
|
+
},
|
|
78
|
+
// Long press can bring up a context menu
|
|
79
|
+
// need to opt out of this behavior
|
|
80
|
+
{
|
|
81
|
+
eventName: "contextmenu",
|
|
82
|
+
fn: (event: Event) => {
|
|
83
|
+
// always opting out of context menu events
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
// On some devices it is possible to have a touch interface with a keyboard.
|
|
88
|
+
// On any keyboard event we cancel a touch drag
|
|
89
|
+
{
|
|
90
|
+
eventName: "keydown",
|
|
91
|
+
fn: (event: KeyboardEvent) => {
|
|
92
|
+
if (getPhase().type !== "DRAGGING") {
|
|
93
|
+
cancel();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// direct cancel: we are preventing the default action
|
|
98
|
+
// indirect cancel: we are not preventing the default action
|
|
99
|
+
|
|
100
|
+
// escape is a direct cancel
|
|
101
|
+
if (event.keyCode === keyCodes.escape) {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
}
|
|
104
|
+
cancel();
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
// Cancel on page visibility change
|
|
108
|
+
{
|
|
109
|
+
eventName: supportedPageVisibilityEventName,
|
|
110
|
+
fn: cancel,
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// All of the touch events get applied to the drag handle of the touch interaction
|
|
116
|
+
// This plays well with the event.target being unmounted during a drag
|
|
117
|
+
function getHandleBindings({
|
|
118
|
+
cancel,
|
|
119
|
+
completed,
|
|
120
|
+
getPhase,
|
|
121
|
+
}: GetBindingArgs): EventBinding[] {
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
eventName: "touchmove",
|
|
125
|
+
// Opting out of passive touchmove (default) so as to prevent scrolling while moving
|
|
126
|
+
// Not worried about performance as effect of move is throttled in requestAnimationFrame
|
|
127
|
+
// Using `capture: false` due to a recent horrible firefox bug: https://twitter.com/alexandereardon/status/1125904207184187393
|
|
128
|
+
options: { capture: false },
|
|
129
|
+
fn: (event: TouchEvent) => {
|
|
130
|
+
const phase: Phase = getPhase();
|
|
131
|
+
// Drag has not yet started and we are waiting for a long press.
|
|
132
|
+
if (phase.type !== "DRAGGING") {
|
|
133
|
+
cancel();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// At this point we are dragging
|
|
138
|
+
phase.hasMoved = true;
|
|
139
|
+
|
|
140
|
+
const { clientX, clientY } = event.touches[0];
|
|
141
|
+
|
|
142
|
+
const point: Position = {
|
|
143
|
+
x: clientX,
|
|
144
|
+
y: clientY,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// We need to prevent the default event in order to block native scrolling
|
|
148
|
+
// Also because we are using it as part of a drag we prevent the default action
|
|
149
|
+
// as a sign that we are using the event
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
phase.actions.move(point);
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
eventName: "touchend",
|
|
156
|
+
fn: (event: TouchEvent) => {
|
|
157
|
+
const phase: Phase = getPhase();
|
|
158
|
+
// drag had not started yet - do not prevent the default action
|
|
159
|
+
if (phase.type !== "DRAGGING") {
|
|
160
|
+
cancel();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ending the drag
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
phase.actions.drop({ shouldBlockNextClick: true });
|
|
167
|
+
completed();
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
eventName: "touchcancel",
|
|
172
|
+
fn: (event: TouchEvent) => {
|
|
173
|
+
// drag had not started yet - do not prevent the default action
|
|
174
|
+
if (getPhase().type !== "DRAGGING") {
|
|
175
|
+
cancel();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// already dragging - this event is directly ending a drag
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
cancel();
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
// Need to opt out of dragging if the user is a force press
|
|
185
|
+
// Only for webkit which has decided to introduce its own custom way of doing things
|
|
186
|
+
// https://developer.apple.com/library/content/documentation/AppleApplications/Conceptual/SafariJSProgTopics/RespondingtoForceTouchEventsfromJavaScript.html
|
|
187
|
+
{
|
|
188
|
+
eventName: "touchforcechange",
|
|
189
|
+
fn: (event: TouchEvent) => {
|
|
190
|
+
const phase: Phase = getPhase();
|
|
191
|
+
|
|
192
|
+
// needed to use phase.actions
|
|
193
|
+
invariant(phase.type !== "IDLE");
|
|
194
|
+
|
|
195
|
+
// This is not fantastic logic, but it is done to account for
|
|
196
|
+
// and issue with forcepress on iOS
|
|
197
|
+
// Calling event.preventDefault() will currently opt out of scrolling and clicking
|
|
198
|
+
// https://github.com/atlassian/react-beautiful-dnd/issues/1401
|
|
199
|
+
|
|
200
|
+
const touch: TouchWithForce | null = (event.touches[0] as any);
|
|
201
|
+
|
|
202
|
+
if (!touch) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const isForcePress: boolean = touch.force >= forcePressThreshold;
|
|
207
|
+
|
|
208
|
+
if (!isForcePress) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const shouldRespect: boolean = phase.actions.shouldRespectForcePress();
|
|
213
|
+
|
|
214
|
+
if (phase.type === "PENDING") {
|
|
215
|
+
if (shouldRespect) {
|
|
216
|
+
cancel();
|
|
217
|
+
}
|
|
218
|
+
// If not respecting we just let the event go through
|
|
219
|
+
// It will not have an impact on the browser until
|
|
220
|
+
// there has been a sufficient time ellapsed
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// 'DRAGGING'
|
|
225
|
+
|
|
226
|
+
if (shouldRespect) {
|
|
227
|
+
if (phase.hasMoved) {
|
|
228
|
+
// After the user has moved we do not allow the dragging item to be force pressed
|
|
229
|
+
// This prevents strange behaviour such as a link preview opening mid drag
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
// indirect cancel
|
|
234
|
+
cancel();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// not respecting during a drag
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
// Cancel on page visibility change
|
|
243
|
+
{
|
|
244
|
+
eventName: supportedPageVisibilityEventName,
|
|
245
|
+
fn: cancel,
|
|
246
|
+
},
|
|
247
|
+
// Not adding a cancel on touchstart as this handler will pick up the initial touchstart event
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export default function useTouchSensor(api: SensorAPI) {
|
|
252
|
+
const phaseRef = useRef<Phase>(idle);
|
|
253
|
+
const unbindEventsRef = useRef<() => void>(noop);
|
|
254
|
+
|
|
255
|
+
const getPhase = useCallback(function getPhase(): Phase {
|
|
256
|
+
return phaseRef.current;
|
|
257
|
+
}, []);
|
|
258
|
+
|
|
259
|
+
const setPhase = useCallback(function setPhase(phase: Phase) {
|
|
260
|
+
phaseRef.current = phase;
|
|
261
|
+
}, []);
|
|
262
|
+
|
|
263
|
+
const startCaptureBinding: EventBinding = useMemo(
|
|
264
|
+
() => ({
|
|
265
|
+
eventName: "touchstart",
|
|
266
|
+
fn: function onTouchStart(event: TouchEvent) {
|
|
267
|
+
// Event already used by something else
|
|
268
|
+
if (event.defaultPrevented) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// We need to NOT call event.preventDefault() so as to maintain as much standard
|
|
273
|
+
// browser interactions as possible.
|
|
274
|
+
// This includes navigation on anchors which we want to preserve
|
|
275
|
+
|
|
276
|
+
const draggableId: DraggableId | null = api.findClosestDraggableId(event);
|
|
277
|
+
|
|
278
|
+
if (!draggableId) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const actions: PreDragActions | null = api.tryGetLock(
|
|
283
|
+
draggableId,
|
|
284
|
+
// eslint-disable-next-line no-use-before-define
|
|
285
|
+
stop,
|
|
286
|
+
{ sourceEvent: event },
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
// could not start a drag
|
|
290
|
+
if (!actions) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const touch: Touch = event.touches[0];
|
|
295
|
+
const { clientX, clientY } = touch;
|
|
296
|
+
const point: Position = {
|
|
297
|
+
x: clientX,
|
|
298
|
+
y: clientY,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
// unbind this event handler
|
|
302
|
+
unbindEventsRef.current();
|
|
303
|
+
|
|
304
|
+
// eslint-disable-next-line no-use-before-define
|
|
305
|
+
startPendingDrag(actions, point);
|
|
306
|
+
},
|
|
307
|
+
}),
|
|
308
|
+
// not including stop or startPendingDrag as it is not defined initially
|
|
309
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
310
|
+
[api],
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
const listenForCapture = useCallback(
|
|
314
|
+
function listenForCapture() {
|
|
315
|
+
const options: EventOptions = {
|
|
316
|
+
capture: true,
|
|
317
|
+
passive: false,
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
unbindEventsRef.current = bindEvents(
|
|
321
|
+
window,
|
|
322
|
+
[startCaptureBinding],
|
|
323
|
+
options,
|
|
324
|
+
);
|
|
325
|
+
},
|
|
326
|
+
[startCaptureBinding],
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
const stop = useCallback(() => {
|
|
330
|
+
const current: Phase = phaseRef.current;
|
|
331
|
+
if (current.type === "IDLE") {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// aborting any pending drag
|
|
336
|
+
if (current.type === "PENDING") {
|
|
337
|
+
clearTimeout(current.longPressTimerId);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
setPhase(idle);
|
|
341
|
+
unbindEventsRef.current();
|
|
342
|
+
|
|
343
|
+
listenForCapture();
|
|
344
|
+
}, [listenForCapture, setPhase]);
|
|
345
|
+
|
|
346
|
+
const cancel = useCallback(() => {
|
|
347
|
+
const phase: Phase = phaseRef.current;
|
|
348
|
+
stop();
|
|
349
|
+
if (phase.type === "DRAGGING" && phase.actions.cancel) {
|
|
350
|
+
phase.actions.cancel({ shouldBlockNextClick: true });
|
|
351
|
+
}
|
|
352
|
+
if (phase.type === "PENDING") {
|
|
353
|
+
phase.actions.abort();
|
|
354
|
+
}
|
|
355
|
+
}, [stop]);
|
|
356
|
+
|
|
357
|
+
const bindCapturingEvents = useCallback(
|
|
358
|
+
function bindCapturingEvents() {
|
|
359
|
+
const options: EventOptions = { capture: true, passive: false };
|
|
360
|
+
const args: GetBindingArgs = {
|
|
361
|
+
cancel,
|
|
362
|
+
completed: stop,
|
|
363
|
+
getPhase,
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// In prior versions of iOS it was required that touch listeners be added
|
|
367
|
+
// to the handle to work correctly (even if the handle got removed in a portal / clone)
|
|
368
|
+
// In the latest version it appears to be the opposite: for reparenting to work
|
|
369
|
+
// the events need to be attached to the window.
|
|
370
|
+
// For now i'll keep these two functions seperate in case we need to swap it back again
|
|
371
|
+
// Old behaviour:
|
|
372
|
+
// https://gist.github.com/parris/dda613e3ae78f14eb2dc9fa0f4bfce3d
|
|
373
|
+
// https://stackoverflow.com/questions/33298828/touch-move-event-dont-fire-after-touch-start-target-is-removed
|
|
374
|
+
const unbindTarget = bindEvents(window, getHandleBindings(args), options);
|
|
375
|
+
const unbindWindow = bindEvents(window, getWindowBindings(args), options);
|
|
376
|
+
|
|
377
|
+
unbindEventsRef.current = function unbindAll() {
|
|
378
|
+
unbindTarget();
|
|
379
|
+
unbindWindow();
|
|
380
|
+
};
|
|
381
|
+
},
|
|
382
|
+
[cancel, getPhase, stop],
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
const startDragging = useCallback(
|
|
386
|
+
function startDragging() {
|
|
387
|
+
const phase: Phase = getPhase();
|
|
388
|
+
invariant(
|
|
389
|
+
phase.type === "PENDING",
|
|
390
|
+
`Cannot start dragging from phase ${phase.type}`,
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
const actions: FluidDragActions = phase.actions.fluidLift(phase.point);
|
|
394
|
+
|
|
395
|
+
setPhase({
|
|
396
|
+
type: "DRAGGING",
|
|
397
|
+
actions,
|
|
398
|
+
hasMoved: false,
|
|
399
|
+
});
|
|
400
|
+
},
|
|
401
|
+
[getPhase, setPhase],
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
const startPendingDrag = useCallback(
|
|
405
|
+
function startPendingDrag(actions: PreDragActions, point: Position) {
|
|
406
|
+
invariant(
|
|
407
|
+
getPhase().type === "IDLE",
|
|
408
|
+
"Expected to move from IDLE to PENDING drag",
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
const longPressTimerId: TimeoutID = setTimeout(
|
|
412
|
+
startDragging,
|
|
413
|
+
timeForLongPress,
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
setPhase({
|
|
417
|
+
type: "PENDING",
|
|
418
|
+
point,
|
|
419
|
+
actions,
|
|
420
|
+
longPressTimerId,
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
bindCapturingEvents();
|
|
424
|
+
},
|
|
425
|
+
[bindCapturingEvents, getPhase, setPhase, startDragging],
|
|
426
|
+
);
|
|
427
|
+
|
|
428
|
+
useLayoutEffect(
|
|
429
|
+
function mount() {
|
|
430
|
+
listenForCapture();
|
|
431
|
+
|
|
432
|
+
return function unmount() {
|
|
433
|
+
// remove any existing listeners
|
|
434
|
+
unbindEventsRef.current();
|
|
435
|
+
|
|
436
|
+
// need to kill any pending drag start timer
|
|
437
|
+
const phase: Phase = getPhase();
|
|
438
|
+
if (phase.type === "PENDING") {
|
|
439
|
+
clearTimeout(phase.longPressTimerId);
|
|
440
|
+
setPhase(idle);
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
},
|
|
444
|
+
[getPhase, listenForCapture, setPhase],
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
// This is needed for safari
|
|
448
|
+
// Simply adding a non capture, non passive 'touchmove' listener.
|
|
449
|
+
// This forces event.preventDefault() in dynamically added
|
|
450
|
+
// touchmove event handlers to actually work
|
|
451
|
+
// https://github.com/atlassian/react-beautiful-dnd/issues/1374
|
|
452
|
+
useLayoutEffect(function webkitHack(): () => void {
|
|
453
|
+
const unbind = bindEvents(window, [
|
|
454
|
+
{
|
|
455
|
+
eventName: 'touchmove',
|
|
456
|
+
// Using a new noop function for each usage as a single
|
|
457
|
+
// removeEventListener() call will remove all handlers
|
|
458
|
+
// with the same reference.
|
|
459
|
+
fn: (): void => {},
|
|
460
|
+
options: { capture: false, passive: false },
|
|
461
|
+
},
|
|
462
|
+
], {});
|
|
463
|
+
|
|
464
|
+
return unbind;
|
|
465
|
+
}, []);
|
|
466
|
+
|
|
467
|
+
// useLayoutEffect(function webkitHack() {
|
|
468
|
+
// const unbind = bindEvents(window, [
|
|
469
|
+
// {
|
|
470
|
+
// eventName: "touchmove",
|
|
471
|
+
// // using a new noop function for each usage as a single `removeEventListener()`
|
|
472
|
+
// // call will remove all handlers with the same reference
|
|
473
|
+
// // https://codesandbox.io/s/removing-multiple-handlers-with-same-reference-fxe15
|
|
474
|
+
// fn: () => {},
|
|
475
|
+
// options: { capture: false, passive: false },
|
|
476
|
+
// },
|
|
477
|
+
// ]);
|
|
478
|
+
|
|
479
|
+
// return unbind;
|
|
480
|
+
// }, []);
|
|
481
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as keyCodes from '../../../key-codes';
|
|
3
|
+
|
|
4
|
+
type KeyMap = {
|
|
5
|
+
[key: number]: true,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const preventedKeys: KeyMap = {
|
|
9
|
+
// submission
|
|
10
|
+
[keyCodes.enter]: true,
|
|
11
|
+
// tabbing
|
|
12
|
+
[keyCodes.tab]: true,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default (event: KeyboardEvent) => {
|
|
16
|
+
if (preventedKeys[event.keyCode]) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { find } from '../../../../native-with-fallback';
|
|
3
|
+
|
|
4
|
+
const supportedEventName: string = ((): string => {
|
|
5
|
+
const base: string = 'visibilitychange';
|
|
6
|
+
|
|
7
|
+
// Server side rendering
|
|
8
|
+
if (typeof document === 'undefined') {
|
|
9
|
+
return base;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
|
|
13
|
+
const candidates: string[] = [
|
|
14
|
+
base,
|
|
15
|
+
`ms${base}`,
|
|
16
|
+
`webkit${base}`,
|
|
17
|
+
`moz${base}`,
|
|
18
|
+
`o${base}`,
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const supported: string | undefined = find(
|
|
22
|
+
candidates,
|
|
23
|
+
(eventName: string): boolean => `on${eventName}` in document,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return supported || base;
|
|
27
|
+
})();
|
|
28
|
+
|
|
29
|
+
export default supportedEventName;
|