@pie-element/categorize 6.7.3-next.137 → 6.7.3-next.1370

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +272 -0
  2. package/configure/CHANGELOG.md +223 -0
  3. package/configure/lib/defaults.js +25 -0
  4. package/configure/lib/defaults.js.map +1 -1
  5. package/configure/lib/design/builder.js +8 -5
  6. package/configure/lib/design/builder.js.map +1 -1
  7. package/configure/lib/design/buttons.js +6 -4
  8. package/configure/lib/design/buttons.js.map +1 -1
  9. package/configure/lib/design/categories/alternateResponses.js +12 -4
  10. package/configure/lib/design/categories/alternateResponses.js.map +1 -1
  11. package/configure/lib/design/categories/category.js +16 -4
  12. package/configure/lib/design/categories/category.js.map +1 -1
  13. package/configure/lib/design/categories/choice-preview.js +4 -4
  14. package/configure/lib/design/categories/choice-preview.js.map +1 -1
  15. package/configure/lib/design/categories/droppable-placeholder.js +3 -3
  16. package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
  17. package/configure/lib/design/categories/index.js +91 -10
  18. package/configure/lib/design/categories/index.js.map +1 -1
  19. package/configure/lib/design/choices/choice.js +28 -6
  20. package/configure/lib/design/choices/choice.js.map +1 -1
  21. package/configure/lib/design/choices/config.js +5 -3
  22. package/configure/lib/design/choices/config.js.map +1 -1
  23. package/configure/lib/design/choices/index.js +44 -7
  24. package/configure/lib/design/choices/index.js.map +1 -1
  25. package/configure/lib/design/header.js +15 -5
  26. package/configure/lib/design/header.js.map +1 -1
  27. package/configure/lib/design/index.js +70 -12
  28. package/configure/lib/design/index.js.map +1 -1
  29. package/configure/lib/design/input-header.js +24 -4
  30. package/configure/lib/design/input-header.js.map +1 -1
  31. package/configure/lib/index.js +17 -3
  32. package/configure/lib/index.js.map +1 -1
  33. package/configure/lib/main.js +4 -2
  34. package/configure/lib/main.js.map +1 -1
  35. package/configure/lib/utils.js +20 -0
  36. package/configure/lib/utils.js.map +1 -0
  37. package/configure/package.json +5 -5
  38. package/controller/CHANGELOG.md +47 -0
  39. package/controller/lib/index.js +103 -15
  40. package/controller/lib/index.js.map +1 -1
  41. package/controller/package.json +1 -1
  42. package/docs/config-schema.json +155 -0
  43. package/docs/config-schema.json.md +121 -1
  44. package/docs/demo/generate.js +1 -0
  45. package/docs/pie-schema.json +48 -0
  46. package/docs/pie-schema.json.md +36 -0
  47. package/lib/categorize/categories.js +9 -4
  48. package/lib/categorize/categories.js.map +1 -1
  49. package/lib/categorize/category.js +4 -4
  50. package/lib/categorize/category.js.map +1 -1
  51. package/lib/categorize/choice.js +5 -4
  52. package/lib/categorize/choice.js.map +1 -1
  53. package/lib/categorize/choices.js +12 -5
  54. package/lib/categorize/choices.js.map +1 -1
  55. package/lib/categorize/droppable-placeholder.js +2 -2
  56. package/lib/categorize/droppable-placeholder.js.map +1 -1
  57. package/lib/categorize/grid-content.js +3 -3
  58. package/lib/categorize/grid-content.js.map +1 -1
  59. package/lib/categorize/index.js +11 -15
  60. package/lib/categorize/index.js.map +1 -1
  61. package/lib/index.js +4 -1
  62. package/lib/index.js.map +1 -1
  63. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["getPartialScore","correctResponse","builtCategories","reduce","acc","choices","placements","length","score","filter","ch","correct","maxScore","extraPlacements","totalScore","parseFloat","toFixed","getAlternates","map","c","alternateResponses","alternate","getTotalScore","question","session","env","Object","keys","categories","answers","alternates","enabled","partialScoring","getCorrectness","Promise","resolve","mode","undefined","createDefaultModel","model","defaults","normalize","feedbackEnabled","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","updateSession","normalizedQuestion","answerCorrectness","role","categoriesPerRow","choicesLabel","choicesPosition","feedback","prompt","removeTilesAfterPlacing","rowLabels","rationale","note","teacherInstructions","lockChoiceOrder","fb","out","correctness","disabled","showNote","outcome","reject","Error","empty","createCorrectResponseSession","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA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AX,EAAmB;AAC7D,SAAO,IAAIS,OAAJ,CAAY,UAACC,OAAD,EAAa;AAAA,gBACPV,GAAG,IAAI,EADA;AAAA,QACtBW,IADsB,SACtBA,IADsB;AAAA,QAChBc,IADgB,SAChBA,IADgB;;AAG9B,QAAId,IAAI,KAAK,UAAT,IAAuBc,IAAI,KAAK,YAApC,EAAkD;AAAA,UACxCjD,eADwC,GACpBsB,QADoB,CACxCtB,eADwC;AAGhDkC,MAAAA,OAAO,CAAC;AAAEN,QAAAA,OAAO,EAAE5B,eAAX;AAA4BuE,QAAAA,EAAE,EAAE;AAAhC,OAAD,CAAP;AACD,KAJD,MAIO;AACL,aAAOrC,OAAO,CAAC,IAAD,CAAd;AACD;AACF,GAVM,CAAP;AAWD,CAZM","sourcesContent":["import isEmpty from 'lodash/isEmpty';\nimport { buildState, score } from '@pie-lib/categorize';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport {\n lockChoices,\n getShuffledChoices,\n partialScoring,\n} from '@pie-lib/controller-utils';\nimport defaults from './defaults';\n\n// eslint-disable-next-line no-console\n\nexport { score };\n\nexport const getPartialScore = (correctResponse, builtCategories) => {\n // in the resulted best scenario we make a sum with all the correct responses\n // and all the placements\n const { placements, score } = builtCategories.reduce(\n (acc, { choices = [] }) => ({\n placements: acc.placements + choices.length,\n score: acc.score + choices.filter((ch) => ch.correct).length,\n }),\n { placements: 0, score: 0 }\n );\n\n // in the correct response, we make a sum of the max possible score\n const { maxScore } = correctResponse.reduce(\n (acc, { choices }) => ({\n maxScore: acc.maxScore + choices.length,\n }),\n { maxScore: 0 }\n );\n\n // if there are any extra placements, we subtract from the obtained score\n const extraPlacements = placements > maxScore ? placements - maxScore : 0;\n const totalScore = (score - extraPlacements) / maxScore;\n\n return totalScore < 0 ? 0 : parseFloat(totalScore.toFixed(2));\n};\n\nconst getAlternates = correctResponse => correctResponse\n .map((c) => c.alternateResponses)\n .filter((alternate) => alternate);\n\nexport const getTotalScore = (question, session, env) => {\n if (!session) {\n return 0;\n }\n\n if (Object.keys(session).length === 0) {\n return 0;\n }\n const { categories, choices } = question || {};\n let { correctResponse } = question || {};\n let { answers } = session || {};\n answers = answers || [];\n correctResponse = correctResponse || [];\n\n // this function is used in pie-ui/categorize as well, in order to get the best scenario\n // so we get the best scenario and calculate the score\n const { categories: builtCategories, correct } = buildState(\n categories,\n choices,\n answers,\n correctResponse\n );\n\n const alternates = getAlternates(correctResponse);\n const enabled = partialScoring.enabled(question, env);\n\n // if there are any alternates, there will be no partial scoring!\n if (enabled && !alternates.length) {\n // we apply partial scoring\n return getPartialScore(correctResponse, builtCategories);\n }\n\n // else we apply dichotomous\n return correct ? 1 : 0;\n};\n\nexport const getCorrectness = (question, session, env) => {\n return new Promise((resolve) => {\n if (env.mode === 'evaluate') {\n const score = getTotalScore(question, session, env);\n if (score === 1) {\n resolve('correct');\n } else if (score === 0) {\n resolve('incorrect');\n } else {\n resolve('partially-correct');\n }\n } else {\n resolve(undefined);\n }\n });\n};\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nexport const normalize = (question) => ({\n feedbackEnabled: true,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport const model = (question, session, env, updateSession) =>\n new Promise(async (resolve) => {\n const normalizedQuestion = normalize(question);\n const answerCorrectness = await getCorrectness(normalizedQuestion, session, env);\n\n const { mode, role } = env || {};\n\n const {\n categories,\n categoriesPerRow,\n choicesLabel,\n choicesPosition,\n correctResponse,\n feedback,\n feedbackEnabled,\n promptEnabled,\n prompt,\n removeTilesAfterPlacing,\n rowLabels,\n rationaleEnabled,\n rationale,\n note,\n teacherInstructionsEnabled,\n teacherInstructions,\n } = normalizedQuestion;\n let { choices } = normalizedQuestion;\n let fb;\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (mode === 'evaluate' && feedbackEnabled) {\n fb = await getFeedbackForCorrectness(\n answerCorrectness,\n feedback\n );\n }\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n const alternates = getAlternates(correctResponse);\n const out = {\n categories: categories || [],\n categoriesPerRow: categoriesPerRow || 2,\n correctness: answerCorrectness,\n choices: choices || [],\n choicesLabel: choicesLabel || '',\n choicesPosition,\n disabled: mode !== 'gather',\n feedback: fb,\n lockChoiceOrder,\n prompt: promptEnabled ? prompt : null,\n removeTilesAfterPlacing,\n rowLabels,\n note,\n env,\n showNote: alternates && alternates.length > 0,\n correctResponse: mode === 'evaluate' ? correctResponse : undefined,\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = rationaleEnabled ? rationale : null;\n out.teacherInstructions = teacherInstructionsEnabled\n ? teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n\nexport const outcome = (question, session, env) => {\n if (env.mode !== 'evaluate') {\n return Promise.reject(\n new Error('Can not call outcome when mode is not evaluate')\n );\n } else {\n return new Promise((resolve) => {\n resolve({\n score: getTotalScore(question, session, env),\n empty: !session || isEmpty(session),\n });\n });\n }\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n const { mode, role } = env || {};\n\n if (mode !== 'evaluate' && role === 'instructor') {\n const { correctResponse } = question;\n\n resolve({ answers: correctResponse, id: 1 });\n } else {\n return resolve(null);\n }\n });\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["getPartialScore","correctResponse","builtCategories","reduce","acc","choices","placements","length","score","filter","ch","correct","maxScore","extraPlacements","totalScore","parseFloat","toFixed","getAlternates","map","c","alternateResponses","alternate","getTotalScore","question","session","env","Object","keys","categories","answers","alternates","enabled","partialScoring","getCorrectness","Promise","resolve","mode","undefined","createDefaultModel","model","defaults","normalize","feedbackEnabled","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","updateSession","normalizedQuestion","answerCorrectness","role","categoriesPerRow","choicesLabel","choicesPosition","feedback","prompt","removeTilesAfterPlacing","rowLabels","rationale","note","teacherInstructions","lockChoiceOrder","filteredCorrectResponse","response","filteredChoices","choice","fb","out","correctness","disabled","showNote","outcome","reject","Error","empty","createCorrectResponseSession","id","validate","config","minChoices","maxChoices","maxCategories","reversedChoices","reverse","errors","choicesErrors","forEach","index","content","identicalAnswer","slice","some","nbOfCategories","nbOfChoices","categoriesError","choicesError","hasAssociations","associationError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAKA;;;;;;AAMO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,eAAD,EAAkBC,eAAlB,EAAsC;AACnE;AACA;AACA,8BAA8BA,eAAe,CAACC,MAAhB,CAC5B,UAACC,GAAD;AAAA,4BAAQC,OAAR;AAAA,QAAQA,OAAR,6BAAkB,EAAlB;AAAA,WAA4B;AAC1BC,MAAAA,UAAU,EAAEF,GAAG,CAACE,UAAJ,GAAiBD,OAAO,CAACE,MADX;AAE1BC,MAAAA,KAAK,EAAEJ,GAAG,CAACI,KAAJ,GAAYH,OAAO,CAACI,MAAR,CAAe,UAACC,EAAD;AAAA,eAAQA,EAAE,CAACC,OAAX;AAAA,OAAf,EAAmCJ;AAF5B,KAA5B;AAAA,GAD4B,EAK5B;AAAED,IAAAA,UAAU,EAAE,CAAd;AAAiBE,IAAAA,KAAK,EAAE;AAAxB,GAL4B,CAA9B;AAAA,MAAQF,UAAR,yBAAQA,UAAR;AAAA,MAAoBE,KAApB,yBAAoBA,KAApB,CAHmE,CAWnE;;;AACA,8BAAqBP,eAAe,CAACE,MAAhB,CACnB,UAACC,GAAD;AAAA,QAAQC,OAAR,SAAQA,OAAR;AAAA,WAAuB;AACrBO,MAAAA,QAAQ,EAAER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AP,GAAuBA,aAAvB;AACD;;AAED,SAAOD,MAAP;AACD,CA/DM","sourcesContent":["import isEmpty from 'lodash/isEmpty';\nimport { buildState, score } from '@pie-lib/categorize';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport {\n lockChoices,\n getShuffledChoices,\n partialScoring,\n} from '@pie-lib/controller-utils';\nimport defaults from './defaults';\n\n// eslint-disable-next-line no-console\n\nexport { score };\n\nexport const getPartialScore = (correctResponse, builtCategories) => {\n // in the resulted best scenario we make a sum with all the correct responses\n // and all the placements\n const { placements, score } = builtCategories.reduce(\n (acc, { choices = [] }) => ({\n placements: acc.placements + choices.length,\n score: acc.score + choices.filter((ch) => ch.correct).length,\n }),\n { placements: 0, score: 0 }\n );\n\n // in the correct response, we make a sum of the max possible score\n const { maxScore } = correctResponse.reduce(\n (acc, { choices }) => ({\n maxScore: acc.maxScore + choices.length,\n }),\n { maxScore: 0 }\n );\n\n // if there are any extra placements, we subtract from the obtained score\n const extraPlacements = placements > maxScore ? placements - maxScore : 0;\n const totalScore = (score - extraPlacements) / maxScore;\n\n return totalScore < 0 ? 0 : parseFloat(totalScore.toFixed(2));\n};\n\nconst getAlternates = correctResponse => correctResponse\n .map((c) => c.alternateResponses)\n .filter((alternate) => alternate);\n\nexport const getTotalScore = (question, session, env) => {\n if (!session) {\n return 0;\n }\n\n if (Object.keys(session).length === 0) {\n return 0;\n }\n const { categories, choices } = question || {};\n let { correctResponse } = question || {};\n let { answers } = session || {};\n answers = answers || [];\n correctResponse = correctResponse || [];\n\n // this function is used in pie-ui/categorize as well, in order to get the best scenario\n // so we get the best scenario and calculate the score\n const { categories: builtCategories, correct } = buildState(\n categories,\n choices,\n answers,\n correctResponse\n );\n\n const alternates = getAlternates(correctResponse);\n const enabled = partialScoring.enabled(question, env);\n\n // if there are any alternates, there will be no partial scoring!\n if (enabled && !alternates.length) {\n // we apply partial scoring\n return getPartialScore(correctResponse, builtCategories);\n }\n\n // else we apply dichotomous\n return correct ? 1 : 0;\n};\n\nexport const getCorrectness = (question, session, env) => {\n return new Promise((resolve) => {\n if (env.mode === 'evaluate') {\n const score = getTotalScore(question, session, env);\n if (score === 1) {\n resolve('correct');\n } else if (score === 0) {\n resolve('incorrect');\n } else {\n resolve('partially-correct');\n }\n } else {\n resolve(undefined);\n }\n });\n};\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nexport const normalize = (question) => ({\n feedbackEnabled: true,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport const model = (question, session, env, updateSession) =>\n new Promise(async (resolve) => {\n const normalizedQuestion = normalize(question);\n const answerCorrectness = await getCorrectness(normalizedQuestion, session, env);\n\n const { mode, role } = env || {};\n\n const {\n categories,\n categoriesPerRow,\n choicesLabel,\n choicesPosition,\n correctResponse,\n feedback,\n feedbackEnabled,\n promptEnabled,\n prompt,\n removeTilesAfterPlacing,\n rowLabels,\n rationaleEnabled,\n rationale,\n note,\n teacherInstructionsEnabled,\n teacherInstructions,\n } = normalizedQuestion;\n let { choices } = normalizedQuestion;\n let fb;\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n const filteredCorrectResponse = correctResponse.map(response => {\n const filteredChoices = (response.choices || []).filter(choice => choice !== 'null');\n return { ...response, choices: filteredChoices};\n });\n\n if (mode === 'evaluate' && feedbackEnabled) {\n fb = await getFeedbackForCorrectness(\n answerCorrectness,\n feedback\n );\n }\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n const alternates = getAlternates(filteredCorrectResponse);\n const out = {\n categories: categories || [],\n categoriesPerRow: categoriesPerRow || 2,\n correctness: answerCorrectness,\n choices: choices || [],\n choicesLabel: choicesLabel || '',\n choicesPosition,\n disabled: mode !== 'gather',\n feedback: fb,\n lockChoiceOrder,\n prompt: promptEnabled ? prompt : null,\n removeTilesAfterPlacing,\n rowLabels,\n note,\n env,\n showNote: alternates && alternates.length > 0,\n correctResponse: mode === 'evaluate' ? filteredCorrectResponse : undefined,\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = rationaleEnabled ? rationale : null;\n out.teacherInstructions = teacherInstructionsEnabled\n ? teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n\nexport const outcome = (question, session, env) => {\n if (env.mode !== 'evaluate') {\n return Promise.reject(\n new Error('Can not call outcome when mode is not evaluate')\n );\n } else {\n return new Promise((resolve) => {\n resolve({\n score: getTotalScore(question, session, env),\n empty: !session || isEmpty(session),\n });\n });\n }\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n const { mode, role } = env || {};\n\n if (mode !== 'evaluate' && role === 'instructor') {\n const { correctResponse } = question;\n\n resolve({ answers: correctResponse, id: 1 });\n } else {\n return resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { categories, choices, correctResponse } = model;\n const { minChoices = 1, maxChoices, maxCategories } = config;\n const reversedChoices = [ ...choices || []].reverse();\n const errors = {};\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { id, content } = choice;\n\n if (content === '' || content === '<div></div>') {\n choicesErrors[id] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.content === content);\n\n if (identicalAnswer) {\n choicesErrors[id] = 'Content should be unique.';\n }\n }\n });\n\n const nbOfCategories = (categories || []).length;\n const nbOfChoices = (choices || []).length\n\n if (nbOfCategories > maxCategories) {\n errors.categoriesError = `No more than ${maxCategories} categories should be defined.`;\n } else if (nbOfCategories < 1) {\n errors.categoriesError = 'There should be at least 1 category defined.';\n }\n\n if (nbOfChoices < minChoices) {\n errors.choicesError = `There should be at least ${minChoices} choices defined.`;\n } else if (nbOfChoices > maxChoices) {\n errors.choicesError = `No more than ${maxChoices} choices should be defined.`;\n }\n\n if (nbOfChoices && nbOfCategories) {\n let hasAssociations = false;\n\n (correctResponse || []).forEach(response => {\n const { choices = [], alternateResponses = [] } = response;\n\n if (choices.length) {\n hasAssociations = true;\n } else {\n alternateResponses.forEach(alternate => {\n if ((alternate || []).length) {\n hasAssociations = true;\n }\n });\n }\n });\n\n if (!hasAssociations) {\n errors.associationError = 'At least one token should be assigned to at least one category.';\n }\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
@@ -7,7 +7,7 @@
7
7
  "@pie-lib/feedback": "^0.4.27",
8
8
  "lodash": "^4.17.15"
9
9
  },
10
- "version": "5.1.17",
10
+ "version": "5.2.8",
11
11
  "description": "",
12
12
  "scripts": {},
13
13
  "main": "lib/index.js",
@@ -35,6 +35,22 @@
35
35
  }
