@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,597 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
// eslint-disable-next-line no-unused-vars
|
|
3
|
+
|
|
4
|
+
import { memo, useMemo, useCallback } from 'react';
|
|
5
|
+
import memoizeOne from 'memoize-one';
|
|
6
|
+
|
|
7
|
+
import { invariant } from '../../invariant';
|
|
8
|
+
|
|
9
|
+
import type {
|
|
10
|
+
State,
|
|
11
|
+
DroppableId,
|
|
12
|
+
DraggableId,
|
|
13
|
+
CompletedDrag,
|
|
14
|
+
DraggableDimension,
|
|
15
|
+
DimensionMap,
|
|
16
|
+
TypeId,
|
|
17
|
+
Critical,
|
|
18
|
+
DraggableRubric,
|
|
19
|
+
DraggableDescriptor,
|
|
20
|
+
} from '../../types';
|
|
21
|
+
|
|
22
|
+
import type {
|
|
23
|
+
MapProps,
|
|
24
|
+
OwnProps,
|
|
25
|
+
DefaultProps,
|
|
26
|
+
Selector,
|
|
27
|
+
StateSnapshot,
|
|
28
|
+
UseClone,
|
|
29
|
+
DraggableChildrenFn,
|
|
30
|
+
} from './droppable-types';
|
|
31
|
+
|
|
32
|
+
import Droppable from './droppable';
|
|
33
|
+
|
|
34
|
+
import whatIsDraggedOver from '../../state/droppable/what-is-dragged-over';
|
|
35
|
+
import whatIsDraggedOverFromResult from '../../state/droppable/what-is-dragged-over-from-result';
|
|
36
|
+
|
|
37
|
+
import {
|
|
38
|
+
updateViewportMaxScroll as updateViewportMaxScrollAction,
|
|
39
|
+
} from '../../state/action-creators';
|
|
40
|
+
|
|
41
|
+
import { isDragging } from '../../state/reducer';
|
|
42
|
+
|
|
43
|
+
import {
|
|
44
|
+
useAppDispatch,
|
|
45
|
+
useAppSelector,
|
|
46
|
+
} from '../context/hooks';
|
|
47
|
+
|
|
48
|
+
// -----------------------------------------------------------------------------
|
|
49
|
+
// Helpers
|
|
50
|
+
// -----------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
const isMatchingType = (
|
|
53
|
+
type: TypeId,
|
|
54
|
+
critical: Critical,
|
|
55
|
+
): boolean => type === critical.droppable.type;
|
|
56
|
+
|
|
57
|
+
const getDraggable = (
|
|
58
|
+
critical: Critical,
|
|
59
|
+
dimensions: DimensionMap,
|
|
60
|
+
): DraggableDimension =>
|
|
61
|
+
dimensions.draggables[critical.draggable.id];
|
|
62
|
+
|
|
63
|
+
// -----------------------------------------------------------------------------
|
|
64
|
+
// Selector
|
|
65
|
+
// -----------------------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
export const makeMapStateToProps = (): Selector => {
|
|
68
|
+
const idleWithAnimation: MapProps = {
|
|
69
|
+
placeholder: null,
|
|
70
|
+
shouldAnimatePlaceholder: true,
|
|
71
|
+
snapshot: {
|
|
72
|
+
isDraggingOver: false,
|
|
73
|
+
draggingOverWith: null,
|
|
74
|
+
draggingFromThisWith: null,
|
|
75
|
+
isUsingPlaceholder: false,
|
|
76
|
+
},
|
|
77
|
+
useClone: null,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const idleWithoutAnimation: MapProps = {
|
|
81
|
+
...idleWithAnimation,
|
|
82
|
+
shouldAnimatePlaceholder: false,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const getDraggableRubric = memoizeOne(
|
|
86
|
+
(descriptor: DraggableDescriptor): DraggableRubric => ({
|
|
87
|
+
draggableId: descriptor.id,
|
|
88
|
+
type: descriptor.type,
|
|
89
|
+
source: {
|
|
90
|
+
index: descriptor.index,
|
|
91
|
+
droppableId: descriptor.droppableId,
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const getMapProps = memoizeOne(
|
|
97
|
+
(
|
|
98
|
+
id: DroppableId,
|
|
99
|
+
isEnabled: boolean,
|
|
100
|
+
isDraggingOverForConsumer: boolean,
|
|
101
|
+
isDraggingOverForImpact: boolean,
|
|
102
|
+
dragging: DraggableDimension,
|
|
103
|
+
renderClone: DraggableChildrenFn | null,
|
|
104
|
+
): MapProps => {
|
|
105
|
+
const draggableId: DraggableId = dragging.descriptor.id;
|
|
106
|
+
const isHome: boolean =
|
|
107
|
+
dragging.descriptor.droppableId === id;
|
|
108
|
+
|
|
109
|
+
if (isHome) {
|
|
110
|
+
const useClone: UseClone | null = renderClone
|
|
111
|
+
? {
|
|
112
|
+
render: renderClone,
|
|
113
|
+
dragging: getDraggableRubric(dragging.descriptor),
|
|
114
|
+
}
|
|
115
|
+
: null;
|
|
116
|
+
|
|
117
|
+
const snapshot: StateSnapshot = {
|
|
118
|
+
isDraggingOver: isDraggingOverForConsumer,
|
|
119
|
+
draggingOverWith: isDraggingOverForConsumer
|
|
120
|
+
? draggableId
|
|
121
|
+
: null,
|
|
122
|
+
draggingFromThisWith: draggableId,
|
|
123
|
+
isUsingPlaceholder: true,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
placeholder: dragging.placeholder,
|
|
128
|
+
shouldAnimatePlaceholder: false,
|
|
129
|
+
snapshot,
|
|
130
|
+
useClone,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!isEnabled) {
|
|
135
|
+
return idleWithoutAnimation;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!isDraggingOverForImpact) {
|
|
139
|
+
return idleWithAnimation;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const snapshot: StateSnapshot = {
|
|
143
|
+
isDraggingOver: isDraggingOverForConsumer,
|
|
144
|
+
draggingOverWith: draggableId,
|
|
145
|
+
draggingFromThisWith: null,
|
|
146
|
+
isUsingPlaceholder: true,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
placeholder: dragging.placeholder,
|
|
151
|
+
shouldAnimatePlaceholder: true,
|
|
152
|
+
snapshot,
|
|
153
|
+
useClone: null,
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const selector: Selector = (
|
|
159
|
+
state: State,
|
|
160
|
+
ownProps: OwnProps,
|
|
161
|
+
): MapProps => {
|
|
162
|
+
const id: DroppableId = ownProps.droppableId;
|
|
163
|
+
const type: TypeId | undefined = ownProps.type;
|
|
164
|
+
const isEnabled: boolean = !ownProps.isDropDisabled;
|
|
165
|
+
const renderClone: DraggableChildrenFn | null =
|
|
166
|
+
ownProps.renderClone;
|
|
167
|
+
|
|
168
|
+
if (isDragging(state)) {
|
|
169
|
+
const critical: Critical = state.critical;
|
|
170
|
+
|
|
171
|
+
if (type && !isMatchingType(type, critical)) {
|
|
172
|
+
return idleWithoutAnimation;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const dragging: DraggableDimension = getDraggable(
|
|
176
|
+
critical,
|
|
177
|
+
state.dimensions,
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const isDraggingOver: boolean =
|
|
181
|
+
whatIsDraggedOver(state.impact) === id;
|
|
182
|
+
|
|
183
|
+
return getMapProps(
|
|
184
|
+
id,
|
|
185
|
+
isEnabled,
|
|
186
|
+
isDraggingOver,
|
|
187
|
+
isDraggingOver,
|
|
188
|
+
dragging,
|
|
189
|
+
renderClone,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (state.phase === 'DROP_ANIMATING') {
|
|
194
|
+
const completed: CompletedDrag = state.completed;
|
|
195
|
+
|
|
196
|
+
if (type && !isMatchingType(type, completed.critical)) {
|
|
197
|
+
return idleWithoutAnimation;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const dragging: DraggableDimension = getDraggable(
|
|
201
|
+
completed.critical,
|
|
202
|
+
state.dimensions,
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
return getMapProps(
|
|
206
|
+
id,
|
|
207
|
+
isEnabled,
|
|
208
|
+
whatIsDraggedOverFromResult(completed.result) === id,
|
|
209
|
+
whatIsDraggedOver(completed.impact) === id,
|
|
210
|
+
dragging,
|
|
211
|
+
renderClone,
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (
|
|
216
|
+
state.phase === 'IDLE' &&
|
|
217
|
+
state.completed &&
|
|
218
|
+
!state.shouldFlush
|
|
219
|
+
) {
|
|
220
|
+
const completed: CompletedDrag = state.completed;
|
|
221
|
+
|
|
222
|
+
if (type && !isMatchingType(type, completed.critical)) {
|
|
223
|
+
return idleWithoutAnimation;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const wasOver: boolean =
|
|
227
|
+
whatIsDraggedOver(completed.impact) === id;
|
|
228
|
+
|
|
229
|
+
const wasCombining: boolean = Boolean(
|
|
230
|
+
completed.impact.at &&
|
|
231
|
+
completed.impact.at.type === 'COMBINE',
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
const isHome: boolean =
|
|
235
|
+
completed.critical.droppable.id === id;
|
|
236
|
+
|
|
237
|
+
if (wasOver) {
|
|
238
|
+
return wasCombining
|
|
239
|
+
? idleWithAnimation
|
|
240
|
+
: idleWithoutAnimation;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (isHome) {
|
|
244
|
+
return idleWithAnimation;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return idleWithoutAnimation;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return idleWithoutAnimation;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
return selector;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// -----------------------------------------------------------------------------
|
|
257
|
+
// Default props
|
|
258
|
+
// -----------------------------------------------------------------------------
|
|
259
|
+
|
|
260
|
+
function getBody(): HTMLElement {
|
|
261
|
+
invariant(document.body, 'document.body is not ready');
|
|
262
|
+
return document.body;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const defaultProps: DefaultProps = {
|
|
266
|
+
mode: 'standard',
|
|
267
|
+
type: 'DEFAULT',
|
|
268
|
+
direction: 'vertical',
|
|
269
|
+
isDropDisabled: false,
|
|
270
|
+
isCombineEnabled: false,
|
|
271
|
+
ignoreContainerClipping: false,
|
|
272
|
+
renderClone: null,
|
|
273
|
+
getContainerForClone: getBody,
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// -----------------------------------------------------------------------------
|
|
277
|
+
// Connected Droppable using hooks
|
|
278
|
+
// -----------------------------------------------------------------------------
|
|
279
|
+
|
|
280
|
+
const ConnectedDroppable = (props: OwnProps) => {
|
|
281
|
+
const mergedProps = {
|
|
282
|
+
...defaultProps,
|
|
283
|
+
...props,
|
|
284
|
+
} as OwnProps;
|
|
285
|
+
|
|
286
|
+
// Each Droppable gets its own memoized selector
|
|
287
|
+
const selector = useMemo(
|
|
288
|
+
() => makeMapStateToProps(),
|
|
289
|
+
[],
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
const mapped: MapProps = useAppSelector(
|
|
293
|
+
(state: State) => selector(state, mergedProps),
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
const dispatch = useAppDispatch();
|
|
297
|
+
|
|
298
|
+
const updateViewportMaxScroll = useCallback(
|
|
299
|
+
(...args: Parameters<typeof updateViewportMaxScrollAction>) =>
|
|
300
|
+
dispatch(updateViewportMaxScrollAction(...args)),
|
|
301
|
+
[dispatch],
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
return (
|
|
305
|
+
<Droppable
|
|
306
|
+
{...mergedProps}
|
|
307
|
+
{...mapped}
|
|
308
|
+
updateViewportMaxScroll={updateViewportMaxScroll}
|
|
309
|
+
/>
|
|
310
|
+
);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
ConnectedDroppable.displayName = 'ConnectedDroppable';
|
|
314
|
+
|
|
315
|
+
export default memo(ConnectedDroppable);
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
// import { Component } from 'react';
|
|
320
|
+
// import { connect } from 'react-redux';
|
|
321
|
+
// import memoizeOne from 'memoize-one';
|
|
322
|
+
// import { invariant } from '../../invariant';
|
|
323
|
+
// import type {
|
|
324
|
+
// State,
|
|
325
|
+
// DroppableId,
|
|
326
|
+
// DraggableId,
|
|
327
|
+
// CompletedDrag,
|
|
328
|
+
// DraggableDimension,
|
|
329
|
+
// DimensionMap,
|
|
330
|
+
// TypeId,
|
|
331
|
+
// Critical,
|
|
332
|
+
// DraggableRubric,
|
|
333
|
+
// DraggableDescriptor,
|
|
334
|
+
// } from '../../types';
|
|
335
|
+
// import type {
|
|
336
|
+
// MapProps,
|
|
337
|
+
// OwnProps,
|
|
338
|
+
// DefaultProps,
|
|
339
|
+
// Selector,
|
|
340
|
+
// DispatchProps,
|
|
341
|
+
// StateSnapshot,
|
|
342
|
+
// UseClone,
|
|
343
|
+
// DraggableChildrenFn,
|
|
344
|
+
// } from './droppable-types';
|
|
345
|
+
// import Droppable from './droppable';
|
|
346
|
+
// import isStrictEqual from '../is-strict-equal';
|
|
347
|
+
// import whatIsDraggedOver from '../../state/droppable/what-is-dragged-over';
|
|
348
|
+
// import { updateViewportMaxScroll as updateViewportMaxScrollAction } from '../../state/action-creators';
|
|
349
|
+
// import StoreContext from '../context/store-context';
|
|
350
|
+
// import whatIsDraggedOverFromResult from '../../state/droppable/what-is-dragged-over-from-result';
|
|
351
|
+
// import { isDragging } from '../../state/reducer';
|
|
352
|
+
|
|
353
|
+
// const isMatchingType = (type: TypeId, critical: Critical): boolean =>
|
|
354
|
+
// type === critical.droppable.type;
|
|
355
|
+
|
|
356
|
+
// const getDraggable = (
|
|
357
|
+
// critical: Critical,
|
|
358
|
+
// dimensions: DimensionMap,
|
|
359
|
+
// ): DraggableDimension => dimensions.draggables[critical.draggable.id];
|
|
360
|
+
|
|
361
|
+
// // Returning a function to ensure each
|
|
362
|
+
// // Droppable gets its own selector
|
|
363
|
+
// export const makeMapStateToProps = (): Selector => {
|
|
364
|
+
// const idleWithAnimation: MapProps = {
|
|
365
|
+
// placeholder: null,
|
|
366
|
+
// shouldAnimatePlaceholder: true,
|
|
367
|
+
// snapshot: {
|
|
368
|
+
// isDraggingOver: false,
|
|
369
|
+
// draggingOverWith: null,
|
|
370
|
+
// draggingFromThisWith: null,
|
|
371
|
+
// isUsingPlaceholder: false,
|
|
372
|
+
// },
|
|
373
|
+
// useClone: null,
|
|
374
|
+
// };
|
|
375
|
+
|
|
376
|
+
// const idleWithoutAnimation = {
|
|
377
|
+
// ...idleWithAnimation,
|
|
378
|
+
// shouldAnimatePlaceholder: false,
|
|
379
|
+
// };
|
|
380
|
+
|
|
381
|
+
// const getDraggableRubric = memoizeOne(
|
|
382
|
+
// (descriptor: DraggableDescriptor): DraggableRubric => ({
|
|
383
|
+
// draggableId: descriptor.id,
|
|
384
|
+
// type: descriptor.type,
|
|
385
|
+
// source: {
|
|
386
|
+
// index: descriptor.index,
|
|
387
|
+
// droppableId: descriptor.droppableId,
|
|
388
|
+
// },
|
|
389
|
+
// }),
|
|
390
|
+
// );
|
|
391
|
+
|
|
392
|
+
// const getMapProps = memoizeOne(
|
|
393
|
+
// (
|
|
394
|
+
// id: DroppableId,
|
|
395
|
+
// isEnabled: boolean,
|
|
396
|
+
// isDraggingOverForConsumer: boolean,
|
|
397
|
+
// isDraggingOverForImpact: boolean,
|
|
398
|
+
// dragging: DraggableDimension,
|
|
399
|
+
// // snapshot: StateSnapshot,
|
|
400
|
+
// renderClone: ?DraggableChildrenFn,
|
|
401
|
+
// ): MapProps => {
|
|
402
|
+
// const draggableId: DraggableId = dragging.descriptor.id;
|
|
403
|
+
// const isHome: boolean = dragging.descriptor.droppableId === id;
|
|
404
|
+
|
|
405
|
+
// if (isHome) {
|
|
406
|
+
// const useClone: ?UseClone = renderClone
|
|
407
|
+
// ? {
|
|
408
|
+
// render: renderClone,
|
|
409
|
+
// dragging: getDraggableRubric(dragging.descriptor),
|
|
410
|
+
// }
|
|
411
|
+
// : null;
|
|
412
|
+
|
|
413
|
+
// const snapshot: StateSnapshot = {
|
|
414
|
+
// isDraggingOver: isDraggingOverForConsumer,
|
|
415
|
+
// draggingOverWith: isDraggingOverForConsumer ? draggableId : null,
|
|
416
|
+
// draggingFromThisWith: draggableId,
|
|
417
|
+
// isUsingPlaceholder: true,
|
|
418
|
+
// };
|
|
419
|
+
|
|
420
|
+
// return {
|
|
421
|
+
// placeholder: dragging.placeholder,
|
|
422
|
+
// shouldAnimatePlaceholder: false,
|
|
423
|
+
// snapshot,
|
|
424
|
+
// useClone,
|
|
425
|
+
// };
|
|
426
|
+
// }
|
|
427
|
+
|
|
428
|
+
// if (!isEnabled) {
|
|
429
|
+
// return idleWithoutAnimation;
|
|
430
|
+
// }
|
|
431
|
+
|
|
432
|
+
// // not over foreign list - return idle
|
|
433
|
+
// if (!isDraggingOverForImpact) {
|
|
434
|
+
// return idleWithAnimation;
|
|
435
|
+
// }
|
|
436
|
+
|
|
437
|
+
// const snapshot: StateSnapshot = {
|
|
438
|
+
// isDraggingOver: isDraggingOverForConsumer,
|
|
439
|
+
// draggingOverWith: draggableId,
|
|
440
|
+
// draggingFromThisWith: null,
|
|
441
|
+
// isUsingPlaceholder: true,
|
|
442
|
+
// };
|
|
443
|
+
|
|
444
|
+
// return {
|
|
445
|
+
// placeholder: dragging.placeholder,
|
|
446
|
+
// // Animating placeholder in foreign list
|
|
447
|
+
// shouldAnimatePlaceholder: true,
|
|
448
|
+
// snapshot,
|
|
449
|
+
// useClone: null,
|
|
450
|
+
// };
|
|
451
|
+
// },
|
|
452
|
+
// );
|
|
453
|
+
|
|
454
|
+
// const selector = (state: State, ownProps: OwnProps): MapProps => {
|
|
455
|
+
// // not checking if item is disabled as we need the home list to display a placeholder
|
|
456
|
+
|
|
457
|
+
// const id: DroppableId = ownProps.droppableId;
|
|
458
|
+
// const type: TypeId = ownProps.type;
|
|
459
|
+
// const isEnabled: boolean = !ownProps.isDropDisabled;
|
|
460
|
+
// const renderClone: ?DraggableChildrenFn = ownProps.renderClone;
|
|
461
|
+
|
|
462
|
+
// if (isDragging(state)) { // Marked for Review state.isDragging
|
|
463
|
+
// const critical: Critical = state.critical;
|
|
464
|
+
// if (!isMatchingType(type, critical)) {
|
|
465
|
+
// return idleWithoutAnimation;
|
|
466
|
+
// }
|
|
467
|
+
|
|
468
|
+
// const dragging: DraggableDimension = getDraggable(
|
|
469
|
+
// critical,
|
|
470
|
+
// state.dimensions,
|
|
471
|
+
// );
|
|
472
|
+
// const isDraggingOver: boolean = whatIsDraggedOver(state.impact) === id;
|
|
473
|
+
|
|
474
|
+
// return getMapProps(
|
|
475
|
+
// id,
|
|
476
|
+
// isEnabled,
|
|
477
|
+
// isDraggingOver,
|
|
478
|
+
// isDraggingOver,
|
|
479
|
+
// dragging,
|
|
480
|
+
// renderClone,
|
|
481
|
+
// );
|
|
482
|
+
// }
|
|
483
|
+
|
|
484
|
+
// if (state.phase === 'DROP_ANIMATING') {
|
|
485
|
+
// const completed: CompletedDrag = state.completed;
|
|
486
|
+
// if (!isMatchingType(type, completed.critical)) {
|
|
487
|
+
// return idleWithoutAnimation;
|
|
488
|
+
// }
|
|
489
|
+
|
|
490
|
+
// const dragging: DraggableDimension = getDraggable(
|
|
491
|
+
// completed.critical,
|
|
492
|
+
// state.dimensions,
|
|
493
|
+
// );
|
|
494
|
+
|
|
495
|
+
// // Snapshot based on result and not impact
|
|
496
|
+
// // The result might be null (cancel) but the impact is populated
|
|
497
|
+
// // to move everything back
|
|
498
|
+
// return getMapProps(
|
|
499
|
+
// id,
|
|
500
|
+
// isEnabled,
|
|
501
|
+
// whatIsDraggedOverFromResult(completed.result) === id,
|
|
502
|
+
// whatIsDraggedOver(completed.impact) === id,
|
|
503
|
+
// dragging,
|
|
504
|
+
// renderClone,
|
|
505
|
+
// );
|
|
506
|
+
// }
|
|
507
|
+
|
|
508
|
+
// if (state.phase === 'IDLE' && state.completed && !state.shouldFlush) {
|
|
509
|
+
// const completed: CompletedDrag = state.completed;
|
|
510
|
+
// if (!isMatchingType(type, completed.critical)) {
|
|
511
|
+
// return idleWithoutAnimation;
|
|
512
|
+
// }
|
|
513
|
+
|
|
514
|
+
// // Looking at impact as this controls the placeholder
|
|
515
|
+
// const wasOver: boolean = whatIsDraggedOver(completed.impact) === id;
|
|
516
|
+
// const wasCombining: boolean = Boolean(
|
|
517
|
+
// completed.impact.at && completed.impact.at.type === 'COMBINE',
|
|
518
|
+
// );
|
|
519
|
+
// const isHome: boolean = completed.critical.droppable.id === id;
|
|
520
|
+
|
|
521
|
+
// if (wasOver) {
|
|
522
|
+
// // if reordering we need to cut an animation immediately
|
|
523
|
+
// // if merging: animate placeholder closed after drop
|
|
524
|
+
// return wasCombining ? idleWithAnimation : idleWithoutAnimation;
|
|
525
|
+
// }
|
|
526
|
+
|
|
527
|
+
// // we need to animate the home placeholder closed if it is not
|
|
528
|
+
// // being dropped into
|
|
529
|
+
// if (isHome) {
|
|
530
|
+
// return idleWithAnimation;
|
|
531
|
+
// }
|
|
532
|
+
|
|
533
|
+
// return idleWithoutAnimation;
|
|
534
|
+
// }
|
|
535
|
+
|
|
536
|
+
// // default: including when flushed
|
|
537
|
+
// return idleWithoutAnimation;
|
|
538
|
+
// };
|
|
539
|
+
|
|
540
|
+
// return selector;
|
|
541
|
+
// };
|
|
542
|
+
|
|
543
|
+
// const mapDispatchToProps: DispatchProps = {
|
|
544
|
+
// updateViewportMaxScroll: updateViewportMaxScrollAction,
|
|
545
|
+
// };
|
|
546
|
+
|
|
547
|
+
// function getBody(): HTMLElement {
|
|
548
|
+
// invariant(document.body, 'document.body is not ready');
|
|
549
|
+
// return document.body;
|
|
550
|
+
// }
|
|
551
|
+
|
|
552
|
+
// const defaultProps = ({
|
|
553
|
+
// mode: 'standard',
|
|
554
|
+
// type: 'DEFAULT',
|
|
555
|
+
// direction: 'vertical',
|
|
556
|
+
// isDropDisabled: false,
|
|
557
|
+
// isCombineEnabled: false,
|
|
558
|
+
// ignoreContainerClipping: false,
|
|
559
|
+
// renderClone: null,
|
|
560
|
+
// getContainerForClone: getBody,
|
|
561
|
+
// }: DefaultProps);
|
|
562
|
+
|
|
563
|
+
// // Abstract class allows to specify props and defaults to component.
|
|
564
|
+
// // All other ways give any or do not let add default props.
|
|
565
|
+
// // eslint-disable-next-line
|
|
566
|
+
// /*::
|
|
567
|
+
// class DroppableType extends Component<OwnProps> {
|
|
568
|
+
// static defaultProps = defaultProps;
|
|
569
|
+
// }
|
|
570
|
+
// */
|
|
571
|
+
|
|
572
|
+
// // Leaning heavily on the default shallow equality checking
|
|
573
|
+
// // that `connect` provides.
|
|
574
|
+
// // It avoids needing to do it own within `Droppable`
|
|
575
|
+
// const ConnectedDroppable: typeof DroppableType = connect(
|
|
576
|
+
// // returning a function so each component can do its own memoization
|
|
577
|
+
// makeMapStateToProps,
|
|
578
|
+
// // no dispatch props for droppable
|
|
579
|
+
// mapDispatchToProps,
|
|
580
|
+
// // mergeProps - using default
|
|
581
|
+
// null,
|
|
582
|
+
// // $FlowFixMe: current react-redux type does not know about context property
|
|
583
|
+
// {
|
|
584
|
+
// // Ensuring our context does not clash with consumers
|
|
585
|
+
// context: StoreContext,
|
|
586
|
+
// // pure: true is default value, but being really clear
|
|
587
|
+
// pure: true,
|
|
588
|
+
// // When pure, compares the result of mapStateToProps to its previous value.
|
|
589
|
+
// // Default value: shallowEqual
|
|
590
|
+
// // Switching to a strictEqual as we return a memoized object on changes
|
|
591
|
+
// areStatePropsEqual: isStrictEqual,
|
|
592
|
+
// },
|
|
593
|
+
// )(Droppable);
|
|
594
|
+
|
|
595
|
+
// ConnectedDroppable.defaultProps = defaultProps;
|
|
596
|
+
|
|
597
|
+
// export default ConnectedDroppable;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import type {
|
|
4
|
+
DraggableId,
|
|
5
|
+
DroppableId,
|
|
6
|
+
TypeId,
|
|
7
|
+
Direction,
|
|
8
|
+
Placeholder,
|
|
9
|
+
State,
|
|
10
|
+
ContextId,
|
|
11
|
+
DraggableRubric,
|
|
12
|
+
DroppableMode,
|
|
13
|
+
} from '../../types';
|
|
14
|
+
import type { ChildrenFn } from '../draggable/draggable-types';
|
|
15
|
+
import { updateViewportMaxScroll } from '../../state/action-creators';
|
|
16
|
+
|
|
17
|
+
export type DraggableChildrenFn = ChildrenFn;
|
|
18
|
+
|
|
19
|
+
// Exact
|
|
20
|
+
export type DroppableProps = {
|
|
21
|
+
// used for shared global styles
|
|
22
|
+
'data-rbd-droppable-context-id': ContextId,
|
|
23
|
+
// Used to lookup. Currently not used for drag and drop lifecycle
|
|
24
|
+
'data-rbd-droppable-id': DroppableId,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Exact
|
|
28
|
+
export type Provided = {
|
|
29
|
+
innerRef: (arg: HTMLElement | null) => void,
|
|
30
|
+
placeholder: ReactNode | null,
|
|
31
|
+
droppableProps: DroppableProps,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Exact
|
|
35
|
+
export type UseClone = {
|
|
36
|
+
dragging: DraggableRubric,
|
|
37
|
+
render: DraggableChildrenFn,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Exact
|
|
41
|
+
export type StateSnapshot = {
|
|
42
|
+
// Is the Droppable being dragged over?
|
|
43
|
+
isDraggingOver: boolean,
|
|
44
|
+
// What is the id of the draggable that is dragging over the Droppable?
|
|
45
|
+
draggingOverWith: DraggableId | null,
|
|
46
|
+
// What is the id of the draggable that is dragging from this list?
|
|
47
|
+
// Useful for styling the home list when not being dragged over
|
|
48
|
+
draggingFromThisWith: DraggableId | null,
|
|
49
|
+
// Whether or not the placeholder is actively being used.
|
|
50
|
+
// This is useful information when working with virtual lists
|
|
51
|
+
isUsingPlaceholder: boolean,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Exact
|
|
55
|
+
export type MapProps = {
|
|
56
|
+
// placeholder:
|
|
57
|
+
// - used to keep space in the home list during the whole drag and drop
|
|
58
|
+
// - used to make space in foreign lists during a drag
|
|
59
|
+
placeholder: Placeholder | null,
|
|
60
|
+
shouldAnimatePlaceholder: boolean,
|
|
61
|
+
// snapshot based on redux state to be provided to consumers
|
|
62
|
+
snapshot: StateSnapshot,
|
|
63
|
+
useClone: UseClone | null,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Exact
|
|
67
|
+
export type DefaultProps = {
|
|
68
|
+
mode?: DroppableMode,
|
|
69
|
+
type?: TypeId,
|
|
70
|
+
isDropDisabled?: boolean,
|
|
71
|
+
isCombineEnabled?: boolean,
|
|
72
|
+
direction?: Direction,
|
|
73
|
+
renderClone?: DraggableChildrenFn | null,
|
|
74
|
+
ignoreContainerClipping?: boolean,
|
|
75
|
+
getContainerForClone: () => HTMLElement,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Exact
|
|
79
|
+
export type DispatchProps = {
|
|
80
|
+
updateViewportMaxScroll: typeof updateViewportMaxScroll,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Exact
|
|
84
|
+
export type OwnProps = DefaultProps & {
|
|
85
|
+
children: (Provided: any, StateSnapshot: any) => ReactNode,
|
|
86
|
+
droppableId: DroppableId,
|
|
87
|
+
renderClone: DraggableChildrenFn | null,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type Props = MapProps & DispatchProps & OwnProps & {
|
|
91
|
+
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Having issues getting the correct type
|
|
95
|
+
// export type Selector = OutputSelector<State, OwnProps, MapProps>;
|
|
96
|
+
export type Selector = (state: State, ownProps: OwnProps) => MapProps;
|