How to use react-sortable-hoc - 10 common examples

To help you get started, we’ve selected a few react-sortable-hoc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bbc / digital-paper-edit-client / src / Components / PaperEdits / PaperEdit / ProgramScript / ProgrammeScript.js View on Github external
import PaperCut from './PaperCut';
import TitleHeading from './TitleHeading';
import Note from './Note';

import {
  faGripLines,
  faPen,
  faTrash,
  faArrowAltCircleLeft,
  faArrowAltCircleRight
} from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

const InsertPoint = (({ text }) =&gt; <span style="{">  {text} </span>);

const DragHandle = sortableHandle(() =&gt; <span>  </span>);

const SortableItem = sortableElement(({ value, index, type, handleDelete, handleEdit }) =&gt; {
  return (<li>
    
      
        
      
      
        {value}
      
      
        {/* TODO: if paper-cut  then don't show edit/pen icon */}
        {type !== 'paper-cut' &amp;&amp; type !== 'insert-point' ?  { handleEdit(index); } } /&gt; : null}

      
      </li>
github resource-watch / resource-watch / components / ui / LegendOld.js View on Github external
import { connect } from 'react-redux';
import { toggleModal } from 'redactions/modal';
import { toggleTooltip, setTooltipPosition } from 'redactions/tooltip';
import { setLayerGroupOpacity } from 'redactions/explore';

// Components
import LegendType from 'components/ui/LegendType';
import Icon from 'components/ui/Icon';
import LayerInfoModal from 'components/modal/LayerInfoModal';
import LayersTooltip from 'components/app/explore/LayersTooltip';
import SliderTooltip from 'components/app/explore/SliderTooltip';
import Button from 'components/ui/Button';

const TIMELINE_INTERVAL_TIMER = 3000;

const SortableItem = SortableElement(({ value }) =&gt; value);

const DragHandle = SortableHandle(() =&gt; (
  <span>
    
  </span>
));

const SortableList = SortableContainer(({ items }) =&gt; (
  <ul>
    {items.map((value, index) =&gt;
      
    )}
  </ul>
));

class Legend extends React.PureComponent {
github ctxhou / react-tabtab / dist / react-tabtab.es.js View on Github external
handleTabSequence = _props.handleTabSequence;

      if (oldIndex === newIndex) {
        if (activeIndex !== oldIndex) {
          handleTabChange(oldIndex);
        }
      } else {
        handleTabSequence({ oldIndex: oldIndex, newIndex: newIndex });
      }
    }
  }]);
  return SortMethod;
}(Component);

//      
var DragTabContainer = SortableContainer(function (_ref) {
  var children = _ref.children;

  return createElement(
    'div',
    { style: { marginTop: '50px' } },
    children
  );
});

var ModalTabListWrapper = function (_SortMethod) {
  inherits(ModalTabListWrapper, _SortMethod);

  function ModalTabListWrapper() {
    classCallCheck(this, ModalTabListWrapper);
    return possibleConstructorReturn(this, (ModalTabListWrapper.__proto__ || Object.getPrototypeOf(ModalTabListWrapper)).apply(this, arguments));
  }
github SaltieRL / DistributedReplays / webapp / src / Components / Player / Overview / PlayStyle / PlayStyleEdit.tsx View on Github external
settings?: SettingsResponse
    sorted?: string[][]
    stats?: StatDescription[]
}

interface Props {
    onUpdate: () =&gt; void
}

//  Component which uses drag-n-drop activation when clicking inside the component
const DragHandle = SortableHandle(({style}) =&gt; (
    &lt; span style={{...style, ...{cursor: " move "}}}&gt; {" ::: "} )
)

// Universal component for turning a TableBody into a sortable container
const TableBodySortable = SortableContainer(({children, displayRowCheckbox}) =&gt; (
    
        {children}
    
))

