diff --git a/jest.config.js b/jest.config.js index 428d381c6b..b783ec509d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,7 +13,7 @@ module.exports = { // Transform ES modules from these packages transformIgnorePatterns: [ - 'node_modules/(?!(@mui|@emotion|@testing-library|@dnd-kit|@hello-pangea|@tiptap|konva|react-konva|d3-.*|internmap|@mapbox/point-geometry)(/|$))', + 'node_modules/(?!(@mui|@emotion|@testing-library|@dnd-kit|@hello-pangea|@tiptap|lodash-es|konva|react-konva|d3-.*|internmap|@mapbox/point-geometry)(/|$))', ], // Custom resolver to handle node: protocol imports diff --git a/old-packages/graph-lines/configure/src/index.js b/old-packages/graph-lines/configure/src/index.js index 5f58fc1bf7..8c4949fd31 100644 --- a/old-packages/graph-lines/configure/src/index.js +++ b/old-packages/graph-lines/configure/src/index.js @@ -11,7 +11,7 @@ import { import debug from 'debug'; import defaultValues from './defaults'; -import defaults from 'lodash/defaults'; +import { defaults } from 'lodash-es'; const log = debug('pie-elements:graph-lines:configure'); diff --git a/old-packages/graph-lines/controller/src/index.js b/old-packages/graph-lines/controller/src/index.js index 992c0a0856..55e85bd2c0 100644 --- a/old-packages/graph-lines/controller/src/index.js +++ b/old-packages/graph-lines/controller/src/index.js @@ -1,7 +1,7 @@ import debug from 'debug'; import { getFeedbackForCorrectness } from '@pie-lib/feedback'; import { lineUtils as utils } from '@pie-lib/charting'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; const log = debug('@pie-element:graph-lines:controller'); diff --git a/old-packages/inline-choice/configure/package.json b/old-packages/inline-choice/configure/package.json index 4ff30c2c18..43d580db33 100644 --- a/old-packages/inline-choice/configure/package.json +++ b/old-packages/inline-choice/configure/package.json @@ -14,7 +14,7 @@ "@pie-lib/config-ui": "11.36.0-mui-update.0", "@pie-lib/scoring-config": "3.33.0-mui-update.0", "debug": "^3.1.0", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "^16.8.1", "react-dom": "^16.8.1" diff --git a/old-packages/inline-choice/configure/src/root.jsx b/old-packages/inline-choice/configure/src/root.jsx index 135a553d9b..d642ca6906 100755 --- a/old-packages/inline-choice/configure/src/root.jsx +++ b/old-packages/inline-choice/configure/src/root.jsx @@ -1,8 +1,7 @@ import React from 'react'; import Main from './main'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep, max } from 'lodash-es'; import PropTypes from 'prop-types'; -import max from 'lodash/max'; export default class Root extends React.Component { static propTypes = { diff --git a/old-packages/inline-choice/controller/src/index.js b/old-packages/inline-choice/controller/src/index.js index 6ca63abf11..0a07bf6eea 100644 --- a/old-packages/inline-choice/controller/src/index.js +++ b/old-packages/inline-choice/controller/src/index.js @@ -1,5 +1,5 @@ import debug from 'debug'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import defaults from './defaults'; diff --git a/old-packages/point-intercept/controller/src/index.js b/old-packages/point-intercept/controller/src/index.js index 756c7b7028..79077f14c3 100644 --- a/old-packages/point-intercept/controller/src/index.js +++ b/old-packages/point-intercept/controller/src/index.js @@ -1,4 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { getFeedbackForCorrectness } from '@pie-lib/feedback'; const getResponseCorrectness = (correctResponseWithLabels, points, graph, partialScores) => { diff --git a/old-packages/text-entry/configure/src/__test__/feedback-mapper.test.js b/old-packages/text-entry/configure/src/__test__/feedback-mapper.test.js index 84424abaf3..9b1063579d 100644 --- a/old-packages/text-entry/configure/src/__test__/feedback-mapper.test.js +++ b/old-packages/text-entry/configure/src/__test__/feedback-mapper.test.js @@ -1,5 +1,4 @@ import * as feedbackMapper from '../feedback-mapper'; -import _ from 'lodash'; describe('feedback-mapper', () => { describe('modelToFeedbackConfig', () => { diff --git a/old-packages/text-entry/configure/src/model-config.jsx b/old-packages/text-entry/configure/src/model-config.jsx index f004981818..e1a78e2da9 100644 --- a/old-packages/text-entry/configure/src/model-config.jsx +++ b/old-packages/text-entry/configure/src/model-config.jsx @@ -3,7 +3,7 @@ import Typography from '@material-ui/core/Typography'; import { NChoice, InputCheckbox } from '@pie-lib/config-ui'; import TextField from '@material-ui/core/TextField'; import { withStyles } from '@material-ui/core/styles'; -import range from 'lodash/range'; +import { range } from 'lodash-es'; import Box from './box'; import PropTypes from 'prop-types'; diff --git a/old-packages/text-entry/controller/src/index.js b/old-packages/text-entry/controller/src/index.js index c7ea2f1a28..90b683a501 100644 --- a/old-packages/text-entry/controller/src/index.js +++ b/old-packages/text-entry/controller/src/index.js @@ -1,4 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { getFeedbackForCorrectness } from '@pie-lib/feedback'; const process = (v, ignoreCase, ignoreWhitespace) => { diff --git a/packages/boilerplate-item-type/configure/package.json b/packages/boilerplate-item-type/configure/package.json index 3c01a360e4..588e5b78b7 100644 --- a/packages/boilerplate-item-type/configure/package.json +++ b/packages/boilerplate-item-type/configure/package.json @@ -15,7 +15,7 @@ "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "@pie-lib/render-ui": "5.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.6.2", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/boilerplate-item-type/configure/src/__tests__/design.test.jsx b/packages/boilerplate-item-type/configure/src/__tests__/design.test.jsx index 3077c3770a..50f64ffe19 100644 --- a/packages/boilerplate-item-type/configure/src/__tests__/design.test.jsx +++ b/packages/boilerplate-item-type/configure/src/__tests__/design.test.jsx @@ -15,7 +15,10 @@ jest.mock('@pie-lib/config-ui', () => ({ }, })); -jest.mock('lodash/debounce', () => (fn) => fn); +jest.mock('lodash-es', () => ({ + debounce: jest.fn((fn) => fn), + cloneDeep: jest.fn((value) => JSON.parse(JSON.stringify(value))), +})); const theme = createTheme(); @@ -43,7 +46,7 @@ describe('design', () => { onModelChanged={onChange} onConfigurationChanged={onChangeConfig} /> - + , ); }; diff --git a/packages/boilerplate-item-type/configure/src/design.jsx b/packages/boilerplate-item-type/configure/src/design.jsx index 4e01743a3b..24e28f0bbe 100644 --- a/packages/boilerplate-item-type/configure/src/design.jsx +++ b/packages/boilerplate-item-type/configure/src/design.jsx @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import { settings, layout } from '@pie-lib/config-ui'; import { InputContainer } from '@pie-lib/render-ui' import EditableHtml from '@pie-lib/editable-html-tip-tap'; diff --git a/packages/boilerplate-item-type/controller/package.json b/packages/boilerplate-item-type/controller/package.json index 58250e0eae..b220501bba 100644 --- a/packages/boilerplate-item-type/controller/package.json +++ b/packages/boilerplate-item-type/controller/package.json @@ -7,11 +7,9 @@ "module": "src/index.js", "dependencies": { "debug": "^4.1.1", - "lodash": "^4.17.15" - }, - "devDependencies": { - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" }, + "devDependencies": {}, "author": "", "license": "ISC" } diff --git a/packages/boilerplate-item-type/controller/src/index.js b/packages/boilerplate-item-type/controller/src/index.js index a613cdc550..d1493925e6 100644 --- a/packages/boilerplate-item-type/controller/src/index.js +++ b/packages/boilerplate-item-type/controller/src/index.js @@ -1,4 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import defaults from './defaults'; export const getCorrectness = (model) => { diff --git a/packages/boilerplate-item-type/src/print.js b/packages/boilerplate-item-type/src/print.js index 61b9059296..6d9a736744 100644 --- a/packages/boilerplate-item-type/src/print.js +++ b/packages/boilerplate-item-type/src/print.js @@ -1,6 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import Main from './main'; import { renderMath } from '@pie-lib/math-rendering'; import debug from 'debug'; diff --git a/packages/categorize/configure/package.json b/packages/categorize/configure/package.json index 47b65a97e9..e5fc2e0391 100644 --- a/packages/categorize/configure/package.json +++ b/packages/categorize/configure/package.json @@ -23,7 +23,7 @@ "@pie-lib/render-ui": "5.1.1-next.0", "@pie-lib/translator": "3.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.6.2", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/categorize/configure/src/design/builder.js b/packages/categorize/configure/src/design/builder.js index 680a4c5f81..de4c0a6e6a 100644 --- a/packages/categorize/configure/src/design/builder.js +++ b/packages/categorize/configure/src/design/builder.js @@ -1,4 +1,4 @@ -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; export const buildCategories = (categories, choices, correctResponse) => { const clonedCategories = cloneDeep(categories); diff --git a/packages/categorize/controller/package.json b/packages/categorize/controller/package.json index b210cef20b..b1945f59c1 100644 --- a/packages/categorize/controller/package.json +++ b/packages/categorize/controller/package.json @@ -6,7 +6,7 @@ "@pie-lib/controller-utils": "1.1.1-next.0", "@pie-lib/feedback": "1.1.1-next.0", "@pie-lib/translator": "3.1.1-next.0", - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" }, "version": "9.0.0-beta.1", "description": "", diff --git a/packages/categorize/controller/src/index.js b/packages/categorize/controller/src/index.js index 644720b93d..6fed8c5700 100644 --- a/packages/categorize/controller/src/index.js +++ b/packages/categorize/controller/src/index.js @@ -1,4 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { buildState, score } from '@pie-lib/categorize'; import { getFeedbackForCorrectness } from '@pie-lib/feedback'; import { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils'; diff --git a/packages/categorize/package.json b/packages/categorize/package.json index f6a6571e2b..2b7b41e5c1 100644 --- a/packages/categorize/package.json +++ b/packages/categorize/package.json @@ -23,7 +23,7 @@ "@pie-lib/render-ui": "5.1.1-next.0", "@pie-lib/translator": "3.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.6.1", "react": "18.3.1", "react-dom": "18.3.1" diff --git a/packages/charting/configure/src/__tests__/correctResponse.test.js b/packages/charting/configure/src/__tests__/correctResponse.test.js index a4e01ba92f..296318bf2a 100644 --- a/packages/charting/configure/src/__tests__/correctResponse.test.js +++ b/packages/charting/configure/src/__tests__/correctResponse.test.js @@ -1,6 +1,6 @@ import React from 'react'; import { getUpdatedCategories } from '../correct-response'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; jest.mock('@pie-lib/charting', () => ({ Chart: (props) =>
{props.children}
, diff --git a/packages/charting/configure/src/correct-response.jsx b/packages/charting/configure/src/correct-response.jsx index 5179e1cf40..024b307db7 100644 --- a/packages/charting/configure/src/correct-response.jsx +++ b/packages/charting/configure/src/correct-response.jsx @@ -2,8 +2,7 @@ import * as React from 'react'; import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; import { Chart } from '@pie-lib/charting'; -import isEqual from 'lodash/isEqual'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep, isEqual } from 'lodash-es'; import Typography from '@mui/material/Typography'; @@ -205,7 +204,7 @@ export class CorrectResponse extends React.Component { Use the tools below to define the correct answer. - {(identicalError || categoriesError) ? ( + {identicalError || categoriesError ? ( export const setCorrectness = (answers, partialScoring) => answers ? answers.map((answer) => ({ - ...answer, - correctness: { - value: partialScoring ? 'incorrect' : 'correct', - label: partialScoring ? 'incorrect' : 'correct', - }, - })) + ...answer, + correctness: { + value: partialScoring ? 'incorrect' : 'correct', + label: partialScoring ? 'incorrect' : 'correct', + }, + })) : []; export const normalize = (question) => ({ ...defaults, ...question }); diff --git a/packages/charting/package.json b/packages/charting/package.json index 82c25ce87f..9e0613e5b3 100644 --- a/packages/charting/package.json +++ b/packages/charting/package.json @@ -20,7 +20,7 @@ "@pie-lib/math-rendering": "4.1.1-next.0", "@pie-lib/render-ui": "5.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "react": "18.3.1", "react-dom": "18.3.1" }, diff --git a/packages/charting/src/__tests__/main.test.js b/packages/charting/src/__tests__/main.test.js index a1b38d0b1e..ad469ede27 100644 --- a/packages/charting/src/__tests__/main.test.js +++ b/packages/charting/src/__tests__/main.test.js @@ -3,9 +3,9 @@ import { render } from '@testing-library/react'; import { ThemeProvider, createTheme } from '@mui/material/styles'; import { Main } from '../main'; -jest.mock('lodash/uniq', () => { - return () => []; -}); +jest.mock('lodash-es', () => ({ + uniq: jest.fn(() => []), +})); jest.mock('@pie-lib/charting', () => ({ Chart: (props) =>
{props.children}
, @@ -74,7 +74,7 @@ describe('Main', () => { return render(
- + , ); }; diff --git a/packages/charting/src/main.jsx b/packages/charting/src/main.jsx index da5352aa3d..219d4c9265 100644 --- a/packages/charting/src/main.jsx +++ b/packages/charting/src/main.jsx @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; import { color, Collapsible, hasText, PreviewPrompt, UiLayout, hasMedia } from '@pie-lib/render-ui'; import { Chart, chartTypes, KeyLegend } from '@pie-lib/charting'; -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'lodash-es'; import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle'; const StyledUiLayout = styled(UiLayout)({ diff --git a/packages/complex-rubric/configure/package.json b/packages/complex-rubric/configure/package.json index 8614cfe6bc..bc69045b62 100644 --- a/packages/complex-rubric/configure/package.json +++ b/packages/complex-rubric/configure/package.json @@ -18,7 +18,7 @@ "@pie-lib/render-ui": "5.1.1-next.0", "@pie-lib/rubric": "1.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.6.2", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/complex-rubric/configure/src/index.js b/packages/complex-rubric/configure/src/index.js index 313fe58dc8..99b9a18042 100644 --- a/packages/complex-rubric/configure/src/index.js +++ b/packages/complex-rubric/configure/src/index.js @@ -4,7 +4,7 @@ import { createRoot } from 'react-dom/client'; import RubricConfigure from '@pie-element/rubric/configure/lib'; import MultiTraitRubricConfigure from '@pie-element/multi-trait-rubric/configure/lib'; import debug from 'debug'; -import defaults from 'lodash/defaults'; +import { defaults } from 'lodash-es'; import Main from './main'; import sensibleDefaults from './defaults'; diff --git a/packages/complex-rubric/controller/package.json b/packages/complex-rubric/controller/package.json index ed6586a0b5..d1b16957be 100644 --- a/packages/complex-rubric/controller/package.json +++ b/packages/complex-rubric/controller/package.json @@ -7,7 +7,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" }, "author": "", "license": "ISC", diff --git a/packages/complex-rubric/package.json b/packages/complex-rubric/package.json index 867dfdda29..017548adce 100644 --- a/packages/complex-rubric/package.json +++ b/packages/complex-rubric/package.json @@ -16,7 +16,7 @@ "@pie-lib/rubric": "1.1.1-next.0", "classnames": "^2.2.5", "debug": "^4.1.1", - "lodash": "^4.17.11", + "lodash-es": "^4.17.23", "prop-types": "^15.7.2" }, "gitHead": "a15dd0ea81626703eb753bc0ab4c81bb2a96d58d", diff --git a/packages/drag-in-the-blank/configure/package.json b/packages/drag-in-the-blank/configure/package.json index e743fc062b..933d45b7c7 100644 --- a/packages/drag-in-the-blank/configure/package.json +++ b/packages/drag-in-the-blank/configure/package.json @@ -17,7 +17,7 @@ "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "@pie-lib/math-rendering": "4.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.6.2", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/drag-in-the-blank/configure/src/index.js b/packages/drag-in-the-blank/configure/src/index.js index 62d764f202..aa6d009bce 100644 --- a/packages/drag-in-the-blank/configure/src/index.js +++ b/packages/drag-in-the-blank/configure/src/index.js @@ -11,7 +11,7 @@ import { createRoot } from 'react-dom/client'; import { renderMath } from '@pie-lib/math-rendering'; import Main from './main'; import debug from 'debug'; -import defaults from 'lodash/defaults'; +import { defaults } from 'lodash-es'; import sensibleDefaults from './defaults'; import { processMarkup, createSlateMarkup } from './markupUtils'; diff --git a/packages/drag-in-the-blank/configure/src/markupUtils.js b/packages/drag-in-the-blank/configure/src/markupUtils.js index 0cd6714d05..d5634750a4 100644 --- a/packages/drag-in-the-blank/configure/src/markupUtils.js +++ b/packages/drag-in-the-blank/configure/src/markupUtils.js @@ -1,4 +1,4 @@ -import escape from 'lodash/escape'; +import { escape } from 'lodash-es'; export const createElementFromHTML = (htmlString) => { const div = document.createElement('div'); diff --git a/packages/drag-in-the-blank/controller/package.json b/packages/drag-in-the-blank/controller/package.json index fe0147a161..2c3e3ce580 100644 --- a/packages/drag-in-the-blank/controller/package.json +++ b/packages/drag-in-the-blank/controller/package.json @@ -10,7 +10,7 @@ "dependencies": { "@pie-lib/controller-utils": "1.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "type-of": "^2.0.1" } } diff --git a/packages/drag-in-the-blank/controller/src/index.js b/packages/drag-in-the-blank/controller/src/index.js index 0e65f8ef31..9585b6937f 100644 --- a/packages/drag-in-the-blank/controller/src/index.js +++ b/packages/drag-in-the-blank/controller/src/index.js @@ -1,4 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { getAllCorrectResponses, choiceIsEmpty } from './utils'; import { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils'; import defaults from './defaults'; diff --git a/packages/drag-in-the-blank/controller/src/utils.js b/packages/drag-in-the-blank/controller/src/utils.js index 7a1a6638a2..2c728bb0e1 100644 --- a/packages/drag-in-the-blank/controller/src/utils.js +++ b/packages/drag-in-the-blank/controller/src/utils.js @@ -1,5 +1,4 @@ -import cloneDeep from 'lodash/cloneDeep'; -import reduce from 'lodash/reduce'; +import { cloneDeep, reduce } from 'lodash-es'; const replaceHtmlRegex = /<(?!img)[^>]*>?/gm; diff --git a/packages/drag-in-the-blank/package.json b/packages/drag-in-the-blank/package.json index 96bb4f5092..cc8661553e 100644 --- a/packages/drag-in-the-blank/package.json +++ b/packages/drag-in-the-blank/package.json @@ -20,7 +20,7 @@ "@pie-lib/mask-markup": "2.1.1-next.1", "@pie-lib/math-rendering": "4.1.1-next.0", "@pie-lib/render-ui": "5.1.1-next.0", - "lodash": "^4.17.10", + "lodash-es": "^4.17.23", "prop-types": "^15.6.1", "react": "18.3.1", "react-dom": "18.3.1" diff --git a/packages/drawing-response/configure/package.json b/packages/drawing-response/configure/package.json index 03f8c2ab5c..931bf13e82 100644 --- a/packages/drawing-response/configure/package.json +++ b/packages/drawing-response/configure/package.json @@ -15,7 +15,7 @@ "@pie-lib/config-ui": "12.1.1-next.1", "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.7.2", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/drawing-response/configure/src/root.jsx b/packages/drawing-response/configure/src/root.jsx index aff9fdd948..38d824ef0e 100644 --- a/packages/drawing-response/configure/src/root.jsx +++ b/packages/drawing-response/configure/src/root.jsx @@ -6,7 +6,7 @@ import Typography from '@mui/material/Typography'; import { styled } from '@mui/material/styles'; import ImageContainer from './image-container'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; const { Panel, toggle, dropdown } = settings; diff --git a/packages/drawing-response/package.json b/packages/drawing-response/package.json index 50cfbf93f2..84ea9463f9 100644 --- a/packages/drawing-response/package.json +++ b/packages/drawing-response/package.json @@ -18,7 +18,7 @@ "@pie-lib/render-ui": "5.1.1-next.0", "@pie-lib/translator": "3.1.1-next.0", "konva": "8.3.0", - "lodash": "^4.17.11", + "lodash-es": "^4.17.23", "prop-types": "^15.6.1", "react": "18.3.1", "react-dom": "18.3.1", diff --git a/packages/drawing-response/src/drawing-response/__tests__/drawing-main.test.jsx b/packages/drawing-response/src/drawing-response/__tests__/drawing-main.test.jsx index f0b46050ee..adf66d080c 100644 --- a/packages/drawing-response/src/drawing-response/__tests__/drawing-main.test.jsx +++ b/packages/drawing-response/src/drawing-response/__tests__/drawing-main.test.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import { ThemeProvider, createTheme } from '@mui/material/styles'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import FreePathDrawable from '../drawable-free-path'; import LineDrawable from '../drawable-line'; import RectangleDrawable from '../drawable-rectangle'; diff --git a/packages/drawing-response/src/drawing-response/drawable-main.jsx b/packages/drawing-response/src/drawing-response/drawable-main.jsx index 814b5c26d0..f8756fc6ee 100644 --- a/packages/drawing-response/src/drawing-response/drawable-main.jsx +++ b/packages/drawing-response/src/drawing-response/drawable-main.jsx @@ -1,8 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import omit from 'lodash/omit'; -import cloneDeep from 'lodash/cloneDeep'; -import isEqual from 'lodash/isEqual'; +import { cloneDeep, isEqual, omit } from 'lodash-es'; import { Layer, Stage } from 'react-konva'; import { styled } from '@mui/material/styles'; import Translator from '@pie-lib/translator'; diff --git a/packages/drawing-response/src/index.js b/packages/drawing-response/src/index.js index 73e4f2fed2..866fade5fd 100644 --- a/packages/drawing-response/src/index.js +++ b/packages/drawing-response/src/index.js @@ -1,6 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { renderMath } from '@pie-lib/math-rendering'; import { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events'; diff --git a/packages/ebsr/configure/package.json b/packages/ebsr/configure/package.json index 2dd96e2833..6af29edd0f 100644 --- a/packages/ebsr/configure/package.json +++ b/packages/ebsr/configure/package.json @@ -14,7 +14,7 @@ "@pie-element/multiple-choice": "^12.0.0-beta.1", "@pie-framework/pie-configure-events": "^1.2.0", "@pie-lib/config-ui": "12.1.1-next.1", - "lodash": "^4.17.23", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/ebsr/configure/src/defaults.js b/packages/ebsr/configure/src/defaults.js index aafefc44df..63b00f76a8 100644 --- a/packages/ebsr/configure/src/defaults.js +++ b/packages/ebsr/configure/src/defaults.js @@ -1,4 +1,4 @@ -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; const defaultConfig = { addChoiceButton: { diff --git a/packages/ebsr/configure/src/index.js b/packages/ebsr/configure/src/index.js index 8be83b0758..394a06fc3e 100644 --- a/packages/ebsr/configure/src/index.js +++ b/packages/ebsr/configure/src/index.js @@ -2,7 +2,7 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import { ModelUpdatedEvent } from '@pie-framework/pie-configure-events'; import MultipleChoiceConfigure from '@pie-element/multiple-choice/configure/lib'; -import defaults from 'lodash/defaults'; +import { defaults } from 'lodash-es'; import Main from './main'; import sensibleDefaults from './defaults'; @@ -104,7 +104,7 @@ export default class EbsrConfigure extends HTMLElement { // check if the language is already included in the languageChoices.options array // and if not, then add it. - if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) { + if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) { this._configuration.languageChoices.options.push({ value: this._model.language, label: this._model.language, diff --git a/packages/ebsr/controller/package.json b/packages/ebsr/controller/package.json index 484a53fb18..6bafbd11eb 100644 --- a/packages/ebsr/controller/package.json +++ b/packages/ebsr/controller/package.json @@ -9,7 +9,7 @@ "dependencies": { "@pie-lib/controller-utils": "1.1.1-next.0", "@pie-lib/translator": "3.1.1-next.0", - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" }, "author": "", "license": "ISC", diff --git a/packages/ebsr/controller/src/index.js b/packages/ebsr/controller/src/index.js index 01164ebb94..c3f8e2139f 100644 --- a/packages/ebsr/controller/src/index.js +++ b/packages/ebsr/controller/src/index.js @@ -1,8 +1,7 @@ import defaults from './defaults'; import { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils'; import { isResponseCorrect } from './utils'; -import get from 'lodash/get'; -import isEmpty from 'lodash/isEmpty'; +import { get, isEmpty } from 'lodash-es'; import Translator from '@pie-lib/translator'; const { translator } = Translator; diff --git a/packages/ebsr/controller/src/utils.js b/packages/ebsr/controller/src/utils.js index e6c60bdc27..da0b8f621c 100644 --- a/packages/ebsr/controller/src/utils.js +++ b/packages/ebsr/controller/src/utils.js @@ -1,4 +1,4 @@ -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'lodash-es'; export const getCorrectResponse = (choices) => choices && diff --git a/packages/ebsr/package.json b/packages/ebsr/package.json index e373c698c3..a82e233402 100644 --- a/packages/ebsr/package.json +++ b/packages/ebsr/package.json @@ -12,7 +12,7 @@ "@pie-lib/translator": "3.1.1-next.0", "classnames": "^2.2.5", "debug": "^4.1.1", - "lodash": "^4.17.23" + "lodash-es": "^4.17.23" }, "author": "pie framework developers", "license": "ISC", diff --git a/packages/ebsr/src/index.js b/packages/ebsr/src/index.js index e413aecf08..4e8aa2e31a 100644 --- a/packages/ebsr/src/index.js +++ b/packages/ebsr/src/index.js @@ -1,6 +1,6 @@ import { SessionChangedEvent } from '@pie-framework/pie-player-events'; import MultipleChoice from '@pie-element/multiple-choice'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import debug from 'debug'; const SESSION_CHANGED = SessionChangedEvent.TYPE; diff --git a/packages/ebsr/src/print.js b/packages/ebsr/src/print.js index c72b216f60..5c96e45230 100644 --- a/packages/ebsr/src/print.js +++ b/packages/ebsr/src/print.js @@ -1,7 +1,6 @@ -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep, get } from 'lodash-es'; import MultipleChoice from '@pie-element/multiple-choice'; import debug from 'debug'; -import get from 'lodash/get'; import { SessionChangedEvent } from '@pie-framework/pie-player-events'; const MC_TAG_NAME = 'ebsr-multiple-choice'; const SESSION_CHANGED = SessionChangedEvent.TYPE; @@ -117,29 +116,29 @@ export default class Ebsr extends HTMLElement { setPartModel(part, key) { if (this._model && this._model[key] && part) { let labels = { - 'partA': undefined, - 'partB': undefined + partA: undefined, + partB: undefined, }; if (this._model.partLabels) { const language = this._model.language; labels = { - 'partA': translator.t('ebsr.part', { + partA: translator.t('ebsr.part', { lng: language, - index: this._model.partLabelType === 'Letters' ? 'A' : '1' + index: this._model.partLabelType === 'Letters' ? 'A' : '1', }), - 'partB': translator.t('ebsr.part', { + partB: translator.t('ebsr.part', { lng: language, - index: this._model.partLabelType === 'Letters' ? 'B' : '2' - }) + index: this._model.partLabelType === 'Letters' ? 'B' : '2', + }), }; } part.model = { ...preparePrintModel(this._model[key], this._options), keyMode: this._model[key].choicePrefix, - partLabel: labels[key] + partLabel: labels[key], }; // pass options to enable print mode detection in multiple-choice component diff --git a/packages/explicit-constructed-response/configure/package.json b/packages/explicit-constructed-response/configure/package.json index 48643b6dd0..515bb577ba 100644 --- a/packages/explicit-constructed-response/configure/package.json +++ b/packages/explicit-constructed-response/configure/package.json @@ -14,7 +14,7 @@ "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "classnames": "^2.2.6", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.6.2", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/explicit-constructed-response/configure/src/alternateResponses.jsx b/packages/explicit-constructed-response/configure/src/alternateResponses.jsx index b801991f62..c1510f1589 100644 --- a/packages/explicit-constructed-response/configure/src/alternateResponses.jsx +++ b/packages/explicit-constructed-response/configure/src/alternateResponses.jsx @@ -1,9 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import isEqual from 'lodash/isEqual'; -import map from 'lodash/map'; -import reduce from 'lodash/reduce'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep, isEqual, map, reduce } from 'lodash-es'; import AlternateSection from './alternateSection'; @@ -15,7 +12,7 @@ export class AlternateResponses extends React.Component { onLengthChange: PropTypes.func.isRequired, maxLengthPerChoiceEnabled: PropTypes.bool.isRequired, spellCheck: PropTypes.bool, - pluginProps: PropTypes.object + pluginProps: PropTypes.object, }; state = { maxLengthPerChoice: cloneDeep(this.props.model.maxLengthPerChoice) }; @@ -169,7 +166,7 @@ export class AlternateResponses extends React.Component { model: { maxLengthPerChoice, maxLengthPerChoiceEnabled }, spellCheck, choicesErrors, - pluginProps + pluginProps, } = this.props; return ( diff --git a/packages/explicit-constructed-response/configure/src/alternateSection.jsx b/packages/explicit-constructed-response/configure/src/alternateSection.jsx index aa8068e39d..cc8484bffa 100644 --- a/packages/explicit-constructed-response/configure/src/alternateSection.jsx +++ b/packages/explicit-constructed-response/configure/src/alternateSection.jsx @@ -1,7 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import debounce from 'lodash/debounce'; -import isEqual from 'lodash/isEqual'; +import { debounce, isEqual } from 'lodash-es'; import Button from '@mui/material/Button'; import Delete from '@mui/icons-material/Delete'; import IconButton from '@mui/material/IconButton'; @@ -9,7 +8,7 @@ import MenuItem from '@mui/material/MenuItem'; import Select from '@mui/material/Select'; import TextField from '@mui/material/TextField'; import { styled } from '@mui/material/styles'; -import max from 'lodash/max'; +import { max } from 'lodash-es'; import EditableHtml from '@pie-lib/editable-html-tip-tap'; import { stripHtmlTags, getAdjustedLength, decodeHTML } from './markupUtils'; @@ -142,10 +141,7 @@ export class Choice extends React.Component { }} {...inputProps} /> - + @@ -222,7 +218,7 @@ export class AlternateSection extends React.Component { const { choiceChanged, lengthChanged, maxLength, choices } = this.props; const labelLengthsArr = choices.map((choice) => decodeHTML(choice.label || '').length); - labelLengthsArr[index] = decodeHTML(value).length; + labelLengthsArr[index] = decodeHTML(value).length; const newLength = Math.max(...labelLengthsArr); @@ -279,7 +275,7 @@ export class AlternateSection extends React.Component { value={value || ''} readOnly={showMaxLength} MenuProps={{ - transitionDuration: { enter: 225, exit: 195 } + transitionDuration: { enter: 225, exit: 195 }, }} > diff --git a/packages/explicit-constructed-response/configure/src/index.js b/packages/explicit-constructed-response/configure/src/index.js index c265463d65..ef799cdf7b 100644 --- a/packages/explicit-constructed-response/configure/src/index.js +++ b/packages/explicit-constructed-response/configure/src/index.js @@ -1,8 +1,7 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import debug from 'debug'; -import defaults from 'lodash/defaults'; -import isArray from 'lodash/isArray'; +import { defaults, isArray } from 'lodash-es'; import { ModelUpdatedEvent, DeleteImageEvent, @@ -63,7 +62,8 @@ export default class ExplicitConstructedResponse extends HTMLElement { set model(s) { this._model = ExplicitConstructedResponse.prepareModel(s); if (this._model.responseAreaInputConfiguration) { - this._model.responseAreaInputConfiguration = this._configuration.responseAreaInputConfiguration?.inputConfiguration; + this._model.responseAreaInputConfiguration = + this._configuration.responseAreaInputConfiguration?.inputConfiguration; } this._render(); } @@ -88,7 +88,7 @@ export default class ExplicitConstructedResponse extends HTMLElement { // check if the language is already included in the languageChoices.options array // and if not, then add it. - if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) { + if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) { this._configuration.languageChoices.options.push({ value: this._model.language, label: this._model.language, @@ -125,13 +125,12 @@ export default class ExplicitConstructedResponse extends HTMLElement { this._model = { ...this._model, - responseAreaInputConfiguration: newInputConfig + responseAreaInputConfiguration: newInputConfig, }; this.onModelChanged(this._model); } - /** @param {done, progress, file} handler */ insertImage(handler) { this.dispatchEvent(new InsertImageEvent(handler)); diff --git a/packages/explicit-constructed-response/configure/src/main.jsx b/packages/explicit-constructed-response/configure/src/main.jsx index 2f2726d5ed..37658cd13c 100644 --- a/packages/explicit-constructed-response/configure/src/main.jsx +++ b/packages/explicit-constructed-response/configure/src/main.jsx @@ -1,9 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import cloneDeep from 'lodash/cloneDeep'; -import isEmpty from 'lodash/isEmpty'; -import pick from 'lodash/pick'; -import throttle from 'lodash/throttle'; +import { cloneDeep, isEmpty, pick, throttle } from 'lodash-es'; import EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html-tip-tap'; import { InputContainer, layout, settings } from '@pie-lib/config-ui'; import { styled } from '@mui/material/styles'; @@ -394,15 +391,8 @@ export class Main extends React.Component { )} - - Define Template, Choices, and Correct Responses - - + Define Template, Choices, and Correct Responses + diff --git a/packages/explicit-constructed-response/configure/src/markupUtils.js b/packages/explicit-constructed-response/configure/src/markupUtils.js index 1ad5423e9e..cf4a34d6f5 100644 --- a/packages/explicit-constructed-response/configure/src/markupUtils.js +++ b/packages/explicit-constructed-response/configure/src/markupUtils.js @@ -1,4 +1,4 @@ -import escape from 'lodash/escape'; +import { escape } from 'lodash-es'; // do not remove \t from \times, \triangle, \tan, \theta or \therefore const tSymbols = 'imes|riangle|an|heta|herefore'; @@ -76,4 +76,4 @@ export const stripHtmlTags = (markup) => { export const decodeHTML = (html) => { const doc = new DOMParser().parseFromString(html, 'text/html'); return doc.body.textContent || ''; -}; \ No newline at end of file +}; diff --git a/packages/explicit-constructed-response/controller/package.json b/packages/explicit-constructed-response/controller/package.json index 0b5c772aa3..1cbf7aa290 100644 --- a/packages/explicit-constructed-response/controller/package.json +++ b/packages/explicit-constructed-response/controller/package.json @@ -12,7 +12,7 @@ "@pie-lib/translator": "3.1.1-next.0", "debug": "^4.1.1", "he": "^1.2.0", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "type-of": "^2.0.1" } } diff --git a/packages/explicit-constructed-response/controller/src/index.js b/packages/explicit-constructed-response/controller/src/index.js index fc1bbb653d..9e33fe0e66 100644 --- a/packages/explicit-constructed-response/controller/src/index.js +++ b/packages/explicit-constructed-response/controller/src/index.js @@ -1,8 +1,5 @@ import debug from 'debug'; -import map from 'lodash/map'; -import reduce from 'lodash/reduce'; -import find from 'lodash/find'; -import isEmpty from 'lodash/isEmpty'; +import { find, isEmpty, map, reduce } from 'lodash-es'; import { decode } from 'he'; import { partialScoring } from '@pie-lib/controller-utils'; import Translator from '@pie-lib/translator'; @@ -69,7 +66,7 @@ const decodeHtmlEntities = (str) => { .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') - .replace(/'|'/g, '\'') + .replace(/'|'/g, "'") .replace(/&/g, '&'); }; @@ -82,107 +79,106 @@ export const normalize = (question) => ({ ...defaults, ...question }); * @param {*} env */ export async function model(question, session, env) { - // this was added to treat an exception, when the model has choices without - // the "value" property like: { label: 'test' } - if (question.choices) { - Object.keys(question.choices).forEach((key) => { - question.choices[key] = (question.choices[key] || []).map((item, index) => { - if (!item.value) { - log('Choice does not contain "value" property, which is required.', item); - return { value: `${index}`, ...item }; - } - - return item; - }); - }); - } + // this was added to treat an exception, when the model has choices without + // the "value" property like: { label: 'test' } + if (question.choices) { + Object.keys(question.choices).forEach((key) => { + question.choices[key] = (question.choices[key] || []).map((item, index) => { + if (!item.value) { + log('Choice does not contain "value" property, which is required.', item); + return { value: `${index}`, ...item }; + } - const normalizedQuestion = normalize(question); - const defaultFeedback = Object.assign( - { correct: 'Correct', incorrect: 'Incorrect' }, - normalizedQuestion.defaultFeedback, - ); - const prepareChoiceFn = prepareChoice(env.mode, defaultFeedback); - const choices = reduce( - normalizedQuestion.choices, - (obj, area, key) => { - obj[key] = map(area, prepareChoiceFn); - - return obj; - }, - {}, - ); - - const { value = {} } = session || {}; - const feedback = - env.mode === 'evaluate' - ? reduce( - normalizedQuestion.choices, - (obj, respArea, key) => { - const chosenValue = value && value[key]; - const val = - !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue)); - - obj[key] = getFeedback(val); - - return obj; - }, - {}, - ) - : {}; - - // check if at least one choice has an alternate - const showNote = Object.values(choices).some((choice) => choice?.length > 1); - const note = - normalizedQuestion.note || - translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language }); - - const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion; - const undefinedLengths = !maxLengthPerChoice.length; - - // calculate maxLengthPerChoice array if it is not defined or defined incorrectly - Object.values(choices).forEach((choice, index) => { - const labelLengthsArr = (choice || []).map((choice) => decodeHtmlEntities(choice.label || '').length); - const length = Math.max(...labelLengthsArr); - - if ( - undefinedLengths || - !maxLengthPerChoice[index] || - maxLengthPerChoice[index] < length || - maxLengthPerChoice[index] > length + 10 - ) { - maxLengthPerChoice[index] = getAdjustedLength(length); - } + return item; + }); }); + } + + const normalizedQuestion = normalize(question); + const defaultFeedback = Object.assign( + { correct: 'Correct', incorrect: 'Incorrect' }, + normalizedQuestion.defaultFeedback, + ); + const prepareChoiceFn = prepareChoice(env.mode, defaultFeedback); + const choices = reduce( + normalizedQuestion.choices, + (obj, area, key) => { + obj[key] = map(area, prepareChoiceFn); - const out = { - choices, - disabled: env.mode !== 'gather', - displayType: normalizedQuestion.displayType, - mode: env.mode, - role: env.role, - feedback, - language: normalizedQuestion.language, - markup: normalizedQuestion.markup, - maxLengthPerChoice, - maxLengthPerChoiceEnabled, - note, - playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled, - prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : defaults.prompt, - rationale: defaults.rationale, - responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined, - showNote, - teacherInstructions: defaults.teacherInstructions, - responseAreaInputConfiguration: normalizedQuestion.responseAreaInputConfiguration, - extraCSSRules: normalizedQuestion.extraCSSRules, - }; - - if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) { - out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : defaults.rationale; - out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled - ? normalizedQuestion.teacherInstructions - : defaults.teacherInstructions; + return obj; + }, + {}, + ); + + const { value = {} } = session || {}; + const feedback = + env.mode === 'evaluate' + ? reduce( + normalizedQuestion.choices, + (obj, respArea, key) => { + const chosenValue = value && value[key]; + const val = !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue)); + + obj[key] = getFeedback(val); + + return obj; + }, + {}, + ) + : {}; + + // check if at least one choice has an alternate + const showNote = Object.values(choices).some((choice) => choice?.length > 1); + const note = + normalizedQuestion.note || + translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language }); + + const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion; + const undefinedLengths = !maxLengthPerChoice.length; + + // calculate maxLengthPerChoice array if it is not defined or defined incorrectly + Object.values(choices).forEach((choice, index) => { + const labelLengthsArr = (choice || []).map((choice) => decodeHtmlEntities(choice.label || '').length); + const length = Math.max(...labelLengthsArr); + + if ( + undefinedLengths || + !maxLengthPerChoice[index] || + maxLengthPerChoice[index] < length || + maxLengthPerChoice[index] > length + 10 + ) { + maxLengthPerChoice[index] = getAdjustedLength(length); } + }); + + const out = { + choices, + disabled: env.mode !== 'gather', + displayType: normalizedQuestion.displayType, + mode: env.mode, + role: env.role, + feedback, + language: normalizedQuestion.language, + markup: normalizedQuestion.markup, + maxLengthPerChoice, + maxLengthPerChoiceEnabled, + note, + playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled, + prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : defaults.prompt, + rationale: defaults.rationale, + responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined, + showNote, + teacherInstructions: defaults.teacherInstructions, + responseAreaInputConfiguration: normalizedQuestion.responseAreaInputConfiguration, + extraCSSRules: normalizedQuestion.extraCSSRules, + }; + + if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) { + out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : defaults.rationale; + out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled + ? normalizedQuestion.teacherInstructions + : defaults.teacherInstructions; + } return out; } diff --git a/packages/explicit-constructed-response/package.json b/packages/explicit-constructed-response/package.json index 1ac69837d4..b90df9e3b7 100644 --- a/packages/explicit-constructed-response/package.json +++ b/packages/explicit-constructed-response/package.json @@ -22,7 +22,7 @@ "@pie-lib/translator": "3.1.1-next.0", "classnames": "^2.2.5", "he": "^1.2.0", - "lodash": "^4.17.10", + "lodash-es": "^4.17.23", "prop-types": "^15.6.1", "react": "18.3.1", "react-dom": "18.3.1" diff --git a/packages/explicit-constructed-response/src/main.jsx b/packages/explicit-constructed-response/src/main.jsx index 9cd9af7c20..8ecceb620e 100644 --- a/packages/explicit-constructed-response/src/main.jsx +++ b/packages/explicit-constructed-response/src/main.jsx @@ -1,8 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import debounce from 'lodash/debounce'; -import isEmpty from 'lodash/isEmpty'; -import isEqual from 'lodash/isEqual'; +import { isEmpty, isEqual, debounce } from 'lodash-es'; import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle'; import { ConstructedResponse } from '@pie-lib/mask-markup'; import { color, Collapsible, hasText, hasMedia, PreviewPrompt, UiLayout } from '@pie-lib/render-ui'; diff --git a/packages/explicit-constructed-response/src/print.js b/packages/explicit-constructed-response/src/print.js index 4b3e77b373..7aa21e3475 100644 --- a/packages/explicit-constructed-response/src/print.js +++ b/packages/explicit-constructed-response/src/print.js @@ -1,6 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import Main from './main'; import { renderMath } from '@pie-lib/math-rendering'; import debug from 'debug'; diff --git a/packages/extended-text-entry/configure/package.json b/packages/extended-text-entry/configure/package.json index 146c92dab1..b8a8299293 100644 --- a/packages/extended-text-entry/configure/package.json +++ b/packages/extended-text-entry/configure/package.json @@ -15,7 +15,7 @@ "@pie-framework/pie-configure-events": "^1.3.0", "@pie-lib/config-ui": "12.1.1-next.1", "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.6.2", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/extended-text-entry/controller/src/__tests__/index.test.js b/packages/extended-text-entry/controller/src/__tests__/index.test.js index 149488ba51..2772951b4e 100644 --- a/packages/extended-text-entry/controller/src/__tests__/index.test.js +++ b/packages/extended-text-entry/controller/src/__tests__/index.test.js @@ -1,5 +1,5 @@ import { model } from '../index'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import defaultValues from '../defaults'; diff --git a/packages/extended-text-entry/src/main.jsx b/packages/extended-text-entry/src/main.jsx index db660d565c..20632d84b8 100644 --- a/packages/extended-text-entry/src/main.jsx +++ b/packages/extended-text-entry/src/main.jsx @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import debug from 'debug'; import Typography from '@mui/material/Typography'; diff --git a/packages/extended-text-entry/src/print.js b/packages/extended-text-entry/src/print.js index 8953f2d66a..d1ba4ad20a 100644 --- a/packages/extended-text-entry/src/print.js +++ b/packages/extended-text-entry/src/print.js @@ -1,6 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import Main from './main'; import { renderMath } from '@pie-lib/math-rendering'; diff --git a/packages/fraction-model/configure/package.json b/packages/fraction-model/configure/package.json index 3198aeb92f..5800e8f922 100644 --- a/packages/fraction-model/configure/package.json +++ b/packages/fraction-model/configure/package.json @@ -14,7 +14,7 @@ "@pie-lib/config-ui": "12.1.1-next.1", "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/fraction-model/configure/src/__tests__/main.test.jsx b/packages/fraction-model/configure/src/__tests__/main.test.jsx index 569e107b99..8765748390 100644 --- a/packages/fraction-model/configure/src/__tests__/main.test.jsx +++ b/packages/fraction-model/configure/src/__tests__/main.test.jsx @@ -42,14 +42,21 @@ jest.mock('@pie-lib/editable-html-tip-tap', () => { const React = require('react'); return { __esModule: true, - default: ({ markup, onChange }) => React.createElement('div', { 'data-testid': 'editable-html', onClick: () => onChange && onChange('test') }, markup), + default: ({ markup, onChange }) => + React.createElement( + 'div', + { 'data-testid': 'editable-html', onClick: () => onChange && onChange('test') }, + markup, + ), ALL_PLUGINS: [], }; }); const theme = createTheme(); -jest.mock('lodash/debounce', () => (fn) => fn); +jest.mock('lodash-es', () => ({ + debounce: jest.fn((fn) => fn), +})); jest.spyOn(Math, 'random').mockReturnValue(0); @@ -93,7 +100,7 @@ describe('Main', () => { imageSupport={imageSupport} {...props} /> - + , ); }; diff --git a/packages/fraction-model/configure/src/__tests__/model-options.test.jsx b/packages/fraction-model/configure/src/__tests__/model-options.test.jsx index 7b4aed9e63..96e4c56489 100644 --- a/packages/fraction-model/configure/src/__tests__/model-options.test.jsx +++ b/packages/fraction-model/configure/src/__tests__/model-options.test.jsx @@ -47,7 +47,10 @@ jest.mock('../number-text-field', () => { const theme = createTheme(); -jest.mock('lodash/debounce', () => (fn) => fn); +jest.mock('lodash-es', () => ({ + debounce: jest.fn((fn) => fn), + cloneDeep: jest.fn((value) => JSON.parse(JSON.stringify(value))), +})); export const defaultProps = { model: { @@ -73,7 +76,7 @@ describe('Model Options', () => { return render( - + , ); }; diff --git a/packages/fraction-model/configure/src/model-options.jsx b/packages/fraction-model/configure/src/model-options.jsx index 676fb1fa7f..5a9173ca5f 100644 --- a/packages/fraction-model/configure/src/model-options.jsx +++ b/packages/fraction-model/configure/src/model-options.jsx @@ -6,7 +6,7 @@ import Select from '@mui/material/Select'; import MenuItem from '@mui/material/MenuItem'; import CardBar from './card-bar'; import { Checkbox } from '@pie-lib/config-ui'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; const GroupInline = styled('div')({ alignItems: 'center', diff --git a/packages/fraction-model/controller/package.json b/packages/fraction-model/controller/package.json index 7a1c6ac009..9731e99bd9 100644 --- a/packages/fraction-model/controller/package.json +++ b/packages/fraction-model/controller/package.json @@ -8,11 +8,9 @@ "dependencies": { "@pie-lib/text-select": "2.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15" - }, - "devDependencies": { - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" }, + "devDependencies": {}, "author": "", "license": "ISC" } diff --git a/packages/fraction-model/controller/src/index.js b/packages/fraction-model/controller/src/index.js index 9c0da3aae7..23d0021fec 100644 --- a/packages/fraction-model/controller/src/index.js +++ b/packages/fraction-model/controller/src/index.js @@ -1,4 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import defaults from './defaults'; /* diff --git a/packages/fraction-model/src/index.js b/packages/fraction-model/src/index.js index 5f0d5c9b71..8ac4b40c78 100644 --- a/packages/fraction-model/src/index.js +++ b/packages/fraction-model/src/index.js @@ -2,7 +2,7 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import { SessionChangedEvent } from '@pie-framework/pie-player-events'; import Main from './main'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import { renderMath } from '@pie-lib/math-rendering'; import FractionModelChart from './fraction-model-chart'; diff --git a/packages/fraction-model/src/main.jsx b/packages/fraction-model/src/main.jsx index b87c98943a..056d7eef83 100644 --- a/packages/fraction-model/src/main.jsx +++ b/packages/fraction-model/src/main.jsx @@ -6,7 +6,7 @@ import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle'; import FractionModelChart from './fraction-model-chart'; import { AlertDialog } from '@pie-lib/config-ui'; import { PreviewPrompt, UiLayout } from '@pie-lib/render-ui'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; const ModelPreview = styled('div')({ padding: '16px', diff --git a/packages/graphing-solution-set/configure/src/correct-response.jsx b/packages/graphing-solution-set/configure/src/correct-response.jsx index 89a7eb5df7..a4e6659fa9 100644 --- a/packages/graphing-solution-set/configure/src/correct-response.jsx +++ b/packages/graphing-solution-set/configure/src/correct-response.jsx @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; import { GraphContainer as Graph } from '@pie-lib/graphing-solution-set'; import { AlertDialog } from '@pie-lib/config-ui'; -import { set } from 'lodash'; +import { set } from 'lodash-es'; import { RadioGroup, Typography } from '@mui/material'; import Radio from '@mui/material/Radio'; import FormControlLabel from '@mui/material/FormControlLabel'; diff --git a/packages/graphing-solution-set/configure/src/graphing-config.jsx b/packages/graphing-solution-set/configure/src/graphing-config.jsx index 953ca9c5a9..07343ca469 100644 --- a/packages/graphing-solution-set/configure/src/graphing-config.jsx +++ b/packages/graphing-solution-set/configure/src/graphing-config.jsx @@ -5,7 +5,7 @@ import { AlertDialog } from '@pie-lib/config-ui'; import { MenuItem, Select, Typography, OutlinedInput } from '@mui/material'; import { styled } from '@mui/material/styles'; import { applyConstraints, filterPlotableMarks, getGridValues, getLabelValues } from './utils'; -import { isEqual, cloneDeep } from 'lodash'; +import { isEqual, cloneDeep } from 'lodash-es'; const Container = styled('div')(({ theme }) => ({ display: 'flex', diff --git a/packages/graphing-solution-set/configure/src/utils.js b/packages/graphing-solution-set/configure/src/utils.js index aff907e2e1..f67216a79f 100644 --- a/packages/graphing-solution-set/configure/src/utils.js +++ b/packages/graphing-solution-set/configure/src/utils.js @@ -1,4 +1,4 @@ -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'lodash-es'; /*Valid grid values*/ const VALID_GRID_VALUES = [ diff --git a/packages/graphing-solution-set/controller/src/index.js b/packages/graphing-solution-set/controller/src/index.js index f85ccd5cfe..d35b7489b7 100644 --- a/packages/graphing-solution-set/controller/src/index.js +++ b/packages/graphing-solution-set/controller/src/index.js @@ -1,7 +1,5 @@ import debug from 'debug'; -import cloneDeep from 'lodash/cloneDeep'; -import uniqWith from 'lodash/uniqWith'; -import isEmpty from 'lodash/isEmpty'; +import { cloneDeep, isEmpty, uniqWith } from 'lodash-es'; import defaults from './defaults'; import { equalMarks, sortedAnswers, removeInvalidAnswers } from './utils'; diff --git a/packages/graphing-solution-set/controller/src/utils.js b/packages/graphing-solution-set/controller/src/utils.js index 7abb0b704a..344146ec73 100644 --- a/packages/graphing-solution-set/controller/src/utils.js +++ b/packages/graphing-solution-set/controller/src/utils.js @@ -1,7 +1,4 @@ -import isEqual from 'lodash/isEqual'; -import lodash from 'lodash'; -import uniqWith from 'lodash/uniqWith'; -import differenceWith from 'lodash/differenceWith'; +import { isEqual, differenceWith, uniq, uniqWith } from 'lodash-es'; /* * Constant to check equal segments @@ -84,7 +81,7 @@ export const equalLine = (line1, line2) => { } else if (c1 !== c2) { return false; } - return lodash.uniq(proportions).length === 1 && line1.fill === line2.fill; + return uniq(proportions).length === 1 && line1.fill === line2.fill; // (y2 - y1)/(x2 - x1) = (y4 - y3)/(x4 - x3); // return ((Math.abs((line1.to.y - line1.from.y) / (line1.to.x - line1.from.x))) === (Math.abs((line2.to.y - line2.from.y) / (line2.to.x - line2.from.x)))); }; diff --git a/packages/graphing/configure/package.json b/packages/graphing/configure/package.json index 12cd399ea6..91689ad4b1 100644 --- a/packages/graphing/configure/package.json +++ b/packages/graphing/configure/package.json @@ -19,7 +19,7 @@ "classnames": "^2.2.5", "core-js": "^3.40.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/graphing/configure/src/configure.jsx b/packages/graphing/configure/src/configure.jsx index 34745d4fe2..a99e820a99 100644 --- a/packages/graphing/configure/src/configure.jsx +++ b/packages/graphing/configure/src/configure.jsx @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import debug from 'debug'; -import intersection from 'lodash/intersection'; +import { intersection } from 'lodash-es'; import { styled } from '@mui/material/styles'; import Typography from '@mui/material/Typography'; diff --git a/packages/graphing/configure/src/correct-response.jsx b/packages/graphing/configure/src/correct-response.jsx index fa28f82f1f..b586a4dbe1 100644 --- a/packages/graphing/configure/src/correct-response.jsx +++ b/packages/graphing/configure/src/correct-response.jsx @@ -6,7 +6,7 @@ import { GraphContainer as Graph } from '@pie-lib/graphing'; import { AlertDialog } from '@pie-lib/config-ui'; import { renderMath } from '@pie-lib/math-rendering'; import Delete from '@mui/icons-material/Delete'; -import { set, isEqual } from 'lodash'; +import { set, isEqual } from 'lodash-es'; import { MenuItem, Select, Tooltip, Typography } from '@mui/material'; import Info from '@mui/icons-material/Info'; diff --git a/packages/graphing/configure/src/graphing-config.jsx b/packages/graphing/configure/src/graphing-config.jsx index 614d801935..a384747eb8 100644 --- a/packages/graphing/configure/src/graphing-config.jsx +++ b/packages/graphing/configure/src/graphing-config.jsx @@ -5,7 +5,7 @@ import { AlertDialog } from '@pie-lib/config-ui'; import { MenuItem, Select, Typography, OutlinedInput } from '@mui/material'; import { styled } from '@mui/material/styles'; import { applyConstraints, filterPlotableMarks, getGridValues, getLabelValues } from './utils'; -import { isEqual } from 'lodash'; +import { isEqual } from 'lodash-es'; const Container = styled('div')(({ theme }) => ({ display: 'flex', diff --git a/packages/graphing/configure/src/index.js b/packages/graphing/configure/src/index.js index e54f60cac1..4580eefef7 100644 --- a/packages/graphing/configure/src/index.js +++ b/packages/graphing/configure/src/index.js @@ -11,7 +11,7 @@ import { import debug from 'debug'; import defaultValues from './defaults'; import { renderMath } from '@pie-lib/math-rendering'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; const log = debug('pie-elements:graphing:configure'); diff --git a/packages/graphing/configure/src/utils.js b/packages/graphing/configure/src/utils.js index 1b011891d3..ea6c3a3df4 100644 --- a/packages/graphing/configure/src/utils.js +++ b/packages/graphing/configure/src/utils.js @@ -1,4 +1,4 @@ -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'lodash-es'; const VALID_GRID_VALUES = [ 0.01, 0.02, 0.04, 0.05, 0.0625, 0.1, 0.125, 0.2, 0.25, 0.5, 1, 2, 3, 4, 5, 8, 10, 12, 15, 20, 40, 50, 64, 100, 500, diff --git a/packages/graphing/controller/src/index.js b/packages/graphing/controller/src/index.js index b785e39167..e655c59ae3 100644 --- a/packages/graphing/controller/src/index.js +++ b/packages/graphing/controller/src/index.js @@ -1,8 +1,6 @@ import debug from 'debug'; -import cloneDeep from 'lodash/cloneDeep'; -import uniqWith from 'lodash/uniqWith'; -import isEmpty from 'lodash/isEmpty'; +import { cloneDeep, isEmpty, uniqWith } from 'lodash-es'; import defaults from './defaults'; import { equalMarks, sortedAnswers } from './utils'; diff --git a/packages/graphing/controller/src/utils.js b/packages/graphing/controller/src/utils.js index 701e8b4862..b003f94a59 100644 --- a/packages/graphing/controller/src/utils.js +++ b/packages/graphing/controller/src/utils.js @@ -1,7 +1,4 @@ -import isEqual from 'lodash/isEqual'; -import lodash from 'lodash'; -import uniqWith from 'lodash/uniqWith'; -import differenceWith from 'lodash/differenceWith'; +import { differenceWith, isEqual, uniq, uniqWith } from 'lodash-es'; import { getAmplitudeAndFreq, pointsToABC, @@ -98,7 +95,7 @@ export const equalLine = (line1, line2) => { return false; } - return lodash.uniq(proportions).length === 1; + return uniq(proportions).length === 1; // (y2 - y1)/(x2 - x1) = (y4 - y3)/(x4 - x3); // return ((Math.abs((line1.to.y - line1.from.y) / (line1.to.x - line1.from.x))) === (Math.abs((line2.to.y - line2.from.y) / (line2.to.x - line2.from.x)))); diff --git a/packages/hotspot/configure/package.json b/packages/hotspot/configure/package.json index d965148838..67f98e9c6a 100644 --- a/packages/hotspot/configure/package.json +++ b/packages/hotspot/configure/package.json @@ -16,7 +16,7 @@ "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "debug": "^4.1.1", "konva": "8.3.0", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.7.2", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/packages/hotspot/configure/src/hotspot-drawable.jsx b/packages/hotspot/configure/src/hotspot-drawable.jsx index 4e049e497a..ec11849159 100644 --- a/packages/hotspot/configure/src/hotspot-drawable.jsx +++ b/packages/hotspot/configure/src/hotspot-drawable.jsx @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Layer, Stage } from 'react-konva'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import { styled } from '@mui/material/styles'; import Rectangle from './hotspot-rectangle'; diff --git a/packages/hotspot/configure/src/utils.js b/packages/hotspot/configure/src/utils.js index 42e74c7a50..dbbcb4e3a1 100644 --- a/packages/hotspot/configure/src/utils.js +++ b/packages/hotspot/configure/src/utils.js @@ -1,4 +1,4 @@ -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import { SHAPE_GROUPS } from './shapes'; const updateImageDimensions = (initialDim, nextDim, keepAspectRatio, resizeType) => { diff --git a/packages/hotspot/controller/package.json b/packages/hotspot/controller/package.json index 208203245f..d873566435 100644 --- a/packages/hotspot/controller/package.json +++ b/packages/hotspot/controller/package.json @@ -13,6 +13,6 @@ "dependencies": { "@pie-lib/controller-utils": "1.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" } } diff --git a/packages/hotspot/controller/src/index.js b/packages/hotspot/controller/src/index.js index 79cfa215a5..535f68561f 100644 --- a/packages/hotspot/controller/src/index.js +++ b/packages/hotspot/controller/src/index.js @@ -1,5 +1,5 @@ import debug from 'debug'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { partialScoring } from '@pie-lib/controller-utils'; import { isResponseCorrect } from './utils'; diff --git a/packages/hotspot/controller/src/utils.js b/packages/hotspot/controller/src/utils.js index 580afd7d22..c0d7c141c1 100644 --- a/packages/hotspot/controller/src/utils.js +++ b/packages/hotspot/controller/src/utils.js @@ -1,5 +1,4 @@ -import isEqual from 'lodash/isEqual'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty, isEqual } from 'lodash-es'; export const getCorrectResponse = (choices) => choices diff --git a/packages/image-cloze-association/controller/package.json b/packages/image-cloze-association/controller/package.json index 768c688f47..9035d4cab8 100644 --- a/packages/image-cloze-association/controller/package.json +++ b/packages/image-cloze-association/controller/package.json @@ -14,6 +14,6 @@ "@pie-lib/controller-utils": "1.1.1-next.0", "debug": "^4.1.1", "humps": "^2.0.1", - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" } } diff --git a/packages/image-cloze-association/controller/src/index.js b/packages/image-cloze-association/controller/src/index.js index afe562af32..5884010d48 100644 --- a/packages/image-cloze-association/controller/src/index.js +++ b/packages/image-cloze-association/controller/src/index.js @@ -1,7 +1,7 @@ import debug from 'debug'; import { camelizeKeys } from 'humps'; import { partialScoring } from '@pie-lib/controller-utils'; -import { cloneDeep, isEmpty, shuffle } from 'lodash'; +import { cloneDeep, isEmpty, shuffle } from 'lodash-es'; import defaults from './defaults'; import { getAllUniqueCorrectness, getCompleteResponseDetails } from './utils'; diff --git a/packages/image-cloze-association/src/root.jsx b/packages/image-cloze-association/src/root.jsx index a87652dd84..4a10a067f8 100644 --- a/packages/image-cloze-association/src/root.jsx +++ b/packages/image-cloze-association/src/root.jsx @@ -8,8 +8,7 @@ import { styled } from '@mui/material/styles'; import NotInterestedIcon from '@mui/icons-material/NotInterested'; import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle'; import Translator from '@pie-lib/translator'; -import groupBy from 'lodash/groupBy'; -import flatMap from 'lodash/flatMap'; +import { flatMap, groupBy } from 'lodash-es'; const { translator } = Translator; import Image from './image-container'; diff --git a/packages/inline-dropdown/configure/package.json b/packages/inline-dropdown/configure/package.json index b6f1d0a25b..acecd3b861 100644 --- a/packages/inline-dropdown/configure/package.json +++ b/packages/inline-dropdown/configure/package.json @@ -16,7 +16,7 @@ "@pie-lib/render-ui": "5.1.1-next.0", "classnames": "^2.2.6", "debug": "^4.1.1", - "lodash": "^4.17.23", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/inline-dropdown/configure/src/__tests__/main.test.jsx b/packages/inline-dropdown/configure/src/__tests__/main.test.jsx index 7532e6bb39..499d276e69 100644 --- a/packages/inline-dropdown/configure/src/__tests__/main.test.jsx +++ b/packages/inline-dropdown/configure/src/__tests__/main.test.jsx @@ -2,7 +2,7 @@ import { render } from '@testing-library/react'; import React from 'react'; import { Main } from '../main'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import sensibleDefaults from '../defaults'; import { createSlateMarkup, processMarkup } from '../markupUtils'; diff --git a/packages/inline-dropdown/configure/src/index.js b/packages/inline-dropdown/configure/src/index.js index 80ff6b0ef4..61c812bd96 100644 --- a/packages/inline-dropdown/configure/src/index.js +++ b/packages/inline-dropdown/configure/src/index.js @@ -10,7 +10,7 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import Main from './main'; import debug from 'debug'; -import defaults from 'lodash/defaults'; +import { defaults } from 'lodash-es'; import sensibleDefaults from './defaults'; import { processMarkup, createSlateMarkup } from './markupUtils'; diff --git a/packages/inline-dropdown/configure/src/inline-dropdown-toolbar.jsx b/packages/inline-dropdown/configure/src/inline-dropdown-toolbar.jsx index d1226c169c..76959fea73 100644 --- a/packages/inline-dropdown/configure/src/inline-dropdown-toolbar.jsx +++ b/packages/inline-dropdown/configure/src/inline-dropdown-toolbar.jsx @@ -5,8 +5,7 @@ import PropTypes from 'prop-types'; import EditableHtml from '@pie-lib/editable-html-tip-tap'; import { renderMath } from '@pie-lib/math-rendering'; import { styled } from '@mui/material/styles'; -import isEqual from 'lodash/isEqual'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty, isEqual } from 'lodash-es'; import { color } from '@pie-lib/render-ui'; import AddIcon from '@mui/icons-material/Add'; @@ -291,7 +290,6 @@ class RespAreaToolbar extends React.Component { }; onBlur = () => { - if (this.clickedInside) { this.clickedInside = false; return; diff --git a/packages/inline-dropdown/configure/src/main.jsx b/packages/inline-dropdown/configure/src/main.jsx index 5b1ba29733..d0f7437b7f 100644 --- a/packages/inline-dropdown/configure/src/main.jsx +++ b/packages/inline-dropdown/configure/src/main.jsx @@ -5,12 +5,7 @@ import EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html-tip-tap'; import { AlertDialog, InputContainer, layout, settings } from '@pie-lib/config-ui'; import { renderMath } from '@pie-lib/math-rendering'; import { color } from '@pie-lib/render-ui'; -import cloneDeep from 'lodash/cloneDeep'; -import isEqual from 'lodash/isEqual'; -import isUndefined from 'lodash/isUndefined'; -import isEmpty from 'lodash/isEmpty'; -import reduce from 'lodash/reduce'; -import max from 'lodash/max'; +import { cloneDeep, isEmpty, isEqual, isUndefined, max, reduce } from 'lodash-es'; import { styled } from '@mui/material/styles'; import Tooltip from '@mui/material/Tooltip'; import Typography from '@mui/material/Typography'; @@ -395,16 +390,16 @@ export class Main extends React.Component { }} /> - this.onChoiceRationaleChanged(key, { ...choice, rationale: c })} - imageSupport={imageSupport} - maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth} - maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight} - uploadSoundSupport={uploadSoundSupport} - mathMlOptions={mathMlOptions} - /> + this.onChoiceRationaleChanged(key, { ...choice, rationale: c })} + imageSupport={imageSupport} + maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth} + maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight} + uploadSoundSupport={uploadSoundSupport} + mathMlOptions={mathMlOptions} + /> ))} @@ -470,57 +465,50 @@ export class Main extends React.Component { > {teacherInstructionsEnabled && ( - - {teacherInstructionsError && {teacherInstructionsError}} + + {teacherInstructionsError && {teacherInstructionsError}} )} {promptEnabled && ( - - {promptError && {promptError}} + + {promptError && {promptError}} )} - - Define Template, Choices, and Correct Responses - - + Define Template, Choices, and Correct Responses + @@ -590,21 +578,21 @@ export class Main extends React.Component { {rationaleEnabled && ( - - {rationaleError && {rationaleError}} + + {rationaleError && {rationaleError}} )} diff --git a/packages/inline-dropdown/configure/src/markupUtils.js b/packages/inline-dropdown/configure/src/markupUtils.js index d5a650f715..7aeac72cc8 100644 --- a/packages/inline-dropdown/configure/src/markupUtils.js +++ b/packages/inline-dropdown/configure/src/markupUtils.js @@ -1,4 +1,4 @@ -import escape from 'lodash/escape'; +import { escape } from 'lodash-es'; // do not remove \t from \times, \triangle, \tan, \theta or \therefore const tSymbols = 'imes|riangle|an|heta|herefore'; diff --git a/packages/inline-dropdown/controller/package.json b/packages/inline-dropdown/controller/package.json index b22a933b60..26daf91c5a 100644 --- a/packages/inline-dropdown/controller/package.json +++ b/packages/inline-dropdown/controller/package.json @@ -10,7 +10,7 @@ "dependencies": { "@pie-lib/controller-utils": "1.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.23", + "lodash-es": "^4.17.23", "type-of": "^2.0.1" } } diff --git a/packages/inline-dropdown/controller/src/index.js b/packages/inline-dropdown/controller/src/index.js index 4c4c869eb0..c5b7c8ea5f 100644 --- a/packages/inline-dropdown/controller/src/index.js +++ b/packages/inline-dropdown/controller/src/index.js @@ -1,6 +1,4 @@ -import map from 'lodash/map'; -import reduce from 'lodash/reduce'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty, map, reduce } from 'lodash-es'; import { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils'; import defaults from './defaults'; @@ -24,136 +22,134 @@ export const normalize = (question) => ({ ...defaults, ...question }); * @param {*} updateSession - optional - a function that will set the properties passed into it on the session. */ export async function model(question, session, env, updateSession) { - const normalizedQuestion = normalize(question); - const { value = {} } = session || {}; - let choices = reduce( - normalizedQuestion.choices, - (obj, area, key) => { - obj[key] = map(area, (choice) => choice); - - return obj; - }, - {}, - ); - - let feedback = {}; + const normalizedQuestion = normalize(question); + const { value = {} } = session || {}; + let choices = reduce( + normalizedQuestion.choices, + (obj, area, key) => { + obj[key] = map(area, (choice) => choice); + + return obj; + }, + {}, + ); + + let feedback = {}; + + if (env.mode === 'evaluate') { + const allCorrectResponses = getAllCorrectResponses(normalizedQuestion); + const respAreaLength = Object.keys(allCorrectResponses).length; + let correctResponses = 0; + + for (let i = 0; i < respAreaLength; i++) { + const result = reduce( + allCorrectResponses, + (obj, choices, key) => { + const answer = (value && value[key]) || ''; + const correctChoice = choices[i] || ''; + const isCorrect = answer && correctChoice && correctChoice === answer; + + obj.feedback[key] = getFeedback(isCorrect); + + if (isCorrect) { + obj.correctResponses += 1; + } + + return obj; + }, + { correctResponses: 0, feedback: {} }, + ); + + if (result.correctResponses >= correctResponses) { + correctResponses = result.correctResponses; + feedback = result.feedback; + } - if (env.mode === 'evaluate') { - const allCorrectResponses = getAllCorrectResponses(normalizedQuestion); - const respAreaLength = Object.keys(allCorrectResponses).length; - let correctResponses = 0; + if (result.correctResponses === respAreaLength) { + break; + } + } + } - for (let i = 0; i < respAreaLength; i++) { - const result = reduce( - allCorrectResponses, - (obj, choices, key) => { - const answer = (value && value[key]) || ''; - const correctChoice = choices[i] || ''; - const isCorrect = answer && correctChoice && correctChoice === answer; + const lockChoiceOrder = lockChoices(normalizedQuestion, session, env); - obj.feedback[key] = getFeedback(isCorrect); + if (!lockChoiceOrder) { + const shuffledValues = {}; + const keys = Object.keys(choices); - if (isCorrect) { - obj.correctResponses += 1; - } + const us = (part) => (id, element, update) => { + return new Promise((resolve) => { + shuffledValues[part] = update.shuffledValues; + resolve(); + }); + }; - return obj; - }, - { correctResponses: 0, feedback: {} }, - ); + let i; - if (result.correctResponses >= correctResponses) { - correctResponses = result.correctResponses; - feedback = result.feedback; - } + for (i = 0; i < keys.length; i++) { + const key = keys[i]; + const storedValues = session?.shuffledValues?.[key]; - if (result.correctResponses === respAreaLength) { - break; - } - } + choices[key] = await getShuffledChoices( + choices[key], + // the shuffledValues structure was updated to an object like { choice_key: [] } + // and we need to override shuffledValues if it's not an array + { shuffledValues: Array.isArray(storedValues) ? storedValues : [] }, + us(key), + 'value', + ); } - const lockChoiceOrder = lockChoices(normalizedQuestion, session, env); - - if (!lockChoiceOrder) { - const shuffledValues = {}; - const keys = Object.keys(choices); - - const us = (part) => (id, element, update) => { - return new Promise((resolve) => { - shuffledValues[part] = update.shuffledValues; - resolve(); + if (!isEmpty(shuffledValues)) { + if (session && updateSession && typeof updateSession === 'function') { + updateSession(session.id, session.element, { + shuffledValues, + }).catch((e) => { + // eslint-disable-next-line no-console + console.error('update session failed', e); }); - }; - - let i; - - for (i = 0; i < keys.length; i++) { - const key = keys[i]; - const storedValues = session?.shuffledValues?.[key]; - - choices[key] = await getShuffledChoices( - choices[key], - // the shuffledValues structure was updated to an object like { choice_key: [] } - // and we need to override shuffledValues if it's not an array - { shuffledValues: Array.isArray(storedValues) ? storedValues : [] }, - us(key), - 'value', - ); - } - - if (!isEmpty(shuffledValues)) { - if (session && updateSession && typeof updateSession === 'function') { - updateSession(session.id, session.element, { - shuffledValues, - }).catch((e) => { - // eslint-disable-next-line no-console - console.error('update session failed', e); - }); - } } } + } - let teacherInstructions = null; - let rationale = null; + let teacherInstructions = null; + let rationale = null; - const choicesWillNullRationales = (Object.keys(choices) || []).reduce((acc, currentValue) => { - acc[currentValue] = (choices[currentValue] || []).map((choice) => ({ - ...choice, - rationale: null, - })); + const choicesWillNullRationales = (Object.keys(choices) || []).reduce((acc, currentValue) => { + acc[currentValue] = (choices[currentValue] || []).map((choice) => ({ + ...choice, + rationale: null, + })); - return acc; - }, {}); + return acc; + }, {}); - if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) { - rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null; - teacherInstructions = normalizedQuestion.teacherInstructionsEnabled - ? normalizedQuestion.teacherInstructions - : null; + if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) { + rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null; + teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null; - choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales; - } else { - rationale = null; - teacherInstructions = null; - choices = choicesWillNullRationales; - } + choices = normalizedQuestion.choiceRationaleEnabled ? normalizedQuestion.choices : choicesWillNullRationales; + } else { + rationale = null; + teacherInstructions = null; + choices = choicesWillNullRationales; + } - const out = { - disabled: env.mode !== 'gather', - mode: env.mode, - prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null, - displayType: normalizedQuestion.displayType, - markup: normalizedQuestion.markup, - choices, - feedback, - - responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined, - rationale, - teacherInstructions, - language: normalizedQuestion.language, - extraCSSRules: normalizedQuestion.extraCSSRules, - }; + const out = { + disabled: env.mode !== 'gather', + mode: env.mode, + prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null, + displayType: normalizedQuestion.displayType, + markup: normalizedQuestion.markup, + choices, + feedback, + + responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined, + rationale, + teacherInstructions, + language: normalizedQuestion.language, + extraCSSRules: normalizedQuestion.extraCSSRules, + }; return out; } diff --git a/packages/inline-dropdown/controller/src/utils.js b/packages/inline-dropdown/controller/src/utils.js index 8e4bc25266..159672888b 100644 --- a/packages/inline-dropdown/controller/src/utils.js +++ b/packages/inline-dropdown/controller/src/utils.js @@ -1,4 +1,4 @@ -import forEach from 'lodash/forEach'; +import { forEach } from 'lodash-es'; export const getAllCorrectResponses = ({ choices, alternateResponse }) => { alternateResponse = alternateResponse || {}; diff --git a/packages/inline-dropdown/package.json b/packages/inline-dropdown/package.json index c6426223c4..fc3daed9ac 100644 --- a/packages/inline-dropdown/package.json +++ b/packages/inline-dropdown/package.json @@ -19,7 +19,7 @@ "@pie-lib/mask-markup": "2.1.1-next.1", "@pie-lib/math-rendering": "4.1.1-next.0", "@pie-lib/render-ui": "5.1.1-next.0", - "lodash": "^4.17.23", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.3.1", "react-dom": "18.3.1" diff --git a/packages/inline-dropdown/src/inline-dropdown.jsx b/packages/inline-dropdown/src/inline-dropdown.jsx index 5947dc2964..026ed520bf 100644 --- a/packages/inline-dropdown/src/inline-dropdown.jsx +++ b/packages/inline-dropdown/src/inline-dropdown.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle'; import { InlineDropdown as DropDown } from '@pie-lib/mask-markup'; import { color, Collapsible, hasText, hasMedia, PreviewPrompt, UiLayout } from '@pie-lib/render-ui'; diff --git a/packages/likert/configure/src/index.js b/packages/likert/configure/src/index.js index 5f1722a940..3ef7c36053 100644 --- a/packages/likert/configure/src/index.js +++ b/packages/likert/configure/src/index.js @@ -4,7 +4,7 @@ import debug from 'debug'; import { ModelUpdatedEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events'; import Main from './main'; -import defaults from 'lodash/defaults'; +import { defaults } from 'lodash-es'; import sensibleDefaults from './defaults'; diff --git a/packages/likert/configure/src/main.jsx b/packages/likert/configure/src/main.jsx index 37afd6dcae..b7a8385de4 100644 --- a/packages/likert/configure/src/main.jsx +++ b/packages/likert/configure/src/main.jsx @@ -6,7 +6,7 @@ import RadioGroup from '@mui/material/RadioGroup'; import FormControlLabel from '@mui/material/FormControlLabel'; import { InputContainer, settings, layout, NumberTextField } from '@pie-lib/config-ui'; import { styled } from '@mui/material/styles'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { LIKERT_TYPE, LIKERT_SCALE, LIKERT_ORIENTATION } from './likertEntities'; import generateChoices from './choiceGenerator'; import { color } from '@pie-lib/render-ui'; @@ -104,16 +104,8 @@ const LikertOrientation = (props) => { value={model.likertOrientation} onChange={onChangeLikertOrientation} > - } - label="Horizontal" - /> - } - label="Vertical" - /> + } label="Horizontal" /> + } label="Vertical" /> ); @@ -135,21 +127,9 @@ const LikertScale = (props) => { Likert Scale - } - label="Likert 3" - /> - } - label="Likert 5" - /> - } - label="Likert 7" - /> + } label="Likert 3" /> + } label="Likert 5" /> + } label="Likert 7" /> ); @@ -178,21 +158,9 @@ const LikertType = (props) => { value={model.likertType} onChange={onChangeLikertType} > - } - label="Agreement" - /> - } - label="Frequency" - /> - } - label="Yes/No" - /> + } label="Agreement" /> + } label="Frequency" /> + } label="Yes/No" /> { value={model.likertType} onChange={onChangeLikertType} > - } - label="Importance" - /> - } - label="Likelihood" - /> + } label="Importance" /> + } label="Likelihood" /> } label="Like" /> diff --git a/packages/likert/controller/package.json b/packages/likert/controller/package.json index 5ea84bb45f..6f6fb957f1 100644 --- a/packages/likert/controller/package.json +++ b/packages/likert/controller/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "debug": "^4.1.1", - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" }, "author": "", "license": "ISC" diff --git a/packages/likert/package.json b/packages/likert/package.json index 67acc95f10..36ac146c96 100644 --- a/packages/likert/package.json +++ b/packages/likert/package.json @@ -19,7 +19,7 @@ "@pie-lib/render-ui": "5.1.1-next.0", "classnames": "^2.2.5", "debug": "^4.1.1", - "lodash": "^4.17.23", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.3.1", "react-dom": "18.3.1", diff --git a/packages/match-list/controller/package.json b/packages/match-list/controller/package.json index 1d2b790b52..70e70e8ea2 100644 --- a/packages/match-list/controller/package.json +++ b/packages/match-list/controller/package.json @@ -12,7 +12,7 @@ "@pie-lib/controller-utils": "1.1.1-next.0", "@pie-lib/feedback": "1.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" }, "devDependencies": { "babel-jest": "^29.7.0", diff --git a/packages/match-list/controller/src/index.js b/packages/match-list/controller/src/index.js index 8d456862eb..9197606b78 100644 --- a/packages/match-list/controller/src/index.js +++ b/packages/match-list/controller/src/index.js @@ -1,4 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { getFeedbackForCorrectness } from '@pie-lib/feedback'; import { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils'; import debug from 'debug'; diff --git a/packages/match-list/package.json b/packages/match-list/package.json index a9c37032e2..4481067406 100644 --- a/packages/match-list/package.json +++ b/packages/match-list/package.json @@ -22,7 +22,7 @@ "@pie-lib/math-rendering": "4.1.1-next.0", "@pie-lib/render-ui": "5.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.10", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.3.1", "react-dom": "18.3.1" diff --git a/packages/match-list/src/__tests__/answer-area.test.js b/packages/match-list/src/__tests__/answer-area.test.js index 44ebd97232..5202f25f52 100644 --- a/packages/match-list/src/__tests__/answer-area.test.js +++ b/packages/match-list/src/__tests__/answer-area.test.js @@ -1,7 +1,6 @@ import * as React from 'react'; import { render } from '@testing-library/react'; -import isObject from 'lodash/isObject'; -import isArray from 'lodash/isArray'; +import { isArray,isObject } from 'lodash-es'; import { AnswerArea } from '../answer-area'; import { model, answer } from '../../docs/demo/config'; diff --git a/packages/match-list/src/answer-area.jsx b/packages/match-list/src/answer-area.jsx index b7919807ff..01ee7b38f9 100644 --- a/packages/match-list/src/answer-area.jsx +++ b/packages/match-list/src/answer-area.jsx @@ -1,9 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; -import isEmpty from 'lodash/isEmpty'; -import isUndefined from 'lodash/isUndefined'; -import reduce from 'lodash/reduce'; +import { isEmpty, isUndefined, reduce } from 'lodash-es'; import Arrow from './arrow'; import DragAndDropAnswer from './answer'; diff --git a/packages/match-list/src/answer.jsx b/packages/match-list/src/answer.jsx index c9517f29a5..d453de7cdb 100644 --- a/packages/match-list/src/answer.jsx +++ b/packages/match-list/src/answer.jsx @@ -4,7 +4,7 @@ import React from 'react'; import debug from 'debug'; import { styled } from '@mui/material/styles'; import { PlaceHolder } from '@pie-lib/drag'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { color } from '@pie-lib/render-ui'; const log = debug('pie-elements:match-title:answer'); diff --git a/packages/match-list/src/choices-list.jsx b/packages/match-list/src/choices-list.jsx index 04d6ee0539..e08ac40c07 100644 --- a/packages/match-list/src/choices-list.jsx +++ b/packages/match-list/src/choices-list.jsx @@ -1,9 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; -import isEmpty from 'lodash/isEmpty'; -import isUndefined from 'lodash/isUndefined'; -import find from 'lodash/find'; +import { find, isEmpty, isUndefined } from 'lodash-es'; import DragAndDropAnswer from './answer'; import { MatchDroppablePlaceholder } from '@pie-lib/drag'; @@ -57,7 +55,7 @@ export class ChoicesList extends React.Component { return ( - {MatchDroppablePlaceholder ? ( + {MatchDroppablePlaceholder ? ( {filteredAnswers} diff --git a/packages/match-list/src/main.jsx b/packages/match-list/src/main.jsx index c8d6dcb8ec..fb13e7920b 100644 --- a/packages/match-list/src/main.jsx +++ b/packages/match-list/src/main.jsx @@ -1,15 +1,11 @@ import React from 'react'; import PropTypes from 'prop-types'; import { swap } from '@pie-lib/drag'; -import { - DndContext, -} from '@dnd-kit/core'; +import { DndContext } from '@dnd-kit/core'; import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle'; import { color, Feedback, PreviewPrompt } from '@pie-lib/render-ui'; import { styled } from '@mui/material/styles'; -import uniqueId from 'lodash/uniqueId'; -import isUndefined from 'lodash/isUndefined'; -import findKey from 'lodash/findKey'; +import { findKey, isUndefined, uniqueId } from 'lodash-es'; import AnswerArea from './answer-area'; import ChoicesList from './choices-list'; @@ -58,7 +54,9 @@ export class Main extends React.Component { if (activeData && overData) { const { session, onSessionChange, model } = this.props; - const { config: { duplicates } } = model; + const { + config: { duplicates }, + } = model; if (isUndefined(session.value)) { session.value = {}; diff --git a/packages/match/configure/package.json b/packages/match/configure/package.json index c9862d903b..d5c8a236cd 100644 --- a/packages/match/configure/package.json +++ b/packages/match/configure/package.json @@ -20,7 +20,7 @@ "@pie-lib/test-utils": "1.1.1-next.0", "classnames": "^2.2.5", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.6.2", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/match/configure/src/__tests__/configure.test.js b/packages/match/configure/src/__tests__/configure.test.js index a98059d4a0..32242aeb0d 100644 --- a/packages/match/configure/src/__tests__/configure.test.js +++ b/packages/match/configure/src/__tests__/configure.test.js @@ -4,7 +4,7 @@ import { Config } from '../configure'; import AnswerConfigBlock from '../answer-config-block'; import GeneralConfigBlock from '../general-config-block'; import { styles } from '../answer-config-block'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import defaultValues from '../defaults'; jest.mock('@mui/material', () => ({ diff --git a/packages/match/configure/src/answer-config-block.jsx b/packages/match/configure/src/answer-config-block.jsx index 1c0961e499..f58a57bf0f 100644 --- a/packages/match/configure/src/answer-config-block.jsx +++ b/packages/match/configure/src/answer-config-block.jsx @@ -7,7 +7,7 @@ import { styled } from '@mui/material/styles'; import AddRow from './add-row'; import Row from './row'; import debug from 'debug'; -import lodash from 'lodash'; +import { set } from 'lodash-es'; import EditableHtml, { DEFAULT_PLUGINS } from '@pie-lib/editable-html-tip-tap'; import { DragProvider } from '@pie-lib/drag'; @@ -141,19 +141,19 @@ class AnswerConfigBlock extends React.Component { onChange = (name, isBoolean) => - ({ target }) => { - const { model, onChange } = this.props; - let value; + ({ target }) => { + const { model, onChange } = this.props; + let value; - if (isBoolean) { - value = target.checked; - } else { - value = target.value; - } + if (isBoolean) { + value = target.checked; + } else { + value = target.value; + } - lodash.set(model, name, value); - onChange(model, name); - }; + set(model, name, value); + onChange(model, name); + }; onHeaderChange = (headerIndex) => (value) => { const { model, onChange } = this.props; @@ -171,8 +171,7 @@ class AnswerConfigBlock extends React.Component { }; render() { - const { model, onAddRow, imageSupport, configuration, toolbarOpts, spellCheck, uploadSoundSupport } = - this.props; + const { model, onAddRow, imageSupport, configuration, toolbarOpts, spellCheck, uploadSoundSupport } = this.props; const { baseInputConfiguration = {}, headers = {}, @@ -200,9 +199,7 @@ class AnswerConfigBlock extends React.Component { Click on the labels to edit or remove. Set the correct answers by clicking each correct answer per row. - + {headers.settings && (model.headers || []).map((header, idx) => ( @@ -211,19 +208,23 @@ class AnswerConfigBlock extends React.Component { className={cx({ questionText: idx === 0, })} - sx={idx === 0 ? { - flex: 2, - display: 'flex', - justifyContent: 'flex-start', - marginRight: 1, - '&> div': { - width: '100%', - padding: 0, - maxWidth: 'unset', - textAlign: 'left', - minWidth: '200px', - }, - } : {}} + sx={ + idx === 0 + ? { + flex: 2, + display: 'flex', + justifyContent: 'flex-start', + marginRight: 1, + '&> div': { + width: '100%', + padding: 0, + maxWidth: 'unset', + textAlign: 'left', + minWidth: '200px', + }, + } + : {} + } > - {columnsErrors && columnsErrors[idx] && ( - {columnsErrors[idx]} - )} + {columnsErrors && columnsErrors[idx] && {columnsErrors[idx]}} ))} diff --git a/packages/match/configure/src/index.js b/packages/match/configure/src/index.js index 4b81a6e4cd..0925e5772b 100644 --- a/packages/match/configure/src/index.js +++ b/packages/match/configure/src/index.js @@ -1,4 +1,4 @@ -import { isEmpty, set } from 'lodash'; +import { isEmpty, set } from 'lodash-es'; import React from 'react'; import { createRoot } from 'react-dom/client'; import Configure from './configure'; @@ -11,7 +11,7 @@ import { } from '@pie-framework/pie-configure-events'; import debug from 'debug'; import defaultValues from './defaults'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; const log = debug('pie-elements:match:configure'); @@ -95,7 +95,7 @@ export default class MatchConfigure extends HTMLElement { * if rows.inputConfiguration is not defined we try to default to the old enableImages flag * This flag 'enableImages' will be removed in the future */ - + if (isEmpty(c?.rows?.inputConfiguration)) { set(this._configuration.rows, 'inputConfiguration.image.disabled', !this._model?.enableImages); set(this._configuration.rows, 'inputConfiguration.video.disabled', true); diff --git a/packages/match/controller/src/index.js b/packages/match/controller/src/index.js index 178c4d6a6f..4f2114018c 100644 --- a/packages/match/controller/src/index.js +++ b/packages/match/controller/src/index.js @@ -1,6 +1,4 @@ -import isEqual from 'lodash/isEqual'; -import isEmpty from 'lodash/isEmpty'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep, isEmpty, isEqual } from 'lodash-es'; import { getFeedbackForCorrectness } from '@pie-lib/feedback'; import { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils'; import debug from 'debug'; @@ -133,8 +131,8 @@ const getOutComeScore = (question, env, answers = {}) => { return correctness === 'correct' ? 1 : correctness === 'partial' && isPartialScoring - ? getPartialScore(question, answers) - : 0; + ? getPartialScore(question, answers) + : 0; }; export const outcome = (question, session, env) => { @@ -210,8 +208,14 @@ export async function model(question, session, env, updateSession) { ? await getFeedbackForCorrectness(correctInfo.correctness, normalizedQuestion.feedback) : undefined; - const { extraCSSRules, feedbackEnabled, promptEnabled, prompt, lockChoiceOrder: _, ...essentials } = - normalizedQuestion; + const { + extraCSSRules, + feedbackEnabled, + promptEnabled, + prompt, + lockChoiceOrder: _, + ...essentials + } = normalizedQuestion; const out = { ...essentials, extraCSSRules, diff --git a/packages/match/package.json b/packages/match/package.json index 743d60e23c..ca6313d7ae 100644 --- a/packages/match/package.json +++ b/packages/match/package.json @@ -22,7 +22,7 @@ "@pie-lib/test-utils": "1.1.1-next.0", "classnames": "^2.2.5", "debug": "^4.1.1", - "lodash": "^4.17.10", + "lodash-es": "^4.17.23", "prop-types": "^15.6.1", "react": "18.3.1", "react-dom": "18.3.1" diff --git a/packages/math-inline/configure/src/general-config-block.jsx b/packages/math-inline/configure/src/general-config-block.jsx index bfb85af7ec..b56699c027 100644 --- a/packages/math-inline/configure/src/general-config-block.jsx +++ b/packages/math-inline/configure/src/general-config-block.jsx @@ -9,7 +9,7 @@ import Select from '@mui/material/Select'; import MenuItem from '@mui/material/MenuItem'; import Response from './response'; import { MathToolbar } from '@pie-lib/math-toolbar'; -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'lodash-es'; import { ResponseTypes, generateValidationMessage, getPluginProps } from './utils'; import MathQuill from '@pie-framework/mathquill'; import Info from '@mui/icons-material/Info'; diff --git a/packages/math-inline/configure/src/index.js b/packages/math-inline/configure/src/index.js index 60a1e31ee4..81298c9d7e 100644 --- a/packages/math-inline/configure/src/index.js +++ b/packages/math-inline/configure/src/index.js @@ -1,7 +1,7 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import Configure from './configure'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { ModelUpdatedEvent, DeleteImageEvent, diff --git a/packages/math-inline/controller/package.json b/packages/math-inline/controller/package.json index e69bf72adf..843a74d588 100644 --- a/packages/math-inline/controller/package.json +++ b/packages/math-inline/controller/package.json @@ -13,7 +13,7 @@ "@pie-lib/feedback": "1.1.1-next.0", "@pie-lib/translator": "3.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" }, "devDependencies": { "babel-jest": "^29.7.0", diff --git a/packages/math-inline/controller/src/index.js b/packages/math-inline/controller/src/index.js index 27524c51f1..7e543f3433 100644 --- a/packages/math-inline/controller/src/index.js +++ b/packages/math-inline/controller/src/index.js @@ -1,5 +1,5 @@ import debug from 'debug'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { getActualFeedbackForCorrectness } from '@pie-lib/feedback'; import { ResponseTypes } from './utils'; diff --git a/packages/math-inline/package.json b/packages/math-inline/package.json index 9cfb756f1d..d32a71b3a2 100644 --- a/packages/math-inline/package.json +++ b/packages/math-inline/package.json @@ -25,7 +25,7 @@ "@pie-lib/translator": "3.1.1-next.0", "classnames": "^2.2.5", "debug": "^4.1.1", - "lodash": "^4.17.10", + "lodash-es": "^4.17.23", "prop-types": "^15.6.1", "react": "18.3.1", "react-dom": "18.3.1" diff --git a/packages/math-inline/src/index.js b/packages/math-inline/src/index.js index 6f543c3aad..9edcea12ac 100644 --- a/packages/math-inline/src/index.js +++ b/packages/math-inline/src/index.js @@ -1,7 +1,7 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import debug from 'debug'; -import _ from 'lodash'; +import { debounce } from 'lodash-es'; import { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events'; import defaults from '../configure/lib/defaults'; @@ -16,7 +16,7 @@ export default class MathInline extends HTMLElement { super(); this._root = null; this._configuration = defaults.configuration; - this.sessionChangedEventCaller = _.debounce(() => { + this.sessionChangedEventCaller = debounce(() => { this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), true)); }, 1000); } diff --git a/packages/math-inline/src/main.jsx b/packages/math-inline/src/main.jsx index fd6d4fa35a..5a6475e0eb 100644 --- a/packages/math-inline/src/main.jsx +++ b/packages/math-inline/src/main.jsx @@ -7,11 +7,10 @@ import { renderMath } from '@pie-lib/math-rendering'; import { styled } from '@mui/material/styles'; import Tooltip from '@mui/material/Tooltip'; import { ResponseTypes } from './utils'; -import isEqual from 'lodash/isEqual'; +import { isEmpty, isEqual } from 'lodash-es'; import SimpleQuestionBlock from './simple-question-block'; import MathQuill from '@pie-framework/mathquill'; import { color } from '@pie-lib/render-ui'; -import isEmpty from 'lodash/isEmpty'; import Translator from '@pie-lib/translator'; import ReactDOM from 'react-dom'; const { translator } = Translator; @@ -637,9 +636,7 @@ export class Main extends React.Component { {viewMode && showTeacherInstructions && (!animationsDisabled ? ( - +
) : ( @@ -776,9 +773,7 @@ export class Main extends React.Component { )} - {viewMode && displayNote && ( - Note: ${note}` }} /> - )} + {viewMode && displayNote && Note: ${note}` }} />} {viewMode && showRationale && @@ -880,9 +875,7 @@ export class Main extends React.Component {
} > - (this.root = r || this.root)}> - {midContent} - + (this.root = r || this.root)}>{midContent} ); @@ -899,9 +892,7 @@ export class Main extends React.Component { this.root = domNode || this.root; }} > - - {midContent} - + {midContent} ); } @@ -1005,13 +996,10 @@ const ResponseContainer = styled('div')(({ theme }) => ({ })); const Expression = styled('div', { - shouldForwardProp: (prop) => !['isIncorrect', 'isCorrect', 'showCorrectness', 'correctAnswerShown', 'printCorrect'].includes(prop), + shouldForwardProp: (prop) => + !['isIncorrect', 'isCorrect', 'showCorrectness', 'correctAnswerShown', 'printCorrect'].includes(prop), })(({ theme, isIncorrect, isCorrect, showCorrectness, correctAnswerShown, printCorrect }) => { - const borderColor = isIncorrect - ? color.incorrect() - : isCorrect - ? color.correct() - : undefined; + const borderColor = isIncorrect ? color.incorrect() : isCorrect ? color.correct() : undefined; return { maxWidth: 'fit-content', @@ -1019,9 +1007,10 @@ const Expression = styled('div', { ...(showCorrectness && { border: borderColor ? `2px solid ${borderColor} !important` : '2px solid', }), - ...(!showCorrectness && borderColor && { - borderColor: `${borderColor} !important`, - }), + ...(!showCorrectness && + borderColor && { + borderColor: `${borderColor} !important`, + }), ...(correctAnswerShown && { padding: theme.spacing(1), letterSpacing: '0.5px', diff --git a/packages/math-inline/src/print.js b/packages/math-inline/src/print.js index e6e552b73c..856c29b362 100644 --- a/packages/math-inline/src/print.js +++ b/packages/math-inline/src/print.js @@ -1,6 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import Main from './main'; import { renderMath } from '@pie-lib/math-rendering'; import debug from 'debug'; diff --git a/packages/math-templated/configure/package.json b/packages/math-templated/configure/package.json index e3670a7a3c..b5322f31a5 100644 --- a/packages/math-templated/configure/package.json +++ b/packages/math-templated/configure/package.json @@ -16,7 +16,7 @@ "@pie-lib/math-toolbar": "2.1.1-next.0", "@pie-lib/render-ui": "5.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/math-templated/configure/src/design.jsx b/packages/math-templated/configure/src/design.jsx index dd770fcc25..d24f08ceb7 100644 --- a/packages/math-templated/configure/src/design.jsx +++ b/packages/math-templated/configure/src/design.jsx @@ -6,9 +6,7 @@ import Select from '@mui/material/Select'; import MenuItem from '@mui/material/MenuItem'; import Info from '@mui/icons-material/Info'; import Tooltip from '@mui/material/Tooltip'; -import cloneDeep from 'lodash/cloneDeep'; -import pick from 'lodash/pick'; -import throttle from 'lodash/throttle'; +import { cloneDeep, pick, throttle } from 'lodash-es'; import { InputContainer, settings, layout } from '@pie-lib/config-ui'; import EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html-tip-tap'; const { dropdown } = settings; @@ -408,15 +406,8 @@ export class Design extends React.Component { )} - - Response Template - - + Response Template + @@ -450,7 +441,7 @@ export class Design extends React.Component { this.handleChange('equationEditor', event.target.value)} value={equationEditor} > diff --git a/packages/math-templated/configure/src/index.js b/packages/math-templated/configure/src/index.js index fb23250460..fa8db79441 100644 --- a/packages/math-templated/configure/src/index.js +++ b/packages/math-templated/configure/src/index.js @@ -1,8 +1,7 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import debug from 'debug'; -import defaults from 'lodash/defaults'; -import isArray from 'lodash/isArray'; +import { defaults, isArray } from 'lodash-es'; import { ModelUpdatedEvent, DeleteImageEvent, @@ -38,7 +37,7 @@ export default class MathTemplateConfigure extends HTMLElement { const joinedObj = { ...sensibleDefaults.model, ...model, - responses: updatedResponses + responses: updatedResponses, }; const slateMarkup = joinedObj.slateMarkup || createSlateMarkup(joinedObj.markup, joinedObj.responses); @@ -101,7 +100,7 @@ export default class MathTemplateConfigure extends HTMLElement { // check if the language is already included in the languageChoices.options array // and if not, then add it. - if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) { + if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) { this._configuration.languageChoices.options.push({ value: this._model.language, label: this._model.language, diff --git a/packages/math-templated/controller/package.json b/packages/math-templated/controller/package.json index 990f113e24..8069c9fe76 100644 --- a/packages/math-templated/controller/package.json +++ b/packages/math-templated/controller/package.json @@ -10,11 +10,9 @@ "@pie-lib/controller-utils": "1.1.1-next.0", "@pie-lib/translator": "3.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.23" - }, - "devDependencies": { - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" }, + "devDependencies": {}, "author": "", "license": "ISC" } diff --git a/packages/math-templated/controller/src/index.js b/packages/math-templated/controller/src/index.js index 78e62be69d..61de26567f 100644 --- a/packages/math-templated/controller/src/index.js +++ b/packages/math-templated/controller/src/index.js @@ -1,5 +1,5 @@ import debug from 'debug'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import Translator from '@pie-lib/translator'; import * as mv from '@pie-framework/math-validation'; diff --git a/packages/math-templated/src/index.js b/packages/math-templated/src/index.js index 19e355cf9f..33275396ac 100644 --- a/packages/math-templated/src/index.js +++ b/packages/math-templated/src/index.js @@ -1,82 +1,84 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import {SessionChangedEvent, ModelSetEvent} from '@pie-framework/pie-player-events'; +import { SessionChangedEvent, ModelSetEvent } from '@pie-framework/pie-player-events'; import Main from './main'; -import _ from 'lodash'; +import { debounce } from 'lodash-es'; export default class MathTemplated extends HTMLElement { - constructor() { - super(); - this._root = null; - this.sessionChangedEventCaller = _.debounce(() => { - this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), true)); - }, 1000); + constructor() { + super(); + this._root = null; + this.sessionChangedEventCaller = debounce(() => { + this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), true)); + }, 1000); + } + + set model(m) { + this._model = m; + + this.render(); + this.dispatchEvent( + new ModelSetEvent(this.tagName.toLowerCase(), this.isSessionComplete(), this._model !== undefined), + ); + } + + get model() { + return this._model; + } + + set session(s) { + this._session = s; + + this.render(); + } + + get session() { + return this._session; + } + + isSessionComplete() { + // a method to check if student answered the question + return true; + } + + onSessionChange(session) { + // you can add an extra step here to validate session + Object.keys(session).map((key) => { + this._session[key] = session[key]; + }); + + this.sessionChangedEventCaller(); + this.render(); + } + + connectedCallback() { + // TODO set accessibility labels + + this.render(); + } + + render() { + if (!this._model || !this._session) { + return; } - set model(m) { - this._model = m; - - this.render(); - this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isSessionComplete(), this._model !== undefined)); - } - - get model() { - return this._model; - } - - set session(s) { - this._session = s; - - this.render(); - } - - get session() { - return this._session; - } - - isSessionComplete() { - // a method to check if student answered the question - return true; - } - - onSessionChange(session) { - // you can add an extra step here to validate session - Object.keys(session).map((key) => { - this._session[key] = session[key]; - }); - - this.sessionChangedEventCaller(); - this.render(); - } - - connectedCallback() { - // TODO set accessibility labels - - this.render(); - } - - render() { - if (!this._model || !this._session) { - return; - } - - if (this._model && this._session) { - const el = React.createElement(Main, { - model: this._model, - session: this._session, - onSessionChange: this.onSessionChange.bind(this), - }); - - if (!this._root) { - this._root = createRoot(this); - } - this._root.render(el); - } + if (this._model && this._session) { + const el = React.createElement(Main, { + model: this._model, + session: this._session, + onSessionChange: this.onSessionChange.bind(this), + }); + + if (!this._root) { + this._root = createRoot(this); + } + this._root.render(el); } + } - disconnectedCallback() { - if (this._root) { - this._root.unmount(); - } + disconnectedCallback() { + if (this._root) { + this._root.unmount(); } + } } diff --git a/packages/math-templated/src/main.jsx b/packages/math-templated/src/main.jsx index b920788f64..387cc8f3c1 100644 --- a/packages/math-templated/src/main.jsx +++ b/packages/math-templated/src/main.jsx @@ -1,7 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import isEqual from 'lodash/isEqual'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty, isEqual } from 'lodash-es'; import { styled } from '@mui/material/styles'; import Tooltip from '@mui/material/Tooltip'; import { mq, HorizontalKeypad, updateSpans } from '@pie-lib/math-input'; @@ -663,7 +662,8 @@ export class Main extends React.Component { ); return ( - - {studentPrintMode ? ( - {MQStatic} - ) : ( -
- {MQStatic} -
- )} + {studentPrintMode ? {MQStatic} :
{MQStatic}
}
); @@ -774,12 +768,7 @@ export class Main extends React.Component { {showCorrectAnswerToggle && ( - + )} diff --git a/packages/math-templated/src/print.js b/packages/math-templated/src/print.js index e026ab6b58..165a321225 100644 --- a/packages/math-templated/src/print.js +++ b/packages/math-templated/src/print.js @@ -1,6 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import Main from './main'; import { renderMath } from '@pie-lib/math-rendering'; import debug from 'debug'; diff --git a/packages/matrix/configure/src/index.js b/packages/matrix/configure/src/index.js index 7df478395c..f37ca62fad 100644 --- a/packages/matrix/configure/src/index.js +++ b/packages/matrix/configure/src/index.js @@ -4,7 +4,7 @@ import debug from 'debug'; import { ModelUpdatedEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events'; import Main from './Main'; -import defaults from 'lodash/defaults'; +import { defaults } from 'lodash-es'; import sensibleDefaults from './defaults'; diff --git a/packages/matrix/controller/package.json b/packages/matrix/controller/package.json index c9e9e48830..e9a71a82f5 100644 --- a/packages/matrix/controller/package.json +++ b/packages/matrix/controller/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "debug": "^4.1.1", - "lodash": "^4.17.23" + "lodash-es": "^4.17.23" }, "author": "", "license": "ISC" diff --git a/packages/matrix/controller/src/index.js b/packages/matrix/controller/src/index.js index 597ec5a5a5..d0a724ac68 100644 --- a/packages/matrix/controller/src/index.js +++ b/packages/matrix/controller/src/index.js @@ -1,5 +1,5 @@ import defaults from './defaults'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; export const createDefaultModel = (model = {}) => new Promise((resolve) => resolve({ ...defaults, ...model })); diff --git a/packages/multi-trait-rubric/configure/package.json b/packages/multi-trait-rubric/configure/package.json index 7103f94e81..d729b1345a 100644 --- a/packages/multi-trait-rubric/configure/package.json +++ b/packages/multi-trait-rubric/configure/package.json @@ -16,7 +16,7 @@ "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "@pie-lib/render-ui": "5.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.6.2", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/multi-trait-rubric/configure/src/main.jsx b/packages/multi-trait-rubric/configure/src/main.jsx index 5bd2c2577d..a05025978f 100644 --- a/packages/multi-trait-rubric/configure/src/main.jsx +++ b/packages/multi-trait-rubric/configure/src/main.jsx @@ -1,9 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -import cloneDeep from 'lodash/cloneDeep'; -import isEmpty from 'lodash/isEmpty'; -import debounce from 'lodash/debounce'; +import { cloneDeep, debounce, isEmpty } from 'lodash-es'; import { styled } from '@mui/material/styles'; @@ -20,7 +18,7 @@ const MIN_WIDTH = '650px'; const StyledDiv = styled('div')(({ theme }) => ({ fontFamily: 'Cerebri Sans', fontSize: theme.typography.fontSize, - padding: '16px 0' + padding: '16px 0', })); const ShowModal = ({ showExcludeZeroDialog, excludeZero, changeExcludeZero, cancel }) => { diff --git a/packages/multi-trait-rubric/configure/src/trait.jsx b/packages/multi-trait-rubric/configure/src/trait.jsx index 4a54fdddc0..24cba31b35 100644 --- a/packages/multi-trait-rubric/configure/src/trait.jsx +++ b/packages/multi-trait-rubric/configure/src/trait.jsx @@ -1,7 +1,7 @@ import React from 'react'; import debug from 'debug'; import PropTypes from 'prop-types'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { useDraggable, useDroppable } from '@dnd-kit/core'; import { styled } from '@mui/material/styles'; @@ -75,7 +75,13 @@ function TraitTile({ const [anchorEl, setAnchorEl] = React.useState(null); const secondaryBlockRef = React.useRef(null); - const { attributes, listeners, setNodeRef: setDragRef, transform, isDragging } = useDraggable({ + const { + attributes, + listeners, + setNodeRef: setDragRef, + transform, + isDragging, + } = useDraggable({ id: `trait-${index}`, data: { type: 'trait', @@ -93,7 +99,11 @@ function TraitTile({ }); React.useEffect(() => { - if (currentPosition !== undefined && secondaryBlockRef.current && secondaryBlockRef.current.scrollLeft !== currentPosition) { + if ( + currentPosition !== undefined && + secondaryBlockRef.current && + secondaryBlockRef.current.scrollLeft !== currentPosition + ) { scrollToPosition(currentPosition); } }, [currentPosition]); @@ -125,10 +135,12 @@ function TraitTile({ handleClose(); }; - const dragStyle = transform ? { - transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`, - opacity: isDragging ? 0.5 : 1, - } : {}; + const dragStyle = transform + ? { + transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`, + opacity: isDragging ? 0.5 : 1, + } + : {}; return (
@@ -146,7 +158,8 @@ function TraitTile({ aria-controls="long-menu" aria-haspopup="true" onClick={handleClick} - size="large"> + size="large" + > @@ -159,9 +172,7 @@ function TraitTile({ transitionDuration={{ enter: 225, exit: 195 }} > - + diff --git a/packages/multi-trait-rubric/controller/package.json b/packages/multi-trait-rubric/controller/package.json index 081a2cdd25..639fa50968 100644 --- a/packages/multi-trait-rubric/controller/package.json +++ b/packages/multi-trait-rubric/controller/package.json @@ -9,6 +9,6 @@ "license": "ISC", "dependencies": { "debug": "^4.1.1", - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" } } diff --git a/packages/multiple-choice/configure/package.json b/packages/multiple-choice/configure/package.json index d277d7c4de..e4762ae4c1 100644 --- a/packages/multiple-choice/configure/package.json +++ b/packages/multiple-choice/configure/package.json @@ -14,7 +14,7 @@ "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "@pie-lib/render-ui": "5.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.23", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/multiple-choice/configure/src/index.js b/packages/multiple-choice/configure/src/index.js index 3a7fa31b58..0db043f231 100644 --- a/packages/multiple-choice/configure/src/index.js +++ b/packages/multiple-choice/configure/src/index.js @@ -11,7 +11,7 @@ import { import Main from './main'; import { choiceUtils as utils } from '@pie-lib/config-ui'; -import defaults from 'lodash/defaults'; +import { defaults } from 'lodash-es'; import sensibleDefaults from './defaults'; @@ -179,7 +179,7 @@ export default class MultipleChoice extends HTMLElement { log('_render - Model:', this._model ? 'present' : 'missing'); log('_render - Configuration:', this._configuration ? 'present' : 'missing'); log('_render - Root exists:', !!this._root); - + try { let element = React.createElement(Main, { model: this._model, @@ -200,19 +200,19 @@ export default class MultipleChoice extends HTMLElement { if (!this._root) { console.log('🔧 [multiple-choice-configure] _render - Creating React container'); log('_render - Creating React container'); - + // Create a container div for React to render into this._reactContainer = document.createElement('div'); this._reactContainer.className = 'pie-configure-wrapper'; this.appendChild(this._reactContainer); - + console.log('🔧 [multiple-choice-configure] _render - Creating new React root'); log('_render - Creating new React root'); this._root = createRoot(this._reactContainer); console.log('✅ [multiple-choice-configure] _render - React root created successfully'); log('_render - React root created successfully'); } - + console.log('🔧 [multiple-choice-configure] _render - Calling root.render()'); log('_render - Calling root.render()'); this._root.render(element); diff --git a/packages/multiple-choice/configure/src/main.jsx b/packages/multiple-choice/configure/src/main.jsx index c991927fdc..7c9b684d5d 100644 --- a/packages/multiple-choice/configure/src/main.jsx +++ b/packages/multiple-choice/configure/src/main.jsx @@ -16,7 +16,7 @@ import Tooltip from '@mui/material/Tooltip'; import Typography from '@mui/material/Typography'; import Box from '@mui/material/Box'; import Info from '@mui/icons-material/Info'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { generateValidationMessage } from './utils'; const { Panel, toggle, radio, dropdown } = settings; diff --git a/packages/multiple-choice/controller/package.json b/packages/multiple-choice/controller/package.json index d1de86d943..f36e7dca78 100644 --- a/packages/multiple-choice/controller/package.json +++ b/packages/multiple-choice/controller/package.json @@ -10,6 +10,6 @@ "dependencies": { "@pie-lib/controller-utils": "1.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.23" + "lodash-es": "^4.17.23" } } diff --git a/packages/multiple-choice/controller/src/index.js b/packages/multiple-choice/controller/src/index.js index 3818b41d0b..5dccd86328 100644 --- a/packages/multiple-choice/controller/src/index.js +++ b/packages/multiple-choice/controller/src/index.js @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { isResponseCorrect } from './utils'; import defaults from './defaults'; import { lockChoices, partialScoring, getShuffledChoices } from '@pie-lib/controller-utils'; diff --git a/packages/multiple-choice/controller/src/utils.js b/packages/multiple-choice/controller/src/utils.js index c99cdce29d..13a0937833 100644 --- a/packages/multiple-choice/controller/src/utils.js +++ b/packages/multiple-choice/controller/src/utils.js @@ -1,4 +1,4 @@ -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'lodash-es'; export const getCorrectResponse = (choices) => choices diff --git a/packages/multiple-choice/package.json b/packages/multiple-choice/package.json index 38f5cc8efb..f8d9b8f5d7 100644 --- a/packages/multiple-choice/package.json +++ b/packages/multiple-choice/package.json @@ -17,7 +17,7 @@ "@pie-lib/translator": "3.1.1-next.0", "classnames": "^2.2.5", "debug": "^4.1.1", - "lodash": "^4.17.23", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.3.1", "react-dom": "18.3.1", diff --git a/packages/multiple-choice/src/__tests__/index-test.jsx b/packages/multiple-choice/src/__tests__/index-test.jsx index ffade9dbc0..4d33b7cbfa 100644 --- a/packages/multiple-choice/src/__tests__/index-test.jsx +++ b/packages/multiple-choice/src/__tests__/index-test.jsx @@ -7,7 +7,9 @@ import { isComplete } from '../index'; jest.useFakeTimers(); jest.mock('@pie-lib/math-rendering', () => ({ renderMath: jest.fn() })); -jest.mock('lodash/debounce', () => jest.fn((fn) => fn)); +jest.mock('lodash-es', () => ({ + debounce: jest.fn((fn) => fn), +})); // Mock the render-ui PreviewLayout jest.mock('@pie-lib/render-ui', () => ({ diff --git a/packages/multiple-choice/src/index.js b/packages/multiple-choice/src/index.js index 282f35ac0c..079bc8e2a7 100644 --- a/packages/multiple-choice/src/index.js +++ b/packages/multiple-choice/src/index.js @@ -1,7 +1,7 @@ import Main from './main'; import React from 'react'; import { createRoot } from 'react-dom/client'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import debug from 'debug'; import { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events'; import { renderMath } from '@pie-lib/math-rendering'; diff --git a/packages/multiple-choice/src/print.js b/packages/multiple-choice/src/print.js index 0ee37bcd26..56158a4fd9 100644 --- a/packages/multiple-choice/src/print.js +++ b/packages/multiple-choice/src/print.js @@ -1,7 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import debounce from 'lodash/debounce'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep, debounce } from 'lodash-es'; import Main from './main'; import { renderMath } from '@pie-lib/math-rendering'; import debug from 'debug'; diff --git a/packages/number-line/configure/package.json b/packages/number-line/configure/package.json index 71381e088f..8f6bee89bf 100644 --- a/packages/number-line/configure/package.json +++ b/packages/number-line/configure/package.json @@ -13,7 +13,7 @@ "@pie-lib/config-ui": "12.1.1-next.1", "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "@pie-lib/render-ui": "5.1.1-next.0", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "react": "18.2.0", "react-dom": "18.2.0" } diff --git a/packages/number-line/configure/src/index.js b/packages/number-line/configure/src/index.js index 11fdd18397..5c73467183 100644 --- a/packages/number-line/configure/src/index.js +++ b/packages/number-line/configure/src/index.js @@ -10,7 +10,7 @@ import { } from '@pie-framework/pie-configure-events'; import * as defaults from './defaults'; import * as math from 'mathjs'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; // this function is duplicated in controller; at some point, use the same shared function const updateTicks = (model) => { diff --git a/packages/number-line/configure/src/main.jsx b/packages/number-line/configure/src/main.jsx index ece4325ba9..5e82377a3d 100644 --- a/packages/number-line/configure/src/main.jsx +++ b/packages/number-line/configure/src/main.jsx @@ -9,7 +9,7 @@ import PropTypes from 'prop-types'; import Domain from './domain'; import Arrows from './arrows'; import PointConfig from './point-config'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import { styled } from '@mui/material/styles'; import Typography from '@mui/material/Typography'; import Info from '@mui/icons-material/Info'; diff --git a/packages/number-line/controller/package.json b/packages/number-line/controller/package.json index 20c0b6e575..30e6d3c0e5 100644 --- a/packages/number-line/controller/package.json +++ b/packages/number-line/controller/package.json @@ -13,7 +13,7 @@ "dependencies": { "@pie-lib/controller-utils": "1.1.1-next.0", "@pie-lib/feedback": "1.1.1-next.0", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "mathjs": "^7.5.1" }, "author": "", diff --git a/packages/number-line/controller/src/__tests__/index.test.js b/packages/number-line/controller/src/__tests__/index.test.js index 9e6e94ebd9..fe4811a50a 100644 --- a/packages/number-line/controller/src/__tests__/index.test.js +++ b/packages/number-line/controller/src/__tests__/index.test.js @@ -1,4 +1,4 @@ -import _ from 'lodash'; +import { isFunction, merge } from 'lodash-es'; import { defaults } from '@pie-lib/feedback'; import * as controller from '../index'; import { normalize } from '../index'; @@ -272,14 +272,14 @@ describe('controller', () => { describe('model', () => { const assertModel = (msg, question, session, env, expected) => { question = mkQuestion(question); - session = _.merge(session, {}); - env = _.merge(env, {}); + session = merge(session, {}); + env = merge(env, {}); it(msg, () => { return controller .model(question, session, env) .then((o) => { - if (_.isFunction(expected)) { + if (isFunction(expected)) { expected(o); } else { expect(o).toMatchObject(expected); diff --git a/packages/number-line/controller/src/index.js b/packages/number-line/controller/src/index.js index dac0f4c70e..24244aac44 100644 --- a/packages/number-line/controller/src/index.js +++ b/packages/number-line/controller/src/index.js @@ -1,9 +1,4 @@ -import cloneDeep from 'lodash/cloneDeep'; -import find from 'lodash/find'; -import isEmpty from 'lodash/isEmpty'; -import isEqualWith from 'lodash/isEqualWith'; -import merge from 'lodash/merge'; -import omitBy from 'lodash/omitBy'; +import { cloneDeep, find, isEmpty, isEqualWith, merge, omitBy } from 'lodash-es'; import { getFeedbackForCorrectness } from '@pie-lib/feedback'; import { partialScoring } from '@pie-lib/controller-utils'; import * as math from 'mathjs'; diff --git a/packages/number-line/controller/src/tickUtils.js b/packages/number-line/controller/src/tickUtils.js index 7406c5ccc2..f796c1ce9f 100644 --- a/packages/number-line/controller/src/tickUtils.js +++ b/packages/number-line/controller/src/tickUtils.js @@ -1,7 +1,5 @@ import * as math from 'mathjs'; -import uniqWith from 'lodash/uniqWith'; -import isObject from 'lodash/isObject'; -import isNumber from 'lodash/isNumber'; +import { isNumber, isObject, uniqWith } from 'lodash-es'; // All these functions are duplicated in src/number-line/graph/tick-utils diff --git a/packages/number-line/package.json b/packages/number-line/package.json index 66e36e14f9..3f9cb2400f 100644 --- a/packages/number-line/package.json +++ b/packages/number-line/package.json @@ -20,7 +20,7 @@ "classnames": "^2.2.5", "d3-scale": "^4.0.2", "d3-selection": "^3.0.0", - "lodash": "^4.17.10", + "lodash-es": "^4.17.23", "mathjs": "^7.5.1", "react": "18.3.1", "react-dom": "18.3.1", diff --git a/packages/number-line/src/index.js b/packages/number-line/src/index.js index 3af30f9ba3..df0d70d731 100644 --- a/packages/number-line/src/index.js +++ b/packages/number-line/src/index.js @@ -9,7 +9,7 @@ import NumberLineComponent from './number-line'; import React from 'react'; import { createRoot } from 'react-dom/client'; import RootComponent from './number-line'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import { renderMath } from '@pie-lib/math-rendering'; //Expose some additional modules for configuration diff --git a/packages/number-line/src/number-line/__tests__/index.test.js b/packages/number-line/src/number-line/__tests__/index.test.js index d517a4c75e..c15abf51f3 100644 --- a/packages/number-line/src/number-line/__tests__/index.test.js +++ b/packages/number-line/src/number-line/__tests__/index.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import _ from 'lodash'; +import { merge } from 'lodash-es'; import { render } from '@testing-library/react'; import { NumberLine, Graph } from '../index'; @@ -23,7 +23,7 @@ describe('NumberLine', () => { onAddElement, }; - props = _.merge(defaults, props); + props = merge(defaults, props); return render(); }; diff --git a/packages/number-line/src/number-line/graph/__tests__/ticks-utils.test.js b/packages/number-line/src/number-line/graph/__tests__/ticks-utils.test.js index 6c3a212319..e0c7497a62 100644 --- a/packages/number-line/src/number-line/graph/__tests__/ticks-utils.test.js +++ b/packages/number-line/src/number-line/graph/__tests__/ticks-utils.test.js @@ -1,7 +1,7 @@ import * as mod from '../tick-utils'; import * as math from 'mathjs'; import { AssertionError } from 'assert'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; const domain = (min, max) => ({ min, max }); const ticks = (minor, major) => ({ minor, major }); diff --git a/packages/number-line/src/number-line/graph/elements/__tests__/line.test.jsx b/packages/number-line/src/number-line/graph/elements/__tests__/line.test.jsx index c8832e7ac3..13770911f2 100644 --- a/packages/number-line/src/number-line/graph/elements/__tests__/line.test.jsx +++ b/packages/number-line/src/number-line/graph/elements/__tests__/line.test.jsx @@ -1,19 +1,20 @@ import React from 'react'; import { render } from '@testing-library/react'; -import _ from 'lodash'; +import { merge } from 'lodash-es'; import { stubContext } from './utils'; import { Line } from '../line'; // Mock Draggable to avoid dnd-kit dependencies jest.mock('../../../../draggable', () => ({ - Draggable: ({ children }) => children({ - setNodeRef: jest.fn(), - attributes: {}, - listeners: {}, - translateX: 0, - isDragging: false, - onMouseDown: jest.fn() - }), + Draggable: ({ children }) => + children({ + setNodeRef: jest.fn(), + attributes: {}, + listeners: {}, + translateX: 0, + isDragging: false, + onMouseDown: jest.fn(), + }), })); // Mock Point component @@ -50,7 +51,7 @@ describe('line', () => { onDragStop, }; - props = _.merge(defaults, props); + props = merge(defaults, props); // Create a wrapper component that provides context const LineWrapper = () => { diff --git a/packages/number-line/src/number-line/graph/elements/__tests__/point.test.jsx b/packages/number-line/src/number-line/graph/elements/__tests__/point.test.jsx index f7ca32fe67..9caec1ef7c 100644 --- a/packages/number-line/src/number-line/graph/elements/__tests__/point.test.jsx +++ b/packages/number-line/src/number-line/graph/elements/__tests__/point.test.jsx @@ -1,19 +1,20 @@ import React from 'react'; import { render } from '@testing-library/react'; -import _ from 'lodash'; +import { merge } from 'lodash-es'; import { stubContext } from './utils'; import { Point } from '../point'; // Mock Draggable to avoid dnd-kit dependencies jest.mock('../../../../draggable', () => ({ - Draggable: ({ children }) => children({ - setNodeRef: jest.fn(), - attributes: {}, - listeners: {}, - translateX: 0, - isDragging: false, - onMouseDown: jest.fn() - }), + Draggable: ({ children }) => + children({ + setNodeRef: jest.fn(), + attributes: {}, + listeners: {}, + translateX: 0, + isDragging: false, + onMouseDown: jest.fn(), + }), })); describe('point', () => { @@ -43,7 +44,7 @@ describe('point', () => { onDrag, }; - props = _.merge(defaults, props); + props = merge(defaults, props); // Create a wrapper component that provides context const PointWrapper = () => { diff --git a/packages/number-line/src/number-line/graph/elements/__tests__/ray.test.jsx b/packages/number-line/src/number-line/graph/elements/__tests__/ray.test.jsx index bb5c2caaca..26bff3391b 100644 --- a/packages/number-line/src/number-line/graph/elements/__tests__/ray.test.jsx +++ b/packages/number-line/src/number-line/graph/elements/__tests__/ray.test.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { render } from '@testing-library/react'; -import _ from 'lodash'; +import { merge } from 'lodash-es'; import { stubContext } from './utils'; import { Ray } from '../ray'; @@ -28,7 +28,7 @@ describe('ray', () => { onToggleSelect: onToggleSelect, }; - props = _.merge(defaults, props); + props = merge(defaults, props); // Create a wrapper component that provides context const RayWrapper = () => { @@ -108,7 +108,7 @@ describe('ray', () => { onToggleSelect: onToggleSelect, }; - props = _.merge(defaults, props); + props = merge(defaults, props); const instance = new Ray(props); instance.context = stubContext; instance.setState = jest.fn((state) => { diff --git a/packages/number-line/src/number-line/graph/elements/line.jsx b/packages/number-line/src/number-line/graph/elements/line.jsx index 11bb2180bc..dd2ffd09f6 100644 --- a/packages/number-line/src/number-line/graph/elements/line.jsx +++ b/packages/number-line/src/number-line/graph/elements/line.jsx @@ -1,8 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; -import isEqual from 'lodash/isEqual'; -import isNumber from 'lodash/isNumber'; +import { isEqual, isNumber } from 'lodash-es'; import { color } from '@pie-lib/render-ui'; import { Draggable } from '../../../draggable'; @@ -116,16 +115,7 @@ export class Line extends React.Component { } render() { - const { - interval, - empty, - position, - domain, - y, - selected, - disabled, - correct, - } = this.props; + const { interval, empty, position, domain, y, selected, disabled, correct } = this.props; const { xScale } = this.context; @@ -196,14 +186,7 @@ export class Line extends React.Component { onMouseDown={onMouseDown} onDragEnd={onLineDragStop} > - {({ - setNodeRef, - attributes, - listeners, - translateX, - isDragging, - onMouseDown: handleMouseDown, - }) => ( + {({ setNodeRef, attributes, listeners, translateX, isDragging, onMouseDown: handleMouseDown }) => ( ({ '& line': { diff --git a/packages/number-line/src/number-line/graph/tick-utils.js b/packages/number-line/src/number-line/graph/tick-utils.js index 2db1c50732..9f9c082185 100644 --- a/packages/number-line/src/number-line/graph/tick-utils.js +++ b/packages/number-line/src/number-line/graph/tick-utils.js @@ -1,7 +1,5 @@ import * as math from 'mathjs'; -import uniqWith from 'lodash/uniqWith'; -import isObject from 'lodash/isObject'; -import isNumber from 'lodash/isNumber'; +import { isNumber, isObject, uniqWith } from 'lodash-es'; // All these functions are duplicated in controller/src/tickUtils diff --git a/packages/number-line/src/number-line/index.jsx b/packages/number-line/src/number-line/index.jsx index c7c96f00d5..fe264a7d85 100644 --- a/packages/number-line/src/number-line/index.jsx +++ b/packages/number-line/src/number-line/index.jsx @@ -1,9 +1,6 @@ import React from 'react'; import Toggle from '@pie-lib/correct-answer-toggle'; -import cloneDeep from 'lodash/cloneDeep'; -import isArray from 'lodash/isArray'; -import isNumber from 'lodash/isNumber'; -import isEqual from 'lodash/isEqual'; +import { cloneDeep, isArray, isEqual, isNumber } from 'lodash-es'; import Translator from '@pie-lib/translator'; import { Collapsible, color, hasMedia, hasText, PreviewPrompt, UiLayout } from '@pie-lib/render-ui'; import { styled } from '@mui/material/styles'; diff --git a/packages/passage/configure/package.json b/packages/passage/configure/package.json index 827212ab3d..132dd90d02 100644 --- a/packages/passage/configure/package.json +++ b/packages/passage/configure/package.json @@ -15,7 +15,7 @@ "@pie-framework/pie-configure-events": "^1.3.0", "@pie-lib/config-ui": "12.1.1-next.1", "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", - "lodash": "^4.17.23", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/passage/controller/package.json b/packages/passage/controller/package.json index 8874e03ed2..775dff9d8d 100644 --- a/packages/passage/controller/package.json +++ b/packages/passage/controller/package.json @@ -8,6 +8,6 @@ "author": "", "license": "ISC", "dependencies": { - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" } } diff --git a/packages/passage/controller/src/index.js b/packages/passage/controller/src/index.js index a6995b597a..cfb85aa0e1 100644 --- a/packages/passage/controller/src/index.js +++ b/packages/passage/controller/src/index.js @@ -1,4 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import defaults from './defaults'; diff --git a/packages/passage/src/print.js b/packages/passage/src/print.js index cc5078a9fc..c69cf23981 100644 --- a/packages/passage/src/print.js +++ b/packages/passage/src/print.js @@ -1,6 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import debug from 'debug'; import StimulusTabs from './stimulus-tabs'; diff --git a/packages/pie-models/package.json b/packages/pie-models/package.json index 1a8d34fe97..c3bd64a7f9 100644 --- a/packages/pie-models/package.json +++ b/packages/pie-models/package.json @@ -22,7 +22,7 @@ "devDependencies": { "@types/command-line-args": "^5.0.0", "@types/fs-extra": "^5.0.4", - "@types/lodash": "^4.14.119", + "@types/lodash-es": "^4.17.12", "@types/node": "^10.12.18", "change-case": "^3.1.0", "command-line-args": "^5.0.2", @@ -30,7 +30,7 @@ "fs-extra": "^7.0.1", "json-schema-deref-sync": "^0.7.0", "json-schema-to-markdown": "^1.0.3", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "ts-node": "^7.0.1", "typescript": "^3.2.2", "typescript-json-schema": "^0.34.0", diff --git a/packages/placement-ordering/configure/package.json b/packages/placement-ordering/configure/package.json index d8a9ffdc81..7307bfa394 100644 --- a/packages/placement-ordering/configure/package.json +++ b/packages/placement-ordering/configure/package.json @@ -16,7 +16,7 @@ "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "@pie-lib/render-ui": "5.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.23", + "lodash-es": "^4.17.23", "nested-property": "^0.0.7", "pluralize": "^8.0.0", "prop-types": "^15.8.1", diff --git a/packages/placement-ordering/configure/src/__tests__/design.test.jsx b/packages/placement-ordering/configure/src/__tests__/design.test.jsx index 099975ef20..e02147bcde 100644 --- a/packages/placement-ordering/configure/src/__tests__/design.test.jsx +++ b/packages/placement-ordering/configure/src/__tests__/design.test.jsx @@ -1,6 +1,6 @@ import { render } from '@testing-library/react'; import React from 'react'; -import _ from 'lodash'; +import { cloneDeep } from 'lodash-es'; import { get, set } from 'nested-property'; import { Design } from '../design'; @@ -48,8 +48,8 @@ describe('Placement Ordering', () => { beforeEach(() => { onModelChanged = jest.fn(); onConfigurationChanged = jest.fn(); - model = _.cloneDeep(defaultValues.model); - configuration = _.cloneDeep(defaultValues.configuration); + model = cloneDeep(defaultValues.model); + configuration = cloneDeep(defaultValues.configuration); }); describe('logic', () => { diff --git a/packages/placement-ordering/configure/src/choice-editor.jsx b/packages/placement-ordering/configure/src/choice-editor.jsx index b6d051769e..a791c2c130 100644 --- a/packages/placement-ordering/configure/src/choice-editor.jsx +++ b/packages/placement-ordering/configure/src/choice-editor.jsx @@ -1,8 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import debug from 'debug'; -import shuffle from 'lodash/shuffle'; -import isEqual from 'lodash/isEqual'; +import { isEqual, shuffle } from 'lodash-es'; import Button from '@mui/material/Button'; import { styled } from '@mui/material/styles'; import { InputContainer } from '@pie-lib/render-ui'; @@ -218,17 +217,11 @@ class ChoiceEditor extends React.Component { {orderError && {orderError}} - + {`SHUFFLE ${pluralChoiceLabel}`.toUpperCase()} - + {`ADD ${singularChoiceLabel}`.toUpperCase()} diff --git a/packages/placement-ordering/configure/src/design.jsx b/packages/placement-ordering/configure/src/design.jsx index 633b3fa6b4..eebcf01352 100644 --- a/packages/placement-ordering/configure/src/design.jsx +++ b/packages/placement-ordering/configure/src/design.jsx @@ -1,10 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import debug from 'debug'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep, isEmpty } from 'lodash-es'; import { get, set } from 'nested-property'; import pluralize from 'pluralize'; -import isEmpty from 'lodash/isEmpty'; import { styled } from '@mui/material/styles'; import Info from '@mui/icons-material/Info'; import Tooltip from '@mui/material/Tooltip'; @@ -22,13 +21,13 @@ const { Panel, toggle, radio, dropdown } = settings; const getSingularAndPlural = (label) => !pluralize.isPlural(label) ? { - singularLabel: label, - pluralLabel: pluralize(label), - } + singularLabel: label, + pluralLabel: pluralize(label), + } : { - singularLabel: pluralize.singular(label), - pluralLabel: label, - }; + singularLabel: pluralize.singular(label), + pluralLabel: label, + }; const StyledInputContainer = styled(InputContainer)(({ theme }) => ({ width: '100%', @@ -133,23 +132,23 @@ export class Design extends React.Component { const target = over.data.current; const source = active.data.current; - const rawFrom = ordering.tiles.find(t => t.id === source.id && t.type === source.type); + const rawFrom = ordering.tiles.find((t) => t.id === source.id && t.type === source.type); const rawTo = target; const from = { - ...rawFrom, - index: normalizeIndex(rawFrom, ordering) + ...rawFrom, + index: normalizeIndex(rawFrom, ordering), }; const to = { ...rawTo, - index: normalizeIndex(rawTo, ordering) + index: normalizeIndex(rawTo, ordering), }; const { response, choices: updatedChoices } = updateResponseOrChoices( ordering.response, ordering.choices, from, - to + to, ); this.onChoiceEditorChange(updatedChoices, response); @@ -202,7 +201,7 @@ export class Design extends React.Component { teacherInstructions: teacherInstructionsError, } = errors || {}; - const ordering = { + const ordering = { choices: model.choices, response: !correctResponse || isEmpty(correctResponse) ? new Array(model.choices.length) : correctResponse, tiles: buildTiles(model.choices, correctResponse), @@ -313,23 +312,18 @@ export class Design extends React.Component { )} - + {choiceLabelEnabled && ( - + + { }, - onConfigurationChanged: () => { }, + onModelChanged: () => {}, + onConfigurationChanged: () => {}, }; Design.propTypes = { diff --git a/packages/placement-ordering/configure/src/index.js b/packages/placement-ordering/configure/src/index.js index ac300ca891..b6b145c5a1 100644 --- a/packages/placement-ordering/configure/src/index.js +++ b/packages/placement-ordering/configure/src/index.js @@ -10,7 +10,7 @@ import Main from './design'; import React from 'react'; import { createRoot } from 'react-dom/client'; import defaultValues from './defaults'; -import defaults from 'lodash/defaults'; +import { defaults } from 'lodash-es'; const prepareCustomizationObject = (config, model) => { const configuration = defaults(config, defaultValues.configuration); @@ -118,7 +118,7 @@ export default class PlacementOrdering extends HTMLElement { // check if the language is already included in the languageChoices.options array // and if not, then add it. - if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) { + if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) { this._configuration.languageChoices.options.push({ value: this._model.language, label: this._model.language, diff --git a/packages/placement-ordering/configure/src/utils.js b/packages/placement-ordering/configure/src/utils.js index 345ac38137..73811d5269 100644 --- a/packages/placement-ordering/configure/src/utils.js +++ b/packages/placement-ordering/configure/src/utils.js @@ -1,4 +1,4 @@ -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; export const generateValidationMessage = () => { const answersMessage = @@ -100,4 +100,4 @@ export function buildTiles(choices, response) { }); return processedChoices.concat(targets); -} \ No newline at end of file +} diff --git a/packages/placement-ordering/controller/package.json b/packages/placement-ordering/controller/package.json index 7d96c49e09..ab650238b7 100644 --- a/packages/placement-ordering/controller/package.json +++ b/packages/placement-ordering/controller/package.json @@ -10,6 +10,6 @@ "@pie-lib/translator": "3.1.1-next.0", "debug": "^4.1.1", "js-combinatorics": "^0.5.4", - "lodash": "^4.17.23" + "lodash-es": "^4.17.23" } } diff --git a/packages/placement-ordering/controller/src/__tests__/index.test.js b/packages/placement-ordering/controller/src/__tests__/index.test.js index 12669cb004..578b095349 100644 --- a/packages/placement-ordering/controller/src/__tests__/index.test.js +++ b/packages/placement-ordering/controller/src/__tests__/index.test.js @@ -1,9 +1,9 @@ -import _ from 'lodash'; +import { isFunction, merge } from 'lodash-es'; import * as controller from '../index'; describe('index', () => { let base = (o) => { - o = _.merge( + o = merge( { prompt: 'hi', promptEnabled: true, @@ -11,7 +11,7 @@ describe('index', () => { correctResponse: [], feedbackEnabled: true, }, - o + o, ); return o; }; @@ -19,14 +19,14 @@ describe('index', () => { describe('model', () => { let assertModel = (q, s, e, partialExpected) => { return async () => { - if (_.isFunction(partialExpected) && partialExpected.name === 'Error') { + if (isFunction(partialExpected) && partialExpected.name === 'Error') { expect(() => controller.model(q, s, e)).toThrow(Error); return Promise.resolve(); } else { const result = await controller.model(q, s, e); - if (_.isFunction(partialExpected)) { + if (isFunction(partialExpected)) { return partialExpected(result); } else { expect(result).toMatchObject(partialExpected); @@ -37,22 +37,16 @@ describe('index', () => { it( 'returns prompt', - assertModel(base(), {}, {}, (m) => expect(m.prompt).toEqual('hi')) + assertModel(base(), {}, {}, (m) => expect(m.prompt).toEqual('hi')), ); - it( - 'returns empty config for mode=gather', - assertModel(base(), {}, { mode: 'gather' }, {}) - ); + it('returns empty config for mode=gather', assertModel(base(), {}, { mode: 'gather' }, {})); - it( - 'returns empty config for mode=view', - assertModel(base(), {}, { mode: 'view' }, { disabled: true }) - ); + it('returns empty config for mode=view', assertModel(base(), {}, { mode: 'view' }, { disabled: true })); it( 'returns config.disabled=true for mode=evaluate', - assertModel(base(), {}, { mode: 'evaluate' }, { disabled: true }) + assertModel(base(), {}, { mode: 'evaluate' }, { disabled: true }), ); it( @@ -64,8 +58,8 @@ describe('index', () => { }), { value: ['a', 'b'] }, { mode: 'evaluate' }, - { feedback: 'foo' } - ) + { feedback: 'foo' }, + ), ); describe('choices and outcomes', () => { @@ -96,8 +90,8 @@ describe('index', () => { { id: 'b', label: 'b' }, { label: 'c', id: 'c' }, ], - } - ) + }, + ), ); // Main Correct Response @@ -109,7 +103,7 @@ describe('index', () => { { id: 'b', outcome: 'correct' }, { id: 'c', outcome: 'correct' }, ], - }) + }), ); // Alternate Correct Response @@ -121,7 +115,7 @@ describe('index', () => { { id: 'b', outcome: 'correct' }, { id: 'a', outcome: 'correct' }, ], - }) + }), ); // Main Correct Response @@ -129,7 +123,7 @@ describe('index', () => { 'returns outcomes - 1 correct', assertModel(model, { value: ['a'] }, env, { outcomes: [{ id: 'a', outcome: 'correct' }], - }) + }), ); // Alternate Correct Response @@ -137,13 +131,10 @@ describe('index', () => { 'returns outcomes for alternate - 1 correct', assertModel(model, { value: ['c'] }, env, { outcomes: [{ id: 'c', outcome: 'correct' }], - }) + }), ); - it( - 'does not return config.correctResponse - 1 correct', - assertModel(model, session, env, { disabled: true }) - ); + it('does not return config.correctResponse - 1 correct', assertModel(model, session, env, { disabled: true })); it( 'returns outcomes - 2 incorrect', @@ -152,27 +143,21 @@ describe('index', () => { { id: 'b', outcome: 'incorrect' }, { id: 'a', outcome: 'incorrect' }, ], - }) + }), ); it( 'returns config.correctResponse - 2 - incorrect', assertModel(model, { value: ['b', 'a'] }, env, { correctResponse: ['a', 'b', 'c'], - }) + }), ); }); describe('session not set', () => { const assertModelCorrectness = (session) => { - it(`returns correctness: incorrect of session is ${JSON.stringify( - session - )}`, async () => { - const m = await controller.model( - base({ correctResponse: ['a', 'b'] }), - session, - { mode: 'evaluate' } - ); + it(`returns correctness: incorrect of session is ${JSON.stringify(session)}`, async () => { + const m = await controller.model(base({ correctResponse: ['a', 'b'] }), session, { mode: 'evaluate' }); expect(m.correctness).toEqual('incorrect'); }); }; @@ -240,7 +225,7 @@ describe('index', () => { describe('outcome', () => { const assertOutcome = (question, value, expectedScore, env) => { it(`${expectedScore} when answer: ${value} and question: ${JSON.stringify( - question + question, )}, env: ${JSON.stringify(env)}`, async () => { const result = await controller.outcome(question, { value }, env); expect(result.score).toEqual(expectedScore); @@ -248,17 +233,11 @@ describe('index', () => { }; const assertOutcomeError = (question, session, env) => { it(`throws error for ${JSON.stringify(question)}`, () => - expect(controller.outcome(question, session, env)).rejects.toThrow( - controller.questionError() - )); + expect(controller.outcome(question, session, env)).rejects.toThrow(controller.questionError())); }; const assertOutcomeSessionNotset = (session) => { - it(`return score: 0 and empty: true if session is ${JSON.stringify( - session - )}`, () => - expect( - controller.outcome({}, session, { mode: 'evaluate' }) - ).resolves.toEqual({ score: 0, empty: true })); + it(`return score: 0 and empty: true if session is ${JSON.stringify(session)}`, () => + expect(controller.outcome({}, session, { mode: 'evaluate' })).resolves.toEqual({ score: 0, empty: true })); }; assertOutcomeError(null, { value: [] }, {}); @@ -277,7 +256,7 @@ describe('index', () => { alternateResponses: [{ response: ['c'] }], }, ['a'], - 1 + 1, ); assertOutcome( { @@ -286,7 +265,7 @@ describe('index', () => { alternateResponses: [{ response: ['c'] }], }, ['b'], - 0 + 0, ); assertOutcome( { @@ -294,20 +273,16 @@ describe('index', () => { alternateResponses: [{ response: ['b', 'c', 'a'] }], }, ['c', 'a', 'b'], - 0.33 - ); - assertOutcome( - { correctResponse: ['a', 'b'], alternateResponses: [['c', 'b']] }, - ['c', 'a', 'b'], - 0 + 0.33, ); + assertOutcome({ correctResponse: ['a', 'b'], alternateResponses: [['c', 'b']] }, ['c', 'a', 'b'], 0); assertOutcome( { correctResponse: ['a', 'b', 'c'], alternateResponses: [{ response: ['a', 'c', 'b'] }], }, ['a', 'b'], - 0.33 + 0.33, ); assertOutcome( { @@ -316,7 +291,7 @@ describe('index', () => { alternateResponses: [{ response: ['a', 'b'] }], }, ['c', 'a', 'b'], - 0.33 + 0.33, ); assertOutcome( { @@ -325,7 +300,7 @@ describe('index', () => { alternateResponses: [{ response: ['a', 'c', 'b'] }], }, ['a', 'b'], - 0 + 0, ); assertOutcome( { @@ -335,7 +310,7 @@ describe('index', () => { }, ['c', 'a', 'b'], 0, - { partialScoring: true } + { partialScoring: true }, ); // Alternate Correct Response @@ -346,7 +321,7 @@ describe('index', () => { alternateResponses: [{ response: ['c'] }], }, ['c'], - 1 + 1, ); assertOutcome( { @@ -355,7 +330,7 @@ describe('index', () => { alternateResponses: [{ response: ['c'] }], }, ['b'], - 0 + 0, ); assertOutcome( { @@ -363,20 +338,16 @@ describe('index', () => { alternateResponses: [{ response: ['c', 'b', 'a'] }], }, ['c', 'a', 'b'], - 0.67 - ); - assertOutcome( - { correctResponse: ['a', 'b'], alternateResponses: [{ response: ['c', 'b'] }] }, - ['c', 'a', 'b'], - 0 + 0.67, ); + assertOutcome({ correctResponse: ['a', 'b'], alternateResponses: [{ response: ['c', 'b'] }] }, ['c', 'a', 'b'], 0); assertOutcome( { correctResponse: ['a', 'b', 'c'], alternateResponses: [{ response: ['c', 'b', 'a'] }], }, ['c', 'b'], - 0.33 + 0.33, ); assertOutcome( { @@ -385,7 +356,7 @@ describe('index', () => { alternateResponses: [{ response: ['a', 'c', 'b'] }], }, ['c', 'a', 'b'], - 0.67 + 0.67, ); assertOutcome( { @@ -394,7 +365,7 @@ describe('index', () => { alternateResponses: [{ response: ['a', 'c', 'b'] }], }, ['a', 'b'], - 0 + 0, ); assertOutcome( { @@ -404,7 +375,7 @@ describe('index', () => { }, ['c', 'a', 'b'], 0, - { partialScoring: true } + { partialScoring: true }, ); }); }); diff --git a/packages/placement-ordering/controller/src/__tests__/scoring.test.js b/packages/placement-ordering/controller/src/__tests__/scoring.test.js index b91458797d..12490b8aaf 100644 --- a/packages/placement-ordering/controller/src/__tests__/scoring.test.js +++ b/packages/placement-ordering/controller/src/__tests__/scoring.test.js @@ -1,5 +1,5 @@ import { flattenCorrect, score, pairwiseCombinationScore, illegalArgumentError } from '../scoring'; -import _ from 'lodash'; +import { cloneDeep, merge } from 'lodash-es'; describe('pairwiseCombinationScore', () => { const assertScore = (correctResponse, opts) => (answer, expectedScore) => { @@ -113,7 +113,7 @@ describe('score', () => { }; describe('partial scoring', () => { - let question = _.merge(_.cloneDeep(baseQuestion), { + let question = merge(cloneDeep(baseQuestion), { partialScoring: true, }); diff --git a/packages/placement-ordering/controller/src/index.js b/packages/placement-ordering/controller/src/index.js index f4d7d87a90..c2029a68a3 100644 --- a/packages/placement-ordering/controller/src/index.js +++ b/packages/placement-ordering/controller/src/index.js @@ -1,13 +1,11 @@ import { flattenCorrect, getAllCorrectResponses, score } from './scoring'; -import _ from 'lodash'; +import { every, isArray, isEmpty, isEqual, map, reduce } from 'lodash-es'; import { getFeedbackForCorrectness } from '@pie-lib/feedback'; import { partialScoring } from '@pie-lib/controller-utils'; import debug from 'debug'; import defaults from './defaults'; -import isEqual from 'lodash/isEqual'; -import isEmpty from 'lodash/isEmpty'; const log = debug('@pie-element:placement-ordering:controller'); import Translator from '@pie-lib/translator'; @@ -18,11 +16,11 @@ export const questionError = () => new Error('Question is missing required array export function outcome(question, session, env) { return new Promise((resolve, reject) => { - if (!session || _.isEmpty(session)) { + if (!session || isEmpty(session)) { resolve({ score: 0, empty: true }); } - if (!question || !question.correctResponse || _.isEmpty(question.correctResponse)) { + if (!question || !question.correctResponse || isEmpty(question.correctResponse)) { reject(questionError()); } else { try { @@ -64,106 +62,105 @@ export const normalize = (question) => ({ * @param {*} env */ export async function model(question, session, env) { - const normalizedQuestion = normalize(question); - const base = {}; + const normalizedQuestion = normalize(question); + const base = {}; - if (question.alternateResponses && _.every(question.alternateResponses, _.isArray)) { - log('Deprecated structure of alternateResponses is in use'); - // eslint-disable-next-line no-console - console.error('Deprecated structure of alternateResponses is in use'); - } + if (question.alternateResponses && every(question.alternateResponses, isArray)) { + log('Deprecated structure of alternateResponses is in use'); + // eslint-disable-next-line no-console + console.error('Deprecated structure of alternateResponses is in use'); + } - base.env = env; - base.extraCSSRules = normalizedQuestion.extraCSSRules; - base.outcomes = []; - base.completeLength = (normalizedQuestion.correctResponse || []).length; - base.choices = (normalizedQuestion.choices || []).filter((choice) => choice.label); - base.note = normalizedQuestion.note; - base.showNote = normalizedQuestion.alternateResponses && normalizedQuestion.alternateResponses.length > 0; - base.language = normalizedQuestion.language; - - log('[model] removing tileSize for the moment.'); - - base.prompt = normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null; - base.config = { - orientation: normalizedQuestion.orientation || 'vertical', - includeTargets: normalizedQuestion.placementArea, - choiceLabelEnabled: normalizedQuestion.choiceLabelEnabled, - targetLabel: normalizedQuestion.targetLabel, - choiceLabel: normalizedQuestion.choiceLabel, - showOrdering: normalizedQuestion.numberedGuides, - allowSameChoiceInTargets: !normalizedQuestion.removeTilesAfterPlacing, - }; - - base.disabled = env.mode !== 'gather'; - - if (!base.note) { - base.note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language }); - } + base.env = env; + base.extraCSSRules = normalizedQuestion.extraCSSRules; + base.outcomes = []; + base.completeLength = (normalizedQuestion.correctResponse || []).length; + base.choices = (normalizedQuestion.choices || []).filter((choice) => choice.label); + base.note = normalizedQuestion.note; + base.showNote = normalizedQuestion.alternateResponses && normalizedQuestion.alternateResponses.length > 0; + base.language = normalizedQuestion.language; + + log('[model] removing tileSize for the moment.'); + + base.prompt = normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null; + base.config = { + orientation: normalizedQuestion.orientation || 'vertical', + includeTargets: normalizedQuestion.placementArea, + choiceLabelEnabled: normalizedQuestion.choiceLabelEnabled, + targetLabel: normalizedQuestion.targetLabel, + choiceLabel: normalizedQuestion.choiceLabel, + showOrdering: normalizedQuestion.numberedGuides, + allowSameChoiceInTargets: !normalizedQuestion.removeTilesAfterPlacing, + }; + + base.disabled = env.mode !== 'gather'; + + if (!base.note) { + base.note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language }); + } - if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) { - base.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null; - base.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled - ? normalizedQuestion.teacherInstructions - : null; - } else { - base.rationale = null; - base.teacherInstructions = null; - } + if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) { + base.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null; + base.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled + ? normalizedQuestion.teacherInstructions + : null; + } else { + base.rationale = null; + base.teacherInstructions = null; + } - if (env.mode === 'evaluate') { - const value = (session && session.value) || []; - const allCorrectResponses = getAllCorrectResponses(normalizedQuestion); - - const bestSetOfResponses = allCorrectResponses.reduce( - (info, cr) => { - const currentScore = _.reduce(value, (acc, c, idx) => acc + (Array.isArray(cr) && cr[idx] === c ? 1 : 0), 0); - - if (currentScore > info.score) { - return { - arr: cr, - score: currentScore, - }; - } - - return info; - }, - { arr: [], score: 0 }, - ); - - base.outcomes = _.map(value, (c, idx) => { - return { - id: c, - outcome: bestSetOfResponses.arr[idx] === c ? 'correct' : 'incorrect', - }; - }); + if (env.mode === 'evaluate') { + const value = (session && session.value) || []; + const allCorrectResponses = getAllCorrectResponses(normalizedQuestion); + + const bestSetOfResponses = allCorrectResponses.reduce( + (info, cr) => { + const currentScore = reduce(value, (acc, c, idx) => acc + (Array.isArray(cr) && cr[idx] === c ? 1 : 0), 0); + + if (currentScore > info.score) { + return { + arr: cr, + score: currentScore, + }; + } + + return info; + }, + { arr: [], score: 0 }, + ); + + base.outcomes = map(value, (c, idx) => { + return { + id: c, + outcome: bestSetOfResponses.arr[idx] === c ? 'correct' : 'incorrect', + }; + }); - const isResponseCorrect = allCorrectResponses.some((response) => _.isEqual(response, value)); - const responseScore = score(question, session); - const isCorrect = responseScore === 1; - const isPartialCorrect = - !isCorrect && partialScoring.enabled(normalizedQuestion, env || {}) && responseScore !== 0; + const isResponseCorrect = allCorrectResponses.some((response) => isEqual(response, value)); + const responseScore = score(question, session); + const isCorrect = responseScore === 1; + const isPartialCorrect = !isCorrect && partialScoring.enabled(normalizedQuestion, env || {}) && responseScore !== 0; - base.correctness = isCorrect ? 'correct' : isPartialCorrect ? 'partial' : 'incorrect'; + base.correctness = isCorrect ? 'correct' : isPartialCorrect ? 'partial' : 'incorrect'; - if (!isResponseCorrect) { - base.correctResponse = flattenCorrect(normalizedQuestion); - } + if (!isResponseCorrect) { + base.correctResponse = flattenCorrect(normalizedQuestion); + } - // requirement made in PD-2182 - if (!normalizedQuestion.feedback) { - normalizedQuestion.feedbackEnabled = false; - } + // requirement made in PD-2182 + if (!normalizedQuestion.feedback) { + normalizedQuestion.feedbackEnabled = false; + } - const feedback = normalizedQuestion.feedbackEnabled - ? await getFeedbackForCorrectness(base.correctness, normalizedQuestion.feedback) - : undefined; + const feedback = normalizedQuestion.feedbackEnabled + ? await getFeedbackForCorrectness(base.correctness, normalizedQuestion.feedback) + : undefined; - base.feedback = feedback; - return base; - } else { - return base; - } + base.feedback = feedback; + return base; + } else { + return base; + } } export const createCorrectResponseSession = (question, env) => { diff --git a/packages/placement-ordering/controller/src/scoring.js b/packages/placement-ordering/controller/src/scoring.js index 07dea69318..b4deb05a94 100644 --- a/packages/placement-ordering/controller/src/scoring.js +++ b/packages/placement-ordering/controller/src/scoring.js @@ -1,4 +1,4 @@ -import _ from 'lodash'; +import { differenceWith, isEqual, uniq } from 'lodash-es'; import { combination } from 'js-combinatorics'; import debug from 'debug'; @@ -9,15 +9,15 @@ export const illegalArgumentError = (answer) => export const pairwiseCombinationScore = (correct, answer, opts) => { opts = { allowDuplicates: false, orderMustBeComplete: false, ...opts }; - if (!opts.allowDuplicates && !_.isEqual(_.uniq(correct), correct)) { + if (!opts.allowDuplicates && !isEqual(uniq(correct), correct)) { throw illegalArgumentError(answer); } - if (opts.allowDuplicates === false && answer.length !== _.uniq(answer).length) { + if (opts.allowDuplicates === false && answer.length !== uniq(answer).length) { return 0; } - answer = opts.allowDuplicates !== false ? answer : _.uniq(answer); + answer = opts.allowDuplicates !== false ? answer : uniq(answer); log('answer:', answer); if (!Array.isArray(correct) || correct.length === 0) { @@ -25,7 +25,7 @@ export const pairwiseCombinationScore = (correct, answer, opts) => { } if (correct.length === 1) { - return _.isEqual(correct, answer) ? 1 : 0; + return isEqual(correct, answer) ? 1 : 0; } if (!Array.isArray(answer) || answer.length < 2) { @@ -43,7 +43,7 @@ export const pairwiseCombinationScore = (correct, answer, opts) => { const correctCombo = combination(correct, 2).toArray(); const answerCombo = combination(answer, 2).toArray(); - const diff = _.differenceWith(answerCombo, correctCombo, _.isEqual); + const diff = differenceWith(answerCombo, correctCombo, isEqual); const comboLengthDiff = correctCombo.length - answerCombo.length; @@ -67,13 +67,15 @@ export const flattenCorrect = (question) => * @param question - array */ export const getAllCorrectResponses = (question) => { - const alternates = (question.alternateResponses || []).map((alternate) => { - if (Array.isArray(alternate)) { - return alternate; - } - - return alternate.response; - }).filter(item => item !== undefined); + const alternates = (question.alternateResponses || []) + .map((alternate) => { + if (Array.isArray(alternate)) { + return alternate; + } + + return alternate.response; + }) + .filter((item) => item !== undefined); return [flattenCorrect(question), ...alternates]; }; diff --git a/packages/placement-ordering/package.json b/packages/placement-ordering/package.json index 1658dac227..78ab4e5f12 100644 --- a/packages/placement-ordering/package.json +++ b/packages/placement-ordering/package.json @@ -20,7 +20,7 @@ "@pie-lib/translator": "3.1.1-next.0", "debug": "^4.1.1", "decimal.js": "^10.0.0", - "lodash": "^4.17.23", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.3.1", "react-dom": "18.3.1", diff --git a/packages/placement-ordering/src/__tests__/ordering.test.js b/packages/placement-ordering/src/__tests__/ordering.test.js index 7026f1dcd0..0e7cd4c8bd 100644 --- a/packages/placement-ordering/src/__tests__/ordering.test.js +++ b/packages/placement-ordering/src/__tests__/ordering.test.js @@ -1,5 +1,5 @@ import { buildState, reducer } from '../ordering'; -import _ from 'lodash'; +import { chunk, take } from 'lodash-es'; describe('ordering', () => { const toLabel = (a) => `${a[0]}->${a[1]}`; @@ -57,7 +57,7 @@ describe('ordering', () => { `${i.tiles.map((t) => t.id)} + ${actions.map(toLabel).join(', ')} = ${e}`; const assertMoveLabel = (i, actions, expected) => { - const tiles = _.take(i.tiles, 4).map((t) => t.id); + const tiles = take(i.tiles, 4).map((t) => t.id); return `${tiles} + ${actions.map(toLabel)} = ${expected.choices.map((c) => c || '_')}|${expected.targets.map( (t) => t || '_', @@ -140,7 +140,7 @@ describe('ordering', () => { const label = assertMoveLabel(state, actions, expected); it(label, () => { - let [choiceTiles, targetTiles] = _.chunk(state.tiles, 4); + let [choiceTiles, targetTiles] = chunk(state.tiles, 4); expect(choiceTiles.map((t) => t.id)).toEqual(expected.choices); expect(targetTiles.map((t) => t.id)).toEqual(expected.targets); diff --git a/packages/placement-ordering/src/index.js b/packages/placement-ordering/src/index.js index 8d575be87d..454f044747 100644 --- a/packages/placement-ordering/src/index.js +++ b/packages/placement-ordering/src/index.js @@ -1,6 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import compact from 'lodash/compact'; +import { compact } from 'lodash-es'; import debug from 'debug'; import { renderMath } from '@pie-lib/math-rendering'; import { SessionChangedEvent } from '@pie-framework/pie-player-events'; diff --git a/packages/placement-ordering/src/ordering.js b/packages/placement-ordering/src/ordering.js index 7f0962fe08..9b37eadc36 100644 --- a/packages/placement-ordering/src/ordering.js +++ b/packages/placement-ordering/src/ordering.js @@ -1,8 +1,5 @@ -import cloneDeep from 'lodash/cloneDeep'; +import { assign, cloneDeep, isEmpty, map } from 'lodash-es'; import debug from 'debug'; -import isEmpty from 'lodash/isEmpty'; -import map from 'lodash/map'; -import assign from 'lodash/assign'; const log = debug('pie-elements:placement-ordering:ordering'); diff --git a/packages/placement-ordering/src/placement-ordering.jsx b/packages/placement-ordering/src/placement-ordering.jsx index 99aeaa737e..cedd7e4c8d 100644 --- a/packages/placement-ordering/src/placement-ordering.jsx +++ b/packages/placement-ordering/src/placement-ordering.jsx @@ -2,9 +2,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import debug from 'debug'; -import uniqueId from 'lodash/uniqueId'; -import isEqual from 'lodash/isEqual'; -import difference from 'lodash/difference'; +import { difference, isEqual, uniqueId } from 'lodash-es'; import { styled } from '@mui/material/styles'; import { closestCenter } from '@dnd-kit/core'; @@ -244,18 +242,18 @@ export class PlacementOrdering extends React.Component { return showingCorrect ? buildState( - model.choices, - model.correctResponse, - model.correctResponse.map((id) => ({ id, outcome: 'correct' })), - { + model.choices, + model.correctResponse, + model.correctResponse.map((id) => ({ id, outcome: 'correct' })), + { + includeTargets, + allowSameChoiceInTargets: model.config.allowSameChoiceInTargets, + }, + ) + : buildState(model.choices, session.value, model.outcomes, { includeTargets, allowSameChoiceInTargets: model.config.allowSameChoiceInTargets, - }, - ) - : buildState(model.choices, session.value, model.outcomes, { - includeTargets, - allowSameChoiceInTargets: model.config.allowSameChoiceInTargets, - }); + }); }; onDragEnd = (event) => { @@ -280,7 +278,7 @@ export class PlacementOrdering extends React.Component { this.onRemoveChoice(draggedItem, ordering); } } - } + }; render() { const { model } = this.props; @@ -365,7 +363,10 @@ export class PlacementOrdering extends React.Component { {displayNote && } {showRationale && ( - + )} diff --git a/packages/rubric/controller/package.json b/packages/rubric/controller/package.json index 973814b76d..84e5d29315 100644 --- a/packages/rubric/controller/package.json +++ b/packages/rubric/controller/package.json @@ -7,6 +7,6 @@ "test": "./node_modules/.bin/jest" }, "dependencies": { - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" } } diff --git a/packages/rubric/src/print.js b/packages/rubric/src/print.js index 7b7243686f..2d32ca376e 100644 --- a/packages/rubric/src/print.js +++ b/packages/rubric/src/print.js @@ -1,6 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import Main from './main'; import { renderMath } from '@pie-lib/math-rendering'; import debug from 'debug'; diff --git a/packages/select-text/configure/package.json b/packages/select-text/configure/package.json index 0c831a765f..d8b4dce4b0 100644 --- a/packages/select-text/configure/package.json +++ b/packages/select-text/configure/package.json @@ -15,7 +15,7 @@ "@pie-lib/editable-html-tip-tap": "1.1.1-next.1", "@pie-lib/text-select": "2.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15", + "lodash-es": "^4.17.23", "prop-types": "^15.8.1", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/packages/select-text/configure/src/__tests__/design.test.jsx b/packages/select-text/configure/src/__tests__/design.test.jsx index d324aac23f..e2c3d00c9d 100644 --- a/packages/select-text/configure/src/__tests__/design.test.jsx +++ b/packages/select-text/configure/src/__tests__/design.test.jsx @@ -18,7 +18,10 @@ jest.mock('@pie-lib/config-ui', () => ({ }, })); -jest.mock('lodash/debounce', () => (fn) => fn); +jest.mock('lodash-es', () => ({ + debounce: jest.fn((fn) => fn), + cloneDeep: jest.fn((value) => JSON.parse(JSON.stringify(value))), +})); describe('design', () => { let w; diff --git a/packages/select-text/configure/src/design.jsx b/packages/select-text/configure/src/design.jsx index 79bf8cdfe3..45d0d4ae9f 100644 --- a/packages/select-text/configure/src/design.jsx +++ b/packages/select-text/configure/src/design.jsx @@ -2,8 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import TextField from '@mui/material/TextField'; import { styled } from '@mui/material/styles'; -import cloneDeep from 'lodash/cloneDeep'; -import debounce from 'lodash/debounce'; +import { cloneDeep, debounce } from 'lodash-es'; import { Tokenizer } from '@pie-lib/text-select'; import { InputContainer, NumberTextField, FeedbackConfig, settings, layout } from '@pie-lib/config-ui'; import Chip from '@mui/material/Chip'; @@ -342,38 +341,23 @@ export class Design extends React.Component { {tokens.settings && ( - + - + )} {tokensError && {tokensError}} {selectionsError && {selectionsError}} - {mode.settings && ( - - )} + {mode.settings && } - {selections.settings && ( - - )} + {selections.settings && } {correctAnswer.settings && ( - t.correct).length}`} - /> + t.correct).length}`} /> )} {selectionCount.settings && ( diff --git a/packages/select-text/controller/package.json b/packages/select-text/controller/package.json index 38c2331fa3..56f1327860 100644 --- a/packages/select-text/controller/package.json +++ b/packages/select-text/controller/package.json @@ -9,11 +9,9 @@ "@pie-lib/controller-utils": "1.1.1-next.0", "@pie-lib/feedback": "1.1.1-next.0", "debug": "^4.1.1", - "lodash": "^4.17.15" - }, - "devDependencies": { - "lodash": "^4.17.15" + "lodash-es": "^4.17.23" }, + "devDependencies": {}, "author": "", "license": "ISC" } diff --git a/packages/select-text/controller/src/__tests__/index.test.js b/packages/select-text/controller/src/__tests__/index.test.js index 6e6d82e156..531480ace4 100644 --- a/packages/select-text/controller/src/__tests__/index.test.js +++ b/packages/select-text/controller/src/__tests__/index.test.js @@ -1,5 +1,5 @@ import { getPartialScore, getCorrectness, model, outcome, createCorrectResponseSession } from '../index'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; jest.mock('@pie-lib/text-select', () => ({ prepareText: jest.fn(), diff --git a/packages/select-text/controller/src/index.js b/packages/select-text/controller/src/index.js index 76d496ace4..c7e96b30f2 100644 --- a/packages/select-text/controller/src/index.js +++ b/packages/select-text/controller/src/index.js @@ -1,5 +1,5 @@ import debug from 'debug'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { getFeedbackForCorrectness } from '@pie-lib/feedback'; import { partialScoring } from '@pie-lib/controller-utils'; import defaults from './defaults'; diff --git a/packages/select-text/src/print.js b/packages/select-text/src/print.js index 730013a574..2a6f6607ce 100644 --- a/packages/select-text/src/print.js +++ b/packages/select-text/src/print.js @@ -1,6 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import Main from './main'; import { renderMath } from '@pie-lib/math-rendering'; import debug from 'debug'; diff --git a/pslb/pslb.config.js b/pslb/pslb.config.js index fcbccc8cd7..66b3260ed7 100644 --- a/pslb/pslb.config.js +++ b/pslb/pslb.config.js @@ -1,6 +1,5 @@ const path = require('path'); const fs = require('fs-extra'); -const _ = require('lodash'); const blacklist = ['pie-models', 'math-inline', 'protractor', 'ruler', 'calculator', 'select-text']; @@ -12,20 +11,19 @@ const listPackages = () => { const files = fs.readdirSync(packagesDir); - return _.compact( - files - .filter((f) => !f.includes('@')) - - .filter((f) => !blacklist.includes(f)) - .map((f) => { - try { - const rootPkg = fs.readJsonSync(path.join(packagesDir, f, 'package.json')); - return rootPkg.name; - } catch (e) { - console.warn(`error for: ${f}, ${e.message}`); - } - }), - ); + return files + .filter((f) => !f.includes('@')) + .filter((f) => !blacklist.includes(f)) + .map((f) => { + try { + const rootPkg = fs.readJsonSync(path.join(packagesDir, f, 'package.json')); + return rootPkg.name; + } catch (e) { + console.warn(`error for: ${f}, ${e.message}`); + return null; + } + }) + .filter(Boolean); }; module.exports = { diff --git a/scripts/build b/scripts/build index 7d631fc040..4ee8761237 100755 --- a/scripts/build +++ b/scripts/build @@ -4,7 +4,6 @@ const debug = require('debug'); const log = debug('pie-element:scripts:build'); const argv = require('minimist')(process.argv.slice(2)); const { readdirSync, pathExistsSync, readJson } = require('fs-extra'); -const _ = require('lodash'); const { Commands, getPackage } = require('@pie-framework/build-helper'); const { resolve, relative, join } = require('path'); const minimist = require('minimist'); @@ -14,8 +13,7 @@ const toPkgFlag = (p) => `--package ${p.pkg.name}`; const args = minimist(process.argv.slice(2)); -const r = (...parts) => - resolve.apply(null, [__dirname, '..', 'packages'].concat(parts)); +const r = (...parts) => resolve.apply(null, [__dirname, '..', 'packages'].concat(parts)); const rel = (p) => relative(resolve(__dirname, '..'), p); @@ -36,7 +34,7 @@ const expandPkg = (d) => { const getElementPackages = (dir) => { const dirs = readdirSync(dir); - const all = _.flatten(dirs.map((d) => expandPkg(d))); + const all = dirs.map((d) => expandPkg(d)).flat(); const out = all.map(getPackage); return out; }; @@ -56,7 +54,7 @@ class ElementsCommands extends Commands { const cwd = resolve(__dirname, '..', p.dir); log('cwd:', cwd); return this.runCmd('rm -fr lib', { cwd }); - }) + }), ); } @@ -67,20 +65,16 @@ class ElementsCommands extends Commands { allPackages.map(async (n) => { const dir = resolve(root, n); return { dir, pkg: await readJson(resolve(dir, 'package.json')) }; - }) + }), ); - const printPkgs = pkgJson.filter( - (p) => p.pkg.exports && p.pkg.exports['./print'] - ); + const printPkgs = pkgJson.filter((p) => p.pkg.exports && p.pkg.exports['./print']); console.log( 'printPkgs', - printPkgs.map((p) => p.dir) + printPkgs.map((p) => p.dir), ); - const cmd = `yarn pslb --config pslb/pslb.config.js ${printPkgs - .map(toPkgFlag) - .join(' ')} --logLevel silly`; + const cmd = `yarn pslb --config pslb/pslb.config.js ${printPkgs.map(toPkgFlag).join(' ')} --logLevel silly`; return this.runCmd(cmd); } @@ -90,22 +84,32 @@ class ElementsCommands extends Commands { } async babel() { - const packages = getElementPackages(join(this.projectRoot, 'packages')) - .filter((p) => pathExistsSync(join(p.dir, 'src'))); - + const packages = getElementPackages(join(this.projectRoot, 'packages')).filter((p) => + pathExistsSync(join(p.dir, 'src')), + ); + + // Splits an array into chunks of a given size. Equivalent to lodash's `chunk` for normal usage. + const chunk = (arr, size) => { + const out = []; + for (let i = 0; i < arr.length; i += size) { + out.push(arr.slice(i, i + size)); + } + return out; + }; + // Process packages in batches to avoid OOM in CI environments // Each babel process spawns a new Node.js process, so running // all in parallel can exhaust memory. Batches of 3 balance speed and memory. const batchSize = 3; - const batches = _.chunk(packages, batchSize); - + const batches = chunk(packages, batchSize); + for (const batch of batches) { await Promise.all( batch.map((p) => { const cwd = resolve(__dirname, '..', p.dir); const cmd = `${this.p.babel} --ignore '**/__test__/**','**/__tests__/**','**/__mocks__/**' src -d lib --source-maps --root-mode upward`; return this.runCmd(cmd, { cwd }); - }) + }), ); } } diff --git a/scripts/fix-versions b/scripts/fix-versions index 4e57fda408..cb928b715e 100755 --- a/scripts/fix-versions +++ b/scripts/fix-versions @@ -6,7 +6,6 @@ const { execSync } = require('child_process'); const minimist = require('minimist'); const args = minimist(process.argv.slice(2)); const semver = require('semver'); -const _ = require('lodash'); console.log('fix versions'); const dirs = fs.readdirSync('packages'); @@ -30,18 +29,11 @@ dirs if (index >= 0) { console.log(pkg.name, pkg.version, 'needs fixing'); - const versions = _(rows) + const versions = rows .filter((r) => r.startsWith(`${pkg.name}@`)) .map((r) => r.replace(`${pkg.name}@`, '')) .filter(semver.valid) - .sort(semver.compare) - .value(); - // const versions = rows - // .filter((r) => { - // return r.startsWith(`${pkg.name}@`); - // }) - // .map((r) => r.replace(`${pkg.name}@`, '')) - // .sort(); + .sort(semver.compare); const last = versions[versions.length - 1]; diff --git a/scripts/hooks/shared.js b/scripts/hooks/shared.js index 4646c49e2b..81a9cfb751 100644 --- a/scripts/hooks/shared.js +++ b/scripts/hooks/shared.js @@ -1,7 +1,6 @@ const { execSync } = require('child_process'); const { readdirSync, readJsonSync, writeJsonSync, readFileSync, pathExistsSync } = require('fs-extra'); -const _ = require('lodash'); const debug = require('debug'); const chalk = require('chalk'); const minimist = require('minimist'); @@ -29,18 +28,17 @@ const pkgInfo = (dir) => { exports.getPackageFiles = () => { const root = resolve(__dirname, '..', '..', 'packages'); const dirs = readdirSync(root); - return _( - dirs.map((d) => { - const out = []; - out.push(pkgInfo(join(root, d))); - out.push(pkgInfo(join(root, d, 'controller'))); - out.push(pkgInfo(join(root, d, 'configure'))); - return out; - }), - ) - .flatten() - .compact() - .value(); + + return dirs + .map((d) => { + const base = pkgInfo(join(root, d)); + const controller = pkgInfo(join(root, d, 'controller')); + const configure = pkgInfo(join(root, d, 'configure')); + + return [base, controller, configure]; + }) + .flat() + .filter(Boolean); }; const getSatisfyingVersions = async (name, range) => { @@ -103,7 +101,14 @@ exports.checkDependencies = async (lock, i) => { }), ); - const groups = _.groupBy(_.compact(results), (r) => (r.version ? 'fixable' : 'notFixable')); + const groups = results.filter(Boolean).reduce( + (acc, r) => { + const key = r.version ? 'fixable' : 'notFixable'; + acc[key].push(r); + return acc; + }, + { fixable: [], notFixable: [] }, + ); groups.fixable = groups.fixable ? groups.fixable.reduce((acc, d) => { @@ -118,5 +123,6 @@ exports.checkDependencies = async (lock, i) => { return acc; }, {}) : undefined; + return { ...i, ...groups }; }; diff --git a/scripts/rm-bad-versions.js b/scripts/rm-bad-versions.js index 8b9eb0a194..16c2162294 100644 --- a/scripts/rm-bad-versions.js +++ b/scripts/rm-bad-versions.js @@ -3,7 +3,6 @@ const { getPackages } = require('@pie-framework/build-helper'); const { resolve } = require('path'); const { execSync } = require('child_process'); const semver = require('semver'); -const _ = require('lodash'); const pkgs = getPackages(resolve(__dirname, '..', 'packages')); diff --git a/yarn.lock b/yarn.lock index 60a3dfe079..a819d33f48 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3955,12 +3955,14 @@ resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-5.0.0.tgz#21413001973106cda1c3a9b91eedd4ccd5469d76" integrity sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q== -"@types/lodash@^4.14.119": - version "4.17.20" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.20.tgz#1ca77361d7363432d29f5e55950d9ec1e1c6ea93" - integrity sha512-H3MHACvFUEiujabxhaI/ImO6gUrd8oOurg7LQtS7mbwIXA/cUqWrvBsaeJ23aZEPk1TAYkurjfMbSELfoCXlGA== +"@types/lodash-es@^4.17.12": + version "4.17.12" + resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.12.tgz#65f6d1e5f80539aa7cfbfc962de5def0cf4f341b" + integrity sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ== + dependencies: + "@types/lodash" "*" -"@types/lodash@^4.14.172": +"@types/lodash@*", "@types/lodash@^4.14.172": version "4.17.23" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.23.tgz#c1bb06db218acc8fc232da0447473fc2fb9d9841" integrity sha512-RDvF6wTulMPjrNdCoYRC8gNR880JNGT8uB+REUpC2Ns4pRqQJhGz90wh7rgdXDPpCczF3VGktDuFGVnz8zP7HA== @@ -10769,6 +10771,11 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" +lodash-es@^4.17.23: + version "4.17.23" + resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.23.tgz#58c4360fd1b5d33afc6c0bbd3d1149349b1138e0" + integrity sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg== + lodash.camelcase@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"