@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,169 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Position, type Rect } from 'css-box-model';
|
|
3
|
+
import { invariant } from '../../../invariant';
|
|
4
|
+
import { closest } from '../../position';
|
|
5
|
+
import isWithin from '../../is-within';
|
|
6
|
+
import { getCorners } from '../../spacing';
|
|
7
|
+
import isPartiallyVisibleThroughFrame from '../../visibility/is-partially-visible-through-frame';
|
|
8
|
+
import { toDroppableList } from '../../dimension-structures';
|
|
9
|
+
import type {
|
|
10
|
+
Axis,
|
|
11
|
+
DroppableDimension,
|
|
12
|
+
DroppableDimensionMap,
|
|
13
|
+
Viewport,
|
|
14
|
+
} from '../../../types';
|
|
15
|
+
|
|
16
|
+
// Exact
|
|
17
|
+
type GetBestDroppableArgs = {
|
|
18
|
+
isMovingForward: boolean,
|
|
19
|
+
// the current position of the dragging item
|
|
20
|
+
pageBorderBoxCenter: Position,
|
|
21
|
+
// the home of the draggable
|
|
22
|
+
source: DroppableDimension,
|
|
23
|
+
// all the droppables in the system
|
|
24
|
+
droppables: DroppableDimensionMap,
|
|
25
|
+
viewport: Viewport,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getKnownActive = (droppable: DroppableDimension): Rect => {
|
|
29
|
+
const rect: Rect | null = droppable.subject.active;
|
|
30
|
+
|
|
31
|
+
invariant(rect, 'Cannot get clipped area from droppable');
|
|
32
|
+
|
|
33
|
+
return rect;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default ({
|
|
37
|
+
isMovingForward,
|
|
38
|
+
pageBorderBoxCenter,
|
|
39
|
+
source,
|
|
40
|
+
droppables,
|
|
41
|
+
viewport,
|
|
42
|
+
}: GetBestDroppableArgs): DroppableDimension | null => {
|
|
43
|
+
const active: Rect | null = source.subject.active;
|
|
44
|
+
|
|
45
|
+
if (!active) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const axis: Axis = source.axis;
|
|
50
|
+
const isBetweenSourceClipped = isWithin(active[axis.start], active[axis.end]);
|
|
51
|
+
const candidates: DroppableDimension[] = toDroppableList(droppables)
|
|
52
|
+
// Remove the source droppable from the list
|
|
53
|
+
.filter((droppable: DroppableDimension): boolean => droppable !== source)
|
|
54
|
+
// Remove any options that are not enabled
|
|
55
|
+
.filter((droppable: DroppableDimension): boolean => droppable.isEnabled)
|
|
56
|
+
// Remove any droppables that do not have a visible subject
|
|
57
|
+
.filter((droppable: DroppableDimension): boolean =>
|
|
58
|
+
Boolean(droppable.subject.active),
|
|
59
|
+
)
|
|
60
|
+
// Remove any that are not visible in the window
|
|
61
|
+
.filter((droppable: DroppableDimension): boolean =>
|
|
62
|
+
isPartiallyVisibleThroughFrame(viewport.frame)(getKnownActive(droppable)),
|
|
63
|
+
)
|
|
64
|
+
.filter((droppable: DroppableDimension): boolean => {
|
|
65
|
+
const activeOfTarget: Rect = getKnownActive(droppable);
|
|
66
|
+
|
|
67
|
+
// is the target in front of the source on the cross axis?
|
|
68
|
+
if (isMovingForward) {
|
|
69
|
+
return active[axis.crossAxisEnd] < activeOfTarget[axis.crossAxisEnd];
|
|
70
|
+
}
|
|
71
|
+
// is the target behind the source on the cross axis?
|
|
72
|
+
return activeOfTarget[axis.crossAxisStart] < active[axis.crossAxisStart];
|
|
73
|
+
})
|
|
74
|
+
// Must have some overlap on the main axis
|
|
75
|
+
.filter((droppable: DroppableDimension): boolean => {
|
|
76
|
+
const activeOfTarget: Rect = getKnownActive(droppable);
|
|
77
|
+
|
|
78
|
+
const isBetweenDestinationClipped = isWithin(
|
|
79
|
+
activeOfTarget[axis.start],
|
|
80
|
+
activeOfTarget[axis.end],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
isBetweenSourceClipped(activeOfTarget[axis.start]) ||
|
|
85
|
+
isBetweenSourceClipped(activeOfTarget[axis.end]) ||
|
|
86
|
+
isBetweenDestinationClipped(active[axis.start]) ||
|
|
87
|
+
isBetweenDestinationClipped(active[axis.end])
|
|
88
|
+
);
|
|
89
|
+
})
|
|
90
|
+
// Sort on the cross axis
|
|
91
|
+
.sort((a: DroppableDimension, b: DroppableDimension) => {
|
|
92
|
+
const first: number = getKnownActive(a)[axis.crossAxisStart];
|
|
93
|
+
const second: number = getKnownActive(b)[axis.crossAxisStart];
|
|
94
|
+
|
|
95
|
+
if (isMovingForward) {
|
|
96
|
+
return first - second;
|
|
97
|
+
}
|
|
98
|
+
return second - first;
|
|
99
|
+
})
|
|
100
|
+
// Find the droppables that have the same cross axis value as the first item
|
|
101
|
+
.filter(
|
|
102
|
+
(
|
|
103
|
+
droppable: DroppableDimension,
|
|
104
|
+
_index: number,
|
|
105
|
+
array: DroppableDimension[],
|
|
106
|
+
): boolean =>
|
|
107
|
+
getKnownActive(droppable)[axis.crossAxisStart] ===
|
|
108
|
+
getKnownActive(array[0])[axis.crossAxisStart],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
// no possible candidates
|
|
112
|
+
if (!candidates.length) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// only one result - all done!
|
|
117
|
+
if (candidates.length === 1) {
|
|
118
|
+
return candidates[0];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// At this point we have a number of candidates that
|
|
122
|
+
// all have the same axis.crossAxisStart value.
|
|
123
|
+
|
|
124
|
+
// Check to see if the center position is within the size of a Droppable on the main axis
|
|
125
|
+
const contains: DroppableDimension[] = candidates.filter(
|
|
126
|
+
(droppable: DroppableDimension) => {
|
|
127
|
+
const isWithinDroppable = isWithin(
|
|
128
|
+
getKnownActive(droppable)[axis.start],
|
|
129
|
+
getKnownActive(droppable)[axis.end],
|
|
130
|
+
);
|
|
131
|
+
return isWithinDroppable(pageBorderBoxCenter[axis.line]);
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
if (contains.length === 1) {
|
|
136
|
+
return contains[0];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// The center point of the draggable falls on the boundary between two droppables
|
|
140
|
+
if (contains.length > 1) {
|
|
141
|
+
// sort on the main axis and choose the first
|
|
142
|
+
return contains.sort(
|
|
143
|
+
(a: DroppableDimension, b: DroppableDimension): number =>
|
|
144
|
+
getKnownActive(a)[axis.start] - getKnownActive(b)[axis.start],
|
|
145
|
+
)[0];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// The center is not contained within any droppable
|
|
149
|
+
// 1. Find the candidate that has the closest corner
|
|
150
|
+
// 2. If there is a tie - choose the one that is first on the main axis
|
|
151
|
+
return candidates.sort(
|
|
152
|
+
(a: DroppableDimension, b: DroppableDimension): number => {
|
|
153
|
+
const first = closest(pageBorderBoxCenter, getCorners(getKnownActive(a)));
|
|
154
|
+
const second = closest(
|
|
155
|
+
pageBorderBoxCenter,
|
|
156
|
+
getCorners(getKnownActive(b)),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// if the distances are not equal - choose the shortest
|
|
160
|
+
if (first !== second) {
|
|
161
|
+
return first - second;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// They both have the same distance -
|
|
165
|
+
// choose the one that is first on the main axis
|
|
166
|
+
return getKnownActive(a)[axis.start] - getKnownActive(b)[axis.start];
|
|
167
|
+
},
|
|
168
|
+
)[0];
|
|
169
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Position } from 'css-box-model';
|
|
3
|
+
import type {
|
|
4
|
+
Viewport,
|
|
5
|
+
DraggableDimension,
|
|
6
|
+
DroppableDimension,
|
|
7
|
+
LiftEffect,
|
|
8
|
+
} from '../../../types';
|
|
9
|
+
import { distance } from '../../position';
|
|
10
|
+
import { isTotallyVisible } from '../../visibility/is-visible';
|
|
11
|
+
import withDroppableDisplacement from '../../with-scroll-change/with-droppable-displacement';
|
|
12
|
+
import {
|
|
13
|
+
getCurrentPageBorderBox,
|
|
14
|
+
getCurrentPageBorderBoxCenter,
|
|
15
|
+
} from './without-starting-displacement';
|
|
16
|
+
|
|
17
|
+
// Exact
|
|
18
|
+
type Args = {
|
|
19
|
+
pageBorderBoxCenter: Position,
|
|
20
|
+
viewport: Viewport,
|
|
21
|
+
// the droppable that is being moved to
|
|
22
|
+
destination: DroppableDimension,
|
|
23
|
+
// the droppables inside the destination
|
|
24
|
+
insideDestination: DraggableDimension[],
|
|
25
|
+
afterCritical: LiftEffect,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default ({
|
|
29
|
+
pageBorderBoxCenter,
|
|
30
|
+
viewport,
|
|
31
|
+
destination,
|
|
32
|
+
insideDestination,
|
|
33
|
+
afterCritical,
|
|
34
|
+
}: Args): DraggableDimension | null => {
|
|
35
|
+
const sorted: DraggableDimension[] = insideDestination
|
|
36
|
+
.filter((draggable: DraggableDimension): boolean =>
|
|
37
|
+
// Allowing movement to draggables that are not visible in the viewport
|
|
38
|
+
// but must be visible in the droppable
|
|
39
|
+
// We can improve this, but this limitation is easier for now
|
|
40
|
+
isTotallyVisible({
|
|
41
|
+
target: getCurrentPageBorderBox(draggable, afterCritical),
|
|
42
|
+
destination,
|
|
43
|
+
viewport: viewport.frame,
|
|
44
|
+
withDroppableDisplacement: true,
|
|
45
|
+
}),
|
|
46
|
+
)
|
|
47
|
+
.sort((a: DraggableDimension, b: DraggableDimension): number => {
|
|
48
|
+
// Need to consider the change in scroll in the destination
|
|
49
|
+
const distanceToA = distance(
|
|
50
|
+
pageBorderBoxCenter,
|
|
51
|
+
withDroppableDisplacement(
|
|
52
|
+
destination,
|
|
53
|
+
getCurrentPageBorderBoxCenter(a, afterCritical),
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
const distanceToB = distance(
|
|
57
|
+
pageBorderBoxCenter,
|
|
58
|
+
withDroppableDisplacement(
|
|
59
|
+
destination,
|
|
60
|
+
getCurrentPageBorderBoxCenter(b, afterCritical),
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// if a is closer - return a
|
|
65
|
+
if (distanceToA < distanceToB) {
|
|
66
|
+
return -1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// if b is closer - return b
|
|
70
|
+
if (distanceToB < distanceToA) {
|
|
71
|
+
return 1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// if the distance to a and b are the same:
|
|
75
|
+
// return the one with the lower index (it will be higher on the main axis)
|
|
76
|
+
return a.descriptor.index - b.descriptor.index;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return sorted[0] || null;
|
|
80
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Position } from 'css-box-model';
|
|
3
|
+
import type { PublicResult } from '../move-in-direction-types';
|
|
4
|
+
import type {
|
|
5
|
+
DroppableDimension,
|
|
6
|
+
DraggableDimension,
|
|
7
|
+
DraggableDimensionMap,
|
|
8
|
+
DroppableDimensionMap,
|
|
9
|
+
DragImpact,
|
|
10
|
+
Viewport,
|
|
11
|
+
LiftEffect,
|
|
12
|
+
} from '../../../types';
|
|
13
|
+
import getBestCrossAxisDroppable from './get-best-cross-axis-droppable';
|
|
14
|
+
import getClosestDraggable from './get-closest-draggable';
|
|
15
|
+
// import moveToNewDroppable from './move-to-new-droppable';
|
|
16
|
+
import getDraggablesInsideDroppable from '../../get-draggables-inside-droppable';
|
|
17
|
+
import getClientFromPageBorderBoxCenter from '../../get-center-from-impact/get-client-border-box-center/get-client-from-page-border-box-center';
|
|
18
|
+
import getPageBorderBoxCenter from '../../get-center-from-impact/get-page-border-box-center';
|
|
19
|
+
import moveToNewDroppable from './move-to-new-droppable';
|
|
20
|
+
|
|
21
|
+
// Exact
|
|
22
|
+
type Args = {
|
|
23
|
+
isMovingForward: boolean,
|
|
24
|
+
// the current page center of the dragging item
|
|
25
|
+
previousPageBorderBoxCenter: Position,
|
|
26
|
+
// the dragging item
|
|
27
|
+
draggable: DraggableDimension,
|
|
28
|
+
// the droppable the dragging item is in
|
|
29
|
+
isOver: DroppableDimension,
|
|
30
|
+
// all the dimensions in the system
|
|
31
|
+
draggables: DraggableDimensionMap,
|
|
32
|
+
droppables: DroppableDimensionMap,
|
|
33
|
+
// the current viewport
|
|
34
|
+
viewport: Viewport,
|
|
35
|
+
afterCritical: LiftEffect,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default ({
|
|
39
|
+
isMovingForward,
|
|
40
|
+
previousPageBorderBoxCenter,
|
|
41
|
+
draggable,
|
|
42
|
+
isOver,
|
|
43
|
+
draggables,
|
|
44
|
+
droppables,
|
|
45
|
+
viewport,
|
|
46
|
+
afterCritical,
|
|
47
|
+
}: Args): PublicResult | null => {
|
|
48
|
+
// not considering the container scroll changes as container scrolling cancels a keyboard drag
|
|
49
|
+
|
|
50
|
+
const destination: DroppableDimension | null = getBestCrossAxisDroppable({
|
|
51
|
+
isMovingForward,
|
|
52
|
+
pageBorderBoxCenter: previousPageBorderBoxCenter,
|
|
53
|
+
source: isOver,
|
|
54
|
+
droppables,
|
|
55
|
+
viewport,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// nothing available to move to
|
|
59
|
+
if (!destination) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const insideDestination: DraggableDimension[] = getDraggablesInsideDroppable(
|
|
64
|
+
destination.descriptor.id,
|
|
65
|
+
draggables,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const moveRelativeTo: DraggableDimension | null= getClosestDraggable({
|
|
69
|
+
pageBorderBoxCenter: previousPageBorderBoxCenter,
|
|
70
|
+
viewport,
|
|
71
|
+
destination,
|
|
72
|
+
insideDestination,
|
|
73
|
+
afterCritical,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const impact: DragImpact | null = moveToNewDroppable({
|
|
77
|
+
previousPageBorderBoxCenter,
|
|
78
|
+
destination,
|
|
79
|
+
draggable,
|
|
80
|
+
draggables,
|
|
81
|
+
moveRelativeTo,
|
|
82
|
+
insideDestination,
|
|
83
|
+
viewport,
|
|
84
|
+
afterCritical,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (!impact) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const pageBorderBoxCenter: Position = getPageBorderBoxCenter({
|
|
92
|
+
impact,
|
|
93
|
+
draggable,
|
|
94
|
+
droppable: destination,
|
|
95
|
+
draggables,
|
|
96
|
+
afterCritical,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const clientSelection: Position = getClientFromPageBorderBoxCenter({
|
|
100
|
+
pageBorderBoxCenter,
|
|
101
|
+
draggable,
|
|
102
|
+
viewport,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
clientSelection,
|
|
107
|
+
impact,
|
|
108
|
+
scrollJumpRequest: null,
|
|
109
|
+
};
|
|
110
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Position } from 'css-box-model';
|
|
3
|
+
import type {
|
|
4
|
+
DragImpact,
|
|
5
|
+
DraggableDimension,
|
|
6
|
+
DraggableDimensionMap,
|
|
7
|
+
DroppableDimension,
|
|
8
|
+
Viewport,
|
|
9
|
+
DisplacedBy,
|
|
10
|
+
LiftEffect,
|
|
11
|
+
} from '../../../types';
|
|
12
|
+
import getDisplacedBy from '../../get-displaced-by';
|
|
13
|
+
import { emptyGroups, noDisplacedBy } from '../../no-impact';
|
|
14
|
+
import getPageBorderBoxCenter from '../../get-center-from-impact/get-page-border-box-center';
|
|
15
|
+
import isTotallyVisibleInNewLocation from '../move-to-next-place/is-totally-visible-in-new-location';
|
|
16
|
+
import { addPlaceholder } from '../../droppable/with-placeholder';
|
|
17
|
+
import isHomeOf from '../../droppable/is-home-of';
|
|
18
|
+
import calculateReorderImpact from '../../calculate-drag-impact/calculate-reorder-impact';
|
|
19
|
+
|
|
20
|
+
// Exact
|
|
21
|
+
type Args = {
|
|
22
|
+
previousPageBorderBoxCenter: Position,
|
|
23
|
+
moveRelativeTo: DraggableDimension | null,
|
|
24
|
+
insideDestination: DraggableDimension[],
|
|
25
|
+
draggable: DraggableDimension,
|
|
26
|
+
draggables: DraggableDimensionMap,
|
|
27
|
+
destination: DroppableDimension,
|
|
28
|
+
viewport: Viewport,
|
|
29
|
+
afterCritical: LiftEffect,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default ({
|
|
33
|
+
previousPageBorderBoxCenter,
|
|
34
|
+
moveRelativeTo,
|
|
35
|
+
insideDestination,
|
|
36
|
+
draggable,
|
|
37
|
+
draggables,
|
|
38
|
+
destination,
|
|
39
|
+
viewport,
|
|
40
|
+
afterCritical,
|
|
41
|
+
}: Args): DragImpact | null => {
|
|
42
|
+
if (!moveRelativeTo) {
|
|
43
|
+
// Draggables available, but none are candidates for movement
|
|
44
|
+
if (insideDestination.length) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Try move to top of empty list if it is visible
|
|
49
|
+
const proposed: DragImpact = {
|
|
50
|
+
displaced: emptyGroups,
|
|
51
|
+
displacedBy: noDisplacedBy,
|
|
52
|
+
at: {
|
|
53
|
+
type: 'REORDER',
|
|
54
|
+
destination: {
|
|
55
|
+
droppableId: destination.descriptor.id,
|
|
56
|
+
index: 0,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const proposedPageBorderBoxCenter: Position = getPageBorderBoxCenter({
|
|
61
|
+
impact: proposed,
|
|
62
|
+
draggable,
|
|
63
|
+
droppable: destination,
|
|
64
|
+
draggables,
|
|
65
|
+
afterCritical,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// need to add room for a placeholder in a foreign list
|
|
69
|
+
const withPlaceholder: DroppableDimension = isHomeOf(draggable, destination)
|
|
70
|
+
? destination
|
|
71
|
+
: addPlaceholder(destination, draggable, draggables);
|
|
72
|
+
|
|
73
|
+
const isVisibleInNewLocation: boolean = isTotallyVisibleInNewLocation({
|
|
74
|
+
draggable,
|
|
75
|
+
destination: withPlaceholder,
|
|
76
|
+
newPageBorderBoxCenter: proposedPageBorderBoxCenter,
|
|
77
|
+
viewport: viewport.frame,
|
|
78
|
+
// already taken into account by getPageBorderBoxCenter
|
|
79
|
+
withDroppableDisplacement: false,
|
|
80
|
+
onlyOnMainAxis: true,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return isVisibleInNewLocation ? proposed : null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const isGoingBeforeTarget: boolean = Boolean(
|
|
87
|
+
// Using <= as we optimise slightly for moving before items in a new list
|
|
88
|
+
// This is nicer in lists with fixed height items
|
|
89
|
+
previousPageBorderBoxCenter[destination.axis.line] <=
|
|
90
|
+
moveRelativeTo.page.borderBox.center[destination.axis.line],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const proposedIndex: number = (() => {
|
|
94
|
+
const relativeTo: number = moveRelativeTo.descriptor.index;
|
|
95
|
+
|
|
96
|
+
if (moveRelativeTo.descriptor.id === draggable.descriptor.id) {
|
|
97
|
+
return relativeTo;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (isGoingBeforeTarget) {
|
|
101
|
+
return relativeTo;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return relativeTo + 1;
|
|
105
|
+
})();
|
|
106
|
+
|
|
107
|
+
const displacedBy: DisplacedBy = getDisplacedBy(
|
|
108
|
+
destination.axis,
|
|
109
|
+
draggable.displaceBy,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return calculateReorderImpact({
|
|
113
|
+
draggable,
|
|
114
|
+
insideDestination,
|
|
115
|
+
destination,
|
|
116
|
+
viewport,
|
|
117
|
+
displacedBy,
|
|
118
|
+
// last groups won't be relevant
|
|
119
|
+
last: emptyGroups,
|
|
120
|
+
index: proposedIndex,
|
|
121
|
+
});
|
|
122
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Position, Rect, Spacing } from 'css-box-model';
|
|
3
|
+
import type { DraggableDimension, LiftEffect } from '../../../types';
|
|
4
|
+
import { negate, subtract } from '../../position';
|
|
5
|
+
import { offsetByPosition } from '../../spacing';
|
|
6
|
+
import didStartAfterCritical from '../../did-start-after-critical';
|
|
7
|
+
|
|
8
|
+
export const getCurrentPageBorderBoxCenter = (
|
|
9
|
+
draggable: DraggableDimension,
|
|
10
|
+
afterCritical: LiftEffect,
|
|
11
|
+
): Position => {
|
|
12
|
+
// If an item started displaced it is now resting
|
|
13
|
+
// in a non-displaced location
|
|
14
|
+
const original: Position = draggable.page.borderBox.center;
|
|
15
|
+
return didStartAfterCritical(draggable.descriptor.id, afterCritical)
|
|
16
|
+
? subtract(original, afterCritical.displacedBy.point)
|
|
17
|
+
: original;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const getCurrentPageBorderBox = (
|
|
21
|
+
draggable: DraggableDimension,
|
|
22
|
+
afterCritical: LiftEffect,
|
|
23
|
+
): Spacing => {
|
|
24
|
+
// If an item started displaced it is now resting
|
|
25
|
+
// in a non-displaced location
|
|
26
|
+
const original: Rect = draggable.page.borderBox;
|
|
27
|
+
|
|
28
|
+
return didStartAfterCritical(draggable.descriptor.id, afterCritical)
|
|
29
|
+
? offsetByPosition(original, negate(afterCritical.displacedBy.point))
|
|
30
|
+
: original;
|
|
31
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Position } from 'css-box-model';
|
|
3
|
+
import type {
|
|
4
|
+
DroppableDimension,
|
|
5
|
+
DraggableDimension,
|
|
6
|
+
DraggableDimensionMap,
|
|
7
|
+
DragImpact,
|
|
8
|
+
Viewport,
|
|
9
|
+
LiftEffect,
|
|
10
|
+
} from '../../../types';
|
|
11
|
+
import type { PublicResult } from '../move-in-direction-types';
|
|
12
|
+
import getDraggablesInsideDroppable from '../../get-draggables-inside-droppable';
|
|
13
|
+
import moveToNextCombine from './move-to-next-combine';
|
|
14
|
+
import moveToNextIndex from './move-to-next-index';
|
|
15
|
+
import isHomeOf from '../../droppable/is-home-of';
|
|
16
|
+
import getPageBorderBoxCenter from '../../get-center-from-impact/get-page-border-box-center';
|
|
17
|
+
import speculativelyIncrease from '../../update-displacement-visibility/speculatively-increase';
|
|
18
|
+
import getClientFromPageBorderBoxCenter from '../../get-center-from-impact/get-client-border-box-center/get-client-from-page-border-box-center';
|
|
19
|
+
import { subtract } from '../../position';
|
|
20
|
+
import isTotallyVisibleInNewLocation from './is-totally-visible-in-new-location';
|
|
21
|
+
|
|
22
|
+
// Exact
|
|
23
|
+
type Args = {
|
|
24
|
+
isMovingForward: boolean,
|
|
25
|
+
draggable: DraggableDimension,
|
|
26
|
+
destination: DroppableDimension,
|
|
27
|
+
draggables: DraggableDimensionMap,
|
|
28
|
+
previousImpact: DragImpact,
|
|
29
|
+
viewport: Viewport,
|
|
30
|
+
previousClientSelection: Position,
|
|
31
|
+
previousPageBorderBoxCenter: Position,
|
|
32
|
+
afterCritical: LiftEffect,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default ({
|
|
36
|
+
isMovingForward,
|
|
37
|
+
draggable,
|
|
38
|
+
destination,
|
|
39
|
+
draggables,
|
|
40
|
+
previousImpact,
|
|
41
|
+
viewport,
|
|
42
|
+
previousPageBorderBoxCenter,
|
|
43
|
+
previousClientSelection,
|
|
44
|
+
afterCritical,
|
|
45
|
+
}: Args): PublicResult | null => {
|
|
46
|
+
if (!destination.isEnabled) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const insideDestination: DraggableDimension[] = getDraggablesInsideDroppable(
|
|
51
|
+
destination.descriptor.id,
|
|
52
|
+
draggables,
|
|
53
|
+
);
|
|
54
|
+
const isInHomeList: boolean = isHomeOf(draggable, destination);
|
|
55
|
+
|
|
56
|
+
const impact: DragImpact | null =
|
|
57
|
+
moveToNextCombine({
|
|
58
|
+
isMovingForward,
|
|
59
|
+
draggable,
|
|
60
|
+
destination,
|
|
61
|
+
insideDestination,
|
|
62
|
+
previousImpact,
|
|
63
|
+
}) ||
|
|
64
|
+
moveToNextIndex({
|
|
65
|
+
isMovingForward,
|
|
66
|
+
isInHomeList,
|
|
67
|
+
draggable,
|
|
68
|
+
draggables,
|
|
69
|
+
destination,
|
|
70
|
+
insideDestination,
|
|
71
|
+
previousImpact,
|
|
72
|
+
viewport,
|
|
73
|
+
afterCritical,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (!impact) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const pageBorderBoxCenter: Position = getPageBorderBoxCenter({
|
|
81
|
+
impact,
|
|
82
|
+
draggable,
|
|
83
|
+
droppable: destination,
|
|
84
|
+
draggables,
|
|
85
|
+
afterCritical,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const isVisibleInNewLocation: boolean = isTotallyVisibleInNewLocation({
|
|
89
|
+
draggable,
|
|
90
|
+
destination,
|
|
91
|
+
newPageBorderBoxCenter: pageBorderBoxCenter,
|
|
92
|
+
viewport: viewport.frame,
|
|
93
|
+
// already taken into account by getPageBorderBoxCenter
|
|
94
|
+
withDroppableDisplacement: false,
|
|
95
|
+
// we only care about it being visible relative to the main axis
|
|
96
|
+
// this is important with dynamic changes as scroll bar and toggle
|
|
97
|
+
// on the cross axis during a drag
|
|
98
|
+
onlyOnMainAxis: true,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (isVisibleInNewLocation) {
|
|
102
|
+
// using the client center as the selection point
|
|
103
|
+
const clientSelection: Position = getClientFromPageBorderBoxCenter({
|
|
104
|
+
pageBorderBoxCenter,
|
|
105
|
+
draggable,
|
|
106
|
+
viewport,
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
clientSelection,
|
|
110
|
+
impact,
|
|
111
|
+
scrollJumpRequest: null,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const distance: Position = subtract(
|
|
116
|
+
pageBorderBoxCenter,
|
|
117
|
+
previousPageBorderBoxCenter,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const cautious: DragImpact = speculativelyIncrease({
|
|
121
|
+
impact,
|
|
122
|
+
viewport,
|
|
123
|
+
destination,
|
|
124
|
+
draggables,
|
|
125
|
+
maxScrollChange: distance,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
clientSelection: previousClientSelection,
|
|
130
|
+
impact: cautious,
|
|
131
|
+
scrollJumpRequest: distance,
|
|
132
|
+
};
|
|
133
|
+
};
|