const Row = SortableElement(({name, children}) =&gt; {
    return (
        
            
                
            
            
                {children}
            
        
    )
github alibaba / ice / tools / iceworks / renderer / src / pages / Home / ProjectDashboard / index.jsx View on Github external
import './index.scss';

const ExtensionMap = {
  [Assets.extensionName]: Assets,
  [Aliyun.extensionName]: Aliyun,
  [Def.extensionName]: Def,
  [Git.extensionName]: Git,
  [Dependencies.extensionName]: Dependencies,
  [Layouts.extensionName]: Layouts,
  [Pages.extensionName]: Pages,
  [Proxies.extensionName]: Proxies,
  [Todo.extensionName]: Todo,
};

// eslint-disable-next-line babel/new-cap
const DragHandle = SortableHandle(() =&gt; (
  <span>
));
// eslint-disable-next-line babel/new-cap
const SortableExtensionItem = SortableElement(
  ({ Component, isSorting, props }) =&gt; {
    return (
      <div>
        
        
      </div>
    );</span>
github SaltieRL / DistributedReplays / webapp / src / Components / Player / Overview / PlayStyle / PlayStyleEdit.tsx View on Github external
import { getChartSettings } from "../../../../Requests/Player/getPlayStyle"
import { getStatsList } from "../../../../Requests/Replay"
import { LoadableWrapper } from "../../../Shared/LoadableWrapper"

interface State {
    settings?: SettingsResponse
    sorted?: string[][]
    stats?: StatDescription[]
}

interface Props {
    onUpdate: () =&gt; void
}

//  Component which uses drag-n-drop activation when clicking inside the component
const DragHandle = SortableHandle(({style}) =&gt; (
    &lt; span style={{...style, ...{cursor: " move "}}}&gt; {" ::: "} )
)

// Universal component for turning a TableBody into a sortable container
const TableBodySortable = SortableContainer(({children, displayRowCheckbox}) =&gt; (
    
        {children}
    
))

const Row = SortableElement(({name, children}) =&gt; {
    return (
github mebble / intervals / src / components / app / app.js View on Github external
import Interval from "../interval/interval";
import Icon from "../icon/icon";
import { ICONS, NOTES } from "../../constants";

const DragHandle = sortableHandle(() =&gt; (
  <span>
    
  </span>
));

const SortableInterval = sortableElement(({ value }) =&gt; (
  <section>
    
  </section>
));
const SortableIntervalContainer = sortableContainer(({ children }) =&gt; (
  <ul>{children}</ul>
));

function useInterval(callback, delay) {
  const savedCallback = useRef();

  // Remember the latest function.
  useEffect(() =&gt; {
    savedCallback.current = callback;
  }, [callback]);

  // Set up the interval.
  useEffect(() =&gt; {
    function tick() {
      savedCallback.current();
    }
github keplergl / kepler.gl / src / components / side-panel / layer-manager.js View on Github external
function LayerManagerFactory(AddDataButton, LayerPanel, SourceDataCatalog) {
  // By wrapping layer panel using a sortable element we don't have to implement the drag and drop logic into the panel itself;
  // Developers can provide any layer panel implementation and it will still be sortable
  const SortableItem = sortableElement(({children, isSorting}) =&gt; {
    return (
      
        {children}
      
    );
  });

  const SortableContainer = sortableContainer(({children}) =&gt; {
    return <div>{children}</div>;
  });

  return class LayerManager extends Component {
    static propTypes = {
      datasets: PropTypes.object.isRequired,
      layerBlending: PropTypes.string.isRequired,
      layerClasses: PropTypes.object.isRequired,
      layers: PropTypes.arrayOf(PropTypes.any).isRequired,
      // functions
      addLayer: PropTypes.func.isRequired,
      layerColorUIChange: PropTypes.func.isRequired,
      layerConfigChange: PropTypes.func.isRequired,
      layerTextLabelChange: PropTypes.func.isRequired,
      layerVisualChannelConfigChange: PropTypes.func.isRequired,
      layerTypeChange: PropTypes.func.isRequired,
github county-of-simcoe-gis / SimcoeCountyWebViewer / src / sidebar / components / toc / Layers.jsx View on Github external
import { sortableContainer, sortableElement } from "react-sortable-hoc";
import { List, AutoSizer } from "react-virtualized";
import VirtualLayers from "./VirtualLayers.jsx";
import arrayMove from "array-move";
import GeoJSON from "ol/format/GeoJSON.js";

// CUSTOM
import "./Layers.css";
import * as helpers from "../../../helpers/helpers";
import * as TOCHelpers from "./TOCHelpers.jsx";
import FloatingMenu, { FloatingMenuItem } from "../../../helpers/FloatingMenu.jsx";
import { Item as MenuItem } from "rc-menu";
import Portal from "../../../helpers/Portal.jsx";
import TOCConfig from "./TOCConfig.json";

const SortableVirtualList = sortableContainer(VirtualLayers, { withRef: true });

class Layers extends Component {
  constructor(props) {
    super(props);

    this.storageKey = "layers";
    this.lastPosition = null;
    this.virtualId = "sc-toc-virtual-layers";
    this.state = {
      allLayers: {},
      layers: []
    };

    // LISTEN FOR MAP TO MOUNT
    window.emitter.addListener("mapLoaded", () => this.onMapLoad());
github getredash / redash / client / app / components / sortable / index.jsx View on Github external
import { isFunction, wrap } from 'lodash';
import React, { useRef, useState } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import { sortableContainer, sortableElement, sortableHandle } from 'react-sortable-hoc';

import './style.less';

export const DragHandle = sortableHandle(({ className, ...restProps }) =&gt; (
  <div>
));

export const SortableContainerWrapper = sortableContainer(({ children }) =&gt; children);

export const SortableElement = sortableElement(({ children }) =&gt; children);

export function SortableContainer({ disabled, containerComponent, containerProps, children, ...wrapperProps }) {
  const containerRef = useRef();
  const [isDragging, setIsDragging] = useState(false);

  wrapperProps = { ...wrapperProps };
  containerProps = { ...containerProps };

  if (disabled) {
    // Disabled state:
    // - forbid drag'n'drop (and therefore no need to hook events
    // - don't override anything on container element
    wrapperProps.shouldCancelStart = () =&gt; true;
  } else {
    // Enabled state:
</div>