@innovaccer/design-system 2.6.0 → 2.7.0-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/.eslintrc.json +10 -9
- package/.github/workflows/chromatic.yml +5 -0
- package/.github/workflows/pull_request.yml +1 -1
- package/.storybook/main.js +4 -0
- package/.vscode/settings.json +11 -0
- package/CHANGELOG.md +36 -0
- package/CONTRIBUTING.md +7 -1
- package/core/accessibility/utils/useAccessibilityProps.ts +4 -2
- package/core/common.type.tsx +22 -0
- package/core/components/atoms/_chip/__tests__/__snapshots__/_chip.test.tsx.snap +9 -9
- package/core/components/atoms/_chip/index.tsx +17 -3
- package/core/components/atoms/avatar/Avatar.tsx +4 -14
- package/core/components/atoms/avatar/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/avatar/__tests__/Avatar.test.tsx +14 -9
- package/core/components/atoms/avatarGroup/AvatarGroup.tsx +3 -5
- package/core/components/atoms/badge/Badge.tsx +2 -12
- package/core/components/atoms/badge/__tests__/Badge.test.tsx +22 -7
- package/core/components/atoms/badge/_stories_/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/badge/_stories_/variants/Subtle.story.tsx +3 -2
- package/core/components/atoms/button/Button.tsx +10 -7
- package/core/components/atoms/button/__stories__/index.story.tsx +1 -1
- package/core/components/atoms/button/__stories__/variants/Appearance.story.tsx +2 -2
- package/core/components/atoms/button/__stories__/variants/Expanded.story.tsx +2 -2
- package/core/components/atoms/button/__stories__/variants/icon/IconLeft.story.tsx +2 -2
- package/core/components/atoms/button/__stories__/variants/icon/IconRight.story.tsx +2 -2
- package/core/components/atoms/button/__tests__/Button.test.tsx +1 -1
- package/core/components/atoms/button/__tests__/__snapshots__/Button.test.tsx.snap +0 -137
- package/core/components/atoms/card/__stories__/empty.story.tsx +1 -1
- package/core/components/atoms/card/__stories__/nested.story.tsx +1 -1
- package/core/components/atoms/card/__stories__/scroll.story.tsx +1 -1
- package/core/components/atoms/checkbox/Checkbox.tsx +8 -9
- package/core/components/atoms/checkbox/__stories__/variants/Size.story.tsx +2 -2
- package/core/components/atoms/chip/Chip.tsx +3 -2
- package/core/components/atoms/chip/__stories__/variants/Selection.story.tsx +17 -0
- package/core/components/atoms/chip/__stories__/variants/Type.story.tsx +2 -2
- package/core/components/atoms/chip/__tests__/Chip.test.tsx +7 -0
- package/core/components/atoms/chipGroup/__tests__/__snapshots__/chipGroup.test.tsx.snap +5 -5
- package/core/components/atoms/chipGroup/__tests__/chipGroup.test.tsx +2 -2
- package/core/components/atoms/chipGroup/_stories_/index.story.tsx +2 -2
- package/core/components/atoms/dropdown/Dropdown.tsx +18 -17
- package/core/components/atoms/dropdown/DropdownButton.tsx +2 -2
- package/core/components/atoms/dropdown/DropdownList.tsx +10 -5
- package/core/components/atoms/dropdown/Loading.tsx +1 -1
- package/core/components/atoms/dropdown/__stories__/CustomSearchPlaceholder.story.tsx +45 -0
- package/core/components/atoms/dropdown/__stories__/_common_/types.tsx +3 -0
- package/core/components/atoms/dropdown/__stories__/variants/Size.story.tsx +2 -2
- package/core/components/atoms/dropdown/__stories__/variants/controlledDropdown/MultiSelect.story.tsx +1 -1
- package/core/components/atoms/dropdown/__tests__/Dropdown.test.tsx +12 -1
- package/core/components/atoms/dropdown/__tests__/Loading.test.tsx +0 -1
- package/core/components/atoms/dropdown/option/index.tsx +1 -1
- package/core/components/atoms/heading/Heading.tsx +4 -4
- package/core/components/atoms/heading/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/heading/__tests__/Heading.test.tsx +4 -3
- package/core/components/atoms/icon/Icon.tsx +3 -3
- package/core/components/atoms/input/Input.tsx +3 -3
- package/core/components/atoms/input/__stories__/InputWithCaption.story.tsx +62 -0
- package/core/components/atoms/input/__stories__/LabelPosition.story.tsx +38 -0
- package/core/components/atoms/input/__stories__/variants/controlledInput.story.tsx +46 -0
- package/core/components/atoms/input/__stories__/variants/types/BasicInput.story.tsx +2 -2
- package/core/components/atoms/input/__stories__/variants/types/IconLeft.story.tsx +2 -10
- package/core/components/atoms/input/__stories__/variants/types/WithLabel.story.tsx +1 -9
- package/core/components/atoms/label/Label.tsx +1 -1
- package/core/components/atoms/legend/Legend.tsx +2 -2
- package/core/components/atoms/legend/__stories__/variants/labelAppearance.story.tsx +2 -2
- package/core/components/atoms/link/Link.tsx +4 -4
- package/core/components/atoms/message/Message.tsx +12 -12
- package/core/components/atoms/message/__stories__/index.story.tsx +1 -1
- package/core/components/atoms/message/__stories__/variants/Appearance.story.tsx +1 -1
- package/core/components/atoms/message/__stories__/variants/AppearanceTitle.story.tsx +1 -1
- package/core/components/atoms/message/__tests__/Message.test.tsx +1 -6
- package/core/components/atoms/message/__tests__/__snapshots__/Message.test.tsx.snap +0 -45
- package/core/components/atoms/metaList/__tests__/MetaList.test.tsx +2 -2
- package/core/components/atoms/metricInput/MetricInput.tsx +5 -5
- package/core/components/atoms/multiSlider/SliderUtils.tsx +1 -4
- package/core/components/atoms/multiSlider/index.tsx +3 -4
- package/core/components/atoms/outsideClick/OutsideClick.tsx +1 -2
- package/core/components/atoms/paragraph/Paragraph.tsx +2 -2
- package/core/components/atoms/paragraph/__stories__/variants/Appearance.story.tsx +2 -2
- package/core/components/atoms/paragraph/__tests__/Paragraph.test.tsx +2 -2
- package/core/components/atoms/pills/Pills.tsx +2 -12
- package/core/components/atoms/pills/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/pills/__stories__/variants/Subtle.story.tsx +3 -2
- package/core/components/atoms/pills/__tests__/Pills.test.tsx +3 -2
- package/core/components/atoms/placeholderImage/PlaceholderImage.tsx +2 -2
- package/core/components/atoms/placeholderImage/__stories__/variants/Size.story.tsx +2 -2
- package/core/components/atoms/placeholderParagraph/PlaceholderParagraph.tsx +2 -2
- package/core/components/atoms/placeholderParagraph/__stories__/variants/Size.story.tsx +2 -2
- package/core/components/atoms/popperWrapper/PopperWrapper.tsx +2 -6
- package/core/components/atoms/progressRing/ProgressRing.tsx +2 -2
- package/core/components/atoms/progressRing/__stories__/variants/Size.story.tsx +1 -1
- package/core/components/atoms/radio/Radio.tsx +4 -5
- package/core/components/atoms/rangeSlider/RangeSlider.tsx +1 -2
- package/core/components/atoms/rangeSlider/__stories__/index.story.tsx +1 -2
- package/core/components/atoms/rangeSlider/__stories__/variants/Controlled.story.tsx +1 -2
- package/core/components/atoms/rangeSlider/__stories__/variants/CustomLabels.story.tsx +1 -2
- package/core/components/atoms/spinner/Spinner.tsx +4 -4
- package/core/components/atoms/spinner/__stories__/variants/Appearance.story.tsx +2 -2
- package/core/components/atoms/spinner/__stories__/variants/Size.story.tsx +1 -1
- package/core/components/atoms/statusHint/StatusHint.tsx +2 -3
- package/core/components/atoms/statusHint/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/statusHint/__tests__/StatusHint.test.tsx +3 -2
- package/core/components/atoms/subheading/Subheading.tsx +2 -2
- package/core/components/atoms/subheading/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/subheading/__tests__/Subheading.test.tsx +3 -2
- package/core/components/atoms/switchInput/Switch.tsx +7 -8
- package/core/components/atoms/text/Text.tsx +4 -4
- package/core/components/atoms/text/__stories__/variants/Appearance.story.tsx +2 -2
- package/core/components/atoms/text/__tests__/Text.test.tsx +2 -3
- package/core/components/atoms/toast/ActionButton.tsx +2 -2
- package/core/components/atoms/toast/Toast.tsx +11 -6
- package/core/components/atoms/toast/__stories__/index.story.tsx +2 -6
- package/core/components/atoms/toast/__stories__/variants/Appearance.story.tsx +3 -2
- package/core/components/atoms/toast/__stories__/variants/ToastMessage.story.tsx +3 -2
- package/core/components/atoms/toast/__stories__/variants/ToastWithAction.story.tsx +3 -2
- package/core/components/atoms/toast/__tests__/Toast.test.tsx +1 -1
- package/core/components/atoms/toast/__tests__/__snapshots__/Toast.test.tsx.snap +0 -131
- package/core/components/css-utilities/Schema.tsx +1 -1
- package/core/components/css-utilities/Spacing/Schema.tsx +1 -1
- package/core/components/molecules/chipInput/__tests__/__snapshots__/ChipInput.test.tsx.snap +2 -2
- package/core/components/molecules/dropzone/Dropzone.tsx +3 -3
- package/core/components/molecules/dropzone/DropzoneBase.tsx +22 -38
- package/core/components/molecules/dropzone/__stories__/index.story.tsx +151 -41
- package/core/components/molecules/dropzone/__tests__/Dropzone.test.tsx +2 -2
- package/core/components/molecules/dropzone/utils.tsx +6 -4
- package/core/components/molecules/editableChipInput/__tests__/__snapshots__/EditableChipInput.test.tsx.snap +4 -4
- package/core/components/molecules/emptyState/EmptyState.tsx +4 -4
- package/core/components/molecules/emptyState/__stories__/pageNotLoadedWithSVG.story.tsx +26 -26
- package/core/components/molecules/fileList/FileListItem.tsx +1 -2
- package/core/components/molecules/fileUploader/FileUploaderItem.tsx +1 -2
- package/core/components/molecules/fileUploader/FileUploaderStatus.tsx +1 -1
- package/core/components/molecules/fileUploader/__stories__/_common_/types.tsx +3 -0
- package/core/components/molecules/fileUploader/__stories__/index.story.tsx +3 -222
- package/core/components/molecules/fullscreenModal/FullscreenModal.tsx +5 -7
- package/core/components/molecules/inputMask/InputMask.tsx +212 -146
- package/core/components/molecules/inputMask/__stories__/index.story.tsx +24 -0
- package/core/components/molecules/modal/Modal.tsx +4 -6
- package/core/components/molecules/modal/__stories__/Confirmation.story.tsx +1 -1
- package/core/components/molecules/placeholder/Placeholder.tsx +2 -2
- package/core/components/molecules/popover/Popover.tsx +2 -9
- package/core/components/molecules/sidesheet/Sidesheet.tsx +5 -7
- package/core/components/molecules/sidesheet/__stories__/variants/CustomHeader.story.tsx +172 -0
- package/core/components/molecules/tooltip/Tooltip.tsx +4 -4
- package/core/components/organisms/calendar/__stories__/variants/firstDayOfWeek.story.tsx +2 -2
- package/core/components/organisms/calendar/utility.ts +3 -3
- package/core/components/organisms/choiceList/ChoiceList.tsx +11 -11
- package/core/components/organisms/datePicker/DatePicker.tsx +1 -1
- package/core/components/organisms/datePicker/Trigger.tsx +1 -5
- package/core/components/organisms/dateRangePicker/DateRangePicker.tsx +9 -10
- package/core/components/organisms/dateRangePicker/SingleInputTrigger.tsx +0 -1
- package/core/components/organisms/dateRangePicker/Trigger.tsx +2 -2
- package/core/components/organisms/dateRangePicker/__stories__/variants/monthsInView.story.tsx +2 -2
- package/core/components/organisms/dateRangePicker/__tests__/__snapshots__/DateRangePicker.test.tsx.snap +16 -16
- package/core/components/organisms/grid/Cell.tsx +19 -19
- package/core/components/organisms/grid/Grid.tsx +3 -4
- package/core/components/organisms/grid/GridBody.tsx +0 -1
- package/core/components/organisms/grid/GridContext.ts +1 -1
- package/core/components/organisms/grid/__stories__/_common_/editableSchema.tsx +1 -3
- package/core/components/organisms/grid/__stories__/_common_/fetchData.ts +1 -1
- package/core/components/organisms/grid/__stories__/_common_/loaderSchema.ts +0 -2
- package/core/components/organisms/grid/__stories__/_common_/schema.tsx +1 -3
- package/core/components/organisms/grid/__stories__/_common_/simpleLoaderSchema.ts +0 -2
- package/core/components/organisms/grid/__stories__/_common_/statusSchema.ts +0 -2
- package/core/components/organisms/inlineMessage/InlineMessage.tsx +2 -2
- package/core/components/organisms/inlineMessage/__tests__/InlineMessage.test.tsx +3 -2
- package/core/components/organisms/list/__stories__/_common_/types.tsx +3 -0
- package/core/components/organisms/list/__stories__/index.story.tsx +0 -16
- package/core/components/organisms/table/Table.tsx +2 -2
- package/core/components/organisms/table/__stories__/CompressedTable.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/DataTable.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/NestedTableWithNestedCard.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/PinnedColumn.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/ResourceTable.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/StandardTable.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/TableAsDescriptionList.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/TableAsOptionList.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/TightStory.story.tsx +1 -1
- package/core/components/organisms/table/__stories__/_common_/types.tsx +3 -0
- package/core/components/organisms/table/__stories__/variants/showHead.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/variants/showMenu.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/variants/size.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/variants/type.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/variants/withCheckbox.story.tsx +2 -2
- package/core/components/organisms/table/__stories__/variants/withPagination.story.tsx +2 -2
- package/core/components/organisms/timePicker/TimePicker.tsx +3 -7
- package/core/components/organisms/verticalNav/__stories__/schema.tsx +0 -2
- package/core/components/organisms/verticalNav/__tests__/VerticalNav.test.tsx +1 -2
- package/core/global.d.ts +9 -0
- package/core/index.tsx +1 -1
- package/core/utils/__tests__/__snapshots__/TS.test.tsx.snap +18 -5
- package/core/utils/docPage/generateImports.tsx +2 -3
- package/core/utils/docPage/index.tsx +30 -20
- package/core/utils/docPage/sandbox.tsx +14 -7
- package/core/utils/overlayHelper.ts +7 -3
- package/core/utils/testHelper.ts +1 -1
- package/core/utils/types.tsx +1 -1
- package/css/dist/index.css +48 -30
- package/css/dist/index.css.map +1 -1
- package/css/src/components/button.css +5 -5
- package/css/src/components/calendar.css +1 -1
- package/css/src/components/chip.css +6 -4
- package/css/src/components/fullscreenModal.css +4 -3
- package/css/src/components/message.css +0 -5
- package/css/src/components/switch.css +23 -2
- package/css/src/components/toast.css +0 -5
- package/css/src/variables/index.css +5 -2
- package/dist/core/accessibility/utils/useAccessibilityProps.d.ts +4 -1
- package/dist/core/common.type.d.ts +12 -0
- package/dist/core/components/atoms/avatar/Avatar.d.ts +4 -4
- package/dist/core/components/atoms/avatarGroup/AvatarGroup.d.ts +2 -3
- package/dist/core/components/atoms/badge/Badge.d.ts +2 -2
- package/dist/core/components/atoms/button/Button.d.ts +6 -6
- package/dist/core/components/atoms/checkbox/Checkbox.d.ts +3 -3
- package/dist/core/components/atoms/chip/Chip.d.ts +2 -2
- package/dist/core/components/atoms/dropdown/Dropdown.d.ts +18 -17
- package/dist/core/components/atoms/dropdown/DropdownButton.d.ts +2 -2
- package/dist/core/components/atoms/dropdown/DropdownList.d.ts +4 -3
- package/dist/core/components/atoms/dropdown/option/index.d.ts +1 -1
- package/dist/core/components/atoms/heading/Heading.d.ts +4 -4
- package/dist/core/components/atoms/icon/Icon.d.ts +2 -2
- package/dist/core/components/atoms/input/Input.d.ts +3 -3
- package/dist/core/components/atoms/legend/Legend.d.ts +2 -2
- package/dist/core/components/atoms/link/Link.d.ts +4 -4
- package/dist/core/components/atoms/message/Message.d.ts +2 -2
- package/dist/core/components/atoms/metricInput/MetricInput.d.ts +3 -3
- package/dist/core/components/atoms/multiSlider/SliderUtils.d.ts +1 -1
- package/dist/core/components/atoms/multiSlider/index.d.ts +3 -3
- package/dist/core/components/atoms/paragraph/Paragraph.d.ts +2 -2
- package/dist/core/components/atoms/pills/Pills.d.ts +2 -2
- package/dist/core/components/atoms/placeholderImage/PlaceholderImage.d.ts +2 -2
- package/dist/core/components/atoms/placeholderParagraph/PlaceholderParagraph.d.ts +2 -2
- package/dist/core/components/atoms/popperWrapper/PopperWrapper.d.ts +1 -2
- package/dist/core/components/atoms/progressRing/ProgressRing.d.ts +2 -2
- package/dist/core/components/atoms/radio/Radio.d.ts +4 -4
- package/dist/core/components/atoms/rangeSlider/RangeSlider.d.ts +1 -1
- package/dist/core/components/atoms/spinner/Spinner.d.ts +4 -4
- package/dist/core/components/atoms/statusHint/StatusHint.d.ts +2 -2
- package/dist/core/components/atoms/subheading/Subheading.d.ts +2 -2
- package/dist/core/components/atoms/switchInput/Switch.d.ts +6 -6
- package/dist/core/components/atoms/text/Text.d.ts +4 -4
- package/dist/core/components/atoms/toast/ActionButton.d.ts +2 -2
- package/dist/core/components/atoms/toast/Toast.d.ts +2 -2
- package/dist/core/components/molecules/dropzone/Dropzone.d.ts +3 -3
- package/dist/core/components/molecules/dropzone/DropzoneBase.d.ts +1 -1
- package/dist/core/components/molecules/dropzone/utils.d.ts +5 -3
- package/dist/core/components/molecules/emptyState/EmptyState.d.ts +4 -4
- package/dist/core/components/molecules/fileList/FileListItem.d.ts +1 -1
- package/dist/core/components/molecules/fileUploader/FileUploaderItem.d.ts +1 -1
- package/dist/core/components/molecules/fileUploader/FileUploaderStatus.d.ts +1 -1
- package/dist/core/components/molecules/fullscreenModal/FullscreenModal.d.ts +4 -7
- package/dist/core/components/molecules/inputMask/InputMask.d.ts +10 -2
- package/dist/core/components/molecules/modal/Modal.d.ts +3 -6
- package/dist/core/components/molecules/placeholder/Placeholder.d.ts +2 -2
- package/dist/core/components/molecules/popover/Popover.d.ts +0 -1
- package/dist/core/components/molecules/sidesheet/Sidesheet.d.ts +3 -6
- package/dist/core/components/molecules/tooltip/Tooltip.d.ts +3 -3
- package/dist/core/components/organisms/choiceList/ChoiceList.d.ts +5 -6
- package/dist/core/components/organisms/dateRangePicker/DateRangePicker.d.ts +24 -0
- package/dist/core/components/organisms/grid/Cell.d.ts +1 -1
- package/dist/core/components/organisms/grid/Grid.d.ts +3 -3
- package/dist/core/components/organisms/grid/GridContext.d.ts +1 -1
- package/dist/core/components/organisms/inlineMessage/InlineMessage.d.ts +2 -2
- package/dist/core/components/organisms/table/Table.d.ts +2 -2
- package/dist/core/components/patterns/dateRangePicker/withCustomPopover.story.d.ts +5 -1
- package/dist/core/utils/docPage/generateImports.d.ts +1 -1
- package/dist/core/utils/overlayHelper.d.ts +1 -1
- package/dist/core/utils/types.d.ts +1 -1
- package/dist/index.esm.js +221 -245
- package/dist/index.js +225 -233
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.br +0 -0
- package/dist/index.umd.js.gz +0 -0
- package/dts.config.js +11 -2
- package/package.json +20 -18
- package/tsconfig.json +3 -16
- package/tsconfig.type.json +2 -1
- package/types/index.d.ts +2217 -0
- package/types/{innovaccer-design-system/tsconfig.json → tsconfig.json} +1 -1
- package/types/{innovaccer-design-system/tslint.json → tslint.json} +0 -0
- package/types/types-tests.tsx +936 -0
- package/core/components/atoms/button/__stories__/variants/state/Success.story.tsx +0 -89
- package/core/components/atoms/message/__stories__/default.story.tsx +0 -16
- package/core/components/atoms/toast/__stories__/DefaultToast.story.tsx +0 -16
- package/core/components/molecules/dropzone/__stories__/variants/DropzoneWithFileList.story.tsx +0 -176
- package/core/components/molecules/fileUploader/__stories__/variants/FileUploaderList.story.tsx +0 -80
- package/types/innovaccer-design-system/index.d.ts +0 -39
- package/types/innovaccer-design-system/innovaccer-design-system-tests.ts +0 -0
|
@@ -106,7 +106,7 @@ export interface DropzoneBaseProps extends BaseProps {
|
|
|
106
106
|
* @param {FileRejection[]} fileRejections
|
|
107
107
|
* @param {(DragEvent|Event)} event
|
|
108
108
|
*/
|
|
109
|
-
onDropRejected?: (event: DragEvent | Event, rejectedFiles: FileRejection[]) =>
|
|
109
|
+
onDropRejected?: (event: DragEvent | Event, rejectedFiles: FileRejection[]) => void;
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Custom validation function
|
|
@@ -149,8 +149,8 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
149
149
|
validator,
|
|
150
150
|
} = props;
|
|
151
151
|
|
|
152
|
-
const rootRef = useRef(null);
|
|
153
|
-
const inputRef = useRef(null);
|
|
152
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
153
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
154
154
|
|
|
155
155
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
156
156
|
const { isFocused, isFileDialogActive, draggedFiles } = state;
|
|
@@ -158,9 +158,9 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
158
158
|
const openFileDialog = useCallback(() => {
|
|
159
159
|
if (inputRef.current) {
|
|
160
160
|
dispatch({ type: 'openDialog' });
|
|
161
|
-
|
|
162
|
-
inputRef.current.value =
|
|
163
|
-
|
|
161
|
+
|
|
162
|
+
inputRef.current.value = '';
|
|
163
|
+
|
|
164
164
|
inputRef.current.click();
|
|
165
165
|
}
|
|
166
166
|
}, [dispatch]);
|
|
@@ -169,10 +169,9 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
169
169
|
if (isFileDialogActive) {
|
|
170
170
|
setTimeout(() => {
|
|
171
171
|
if (inputRef.current) {
|
|
172
|
-
// @ts-ignore
|
|
173
172
|
const { files } = inputRef.current;
|
|
174
173
|
|
|
175
|
-
if (!files.length) {
|
|
174
|
+
if (!files || !files.length) {
|
|
176
175
|
dispatch({ type: 'closeDialog' });
|
|
177
176
|
|
|
178
177
|
if (typeof onFileDialogCancel === 'function') {
|
|
@@ -193,7 +192,6 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
193
192
|
// Cb to open the file dialog when SPACE/ENTER occurs on the dropzone
|
|
194
193
|
const onKeyDownCb = useCallback(
|
|
195
194
|
(event) => {
|
|
196
|
-
// @ts-ignore
|
|
197
195
|
if (!rootRef.current || !rootRef.current.isEqualNode(event.target)) {
|
|
198
196
|
return;
|
|
199
197
|
}
|
|
@@ -215,11 +213,11 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
215
213
|
dispatch({ type: 'blur' });
|
|
216
214
|
}, []);
|
|
217
215
|
|
|
218
|
-
const dragTargetsRef = useRef([]);
|
|
216
|
+
const dragTargetsRef = useRef<HTMLElement[]>([]);
|
|
219
217
|
|
|
220
|
-
const onDocumentDrop = (event:
|
|
221
|
-
//
|
|
222
|
-
if (rootRef.current && rootRef.current.contains(event.target)) {
|
|
218
|
+
const onDocumentDrop = (event: DragEvent) => {
|
|
219
|
+
// Not every event target type is element so we have to check if it is.
|
|
220
|
+
if (event.target instanceof HTMLDivElement && rootRef.current && rootRef.current.contains(event.target)) {
|
|
223
221
|
return;
|
|
224
222
|
}
|
|
225
223
|
event.preventDefault();
|
|
@@ -245,7 +243,6 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
245
243
|
event.preventDefault();
|
|
246
244
|
event.persist();
|
|
247
245
|
|
|
248
|
-
// @ts-ignore
|
|
249
246
|
dragTargetsRef.current = [...dragTargetsRef.current, event.target];
|
|
250
247
|
|
|
251
248
|
if (isEvtWithFiles(event)) {
|
|
@@ -294,11 +291,7 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
294
291
|
event.preventDefault();
|
|
295
292
|
event.persist();
|
|
296
293
|
|
|
297
|
-
const targets = dragTargetsRef.current.filter(
|
|
298
|
-
// @ts-ignore
|
|
299
|
-
(target) => rootRef.current && rootRef.current.contains(target)
|
|
300
|
-
);
|
|
301
|
-
// @ts-ignore
|
|
294
|
+
const targets = dragTargetsRef.current.filter((target) => rootRef.current && rootRef.current.contains(target));
|
|
302
295
|
const targetIdx = targets.indexOf(event.target);
|
|
303
296
|
if (targetIdx !== -1) {
|
|
304
297
|
targets.splice(targetIdx, 1);
|
|
@@ -336,7 +329,10 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
336
329
|
}
|
|
337
330
|
|
|
338
331
|
const acceptedFiles: File[] = [];
|
|
339
|
-
const fileRejections:
|
|
332
|
+
const fileRejections: {
|
|
333
|
+
file: File;
|
|
334
|
+
errors: FileError[];
|
|
335
|
+
}[] = [];
|
|
340
336
|
|
|
341
337
|
files.forEach((file: File) => {
|
|
342
338
|
const [accepted, acceptError] = fileAccepted(file, accept);
|
|
@@ -351,8 +347,8 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
351
347
|
if (customErrors) {
|
|
352
348
|
errors = errors.concat(customErrors);
|
|
353
349
|
}
|
|
354
|
-
|
|
355
|
-
fileRejections.push({ file, errors:
|
|
350
|
+
const filteredErrors = errors.filter((e) => e) as Array<FileError>;
|
|
351
|
+
fileRejections.push({ file, errors: filteredErrors });
|
|
356
352
|
}
|
|
357
353
|
});
|
|
358
354
|
|
|
@@ -380,18 +376,10 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
380
376
|
[multiple, accept, minSize, maxSize, getFilesFromEvent, onDrop, onDropAccepted, onDropRejected]
|
|
381
377
|
);
|
|
382
378
|
|
|
383
|
-
const
|
|
379
|
+
const composeDragHandler = (fn: (event: DragEvent) => void) => {
|
|
384
380
|
return disabled ? null : fn;
|
|
385
381
|
};
|
|
386
382
|
|
|
387
|
-
const composeKeyboardHandler = (_fn: any) => {
|
|
388
|
-
return null;
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
const composeDragHandler = (fn: any) => {
|
|
392
|
-
return composeHandler(fn);
|
|
393
|
-
};
|
|
394
|
-
|
|
395
383
|
const getRootProps = useMemo(
|
|
396
384
|
() =>
|
|
397
385
|
({
|
|
@@ -406,10 +394,6 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
406
394
|
onDropCallback,
|
|
407
395
|
...rest
|
|
408
396
|
}: any = {}) => ({
|
|
409
|
-
onKeyDown: composeKeyboardHandler(composeEventHandlers(onKeyDown, onKeyDownCb)),
|
|
410
|
-
onFocus: composeKeyboardHandler(composeEventHandlers(onFocus, onFocusCb)),
|
|
411
|
-
onBlur: composeKeyboardHandler(composeEventHandlers(onBlur, onBlurCb)),
|
|
412
|
-
// onClick: composeHandler(composeEventHandlers(onClick, onClickCb)),
|
|
413
397
|
onDragEnter: composeDragHandler(composeEventHandlers(onDragEnterCallback, onDragEnterCb)),
|
|
414
398
|
onDragOver: composeDragHandler(composeEventHandlers(onDragOverCallback, onDragOverCb)),
|
|
415
399
|
onDragLeave: composeDragHandler(composeEventHandlers(onDragLeaveCallback, onDragLeaveCb)),
|
|
@@ -432,8 +416,8 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
432
416
|
multiple,
|
|
433
417
|
type: 'file',
|
|
434
418
|
style: { display: 'none' },
|
|
435
|
-
onChange:
|
|
436
|
-
onClick:
|
|
419
|
+
onChange: composeDragHandler(composeEventHandlers(onChange, onDropCb)),
|
|
420
|
+
onClick: composeDragHandler(composeEventHandlers(onClick, onInputElementClick)),
|
|
437
421
|
autoComplete: 'off',
|
|
438
422
|
tabIndex: -1,
|
|
439
423
|
[refKey]: inputRef,
|
|
@@ -463,7 +447,7 @@ export const DropzoneBase = (props: DropzoneBaseProps) => {
|
|
|
463
447
|
draggedFiles,
|
|
464
448
|
fileError,
|
|
465
449
|
isFocused: isFocused && !disabled,
|
|
466
|
-
open:
|
|
450
|
+
open: composeDragHandler(openFileDialog),
|
|
467
451
|
};
|
|
468
452
|
};
|
|
469
453
|
|
|
@@ -1,57 +1,167 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Dropzone, Link } from '@/index';
|
|
3
|
-
import {
|
|
4
|
-
import { action } from '@storybook/addon-actions';
|
|
5
|
-
import { DropzoneProps } from '@/index.type';
|
|
2
|
+
import { Dropzone, Link, FileList, Button } from '@/index';
|
|
3
|
+
import { DropzoneProps, FileListProps } from '@/index.type';
|
|
6
4
|
|
|
7
5
|
export const all = () => {
|
|
8
|
-
const
|
|
6
|
+
const [files, setFiles] = React.useState<FileListProps['fileList']>([]);
|
|
7
|
+
const getSize = (size: number) => `${(size / (1024 * 1024)).toFixed(2)} MB`;
|
|
9
8
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const onDelete = (id: number) => {
|
|
10
|
+
const updatedFiles = files.filter((file) => file.id !== id);
|
|
11
|
+
setFiles(updatedFiles);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const onDropHandler: DropzoneProps['onDrop'] = (_event, acceptedFiles, rejectedFiles) => {
|
|
15
|
+
const acceptedFileDetailList: FileListProps['fileList'] = acceptedFiles.map((file, id) => ({
|
|
16
|
+
file,
|
|
17
|
+
id: files.length + id,
|
|
18
|
+
fileSize: getSize(file.size),
|
|
19
|
+
networkError: false,
|
|
20
|
+
status: 'completed',
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const rejectedFilesDetailList: FileListProps['fileList'] = rejectedFiles.map((rejectedFile, id) => {
|
|
24
|
+
const { file, errors } = rejectedFile;
|
|
25
|
+
const errorMessageArray = errors.map((error) => error.message);
|
|
26
|
+
return {
|
|
27
|
+
file,
|
|
28
|
+
id: files.length + id,
|
|
29
|
+
fileSize: getSize(file.size),
|
|
30
|
+
status: 'error',
|
|
31
|
+
errorMessage: errorMessageArray.join(' and '),
|
|
32
|
+
networkError: false,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const updatedFiles = [...files, ...acceptedFileDetailList, ...rejectedFilesDetailList];
|
|
37
|
+
setFiles(updatedFiles);
|
|
38
|
+
};
|
|
13
39
|
|
|
14
|
-
const
|
|
15
|
-
return
|
|
40
|
+
const actionRenderer: FileListProps['actionRenderer'] = (fileItem) => {
|
|
41
|
+
return (
|
|
42
|
+
<React.Fragment>
|
|
43
|
+
{fileItem.networkError && (
|
|
44
|
+
<Button appearance="transparent" icon="refresh" size="regular" className={'cursor-pointer'} />
|
|
45
|
+
)}
|
|
46
|
+
<Button
|
|
47
|
+
appearance="transparent"
|
|
48
|
+
icon="close"
|
|
49
|
+
size="regular"
|
|
50
|
+
onClick={() => onDelete(fileItem.id)}
|
|
51
|
+
className={'cursor-pointer'}
|
|
52
|
+
/>
|
|
53
|
+
</React.Fragment>
|
|
54
|
+
);
|
|
16
55
|
};
|
|
17
56
|
|
|
18
57
|
return (
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
58
|
+
<React.Fragment>
|
|
59
|
+
<Dropzone
|
|
60
|
+
accept="image/jpeg, image/png"
|
|
61
|
+
formatLabel="Accepted formats: PDF, jpg"
|
|
62
|
+
sizeLabel="Maximum size: 25 MB"
|
|
63
|
+
multiple={true}
|
|
64
|
+
onDrop={onDropHandler}
|
|
65
|
+
className="mb-5"
|
|
66
|
+
sampleFileLink={
|
|
67
|
+
<Link
|
|
68
|
+
href="http://www.adobe.com/content/dam/Adobe/en/accessibility/pdfs/accessing-pdf-sr.pdf"
|
|
69
|
+
download="Test.pdf"
|
|
70
|
+
target="_blank"
|
|
71
|
+
>
|
|
72
|
+
Download sample file
|
|
73
|
+
</Link>
|
|
74
|
+
}
|
|
75
|
+
/>
|
|
76
|
+
<FileList fileList={files.map(({ file, metadata }) => ({ file, ...metadata }))} actionRenderer={actionRenderer} />
|
|
77
|
+
</React.Fragment>
|
|
35
78
|
);
|
|
36
79
|
};
|
|
37
80
|
|
|
38
81
|
const customCode = `() => {
|
|
82
|
+
const [files, setFiles] = React.useState([]);
|
|
83
|
+
|
|
84
|
+
const getSize = (size) => (
|
|
85
|
+
\`\${(size / (1024 * 1024)).toFixed(2)} MB\`
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const onDelete = (fileItem) => {
|
|
89
|
+
const updatedFiles = files.filter((file) => file.id !== fileItem.id);
|
|
90
|
+
setFiles(updatedFiles);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const onDropHandler = (event, acceptedFiles, rejectedFiles) => {
|
|
94
|
+
const acceptedFileDetailList = acceptedFiles.map((file, id) => (
|
|
95
|
+
{
|
|
96
|
+
file,
|
|
97
|
+
id: files.length + id,
|
|
98
|
+
fileSize: getSize(file.size),
|
|
99
|
+
networkError: false,
|
|
100
|
+
}
|
|
101
|
+
));
|
|
102
|
+
|
|
103
|
+
const rejectedFilesDetailList = rejectedFiles.map((rejectedFile, id) => {
|
|
104
|
+
const { file, errors } = rejectedFile;
|
|
105
|
+
const errorMessageArray = errors.map((error) => error.message);
|
|
106
|
+
return {
|
|
107
|
+
file,
|
|
108
|
+
id: files.length + id,
|
|
109
|
+
fileSize: getSize(file.size),
|
|
110
|
+
status: 'error',
|
|
111
|
+
errorMessage: errorMessageArray.join(' and '),
|
|
112
|
+
networkError: false,
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
const updatedFiles = [...files, ...acceptedFileDetailList, ...rejectedFilesDetailList];
|
|
116
|
+
setFiles(updatedFiles);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const actionRenderer = (fileItem) => {
|
|
120
|
+
return (
|
|
121
|
+
<React.Fragment>
|
|
122
|
+
{fileItem.networkError && (
|
|
123
|
+
<Button
|
|
124
|
+
appearance="transparent"
|
|
125
|
+
icon="refresh"
|
|
126
|
+
size="regular"
|
|
127
|
+
className={'cursor-pointer'}
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
130
|
+
<Button
|
|
131
|
+
appearance="transparent"
|
|
132
|
+
icon="close"
|
|
133
|
+
size="regular"
|
|
134
|
+
onClick={() => onDelete(fileItem)}
|
|
135
|
+
className={'cursor-pointer'}
|
|
136
|
+
/>
|
|
137
|
+
</React.Fragment>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
39
141
|
return (
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
142
|
+
<React.Fragment>
|
|
143
|
+
<Dropzone
|
|
144
|
+
accept="image/jpeg, image/png"
|
|
145
|
+
formatLabel="Accepted formats: PDF, jpg"
|
|
146
|
+
sizeLabel="Maximum size: 25 MB"
|
|
147
|
+
multiple={true}
|
|
148
|
+
onDrop={onDropHandler}
|
|
149
|
+
className="mb-5"
|
|
150
|
+
sampleFileLink={(
|
|
151
|
+
<Link
|
|
152
|
+
href="http://www.adobe.com/content/dam/Adobe/en/accessibility/pdfs/accessing-pdf-sr.pdf"
|
|
153
|
+
download="Test.pdf"
|
|
154
|
+
target="_blank"
|
|
155
|
+
>
|
|
156
|
+
Download sample file
|
|
157
|
+
</Link>
|
|
158
|
+
)}
|
|
159
|
+
/>
|
|
160
|
+
<FileList
|
|
161
|
+
fileList={files}
|
|
162
|
+
actionRenderer={actionRenderer}
|
|
163
|
+
/>
|
|
164
|
+
</React.Fragment>
|
|
55
165
|
);
|
|
56
166
|
}`;
|
|
57
167
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { render, fireEvent } from '@testing-library/react';
|
|
3
3
|
import { testHelper, filterUndefined, valueHelper, testMessageHelper } from '@/utils/testHelper';
|
|
4
|
-
import Dropzone, { DropzoneProps as Props,
|
|
4
|
+
import Dropzone, { DropzoneProps as Props, DropZoneType } from '../Dropzone';
|
|
5
5
|
import Link from '@/components/atoms/link';
|
|
6
6
|
import DropzoneError from '../DropzoneError';
|
|
7
7
|
import { fromEvent } from '../FileSelectorUtils';
|
|
@@ -29,7 +29,7 @@ const multipleFileData = {
|
|
|
29
29
|
|
|
30
30
|
const minSize = 50;
|
|
31
31
|
const maxSize = 300;
|
|
32
|
-
const types:
|
|
32
|
+
const types: DropZoneType[] = ['standard', 'compressed', 'tight'];
|
|
33
33
|
|
|
34
34
|
describe('Dropzone component snapshot', () => {
|
|
35
35
|
const mapper: Record<string, any> = {
|
|
@@ -48,11 +48,11 @@ export const isEvtWithFiles = (event: any) => {
|
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export const isKindFile = (item:
|
|
51
|
+
export const isKindFile = (item: null | Record<string, unknown>) => {
|
|
52
52
|
return typeof item === 'object' && item !== null && item.kind === 'file';
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
export const onDocumentDragOver = (event:
|
|
55
|
+
export const onDocumentDragOver = (event: DragEvent) => {
|
|
56
56
|
event.preventDefault();
|
|
57
57
|
};
|
|
58
58
|
|
|
@@ -60,8 +60,10 @@ export const isIeOrEdge = (userAgent = window.navigator.userAgent) => {
|
|
|
60
60
|
return isIe(userAgent) || isEdge(userAgent);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
type functype = (event: Event, ...args: unknown[]) => void;
|
|
64
|
+
|
|
65
|
+
export const composeEventHandlers = (...fns: functype[]) => {
|
|
66
|
+
return (event: Event, ...args: unknown[]) =>
|
|
65
67
|
fns.some((fn) => {
|
|
66
68
|
if (!isPropagationStopped(event) && fn) {
|
|
67
69
|
fn(event, ...args);
|
|
@@ -30,7 +30,7 @@ exports[`EditableChipInput component
|
|
|
30
30
|
Chip1
|
|
31
31
|
</span>
|
|
32
32
|
<i
|
|
33
|
-
class="material-icons material-icons-round Icon
|
|
33
|
+
class="material-icons material-icons-round Icon Chip-icon Chip-icon--right cursor-pointer"
|
|
34
34
|
data-test="DesignSystem-GenericChip--clearButton"
|
|
35
35
|
role="button"
|
|
36
36
|
style="font-size: 16px; width: 16px;"
|
|
@@ -50,7 +50,7 @@ exports[`EditableChipInput component
|
|
|
50
50
|
Chip2
|
|
51
51
|
</span>
|
|
52
52
|
<i
|
|
53
|
-
class="material-icons material-icons-round Icon
|
|
53
|
+
class="material-icons material-icons-round Icon Chip-icon Chip-icon--right cursor-pointer"
|
|
54
54
|
data-test="DesignSystem-GenericChip--clearButton"
|
|
55
55
|
role="button"
|
|
56
56
|
style="font-size: 16px; width: 16px;"
|
|
@@ -96,7 +96,7 @@ exports[`EditableChipInput component
|
|
|
96
96
|
Chip1
|
|
97
97
|
</span>
|
|
98
98
|
<i
|
|
99
|
-
class="material-icons material-icons-round Icon
|
|
99
|
+
class="material-icons material-icons-round Icon Chip-icon Chip-icon--right cursor-pointer"
|
|
100
100
|
data-test="DesignSystem-GenericChip--clearButton"
|
|
101
101
|
role="button"
|
|
102
102
|
style="font-size: 16px; width: 16px;"
|
|
@@ -116,7 +116,7 @@ exports[`EditableChipInput component
|
|
|
116
116
|
Chip2
|
|
117
117
|
</span>
|
|
118
118
|
<i
|
|
119
|
-
class="material-icons material-icons-round Icon
|
|
119
|
+
class="material-icons material-icons-round Icon Chip-icon Chip-icon--right cursor-pointer"
|
|
120
120
|
data-test="DesignSystem-GenericChip--clearButton"
|
|
121
121
|
role="button"
|
|
122
122
|
style="font-size: 16px; width: 16px;"
|
|
@@ -4,7 +4,7 @@ import { HeadingProps, TextProps } from '@/index.type';
|
|
|
4
4
|
import { Heading, Text } from '@/index';
|
|
5
5
|
import { BaseProps, extractBaseProps } from '@/utils/types';
|
|
6
6
|
|
|
7
|
-
type
|
|
7
|
+
type EmptyStateSize = 'large' | 'small';
|
|
8
8
|
|
|
9
9
|
export interface EmptyStateProps extends BaseProps {
|
|
10
10
|
/**
|
|
@@ -24,7 +24,7 @@ export interface EmptyStateProps extends BaseProps {
|
|
|
24
24
|
*
|
|
25
25
|
* Size: 'large' | 'small'
|
|
26
26
|
*/
|
|
27
|
-
size:
|
|
27
|
+
size: EmptyStateSize;
|
|
28
28
|
/**
|
|
29
29
|
* Button / ButtonGroups to be added inside `EmptyState`
|
|
30
30
|
*/
|
|
@@ -40,12 +40,12 @@ export const imageHeight = {
|
|
|
40
40
|
small: '128px',
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export const HeadingSize: Record<
|
|
43
|
+
export const HeadingSize: Record<EmptyStateSize, HeadingProps['size']> = {
|
|
44
44
|
large: 'l',
|
|
45
45
|
small: 'm',
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
export const textSize: Record<
|
|
48
|
+
export const textSize: Record<EmptyStateSize, TextProps['size']> = {
|
|
49
49
|
large: 'large',
|
|
50
50
|
small: 'regular',
|
|
51
51
|
};
|