@pie-lib/drag 4.0.3-next.37 → 4.0.3-next.57
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/CHANGELOG.json +1 -0
- package/CHANGELOG.md +802 -0
- package/LICENSE.md +5 -0
- package/lib/drag-in-the-blank-dp.js +66 -0
- package/lib/drag-in-the-blank-dp.js.map +1 -0
- package/lib/drag-provider.js +61 -0
- package/lib/drag-provider.js.map +1 -0
- package/lib/drag-type.js +14 -0
- package/lib/drag-type.js.map +1 -0
- package/lib/draggable-choice.js +95 -0
- package/lib/draggable-choice.js.map +1 -0
- package/lib/droppable-placeholder.js +50 -0
- package/lib/droppable-placeholder.js.map +1 -0
- package/lib/ica-dp.js +37 -0
- package/lib/ica-dp.js.map +1 -0
- package/lib/index.js +61 -0
- package/lib/index.js.map +1 -0
- package/lib/match-list-dp.js +49 -0
- package/lib/match-list-dp.js.map +1 -0
- package/lib/placeholder.js +131 -0
- package/lib/placeholder.js.map +1 -0
- package/lib/preview-component.js +154 -0
- package/lib/preview-component.js.map +1 -0
- package/lib/swap.js +18 -0
- package/lib/swap.js.map +1 -0
- package/lib/uid-context.js +26 -0
- package/lib/uid-context.js.map +1 -0
- package/package.json +16 -34
- package/src/__tests__/drag-provider.test.jsx +313 -0
- package/src/__tests__/placeholder.test.jsx +107 -0
- package/src/__tests__/preview-component.test.jsx +537 -0
- package/src/__tests__/swap.test.js +161 -0
- package/src/__tests__/uid-context.test.jsx +54 -0
- package/src/drag-in-the-blank-dp.jsx +65 -0
- package/src/drag-provider.jsx +50 -0
- package/src/drag-type.js +7 -0
- package/src/draggable-choice.jsx +83 -0
- package/src/droppable-placeholder.jsx +41 -0
- package/src/ica-dp.jsx +25 -0
- package/src/index.js +19 -0
- package/src/match-list-dp.jsx +36 -0
- package/src/placeholder.jsx +132 -0
- package/src/preview-component.jsx +145 -0
- package/src/swap.js +14 -0
- package/src/uid-context.js +13 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -11
- package/dist/drag-in-the-blank-dp.d.ts +0 -29
- package/dist/drag-in-the-blank-dp.js +0 -44
- package/dist/drag-provider.d.ts +0 -29
- package/dist/drag-provider.js +0 -31
- package/dist/drag-type.d.ts +0 -16
- package/dist/draggable-choice.d.ts +0 -43
- package/dist/draggable-choice.js +0 -63
- package/dist/droppable-placeholder.d.ts +0 -29
- package/dist/droppable-placeholder.js +0 -36
- package/dist/ica-dp.d.ts +0 -24
- package/dist/ica-dp.js +0 -20
- package/dist/index.d.ts +0 -17
- package/dist/index.js +0 -9
- package/dist/match-list-dp.d.ts +0 -26
- package/dist/match-list-dp.js +0 -21
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
- package/dist/placeholder.d.ts +0 -31
- package/dist/placeholder.js +0 -98
- package/dist/preview-component.d.ts +0 -11
- package/dist/swap.d.ts +0 -10
- package/dist/swap.js +0 -9
- package/dist/uid-context.d.ts +0 -13
- package/dist/uid-context.js +0 -15
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = exports.PlaceHolder = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _styles = require("@mui/material/styles");
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
14
|
+
var _colors = require("@mui/material/colors");
|
|
15
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
+
var StyledPlaceholder = (0, _styles.styled)('div')(function (_ref) {
|
|
18
|
+
var theme = _ref.theme;
|
|
19
|
+
return {
|
|
20
|
+
'&.placeholder': {
|
|
21
|
+
WebkitTouchCallout: 'none',
|
|
22
|
+
WebkitUserSelect: 'none',
|
|
23
|
+
KhtmlUserSelect: 'none',
|
|
24
|
+
MozUserSelect: 'none',
|
|
25
|
+
MsUserSelect: 'none',
|
|
26
|
+
userSelect: 'none',
|
|
27
|
+
width: '100%',
|
|
28
|
+
height: '100%',
|
|
29
|
+
background: _renderUi.color.white(),
|
|
30
|
+
transition: 'background-color 200ms linear, border-color 200ms linear',
|
|
31
|
+
boxSizing: 'border-box',
|
|
32
|
+
display: 'grid',
|
|
33
|
+
gridRowGap: theme.spacing(1),
|
|
34
|
+
gridColumnGap: theme.spacing(1),
|
|
35
|
+
padding: theme.spacing(1),
|
|
36
|
+
border: "2px dashed ".concat(_renderUi.color.black())
|
|
37
|
+
},
|
|
38
|
+
'&.disabled': {
|
|
39
|
+
boxShadow: 'none',
|
|
40
|
+
background: theme.palette.background.paper
|
|
41
|
+
},
|
|
42
|
+
'&.over': {
|
|
43
|
+
border: "1px solid ".concat(_colors.grey[500]),
|
|
44
|
+
backgroundColor: "".concat(_colors.grey[300])
|
|
45
|
+
},
|
|
46
|
+
'&.board': {
|
|
47
|
+
padding: theme.spacing(1),
|
|
48
|
+
display: 'flex',
|
|
49
|
+
flexWrap: 'wrap',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
minHeight: '100px',
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
overflow: 'hidden',
|
|
54
|
+
touchAction: 'none',
|
|
55
|
+
backgroundColor: _renderUi.color.backgroundDark()
|
|
56
|
+
},
|
|
57
|
+
'&.categorizeBoard': {
|
|
58
|
+
padding: theme.spacing(0.5),
|
|
59
|
+
display: 'flex',
|
|
60
|
+
flexWrap: 'wrap',
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
minHeight: '100px',
|
|
63
|
+
justifyContent: 'center',
|
|
64
|
+
overflow: 'hidden',
|
|
65
|
+
touchAction: 'none',
|
|
66
|
+
backgroundColor: _renderUi.color.backgroundDark()
|
|
67
|
+
},
|
|
68
|
+
'&.verticalPool': {
|
|
69
|
+
display: 'flex',
|
|
70
|
+
flexFlow: 'column wrap'
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
var PlaceHolder = exports.PlaceHolder = function PlaceHolder(props) {
|
|
75
|
+
var children = props.children,
|
|
76
|
+
className = props.className,
|
|
77
|
+
isOver = props.isOver,
|
|
78
|
+
type = props.type,
|
|
79
|
+
grid = props.grid,
|
|
80
|
+
disabled = props.disabled,
|
|
81
|
+
choiceBoard = props.choiceBoard,
|
|
82
|
+
isCategorize = props.isCategorize,
|
|
83
|
+
isVerticalPool = props.isVerticalPool,
|
|
84
|
+
minHeight = props.minHeight,
|
|
85
|
+
extraStyles = props.extraStyles;
|
|
86
|
+
var names = (0, _classnames["default"])('placeholder', disabled && 'disabled', isOver && 'over', type, className);
|
|
87
|
+
var style = {};
|
|
88
|
+
if (grid && grid.columns) {
|
|
89
|
+
style.gridTemplateColumns = "repeat(".concat(grid.columns, ", 1fr)");
|
|
90
|
+
}
|
|
91
|
+
if (grid && grid.rows) {
|
|
92
|
+
var repeatValue = grid.rowsRepeatValue || '1fr';
|
|
93
|
+
style.gridTemplateRows = "repeat(".concat(grid.rows, ", ").concat(repeatValue, ")");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// The "type" is only sent through placement-ordering / placeholder
|
|
97
|
+
// It can be "choice" or "target"
|
|
98
|
+
// We apply a different style for the "choice" type
|
|
99
|
+
// For any other type, use a dashed black border and a white fill
|
|
100
|
+
if (type === 'choice') {
|
|
101
|
+
style.border = "1px solid ".concat(_renderUi.color.borderLight());
|
|
102
|
+
style.background = _renderUi.color.backgroundDark();
|
|
103
|
+
}
|
|
104
|
+
var boardStyle = isCategorize ? 'categorizeBoard' : 'board';
|
|
105
|
+
return /*#__PURE__*/_react["default"].createElement(StyledPlaceholder, {
|
|
106
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
107
|
+
minHeight: minHeight
|
|
108
|
+
}, extraStyles),
|
|
109
|
+
className: (0, _classnames["default"])(choiceBoard ? boardStyle : names, isVerticalPool && 'verticalPool')
|
|
110
|
+
}, children);
|
|
111
|
+
};
|
|
112
|
+
PlaceHolder.propTypes = {
|
|
113
|
+
choiceBoard: _propTypes["default"].bool,
|
|
114
|
+
grid: _propTypes["default"].shape({
|
|
115
|
+
columns: _propTypes["default"].number,
|
|
116
|
+
rows: _propTypes["default"].number,
|
|
117
|
+
// if a different value then 1fr is wanted
|
|
118
|
+
rowsRepeatValue: _propTypes["default"].string
|
|
119
|
+
}),
|
|
120
|
+
children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired,
|
|
121
|
+
className: _propTypes["default"].string,
|
|
122
|
+
isOver: _propTypes["default"].bool,
|
|
123
|
+
index: _propTypes["default"].number,
|
|
124
|
+
type: _propTypes["default"].string,
|
|
125
|
+
disabled: _propTypes["default"].bool,
|
|
126
|
+
isCategorize: _propTypes["default"].bool,
|
|
127
|
+
isVerticalPool: _propTypes["default"].bool,
|
|
128
|
+
minHeight: _propTypes["default"].number
|
|
129
|
+
};
|
|
130
|
+
var _default = exports["default"] = PlaceHolder;
|
|
131
|
+
//# sourceMappingURL=placeholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placeholder.js","names":["_react","_interopRequireDefault","require","_styles","_classnames","_propTypes","_renderUi","_colors","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","StyledPlaceholder","styled","_ref","theme","WebkitTouchCallout","WebkitUserSelect","KhtmlUserSelect","MozUserSelect","MsUserSelect","userSelect","width","height","background","color","white","transition","boxSizing","display","gridRowGap","spacing","gridColumnGap","padding","border","concat","black","boxShadow","palette","paper","grey","backgroundColor","flexWrap","alignItems","minHeight","justifyContent","overflow","touchAction","backgroundDark","flexFlow","PlaceHolder","exports","props","children","className","isOver","type","grid","disabled","choiceBoard","isCategorize","isVerticalPool","extraStyles","names","classNames","style","columns","gridTemplateColumns","rows","repeatValue","rowsRepeatValue","gridTemplateRows","borderLight","boardStyle","createElement","propTypes","PropTypes","bool","shape","number","string","oneOfType","arrayOf","node","isRequired","index","_default"],"sources":["../src/placeholder.jsx"],"sourcesContent":["import React from 'react';\nimport { styled } from '@mui/material/styles';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\nimport { color } from '@pie-lib/render-ui';\nimport { grey } from '@mui/material/colors';\n\nconst StyledPlaceholder = styled('div')(({ theme }) => ({\n '&.placeholder': {\n WebkitTouchCallout: 'none',\n WebkitUserSelect: 'none',\n KhtmlUserSelect: 'none',\n MozUserSelect: 'none',\n MsUserSelect: 'none',\n userSelect: 'none',\n width: '100%',\n height: '100%',\n background: color.white(),\n transition: 'background-color 200ms linear, border-color 200ms linear',\n boxSizing: 'border-box',\n display: 'grid',\n gridRowGap: theme.spacing(1),\n gridColumnGap: theme.spacing(1),\n padding: theme.spacing(1),\n border: `2px dashed ${color.black()}`,\n },\n '&.disabled': {\n boxShadow: 'none',\n background: theme.palette.background.paper,\n },\n '&.over': {\n border: `1px solid ${grey[500]}`,\n backgroundColor: `${grey[300]}`,\n },\n '&.board': {\n padding: theme.spacing(1),\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'center',\n minHeight: '100px',\n justifyContent: 'center',\n overflow: 'hidden',\n touchAction: 'none',\n backgroundColor: color.backgroundDark(),\n },\n '&.categorizeBoard': {\n padding: theme.spacing(0.5),\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'center',\n minHeight: '100px',\n justifyContent: 'center',\n overflow: 'hidden',\n touchAction: 'none',\n backgroundColor: color.backgroundDark(),\n },\n '&.verticalPool': {\n display: 'flex',\n flexFlow: 'column wrap',\n },\n}));\n\nexport const PlaceHolder = (props) => {\n const {\n children,\n className,\n isOver,\n type,\n grid,\n disabled,\n choiceBoard,\n isCategorize,\n isVerticalPool,\n minHeight,\n extraStyles,\n } = props;\n\n const names = classNames('placeholder', disabled && 'disabled', isOver && 'over', type, className);\n\n const style = {};\n\n if (grid && grid.columns) {\n style.gridTemplateColumns = `repeat(${grid.columns}, 1fr)`;\n }\n\n if (grid && grid.rows) {\n const repeatValue = grid.rowsRepeatValue || '1fr';\n\n style.gridTemplateRows = `repeat(${grid.rows}, ${repeatValue})`;\n }\n\n // The \"type\" is only sent through placement-ordering / placeholder\n // It can be \"choice\" or \"target\"\n // We apply a different style for the \"choice\" type\n // For any other type, use a dashed black border and a white fill\n if (type === 'choice') {\n style.border = `1px solid ${color.borderLight()}`;\n style.background = color.backgroundDark();\n }\n\n const boardStyle = isCategorize ? 'categorizeBoard' : 'board';\n\n return (\n <StyledPlaceholder\n style={{ ...style, minHeight: minHeight, ...extraStyles }}\n className={classNames(choiceBoard ? boardStyle : names, isVerticalPool && 'verticalPool')}\n >\n {children}\n </StyledPlaceholder>\n );\n};\n\nPlaceHolder.propTypes = {\n choiceBoard: PropTypes.bool,\n grid: PropTypes.shape({\n columns: PropTypes.number,\n rows: PropTypes.number,\n // if a different value then 1fr is wanted\n rowsRepeatValue: PropTypes.string,\n }),\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,\n className: PropTypes.string,\n isOver: PropTypes.bool,\n index: PropTypes.number,\n type: PropTypes.string,\n disabled: PropTypes.bool,\n isCategorize: PropTypes.bool,\n isVerticalPool: PropTypes.bool,\n minHeight: PropTypes.number,\n};\n\nexport default PlaceHolder;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAA4C,SAAAM,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,QAAAe,gBAAA,aAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA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,qBAAS,CAACE,KAAK,CAAC;IACpBZ,OAAO,EAAEU,qBAAS,CAACG,MAAM;IACzBX,IAAI,EAAEQ,qBAAS,CAACG,MAAM;IACtB;IACAT,eAAe,EAAEM,qBAAS,CAACI;EAC7B,CAAC,CAAC;EACF3B,QAAQ,EAAEuB,qBAAS,CAACK,SAAS,CAAC,CAACL,qBAAS,CAACM,OAAO,CAACN,qBAAS,CAACO,IAAI,CAAC,EAAEP,qBAAS,CAACO,IAAI,CAAC,CAAC,CAACC,UAAU;EAC7F9B,SAAS,EAAEsB,qBAAS,CAACI,MAAM;EAC3BzB,MAAM,EAAEqB,qBAAS,CAACC,IAAI;EACtBQ,KAAK,EAAET,qBAAS,CAACG,MAAM;EACvBvB,IAAI,EAAEoB,qBAAS,CAACI,MAAM;EACtBtB,QAAQ,EAAEkB,qBAAS,CAACC,IAAI;EACxBjB,YAAY,EAAEgB,qBAAS,CAACC,IAAI;EAC5BhB,cAAc,EAAEe,qBAAS,CAACC,IAAI;EAC9BjC,SAAS,EAAEgC,qBAAS,CAACG;AACvB,CAAC;AAAC,IAAAO,QAAA,GAAAnC,OAAA,cAEaD,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _core = require("@dnd-kit/core");
|
|
13
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
14
|
+
var _mathRendering = require("@pie-lib/math-rendering");
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
+
var styles = {
|
|
19
|
+
maskBlank: {
|
|
20
|
+
// this style is applied only on small screens and for touch devices when dragging, for drag-in-the-blank.
|
|
21
|
+
// It is styled to be identical to the drag-in-the-blank chip
|
|
22
|
+
backgroundColor: _renderUi.color.white(),
|
|
23
|
+
border: "1px solid ".concat(_renderUi.color.text()),
|
|
24
|
+
color: _renderUi.color.text(),
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
display: 'inline-flex',
|
|
27
|
+
height: 'initial',
|
|
28
|
+
minHeight: '32px',
|
|
29
|
+
fontSize: 'inherit',
|
|
30
|
+
whiteSpace: 'pre-wrap',
|
|
31
|
+
maxWidth: '374px',
|
|
32
|
+
borderRadius: '3px',
|
|
33
|
+
padding: '12px'
|
|
34
|
+
},
|
|
35
|
+
ica: {
|
|
36
|
+
backgroundColor: _renderUi.color.background(),
|
|
37
|
+
border: "1px solid ".concat(_renderUi.color.borderDark()),
|
|
38
|
+
display: 'flex',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
minHeight: '28px',
|
|
42
|
+
padding: '0 3px',
|
|
43
|
+
marginLeft: 2,
|
|
44
|
+
marginTop: 2,
|
|
45
|
+
width: 'fit-content'
|
|
46
|
+
},
|
|
47
|
+
categorize: {
|
|
48
|
+
color: _renderUi.color.text(),
|
|
49
|
+
backgroundColor: _renderUi.color.background(),
|
|
50
|
+
padding: '16px',
|
|
51
|
+
borderRadius: '4px',
|
|
52
|
+
border: '1px solid'
|
|
53
|
+
},
|
|
54
|
+
matchList: {
|
|
55
|
+
color: _renderUi.color.text(),
|
|
56
|
+
backgroundColor: _renderUi.color.background(),
|
|
57
|
+
padding: '10px',
|
|
58
|
+
boxSizing: 'border-box',
|
|
59
|
+
border: '1px solid #D1D1D1'
|
|
60
|
+
},
|
|
61
|
+
placementOrdering: {
|
|
62
|
+
padding: '10px',
|
|
63
|
+
boxSizing: 'border-box',
|
|
64
|
+
border: '1px solid #D1D1D1',
|
|
65
|
+
backgroundColor: _renderUi.color.background()
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var getPrompt = function getPrompt(dragData) {
|
|
69
|
+
var _dragData$choice;
|
|
70
|
+
if (!dragData) return undefined;
|
|
71
|
+
|
|
72
|
+
// Handle different drag data structures based on the component type
|
|
73
|
+
if (dragData.choiceId) {
|
|
74
|
+
// DraggableChoice format
|
|
75
|
+
return dragData.value;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Legacy format support
|
|
79
|
+
switch (dragData.itemType) {
|
|
80
|
+
case 'MaskBlank':
|
|
81
|
+
return (_dragData$choice = dragData.choice) === null || _dragData$choice === void 0 ? void 0 : _dragData$choice.value;
|
|
82
|
+
case 'dnd-kit-response':
|
|
83
|
+
return dragData.value;
|
|
84
|
+
case 'Answer':
|
|
85
|
+
return dragData.value;
|
|
86
|
+
case 'Tile':
|
|
87
|
+
return dragData.value;
|
|
88
|
+
case 'categorize':
|
|
89
|
+
return dragData.value;
|
|
90
|
+
default:
|
|
91
|
+
return dragData.value;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var getCustomStyle = function getCustomStyle(dragData) {
|
|
95
|
+
if (!dragData) return {};
|
|
96
|
+
var baseStyle = {
|
|
97
|
+
cursor: 'grabbing',
|
|
98
|
+
opacity: 0.8,
|
|
99
|
+
transform: 'rotate(5deg)' // Slight rotation for visual feedback
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Apply specific styles based on item type
|
|
103
|
+
if (dragData.itemType === 'MaskBlank') {
|
|
104
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.maskBlank);
|
|
105
|
+
}
|
|
106
|
+
if (dragData.itemType === 'categorize') {
|
|
107
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.categorize);
|
|
108
|
+
}
|
|
109
|
+
if (dragData.itemType === 'Answer') {
|
|
110
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.matchList);
|
|
111
|
+
}
|
|
112
|
+
if (dragData.itemType === 'Tile') {
|
|
113
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.placementOrdering);
|
|
114
|
+
}
|
|
115
|
+
if (dragData.itemType === 'dnd-kit-response') {
|
|
116
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.ica);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Default style for choice items
|
|
120
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.categorize);
|
|
121
|
+
};
|
|
122
|
+
var PreviewComponent = function PreviewComponent() {
|
|
123
|
+
var _active$data;
|
|
124
|
+
var _useDndContext = (0, _core.useDndContext)(),
|
|
125
|
+
active = _useDndContext.active;
|
|
126
|
+
var _useState = (0, _react.useState)(1),
|
|
127
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
128
|
+
zoomLevel = _useState2[0],
|
|
129
|
+
setZoomLevel = _useState2[1];
|
|
130
|
+
var root = (0, _react.useRef)(null);
|
|
131
|
+
var dragData = active === null || active === void 0 || (_active$data = active.data) === null || _active$data === void 0 ? void 0 : _active$data.current;
|
|
132
|
+
var isActive = !!active;
|
|
133
|
+
(0, _react.useEffect)(function () {
|
|
134
|
+
if (isActive && root.current) {
|
|
135
|
+
(0, _mathRendering.renderMath)(root.current);
|
|
136
|
+
|
|
137
|
+
// Adjusted for precise zoom level calculation in Online Testing, targeting the specific class pattern .asmt-zoomable.asmt-zoom-NR .asmt-question .padding
|
|
138
|
+
var zoomAffectedElement = document.querySelector('.padding') || document.body;
|
|
139
|
+
setZoomLevel(parseFloat(getComputedStyle(zoomAffectedElement).zoom) || 1);
|
|
140
|
+
}
|
|
141
|
+
}, [isActive, dragData]);
|
|
142
|
+
var customStyle = getCustomStyle(dragData);
|
|
143
|
+
var prompt = getPrompt(dragData);
|
|
144
|
+
return /*#__PURE__*/_react["default"].createElement(_core.DragOverlay, null, isActive && prompt && /*#__PURE__*/_react["default"].createElement("div", {
|
|
145
|
+
ref: root,
|
|
146
|
+
style: customStyle
|
|
147
|
+
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
148
|
+
className: "prompt-label",
|
|
149
|
+
prompt: prompt,
|
|
150
|
+
tagName: "span"
|
|
151
|
+
})));
|
|
152
|
+
};
|
|
153
|
+
var _default = exports["default"] = PreviewComponent;
|
|
154
|
+
//# sourceMappingURL=preview-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-component.js","names":["_react","_interopRequireWildcard","require","_core","_renderUi","_mathRendering","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","styles","maskBlank","backgroundColor","color","white","border","concat","text","alignItems","display","height","minHeight","fontSize","whiteSpace","maxWidth","borderRadius","padding","ica","background","borderDark","justifyContent","marginLeft","marginTop","width","categorize","matchList","boxSizing","placementOrdering","getPrompt","dragData","_dragData$choice","undefined","choiceId","value","itemType","choice","getCustomStyle","baseStyle","cursor","opacity","transform","PreviewComponent","_active$data","_useDndContext","useDndContext","active","_useState","useState","_useState2","_slicedToArray2","zoomLevel","setZoomLevel","root","useRef","data","current","isActive","useEffect","renderMath","zoomAffectedElement","document","querySelector","body","parseFloat","getComputedStyle","zoom","customStyle","prompt","createElement","DragOverlay","ref","style","PreviewPrompt","className","tagName","_default","exports"],"sources":["../src/preview-component.jsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { DragOverlay, useDndContext } from '@dnd-kit/core';\nimport { color, PreviewPrompt } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nconst styles = {\n maskBlank: {\n // this style is applied only on small screens and for touch devices when dragging, for drag-in-the-blank.\n // It is styled to be identical to the drag-in-the-blank chip\n backgroundColor: color.white(),\n border: `1px solid ${color.text()}`,\n color: color.text(),\n alignItems: 'center',\n display: 'inline-flex',\n height: 'initial',\n minHeight: '32px',\n fontSize: 'inherit',\n whiteSpace: 'pre-wrap',\n maxWidth: '374px',\n borderRadius: '3px',\n padding: '12px',\n },\n ica: {\n backgroundColor: color.background(),\n border: `1px solid ${color.borderDark()}`,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: '28px',\n padding: '0 3px',\n marginLeft: 2,\n marginTop: 2,\n width: 'fit-content',\n },\n categorize: {\n color: color.text(),\n backgroundColor: color.background(),\n padding: '16px',\n borderRadius: '4px',\n border: '1px solid',\n },\n matchList: {\n color: color.text(),\n backgroundColor: color.background(),\n padding: '10px',\n boxSizing: 'border-box',\n border: '1px solid #D1D1D1',\n },\n placementOrdering: {\n padding: '10px',\n boxSizing: 'border-box',\n border: '1px solid #D1D1D1',\n backgroundColor: color.background(),\n },\n};\n\nconst getPrompt = (dragData) => {\n if (!dragData) return undefined;\n\n // Handle different drag data structures based on the component type\n if (dragData.choiceId) {\n // DraggableChoice format\n return dragData.value;\n }\n\n // Legacy format support\n switch (dragData.itemType) {\n case 'MaskBlank':\n return dragData.choice?.value;\n case 'dnd-kit-response':\n return dragData.value;\n case 'Answer':\n return dragData.value;\n case 'Tile':\n return dragData.value;\n case 'categorize':\n return dragData.value;\n default:\n return dragData.value;\n }\n};\n\nconst getCustomStyle = (dragData) => {\n if (!dragData) return {};\n\n const baseStyle = {\n cursor: 'grabbing',\n opacity: 0.8,\n transform: 'rotate(5deg)', // Slight rotation for visual feedback\n };\n\n // Apply specific styles based on item type\n if (dragData.itemType === 'MaskBlank') {\n return { ...baseStyle, ...styles.maskBlank };\n }\n if (dragData.itemType === 'categorize') {\n return { ...baseStyle, ...styles.categorize };\n }\n if (dragData.itemType === 'Answer') {\n return { ...baseStyle, ...styles.matchList };\n }\n if (dragData.itemType === 'Tile') {\n return { ...baseStyle, ...styles.placementOrdering };\n }\n if (dragData.itemType === 'dnd-kit-response') {\n return { ...baseStyle, ...styles.ica };\n }\n\n // Default style for choice items\n return { ...baseStyle, ...styles.categorize };\n};\n\nconst PreviewComponent = () => {\n const { active } = useDndContext();\n const [zoomLevel, setZoomLevel] = useState(1);\n const root = useRef(null);\n\n const dragData = active?.data?.current;\n const isActive = !!active;\n\n useEffect(() => {\n if (isActive && root.current) {\n renderMath(root.current);\n\n // Adjusted for precise zoom level calculation in Online Testing, targeting the specific class pattern .asmt-zoomable.asmt-zoom-NR .asmt-question .padding\n const zoomAffectedElement = document.querySelector('.padding') || document.body;\n setZoomLevel(parseFloat(getComputedStyle(zoomAffectedElement).zoom) || 1);\n }\n }, [isActive, dragData]);\n\n const customStyle = getCustomStyle(dragData);\n const prompt = getPrompt(dragData);\n\n return (\n <DragOverlay>\n {isActive && prompt && (\n <div ref={root} style={customStyle}>\n <PreviewPrompt className=\"prompt-label\" prompt={prompt} tagName=\"span\" />\n </div>\n )}\n </DragOverlay>\n );\n};\n\nexport default PreviewComponent;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAAqD,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,wBAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAnB,CAAA,EAAAc,EAAA,OAAAP,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAM,EAAA,EAAAP,CAAA,IAA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UAAU,CAACC,gBAAgB,CAACL,mBAAmB,CAAC,CAACM,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3E;EACF,CAAC,EAAE,CAACT,QAAQ,EAAE3B,QAAQ,CAAC,CAAC;EAExB,IAAMqC,WAAW,GAAG9B,cAAc,CAACP,QAAQ,CAAC;EAC5C,IAAMsC,MAAM,GAAGvC,SAAS,CAACC,QAAQ,CAAC;EAElC,oBACErE,MAAA,YAAA4G,aAAA,CAACzG,KAAA,CAAA0G,WAAW,QACTb,QAAQ,IAAIW,MAAM,iBACjB3G,MAAA,YAAA4G,aAAA;IAAKE,GAAG,EAAElB,IAAK;IAACmB,KAAK,EAAEL;EAAY,gBACjC1G,MAAA,YAAA4G,aAAA,CAACxG,SAAA,CAAA4G,aAAa;IAACC,SAAS,EAAC,cAAc;IAACN,MAAM,EAAEA,MAAO;IAACO,OAAO,EAAC;EAAM,CAAE,CACrE,CAEI,CAAC;AAElB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEanC,gBAAgB","ignoreList":[]}
|
package/lib/swap.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
8
|
+
var _default = exports["default"] = function _default(arr, fromIndex, toIndex) {
|
|
9
|
+
if (!arr || arr.length <= 1 || fromIndex === undefined || toIndex === undefined) {
|
|
10
|
+
throw new Error("swap requires a non-empty array, fromIndex, toIndex: ".concat(arr, ", ").concat(fromIndex, " ").concat(toIndex));
|
|
11
|
+
}
|
|
12
|
+
var update = (0, _lodashEs.cloneDeep)(arr);
|
|
13
|
+
var tmp = arr[toIndex];
|
|
14
|
+
update[toIndex] = update[fromIndex];
|
|
15
|
+
update[fromIndex] = tmp;
|
|
16
|
+
return update;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=swap.js.map
|
package/lib/swap.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap.js","names":["_lodashEs","require","_default","exports","arr","fromIndex","toIndex","length","undefined","Error","concat","update","cloneDeep","tmp"],"sources":["../src/swap.js"],"sourcesContent":["import { cloneDeep } from 'lodash-es';\n\nexport default (arr, fromIndex, toIndex) => {\n if (!arr || arr.length <= 1 || fromIndex === undefined || toIndex === undefined) {\n throw new Error(`swap requires a non-empty array, fromIndex, toIndex: ${arr}, ${fromIndex} ${toIndex}`);\n }\n\n const update = cloneDeep(arr);\n const tmp = arr[toIndex];\n update[toIndex] = update[fromIndex];\n update[fromIndex] = tmp;\n\n return update;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAAsC,IAAAC,QAAA,GAAAC,OAAA,cAEvB,SAAAD,SAACE,GAAG,EAAEC,SAAS,EAAEC,OAAO,EAAK;EAC1C,IAAI,CAACF,GAAG,IAAIA,GAAG,CAACG,MAAM,IAAI,CAAC,IAAIF,SAAS,KAAKG,SAAS,IAAIF,OAAO,KAAKE,SAAS,EAAE;IAC/E,MAAM,IAAIC,KAAK,yDAAAC,MAAA,CAAyDN,GAAG,QAAAM,MAAA,CAAKL,SAAS,OAAAK,MAAA,CAAIJ,OAAO,CAAE,CAAC;EACzG;EAEA,IAAMK,MAAM,GAAG,IAAAC,mBAAS,EAACR,GAAG,CAAC;EAC7B,IAAMS,GAAG,GAAGT,GAAG,CAACE,OAAO,CAAC;EACxBK,MAAM,CAACL,OAAO,CAAC,GAAGK,MAAM,CAACN,SAAS,CAAC;EACnCM,MAAM,CAACN,SAAS,CAAC,GAAGQ,GAAG;EAEvB,OAAOF,MAAM;AACf,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.withUid = exports.generateId = exports.Provider = exports.Consumer = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _React$createContext = /*#__PURE__*/_react["default"].createContext(-1),
|
|
11
|
+
Consumer = exports.Consumer = _React$createContext.Consumer,
|
|
12
|
+
Provider = exports.Provider = _React$createContext.Provider;
|
|
13
|
+
var generateId = exports.generateId = function generateId() {
|
|
14
|
+
return (Math.random() * 1000001).toFixed(0);
|
|
15
|
+
};
|
|
16
|
+
var withUid = exports.withUid = function withUid(Component) {
|
|
17
|
+
var Wrapped = function Wrapped(props) {
|
|
18
|
+
return /*#__PURE__*/_react["default"].createElement(Consumer, null, function (uid) {
|
|
19
|
+
return /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({}, props, {
|
|
20
|
+
uid: uid
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
return Wrapped;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=uid-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uid-context.js","names":["_react","_interopRequireDefault","require","_React$createContext","React","createContext","Consumer","exports","Provider","generateId","Math","random","toFixed","withUid","Component","Wrapped","props","createElement","uid","_extends2"],"sources":["../src/uid-context.js"],"sourcesContent":["import React from 'react';\n\nconst { Consumer, Provider } = React.createContext(-1);\n\nexport { Provider, Consumer };\n\nexport const generateId = () => (Math.random() * 1000001).toFixed(0);\n\nexport const withUid = (Component) => {\n const Wrapped = (props) => <Consumer>{(uid) => <Component {...props} uid={uid} />}</Consumer>;\n\n return Wrapped;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,oBAAA,gBAA+BC,iBAAK,CAACC,aAAa,CAAC,CAAC,CAAC,CAAC;EAA9CC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAAH,oBAAA,CAARG,QAAQ;EAAEE,QAAQ,GAAAD,OAAA,CAAAC,QAAA,GAAAL,oBAAA,CAARK,QAAQ;AAInB,IAAMC,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAG,SAAbA,UAAUA,CAAA;EAAA,OAAS,CAACC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,OAAO,EAAEC,OAAO,CAAC,CAAC,CAAC;AAAA;AAE7D,IAAMC,OAAO,GAAAN,OAAA,CAAAM,OAAA,GAAG,SAAVA,OAAOA,CAAIC,SAAS,EAAK;EACpC,IAAMC,OAAO,GAAG,SAAVA,OAAOA,CAAIC,KAAK;IAAA,oBAAKhB,MAAA,YAAAiB,aAAA,CAACX,QAAQ,QAAE,UAACY,GAAG;MAAA,oBAAKlB,MAAA,YAAAiB,aAAA,CAACH,SAAS,MAAAK,SAAA,iBAAKH,KAAK;QAAEE,GAAG,EAAEA;MAAI,EAAE,CAAC;IAAA,CAAW,CAAC;EAAA;EAE7F,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,48 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/drag",
|
|
3
|
-
"version": "4.0.3-next.
|
|
3
|
+
"version": "4.0.3-next.57+af2792a91",
|
|
4
4
|
"description": "",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"module": "src/index.js",
|
|
7
|
+
"repository": "pie-framework/pie-lib",
|
|
5
8
|
"dependencies": {
|
|
6
9
|
"@dnd-kit/core": "6.3.1",
|
|
7
10
|
"@dnd-kit/sortable": "10.0.0",
|
|
8
11
|
"@dnd-kit/utilities": "3.2.2",
|
|
9
12
|
"@emotion/react": "^11.14.0",
|
|
10
|
-
"@emotion/
|
|
13
|
+
"@emotion/styled": "^11.14.1",
|
|
11
14
|
"@mui/icons-material": "^7.3.4",
|
|
12
15
|
"@mui/material": "^7.3.4",
|
|
13
|
-
"@pie-lib/
|
|
16
|
+
"@pie-lib/math-rendering": "^5.0.2",
|
|
17
|
+
"@pie-lib/render-ui": "^6.1.1-next.57+af2792a91",
|
|
18
|
+
"classnames": "^2.2.6",
|
|
19
|
+
"lodash-es": "^4.17.23",
|
|
14
20
|
"prop-types": "^15.7.2",
|
|
15
|
-
"
|
|
16
|
-
"@pie-element/shared-math-rendering-mathjax": "0.1.1-next.0",
|
|
17
|
-
"@pie-element/shared-lodash": "0.1.1-next.0"
|
|
21
|
+
"react": "^18.2.0"
|
|
18
22
|
},
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
22
|
-
"exports": {
|
|
23
|
-
".": {
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
25
|
-
"default": "./dist/index.js"
|
|
26
|
-
}
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
27
25
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"scripts": {
|
|
33
|
-
"build": "bun x vite build && bun x tsc --emitDeclarationOnly",
|
|
34
|
-
"dev": "bun x vite",
|
|
35
|
-
"test": "bun x vitest run"
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"vite": "^8.0.1",
|
|
39
|
-
"typescript": "^5.9.3",
|
|
40
|
-
"@vitejs/plugin-react": "^6.0.1",
|
|
41
|
-
"@types/react": "^18.2.0",
|
|
42
|
-
"@types/react-dom": "^18.2.0"
|
|
43
|
-
},
|
|
44
|
-
"peerDependencies": {
|
|
45
|
-
"react": "^18.0.0",
|
|
46
|
-
"react-dom": "^18.0.0"
|
|
47
|
-
}
|
|
26
|
+
"scripts": {},
|
|
27
|
+
"author": "",
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"gitHead": "af2792a9190705d4040f24ad3bf67420998960fd"
|
|
48
30
|
}
|