@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,12 @@
|
|
|
1
|
+
import type { ContextId, Sensor } from "../../types";
|
|
2
|
+
import type { Store } from "../../state/store-types";
|
|
3
|
+
import type { Registry } from "../../state/registry/registry-types";
|
|
4
|
+
type SensorMarshalArgs = {
|
|
5
|
+
contextId: ContextId;
|
|
6
|
+
registry: Registry;
|
|
7
|
+
store: Store;
|
|
8
|
+
customSensors?: (Sensor[]) | null;
|
|
9
|
+
enableDefaultSensors: boolean;
|
|
10
|
+
};
|
|
11
|
+
export default function useSensorMarshal({ contextId, store, registry, customSensors, enableDefaultSensors, }: SensorMarshalArgs): void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContextId } from '../../types';
|
|
2
|
+
export type Styles = {
|
|
3
|
+
always: string;
|
|
4
|
+
dragging: string;
|
|
5
|
+
resting: string;
|
|
6
|
+
dropAnimating: string;
|
|
7
|
+
userCancel: string;
|
|
8
|
+
};
|
|
9
|
+
declare const _default: (contextId: ContextId) => Styles;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './use-style-marshal';
|
package/package.json
CHANGED
|
@@ -1,6 +1,159 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helpdice/draggable",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Beautiful and accessible drag and drop for lists with React",
|
|
5
|
+
"author": "Helpdice",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"drag and drop",
|
|
9
|
+
"dnd",
|
|
10
|
+
"sortable",
|
|
11
|
+
"reorder",
|
|
12
|
+
"reorderable",
|
|
13
|
+
"react",
|
|
14
|
+
"react.js",
|
|
15
|
+
"natural",
|
|
16
|
+
"beautiful",
|
|
17
|
+
"accessible"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/helpdice/draggable.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/helpdice/draggable/issues"
|
|
25
|
+
},
|
|
26
|
+
"main": "dist/draggable.cjs.js",
|
|
27
|
+
"module": "dist/draggable.esm.js",
|
|
28
|
+
"types": "dist/types/index.d.ts",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"files": [
|
|
31
|
+
"/dist",
|
|
32
|
+
"/src"
|
|
33
|
+
],
|
|
34
|
+
"config": {
|
|
35
|
+
"prettier_target": "*.{js,jsx,md,json} src/**/*.{js,jsx,md,json} test/**/*.{js,jsx,md,json} docs/**/*.{js,jsx,md,json} stories/**/*.{js,jsx,md,json} cypress/**/*.{js,jsx,md,json} csp-server/**/*.{js,jsx,md,json}"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"test:accessibility": "lighthouse http://localhost:9002/iframe.html?id=single-vertical-list--basic --chrome-flags='--headless' --output=json --output=html --output-path=./test-reports/lighthouse/a11y.json && node a11y-audit-parse.js",
|
|
39
|
+
"test": "jest --config ./jest.config.js",
|
|
40
|
+
"test:ci": "jest test --maxWorkers=2",
|
|
41
|
+
"test:browser": "cypress open",
|
|
42
|
+
"test:browser:ci": "cypress run",
|
|
43
|
+
"test:coverage": "yarn test --coverage --coveragePathIgnorePatterns=/debug",
|
|
44
|
+
"validate": "yarn prettier:check && yarn lint:eslint && yarn lint:css && yarn typecheck",
|
|
45
|
+
"prettier:check": "yarn prettier --debug-check $npm_package_config_prettier_target",
|
|
46
|
+
"prettier:write": "yarn prettier --write $npm_package_config_prettier_target",
|
|
47
|
+
"lint:eslint": "yarn eslint \"./**/*.{js,jsx}\"",
|
|
48
|
+
"lint:css": "stylelint \"stories/**/*.{js,jsx}\"",
|
|
49
|
+
"typecheck": "flow check --max-warnings=0",
|
|
50
|
+
"bundle-size:check": "cross-env SNAPSHOT=match yarn bundle-size:update",
|
|
51
|
+
"bundle-size:update": "yarn build:clean && yarn build:dist && yarn build:clean",
|
|
52
|
+
"build": "yarn build:clean && yarn build:dist && yarn build:types",
|
|
53
|
+
"build:clean": "rimraf dist",
|
|
54
|
+
"build:dist": "rollup -c",
|
|
55
|
+
"build:types": "npx tsc -p tsconfig.types.json",
|
|
56
|
+
"build:flow": "echo \"// @flow\n\nexport * from '../src';\" > dist/draggable.cjs.js.flow",
|
|
57
|
+
"storybook": "start-storybook -p 9002",
|
|
58
|
+
"build-storybook": "build-storybook -c .storybook -o site",
|
|
59
|
+
"prepublishOnly": "yarn build"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@babel/runtime": "^8.1.2",
|
|
63
|
+
"@helpdice/memoizer": "^1.0.5",
|
|
64
|
+
"css-box-model": "^1.2.1",
|
|
65
|
+
"memoize-one": "^6.0.0",
|
|
66
|
+
"raf-schd": "^4.0.2",
|
|
67
|
+
"react-redux": "^9.3.1",
|
|
68
|
+
"redux": "^5.0.1"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@babel/core": "7.9.0",
|
|
72
|
+
"@babel/plugin-proposal-class-properties": "7.8.3",
|
|
73
|
+
"@babel/plugin-transform-modules-commonjs": "7.9.0",
|
|
74
|
+
"@babel/plugin-transform-object-assign": "7.8.3",
|
|
75
|
+
"@babel/plugin-transform-runtime": "7.9.0",
|
|
76
|
+
"@babel/preset-env": "7.9.5",
|
|
77
|
+
"@babel/preset-flow": "7.9.0",
|
|
78
|
+
"@babel/preset-react": "7.9.4",
|
|
79
|
+
"@emotion/babel-preset-css-prop": "10.0.27",
|
|
80
|
+
"@emotion/core": "10.0.28",
|
|
81
|
+
"@emotion/styled": "10.0.27",
|
|
82
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
83
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
84
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
85
|
+
"@rollup/plugin-typescript": "^12.3.1",
|
|
86
|
+
"@storybook/addon-storysource": "5.3.21",
|
|
87
|
+
"@storybook/react": "5.3.21",
|
|
88
|
+
"@storybook/theming": "5.3.21",
|
|
89
|
+
"@testing-library/react": "10.4.9",
|
|
90
|
+
"@types/node": "^26.6.6",
|
|
91
|
+
"@types/raf-schd": "^4.0.3",
|
|
92
|
+
"@types/react-dom": "^19.3.0",
|
|
93
|
+
"babel-core": "7.0.0-bridge.0",
|
|
94
|
+
"babel-eslint": "10.1.0",
|
|
95
|
+
"babel-jest": "25.5.1",
|
|
96
|
+
"babel-loader": "8.1.0",
|
|
97
|
+
"babel-plugin-dev-expression": "0.2.2",
|
|
98
|
+
"babel-plugin-emotion": "10.0.33",
|
|
99
|
+
"cross-env": "7.0.3",
|
|
100
|
+
"cypress": "4.4.0",
|
|
101
|
+
"emotion-theming": "10.0.27",
|
|
102
|
+
"eslint": "6.8.0",
|
|
103
|
+
"eslint-config-airbnb": "18.1.0",
|
|
104
|
+
"eslint-config-prettier": "6.15.0",
|
|
105
|
+
"eslint-plugin-cypress": "2.11.3",
|
|
106
|
+
"eslint-plugin-emotion": "10.0.27",
|
|
107
|
+
"eslint-plugin-es5": "1.5.0",
|
|
108
|
+
"eslint-plugin-flowtype": "4.7.0",
|
|
109
|
+
"eslint-plugin-import": "2.22.1",
|
|
110
|
+
"eslint-plugin-jest": "23.20.0",
|
|
111
|
+
"eslint-plugin-jsx-a11y": "6.4.1",
|
|
112
|
+
"eslint-plugin-prettier": "3.3.1",
|
|
113
|
+
"eslint-plugin-react": "7.19.0",
|
|
114
|
+
"eslint-plugin-react-hooks": "3.0.0",
|
|
115
|
+
"flow-bin": "0.110.1",
|
|
116
|
+
"fs-extra": "9.1.0",
|
|
117
|
+
"globby": "11.0.3",
|
|
118
|
+
"jest": "25.5.4",
|
|
119
|
+
"jest-axe": "3.5.0",
|
|
120
|
+
"jest-junit": "10.0.0",
|
|
121
|
+
"jest-watch-typeahead": "0.6.1",
|
|
122
|
+
"lighthouse": "5.6.0",
|
|
123
|
+
"markdown-it": "10.0.0",
|
|
124
|
+
"prettier": "2.0.4",
|
|
125
|
+
"raf-stub": "3.0.0",
|
|
126
|
+
"react": "^19.3.1",
|
|
127
|
+
"react-dom": "^19.3.1",
|
|
128
|
+
"react-test-renderer": "19.3.1",
|
|
129
|
+
"react-virtualized": "10.0.1",
|
|
130
|
+
"react-window": "2.5.3",
|
|
131
|
+
"require-from-string": "2.0.2",
|
|
132
|
+
"rimraf": "3.0.2",
|
|
133
|
+
"rollup": "4.68.0",
|
|
134
|
+
"rollup-plugin-babel": "4.4.0",
|
|
135
|
+
"rollup-plugin-json": "4.0.0",
|
|
136
|
+
"rollup-plugin-replace": "2.2.0",
|
|
137
|
+
"rollup-plugin-size-snapshot": "0.11.0",
|
|
138
|
+
"rollup-plugin-strip": "1.2.2",
|
|
139
|
+
"rollup-plugin-terser": "5.3.1",
|
|
140
|
+
"styled-components": "5.1.0",
|
|
141
|
+
"stylelint": "13.13.1",
|
|
142
|
+
"stylelint-config-prettier": "8.0.2",
|
|
143
|
+
"stylelint-config-recommended": "3.0.0",
|
|
144
|
+
"stylelint-config-standard": "20.0.0",
|
|
145
|
+
"stylelint-config-styled-components": "0.1.1",
|
|
146
|
+
"stylelint-processor-styled-components": "1.10.0",
|
|
147
|
+
"typescript": "^6.0.3",
|
|
148
|
+
"wait-port": "0.2.9",
|
|
149
|
+
"webpack": "4.42.1"
|
|
150
|
+
},
|
|
151
|
+
"peerDependencies": {
|
|
152
|
+
"react": "^19.3.1",
|
|
153
|
+
"react-dom": "^19.3.1"
|
|
154
|
+
},
|
|
155
|
+
"license": "Apache-2.0",
|
|
156
|
+
"jest-junit": {
|
|
157
|
+
"output": "test-reports/junit/js-test-results.xml"
|
|
158
|
+
}
|
|
159
|
+
}
|
package/src/animation.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Position } from 'css-box-model';
|
|
3
|
+
import { isEqual, origin } from './state/position';
|
|
4
|
+
|
|
5
|
+
export const curves = {
|
|
6
|
+
outOfTheWay: 'cubic-bezier(0.2, 0, 0, 1)',
|
|
7
|
+
drop: 'cubic-bezier(.2,1,.1,1)',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const combine = {
|
|
11
|
+
opacity: {
|
|
12
|
+
// while dropping: fade out totally
|
|
13
|
+
drop: 0,
|
|
14
|
+
// while dragging: fade out partially
|
|
15
|
+
combining: 0.7,
|
|
16
|
+
},
|
|
17
|
+
scale: {
|
|
18
|
+
drop: 0.75,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const timings = {
|
|
23
|
+
outOfTheWay: 0.2,
|
|
24
|
+
// greater than the out of the way time
|
|
25
|
+
// so that when the drop ends everything will
|
|
26
|
+
// have to be out of the way
|
|
27
|
+
minDropTime: 0.33,
|
|
28
|
+
maxDropTime: 0.55,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// slow timings
|
|
32
|
+
// uncomment to use
|
|
33
|
+
// export const timings = {
|
|
34
|
+
// outOfTheWay: 2,
|
|
35
|
+
// // greater than the out of the way time
|
|
36
|
+
// // so that when the drop ends everything will
|
|
37
|
+
// // have to be out of the way
|
|
38
|
+
// minDropTime: 3,
|
|
39
|
+
// maxDropTime: 4,
|
|
40
|
+
// };
|
|
41
|
+
|
|
42
|
+
const outOfTheWayTiming: string = `${timings.outOfTheWay}s ${curves.outOfTheWay}`;
|
|
43
|
+
export const placeholderTransitionDelayTime: number = 0.1;
|
|
44
|
+
|
|
45
|
+
export const transitions = {
|
|
46
|
+
fluid: `opacity ${outOfTheWayTiming}`,
|
|
47
|
+
snap: `transform ${outOfTheWayTiming}, opacity ${outOfTheWayTiming}`,
|
|
48
|
+
drop: (duration: number): string => {
|
|
49
|
+
const timing: string = `${duration}s ${curves.drop}`;
|
|
50
|
+
return `transform ${timing}, opacity ${timing}`;
|
|
51
|
+
},
|
|
52
|
+
outOfTheWay: `transform ${outOfTheWayTiming}`,
|
|
53
|
+
placeholder: `height ${outOfTheWayTiming}, width ${outOfTheWayTiming}, margin ${outOfTheWayTiming}`,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const moveTo = (offset: Position): string | null =>
|
|
57
|
+
isEqual(offset, origin) ? null : `translate(${offset.x}px, ${offset.y}px)`;
|
|
58
|
+
|
|
59
|
+
export const transforms = {
|
|
60
|
+
moveTo,
|
|
61
|
+
drop: (offset: Position, isCombining: boolean) => {
|
|
62
|
+
const translate: string | null = moveTo(offset);
|
|
63
|
+
if (!translate) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// only transforming the translate
|
|
68
|
+
if (!isCombining) {
|
|
69
|
+
return translate;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// when dropping while combining we also update the scale
|
|
73
|
+
return `${translate} scale(${combine.scale.drop})`;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import type { Action } from '../../state/store-types';
|
|
4
|
+
|
|
5
|
+
type Bucket = {
|
|
6
|
+
[key: string]: number[],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const average = (values: number[]): number => {
|
|
10
|
+
const sum: number = values.reduce(
|
|
11
|
+
(previous: number, current: number) => previous + current,
|
|
12
|
+
0,
|
|
13
|
+
);
|
|
14
|
+
return sum / values.length;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default (groupSize: number) => {
|
|
18
|
+
console.log('Starting average action timer middleware');
|
|
19
|
+
console.log(`Will take an average every ${groupSize} actions`);
|
|
20
|
+
const bucket: Bucket = {};
|
|
21
|
+
|
|
22
|
+
return () => (next: (arg: Action) => unknown) => (action: Action): any => {
|
|
23
|
+
const start: number = performance.now();
|
|
24
|
+
|
|
25
|
+
const result: unknown = next(action);
|
|
26
|
+
|
|
27
|
+
const end: number = performance.now();
|
|
28
|
+
|
|
29
|
+
const duration: number = end - start;
|
|
30
|
+
|
|
31
|
+
if (!bucket[action.type]) {
|
|
32
|
+
bucket[action.type] = [duration];
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
bucket[action.type].push(duration);
|
|
37
|
+
|
|
38
|
+
if (bucket[action.type].length < groupSize) {
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.warn(
|
|
43
|
+
`Average time for ${action.type}`,
|
|
44
|
+
average(bucket[action.type]),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// reset
|
|
48
|
+
bucket[action.type] = [];
|
|
49
|
+
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import * as timings from '../timings';
|
|
4
|
+
import type { Action } from '../../state/store-types';
|
|
5
|
+
|
|
6
|
+
export default () => (next: (arg: Action) => unknown) => (action: Action): any => {
|
|
7
|
+
timings.forceEnable();
|
|
8
|
+
const key = `redux action: ${action.type}`;
|
|
9
|
+
timings.start(key);
|
|
10
|
+
|
|
11
|
+
const result: unknown = next(action);
|
|
12
|
+
|
|
13
|
+
timings.finish(key);
|
|
14
|
+
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import type { Action, Store } from '../../state/store-types';
|
|
4
|
+
|
|
5
|
+
type Mode = 'verbose' | 'light';
|
|
6
|
+
|
|
7
|
+
export default (mode: Mode = 'verbose') => (store: Store) => (
|
|
8
|
+
next: (arg: Action) => unknown,
|
|
9
|
+
) => (action: Action): any => {
|
|
10
|
+
if (mode === 'light') {
|
|
11
|
+
console.log('🏃 Action:', action.type);
|
|
12
|
+
return next(action);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
console.group(`action: ${action.type}`);
|
|
16
|
+
console.log('action payload', action.payload);
|
|
17
|
+
|
|
18
|
+
console.log('state before', store.getState());
|
|
19
|
+
|
|
20
|
+
const result: unknown = next(action);
|
|
21
|
+
|
|
22
|
+
console.log('state after', store.getState());
|
|
23
|
+
console.groupEnd();
|
|
24
|
+
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Action } from '../../state/store-types';
|
|
3
|
+
|
|
4
|
+
export default () => (next: (arg: Action) => unknown) => (action: Action): any => {
|
|
5
|
+
const title: string = `👾 redux (action): ${action.type}`;
|
|
6
|
+
const startMark: string = `${action.type}:start`;
|
|
7
|
+
const endMark: string = `${action.type}:end`;
|
|
8
|
+
|
|
9
|
+
performance.mark(startMark);
|
|
10
|
+
const result: unknown = next(action);
|
|
11
|
+
performance.mark(endMark);
|
|
12
|
+
|
|
13
|
+
performance.measure(title, startMark, endMark);
|
|
14
|
+
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
type Records = {
|
|
3
|
+
[key: string]: number,
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
const records: Records = {};
|
|
7
|
+
let isEnabled: boolean = false;
|
|
8
|
+
|
|
9
|
+
const isTimingsEnabled = (): boolean => isEnabled;
|
|
10
|
+
|
|
11
|
+
export const forceEnable = () => {
|
|
12
|
+
isEnabled = true;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Debug: uncomment to enable
|
|
16
|
+
// forceEnable();
|
|
17
|
+
|
|
18
|
+
export const start = (key: string) => {
|
|
19
|
+
// we want to strip all the code out for production builds
|
|
20
|
+
// draw back: can only do timings in dev env (which seems to be fine for now)
|
|
21
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
22
|
+
if (!isTimingsEnabled()) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const now: number = performance.now();
|
|
26
|
+
|
|
27
|
+
records[key] = now;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Exact
|
|
32
|
+
type Style = {
|
|
33
|
+
textColor: string,
|
|
34
|
+
symbol: string,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const finish = (key: string) => {
|
|
38
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
39
|
+
if (!isTimingsEnabled()) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const now: number = performance.now();
|
|
43
|
+
|
|
44
|
+
const previous: number | null = records[key];
|
|
45
|
+
|
|
46
|
+
if (!previous) {
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
console.warn('cannot finish timing as no previous time found', key);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const result: number = now - previous;
|
|
53
|
+
const rounded: string = result.toFixed(2);
|
|
54
|
+
|
|
55
|
+
const style: Style = (() => {
|
|
56
|
+
if (result < 12) {
|
|
57
|
+
return {
|
|
58
|
+
textColor: 'green',
|
|
59
|
+
symbol: '✅',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (result < 40) {
|
|
63
|
+
return {
|
|
64
|
+
textColor: 'orange',
|
|
65
|
+
symbol: '⚠️',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
textColor: 'red',
|
|
70
|
+
symbol: '❌',
|
|
71
|
+
};
|
|
72
|
+
})();
|
|
73
|
+
|
|
74
|
+
// eslint-disable-next-line no-console
|
|
75
|
+
console.log(
|
|
76
|
+
`${style.symbol} %cTiming %c${rounded} %cms %c${key}`,
|
|
77
|
+
// title
|
|
78
|
+
'color: blue; font-weight: bold;',
|
|
79
|
+
// result
|
|
80
|
+
`color: ${style.textColor}; font-size: 1.1em;`,
|
|
81
|
+
// ms
|
|
82
|
+
'color: grey;',
|
|
83
|
+
// key
|
|
84
|
+
'color: purple; font-weight: bold;',
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
const isProduction: boolean = process.env.NODE_ENV === 'production';
|
|
4
|
+
|
|
5
|
+
// not replacing newlines (which \s does)
|
|
6
|
+
const spacesAndTabs: RegExp = /[ \t]{2,}/g;
|
|
7
|
+
const lineStartWithSpaces: RegExp = /^[ \t]*/gm;
|
|
8
|
+
|
|
9
|
+
// using .trim() to clear the any newlines before the first text and after last text
|
|
10
|
+
const clean = (value: string): string =>
|
|
11
|
+
value.replace(spacesAndTabs, ' ').replace(lineStartWithSpaces, '').trim();
|
|
12
|
+
|
|
13
|
+
const getDevMessage = (message: string): string =>
|
|
14
|
+
clean(`
|
|
15
|
+
%creact-beautiful-dnd
|
|
16
|
+
|
|
17
|
+
%c${clean(message)}
|
|
18
|
+
|
|
19
|
+
%c👷 This is a development only message. It will be removed in production builds.
|
|
20
|
+
`);
|
|
21
|
+
|
|
22
|
+
export const getFormattedMessage = (message: string): string[] => [
|
|
23
|
+
getDevMessage(message),
|
|
24
|
+
// title (green400)
|
|
25
|
+
'color: #00C584; font-size: 1.2em; font-weight: bold;',
|
|
26
|
+
// message
|
|
27
|
+
'line-height: 1.5',
|
|
28
|
+
// footer (purple300)
|
|
29
|
+
'color: #723874;',
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const isDisabledFlag: string = '__react-beautiful-dnd-disable-dev-warnings';
|
|
33
|
+
|
|
34
|
+
export function log(type: 'error' | 'warn', message: string) {
|
|
35
|
+
// no warnings in production
|
|
36
|
+
if (isProduction) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// manual opt out of warnings
|
|
41
|
+
if (typeof window !== 'undefined' && window[isDisabledFlag as any]) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console[type](...getFormattedMessage(message));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const warning = log.bind(null, 'warn');
|
|
50
|
+
export const error = log.bind(null, 'error');
|
package/src/empty.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
// Components
|
|
4
|
+
|
|
5
|
+
export { default as DragDropContext } from './view/drag-drop-context';
|
|
6
|
+
export { default as Droppable } from './view/droppable';
|
|
7
|
+
export { default as Draggable } from './view/draggable';
|
|
8
|
+
|
|
9
|
+
// Default sensors
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
useMouseSensor,
|
|
13
|
+
useTouchSensor,
|
|
14
|
+
useKeyboardSensor,
|
|
15
|
+
} from './view/use-sensor-marshal';
|
|
16
|
+
|
|
17
|
+
// Utils
|
|
18
|
+
|
|
19
|
+
export { resetServerContext } from './view/drag-drop-context';
|
|
20
|
+
|
|
21
|
+
// Public flow types
|
|
22
|
+
|
|
23
|
+
export type {
|
|
24
|
+
Id,
|
|
25
|
+
TypeId,
|
|
26
|
+
DraggableId,
|
|
27
|
+
DroppableId,
|
|
28
|
+
DraggableRubric,
|
|
29
|
+
MovementMode,
|
|
30
|
+
BeforeCapture,
|
|
31
|
+
DragStart,
|
|
32
|
+
DragUpdate,
|
|
33
|
+
DropResult,
|
|
34
|
+
Direction,
|
|
35
|
+
ResponderProvided,
|
|
36
|
+
Announce,
|
|
37
|
+
DraggableLocation,
|
|
38
|
+
OnBeforeCaptureResponder,
|
|
39
|
+
OnBeforeDragStartResponder,
|
|
40
|
+
OnDragStartResponder,
|
|
41
|
+
OnDragUpdateResponder,
|
|
42
|
+
OnDragEndResponder,
|
|
43
|
+
SensorAPI,
|
|
44
|
+
Sensor,
|
|
45
|
+
TryGetLock,
|
|
46
|
+
TryGetLockOptions,
|
|
47
|
+
} from './types';
|
|
48
|
+
|
|
49
|
+
// Droppable types
|
|
50
|
+
export type {
|
|
51
|
+
Provided as DroppableProvided,
|
|
52
|
+
StateSnapshot as DroppableStateSnapshot,
|
|
53
|
+
DroppableProps,
|
|
54
|
+
} from './view/droppable/droppable-types';
|
|
55
|
+
|
|
56
|
+
// Draggable types
|
|
57
|
+
export type {
|
|
58
|
+
Provided as DraggableProvided,
|
|
59
|
+
StateSnapshot as DraggableStateSnapshot,
|
|
60
|
+
DragHandleProps,
|
|
61
|
+
DropAnimation,
|
|
62
|
+
DraggableProps,
|
|
63
|
+
DraggableStyle,
|
|
64
|
+
DraggingStyle,
|
|
65
|
+
NotDraggingStyle,
|
|
66
|
+
ChildrenFn as DraggableChildrenFn,
|
|
67
|
+
} from './view/draggable/draggable-types';
|