@helpdice/draggable 0.0.0-stage → 0.0.1
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 +9915 -0
- package/dist/draggable.cjs.js.map +1 -0
- package/dist/draggable.esm.js +9889 -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,255 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { invariant } from '../../../invariant';
|
|
3
|
+
import messagePreset from '../../../screen-reader-message-preset';
|
|
4
|
+
import * as timings from '../../../debug/timings';
|
|
5
|
+
import getExpiringAnnounce, {
|
|
6
|
+
type ExpiringAnnounce,
|
|
7
|
+
} from './expiring-announce';
|
|
8
|
+
import getAsyncMarshal, { type AsyncMarshal } from './async-marshal';
|
|
9
|
+
import type {
|
|
10
|
+
DropResult,
|
|
11
|
+
Responders,
|
|
12
|
+
ResponderProvided,
|
|
13
|
+
Critical,
|
|
14
|
+
BeforeCapture,
|
|
15
|
+
DragImpact,
|
|
16
|
+
DraggableLocation,
|
|
17
|
+
Combine,
|
|
18
|
+
DragStart,
|
|
19
|
+
Announce,
|
|
20
|
+
DragUpdate,
|
|
21
|
+
MovementMode,
|
|
22
|
+
DraggableId,
|
|
23
|
+
OnBeforeCaptureResponder,
|
|
24
|
+
OnBeforeDragStartResponder,
|
|
25
|
+
OnDragStartResponder,
|
|
26
|
+
OnDragUpdateResponder,
|
|
27
|
+
OnDragEndResponder,
|
|
28
|
+
} from '../../../types';
|
|
29
|
+
import { isCombineEqual, isCriticalEqual, areLocationsEqual } from './is-equal';
|
|
30
|
+
import { tryGetDestination, tryGetCombine } from '../../get-impact-location';
|
|
31
|
+
|
|
32
|
+
const withTimings = (key: string, fn: Function) => {
|
|
33
|
+
timings.start(key);
|
|
34
|
+
fn();
|
|
35
|
+
timings.finish(key);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const getDragStart = (critical: Critical, mode: MovementMode): DragStart => ({
|
|
39
|
+
draggableId: critical.draggable.id,
|
|
40
|
+
type: critical.droppable.type,
|
|
41
|
+
source: {
|
|
42
|
+
droppableId: critical.droppable.id,
|
|
43
|
+
index: critical.draggable.index,
|
|
44
|
+
},
|
|
45
|
+
mode,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
type AnyPrimaryResponderFn =
|
|
49
|
+
| OnDragStartResponder
|
|
50
|
+
| OnDragUpdateResponder
|
|
51
|
+
| OnDragEndResponder;
|
|
52
|
+
|
|
53
|
+
type AnyResponderData = DragStart | DragUpdate | DropResult;
|
|
54
|
+
|
|
55
|
+
const execute = (
|
|
56
|
+
responder: AnyPrimaryResponderFn | null,
|
|
57
|
+
data: AnyResponderData,
|
|
58
|
+
announce: Announce,
|
|
59
|
+
getDefaultMessage: (data: any) => string,
|
|
60
|
+
) => {
|
|
61
|
+
if (!responder) {
|
|
62
|
+
announce(getDefaultMessage(data));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const willExpire: ExpiringAnnounce = getExpiringAnnounce(announce);
|
|
67
|
+
const provided: ResponderProvided = {
|
|
68
|
+
announce: willExpire,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Casting because we are not validating which data type is going into which responder
|
|
72
|
+
responder(data as any, provided); // Casted to any
|
|
73
|
+
|
|
74
|
+
if (!willExpire.wasCalled()) {
|
|
75
|
+
announce(getDefaultMessage(data));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Exact
|
|
80
|
+
export type WhileDragging = {
|
|
81
|
+
mode: MovementMode
|
|
82
|
+
lastCritical: Critical,
|
|
83
|
+
lastCombine: Combine | null,
|
|
84
|
+
lastLocation: DraggableLocation | null,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default (getResponders: () => Responders, announce: Announce) => {
|
|
88
|
+
const asyncMarshal: AsyncMarshal = getAsyncMarshal();
|
|
89
|
+
let dragging: WhileDragging | null = null;
|
|
90
|
+
|
|
91
|
+
const beforeCapture = (draggableId: DraggableId, mode: MovementMode) => {
|
|
92
|
+
invariant(
|
|
93
|
+
!dragging,
|
|
94
|
+
'Cannot fire onBeforeCapture as a drag start has already been published',
|
|
95
|
+
);
|
|
96
|
+
withTimings('onBeforeCapture', () => {
|
|
97
|
+
// No use of screen reader for this responder
|
|
98
|
+
const fn: OnBeforeCaptureResponder | null = getResponders().onBeforeCapture;
|
|
99
|
+
if (fn) {
|
|
100
|
+
const before: BeforeCapture = {
|
|
101
|
+
draggableId,
|
|
102
|
+
mode,
|
|
103
|
+
};
|
|
104
|
+
fn(before);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const beforeStart = (critical: Critical, mode: MovementMode) => {
|
|
110
|
+
invariant(
|
|
111
|
+
!dragging,
|
|
112
|
+
'Cannot fire onBeforeDragStart as a drag start has already been published',
|
|
113
|
+
);
|
|
114
|
+
withTimings('onBeforeDragStart', () => {
|
|
115
|
+
// No use of screen reader for this responder
|
|
116
|
+
const fn: OnBeforeDragStartResponder | null = getResponders().onBeforeDragStart;
|
|
117
|
+
if (fn) {
|
|
118
|
+
fn(getDragStart(critical, mode));
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const start = (critical: Critical, mode: MovementMode) => {
|
|
124
|
+
invariant(
|
|
125
|
+
!dragging,
|
|
126
|
+
'Cannot fire onBeforeDragStart as a drag start has already been published',
|
|
127
|
+
);
|
|
128
|
+
const data: DragStart = getDragStart(critical, mode);
|
|
129
|
+
dragging = {
|
|
130
|
+
mode,
|
|
131
|
+
lastCritical: critical,
|
|
132
|
+
lastLocation: data.source,
|
|
133
|
+
lastCombine: null,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// we will flush this frame if we receive any responder updates
|
|
137
|
+
asyncMarshal.add(() => {
|
|
138
|
+
withTimings('onDragStart', () =>
|
|
139
|
+
execute(
|
|
140
|
+
getResponders().onDragStart,
|
|
141
|
+
data,
|
|
142
|
+
announce,
|
|
143
|
+
messagePreset.onDragStart,
|
|
144
|
+
),
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// Passing in the critical location again as it can change during a drag
|
|
150
|
+
const update = (critical: Critical, impact: DragImpact) => {
|
|
151
|
+
const location: DraggableLocation | null = tryGetDestination(impact);
|
|
152
|
+
const combine: Combine | null = tryGetCombine(impact);
|
|
153
|
+
|
|
154
|
+
invariant(
|
|
155
|
+
dragging,
|
|
156
|
+
'Cannot fire onDragMove when onDragStart has not been called',
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// Has the critical changed? Will result in a source change
|
|
160
|
+
const hasCriticalChanged: boolean = !isCriticalEqual(
|
|
161
|
+
critical,
|
|
162
|
+
dragging.lastCritical,
|
|
163
|
+
);
|
|
164
|
+
if (hasCriticalChanged) {
|
|
165
|
+
dragging.lastCritical = critical;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Has the location changed? Will result in a destination change
|
|
169
|
+
const hasLocationChanged: boolean = !areLocationsEqual(
|
|
170
|
+
dragging.lastLocation,
|
|
171
|
+
location,
|
|
172
|
+
);
|
|
173
|
+
if (hasLocationChanged) {
|
|
174
|
+
dragging.lastLocation = location;
|
|
175
|
+
}
|
|
176
|
+
const hasGroupingChanged: boolean = !isCombineEqual(
|
|
177
|
+
dragging.lastCombine,
|
|
178
|
+
combine,
|
|
179
|
+
);
|
|
180
|
+
if (hasGroupingChanged) {
|
|
181
|
+
dragging.lastCombine = combine;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Nothing has changed - no update needed
|
|
185
|
+
if (!hasCriticalChanged && !hasLocationChanged && !hasGroupingChanged) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const data: DragUpdate = {
|
|
190
|
+
...getDragStart(critical, dragging.mode),
|
|
191
|
+
combine,
|
|
192
|
+
destination: location,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
asyncMarshal.add(() => {
|
|
196
|
+
withTimings('onDragUpdate', () =>
|
|
197
|
+
execute(
|
|
198
|
+
getResponders().onDragUpdate,
|
|
199
|
+
data,
|
|
200
|
+
announce,
|
|
201
|
+
messagePreset.onDragUpdate,
|
|
202
|
+
),
|
|
203
|
+
);
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const flush = () => {
|
|
208
|
+
invariant(dragging, 'Can only flush responders while dragging');
|
|
209
|
+
asyncMarshal.flush();
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const drop = (result: DropResult) => {
|
|
213
|
+
invariant(
|
|
214
|
+
dragging,
|
|
215
|
+
'Cannot fire onDragEnd when there is no matching onDragStart',
|
|
216
|
+
);
|
|
217
|
+
dragging = null;
|
|
218
|
+
// not adding to frame marshal - we want this to be done in the same render pass
|
|
219
|
+
// we also want the consumers reorder logic to be in the same render pass
|
|
220
|
+
withTimings('onDragEnd', () =>
|
|
221
|
+
execute(
|
|
222
|
+
getResponders().onDragEnd,
|
|
223
|
+
result,
|
|
224
|
+
announce,
|
|
225
|
+
messagePreset.onDragEnd,
|
|
226
|
+
),
|
|
227
|
+
);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// A non user initiated cancel
|
|
231
|
+
const abort = () => {
|
|
232
|
+
// aborting can happen defensively
|
|
233
|
+
if (!dragging) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const result: DropResult = {
|
|
238
|
+
...getDragStart(dragging.lastCritical, dragging.mode),
|
|
239
|
+
combine: null,
|
|
240
|
+
destination: null,
|
|
241
|
+
reason: 'CANCEL',
|
|
242
|
+
};
|
|
243
|
+
drop(result);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
beforeCapture,
|
|
248
|
+
beforeStart,
|
|
249
|
+
start,
|
|
250
|
+
update,
|
|
251
|
+
flush,
|
|
252
|
+
drop,
|
|
253
|
+
abort,
|
|
254
|
+
};
|
|
255
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import getPublisher from './publisher';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
State,
|
|
6
|
+
DropResult,
|
|
7
|
+
Responders,
|
|
8
|
+
Critical,
|
|
9
|
+
Announce,
|
|
10
|
+
} from '../../../types';
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
Action,
|
|
14
|
+
// Middleware,
|
|
15
|
+
MiddlewareStore,
|
|
16
|
+
Dispatch,
|
|
17
|
+
} from '../../store-types';
|
|
18
|
+
|
|
19
|
+
export default (
|
|
20
|
+
getResponders: () => Responders,
|
|
21
|
+
announce: Announce,
|
|
22
|
+
) => { // Middleware
|
|
23
|
+
const publisher = getPublisher(
|
|
24
|
+
getResponders,
|
|
25
|
+
announce,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return (store: MiddlewareStore) => (next: Dispatch) => (
|
|
29
|
+
action: Action,
|
|
30
|
+
): any => {
|
|
31
|
+
|
|
32
|
+
if (action.type === 'BEFORE_INITIAL_CAPTURE') {
|
|
33
|
+
publisher.beforeCapture(
|
|
34
|
+
action.payload.draggableId,
|
|
35
|
+
action.payload.movementMode,
|
|
36
|
+
);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (action.type === 'INITIAL_PUBLISH') {
|
|
41
|
+
const critical: Critical = action.payload.critical;
|
|
42
|
+
publisher.beforeStart(critical, action.payload.movementMode);
|
|
43
|
+
next(action);
|
|
44
|
+
publisher.start(critical, action.payload.movementMode);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Drag end
|
|
49
|
+
if (action.type === 'DROP_COMPLETE') {
|
|
50
|
+
// it is important that we use the result and not the last impact
|
|
51
|
+
// the last impact might be different to the result for visual reasons
|
|
52
|
+
const result: DropResult = action.payload.completed.result;
|
|
53
|
+
// flushing all pending responders before snapshots are updated
|
|
54
|
+
publisher.flush();
|
|
55
|
+
next(action);
|
|
56
|
+
publisher.drop(result);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// All other responders can fire after we have updated our connected components
|
|
61
|
+
next(action);
|
|
62
|
+
|
|
63
|
+
// Drag state resetting - need to check if
|
|
64
|
+
// we should fire a onDragEnd responder
|
|
65
|
+
if (action.type === 'FLUSH') {
|
|
66
|
+
publisher.abort();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ## Perform drag updates
|
|
71
|
+
// impact of action has already been reduced
|
|
72
|
+
|
|
73
|
+
const state: State = store.getState();
|
|
74
|
+
|
|
75
|
+
if (state.phase === 'DRAGGING') {
|
|
76
|
+
publisher.update(state.critical, state.impact);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
};
|
|
81
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Position } from 'css-box-model';
|
|
3
|
+
import { moveByWindowScroll } from '../action-creators';
|
|
4
|
+
import type { MiddlewareStore, Action, Dispatch } from '../store-types';
|
|
5
|
+
import getScrollListener from '../../view/scroll-listener';
|
|
6
|
+
|
|
7
|
+
// TODO: this is taken from auto-scroll. Let's make it a util
|
|
8
|
+
const shouldEnd = (action: Action): boolean =>
|
|
9
|
+
action.type === 'DROP_COMPLETE' ||
|
|
10
|
+
action.type === 'DROP_ANIMATE' ||
|
|
11
|
+
action.type === 'FLUSH';
|
|
12
|
+
|
|
13
|
+
export default (store: MiddlewareStore) => {
|
|
14
|
+
const listener = getScrollListener({
|
|
15
|
+
onWindowScroll: (newScroll: Position) => {
|
|
16
|
+
store.dispatch(moveByWindowScroll({ newScroll }));
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return (next: Dispatch) => (action: Action): any => {
|
|
21
|
+
if (!listener.isActive() && action.type === 'INITIAL_PUBLISH') {
|
|
22
|
+
listener.start();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (listener.isActive() && shouldEnd(action)) {
|
|
26
|
+
listener.stop();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
next(action);
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Action, Dispatch } from '../store-types';
|
|
3
|
+
import type { StyleMarshal } from '../../view/use-style-marshal/style-marshal-types';
|
|
4
|
+
|
|
5
|
+
export default (marshal: StyleMarshal) => () => (next: Dispatch) => (
|
|
6
|
+
action: Action,
|
|
7
|
+
): any => {
|
|
8
|
+
if (action.type === 'INITIAL_PUBLISH') {
|
|
9
|
+
marshal.dragging();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (action.type === 'DROP_ANIMATE') {
|
|
13
|
+
marshal.dropping(action.payload.completed.result.reason);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// this will clear any styles immediately before a reorder
|
|
17
|
+
if (action.type === 'FLUSH' || action.type === 'DROP_COMPLETE') {
|
|
18
|
+
marshal.resting();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
next(action);
|
|
22
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type {
|
|
3
|
+
Critical,
|
|
4
|
+
DimensionMap,
|
|
5
|
+
DraggableDimension,
|
|
6
|
+
} from '../../../types';
|
|
7
|
+
import getDraggablesInsideDroppable from '../../get-draggables-inside-droppable';
|
|
8
|
+
import { warning } from '../../../dev-warning';
|
|
9
|
+
|
|
10
|
+
type ErrorMap = {
|
|
11
|
+
[index: number]: true,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function checkIndexes(insideDestination: DraggableDimension[]) {
|
|
15
|
+
// no point running if there are 1 or less items
|
|
16
|
+
if (insideDestination.length <= 1) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const indexes: number[] = insideDestination.map(
|
|
21
|
+
(d: DraggableDimension): number => d.descriptor.index,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const errors: ErrorMap = {};
|
|
25
|
+
|
|
26
|
+
for (let i = 1; i < indexes.length; i++) {
|
|
27
|
+
const current: number = indexes[i];
|
|
28
|
+
const previous: number = indexes[i - 1];
|
|
29
|
+
|
|
30
|
+
// this will be an error if:
|
|
31
|
+
// 1. index is not consecutive
|
|
32
|
+
// 2. index is duplicated (which is true if #1 is not passed)
|
|
33
|
+
if (current !== previous + 1) {
|
|
34
|
+
errors[current] = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!Object.keys(errors).length) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const formatted: string = indexes
|
|
43
|
+
.map((index: number): string => {
|
|
44
|
+
const hasError: boolean = Boolean(errors[index]);
|
|
45
|
+
|
|
46
|
+
return hasError ? `[🔥${index}]` : `${index}`;
|
|
47
|
+
})
|
|
48
|
+
.join(', ');
|
|
49
|
+
|
|
50
|
+
warning(`
|
|
51
|
+
Detected non-consecutive <Draggable /> indexes.
|
|
52
|
+
|
|
53
|
+
(This can cause unexpected bugs)
|
|
54
|
+
|
|
55
|
+
${formatted}
|
|
56
|
+
`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default function validateDimensions(
|
|
60
|
+
critical: Critical,
|
|
61
|
+
dimensions: DimensionMap,
|
|
62
|
+
): void {
|
|
63
|
+
// wrapping entire block for better minification
|
|
64
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
65
|
+
const insideDestination: DraggableDimension[] = getDraggablesInsideDroppable(
|
|
66
|
+
critical.droppable.id,
|
|
67
|
+
dimensions.draggables,
|
|
68
|
+
);
|
|
69
|
+
checkIndexes(insideDestination);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Position } from 'css-box-model';
|
|
3
|
+
import type { PublicResult } from './move-in-direction-types';
|
|
4
|
+
import type {
|
|
5
|
+
DroppableId,
|
|
6
|
+
DraggingState,
|
|
7
|
+
Direction,
|
|
8
|
+
DroppableDimension,
|
|
9
|
+
DraggableDimension,
|
|
10
|
+
DroppableDimensionMap,
|
|
11
|
+
DragImpact,
|
|
12
|
+
} from '../../types';
|
|
13
|
+
import moveToNextPlace from './move-to-next-place';
|
|
14
|
+
import moveCrossAxis from './move-cross-axis';
|
|
15
|
+
import whatIsDraggedOver from '../droppable/what-is-dragged-over';
|
|
16
|
+
|
|
17
|
+
// Exact
|
|
18
|
+
type Args = {
|
|
19
|
+
state: DraggingState,
|
|
20
|
+
type: 'MOVE_UP' | 'MOVE_RIGHT' | 'MOVE_DOWN' | 'MOVE_LEFT',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getDroppableOver = (
|
|
24
|
+
impact: DragImpact,
|
|
25
|
+
droppables: DroppableDimensionMap,
|
|
26
|
+
): DroppableDimension | null => {
|
|
27
|
+
const id: DroppableId | null = whatIsDraggedOver(impact);
|
|
28
|
+
return id ? droppables[id] : null;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default ({ state, type }: Args): PublicResult | null => {
|
|
32
|
+
const isActuallyOver: DroppableDimension | null = getDroppableOver(
|
|
33
|
+
state.impact,
|
|
34
|
+
state.dimensions.droppables,
|
|
35
|
+
);
|
|
36
|
+
const isMainAxisMovementAllowed: boolean = Boolean(isActuallyOver);
|
|
37
|
+
const home: DroppableDimension =
|
|
38
|
+
state.dimensions.droppables[state.critical.droppable.id];
|
|
39
|
+
// use home when not actually over a droppable (can happen when move is disabled)
|
|
40
|
+
const isOver: DroppableDimension = isActuallyOver || home;
|
|
41
|
+
|
|
42
|
+
const direction: Direction = isOver.axis.direction;
|
|
43
|
+
const isMovingOnMainAxis: boolean =
|
|
44
|
+
(direction === 'vertical' &&
|
|
45
|
+
(type === 'MOVE_UP' || type === 'MOVE_DOWN')) ||
|
|
46
|
+
(direction === 'horizontal' &&
|
|
47
|
+
(type === 'MOVE_LEFT' || type === 'MOVE_RIGHT'));
|
|
48
|
+
|
|
49
|
+
// This movement is not permitted right now
|
|
50
|
+
if (isMovingOnMainAxis && !isMainAxisMovementAllowed) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const isMovingForward: boolean =
|
|
55
|
+
type === 'MOVE_DOWN' || type === 'MOVE_RIGHT';
|
|
56
|
+
|
|
57
|
+
const draggable: DraggableDimension =
|
|
58
|
+
state.dimensions.draggables[state.critical.draggable.id];
|
|
59
|
+
const previousPageBorderBoxCenter: Position =
|
|
60
|
+
state.current.page.borderBoxCenter;
|
|
61
|
+
const { draggables, droppables } = state.dimensions;
|
|
62
|
+
|
|
63
|
+
return isMovingOnMainAxis
|
|
64
|
+
? moveToNextPlace({
|
|
65
|
+
isMovingForward,
|
|
66
|
+
previousPageBorderBoxCenter,
|
|
67
|
+
draggable,
|
|
68
|
+
destination: isOver,
|
|
69
|
+
draggables,
|
|
70
|
+
viewport: state.viewport,
|
|
71
|
+
previousClientSelection: state.current.client.selection,
|
|
72
|
+
previousImpact: state.impact,
|
|
73
|
+
afterCritical: state.afterCritical,
|
|
74
|
+
})
|
|
75
|
+
: moveCrossAxis({
|
|
76
|
+
isMovingForward,
|
|
77
|
+
previousPageBorderBoxCenter,
|
|
78
|
+
draggable,
|
|
79
|
+
isOver,
|
|
80
|
+
draggables,
|
|
81
|
+
droppables,
|
|
82
|
+
viewport: state.viewport,
|
|
83
|
+
afterCritical: state.afterCritical,
|
|
84
|
+
});
|
|
85
|
+
};
|