@popsure/dirty-swan 0.57.8 → 0.58.0
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/dist/cjs/index.js +98 -63
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/input/checkbox/index.d.ts +2 -1
- package/dist/cjs/lib/components/input/checkbox/index.stories.d.ts +11 -7
- package/dist/cjs/lib/components/input/radio/index.d.ts +3 -1
- package/dist/cjs/lib/components/input/radio/index.stories.d.ts +10 -2
- package/dist/cjs/lib/components/multiDropzone/utils/index.d.ts +9 -2
- package/dist/esm/{TableSection-a26ba0c5.js → TableSection-ebace923.js} +1 -1
- package/dist/esm/{TableSection-a26ba0c5.js.map → TableSection-ebace923.js.map} +1 -1
- package/dist/esm/components/chip/index.js +2 -2
- package/dist/esm/components/chip/index.js.map +1 -1
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js +1 -1
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js.map +1 -1
- package/dist/esm/components/input/checkbox/index.js +19 -16
- package/dist/esm/components/input/checkbox/index.js.map +1 -1
- package/dist/esm/components/input/checkbox/index.stories.js +24 -20
- package/dist/esm/components/input/checkbox/index.stories.js.map +1 -1
- package/dist/esm/components/input/index.js +1 -1
- package/dist/esm/components/input/index.js.map +1 -1
- package/dist/esm/components/input/radio/index.js +23 -21
- package/dist/esm/components/input/radio/index.js.map +1 -1
- package/dist/esm/components/input/radio/index.stories.js +12 -3
- package/dist/esm/components/input/radio/index.stories.js.map +1 -1
- package/dist/esm/components/input/radio/index.test.js +1 -0
- package/dist/esm/components/input/radio/index.test.js.map +1 -1
- package/dist/esm/components/multiDropzone/UploadFileCell/index.js +6 -7
- package/dist/esm/components/multiDropzone/UploadFileCell/index.js.map +1 -1
- package/dist/esm/components/multiDropzone/index.js +51 -17
- package/dist/esm/components/multiDropzone/index.js.map +1 -1
- package/dist/esm/components/multiDropzone/index.stories.js +1 -0
- package/dist/esm/components/multiDropzone/index.stories.js.map +1 -1
- package/dist/esm/components/multiDropzone/index.test.js +1 -0
- package/dist/esm/components/multiDropzone/index.test.js.map +1 -1
- package/dist/esm/components/table/Table.js +1 -1
- package/dist/esm/components/table/Table.stories.js +1 -1
- package/dist/esm/components/table/Table.test.js +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.js +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.test.js +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.js +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.test.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/components/input/checkbox/index.d.ts +2 -1
- package/dist/esm/lib/components/input/checkbox/index.stories.d.ts +11 -7
- package/dist/esm/lib/components/input/radio/index.d.ts +3 -1
- package/dist/esm/lib/components/input/radio/index.stories.d.ts +10 -2
- package/dist/esm/lib/components/multiDropzone/utils/index.d.ts +9 -2
- package/package.json +1 -1
- package/src/lib/components/chip/index.tsx +1 -0
- package/src/lib/components/chip/style.module.scss +5 -0
- package/src/lib/components/comparisonTable/components/TableInfoButton/index.tsx +2 -0
- package/src/lib/components/input/checkbox/index.stories.tsx +81 -58
- package/src/lib/components/input/checkbox/index.tsx +11 -2
- package/src/lib/components/input/checkbox/styles.module.scss +4 -0
- package/src/lib/components/input/index.tsx +2 -0
- package/src/lib/components/input/radio/index.stories.tsx +17 -2
- package/src/lib/components/input/radio/index.tsx +11 -2
- package/src/lib/components/input/radio/styles.module.scss +5 -1
- package/src/lib/components/multiDropzone/UploadFileCell/index.tsx +25 -19
- package/src/lib/components/multiDropzone/UploadFileCell/style.module.scss +11 -29
- package/src/lib/components/multiDropzone/index.tsx +17 -5
- package/src/lib/components/multiDropzone/style.module.scss +12 -9
- package/src/lib/components/multiDropzone/utils/index.test.ts +128 -45
- package/src/lib/components/multiDropzone/utils/index.ts +89 -36
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { c as classNames } from '../../../index-6ea95111.js';
|
|
3
3
|
import { s as styleInject } from '../../../style-inject.es-1f59c1d0.js';
|
|
4
|
+
import { g as generateId } from '../../../index-69a46657.js';
|
|
4
5
|
|
|
5
|
-
var css_248z = ".styles-module_container__3M-sc {\n max-width: 100%;\n}\n\n.styles-module_narrow__3VUzp {\n max-width: 424px;\n}\n\n.styles-module_wide__3nLhz {\n max-width: 736px;\n}";
|
|
6
|
+
var css_248z = ".styles-module_container__3M-sc {\n max-width: 100%;\n border: 0;\n margin: 0;\n min-width: 0;\n padding: 0.01em 0 0 0;\n}\n\n.styles-module_narrow__3VUzp {\n max-width: 424px;\n}\n\n.styles-module_wide__3nLhz {\n max-width: 736px;\n}";
|
|
6
7
|
var styles = {"container":"styles-module_container__3M-sc","narrow":"styles-module_narrow__3VUzp","wide":"styles-module_wide__3nLhz"};
|
|
7
8
|
styleInject(css_248z);
|
|
8
9
|
|
|
9
10
|
var Radio = function (_a) {
|
|
10
11
|
var _b;
|
|
11
|
-
var options = _a.options, value = _a.value, onChange = _a.onChange, _c = _a.wide, wide = _c === void 0 ? false : _c, _d = _a.inlineLayout, inlineLayout = _d === void 0 ? false : _d, _e = _a.inlineIcon, inlineIcon = _e === void 0 ? false : _e, classNamesObj = _a.classNames, _f = _a.bordered, bordered = _f === void 0 ? true : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g;
|
|
12
|
+
var options = _a.options, value = _a.value, onChange = _a.onChange, _c = _a.wide, wide = _c === void 0 ? false : _c, _d = _a.inlineLayout, inlineLayout = _d === void 0 ? false : _d, _e = _a.inlineIcon, inlineIcon = _e === void 0 ? false : _e, classNamesObj = _a.classNames, _f = _a.bordered, bordered = _f === void 0 ? true : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.fieldLegend, fieldLegend = _h === void 0 ? 'Select an option' : _h, groupName = _a.groupName;
|
|
12
13
|
var entries = Object.entries(options);
|
|
13
|
-
|
|
14
|
+
var name = groupName !== null && groupName !== void 0 ? groupName : generateId();
|
|
15
|
+
return (jsxs("fieldset", { className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.container, styles.container, 'd-flex gap8', (_b = {},
|
|
14
16
|
_b[styles.wide] = wide,
|
|
15
17
|
_b[styles.narrow] = !wide,
|
|
16
18
|
_b['fd-row'] = inlineLayout,
|
|
17
19
|
_b['f-wrap'] = inlineLayout,
|
|
18
20
|
_b['fd-column'] = !inlineLayout,
|
|
19
|
-
_b)), children: entries.map(function (_a) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
_b)), children: [jsx("legend", { className: "sr-only", children: fieldLegend }), entries.map(function (_a) {
|
|
22
|
+
var currentValue = _a[0], label = _a[1];
|
|
23
|
+
var checked = value === currentValue;
|
|
24
|
+
var customIcon = label === null || label === void 0 ? void 0 : label.icon;
|
|
25
|
+
var hideIcon = label === null || label === void 0 ? void 0 : label.hideBox;
|
|
26
|
+
var isRadioLabelObject = function (label) {
|
|
27
|
+
return label.title !== undefined;
|
|
28
|
+
};
|
|
29
|
+
return (jsxs("div", { className: classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.option, children: [jsx("input", { className: classNames('p-radio', {
|
|
30
|
+
'p-radio--no-icon': customIcon || hideIcon,
|
|
31
|
+
'p-radio--centered': !label,
|
|
32
|
+
}), id: currentValue, type: "radio", value: currentValue, onChange: function () { return onChange(currentValue); }, checked: checked, "data-testid": "radio-input-".concat(currentValue), disabled: disabled, name: name }), jsxs("label", { htmlFor: currentValue, className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.label, 'p-label', {
|
|
33
|
+
'jc-center': customIcon && !inlineIcon,
|
|
34
|
+
'fd-column': customIcon && !inlineIcon,
|
|
35
|
+
'p-label--bordered': bordered,
|
|
36
|
+
}), "data-cy": "radio-".concat(currentValue), "data-testid": "radio-".concat(currentValue), children: [customIcon && (jsx("div", { className: classNames('d-inline-flex ai-center jc-center', inlineIcon ? 'mr8' : 'mt8'), children: customIcon === null || customIcon === void 0 ? void 0 : customIcon(checked) })), isRadioLabelObject(label) ? (jsxs("div", { children: [jsx("p", { className: "p-p", children: label.title }), jsx("span", { className: "d-block p-p p-p--small tc-grey-600", children: label.description })] })) : (label)] })] }, currentValue));
|
|
37
|
+
})] }));
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
export { Radio };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/radio/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ReactNode } from 'react';\n\nimport styles from './styles.module.scss';\nexport interface RadioWithDescription {\n title: ReactNode;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n hideBox?: boolean;\n}\n\nexport interface RadioProps<ValueType extends string> {\n options: Record<ValueType, ReactNode | RadioWithDescription>;\n value?: ValueType;\n onChange: (value: ValueType) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n inlineIcon?: boolean;\n classNames?: {\n container?: string;\n label?: string;\n option?: string;\n };\n bordered?: boolean;\n disabled?: boolean;\n}\n\nexport const Radio = <ValueType extends string>({\n options,\n value,\n onChange,\n wide = false,\n inlineLayout = false,\n inlineIcon = false,\n classNames: classNamesObj,\n bordered = true,\n disabled = false,\n}: RadioProps<ValueType>) => {\n const entries = Object.entries(options) as [\n ValueType,\n ReactNode | RadioWithDescription\n ][];\n\n return (\n <
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/radio/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ReactNode } from 'react';\n\nimport styles from './styles.module.scss';\nimport generateId from '../../../util/generateId';\nexport interface RadioWithDescription {\n title: ReactNode;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n hideBox?: boolean;\n}\n\nexport interface RadioProps<ValueType extends string> {\n options: Record<ValueType, ReactNode | RadioWithDescription>;\n value?: ValueType;\n onChange: (value: ValueType) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n inlineIcon?: boolean;\n classNames?: {\n container?: string;\n label?: string;\n option?: string;\n };\n bordered?: boolean;\n disabled?: boolean;\n fieldLegend?: string;\n groupName?: string;\n}\n\nexport const Radio = <ValueType extends string>({\n options,\n value,\n onChange,\n wide = false,\n inlineLayout = false,\n inlineIcon = false,\n classNames: classNamesObj,\n bordered = true,\n disabled = false,\n fieldLegend = 'Select an option',\n groupName,\n}: RadioProps<ValueType>) => {\n const entries = Object.entries(options) as [\n ValueType,\n ReactNode | RadioWithDescription\n ][];\n\n const name = groupName ?? generateId();\n\n return (\n <fieldset\n className={classNames(\n classNamesObj?.container,\n styles.container,\n 'd-flex gap8',\n {\n [styles.wide]: wide,\n [styles.narrow]: !wide,\n 'fd-row': inlineLayout,\n 'f-wrap': inlineLayout,\n 'fd-column': !inlineLayout,\n }\n )}\n >\n <legend className=\"sr-only\">{fieldLegend}</legend>\n {entries.map(([currentValue, label]) => {\n const checked = value === currentValue;\n const customIcon = (label as RadioWithDescription)?.icon;\n const hideIcon = (label as RadioWithDescription)?.hideBox;\n\n const isRadioLabelObject = (\n label: ReactNode | RadioWithDescription\n ): label is RadioWithDescription => {\n return (label as RadioWithDescription).title !== undefined;\n };\n\n return (\n <div className={classNamesObj?.option} key={currentValue}>\n <input\n className={classNames('p-radio', {\n 'p-radio--no-icon': customIcon || hideIcon,\n 'p-radio--centered': !label,\n })}\n id={currentValue}\n type=\"radio\"\n value={currentValue}\n onChange={() => onChange(currentValue)}\n checked={checked}\n data-testid={`radio-input-${currentValue}`}\n disabled={disabled}\n name={name}\n />\n\n <label\n htmlFor={currentValue}\n className={classNames(classNamesObj?.label, 'p-label', {\n 'jc-center': customIcon && !inlineIcon,\n 'fd-column': customIcon && !inlineIcon,\n 'p-label--bordered': bordered,\n })}\n data-cy={`radio-${currentValue}`}\n data-testid={`radio-${currentValue}`}\n >\n {customIcon && (\n <div\n className={classNames(\n 'd-inline-flex ai-center jc-center',\n inlineIcon ? 'mr8' : 'mt8'\n )}\n >\n {customIcon?.(checked)}\n </div>\n )}\n\n {isRadioLabelObject(label) ? (\n <div>\n <p className=\"p-p\">{label.title}</p>\n <span className=\"d-block p-p p-p--small tc-grey-600\">\n {label.description}\n </span>\n </div>\n ) : (\n label\n )}\n </label>\n </div>\n );\n })}\n </fieldset>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;IA8Ba,KAAK,GAAG,UAA2B,EAYxB;;QAXtB,OAAO,aAAA,EACP,KAAK,WAAA,EACL,QAAQ,cAAA,EACR,YAAY,EAAZ,IAAI,mBAAG,KAAK,KAAA,EACZ,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA,EACpB,kBAAkB,EAAlB,UAAU,mBAAG,KAAK,KAAA,EACN,aAAa,gBAAA,EACzB,gBAAe,EAAf,QAAQ,mBAAG,IAAI,KAAA,EACf,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,mBAAgC,EAAhC,WAAW,mBAAG,kBAAkB,KAAA,EAChC,SAAS,eAAA;IAET,IAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAGnC,CAAC;IAEJ,IAAM,IAAI,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,UAAU,EAAE,CAAC;IAEvC,QACEA,mBACE,SAAS,EAAE,UAAU,CACnB,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,EACxB,MAAM,CAAC,SAAS,EAChB,aAAa;YAEX,GAAC,MAAM,CAAC,IAAI,IAAG,IAAI;YACnB,GAAC,MAAM,CAAC,MAAM,IAAG,CAAC,IAAI;YACtB,YAAQ,GAAE,YAAY;YACtB,YAAQ,GAAE,YAAY;YACtB,eAAW,GAAE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,UAAU,KACTC,aACE,SAAS,EAAE,UAAU,CACnB,mCAAmC,EACnC,UAAU,GAAG,KAAK,GAAG,KAAK,CAC3B,YAEA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,OAAO,CAAC,GAClB,CACP,EAEA,kBAAkB,CAAC,KAAK,CAAC,IACxBD,yBACEC,WAAG,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,KAAK,GAAK,EACpCA,cAAM,SAAS,EAAC,oCAAoC,YACjD,KAAK,CAAC,WAAW,GACb,IACH,KAEN,KAAK,CACN,IACK,KA/CkC,YAAY,CAgDlD,EACN;aACH,CAAC,IACO,EACX;AACJ;;;;"}
|
|
@@ -4,6 +4,7 @@ import { Radio } from './index.js';
|
|
|
4
4
|
import { a as images } from '../../../index-29e6f39e.js';
|
|
5
5
|
import '../../../index-6ea95111.js';
|
|
6
6
|
import '../../../style-inject.es-1f59c1d0.js';
|
|
7
|
+
import '../../../index-69a46657.js';
|
|
7
8
|
|
|
8
9
|
var story = {
|
|
9
10
|
title: 'JSX/Inputs/Radio',
|
|
@@ -15,6 +16,12 @@ var story = {
|
|
|
15
16
|
value: {
|
|
16
17
|
description: 'Current checked values.',
|
|
17
18
|
},
|
|
19
|
+
fieldLegend: {
|
|
20
|
+
description: 'Property that describes the purpose of a group of radio buttons, read aloud by screen readers to provide context.',
|
|
21
|
+
},
|
|
22
|
+
groupName: {
|
|
23
|
+
description: 'Property passed to each radio button. Informs the browser that the radio buttons belong to the same group, so only one can be selected',
|
|
24
|
+
},
|
|
18
25
|
onChange: {
|
|
19
26
|
description: 'Function called everytime a value changes.',
|
|
20
27
|
action: true,
|
|
@@ -56,6 +63,8 @@ var story = {
|
|
|
56
63
|
description: 'No pets',
|
|
57
64
|
},
|
|
58
65
|
},
|
|
66
|
+
fieldLegend: 'Owned pets',
|
|
67
|
+
groupName: 'Pets',
|
|
59
68
|
value: '',
|
|
60
69
|
wide: false,
|
|
61
70
|
classNames: {
|
|
@@ -67,16 +76,16 @@ var story = {
|
|
|
67
76
|
inlineLayout: false,
|
|
68
77
|
inlineIcon: false,
|
|
69
78
|
disabled: false,
|
|
70
|
-
}
|
|
79
|
+
},
|
|
71
80
|
};
|
|
72
81
|
var RadioStory = function (_a) {
|
|
73
|
-
var onChange = _a.onChange, options = _a.options, wide = _a.wide, classNames = _a.classNames, inlineLayout = _a.inlineLayout, bordered = _a.bordered, disabled = _a.disabled;
|
|
82
|
+
var onChange = _a.onChange, options = _a.options, wide = _a.wide, classNames = _a.classNames, inlineLayout = _a.inlineLayout, bordered = _a.bordered, disabled = _a.disabled, fieldLegend = _a.fieldLegend, groupName = _a.groupName;
|
|
74
83
|
var _b = useState(), checkedValues = _b[0], setCheckedValues = _b[1];
|
|
75
84
|
var handleOnChange = function (newValue) {
|
|
76
85
|
setCheckedValues(newValue);
|
|
77
86
|
onChange(newValue);
|
|
78
87
|
};
|
|
79
|
-
return (jsx(Radio, { wide: wide, options: options, onChange: handleOnChange, value: checkedValues, classNames: classNames, inlineLayout: inlineLayout, bordered: bordered, disabled: disabled }));
|
|
88
|
+
return (jsx(Radio, { wide: wide, options: options, onChange: handleOnChange, value: checkedValues, classNames: classNames, inlineLayout: inlineLayout, bordered: bordered, disabled: disabled, fieldLegend: fieldLegend, groupName: groupName }));
|
|
80
89
|
};
|
|
81
90
|
var RadioWithCustomWrapperStyles = function (_a) {
|
|
82
91
|
var onChange = _a.onChange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.stories.js","sources":["../../../../../../src/lib/components/input/radio/index.stories.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Radio, RadioProps } from '.';\nimport { images } from '../../../util/images';\n\nconst story = {\n title: 'JSX/Inputs/Radio',\n component: Radio,\n argTypes: {\n options: {\n description:\n 'Object that contains the possible options for rendering in the input.',\n },\n value: {\n description: 'Current checked values.',\n },\n onChange: {\n description: 'Function called everytime a value changes.',\n action: true,\n table: {\n category: 'Callbacks',\n },\n },\n wide: {\n description:\n 'Property that defines if options should fill 100% of available horizontal space',\n },\n inlineLayout: {\n description:\n 'Property that defines if options should show inline instead of block. Check inline radio options story for examples.',\n },\n inlineIcon: {\n description: 'Property that defines if options should show inline with icon',\n },\n classNames: {\n description: 'ClassNames for custom styling',\n },\n bordered: {\n description: 'Property that defines if option should show with border',\n },\n disabled: {\n description:\n 'Property that defines if the input and corresponding label are disabled and not clickable',\n },\n },\n args: {\n options: {\n CAT: {\n title: 'Cat',\n description: 'At least 1',\n },\n DOG: {\n title: 'Dog',\n description: 'At least 2',\n },\n NONE: {\n title: 'None',\n description: 'No pets',\n },\n },\n value: '',\n wide: false,\n classNames: {\n container: '',\n label: '',\n option: '',\n },\n bordered: true,\n inlineLayout: false,\n inlineIcon: false,\n disabled: false,\n }\n};\n\nexport const RadioStory = ({\n onChange,\n options,\n wide,\n classNames,\n inlineLayout,\n bordered,\n disabled,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n wide={wide}\n options={options}\n onChange={handleOnChange}\n value={checkedValues}\n classNames={classNames}\n inlineLayout={inlineLayout}\n bordered={bordered}\n disabled={disabled}\n />\n );\n};\n\nexport const RadioWithCustomWrapperStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT1: 'Cat',\n DOG1: 'Dog',\n }}\n classNames={{ container: 'p32 bg-primary-300 br24 bs-lg' }}\n />\n );\n};\n\nexport const RadioWithCustomOptionStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT2: 'Cat',\n DOG2: 'Dog',\n }}\n classNames={{ option: 'mb32 p24 bg-green-100 br12 bs-lg' }}\n />\n );\n};\n\nexport const RadioWithCustomLabelStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT3: 'Cat',\n DOG3: 'Dog',\n }}\n classNames={{ label: 'bg-grey-900 tc-white' }}\n />\n );\n};\n\nexport const RadioWithInlineLayout = ({ onChange }: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT4: 'Cat',\n DOG4: 'Dog',\n FISHER: 'Fish',\n RABBIT: 'Rabbit',\n RAT: 'Rat',\n ANOTHER: 'Other',\n }}\n classNames={{ option: 'w30' }}\n inlineLayout\n wide\n />\n );\n};\n\nexport const RadioWithCustomLabel = ({\n onChange,\n wide,\n classNames,\n inlineLayout,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n options={{\n BIGDOG: {\n icon: () => <img src={images.bigDog} alt=\"\" />,\n title: 'Dog',\n },\n FISH: {\n icon: () => <img src={images.brokenAquarium} alt=\"\" />,\n title: 'Fish',\n },\n OTHER: {\n icon: () => <img src={images.brokenGlass} alt=\"\" />,\n title: 'Other',\n },\n }}\n onChange={handleOnChange}\n value={checkedValues}\n classNames={{ option: 'w30' }}\n inlineLayout\n />\n );\n};\n\nexport const RadioWithCustomLabelInline = ({\n onChange,\n wide,\n classNames,\n inlineLayout,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n options={{\n BIGDOG: {\n icon: () => <img src={images.bigDog} alt=\"\" />,\n title: 'Dog',\n },\n FISH: {\n icon: () => <img src={images.brokenAquarium} alt=\"\" />,\n title: 'Fish',\n },\n OTHER: {\n icon: () => <img src={images.brokenGlass} alt=\"\" />,\n title: 'Other',\n },\n }}\n onChange={handleOnChange}\n inlineIcon\n value={checkedValues}\n classNames={{ option: 'w30' }}\n inlineLayout\n />\n );\n};\n\nRadioStory.storyName = 'Radio';\n\nexport const RadioIconOnly = ({ onChange }: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n options={{ NOTHING: '' }}\n onChange={handleOnChange}\n classNames={{ label: 'jc-start' }}\n value={checkedValues}\n bordered={false}\n />\n );\n};\n\nRadioStory.storyName = 'Radio';\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;IAIM,KAAK,GAAG;IACZ,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,WAAW,EACT,uEAAuE;SAC1E;QACD,KAAK,EAAE;YACL,WAAW,EAAE,yBAAyB;SACvC;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,4CAA4C;YACzD,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE;gBACL,QAAQ,EAAE,WAAW;aACtB;SACF;QACD,IAAI,EAAE;YACJ,WAAW,EACT,iFAAiF;SACpF;QACD,YAAY,EAAE;YACZ,WAAW,EACT,sHAAsH;SACzH;QACD,UAAU,EAAE;YACV,WAAW,EAAE,+DAA+D;SAC7E;QACD,UAAU,EAAE;YACV,WAAW,EAAE,+BAA+B;SAC7C;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,yDAAyD;SACvE;QACD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Aa,EACpB,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAC7B,YAAY,SACZ,EACF;AACJ,EAAE;AAEF,UAAU,CAAC,SAAS,GAAG,OAAO,CAAC;IAElB,aAAa,GAAG,UAAC,EAAgC;QAA9B,QAAQ,cAAA;IAChC,IAAA,KAAoC,QAAQ,EAAU,EAArD,aAAa,QAAA,EAAE,gBAAgB,QAAsB,CAAC;IAE7D,IAAM,cAAc,GAAG,UAAC,QAAgB;QACtC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC3B,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACpB,CAAC;IAEF,QACEA,IAAC,KAAK,IACJ,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EACxB,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,EACjC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,KAAK,GACf,EACF;AACJ,EAAE;AAEF,UAAU,CAAC,SAAS,GAAG,OAAO;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.stories.js","sources":["../../../../../../src/lib/components/input/radio/index.stories.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Radio, RadioProps } from '.';\nimport { images } from '../../../util/images';\n\nconst story = {\n title: 'JSX/Inputs/Radio',\n component: Radio,\n argTypes: {\n options: {\n description:\n 'Object that contains the possible options for rendering in the input.',\n },\n value: {\n description: 'Current checked values.',\n },\n fieldLegend: {\n description:\n 'Property that describes the purpose of a group of radio buttons, read aloud by screen readers to provide context.',\n },\n groupName: {\n description:\n 'Property passed to each radio button. Informs the browser that the radio buttons belong to the same group, so only one can be selected',\n },\n onChange: {\n description: 'Function called everytime a value changes.',\n action: true,\n table: {\n category: 'Callbacks',\n },\n },\n wide: {\n description:\n 'Property that defines if options should fill 100% of available horizontal space',\n },\n inlineLayout: {\n description:\n 'Property that defines if options should show inline instead of block. Check inline radio options story for examples.',\n },\n inlineIcon: {\n description:\n 'Property that defines if options should show inline with icon',\n },\n classNames: {\n description: 'ClassNames for custom styling',\n },\n bordered: {\n description: 'Property that defines if option should show with border',\n },\n disabled: {\n description:\n 'Property that defines if the input and corresponding label are disabled and not clickable',\n },\n },\n args: {\n options: {\n CAT: {\n title: 'Cat',\n description: 'At least 1',\n },\n DOG: {\n title: 'Dog',\n description: 'At least 2',\n },\n NONE: {\n title: 'None',\n description: 'No pets',\n },\n },\n fieldLegend: 'Owned pets',\n groupName: 'Pets',\n value: '',\n wide: false,\n classNames: {\n container: '',\n label: '',\n option: '',\n },\n bordered: true,\n inlineLayout: false,\n inlineIcon: false,\n disabled: false,\n },\n};\n\nexport const RadioStory = ({\n onChange,\n options,\n wide,\n classNames,\n inlineLayout,\n bordered,\n disabled,\n fieldLegend,\n groupName,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n wide={wide}\n options={options}\n onChange={handleOnChange}\n value={checkedValues}\n classNames={classNames}\n inlineLayout={inlineLayout}\n bordered={bordered}\n disabled={disabled}\n fieldLegend={fieldLegend}\n groupName={groupName}\n />\n );\n};\n\nexport const RadioWithCustomWrapperStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT1: 'Cat',\n DOG1: 'Dog',\n }}\n classNames={{ container: 'p32 bg-primary-300 br24 bs-lg' }}\n />\n );\n};\n\nexport const RadioWithCustomOptionStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT2: 'Cat',\n DOG2: 'Dog',\n }}\n classNames={{ option: 'mb32 p24 bg-green-100 br12 bs-lg' }}\n />\n );\n};\n\nexport const RadioWithCustomLabelStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT3: 'Cat',\n DOG3: 'Dog',\n }}\n classNames={{ label: 'bg-grey-900 tc-white' }}\n />\n );\n};\n\nexport const RadioWithInlineLayout = ({ onChange }: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT4: 'Cat',\n DOG4: 'Dog',\n FISHER: 'Fish',\n RABBIT: 'Rabbit',\n RAT: 'Rat',\n ANOTHER: 'Other',\n }}\n classNames={{ option: 'w30' }}\n inlineLayout\n wide\n />\n );\n};\n\nexport const RadioWithCustomLabel = ({\n onChange,\n wide,\n classNames,\n inlineLayout,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n options={{\n BIGDOG: {\n icon: () => <img src={images.bigDog} alt=\"\" />,\n title: 'Dog',\n },\n FISH: {\n icon: () => <img src={images.brokenAquarium} alt=\"\" />,\n title: 'Fish',\n },\n OTHER: {\n icon: () => <img src={images.brokenGlass} alt=\"\" />,\n title: 'Other',\n },\n }}\n onChange={handleOnChange}\n value={checkedValues}\n classNames={{ option: 'w30' }}\n inlineLayout\n />\n );\n};\n\nexport const RadioWithCustomLabelInline = ({\n onChange,\n wide,\n classNames,\n inlineLayout,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n options={{\n BIGDOG: {\n icon: () => <img src={images.bigDog} alt=\"\" />,\n title: 'Dog',\n },\n FISH: {\n icon: () => <img src={images.brokenAquarium} alt=\"\" />,\n title: 'Fish',\n },\n OTHER: {\n icon: () => <img src={images.brokenGlass} alt=\"\" />,\n title: 'Other',\n },\n }}\n onChange={handleOnChange}\n inlineIcon\n value={checkedValues}\n classNames={{ option: 'w30' }}\n inlineLayout\n />\n );\n};\n\nRadioStory.storyName = 'Radio';\n\nexport const RadioIconOnly = ({ onChange }: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n options={{ NOTHING: '' }}\n onChange={handleOnChange}\n classNames={{ label: 'jc-start' }}\n value={checkedValues}\n bordered={false}\n />\n );\n};\n\nRadioStory.storyName = 'Radio';\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;IAIM,KAAK,GAAG;IACZ,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,WAAW,EACT,uEAAuE;SAC1E;QACD,KAAK,EAAE;YACL,WAAW,EAAE,yBAAyB;SACvC;QACD,WAAW,EAAE;YACX,WAAW,EACT,mHAAmH;SACtH;QACD,SAAS,EAAE;YACT,WAAW,EACT,wIAAwI;SAC3I;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,4CAA4C;YACzD,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE;gBACL,QAAQ,EAAE,WAAW;aACtB;SACF;QACD,IAAI,EAAE;YACJ,WAAW,EACT,iFAAiF;SACpF;QACD,YAAY,EAAE;YACZ,WAAW,EACT,sHAAsH;SACzH;QACD,UAAU,EAAE;YACV,WAAW,EACT,+DAA+D;SAClE;QACD,UAAU,EAAE;YACV,WAAW,EAA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,EAAE;gBACL,IAAI,EAAE,cAAM,OAAAA,aAAK,GAAG,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,EAAC,EAAE,GAAG,GAAA;gBACnD,KAAK,EAAE,OAAO;aACf;SACF,EACD,QAAQ,EAAE,cAAc,EACxB,UAAU,QACV,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAC7B,YAAY,SACZ,EACF;AACJ,EAAE;AAEF,UAAU,CAAC,SAAS,GAAG,OAAO,CAAC;IAElB,aAAa,GAAG,UAAC,EAAgC;QAA9B,QAAQ,cAAA;IAChC,IAAA,KAAoC,QAAQ,EAAU,EAArD,aAAa,QAAA,EAAE,gBAAgB,QAAsB,CAAC;IAE7D,IAAM,cAAc,GAAG,UAAC,QAAgB;QACtC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC3B,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACpB,CAAC;IAEF,QACEA,IAAC,KAAK,IACJ,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EACxB,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,EACjC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,KAAK,GACf,EACF;AACJ,EAAE;AAEF,UAAU,CAAC,SAAS,GAAG,OAAO;;;;;"}
|
|
@@ -8,6 +8,7 @@ import '../../../_commonjsHelpers-4730bd53.js';
|
|
|
8
8
|
import 'react-dom/test-utils';
|
|
9
9
|
import '../../../index-6ea95111.js';
|
|
10
10
|
import '../../../style-inject.es-1f59c1d0.js';
|
|
11
|
+
import '../../../index-69a46657.js';
|
|
11
12
|
|
|
12
13
|
var mockOnChange = jest.fn();
|
|
13
14
|
var setup = function (onChange, value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sources":["../../../../../../src/lib/components/input/radio/index.test.tsx"],"sourcesContent":["import { render } from '../../../util/testUtils';\n\nimport { Radio, RadioProps } from '.';\n\nconst mockOnChange = jest.fn();\n\nconst setup = (onChange: RadioProps<string>['onChange'], value?: string) => {\n const utils = render(\n <Radio\n options={{\n CAT: 'Cat',\n DOG: 'Dog',\n NONE: 'None',\n }}\n onChange={onChange}\n value={value}\n />\n );\n\n return utils;\n};\n\ndescribe('Radio component', () => {\n it('Should render options', () => {\n const { getByText } = setup(mockOnChange);\n\n expect(getByText('Cat')).toBeInTheDocument();\n expect(getByText('Dog')).toBeInTheDocument();\n expect(getByText('None')).toBeInTheDocument();\n });\n\n it('Should call onchange on selecting an option', async () => {\n const { getByTestId, user } = setup(mockOnChange);\n\n await user.click(getByTestId('radio-DOG'));\n\n expect(mockOnChange).toBeCalledWith('DOG');\n });\n\n it('Should render checked items when value is passed', async () => {\n const { getByTestId } = setup(mockOnChange, 'CAT');\n\n expect(getByTestId('radio-input-CAT')).toBeChecked();\n });\n\n it('Should render custom description', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('Cat description')).toBeInTheDocument();\n });\n\n it('Should render custom icon', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n icon: () => 'ICON',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('ICON')).toBeInTheDocument();\n });\n\n it('Should render custom icon with selected', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n icon: (selected) => (selected ? 'SELECTED-ICON' : 'ICON'),\n },\n }}\n onChange={mockOnChange}\n value={'CAT'}\n />\n );\n\n expect(getByText('SELECTED-ICON')).toBeInTheDocument();\n });\n\n it('Should render label text passed in HTML format', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: <p>Cat</p>,\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('Cat')).toBeInTheDocument();\n });\n\n it('Should disable the input', async () => {\n const { getByTestId } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n disabled\n />\n );\n\n const radioInput = getByTestId('radio-input-CAT');\n\n expect(radioInput).toBeDisabled();\n });\n});\n"],"names":["render","_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.test.js","sources":["../../../../../../src/lib/components/input/radio/index.test.tsx"],"sourcesContent":["import { render } from '../../../util/testUtils';\n\nimport { Radio, RadioProps } from '.';\n\nconst mockOnChange = jest.fn();\n\nconst setup = (onChange: RadioProps<string>['onChange'], value?: string) => {\n const utils = render(\n <Radio\n options={{\n CAT: 'Cat',\n DOG: 'Dog',\n NONE: 'None',\n }}\n onChange={onChange}\n value={value}\n />\n );\n\n return utils;\n};\n\ndescribe('Radio component', () => {\n it('Should render options', () => {\n const { getByText } = setup(mockOnChange);\n\n expect(getByText('Cat')).toBeInTheDocument();\n expect(getByText('Dog')).toBeInTheDocument();\n expect(getByText('None')).toBeInTheDocument();\n });\n\n it('Should call onchange on selecting an option', async () => {\n const { getByTestId, user } = setup(mockOnChange);\n\n await user.click(getByTestId('radio-DOG'));\n\n expect(mockOnChange).toBeCalledWith('DOG');\n });\n\n it('Should render checked items when value is passed', async () => {\n const { getByTestId } = setup(mockOnChange, 'CAT');\n\n expect(getByTestId('radio-input-CAT')).toBeChecked();\n });\n\n it('Should render custom description', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('Cat description')).toBeInTheDocument();\n });\n\n it('Should render custom icon', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n icon: () => 'ICON',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('ICON')).toBeInTheDocument();\n });\n\n it('Should render custom icon with selected', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n icon: (selected) => (selected ? 'SELECTED-ICON' : 'ICON'),\n },\n }}\n onChange={mockOnChange}\n value={'CAT'}\n />\n );\n\n expect(getByText('SELECTED-ICON')).toBeInTheDocument();\n });\n\n it('Should render label text passed in HTML format', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: <p>Cat</p>,\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('Cat')).toBeInTheDocument();\n });\n\n it('Should disable the input', async () => {\n const { getByTestId } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n disabled\n />\n );\n\n const radioInput = getByTestId('radio-input-CAT');\n\n expect(radioInput).toBeDisabled();\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;AAIA,IAAM,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAE/B,IAAM,KAAK,GAAG,UAAC,QAAwC,EAAE,KAAc;IACrE,IAAM,KAAK,GAAGA,YAAM,CAClBC,IAAC,KAAK,IACJ,OAAO,EAAE;YACP,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,QAAQ,CAAC,iBAAiB,EAAE;IAC1B,EAAE,CAAC,uBAAuB,EAAE;QAClB,IAAA,SAAS,GAAK,KAAK,CAAC,YAAY,CAAC,UAAxB,CAAyB;QAE1C,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC7C,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC7C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KAC/C,CAAC,CAAC;IAEH,E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KD,YAAM,CAC1BC,IAAC,KAAK,IACJ,OAAO,EAAE;gBACP,GAAG,EAAE;oBACH,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,UAAC,QAAQ,IAAK,QAAC,QAAQ,GAAG,eAAe,GAAG,MAAM,IAAC;iBAC1D;aACF,EACD,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,KAAK,GACZ,CACH,UAXgB,CAWf;QAEF,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KACxD,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE;QAC3C,IAAA,SAAS,GAAKD,YAAM,CAC1BC,IAAC,KAAK,IACJ,OAAO,EAAE;gBACP,GAAG,EAAE;oBACH,KAAK,EAAEA,6BAAU;oBACjB,WAAW,EAAE,iBAAiB;iBAC/B;aACF,EACD,QAAQ,EAAE,YAAY,GACtB,CACH,UAVgB,CAUf;QAEF,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KAC9C,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE;;;YACrB,WAAW,GAAKD,YAAM,CAC5BC,IAAC,KAAK,IACJ,OAAO,EAAE;oBACP,GAAG,EAAE;wBACH,KAAK,EAAE,KAAK;wBACZ,WAAW,EAAE,iBAAiB;qBAC/B;iBACF,EACD,QAAQ,EAAE,YAAY,EACtB,QAAQ,SACR,CACH,YAXkB,CAWjB;YAEI,UAAU,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;YAElD,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,EAAE,CAAC;;;SACnC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -4,18 +4,19 @@ import { s as styleInject } from '../../../style-inject.es-1f59c1d0.js';
|
|
|
4
4
|
import EyeVisionIcon from '../../icon/icons/EyeVision.js';
|
|
5
5
|
import FileIcon from '../../icon/icons/File.js';
|
|
6
6
|
import Trash2Icon from '../../icon/icons/Trash2.js';
|
|
7
|
+
import { Button } from '../../button/index.js';
|
|
7
8
|
import 'react';
|
|
8
9
|
import '../../icon/IconWrapper/IconWrapper.js';
|
|
9
10
|
import '../../../tslib.es6-a39f91fc.js';
|
|
10
11
|
|
|
11
|
-
var css_248z = ".style-module_upload-file-cell__3nv5i {\n display: flex;\n align-items: center;\n justify-content: space-between;\n min-height: 64px;\n padding: 8px 16px;\n border: 1px solid #d2d2d8;\n border-radius: 8px;\n background-color: white;\n animation: style-module_appear-down__14rCV 0.6s;\n animation-fill-mode: both;\n animation-delay: 0s;\n}\n\n.style-module_upload-file-cell-error__3KcSe {\n border-color: #e55454;\n background-color: rgba(229, 84, 84, 0.2);\n}\n\n.style-module_cell-left-section__3Iv8c {\n display: flex;\n align-items: center;\n}\n\n.style-
|
|
12
|
-
var styles = {"upload-file-cell":"style-module_upload-file-cell__3nv5i","appear-down":"style-module_appear-down__14rCV","upload-file-cell-error":"style-module_upload-file-cell-error__3KcSe","cell-left-section":"style-module_cell-left-section__3Iv8c","
|
|
12
|
+
var css_248z = ".style-module_upload-file-cell__3nv5i {\n display: flex;\n align-items: center;\n justify-content: space-between;\n min-height: 64px;\n padding: 8px 16px;\n border: 1px solid #d2d2d8;\n border-radius: 8px;\n background-color: white;\n animation: style-module_appear-down__14rCV 0.6s;\n animation-fill-mode: both;\n animation-delay: 0s;\n}\n\n.style-module_upload-file-cell-error__3KcSe {\n border-color: #e55454;\n background-color: rgba(229, 84, 84, 0.2);\n}\n\n.style-module_cell-left-section__3Iv8c {\n display: flex;\n align-items: center;\n}\n\n.style-module_main-icon__335_Y {\n margin-right: 16px;\n}\n\n.style-module_upload-display-text__3Rd68 {\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n\n.style-module_progress-bar-container__2JCBO {\n position: relative;\n}\n\n.style-module_progress-bar__1Rosf {\n background-color: #f5f6fb;\n border-radius: 10px;\n height: 4px;\n}\n\n.style-module_progress-bar-filler__131fA {\n background-color: #8e8cee;\n border-radius: 10px;\n height: 4px;\n position: absolute;\n bottom: 0;\n transition: 1s ease;\n}\n\n.style-module_cell-right-section__dVWqJ {\n display: flex;\n}\n\n.style-module_cell-right-section-complete__c0rHc {\n min-width: 64px;\n}\n\n.style-module_button__xo5tR {\n width: 32px;\n}\n.style-module_button__xo5tR div span span {\n min-width: 24px !important;\n height: 24px !important;\n}\n.style-module_button__xo5tR:focus-visible {\n outline: 2px solid #26262e;\n border-radius: 2px;\n outline-offset: 2px;\n}\n\n@keyframes style-module_appear-down__14rCV {\n from {\n transform: translateY(-10px);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n}";
|
|
13
|
+
var styles = {"upload-file-cell":"style-module_upload-file-cell__3nv5i","appear-down":"style-module_appear-down__14rCV","upload-file-cell-error":"style-module_upload-file-cell-error__3KcSe","cell-left-section":"style-module_cell-left-section__3Iv8c","main-icon":"style-module_main-icon__335_Y","upload-display-text":"style-module_upload-display-text__3Rd68","progress-bar-container":"style-module_progress-bar-container__2JCBO","progress-bar":"style-module_progress-bar__1Rosf","progress-bar-filler":"style-module_progress-bar-filler__131fA","cell-right-section":"style-module_cell-right-section__dVWqJ","cell-right-section-complete":"style-module_cell-right-section-complete__c0rHc","button":"style-module_button__xo5tR"};
|
|
13
14
|
styleInject(css_248z);
|
|
14
15
|
|
|
15
16
|
var UploadFileCell = function (_a) {
|
|
16
|
-
var _b, _c
|
|
17
|
+
var _b, _c;
|
|
17
18
|
var uploadStatus = _a.uploadStatus, file = _a.file, onRemoveFile = _a.onRemoveFile, uploading = _a.uploading;
|
|
18
|
-
var id = file.id, error = file.error, name = file.name, progress = file.progress, previewUrl = file.previewUrl,
|
|
19
|
+
var id = file.id, error = file.error, name = file.name, progress = file.progress, previewUrl = file.previewUrl, _d = file.showLoadingSpinner, showLoadingSpinner = _d === void 0 ? false : _d, _e = file.showProgressBar, showProgressBar = _e === void 0 ? true : _e;
|
|
19
20
|
var isComplete = uploadStatus === 'COMPLETE';
|
|
20
21
|
var isUploading = uploadStatus === 'UPLOADING';
|
|
21
22
|
var hasError = uploadStatus === 'ERROR';
|
|
@@ -33,9 +34,7 @@ var UploadFileCell = function (_a) {
|
|
|
33
34
|
_b[styles['upload-file-cell-error']] = hasError,
|
|
34
35
|
_b)), children: [jsxs("div", { className: "w100 ".concat(styles['cell-left-section']), children: [jsx(FileIcon, { className: classNames("".concat(styles['main-icon'], " ").concat(styles.icon)), color: mapFileIconColor[uploadStatus], size: 24 }), jsxs("div", { className: "w100", children: [jsx("div", { className: "p-p ".concat(styles['upload-display-text']), title: displayText, children: displayText }), isUploading && showProgressBar && (jsxs("div", { className: "mt8 w100 ".concat(styles['progress-bar-container']), children: [jsx("div", { className: "".concat(styles['progress-bar']) }), jsx("div", { "data-testid": "ds-filecell-progressbar", className: "".concat(styles['progress-bar-filler']), style: { width: "".concat(progress, "%") } })] }))] })] }), jsx("div", { className: classNames(styles['cell-right-section'], (_c = {},
|
|
35
36
|
_c[styles['cell-right-section-complete']] = isComplete,
|
|
36
|
-
_c)), children: isUploading ? (jsx("div", { className: styles.spinner, children: showLoadingSpinner && (jsx("div", { className: "ds-spinner ds-spinner__m", "data-testid": "ds-filecell-spinner" })) })) : (jsxs(Fragment, { children: [isComplete && (jsx(
|
|
37
|
-
_d[styles.disabled] = uploading,
|
|
38
|
-
_d)), "data-testid": "remove-button", children: jsx(Trash2Icon, { color: hasError ? 'red-500' : 'grey-500', size: 24, className: styles.icon }) }))] })) })] }));
|
|
37
|
+
_c)), children: isUploading ? (jsx("div", { className: styles.spinner, children: showLoadingSpinner && (jsx("div", { className: "ds-spinner ds-spinner__m", "data-testid": "ds-filecell-spinner" })) })) : (jsxs(Fragment, { children: [isComplete && (jsx(Button, { as: "a", href: previewUrl, target: "_blank", rel: "noopener noreferrer", hideLabel: true, variant: "filledWhite", className: classNames('mr16', styles.button), leftIcon: jsx(EyeVisionIcon, { noMargin: true, color: 'grey-500', size: 24 }), children: "Preview file" })), onRemoveFile && (jsx(Button, { onClick: function () { return onRemoveFile(id); }, disabled: uploading, "data-testid": "remove-button", className: styles.button, leftIcon: jsx(Trash2Icon, { color: hasError ? 'red-500' : 'grey-500', size: 24, noMargin: true }), hideLabel: true, variant: "filledWhite", children: "Delete file" }))] })) })] }));
|
|
39
38
|
};
|
|
40
39
|
|
|
41
40
|
export default UploadFileCell;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/multiDropzone/UploadFileCell/index.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\n\nimport styles from './style.module.scss';\nimport { FileIcon, Trash2Icon, EyeVisionIcon } from '../../icon/icons';\nimport { Color } from '../../../models/styles';\nimport { UploadStatus, UploadedFile } from '../types';\n\ninterface Props {\n uploadStatus: UploadStatus;\n file: UploadedFile;\n onRemoveFile?: (id: string) => void;\n uploading: boolean;\n}\n\nconst UploadFileCell: React.FC<Props> = ({\n uploadStatus,\n file,\n onRemoveFile,\n uploading,\n}) => {\n const {\n id,\n error,\n name,\n progress,\n previewUrl,\n showLoadingSpinner = false,\n showProgressBar = true,\n } = file;\n\n const isComplete = uploadStatus === 'COMPLETE';\n const isUploading = uploadStatus === 'UPLOADING';\n const hasError = uploadStatus === 'ERROR';\n\n const mapFileIconColor: { [k in UploadStatus]: Color } = {\n UPLOADING: 'purple-500',\n COMPLETE: 'grey-500',\n ERROR: 'red-500',\n };\n\n const displayText = {\n UPLOADING: 'Uploading...',\n COMPLETE: name,\n ERROR: error ?? 'Something went wrong. Try uploading again.',\n }[uploadStatus];\n\n return (\n <div\n className={classnames(`mt8 ${styles['upload-file-cell']}`, {\n [styles['upload-file-cell-error']]: hasError,\n })}\n >\n <div className={`w100 ${styles['cell-left-section']}`}>\n <FileIcon\n className={classnames(`${styles['main-icon']} ${styles.icon}`)}\n color={mapFileIconColor[uploadStatus]}\n size={24}\n />\n <div className=\"w100\">\n <div\n className={`p-p ${styles['upload-display-text']}`}\n title={displayText}\n >\n {displayText}\n </div>\n\n {isUploading && showProgressBar && (\n <div className={`mt8 w100 ${styles['progress-bar-container']}`}>\n <div className={`${styles['progress-bar']}`} />\n <div\n data-testid=\"ds-filecell-progressbar\"\n className={`${styles['progress-bar-filler']}`}\n style={{ width: `${progress}%` }}\n />\n </div>\n )}\n </div>\n </div>\n <div\n className={classnames(styles['cell-right-section'], {\n [styles['cell-right-section-complete']]: isComplete,\n })}\n >\n {isUploading ? (\n <div className={styles.spinner}>\n {showLoadingSpinner && (\n <div\n className=\"ds-spinner ds-spinner__m\"\n data-testid=\"ds-filecell-spinner\"\n />\n )}\n </div>\n ) : (\n <>\n {isComplete && (\n <
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/multiDropzone/UploadFileCell/index.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\n\nimport styles from './style.module.scss';\nimport { FileIcon, Trash2Icon, EyeVisionIcon } from '../../icon/icons';\nimport { Color } from '../../../models/styles';\nimport { UploadStatus, UploadedFile } from '../types';\nimport { Button } from '../../button';\n\ninterface Props {\n uploadStatus: UploadStatus;\n file: UploadedFile;\n onRemoveFile?: (id: string) => void;\n uploading: boolean;\n}\n\nconst UploadFileCell: React.FC<Props> = ({\n uploadStatus,\n file,\n onRemoveFile,\n uploading,\n}) => {\n const {\n id,\n error,\n name,\n progress,\n previewUrl,\n showLoadingSpinner = false,\n showProgressBar = true,\n } = file;\n\n const isComplete = uploadStatus === 'COMPLETE';\n const isUploading = uploadStatus === 'UPLOADING';\n const hasError = uploadStatus === 'ERROR';\n\n const mapFileIconColor: { [k in UploadStatus]: Color } = {\n UPLOADING: 'purple-500',\n COMPLETE: 'grey-500',\n ERROR: 'red-500',\n };\n\n const displayText = {\n UPLOADING: 'Uploading...',\n COMPLETE: name,\n ERROR: error ?? 'Something went wrong. Try uploading again.',\n }[uploadStatus];\n\n return (\n <div\n className={classnames(`mt8 ${styles['upload-file-cell']}`, {\n [styles['upload-file-cell-error']]: hasError,\n })}\n >\n <div className={`w100 ${styles['cell-left-section']}`}>\n <FileIcon\n className={classnames(`${styles['main-icon']} ${styles.icon}`)}\n color={mapFileIconColor[uploadStatus]}\n size={24}\n />\n <div className=\"w100\">\n <div\n className={`p-p ${styles['upload-display-text']}`}\n title={displayText}\n >\n {displayText}\n </div>\n\n {isUploading && showProgressBar && (\n <div className={`mt8 w100 ${styles['progress-bar-container']}`}>\n <div className={`${styles['progress-bar']}`} />\n <div\n data-testid=\"ds-filecell-progressbar\"\n className={`${styles['progress-bar-filler']}`}\n style={{ width: `${progress}%` }}\n />\n </div>\n )}\n </div>\n </div>\n <div\n className={classnames(styles['cell-right-section'], {\n [styles['cell-right-section-complete']]: isComplete,\n })}\n >\n {isUploading ? (\n <div className={styles.spinner}>\n {showLoadingSpinner && (\n <div\n className=\"ds-spinner ds-spinner__m\"\n data-testid=\"ds-filecell-spinner\"\n />\n )}\n </div>\n ) : (\n <>\n {isComplete && (\n <Button\n as=\"a\"\n href={previewUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n hideLabel\n variant=\"filledWhite\"\n className={classnames('mr16', styles.button)}\n leftIcon={\n <EyeVisionIcon noMargin color={'grey-500'} size={24} />\n }\n >\n Preview file\n </Button>\n )}\n\n {onRemoveFile && (\n <Button\n onClick={() => onRemoveFile(id)}\n disabled={uploading}\n data-testid=\"remove-button\"\n className={styles.button}\n leftIcon={\n <Trash2Icon\n color={hasError ? 'red-500' : 'grey-500'}\n size={24}\n noMargin\n />\n }\n hideLabel\n variant=\"filledWhite\"\n >\n Delete file\n </Button>\n )}\n </>\n )}\n </div>\n </div>\n );\n};\n\nexport default UploadFileCell;\n"],"names":["_jsxs","classnames","_jsx"],"mappings":";;;;;;;;;;;;;;;IAgBM,cAAc,GAAoB,UAAC,EAKxC;;QAJC,YAAY,kBAAA,EACZ,IAAI,UAAA,EACJ,YAAY,kBAAA,EACZ,SAAS,eAAA;IAGP,IA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,aAAa,4BAGd,CACV,IACA,CACJ,GACG,IACF,EACN;AACJ;;;;"}
|
|
@@ -12,6 +12,7 @@ import '../icon/IconWrapper/IconWrapper.js';
|
|
|
12
12
|
import '../icon/icons/EyeVision.js';
|
|
13
13
|
import '../icon/icons/File.js';
|
|
14
14
|
import '../icon/icons/Trash2.js';
|
|
15
|
+
import '../button/index.js';
|
|
15
16
|
|
|
16
17
|
var propTypes = {exports: {}};
|
|
17
18
|
|
|
@@ -2731,7 +2732,7 @@ function reducer(state, action) {
|
|
|
2731
2732
|
|
|
2732
2733
|
function noop() {}
|
|
2733
2734
|
|
|
2734
|
-
var css_248z = ".style-module_container__Uyltc {\n background-color: transparent;\n}\n\n.style-module_dropzoneContainer__yZoGP {\n border: 1px dashed var(--ds-primary-500);\n padding: 32px 0;\n background-color: white;\n transition: all 0.6s ease-in-out;\n}\n
|
|
2735
|
+
var css_248z = ".style-module_container__Uyltc {\n background-color: transparent;\n}\n\n.style-module_dropzoneContainer__yZoGP {\n border: 1px dashed var(--ds-primary-500);\n padding: 32px 0;\n background-color: white;\n transition: all 0.6s ease-in-out;\n}\n.style-module_dropzoneContainer__yZoGP:focus-visible {\n outline: 2px solid #26262e;\n border-radius: 2px;\n outline-offset: 2px;\n}\n.style-module_dropzoneContainer__yZoGP:hover {\n background-color: var(--ds-primary-100);\n transition: 0.5s ease;\n}\n\n.style-module_img__11JI8 {\n vertical-align: middle;\n margin-right: 8px;\n height: 18px;\n}\n\n.style-module_textInline__2F21z {\n display: inline-flex;\n}\n\n.style-module_dropzoneContainerDisabled__1X3gP {\n pointer-events: none;\n opacity: 0.4;\n}";
|
|
2735
2736
|
var styles = {"container":"style-module_container__Uyltc","dropzoneContainer":"style-module_dropzoneContainer__yZoGP","img":"style-module_img__11JI8","textInline":"style-module_textInline__2F21z","dropzoneContainerDisabled":"style-module_dropzoneContainerDisabled__1X3gP"};
|
|
2736
2737
|
styleInject(css_248z);
|
|
2737
2738
|
|
|
@@ -2799,13 +2800,13 @@ var IMAGE_FILES_ACCEPT = formatMimeType(IMAGE_FILES);
|
|
|
2799
2800
|
var VIDEO_FILES_ACCEPT = formatMimeType(VIDEO_FILES);
|
|
2800
2801
|
var getFormattedAcceptObject = function (accept) {
|
|
2801
2802
|
if (accept === void 0) { accept = {}; }
|
|
2802
|
-
if (accept ===
|
|
2803
|
+
if (accept === 'document') {
|
|
2803
2804
|
return DOCUMENT_FILES_ACCEPT;
|
|
2804
2805
|
}
|
|
2805
|
-
if (accept ===
|
|
2806
|
+
if (accept === 'image') {
|
|
2806
2807
|
return IMAGE_FILES_ACCEPT;
|
|
2807
2808
|
}
|
|
2808
|
-
if (accept ===
|
|
2809
|
+
if (accept === 'video') {
|
|
2809
2810
|
return VIDEO_FILES_ACCEPT;
|
|
2810
2811
|
}
|
|
2811
2812
|
if (accept) {
|
|
@@ -2813,11 +2814,13 @@ var getFormattedAcceptObject = function (accept) {
|
|
|
2813
2814
|
}
|
|
2814
2815
|
return __assign(__assign(__assign({}, DOCUMENT_FILES_ACCEPT), IMAGE_FILES_ACCEPT), VIDEO_FILES_ACCEPT);
|
|
2815
2816
|
};
|
|
2816
|
-
var formatAcceptFileList = function (accept) {
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2817
|
+
var formatAcceptFileList = function (accept) {
|
|
2818
|
+
return Object.values(accept)
|
|
2819
|
+
.reduce(function (acc, value) { return __spreadArray$1(__spreadArray$1([], acc, true), value, true); }, [])
|
|
2820
|
+
.join(', ')
|
|
2821
|
+
.replace(/\./g, '')
|
|
2822
|
+
.toUpperCase();
|
|
2823
|
+
};
|
|
2821
2824
|
var getPlaceholder = function (textOverrides, accept, maxSize) {
|
|
2822
2825
|
var maxSizePlaceholder = maxSize && maxSize > 0
|
|
2823
2826
|
? "".concat((textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.sizeUpToText) || 'up to', " ").concat(formatBytes(maxSize))
|
|
@@ -2825,26 +2828,48 @@ var getPlaceholder = function (textOverrides, accept, maxSize) {
|
|
|
2825
2828
|
var isAcceptString = typeof accept === 'string' &&
|
|
2826
2829
|
['video', 'image', 'document'].includes(accept);
|
|
2827
2830
|
var defaultPlaceholder = "".concat((textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.supportsTextShort) || 'Supports images, videos and documents', " ").concat(maxSizePlaceholder);
|
|
2828
|
-
var acceptPlaceholder = "".concat((textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.supportsTextShort) ||
|
|
2831
|
+
var acceptPlaceholder = "".concat((textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.supportsTextShort) ||
|
|
2832
|
+
"Supports ".concat(accept, "s ").concat(maxSizePlaceholder));
|
|
2829
2833
|
return isAcceptString ? acceptPlaceholder : defaultPlaceholder;
|
|
2830
2834
|
};
|
|
2831
2835
|
var getErrorMessage = function (_a, _b, textOverrides) {
|
|
2832
2836
|
var code = _a.code, message = _a.message;
|
|
2833
|
-
var _c = _b.fileList, fileList = _c === void 0 ?
|
|
2837
|
+
var _c = _b.fileList, fileList = _c === void 0 ? '' : _c, maxSize = _b.maxSize;
|
|
2834
2838
|
switch (code) {
|
|
2835
2839
|
case ErrorCode.FileInvalidType:
|
|
2836
|
-
return "".concat((textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.fileTypeError) ||
|
|
2840
|
+
return "".concat((textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.fileTypeError) || 'File type must be', " ").concat(fileList);
|
|
2837
2841
|
case ErrorCode.FileTooLarge:
|
|
2838
|
-
return "".concat((textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.fileTooLargeError) ||
|
|
2842
|
+
return "".concat((textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.fileTooLargeError) ||
|
|
2843
|
+
'File is too large. It must be less than', " ").concat(formatBytes(maxSize || 0), ".");
|
|
2839
2844
|
default:
|
|
2840
2845
|
return message;
|
|
2841
2846
|
}
|
|
2842
2847
|
};
|
|
2848
|
+
var getStatusMessage = function (_a) {
|
|
2849
|
+
var acceptedFiles = _a.acceptedFiles, filesRejected = _a.filesRejected, fileList = _a.fileList, maxSize = _a.maxSize, textOverrides = _a.textOverrides;
|
|
2850
|
+
var message = '';
|
|
2851
|
+
if (acceptedFiles.length > 0) {
|
|
2852
|
+
var fileNames = acceptedFiles.map(function (file) { return file.name; }).join(', ');
|
|
2853
|
+
message += "File".concat(acceptedFiles.length > 1 ? 's' : '', " uploaded: ").concat(fileNames, ". ");
|
|
2854
|
+
}
|
|
2855
|
+
if (filesRejected.length > 0) {
|
|
2856
|
+
var rejectionMessages = filesRejected.map(function (rejection) {
|
|
2857
|
+
var firstError = rejection.errors[0];
|
|
2858
|
+
var rejectionMessage = getErrorMessage(firstError, { fileList: fileList, maxSize: maxSize }, textOverrides);
|
|
2859
|
+
return "Could not upload ".concat(rejection.file.name, ": ").concat(rejectionMessage.endsWith('.')
|
|
2860
|
+
? rejectionMessage
|
|
2861
|
+
: "".concat(rejectionMessage, "."));
|
|
2862
|
+
});
|
|
2863
|
+
message += rejectionMessages.join('');
|
|
2864
|
+
}
|
|
2865
|
+
return message.trim();
|
|
2866
|
+
};
|
|
2843
2867
|
|
|
2844
2868
|
var MultiDropzone = function (_a) {
|
|
2845
2869
|
var _b;
|
|
2846
2870
|
var uploadedFiles = _a.uploadedFiles, onFileSelect = _a.onFileSelect, onRemoveFile = _a.onRemoveFile, uploading = _a.uploading, _c = _a.isCondensed, isCondensed = _c === void 0 ? false : _c, accept = _a.accept, _d = _a.maxFiles, maxFiles = _d === void 0 ? 0 : _d, maxSize = _a.maxSize, textOverrides = _a.textOverrides;
|
|
2847
2871
|
var _e = useState([]), errors = _e[0], setErrors = _e[1];
|
|
2872
|
+
var _f = useState(''), statusMessage = _f[0], setStatusMessage = _f[1];
|
|
2848
2873
|
var formattedAccept = getFormattedAcceptObject(accept);
|
|
2849
2874
|
var fileList = formatAcceptFileList(formattedAccept);
|
|
2850
2875
|
var placeholder = getPlaceholder(textOverrides, accept, maxSize);
|
|
@@ -2857,6 +2882,14 @@ var MultiDropzone = function (_a) {
|
|
|
2857
2882
|
};
|
|
2858
2883
|
var onDrop = useCallback(function (acceptedFiles, filesRejected) {
|
|
2859
2884
|
onFileSelect(acceptedFiles);
|
|
2885
|
+
var messageForScreenReader = getStatusMessage({
|
|
2886
|
+
acceptedFiles: acceptedFiles,
|
|
2887
|
+
filesRejected: filesRejected,
|
|
2888
|
+
fileList: fileList,
|
|
2889
|
+
maxSize: maxSize,
|
|
2890
|
+
textOverrides: textOverrides,
|
|
2891
|
+
});
|
|
2892
|
+
setStatusMessage(messageForScreenReader);
|
|
2860
2893
|
setErrors(function (previousErrors) { return __spreadArray$1(__spreadArray$1([], previousErrors, true), filesRejected.map(function (_a) {
|
|
2861
2894
|
var errors = _a.errors;
|
|
2862
2895
|
return ({
|
|
@@ -2865,15 +2898,15 @@ var MultiDropzone = function (_a) {
|
|
|
2865
2898
|
});
|
|
2866
2899
|
}), true); });
|
|
2867
2900
|
}, [fileList, maxSize, onFileSelect, textOverrides]);
|
|
2868
|
-
var
|
|
2901
|
+
var _g = useDropzone({
|
|
2869
2902
|
accept: formattedAccept,
|
|
2870
2903
|
disabled: uploading,
|
|
2871
2904
|
maxSize: maxSize,
|
|
2872
2905
|
onDrop: onDrop,
|
|
2873
|
-
}), getRootProps =
|
|
2906
|
+
}), getRootProps = _g.getRootProps, getInputProps = _g.getInputProps;
|
|
2874
2907
|
return (jsxs("div", { className: styles.container, children: [jsxs("div", __assign({ className: classNames("w100 ta-center br8 c-pointer ".concat(styles.dropzoneContainer), (_b = {},
|
|
2875
2908
|
_b[styles['dropzoneContainerDisabled']] = uploading,
|
|
2876
|
-
_b)) }, getRootProps(), { children: [jsx("input", __assign({ "data-testid": "ds-drop-input" }, getInputProps())), jsx(UploadCloudIcon, { className: isCondensed ? styles.img : '', size: isCondensed ? 24 : 64, color: 'purple-500' }), jsx("div", { className: "p-h4 mt8 d-block c-pointer ".concat(isCondensed ? styles.textInline : ''), children: uploading
|
|
2909
|
+
_b)) }, getRootProps(), { children: [jsx("div", { className: "sr-only", "aria-live": "polite", "aria-atomic": "true", children: statusMessage }), jsx("input", __assign({ "data-testid": "ds-drop-input" }, getInputProps())), jsx(UploadCloudIcon, { className: isCondensed ? styles.img : '', size: isCondensed ? 24 : 64, color: 'purple-500' }), jsx("div", { className: "p-h4 mt8 d-block c-pointer ".concat(isCondensed ? styles.textInline : ''), children: uploading
|
|
2877
2910
|
? (textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.currentlyUploadingText) ||
|
|
2878
2911
|
'Please wait while uploading file...'
|
|
2879
2912
|
: (textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.instructionsText) || 'Choose file or drag & drop' }), jsx("div", { className: "p-p--small tc-grey-500", children: (textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.supportsText) || placeholder })] })), errors.map(function (_a) {
|
|
@@ -2884,7 +2917,8 @@ var MultiDropzone = function (_a) {
|
|
|
2884
2917
|
name: message,
|
|
2885
2918
|
progress: 0,
|
|
2886
2919
|
}, onRemoveFile: function () { return removeError(id); }, uploading: false }, id));
|
|
2887
|
-
}), uploadedFiles.length > 0 && (jsx("div", { className: "w100 mt16", children: uploadedFiles.map(function (file) { return (jsx(UploadFileCell, __assign({ uploadStatus: getUploadStatus(file.progress, file.error), file: file }, (!onRemoveFile ? {} : { onRemoveFile: onRemoveFile }), { uploading: uploading }), file.id)); }) })), jsx(AnimateHeight, { duration: 300, height: isOverMaxFiles ? 'auto' : 0, children: jsx("p", { className: "tc-red-500 mt16", children: (textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.tooManyFilesError) ||
|
|
2920
|
+
}), uploadedFiles.length > 0 && (jsx("div", { className: "w100 mt16", children: uploadedFiles.map(function (file) { return (jsx(UploadFileCell, __assign({ uploadStatus: getUploadStatus(file.progress, file.error), file: file }, (!onRemoveFile ? {} : { onRemoveFile: onRemoveFile }), { uploading: uploading }), file.id)); }) })), jsx(AnimateHeight, { duration: 300, height: isOverMaxFiles ? 'auto' : 0, children: jsx("p", { className: "tc-red-500 mt16", children: (textOverrides === null || textOverrides === void 0 ? void 0 : textOverrides.tooManyFilesError) ||
|
|
2921
|
+
"You can upload maximum ".concat(maxFiles, " files.") }) })] }));
|
|
2888
2922
|
};
|
|
2889
2923
|
|
|
2890
2924
|
export { MultiDropzone };
|