36
36
  }
37
37
  },
38
+ "spellCheck": {
39
+ "title": "ConfigureProp",
40
+ "type": "object",
41
+ "properties": {
42
+ "settings": {
43
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
44
+ "type": "boolean",
45
+ "title": "settings"
46
+ },
47
+ "label": {
48
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
49
+ "type": "string",
50
+ "title": "label"
51
+ }
52
+ }
53
+ },
38
54
  "scoringType": {
39
55
  "title": "ConfigureProp",
40
56
  "type": "object",
@@ -83,6 +99,109 @@
83
99
  }
84
100
  }
85
101
  },
102
+ "minChoices": {
103
+ "description": "Minimum number of choices",
104
+ "type": "number",
105
+ "title": "minChoices"
106
+ },
107
+ "maxChoices": {
108
+ "description": "Maximum number of choices",
109
+ "type": "number",
110
+ "title": "maxChoices"
111
+ },
112
+ "maxCategories": {
113
+ "description": "Maximum number of categories",
114
+ "type": "number",
115
+ "title": "maxCategories"
116
+ },
117
+ "maxImageWidth": {
118
+ "title": "ConfigureMaxImageDimensionsProp",
119
+ "type": "object",
120
+ "properties": {
121
+ "teacherInstructions": {
122
+ "description": "Indicates the max dimension for images in teacher instructions",
123
+ "type": "number",
124
+ "title": "teacherInstructions"
125
+ },
126
+ "prompt": {
127
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
128
+ "type": "number",
129
+ "title": "prompt"
130
+ },
131
+ "rationale": {
132
+ "description": "Indicates the max dimension for images in rationale",
133
+ "type": "number",
134
+ "title": "rationale"
135
+ },
136
+ "choices": {
137
+ "description": "Indicates the max dimension for images in choices",
138
+ "type": "number",
139
+ "title": "choices"
140
+ },
141
+ "rowLabel": {
142
+ "description": "Indicates the max dimension for images in row labels",
143
+ "type": "number",
144
+ "title": "rowLabel"
145
+ },
146
+ "categoryLabel": {
147
+ "description": "Indicates the max dimension for images in category labels",
148
+ "type": "number",
149
+ "title": "categoryLabel"
150
+ }
151
+ }
152
+ },
153
+ "maxImageHeight": {
154
+ "title": "ConfigureMaxImageDimensionsProp",
155
+ "type": "object",
156
+ "properties": {
157
+ "teacherInstructions": {
158
+ "description": "Indicates the max dimension for images in teacher instructions",
159
+ "type": "number",
160
+ "title": "teacherInstructions"
161
+ },
162
+ "prompt": {
163
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
164
+ "type": "number",
165
+ "title": "prompt"
166
+ },
167
+ "rationale": {
168
+ "description": "Indicates the max dimension for images in rationale",
169
+ "type": "number",
170
+ "title": "rationale"
171
+ },
172
+ "choices": {
173
+ "description": "Indicates the max dimension for images in choices",
174
+ "type": "number",
175
+ "title": "choices"
176
+ },
177
+ "rowLabel": {
178
+ "description": "Indicates the max dimension for images in row labels",
179
+ "type": "number",
180
+ "title": "rowLabel"
181
+ },
182
+ "categoryLabel": {
183
+ "description": "Indicates the max dimension for images in category labels",
184
+ "type": "number",
185
+ "title": "categoryLabel"
186
+ }
187
+ }
188
+ },
189
+ "withRubric": {
190
+ "title": "ConfigureProp",
191
+ "type": "object",
192
+ "properties": {
193
+ "settings": {
194
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
195
+ "type": "boolean",
196
+ "title": "settings"
197
+ },
198
+ "label": {
199
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
200
+ "type": "string",
201
+ "title": "label"
202
+ }
203
+ }
204
+ },
86
205
  "showPrompt": {
87
206
  "description": "Determines whether prompt field will be displayed or not",
88
207
  "default": true,
@@ -118,6 +237,42 @@
118
237
  "title": "label"
119
238
  }
