forked from M-Labs/web2019
Compare commits
4 Commits
master
...
react-to-p
Author | SHA1 | Date |
---|---|---|
Egor Savkin | 448cf9c29a | |
Egor Savkin | 5c65815f76 | |
Egor Savkin | aa78140aa3 | |
Egor Savkin | 70b8dd1075 |
|
@ -12,6 +12,7 @@
|
||||||
"@babel/core": "^7.23.2",
|
"@babel/core": "^7.23.2",
|
||||||
"@babel/preset-env": "^7.23.2",
|
"@babel/preset-env": "^7.23.2",
|
||||||
"@babel/preset-react": "^7.22.15",
|
"@babel/preset-react": "^7.22.15",
|
||||||
|
"@dnd-kit/core": "^6.1.0",
|
||||||
"@hello-pangea/dnd": "^16.5.0",
|
"@hello-pangea/dnd": "^16.5.0",
|
||||||
"@uidotdev/usehooks": "^2.4.1",
|
"@uidotdev/usehooks": "^2.4.1",
|
||||||
"babel-loader": "^9.1.3",
|
"babel-loader": "^9.1.3",
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
"bootstrap": "^5.3.0",
|
"bootstrap": "^5.3.0",
|
||||||
"jquery": "^3.7.0",
|
"jquery": "^3.7.0",
|
||||||
"json-logic-js": "^2.0.2",
|
"json-logic-js": "^2.0.2",
|
||||||
|
"preact": "^10.19.3",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-bootstrap": "^2.9.1",
|
"react-bootstrap": "^2.9.1",
|
||||||
|
@ -1855,6 +1857,45 @@
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@dnd-kit/accessibility": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@dnd-kit/accessibility/-/accessibility-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-ea7IkhKvlJUv9iSHJOnxinBcoOI3ppGnnL+VDJ75O45Nss6HtZd8IdN8touXPDtASfeI2T2LImb8VOZcL47wjQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@dnd-kit/core": {
|
||||||
|
"version": "6.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.1.0.tgz",
|
||||||
|
"integrity": "sha512-J3cQBClB4TVxwGo3KEjssGEXNJqGVWx17aRTZ1ob0FliR5IjYgTxl5YJbKTzA6IzrtelotH19v6y7uoIRUZPSg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@dnd-kit/accessibility": "^3.1.0",
|
||||||
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
|
"tslib": "^2.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.8.0",
|
||||||
|
"react-dom": ">=16.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@dnd-kit/utilities": {
|
||||||
|
"version": "3.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@dnd-kit/utilities/-/utilities-3.2.2.tgz",
|
||||||
|
"integrity": "sha512-+MKAJEOfaBe5SmV6t34p80MMKhjvUz0vRrvVJbPT0WElzaOJ/1xs+D+KDv+tD/NE5ujfrChEcshd4fLn0wpiqg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@hello-pangea/dnd": {
|
"node_modules/@hello-pangea/dnd": {
|
||||||
"version": "16.5.0",
|
"version": "16.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/@hello-pangea/dnd/-/dnd-16.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/@hello-pangea/dnd/-/dnd-16.5.0.tgz",
|
||||||
|
@ -3992,6 +4033,16 @@
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/preact": {
|
||||||
|
"version": "10.19.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/preact/-/preact-10.19.3.tgz",
|
||||||
|
"integrity": "sha512-nHHTeFVBTHRGxJXKkKu5hT8C/YWBkPso4/Gad6xuj5dbptt9iF9NZr9pHbPhBrnT2klheu7mHTxTZ/LjwJiEiQ==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/preact"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/prop-types": {
|
"node_modules/prop-types": {
|
||||||
"version": "15.8.1",
|
"version": "15.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
"json-logic-js": "^2.0.2",
|
"json-logic-js": "^2.0.2",
|
||||||
"zustand": "^4.4.7",
|
"zustand": "^4.4.7",
|
||||||
"@uidotdev/usehooks":"^2.4.1",
|
"@uidotdev/usehooks":"^2.4.1",
|
||||||
"webpack-preprocessor-loader": "^1.3.0"
|
"webpack-preprocessor-loader": "^1.3.0",
|
||||||
|
"preact": "^10.19.3",
|
||||||
|
"@dnd-kit/core": "^6.1.0"
|
||||||
},
|
},
|
||||||
"babel": {
|
"babel": {
|
||||||
"presets": [
|
"presets": [
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Droppable} from "@hello-pangea/dnd";
|
import {Droppable} from './dnd/Droppable';
|
||||||
import {ProductItem} from "./ProductItem";
|
import {ProductItem} from "./ProductItem";
|
||||||
import {useShopStore} from "./shop_store";
|
import {useShopStore} from "./shop_store";
|
||||||
// #!render_count
|
// #!render_count
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {Droppable} from "@hello-pangea/dnd";
|
import {Droppable} from './dnd/Droppable';
|
||||||
import {cartStyle, compareArraysWithIds} from "./utils";
|
import {cartStyle, compareArraysWithIds} from "./utils";
|
||||||
import {ProductCartItem} from "./ProductCartItem";
|
import {ProductCartItem} from "./ProductCartItem";
|
||||||
import {FakePlaceholder} from "./FakePlaceholder";
|
import {FakePlaceholder} from "./FakePlaceholder";
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {Draggable} from "@hello-pangea/dnd";
|
//import {Draggable} from "@hello-pangea/dnd";
|
||||||
|
import {Draggable} from './dnd/Draggable';
|
||||||
import {compareObjectsEmptiness, productStyle} from "./utils";
|
import {compareObjectsEmptiness, productStyle} from "./utils";
|
||||||
import {Resources} from "./Resources";
|
import {Resources} from "./Resources";
|
||||||
import {CardWarnings} from "./CardWarnings";
|
import {CardWarnings} from "./CardWarnings";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Draggable} from "@hello-pangea/dnd";
|
import {Draggable} from './dnd/Draggable';
|
||||||
import {formatMoney, productStyle} from "./utils";
|
import {formatMoney, productStyle} from "./utils";
|
||||||
import {useShopStore} from "./shop_store";
|
import {useShopStore} from "./shop_store";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React, {useEffect} from 'react';
|
import React, {useEffect} from 'react';
|
||||||
import {DragDropContext} from "@hello-pangea/dnd";
|
//import {DragDropContext} from "@hello-pangea/dnd";
|
||||||
|
import {DndContext, useSensor, useSensors, TouchSensor, MouseSensor} from "@dnd-kit/core";
|
||||||
|
|
||||||
// #!render_count
|
// #!render_count
|
||||||
import {useRenderCount} from "@uidotdev/usehooks";
|
import {useRenderCount} from "@uidotdev/usehooks";
|
||||||
|
@ -23,7 +24,16 @@ export function Shop() {
|
||||||
const deleteCard = useShopStore((state) => state.deleteCard);
|
const deleteCard = useShopStore((state) => state.deleteCard);
|
||||||
const cardIndexById = useShopStore((state) => state.cardIndexById);
|
const cardIndexById = useShopStore((state) => state.cardIndexById);
|
||||||
|
|
||||||
const handleOnDragEnd = (drop_result, _provided) => {
|
const mouseSensor = useSensor(MouseSensor);
|
||||||
|
const touchSensor = useSensor(TouchSensor);
|
||||||
|
const sensors = useSensors(
|
||||||
|
mouseSensor,
|
||||||
|
touchSensor,
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleOnDragEnd = (event) => {
|
||||||
|
console.log(event);
|
||||||
|
|
||||||
if (!drop_result.destination) {
|
if (!drop_result.destination) {
|
||||||
console.warn("No drop destination");
|
console.warn("No drop destination");
|
||||||
return;
|
return;
|
||||||
|
@ -44,7 +54,7 @@ export function Shop() {
|
||||||
console.log("Shop renders: ", renderCount)
|
console.log("Shop renders: ", renderCount)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DragDropContext onDragEnd={handleOnDragEnd}>
|
<DndContext sensors={sensors} onDragEnd={handleOnDragEnd}>
|
||||||
<Layout
|
<Layout
|
||||||
aside={
|
aside={
|
||||||
<Backlog/>
|
<Backlog/>
|
||||||
|
@ -62,7 +72,7 @@ export function Shop() {
|
||||||
/>
|
/>
|
||||||
)}>
|
)}>
|
||||||
</Layout>
|
</Layout>
|
||||||
</DragDropContext>
|
</DndContext>
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
import React from 'react';
|
||||||
|
import {useDraggable} from '@dnd-kit/core';
|
||||||
|
|
||||||
|
export function Draggable(props) {
|
||||||
|
const Element = props.element || 'div';
|
||||||
|
const {attributes, listeners, setNodeRef} = useDraggable({
|
||||||
|
id: props.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Element ref={setNodeRef} {...listeners} {...attributes}>
|
||||||
|
{props.children}
|
||||||
|
</Element>
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
import {useDroppable} from '@dnd-kit/core';
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export function Droppable(props) {
|
||||||
|
const {setNodeRef} = useDroppable({
|
||||||
|
id: props.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div ref={setNodeRef}>
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -35,7 +35,6 @@ class Switch extends Component {
|
||||||
id={key}
|
id={key}
|
||||||
checked={this.state.checked}
|
checked={this.state.checked}
|
||||||
onClick={this.handleClick}
|
onClick={this.handleClick}
|
||||||
onChange={this.handleClick}
|
|
||||||
/>
|
/>
|
||||||
<label className="form-check-label" htmlFor={key} style={{"display": "inline"}}>
|
<label className="form-check-label" htmlFor={key} style={{"display": "inline"}}>
|
||||||
{this.props.icon && <img src={`/images${this.props.icon}`} className="options-icon"/>}
|
{this.props.icon && <img src={`/images${this.props.icon}`} className="options-icon"/>}
|
||||||
|
|
|
@ -46,7 +46,6 @@ class SwitchLine extends Component {
|
||||||
id={key + "switch"}
|
id={key + "switch"}
|
||||||
checked={this.state.checked}
|
checked={this.state.checked}
|
||||||
onClick={this.handleCheck}
|
onClick={this.handleCheck}
|
||||||
onChange={this.handleCheck}
|
|
||||||
/>
|
/>
|
||||||
<label className="form-check-label" htmlFor={key + "switch"}>
|
<label className="form-check-label" htmlFor={key + "switch"}>
|
||||||
{this.props.icon && <img src={`/images${this.props.icon}`} className="options-icon"/>}
|
{this.props.icon && <img src={`/images${this.props.icon}`} className="options-icon"/>}
|
||||||
|
|
|
@ -36,6 +36,12 @@ module.exports = {
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.tsx', '.ts', '.js', '.jsx'],
|
extensions: ['.tsx', '.ts', '.js', '.jsx'],
|
||||||
|
"alias": {
|
||||||
|
"react": "preact/compat",
|
||||||
|
"react-dom/test-utils": "preact/test-utils",
|
||||||
|
"react-dom": "preact/compat", // Must be below test-utils
|
||||||
|
"react/jsx-runtime": "preact/jsx-runtime"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
//devtool: "inline-source-map",
|
//devtool: "inline-source-map",
|
||||||
//mode: "development"
|
//mode: "development"
|
||||||
|
|
Loading…
Reference in New Issue