@coorpacademy/components 11.41.0 → 11.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/atom/radio-group/index.d.ts +13 -7
- package/es/atom/radio-group/index.d.ts.map +1 -1
- package/es/atom/radio-group/index.js +51 -0
- package/es/atom/radio-group/index.js.map +1 -1
- package/es/atom/radio-group/style.css +37 -0
- package/es/molecule/assignment-status-tag/index.d.ts.map +1 -1
- package/es/molecule/assignment-status-tag/index.js +5 -0
- package/es/molecule/assignment-status-tag/index.js.map +1 -1
- package/es/molecule/draggable-list/index.d.ts +6 -0
- package/es/molecule/setup-section/index.d.ts +6 -0
- package/es/molecule/setup-sections/index.d.ts +6 -0
- package/es/organism/assignment-audience/index.d.ts +23 -11
- package/es/organism/assignment-audience/index.d.ts.map +1 -1
- package/es/organism/assignment-audience/index.js +100 -59
- package/es/organism/assignment-audience/index.js.map +1 -1
- package/es/organism/assignment-audience/types.d.ts +39 -15
- package/es/organism/assignment-audience/types.d.ts.map +1 -1
- package/es/organism/assignment-audience/types.js +17 -5
- package/es/organism/assignment-audience/types.js.map +1 -1
- package/es/organism/assignment-audience/upload-result.d.ts.map +1 -1
- package/es/organism/assignment-audience/upload-result.js +4 -7
- package/es/organism/assignment-audience/upload-result.js.map +1 -1
- package/es/organism/brand-learning-priorities/index.d.ts +6 -0
- package/es/organism/header-with-actions/index.d.ts +13 -4
- package/es/organism/header-with-actions/index.d.ts.map +1 -1
- package/es/organism/header-with-actions/index.js +31 -6
- package/es/organism/header-with-actions/index.js.map +1 -1
- package/es/organism/header-with-actions/style.css +42 -0
- package/es/organism/header-with-actions/types.d.ts +24 -6
- package/es/organism/header-with-actions/types.d.ts.map +1 -1
- package/es/organism/header-with-actions/types.js +7 -2
- package/es/organism/header-with-actions/types.js.map +1 -1
- package/es/template/back-office/brand-update/index.d.ts +40 -4
- package/es/template/back-office/brand-update/index.d.ts.map +1 -1
- package/es/template/back-office/brand-update/index.js +19 -4
- package/es/template/back-office/brand-update/index.js.map +1 -1
- package/es/template/back-office/brand-update/style.css +18 -0
- package/lib/atom/radio-group/index.d.ts +13 -7
- package/lib/atom/radio-group/index.d.ts.map +1 -1
- package/lib/atom/radio-group/index.js +51 -0
- package/lib/atom/radio-group/index.js.map +1 -1
- package/lib/atom/radio-group/style.css +37 -0
- package/lib/molecule/assignment-status-tag/index.d.ts.map +1 -1
- package/lib/molecule/assignment-status-tag/index.js +5 -0
- package/lib/molecule/assignment-status-tag/index.js.map +1 -1
- package/lib/molecule/draggable-list/index.d.ts +6 -0
- package/lib/molecule/setup-section/index.d.ts +6 -0
- package/lib/molecule/setup-sections/index.d.ts +6 -0
- package/lib/organism/assignment-audience/index.d.ts +23 -11
- package/lib/organism/assignment-audience/index.d.ts.map +1 -1
- package/lib/organism/assignment-audience/index.js +100 -59
- package/lib/organism/assignment-audience/index.js.map +1 -1
- package/lib/organism/assignment-audience/types.d.ts +39 -15
- package/lib/organism/assignment-audience/types.d.ts.map +1 -1
- package/lib/organism/assignment-audience/types.js +17 -5
- package/lib/organism/assignment-audience/types.js.map +1 -1
- package/lib/organism/assignment-audience/upload-result.d.ts.map +1 -1
- package/lib/organism/assignment-audience/upload-result.js +3 -7
- package/lib/organism/assignment-audience/upload-result.js.map +1 -1
- package/lib/organism/brand-learning-priorities/index.d.ts +6 -0
- package/lib/organism/header-with-actions/index.d.ts +13 -4
- package/lib/organism/header-with-actions/index.d.ts.map +1 -1
- package/lib/organism/header-with-actions/index.js +31 -6
- package/lib/organism/header-with-actions/index.js.map +1 -1
- package/lib/organism/header-with-actions/style.css +42 -0
- package/lib/organism/header-with-actions/types.d.ts +24 -6
- package/lib/organism/header-with-actions/types.d.ts.map +1 -1
- package/lib/organism/header-with-actions/types.js +7 -2
- package/lib/organism/header-with-actions/types.js.map +1 -1
- package/lib/template/back-office/brand-update/index.d.ts +40 -4
- package/lib/template/back-office/brand-update/index.d.ts.map +1 -1
- package/lib/template/back-office/brand-update/index.js +19 -4
- package/lib/template/back-office/brand-update/index.js.map +1 -1
- package/lib/template/back-office/brand-update/style.css +18 -0
- package/locales/bs/global.json +2 -2
- package/locales/cs/global.json +2 -2
- package/locales/de/global.json +2 -2
- package/locales/es/global.json +2 -2
- package/locales/et/global.json +2 -2
- package/locales/fi/global.json +2 -2
- package/locales/fr/global.json +2 -2
- package/locales/hr/global.json +2 -2
- package/locales/hu/global.json +2 -2
- package/locales/hy/global.json +2 -2
- package/locales/it/global.json +2 -2
- package/locales/ja/global.json +2 -2
- package/locales/ko/global.json +2 -2
- package/locales/lt/global.json +2 -2
- package/locales/nl/global.json +2 -2
- package/locales/pl/global.json +2 -2
- package/locales/pt/global.json +2 -2
- package/locales/ro/global.json +2 -2
- package/locales/ru/global.json +2 -2
- package/locales/sk/global.json +2 -2
- package/locales/sl/global.json +2 -2
- package/locales/sv/global.json +2 -2
- package/locales/tl/global.json +2 -2
- package/locales/tr/global.json +2 -2
- package/locales/uk/global.json +2 -2
- package/locales/vi/global.json +2 -2
- package/locales/zh/global.json +2 -2
- package/locales/zh_TW/global.json +2 -2
- package/package.json +2 -2
|
@@ -24,11 +24,17 @@ declare namespace RadioGroup {
|
|
|
24
24
|
}>;
|
|
25
25
|
}>>;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const propTypes: {
|
|
28
|
+
color: PropTypes.Requireable<string>;
|
|
29
|
+
theme: PropTypes.Requireable<string>;
|
|
30
|
+
className: PropTypes.Requireable<string>;
|
|
31
|
+
options: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
32
|
+
label: PropTypes.Validator<string>;
|
|
33
|
+
value: PropTypes.Validator<string>;
|
|
34
|
+
}> | null | undefined)[]>;
|
|
35
|
+
value: PropTypes.Requireable<string>;
|
|
36
|
+
'aria-label': PropTypes.Requireable<string>;
|
|
37
|
+
list: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
32
38
|
color: PropTypes.Requireable<string>;
|
|
33
39
|
value: PropTypes.Validator<string>;
|
|
34
40
|
name: PropTypes.Requireable<string>;
|
|
@@ -37,8 +43,8 @@ declare namespace RadioGroup {
|
|
|
37
43
|
label: PropTypes.Requireable<string>;
|
|
38
44
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
39
45
|
}> | null | undefined)[]>;
|
|
40
|
-
|
|
41
|
-
}
|
|
46
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
47
|
+
};
|
|
42
48
|
}
|
|
43
49
|
import PropTypes from "prop-types";
|
|
44
50
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/radio-group/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/radio-group/index.js"],"names":[],"mappings":";AAsDA,mEAkBC"}
|
|
@@ -11,7 +11,52 @@ const themeStyle = {
|
|
|
11
11
|
setup: style.setup,
|
|
12
12
|
coorpmanager: style.coorpmanager
|
|
13
13
|
};
|
|
14
|
+
const renderSegmentedControl = ({
|
|
15
|
+
options,
|
|
16
|
+
value,
|
|
17
|
+
onChange,
|
|
18
|
+
'aria-label': ariaLabel
|
|
19
|
+
}) => {
|
|
20
|
+
const activate = nextValue => {
|
|
21
|
+
if (nextValue !== value) onChange(nextValue);
|
|
22
|
+
};
|
|
23
|
+
function handleClick(event) {
|
|
24
|
+
activate(event.currentTarget.value);
|
|
25
|
+
}
|
|
26
|
+
function handleKeyDown(event) {
|
|
27
|
+
const {
|
|
28
|
+
key,
|
|
29
|
+
currentTarget
|
|
30
|
+
} = event;
|
|
31
|
+
if (!['ArrowRight', 'ArrowDown', 'ArrowLeft', 'ArrowUp'].includes(key)) return;
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
const index = options.findIndex(option => option.value === currentTarget.value);
|
|
34
|
+
const direction = key === 'ArrowRight' || key === 'ArrowDown' ? 1 : -1;
|
|
35
|
+
const destination = (index + direction + options.length) % options.length;
|
|
36
|
+
currentTarget.parentElement.children[destination].focus();
|
|
37
|
+
activate(options[destination].value);
|
|
38
|
+
}
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
role: "radiogroup",
|
|
41
|
+
"aria-label": ariaLabel,
|
|
42
|
+
className: style.segmented
|
|
43
|
+
}, options.map(option => /*#__PURE__*/React.createElement("button", {
|
|
44
|
+
key: option.value,
|
|
45
|
+
type: "button",
|
|
46
|
+
role: "radio",
|
|
47
|
+
value: option.value,
|
|
48
|
+
"aria-checked": option.value === value,
|
|
49
|
+
tabIndex: option.value === value ? 0 : -1,
|
|
50
|
+
className: style.segmentedOption,
|
|
51
|
+
onClick: handleClick,
|
|
52
|
+
onKeyDown: handleKeyDown
|
|
53
|
+
}, option.label)));
|
|
54
|
+
};
|
|
14
55
|
const RadioGroup = (props, context) => {
|
|
56
|
+
const {
|
|
57
|
+
options
|
|
58
|
+
} = props;
|
|
59
|
+
if (options) return renderSegmentedControl(props);
|
|
15
60
|
const {
|
|
16
61
|
list = [],
|
|
17
62
|
onChange,
|
|
@@ -46,6 +91,12 @@ RadioGroup.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
46
91
|
color: PropTypes.string,
|
|
47
92
|
theme: PropTypes.string,
|
|
48
93
|
className: PropTypes.string,
|
|
94
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
95
|
+
label: PropTypes.string.isRequired,
|
|
96
|
+
value: PropTypes.string.isRequired
|
|
97
|
+
})),
|
|
98
|
+
value: PropTypes.string,
|
|
99
|
+
'aria-label': PropTypes.string,
|
|
49
100
|
list: PropTypes.arrayOf(PropTypes.shape(Item.propTypes)),
|
|
50
101
|
onChange: PropTypes.func
|
|
51
102
|
} : {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["classnames","React","PropTypes","Provider","style","Item","themeStyle","setup","coorpmanager","
|
|
1
|
+
{"version":3,"file":"index.js","names":["classnames","React","PropTypes","Provider","style","Item","themeStyle","setup","coorpmanager","renderSegmentedControl","options","value","onChange","ariaLabel","activate","nextValue","handleClick","event","currentTarget","handleKeyDown","key","includes","preventDefault","index","findIndex","option","direction","destination","length","parentElement","children","focus","createElement","role","className","segmented","map","type","tabIndex","segmentedOption","onClick","onKeyDown","label","RadioGroup","props","context","list","color","theme","skin","borderColor","_get","mainClass","items","_map","itemProps","_extends","container","contextTypes","childContextTypes","propTypes","process","env","NODE_ENV","string","arrayOf","shape","isRequired","func"],"sources":["../../../src/atom/radio-group/index.js"],"sourcesContent":["import classnames from 'classnames';\nimport React from 'react';\nimport {get, map} from 'lodash/fp';\nimport PropTypes from 'prop-types';\nimport Provider from '../provider';\nimport style from './style.css';\n\nimport Item from './item';\n\nconst themeStyle = {\n setup: style.setup,\n coorpmanager: style.coorpmanager\n};\n\nconst renderSegmentedControl = ({options, value, onChange, 'aria-label': ariaLabel}) => {\n const activate = nextValue => {\n if (nextValue !== value) onChange(nextValue);\n };\n function handleClick(event) {\n activate(event.currentTarget.value);\n }\n\n function handleKeyDown(event) {\n const {key, currentTarget} = event;\n if (!['ArrowRight', 'ArrowDown', 'ArrowLeft', 'ArrowUp'].includes(key)) return;\n event.preventDefault();\n const index = options.findIndex(option => option.value === currentTarget.value);\n const direction = key === 'ArrowRight' || key === 'ArrowDown' ? 1 : -1;\n const destination = (index + direction + options.length) % options.length;\n currentTarget.parentElement.children[destination].focus();\n activate(options[destination].value);\n }\n\n return (\n <div role=\"radiogroup\" aria-label={ariaLabel} className={style.segmented}>\n {options.map(option => (\n <button\n key={option.value}\n type=\"button\"\n role=\"radio\"\n value={option.value}\n aria-checked={option.value === value}\n tabIndex={option.value === value ? 0 : -1}\n className={style.segmentedOption}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {option.label}\n </button>\n ))}\n </div>\n );\n};\n\nconst RadioGroup = (props, context) => {\n const {options} = props;\n if (options) return renderSegmentedControl(props);\n const {list = [], onChange, color, className, theme = 'setup'} = props;\n const {skin} = context;\n const borderColor = color || get('common.primary', skin);\n const mainClass = themeStyle[theme];\n const items = map(itemProps => {\n return (\n <Item {...itemProps} color={color} theme={theme} onChange={onChange} key={itemProps.value} />\n );\n }, list);\n\n return (\n <div className={classnames([mainClass, style.container, className])} style={{borderColor}}>\n {items}\n </div>\n );\n};\n\nRadioGroup.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nRadioGroup.propTypes = {\n color: PropTypes.string,\n theme: PropTypes.string,\n className: PropTypes.string,\n options: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.string.isRequired,\n value: PropTypes.string.isRequired\n })\n ),\n value: PropTypes.string,\n 'aria-label': PropTypes.string,\n list: PropTypes.arrayOf(PropTypes.shape(Item.propTypes)),\n onChange: PropTypes.func\n};\n\nexport default RadioGroup;\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -17,3 +17,40 @@
|
|
|
17
17
|
margin: 0px auto;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
|
|
21
|
+
@value colors: "../../variables/colors.css";
|
|
22
|
+
@value cm_primary_blue, cm_blue_50, cm_grey_400 from colors;
|
|
23
|
+
|
|
24
|
+
.segmented {
|
|
25
|
+
composes: container;
|
|
26
|
+
flex-wrap: nowrap;
|
|
27
|
+
border: 0;
|
|
28
|
+
height: 36px;
|
|
29
|
+
gap: 4px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.segmentedOption {
|
|
33
|
+
composes: label from "./item.css";
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
height: 36px;
|
|
37
|
+
padding: 8px 16px;
|
|
38
|
+
border: 0;
|
|
39
|
+
border-radius: 5px;
|
|
40
|
+
background: transparent;
|
|
41
|
+
color: cm_grey_400;
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
font-weight: bold;
|
|
44
|
+
line-height: 1.43;
|
|
45
|
+
white-space: nowrap;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.segmentedOption[aria-checked="true"] {
|
|
49
|
+
color: cm_primary_blue;
|
|
50
|
+
background: cm_blue_50;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.segmentedOption:focus {
|
|
54
|
+
outline: 2px solid cm_primary_blue;
|
|
55
|
+
outline-offset: 2px;
|
|
56
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/assignment-status-tag/index.tsx"],"names":[],"mappings":";AAIA,OAAkB,EAAC,wBAAwB,EAAE,OAAO,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/assignment-status-tag/index.tsx"],"names":[],"mappings":";AAIA,OAAkB,EAAC,wBAAwB,EAAE,OAAO,EAAC,MAAM,SAAS,CAAC;AAgCrE,eAAO,MAAM,mBAAmB,UAAkB,CAAC;AAEnD,eAAO,MAAM,oBAAoB,YAAa,MAAM,GAAG,IAAI,KAAG,OACI,CAAC;AAEnE,QAAA,MAAM,mBAAmB;wBAAqB,wBAAwB;;;;;CAErE,CAAC;AAIF,eAAe,mBAAmB,CAAC"}
|
|
@@ -12,6 +12,11 @@ const TAG_TYPES = {
|
|
|
12
12
|
active: 'success',
|
|
13
13
|
ended: 'default',
|
|
14
14
|
disabled: 'warning',
|
|
15
|
+
// Login resolution in an audience upload
|
|
16
|
+
loginValid: 'success',
|
|
17
|
+
loginUnknown: 'failure',
|
|
18
|
+
loginAmbiguous: 'warning',
|
|
19
|
+
loginInactive: 'warning',
|
|
15
20
|
// List-row information tags: « Ongoing changes », « N modules unavailable »
|
|
16
21
|
ongoingChanges: 'progress',
|
|
17
22
|
unavailable: 'warning',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","has","keys","Tag","propTypes","TAG_TYPES","draft","upcoming","active","ended","disabled","ongoingChanges","unavailable","processing","syncError","assigned","inProgress","completed","removed","dueSoon","overdue","late","ASSIGNMENT_TAG_KEYS","getAssignmentTagType","status","AssignmentStatusTag","label","createElement","type","process","env","NODE_ENV"],"sources":["../../../src/molecule/assignment-status-tag/index.tsx"],"sourcesContent":["import React from 'react';\nimport has from 'lodash/fp/has';\nimport keys from 'lodash/fp/keys';\nimport Tag from '../../atom/tag';\nimport propTypes, {AssignmentStatusTagProps, TagType} from './types';\n\n// One status vocabulary for every assignment surface. Labels come from the consumer.\nconst TAG_TYPES: Record<string, TagType> = {\n // Assignment lifecycle: edit-page and tracking headers only, never on a list row\n draft: 'progress',\n upcoming: 'info',\n active: 'success',\n ended: 'default',\n disabled: 'warning',\n // List-row information tags: « Ongoing changes », « N modules unavailable »\n ongoingChanges: 'progress',\n unavailable: 'warning',\n // Sync, only when not up to date: there is no \"up to date\" key\n processing: 'progress',\n syncError: 'failure',\n // Learner row in the tracking table; \"completed late\" is a computed flag, not a status\n assigned: 'default',\n inProgress: 'info',\n completed: 'success',\n removed: 'default',\n // Computed learner flags\n dueSoon: 'warning',\n overdue: 'failure',\n late: 'warning'\n};\n\nexport const ASSIGNMENT_TAG_KEYS = keys(TAG_TYPES);\n\nexport const getAssignmentTagType = (status?: string | null): TagType =>\n status && has(status, TAG_TYPES) ? TAG_TYPES[status] : 'default';\n\nconst AssignmentStatusTag = ({status, label}: AssignmentStatusTagProps) => (\n <Tag type={getAssignmentTagType(status)} label={label} />\n);\n\nAssignmentStatusTag.propTypes = propTypes;\n\nexport default AssignmentStatusTag;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,IAAI,MAAM,gBAAgB;AACjC,OAAOC,GAAG,MAAM,gBAAgB;AAChC,OAAOC,SAAS,MAA2C,SAAS;;AAEpE;AACA,MAAMC,SAAkC,GAAG;EACzC;EACAC,KAAK,EAAE,UAAU;EACjBC,QAAQ,EAAE,MAAM;EAChBC,MAAM,EAAE,SAAS;EACjBC,KAAK,EAAE,SAAS;EAChBC,QAAQ,EAAE,SAAS;EACnB;EACAC,cAAc,EAAE,UAAU;EAC1BC,WAAW,EAAE,SAAS;EACtB;EACAC,UAAU,EAAE,UAAU;EACtBC,SAAS,EAAE,SAAS;EACpB;EACAC,QAAQ,EAAE,SAAS;EACnBC,UAAU,EAAE,MAAM;EAClBC,SAAS,EAAE,SAAS;EACpBC,OAAO,EAAE,SAAS;EAClB;EACAC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAMC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","has","keys","Tag","propTypes","TAG_TYPES","draft","upcoming","active","ended","disabled","loginValid","loginUnknown","loginAmbiguous","loginInactive","ongoingChanges","unavailable","processing","syncError","assigned","inProgress","completed","removed","dueSoon","overdue","late","ASSIGNMENT_TAG_KEYS","getAssignmentTagType","status","AssignmentStatusTag","label","createElement","type","process","env","NODE_ENV"],"sources":["../../../src/molecule/assignment-status-tag/index.tsx"],"sourcesContent":["import React from 'react';\nimport has from 'lodash/fp/has';\nimport keys from 'lodash/fp/keys';\nimport Tag from '../../atom/tag';\nimport propTypes, {AssignmentStatusTagProps, TagType} from './types';\n\n// One status vocabulary for every assignment surface. Labels come from the consumer.\nconst TAG_TYPES: Record<string, TagType> = {\n // Assignment lifecycle: edit-page and tracking headers only, never on a list row\n draft: 'progress',\n upcoming: 'info',\n active: 'success',\n ended: 'default',\n disabled: 'warning',\n // Login resolution in an audience upload\n loginValid: 'success',\n loginUnknown: 'failure',\n loginAmbiguous: 'warning',\n loginInactive: 'warning',\n // List-row information tags: « Ongoing changes », « N modules unavailable »\n ongoingChanges: 'progress',\n unavailable: 'warning',\n // Sync, only when not up to date: there is no \"up to date\" key\n processing: 'progress',\n syncError: 'failure',\n // Learner row in the tracking table; \"completed late\" is a computed flag, not a status\n assigned: 'default',\n inProgress: 'info',\n completed: 'success',\n removed: 'default',\n // Computed learner flags\n dueSoon: 'warning',\n overdue: 'failure',\n late: 'warning'\n};\n\nexport const ASSIGNMENT_TAG_KEYS = keys(TAG_TYPES);\n\nexport const getAssignmentTagType = (status?: string | null): TagType =>\n status && has(status, TAG_TYPES) ? TAG_TYPES[status] : 'default';\n\nconst AssignmentStatusTag = ({status, label}: AssignmentStatusTagProps) => (\n <Tag type={getAssignmentTagType(status)} label={label} />\n);\n\nAssignmentStatusTag.propTypes = propTypes;\n\nexport default AssignmentStatusTag;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,IAAI,MAAM,gBAAgB;AACjC,OAAOC,GAAG,MAAM,gBAAgB;AAChC,OAAOC,SAAS,MAA2C,SAAS;;AAEpE;AACA,MAAMC,SAAkC,GAAG;EACzC;EACAC,KAAK,EAAE,UAAU;EACjBC,QAAQ,EAAE,MAAM;EAChBC,MAAM,EAAE,SAAS;EACjBC,KAAK,EAAE,SAAS;EAChBC,QAAQ,EAAE,SAAS;EACnB;EACAC,UAAU,EAAE,SAAS;EACrBC,YAAY,EAAE,SAAS;EACvBC,cAAc,EAAE,SAAS;EACzBC,aAAa,EAAE,SAAS;EACxB;EACAC,cAAc,EAAE,UAAU;EAC1BC,WAAW,EAAE,SAAS;EACtB;EACAC,UAAU,EAAE,UAAU;EACtBC,SAAS,EAAE,SAAS;EACpB;EACAC,QAAQ,EAAE,SAAS;EACnBC,UAAU,EAAE,MAAM;EAClBC,SAAS,EAAE,SAAS;EACpBC,OAAO,EAAE,SAAS;EAClB;EACAC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAMC,mBAAmB,GAAGxB,IAAI,CAACG,SAAS,CAAC;AAElD,OAAO,MAAMsB,oBAAoB,GAAIC,MAAsB,IACzDA,MAAM,IAAI3B,GAAG,CAAC2B,MAAM,EAAEvB,SAAS,CAAC,GAAGA,SAAS,CAACuB,MAAM,CAAC,GAAG,SAAS;AAElE,MAAMC,mBAAmB,GAAGA,CAAC;EAACD,MAAM;EAAEE;AAA+B,CAAC,kBACpE9B,KAAA,CAAA+B,aAAA,CAAC5B,GAAG;EAAC6B,IAAI,EAAEL,oBAAoB,CAACC,MAAM,CAAE;EAACE,KAAK,EAAEA;AAAM,CAAE,CACzD;AAEDD,mBAAmB,CAACzB,SAAS,GAAA6B,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAG/B,SAAS;AAEzC,eAAeyB,mBAAmB","ignoreList":[]}
|
|
@@ -130,6 +130,12 @@ declare namespace DraggableList {
|
|
|
130
130
|
color: PropTypes.Requireable<string>;
|
|
131
131
|
theme: PropTypes.Requireable<string>;
|
|
132
132
|
className: PropTypes.Requireable<string>;
|
|
133
|
+
options: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
134
|
+
label: PropTypes.Validator<string>;
|
|
135
|
+
value: PropTypes.Validator<string>;
|
|
136
|
+
}> | null | undefined)[]>;
|
|
137
|
+
value: PropTypes.Requireable<string>;
|
|
138
|
+
'aria-label': PropTypes.Requireable<string>;
|
|
133
139
|
list: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
134
140
|
color: PropTypes.Requireable<string>;
|
|
135
141
|
value: PropTypes.Validator<string>;
|
|
@@ -85,6 +85,12 @@ declare namespace ContentTypesToggler {
|
|
|
85
85
|
color: PropTypes.Requireable<string>;
|
|
86
86
|
theme: PropTypes.Requireable<string>;
|
|
87
87
|
className: PropTypes.Requireable<string>;
|
|
88
|
+
options: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
89
|
+
label: PropTypes.Validator<string>;
|
|
90
|
+
value: PropTypes.Validator<string>;
|
|
91
|
+
}> | null | undefined)[]>;
|
|
92
|
+
value: PropTypes.Requireable<string>;
|
|
93
|
+
'aria-label': PropTypes.Requireable<string>;
|
|
88
94
|
list: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
89
95
|
color: PropTypes.Requireable<string>;
|
|
90
96
|
value: PropTypes.Validator<string>;
|
|
@@ -33,6 +33,12 @@ declare namespace SetupSections {
|
|
|
33
33
|
color: PropTypes.Requireable<string>;
|
|
34
34
|
theme: PropTypes.Requireable<string>;
|
|
35
35
|
className: PropTypes.Requireable<string>;
|
|
36
|
+
options: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
37
|
+
label: PropTypes.Validator<string>;
|
|
38
|
+
value: PropTypes.Validator<string>;
|
|
39
|
+
}> | null | undefined)[]>;
|
|
40
|
+
value: PropTypes.Requireable<string>;
|
|
41
|
+
'aria-label': PropTypes.Requireable<string>;
|
|
36
42
|
list: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
37
43
|
color: PropTypes.Requireable<string>;
|
|
38
44
|
value: PropTypes.Validator<string>;
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { AssignmentAudienceProps } from './types';
|
|
3
3
|
declare const AssignmentAudience: {
|
|
4
|
-
({ title, subtitle, disabledExplanation, everyone, populations, upload, individuals, total }: AssignmentAudienceProps): JSX.Element;
|
|
4
|
+
({ title, subtitle, disabledExplanation, everyone, team, invalidTargets, invalidLabel, error, disabled, populations, upload, individuals, total }: AssignmentAudienceProps): JSX.Element;
|
|
5
5
|
propTypes: {
|
|
6
6
|
title: import("prop-types").Validator<string>;
|
|
7
7
|
subtitle: import("prop-types").Requireable<string>;
|
|
8
8
|
disabledExplanation: import("prop-types").Requireable<string>;
|
|
9
|
-
|
|
9
|
+
team: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
10
|
+
label: import("prop-types").Validator<string>;
|
|
11
|
+
name: import("prop-types").Validator<string>;
|
|
12
|
+
}>>;
|
|
13
|
+
invalidTargets: import("prop-types").Requireable<(import("prop-types").InferProps<{
|
|
14
|
+
ref: import("prop-types").Validator<string>;
|
|
15
|
+
label: import("prop-types").Validator<string>;
|
|
16
|
+
onRemove: import("prop-types").Validator<(...args: any[]) => any>;
|
|
17
|
+
}> | null | undefined)[]>;
|
|
18
|
+
invalidLabel: import("prop-types").Requireable<string>;
|
|
19
|
+
error: import("prop-types").Requireable<string>;
|
|
20
|
+
disabled: import("prop-types").Requireable<boolean>;
|
|
21
|
+
everyone: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
10
22
|
title: import("prop-types").Requireable<string>;
|
|
11
23
|
label: import("prop-types").Validator<string>;
|
|
12
24
|
value: import("prop-types").Validator<boolean>;
|
|
13
25
|
onChange: import("prop-types").Validator<(...args: any[]) => any>;
|
|
14
|
-
}
|
|
15
|
-
populations: import("prop-types").
|
|
26
|
+
}>>;
|
|
27
|
+
populations: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
16
28
|
title: import("prop-types").Requireable<string>;
|
|
17
29
|
subtitle: import("prop-types").Requireable<string>;
|
|
18
30
|
label: import("prop-types").Requireable<string>;
|
|
@@ -24,8 +36,8 @@ declare const AssignmentAudience: {
|
|
|
24
36
|
}> | null | undefined)[]>;
|
|
25
37
|
removeLabel: import("prop-types").Requireable<string>;
|
|
26
38
|
onChange: import("prop-types").Validator<(...args: any[]) => any>;
|
|
27
|
-
}
|
|
28
|
-
upload: import("prop-types").
|
|
39
|
+
}>>;
|
|
40
|
+
upload: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
29
41
|
title: import("prop-types").Requireable<string>;
|
|
30
42
|
subtitle: import("prop-types").Requireable<string>;
|
|
31
43
|
templateLink: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
@@ -62,8 +74,8 @@ declare const AssignmentAudience: {
|
|
|
62
74
|
}>>;
|
|
63
75
|
removeLabel: import("prop-types").Requireable<string>;
|
|
64
76
|
onRemove: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
65
|
-
}
|
|
66
|
-
individuals: import("prop-types").
|
|
77
|
+
}>>;
|
|
78
|
+
individuals: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
67
79
|
title: import("prop-types").Requireable<string>;
|
|
68
80
|
placeholder: import("prop-types").Requireable<string>;
|
|
69
81
|
value: import("prop-types").Requireable<string>;
|
|
@@ -81,11 +93,11 @@ declare const AssignmentAudience: {
|
|
|
81
93
|
onSearch: import("prop-types").Validator<(...args: any[]) => any>;
|
|
82
94
|
onAdd: import("prop-types").Validator<(...args: any[]) => any>;
|
|
83
95
|
onRemove: import("prop-types").Validator<(...args: any[]) => any>;
|
|
84
|
-
}
|
|
85
|
-
total: import("prop-types").
|
|
96
|
+
}>>;
|
|
97
|
+
total: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
86
98
|
label: import("prop-types").Validator<string>;
|
|
87
99
|
detail: import("prop-types").Requireable<string>;
|
|
88
|
-
}
|
|
100
|
+
}>>;
|
|
89
101
|
};
|
|
90
102
|
};
|
|
91
103
|
export default AssignmentAudience;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/organism/assignment-audience/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/organism/assignment-audience/index.tsx"],"names":[],"mappings":";AAUA,OAAoC,EAClC,uBAAuB,EAGxB,MAAM,SAAS,CAAC;AAwDjB,QAAA,MAAM,kBAAkB;uJAcrB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4RzB,CAAC;AAIF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
1
2
|
import React, { useCallback, useMemo } from 'react';
|
|
2
3
|
import uniqueId from 'lodash/fp/uniqueId';
|
|
3
4
|
import InputSwitch from '../../atom/input-switch';
|
|
4
5
|
import SelectMultiple from '../../molecule/select-multiple';
|
|
6
|
+
import Banner from '../../molecule/banner';
|
|
5
7
|
import InputFileDraggable from '../../atom/input-file-draggable';
|
|
6
8
|
import Autocomplete from '../../atom/autocomplete';
|
|
7
9
|
import Title from '../../atom/title';
|
|
@@ -59,60 +61,62 @@ const AssignmentAudience = ({
|
|
|
59
61
|
subtitle,
|
|
60
62
|
disabledExplanation,
|
|
61
63
|
everyone,
|
|
64
|
+
team,
|
|
65
|
+
invalidTargets,
|
|
66
|
+
invalidLabel,
|
|
67
|
+
error,
|
|
68
|
+
disabled = false,
|
|
62
69
|
populations,
|
|
63
70
|
upload,
|
|
64
71
|
individuals,
|
|
65
72
|
total
|
|
66
73
|
}) => {
|
|
67
|
-
const
|
|
68
|
-
const loading = upload
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
selected = [],
|
|
84
|
-
onSearch,
|
|
85
|
-
onAdd,
|
|
86
|
-
onRemove
|
|
87
|
-
} = individuals;
|
|
74
|
+
const sourcesDisabled = disabled || Boolean(everyone?.value);
|
|
75
|
+
const loading = upload?.status === 'loading';
|
|
76
|
+
const onEveryoneChange = everyone?.onChange;
|
|
77
|
+
const handleEveryoneChange = useCallback(nextValue => {
|
|
78
|
+
if (!disabled) onEveryoneChange?.(nextValue);
|
|
79
|
+
}, [disabled, onEveryoneChange]);
|
|
80
|
+
const populationOptions = populations?.options;
|
|
81
|
+
const onPopulationsChange = populations?.onChange;
|
|
82
|
+
const onUpload = upload?.onUpload;
|
|
83
|
+
const onRemoveFile = upload?.onRemove;
|
|
84
|
+
const value = individuals?.value || '';
|
|
85
|
+
const suggestions = individuals?.suggestions;
|
|
86
|
+
const selected = individuals?.selected;
|
|
87
|
+
const onSearch = individuals?.onSearch;
|
|
88
|
+
const onAdd = individuals?.onAdd;
|
|
89
|
+
const onRemove = individuals?.onRemove;
|
|
88
90
|
const explanationId = useMemo(() => uniqueId('assignment-audience-explanation-'), []);
|
|
89
|
-
const handlePopulations = useCallback(choices => onPopulationsChange(populationOptions.filter(option => choices.some(choice => choice.value === option.value)).map(option => ({
|
|
91
|
+
const handlePopulations = useCallback(choices => !sourcesDisabled && onPopulationsChange?.((populationOptions || []).filter(option => choices.some(choice => choice.value === option.value)).map(option => ({
|
|
90
92
|
...option,
|
|
91
93
|
selected: true
|
|
92
|
-
}))), [populationOptions, onPopulationsChange]);
|
|
93
|
-
const selectedPopulations = useMemo(() => populationOptions.filter(option => option.selected), [populationOptions]);
|
|
94
|
-
const handleRemovePopulation = useCallback(populationValue => () => onPopulationsChange(selectedPopulations.filter(option => option.value !== populationValue)), [selectedPopulations, onPopulationsChange]);
|
|
94
|
+
}))), [sourcesDisabled, populationOptions, onPopulationsChange]);
|
|
95
|
+
const selectedPopulations = useMemo(() => (populationOptions || []).filter(option => option.selected), [populationOptions]);
|
|
96
|
+
const handleRemovePopulation = useCallback(populationValue => () => !sourcesDisabled && onPopulationsChange?.(selectedPopulations.filter(option => option.value !== populationValue)), [sourcesDisabled, selectedPopulations, onPopulationsChange]);
|
|
95
97
|
|
|
96
98
|
// The native input receives both a browse and a drop, and fires change for each.
|
|
97
99
|
const handleFileChange = useCallback(event => {
|
|
98
100
|
const file = event.target.files && event.target.files[0];
|
|
99
|
-
if (
|
|
100
|
-
onUpload(file);
|
|
101
|
-
}, [
|
|
101
|
+
if (sourcesDisabled || loading || !file) return;
|
|
102
|
+
onUpload?.(file);
|
|
103
|
+
}, [sourcesDisabled, loading, onUpload]);
|
|
102
104
|
|
|
103
105
|
// The loader's cross cancels the check: the file is dropped, as with Remove.
|
|
104
106
|
const handleCancelCheck = useCallback(() => {
|
|
105
|
-
if (
|
|
106
|
-
}, [onRemoveFile]);
|
|
107
|
-
const availableSuggestions = useMemo(() => suggestions.filter(suggestion => !selected
|
|
108
|
-
const handleSearch = useCallback(event => onSearch(event.target.value), [onSearch]);
|
|
107
|
+
if (!sourcesDisabled) onRemoveFile?.();
|
|
108
|
+
}, [sourcesDisabled, onRemoveFile]);
|
|
109
|
+
const availableSuggestions = useMemo(() => sourcesDisabled ? [] : (suggestions || []).filter(suggestion => !selected?.some(learner => learner.id === suggestion.id)), [sourcesDisabled, suggestions, selected]);
|
|
110
|
+
const handleSearch = useCallback(event => !sourcesDisabled && onSearch?.(event.target.value), [sourcesDisabled, onSearch]);
|
|
109
111
|
const handleAdd = useCallback(({
|
|
110
112
|
suggestion
|
|
111
113
|
}) => {
|
|
112
114
|
const learner = availableSuggestions.find(item => item.id === suggestion.value);
|
|
113
|
-
if (learner) onAdd(learner);
|
|
114
|
-
}, [availableSuggestions, onAdd]);
|
|
115
|
-
const handleRemove = useCallback(id => () =>
|
|
115
|
+
if (!sourcesDisabled && learner) onAdd?.(learner);
|
|
116
|
+
}, [sourcesDisabled, availableSuggestions, onAdd]);
|
|
117
|
+
const handleRemove = useCallback(id => () => {
|
|
118
|
+
if (!sourcesDisabled) onRemove?.(id);
|
|
119
|
+
}, [sourcesDisabled, onRemove]);
|
|
116
120
|
return /*#__PURE__*/React.createElement("section", {
|
|
117
121
|
className: style.container,
|
|
118
122
|
"data-name": "assignment-audience",
|
|
@@ -123,25 +127,54 @@ const AssignmentAudience = ({
|
|
|
123
127
|
title: title,
|
|
124
128
|
subtitle: subtitle,
|
|
125
129
|
headingLevel: 2
|
|
126
|
-
}), /*#__PURE__*/React.createElement(
|
|
130
|
+
}), error ? /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
role: "alert"
|
|
132
|
+
}, /*#__PURE__*/React.createElement(Banner, {
|
|
133
|
+
type: "error",
|
|
134
|
+
message: error
|
|
135
|
+
})) : null, team ? /*#__PURE__*/React.createElement(Block, {
|
|
136
|
+
name: "team"
|
|
137
|
+
}, /*#__PURE__*/React.createElement(Chip, {
|
|
138
|
+
text: team.label,
|
|
139
|
+
subText: team.name,
|
|
140
|
+
customIcon: "none"
|
|
141
|
+
})) : null, invalidTargets?.length ? /*#__PURE__*/React.createElement("fieldset", {
|
|
142
|
+
disabled: disabled,
|
|
143
|
+
className: style.sources,
|
|
144
|
+
"data-name": "invalid-targets"
|
|
145
|
+
}, invalidTargets.map(target => /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
key: target.ref,
|
|
147
|
+
"data-target-ref": target.ref
|
|
148
|
+
}, /*#__PURE__*/React.createElement(Banner, {
|
|
149
|
+
type: "error",
|
|
150
|
+
message: invalidLabel ? `${target.label}: ${invalidLabel}` : target.label,
|
|
151
|
+
cta: [{
|
|
152
|
+
type: 'button',
|
|
153
|
+
label: 'Remove',
|
|
154
|
+
action: () => {
|
|
155
|
+
if (!disabled) target.onRemove();
|
|
156
|
+
}
|
|
157
|
+
}]
|
|
158
|
+
})))) : null, everyone ? /*#__PURE__*/React.createElement(Block, {
|
|
127
159
|
name: "everyone",
|
|
128
160
|
title: everyone.title
|
|
129
161
|
}, /*#__PURE__*/React.createElement(InputSwitch, {
|
|
130
162
|
title: everyone.label,
|
|
131
163
|
value: everyone.value,
|
|
132
|
-
|
|
164
|
+
disabled: disabled,
|
|
165
|
+
onChange: handleEveryoneChange,
|
|
133
166
|
theme: "coorpmanager",
|
|
134
167
|
"data-name": "assignment-everyone",
|
|
135
168
|
"aria-label": everyone.label
|
|
136
|
-
}),
|
|
169
|
+
}), everyone.value ? /*#__PURE__*/React.createElement("p", {
|
|
137
170
|
id: explanationId,
|
|
138
171
|
className: style.explanation
|
|
139
|
-
}, disabledExplanation) : null), /*#__PURE__*/React.createElement("fieldset", {
|
|
140
|
-
disabled:
|
|
141
|
-
"aria-describedby":
|
|
172
|
+
}, disabledExplanation) : null) : null, /*#__PURE__*/React.createElement("fieldset", {
|
|
173
|
+
disabled: sourcesDisabled,
|
|
174
|
+
"aria-describedby": everyone?.value && disabledExplanation ? explanationId : undefined,
|
|
142
175
|
className: style.sources,
|
|
143
176
|
"data-name": "audience-sources"
|
|
144
|
-
}, /*#__PURE__*/React.createElement(Block, {
|
|
177
|
+
}, populations ? /*#__PURE__*/React.createElement(Block, {
|
|
145
178
|
name: "populations",
|
|
146
179
|
title: populations.title,
|
|
147
180
|
subtitle: populations.subtitle
|
|
@@ -150,7 +183,7 @@ const AssignmentAudience = ({
|
|
|
150
183
|
options: populations.options,
|
|
151
184
|
multiple: true,
|
|
152
185
|
theme: "coorpmanager",
|
|
153
|
-
disabled:
|
|
186
|
+
disabled: sourcesDisabled,
|
|
154
187
|
onChange: handlePopulations
|
|
155
188
|
}), selectedPopulations.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
156
189
|
className: style.chips,
|
|
@@ -160,21 +193,21 @@ const AssignmentAudience = ({
|
|
|
160
193
|
text: option.name,
|
|
161
194
|
subText: option.count === undefined ? undefined : `${option.count}`,
|
|
162
195
|
selected: true,
|
|
163
|
-
customIcon:
|
|
164
|
-
ariaLabel:
|
|
165
|
-
onClick:
|
|
166
|
-
}))) : null), /*#__PURE__*/React.createElement(Block, {
|
|
196
|
+
customIcon: sourcesDisabled ? 'none' : 'times',
|
|
197
|
+
ariaLabel: sourcesDisabled ? undefined : chipLabel(populations.removeLabel, option.name),
|
|
198
|
+
onClick: sourcesDisabled ? undefined : handleRemovePopulation(option.value)
|
|
199
|
+
}))) : null) : null, upload ? /*#__PURE__*/React.createElement(Block, {
|
|
167
200
|
name: "upload",
|
|
168
201
|
title: upload.title,
|
|
169
202
|
subtitle: upload.subtitle,
|
|
170
203
|
button: upload.templateLink ? {
|
|
171
204
|
type: 'text',
|
|
172
205
|
label: upload.templateLink.label,
|
|
173
|
-
link:
|
|
206
|
+
link: sourcesDisabled ? undefined : {
|
|
174
207
|
href: upload.templateLink.href,
|
|
175
208
|
download: true
|
|
176
209
|
},
|
|
177
|
-
disabled,
|
|
210
|
+
disabled: sourcesDisabled,
|
|
178
211
|
'data-name': 'upload-template-link',
|
|
179
212
|
customStyle: FIT_CONTENT
|
|
180
213
|
} : undefined
|
|
@@ -185,7 +218,15 @@ const AssignmentAudience = ({
|
|
|
185
218
|
"aria-busy": loading,
|
|
186
219
|
"aria-live": "polite",
|
|
187
220
|
"data-name": "upload-dropzone"
|
|
188
|
-
}, upload.status === 'done' ? /*#__PURE__*/React.createElement(UploadResult,
|
|
221
|
+
}, upload.status === 'done' ? /*#__PURE__*/React.createElement(UploadResult, _extends({}, upload, {
|
|
222
|
+
onRemove: upload.onRemove ? handleCancelCheck : undefined,
|
|
223
|
+
report: upload.report ? {
|
|
224
|
+
...upload.report,
|
|
225
|
+
onDownload: () => {
|
|
226
|
+
if (!sourcesDisabled) upload.report?.onDownload();
|
|
227
|
+
}
|
|
228
|
+
} : undefined
|
|
229
|
+
})) : /*#__PURE__*/React.createElement(InputFileDraggable, {
|
|
189
230
|
name: "assignment-audience-file",
|
|
190
231
|
filesTypes: ACCEPTED_FILES,
|
|
191
232
|
description: upload.dropzone?.description,
|
|
@@ -194,11 +235,11 @@ const AssignmentAudience = ({
|
|
|
194
235
|
dragAndDropLabel: upload.dropzone?.dropLabel,
|
|
195
236
|
loadingLabel: upload.dropzone?.loadingLabel,
|
|
196
237
|
loading: loading,
|
|
197
|
-
disabled:
|
|
238
|
+
disabled: sourcesDisabled,
|
|
198
239
|
error: upload.status === 'error' ? upload.error : '',
|
|
199
240
|
onChange: handleFileChange,
|
|
200
241
|
onReset: handleCancelCheck
|
|
201
|
-
})))), /*#__PURE__*/React.createElement(Block, {
|
|
242
|
+
})))) : null, individuals ? /*#__PURE__*/React.createElement(Block, {
|
|
202
243
|
name: "individuals",
|
|
203
244
|
title: individuals.title
|
|
204
245
|
}, /*#__PURE__*/React.createElement(Autocomplete, {
|
|
@@ -211,17 +252,17 @@ const AssignmentAudience = ({
|
|
|
211
252
|
})),
|
|
212
253
|
onInput: handleSearch,
|
|
213
254
|
onSuggestionSelected: handleAdd
|
|
214
|
-
}), selected
|
|
255
|
+
}), (selected?.length || 0) > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
215
256
|
className: style.chips
|
|
216
|
-
}, selected
|
|
257
|
+
}, selected?.map(learner => /*#__PURE__*/React.createElement(Chip, {
|
|
217
258
|
key: learner.id,
|
|
218
259
|
text: learner.label,
|
|
219
260
|
subText: learner.login,
|
|
220
261
|
selected: true,
|
|
221
|
-
customIcon:
|
|
222
|
-
ariaLabel:
|
|
223
|
-
onClick:
|
|
224
|
-
}))) : null)), /*#__PURE__*/React.createElement("div", {
|
|
262
|
+
customIcon: sourcesDisabled ? 'none' : 'times',
|
|
263
|
+
ariaLabel: sourcesDisabled ? undefined : chipLabel(individuals.removeLabel, learner.label),
|
|
264
|
+
onClick: sourcesDisabled ? undefined : handleRemove(learner.id)
|
|
265
|
+
}))) : null) : null), total ? /*#__PURE__*/React.createElement("div", {
|
|
225
266
|
className: style.total,
|
|
226
267
|
"data-name": "estimated-audience",
|
|
227
268
|
"aria-live": "polite"
|
|
@@ -229,7 +270,7 @@ const AssignmentAudience = ({
|
|
|
229
270
|
className: style.totalLabel
|
|
230
271
|
}, total.label), total.detail ? /*#__PURE__*/React.createElement("span", {
|
|
231
272
|
className: style.muted
|
|
232
|
-
}, total.detail) : null));
|
|
273
|
+
}, total.detail) : null) : null);
|
|
233
274
|
};
|
|
234
275
|
AssignmentAudience.propTypes = process.env.NODE_ENV !== "production" ? AssignmentAudiencePropTypes : {};
|
|
235
276
|
export default AssignmentAudience;
|