120
239
  }
240
+ },
241
+ "ConfigureMaxImageDimensionsProp": {
242
+ "title": "ConfigureMaxImageDimensionsProp",
243
+ "type": "object",
244
+ "properties": {
245
+ "teacherInstructions": {
246
+ "description": "Indicates the max dimension for images in teacher instructions",
247
+ "type": "number",
248
+ "title": "teacherInstructions"
249
+ },
250
+ "prompt": {
251
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
252
+ "type": "number",
253
+ "title": "prompt"
254
+ },
255
+ "rationale": {
256
+ "description": "Indicates the max dimension for images in rationale",
257
+ "type": "number",
258
+ "title": "rationale"
259
+ },
260
+ "choices": {
261
+ "description": "Indicates the max dimension for images in choices",
262
+ "type": "number",
263
+ "title": "choices"
264
+ },
265
+ "rowLabel": {
266
+ "description": "Indicates the max dimension for images in row labels",
267
+ "type": "number",
268
+ "title": "rowLabel"
269
+ },
270
+ "categoryLabel": {
271
+ "description": "Indicates the max dimension for images in category labels",
272
+ "type": "number",
273
+ "title": "categoryLabel"
274
+ }
275
+ }
121
276
  }
122
277
  },
123
278
  "$schema": "http://json-schema.org/draft-07/schema#"
@@ -26,6 +26,18 @@ Indicates if the item has to be displayed in the Settings Panel
26
26
 
27
27
  Indicates the label for the item that has to be displayed in the Settings Panel
28
28
 
29
+ # `spellCheck` (object)
30
+
31
+ Properties of the `spellCheck` object:
32
+
33
+ ## `settings` (boolean)
34
+
35
+ Indicates if the item has to be displayed in the Settings Panel
36
+
37
+ ## `label` (string)
38
+
39
+ Indicates the label for the item that has to be displayed in the Settings Panel
40
+
29
41
  # `scoringType` (object)
30
42
 
31
43
  Properties of the `scoringType` object:
@@ -62,6 +74,86 @@ Indicates if the item has to be displayed in the Settings Panel
62
74
 
63
75
  Indicates the label for the item that has to be displayed in the Settings Panel
64
76
 
77
+ # `minChoices` (number)
78
+
79
+ Minimum number of choices
80
+
81
+ # `maxChoices` (number)
82
+
83
+ Maximum number of choices
84
+
85
+ # `maxCategories` (number)
86
+
87
+ Maximum number of categories
88
+
89
+ # `maxImageWidth` (object)
90
+
91
+ Properties of the `maxImageWidth` object:
92
+
93
+ ## `teacherInstructions` (number)
94
+
95
+ Indicates the max dimension for images in teacher instructions
96
+
97
+ ## `prompt` (number)
98
+
99
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
100
+
101
+ ## `rationale` (number)
102
+
103
+ Indicates the max dimension for images in rationale
104
+
105
+ ## `choices` (number)
106
+
107
+ Indicates the max dimension for images in choices
108
+
109
+ ## `rowLabel` (number)
110
+
111
+ Indicates the max dimension for images in row labels
112
+
113
+ ## `categoryLabel` (number)
114
+
115
+ Indicates the max dimension for images in category labels
116
+
117
+ # `maxImageHeight` (object)
118
+
119
+ Properties of the `maxImageHeight` object:
120
+
121
+ ## `teacherInstructions` (number)
122
+
123
+ Indicates the max dimension for images in teacher instructions
124
+
125
+ ## `prompt` (number)
126
+
127
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
128
+
129
+ ## `rationale` (number)
130
+
131
+ Indicates the max dimension for images in rationale
132
+
133
+ ## `choices` (number)
134
+
135
+ Indicates the max dimension for images in choices
136
+
137
+ ## `rowLabel` (number)
138
+
139
+ Indicates the max dimension for images in row labels
140
+
141
+ ## `categoryLabel` (number)
142
+
143
+ Indicates the max dimension for images in category labels
144
+
145
+ # `withRubric` (object)
146
+
147
+ Properties of the `withRubric` object:
148
+
149
+ ## `settings` (boolean)
150
+
151
+ Indicates if the item has to be displayed in the Settings Panel
152
+
153
+ ## `label` (string)
154
+
155
+ Indicates the label for the item that has to be displayed in the Settings Panel
156
+
65
157
  # `showPrompt` (boolean)
66
158
 
67
159
  Determines whether prompt field will be displayed or not
@@ -96,4 +188,32 @@ Indicates if the item has to be displayed in the Settings Panel
96
188
 
97
189
  ### `label` (string)
98
190
 
99
- Indicates the label for the item that has to be displayed in the Settings Panel
191
+ Indicates the label for the item that has to be displayed in the Settings Panel
192
+
193
+ ## `ConfigureMaxImageDimensionsProp` (object)
194
+
195
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
196
+
197
+ ### `teacherInstructions` (number)
198
+
199
+ Indicates the max dimension for images in teacher instructions
200
+
201
+ ### `prompt` (number)
202
+
203
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
204
+
205
+ ### `rationale` (number)
206
+
207
+ Indicates the max dimension for images in rationale
208
+
209
+ ### `choices` (number)
210
+
211
+ Indicates the max dimension for images in choices
212
+
213
+ ### `rowLabel` (number)
214
+
215
+ Indicates the max dimension for images in row labels
216
+
217
+ ### `categoryLabel` (number)
218
+
219
+ Indicates the max dimension for images in category labels
@@ -339,4 +339,5 @@ exports.model = (id, element) => ({
339
339
  teacherInstructionsEnabled: true,
340
340
  studentInstructionsEnabled: true,
341
341
  toolbarEditorPosition: 'bottom',
342
+ rubricEnabled: false
342
343
  });
@@ -373,6 +373,11 @@
373
373
  "type": "boolean",
374
374
  "title": "rationaleEnabled"
375
375
  },
376
+ "spellCheckEnabled": {
377
+ "description": "Indicates if spellcheck is enabled for the author. Default value is true",
378
+ "type": "boolean",
379
+ "title": "spellCheckEnabled"
380
+ },
376
381
  "studentInstructionsEnabled": {
377
382
  "description": "Indicates if Student Instructions are enabled",
378
383
  "type": "boolean",
@@ -398,6 +403,11 @@
398
403
  "type": "string",
399
404
  "title": "toolbarEditorPosition"
400
405
  },
406
+ "rubricEnabled": {
407
+ "description": "Indicates if Rubric is enabled",
408
+ "type": "boolean",
409
+ "title": "rubricEnabled"
410
+ },
401
411
  "id": {
402
412
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
403
413
  "type": "string",
@@ -417,6 +427,8 @@
417
427
  "id",
418
428
  "prompt",
419
429
  "rationaleEnabled",
430
+ "rubricEnabled",
431
+ "spellCheckEnabled",
420
432
  "studentInstructionsEnabled",
421
433
  "teacherInstructionsEnabled"
422
434
  ],
@@ -437,6 +449,42 @@
437
449
  }
438
450
  }
439
451
  },
452
+ "ConfigureMaxImageDimensionsProp": {
453
+ "title": "ConfigureMaxImageDimensionsProp",
454
+ "type": "object",
455
+ "properties": {
456
+ "teacherInstructions": {
457
+ "description": "Indicates the max dimension for images in teacher instructions",
458
+ "type": "number",
459
+ "title": "teacherInstructions"
460
+ },
461
+ "prompt": {
462
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
463
+ "type": "number",
464
+ "title": "prompt"
465
+ },
466
+ "rationale": {
467
+ "description": "Indicates the max dimension for images in rationale",
468
+ "type": "number",
469
+ "title": "rationale"
470
+ },
471
+ "choices": {
472
+ "description": "Indicates the max dimension for images in choices",
473
+ "type": "number",
474
+ "title": "choices"
475
+ },
476
+ "rowLabel": {
477
+ "description": "Indicates the max dimension for images in row labels",
478
+ "type": "number",
479
+ "title": "rowLabel"
480
+ },
481
+ "categoryLabel": {
482
+ "description": "Indicates the max dimension for images in category labels",
483
+ "type": "number",
484
+ "title": "categoryLabel"
485
+ }
486
+ }
487
+ },
440
488
  "CategoryChoice": {
441
489
  "title": "CategoryChoice",
442
490
  "type": "object",
@@ -150,6 +150,10 @@ Indicates if Feedback is enabled
150
150
 
151
151
  Indicates if Rationale are enabled
152
152
 
153
+ # `spellCheckEnabled` (boolean, required)
154
+
155
+ Indicates if spellcheck is enabled for the author. Default value is true
156
+
153
157
  # `studentInstructionsEnabled` (boolean, required)
154
158
 
155
159
  Indicates if Student Instructions are enabled
@@ -173,6 +177,10 @@ This element must be one of the following enum values:
173
177
 
174
178
  Default: `": 'bottom'"`
175
179
 
180
+ # `rubricEnabled` (boolean, required)
181
+
182
+ Indicates if Rubric is enabled
183
+
176
184
  # `id` (string, required)
177
185
 
178
186
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
@@ -199,6 +207,34 @@ Indicates if the item has to be displayed in the Settings Panel
199
207
 
200
208
  Indicates the label for the item that has to be displayed in the Settings Panel
201
209
 
210
+ ## `ConfigureMaxImageDimensionsProp` (object)
211
+
212
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
213
+
214
+ ### `teacherInstructions` (number)
215
+
216
+ Indicates the max dimension for images in teacher instructions
217
+
218
+ ### `prompt` (number)
219
+
220
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
221
+
222
+ ### `rationale` (number)
223
+
224
+ Indicates the max dimension for images in rationale
225
+
226
+ ### `choices` (number)
227
+
228
+ Indicates the max dimension for images in choices
229
+
230
+ ### `rowLabel` (number)
231
+
232
+ Indicates the max dimension for images in row labels
233
+
234
+ ### `categoryLabel` (number)
235
+
236
+ Indicates the max dimension for images in category labels
237
+
202
238
  ## `CategoryChoice` (object)
203
239
 
204
240
  Properties of the `CategoryChoice` object:
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
+ exports.Categories = void 0;
10
11
  Object.defineProperty(exports, "CategoryType", {
11
12
  enumerable: true,
12
13
  get: function get() {
13
14
  return _category.CategoryType;
14
15
  }
15
16
  });
16
- exports["default"] = exports.Categories = void 0;
17
+ exports["default"] = void 0;
17
18
 
18
19
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
19
20
 
@@ -45,9 +46,13 @@ var _gridContent = _interopRequireDefault(require("./grid-content"));
45
46
 
46
47
  var _category = _interopRequireWildcard(require("./category"));
47
48
 
49
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
50
+
51
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
52
+
48
53
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
49
54
 
50
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
55
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
51
56
 
52
57
  var Categories = /*#__PURE__*/function (_React$Component) {
53
58
  (0, _inherits2["default"])(Categories, _React$Component);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/categorize/categories.jsx"],"names":["Categories","props","classes","categories","model","disabled","onDropChoice","onRemoveChoice","categoriesPerRow","chunkedCategories","Math","ceil","length","map","cat","rowIndex","items","forEach","c","columnIndex","push","label","__html","concat","Array","fill","h","id","category","React","Component","PropTypes","object","isRequired","arrayOf","shape","CategoryType","number","bool","func","styles","theme","flex","color","text","backgroundColor","background","fontSize","typography","textAlign","paddingTop","spacing","unit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;;;;;IAIaA,U;;;;;;;;;;;;WAkBX,kBAAS;AAAA,wBAQH,KAAKC,KARF;AAAA,UAELC,OAFK,eAELA,OAFK;AAAA,UAGLC,UAHK,eAGLA,UAHK;AAAA,UAILC,KAJK,eAILA,KAJK;AAAA,UAKLC,QALK,eAKLA,QALK;AAAA,UAMLC,aANK,eAMLA,YANK;AAAA,UAOLC,cAPK,eAOLA,cAPK;AAAA,UASCC,gBATD,GASsBJ,KATtB,CASCI,gBATD,EAWP;AACA;;AACA,UAAMC,iBAAiB,GAAG,uBAAMN,UAAN,EAAkBK,gBAAlB,CAA1B;AAEA,0BACE,gCAAC,uBAAD;AACE,QAAA,OAAO,EAAEA,gBADX;AAEE,QAAA,SAAS,EAAEN,OAAO,CAACC,UAFrB;AAGE,QAAA,IAAI,EAAEO,IAAI,CAACC,IAAL,CAAUR,UAAU,CAACS,MAAX,GAAoBJ,gBAA9B,IAAkD;AAH1D,SAMIC,iBAAiB,CAACI,GAAlB,CAAsB,UAACC,GAAD,EAAMC,QAAN,EAAmB;AACvC,YAAIC,KAAK,GAAG,EAAZ,CADuC,CAGvC;;AACAF,QAAAA,GAAG,CAACG,OAAJ,CAAY,UAACC,CAAD,EAAIC,W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AE4B,sBAAUG,OAAV,CAAkBH,sBAAUI,KAAV,CAAgBC,sBAAhB,CAAlB,CAFK;AAGjBhC,EAAAA,KAAK,EAAE2B,sBAAUI,KAAV,CAAgB;AACrB3B,IAAAA,gBAAgB,EAAEuB,sBAAUM;AADP,GAAhB,CAHU;AAMjBhC,EAAAA,QAAQ,EAAE0B,sBAAUO,IANH;AAOjBhC,EAAAA,YAAY,EAAEyB,sBAAUQ,IAAV,CAAeN,UAPZ;AAQjB1B,EAAAA,cAAc,EAAEwB,sBAAUQ,IAAV,CAAeN;AARd,C;iCADRjC,U,kBAYW;AACpBI,EAAAA,KAAK,EAAE;AACLI,IAAAA,gBAAgB,EAAE;AADb;AADa,C;;AAiExB,IAAMgC,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBtC,IAAAA,UAAU,EAAE;AACVuC,MAAAA,IAAI,EAAE;AADI,KADW;AAIvBrB,IAAAA,KAAK,EAAE;AACLsB,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADF;AAELC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFZ;AAGLC,MAAAA,QAAQ,EAAEN,KAAK,CAACO,UAAN,CAAiBD,QAHtB;AAILE,MAAAA,SAAS,EAAE,QAJN;AAKLC,MAAAA,UAAU,EAAET,KAAK,CAACU,OAAN,CAAcC;AALrB;AAJgB,GAAL;AAAA,CAApB;;eAYe,wBAAWZ,MAAX,EAAmBxC,UAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport { color } from '@pie-lib/render-ui';\n\nimport chunk from 'lodash/chunk';\n\nimport GridContent from './grid-content';\nimport Category, { CategoryType } from './category';\n\nexport { CategoryType };\n\nexport class Categories extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n categories: PropTypes.arrayOf(PropTypes.shape(CategoryType)),\n model: PropTypes.shape({\n categoriesPerRow: PropTypes.number\n }),\n disabled: PropTypes.bool,\n onDropChoice: PropTypes.func.isRequired,\n onRemoveChoice: PropTypes.func.isRequired,\n };\n\n static defaultProps = {\n model: {\n categoriesPerRow: 1\n }\n };\n\n render() {\n const {\n classes,\n categories,\n model,\n disabled,\n onDropChoice,\n onRemoveChoice,\n } = this.props;\n const { categoriesPerRow } = model;\n\n // split categories into an array of arrays (inner array),\n // where each inner array represents how many categories should be displayed on one row\n const chunkedCategories = chunk(categories, categoriesPerRow);\n\n return (\n <GridContent\n columns={categoriesPerRow}\n className={classes.categories}\n rows={Math.ceil(categories.length / categoriesPerRow) * 2}\n >\n {\n chunkedCategories.map((cat, rowIndex) => {\n let items = [];\n\n // for each inner array of categories, create a row with category titles\n cat.forEach((c, columnIndex) => {\n items.push((\n <Typography className={classes.label} key={`category-label-${rowIndex}-${columnIndex}`}>\n <span dangerouslySetInnerHTML={{ __html: c.label }}/>\n </Typography>));\n });\n\n // if the last row has less categories than max on a row, fill the spaces with divs\n items = items.concat(Array(categoriesPerRow - cat.length).fill(<div/>));\n\n // for each inner array of categories, create a row with category containers\n cat.forEach((c, columnIndex) => {\n items.push(<Category\n onDropChoice={h => onDropChoice(c.id, h)}\n onRemoveChoice={onRemoveChoice}\n disabled={disabled}\n className={classes.category}\n key={`category-element-${rowIndex}-${columnIndex}`}\n {...c}\n />);\n });\n\n // if the last row has less categories than max on a row, fill the spaces with divs\n items = items.concat(Array(categoriesPerRow - cat.length).fill(<div/>));\n\n return items;\n })\n }\n </GridContent>\n );\n }\n}\n\nconst styles = theme => ({\n categories: {\n flex: 1\n },\n label: {\n color: color.text(),\n backgroundColor: color.background(),\n fontSize: theme.typography.fontSize,\n textAlign: 'center',\n paddingTop: theme.spacing.unit\n }\n});\nexport default withStyles(styles)(Categories);\n"],"file":"categories.js"}
1
+ {"version":3,"sources":["../../src/categorize/categories.jsx"],"names":["Categories","props","classes","categories","model","disabled","onDropChoice","onRemoveChoice","categoriesPerRow","chunkedCategories","Math","ceil","length","map","cat","rowIndex","items","forEach","c","columnIndex","push","label","__html","concat","Array","fill","h","id","category","React","Component","PropTypes","object","isRequired","arrayOf","shape","CategoryType","number","bool","func","styles","theme","flex","color","text","backgroundColor","background","fontSize","typography","textAlign","paddingTop","spacing","unit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;;;;;;;;;IAIaA,U;;;;;;;;;;;;WAkBX,kBAAS;AACP,wBAOI,KAAKC,KAPT;AAAA,UACEC,OADF,eACEA,OADF;AAAA,UAEEC,UAFF,eAEEA,UAFF;AAAA,UAGEC,KAHF,eAGEA,KAHF;AAAA,UAIEC,QAJF,eAIEA,QAJF;AAAA,UAKEC,aALF,eAKEA,YALF;AAAA,UAMEC,cANF,eAMEA,cANF;AAQA,UAAQC,gBAAR,GAA6BJ,KAA7B,CAAQI,gBAAR,CATO,CAWP;AACA;;AACA,UAAMC,iBAAiB,GAAG,uBAAMN,UAAN,EAAkBK,gBAAlB,CAA1B;AAEA,0BACE,gCAAC,uBAAD;AACE,QAAA,OAAO,EAAEA,gBADX;AAEE,QAAA,SAAS,EAAEN,OAAO,CAACC,UAFrB;AAGE,QAAA,IAAI,EAAEO,IAAI,CAACC,IAAL,CAAUR,UAAU,CAACS,MAAX,GAAoBJ,gBAA9B,IAAkD;AAH1D,SAMIC,iBAAiB,CAACI,GAAlB,CAAsB,UAACC,GAAD,EAAMC,QAAN,EAAmB;AACvC,YAAIC,KAAK,GAAG,EAAZ,CADuC,CAGvC;;AACAF,QAAAA,GAAG,CAACG,OAAJ,CAAY,UAACC,CAAD,EAAIC,WAAJ,EAAoB;AAC9BH,UAAAA,KAAK,CAACI,IAAN,eACE,gCAAC,sBAAD;AAAY,YAAA,SAAS,EAAElB,OAAO,CAACmB,KAA/B;AAAsC,YAAA,GAAG,2BAAoBN,QAApB,cAAgCI,WAAhC;AAAzC,0BACE;AAAM,YAAA,uBAAuB,EAAE;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QAAQ,EAAE0B,sBAAUO,IANH;AAOjBhC,EAAAA,YAAY,EAAEyB,sBAAUQ,IAAV,CAAeN,UAPZ;AAQjB1B,EAAAA,cAAc,EAAEwB,sBAAUQ,IAAV,CAAeN;AARd,C;iCADRjC,U,kBAYW;AACpBI,EAAAA,KAAK,EAAE;AACLI,IAAAA,gBAAgB,EAAE;AADb;AADa,C;;AAiExB,IAAMgC,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBtC,IAAAA,UAAU,EAAE;AACVuC,MAAAA,IAAI,EAAE;AADI,KADW;AAIvBrB,IAAAA,KAAK,EAAE;AACLsB,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADF;AAELC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFZ;AAGLC,MAAAA,QAAQ,EAAEN,KAAK,CAACO,UAAN,CAAiBD,QAHtB;AAILE,MAAAA,SAAS,EAAE,QAJN;AAKLC,MAAAA,UAAU,EAAET,KAAK,CAACU,OAAN,CAAcC;AALrB;AAJgB,GAAL;AAAA,CAApB;;eAYe,wBAAWZ,MAAX,EAAmBxC,UAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport { color } from '@pie-lib/render-ui';\n\nimport chunk from 'lodash/chunk';\n\nimport GridContent from './grid-content';\nimport Category, { CategoryType } from './category';\n\nexport { CategoryType };\n\nexport class Categories extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n categories: PropTypes.arrayOf(PropTypes.shape(CategoryType)),\n model: PropTypes.shape({\n categoriesPerRow: PropTypes.number\n }),\n disabled: PropTypes.bool,\n onDropChoice: PropTypes.func.isRequired,\n onRemoveChoice: PropTypes.func.isRequired,\n };\n\n static defaultProps = {\n model: {\n categoriesPerRow: 1\n }\n };\n\n render() {\n const {\n classes,\n categories,\n model,\n disabled,\n onDropChoice,\n onRemoveChoice,\n } = this.props;\n const { categoriesPerRow } = model;\n\n // split categories into an array of arrays (inner array),\n // where each inner array represents how many categories should be displayed on one row\n const chunkedCategories = chunk(categories, categoriesPerRow);\n\n return (\n <GridContent\n columns={categoriesPerRow}\n className={classes.categories}\n rows={Math.ceil(categories.length / categoriesPerRow) * 2}\n >\n {\n chunkedCategories.map((cat, rowIndex) => {\n let items = [];\n\n // for each inner array of categories, create a row with category titles\n cat.forEach((c, columnIndex) => {\n items.push((\n <Typography className={classes.label} key={`category-label-${rowIndex}-${columnIndex}`}>\n <span dangerouslySetInnerHTML={{ __html: c.label }}/>\n </Typography>));\n });\n\n // if the last row has less categories than max on a row, fill the spaces with divs\n items = items.concat(Array(categoriesPerRow - cat.length).fill(<div/>));\n\n // for each inner array of categories, create a row with category containers\n cat.forEach((c, columnIndex) => {\n items.push(<Category\n onDropChoice={h => onDropChoice(c.id, h)}\n onRemoveChoice={onRemoveChoice}\n disabled={disabled}\n className={classes.category}\n key={`category-element-${rowIndex}-${columnIndex}`}\n {...c}\n />);\n });\n\n // if the last row has less categories than max on a row, fill the spaces with divs\n items = items.concat(Array(categoriesPerRow - cat.length).fill(<div/>));\n\n return items;\n })\n }\n </GridContent>\n );\n }\n}\n\nconst styles = theme => ({\n categories: {\n flex: 1\n },\n label: {\n color: color.text(),\n backgroundColor: color.background(),\n fontSize: theme.typography.fontSize,\n textAlign: 'center',\n paddingTop: theme.spacing.unit\n }\n});\nexport default withStyles(styles)(Categories);\n"],"file":"categories.js"}
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = exports.Category = exports.CategoryType = void 0;
8
+ exports["default"] = exports.CategoryType = exports.Category = void 0;
9
9
 
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
 
@@ -35,13 +35,13 @@ var _droppablePlaceholder = _interopRequireDefault(require("./droppable-placehol
35
35
 
36
36
  var _renderUi = require("@pie-lib/render-ui");
37
37
 
38
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
38
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
39
39
 
40
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
40
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
41
41
 
42
42
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
43
43
 
44
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
44
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
45
45
 
46
46
  var CategoryType = {
47
47
  id: _propTypes["default"].string.isRequired,