diff --git a/components/calendar/src/stories/calendar-story-wrapper.js b/components/calendar/src/stories/calendar-story-wrapper.js index 89724da63a..e1f8d362b9 100644 --- a/components/calendar/src/stories/calendar-story-wrapper.js +++ b/components/calendar/src/stories/calendar-story-wrapper.js @@ -1,7 +1,6 @@ import { constants } from '@dhis2/multi-calendar-dates' import PropTypes from 'prop-types' import React, { useState } from 'react' -import { Calendar } from '../calendar/calendar.js' const { calendars, numberingSystems } = constants export const CalendarStoryWrapper = (props) => { diff --git a/components/file-input/src/file-input-field-with-list/file-input-field-with-list.js b/components/file-input/src/file-input-field-with-list/file-input-field-with-list.js index c63eae61e1..c43c564fc1 100644 --- a/components/file-input/src/file-input-field-with-list/file-input-field-with-list.js +++ b/components/file-input/src/file-input-field-with-list/file-input-field-with-list.js @@ -2,7 +2,6 @@ import { sharedPropTypes } from '@dhis2/ui-constants' import PropTypes from 'prop-types' import React, { Component } from 'react' import { FileInputField } from '../file-input-field/index.js' -import i18n from '../locales/index.js' import { FileListItemWithRemove } from './file-list-item-with-remove.js' // TODO: i18n diff --git a/components/file-input/src/file-input-field-with-list/file-input-field-with-list.prod.stories.js b/components/file-input/src/file-input-field-with-list/file-input-field-with-list.prod.stories.js index 7e1fd5a71e..e996b4ca26 100644 --- a/components/file-input/src/file-input-field-with-list/file-input-field-with-list.prod.stories.js +++ b/components/file-input/src/file-input-field-with-list/file-input-field-with-list.prod.stories.js @@ -24,7 +24,11 @@ export default { parameters: { docs: { description: { component: description } } }, args: { // Handle default props bug (see Transfer stories) - ...FileInputFieldWithList.defaultProps, + dataTest: 'dhis2-uiwidgets-fileinputfieldwithlist', + files: [], + buttonLabel: 'Upload a file', + placeholder: 'No file uploaded yet', + removeText: 'Remove', multiple: true, onChange: onChange, name: 'uploadName', diff --git a/components/file-input/src/file-input-field/file-input-field.prod.stories.js b/components/file-input/src/file-input-field/file-input-field.prod.stories.js index bcb4a8094b..14b6a6b70a 100644 --- a/components/file-input/src/file-input-field/file-input-field.prod.stories.js +++ b/components/file-input/src/file-input-field/file-input-field.prod.stories.js @@ -22,7 +22,9 @@ export default { // Default args: args: { // Handle default values (see comment in Transfer.js) - ...FileInputField.defaultProps, + accept: '*', + dataTest: 'dhis2-uiwidgets-fileinputfield', + placeholder: 'No file uploaded yet', onChange: onChange, name: 'uploadName', label: 'Upload something', diff --git a/components/layer/src/layer.prod.stories.js b/components/layer/src/layer.prod.stories.js index 7ffee2f769..696a76e7e6 100644 --- a/components/layer/src/layer.prod.stories.js +++ b/components/layer/src/layer.prod.stories.js @@ -33,7 +33,11 @@ export default { }, }, // Handle weird treatment of non-literal defaultProps (see Transfer.stories) - args: { ...Layer.defaultProps }, + args: { + position: 'fixed', + dataTest: 'dhis2-uicore-layer', + level: 'auto', + }, } const Template = (args) => ( diff --git a/components/pagination/src/__tests__/page-summary.test.js b/components/pagination/src/__tests__/page-summary.test.js index 96f7df9376..6fb263472d 100644 --- a/components/pagination/src/__tests__/page-summary.test.js +++ b/components/pagination/src/__tests__/page-summary.test.js @@ -1,12 +1,12 @@ import { shallow } from 'enzyme' import React from 'react' +import { getDefaultPageSummaryText } from '../get-default-page-summary-text.js' import { PageSummary } from '../page-summary.js' -import { Pagination } from '../pagination.js' describe('', () => { const props = { dataTest: 'test', - pageSummaryText: Pagination.defaultProps.pageSummaryText, + pageSummaryText: getDefaultPageSummaryText, } it('renders without errors', () => { diff --git a/components/popover/src/popover.prod.stories.js b/components/popover/src/popover.prod.stories.js index c586f0872c..801cad5c4b 100644 --- a/components/popover/src/popover.prod.stories.js +++ b/components/popover/src/popover.prod.stories.js @@ -37,7 +37,13 @@ export default { }, }, // Handles weird treatment of non-literal args (`elevation: elevations.e200`) - args: { ...Popover.defaultProps }, + args: { + arrow: true, + dataTest: 'dhis2-uicore-popover', + elevation: elevations.e200, + maxWidth: 360, + placement: 'top', + }, argTypes: { reference: { ...sharedPropTypes.popperReferenceArgType }, placement: { ...sharedPropTypes.popperPlacementArgType }, diff --git a/components/select/src/multi-select-field/multi-select-field.js b/components/select/src/multi-select-field/multi-select-field.js index acabd4cbc8..c31e62dcd3 100644 --- a/components/select/src/multi-select-field/multi-select-field.js +++ b/components/select/src/multi-select-field/multi-select-field.js @@ -3,7 +3,6 @@ import { Box } from '@dhis2-ui/box' import { Field } from '@dhis2-ui/field' import PropTypes from 'prop-types' import React from 'react' -import i18n from '../locales/index.js' import { MultiSelect } from '../multi-select/index.js' // TODO: translate diff --git a/components/select/src/multi-select-field/multi-select-field.prod.stories.js b/components/select/src/multi-select-field/multi-select-field.prod.stories.js index 0dd203d8c1..69869c2d3c 100644 --- a/components/select/src/multi-select-field/multi-select-field.prod.stories.js +++ b/components/select/src/multi-select-field/multi-select-field.prod.stories.js @@ -39,7 +39,13 @@ export default { // default args for stories args: { // Fix default prop issues - causes 'i18n is not defined' error - ...MultiSelectField.defaultProps, + dataTest: 'dhis2-uiwidgets-multiselectfield', + clearText: 'Clear', + empty: 'No data found', + filterPlaceholder: 'Type to filter options', + loadingText: 'Loading options', + noMatchText: 'No options found', + label: 'Default label', selected: ['1'], children: options, diff --git a/components/select/src/single-select-field/single-select-field.js b/components/select/src/single-select-field/single-select-field.js index b9e3de1803..6455248b2f 100644 --- a/components/select/src/single-select-field/single-select-field.js +++ b/components/select/src/single-select-field/single-select-field.js @@ -3,7 +3,6 @@ import { Box } from '@dhis2-ui/box' import { Field } from '@dhis2-ui/field' import PropTypes from 'prop-types' import React from 'react' -import i18n from '../locales/index.js' import { SingleSelect } from '../single-select/index.js' // TODO: translate diff --git a/components/select/src/single-select-field/single-select-field.prod.stories.js b/components/select/src/single-select-field/single-select-field.prod.stories.js index bd0a610a00..cf20d6dbc9 100644 --- a/components/select/src/single-select-field/single-select-field.prod.stories.js +++ b/components/select/src/single-select-field/single-select-field.prod.stories.js @@ -39,7 +39,15 @@ export default { // default args for stories args: { // Fix default prop issues - causes 'i18n is not defined' error - ...SingleSelectField.defaultProps, + dataTest: 'dhis2-uiwidgets-singleselectfield', + selected: '', + + clearText: 'Clear', + empty: 'No data found', + filterPlaceholder: 'Type to filter options', + loadingText: 'Loading options', + noMatchText: 'No options found', + label: 'Default label', children: options, onChange: onChange, diff --git a/components/transfer/src/transfer.prod.stories.js b/components/transfer/src/transfer.prod.stories.js index 4b546f01d1..793d0f4d16 100644 --- a/components/transfer/src/transfer.prod.stories.js +++ b/components/transfer/src/transfer.prod.stories.js @@ -150,7 +150,14 @@ export default { }, // Default args: args: { - ...Transfer.defaultProps, + dataTest: 'dhis2-uicore-transfer', + height: '240px', + initialSearchTerm: '', + initialSearchTermPicked: '', + maxSelections: Infinity, + optionsWidth: '320px', + selected: [], + selectedWidth: '320px', options: options, }, } diff --git a/docs/src/components/DemoComponent.jsx b/docs/src/components/DemoComponent.jsx index db6c27866d..cc457947e3 100644 --- a/docs/src/components/DemoComponent.jsx +++ b/docs/src/components/DemoComponent.jsx @@ -3,7 +3,7 @@ import React, { useRef } from 'react' import { DEMO_URL } from '../constants.js' import styles from './DemoComponent.module.css' -export const Demo = ({ path, args, height }) => { +export const Demo = ({ path, args = '', height = '100px' }) => { const iframeRef = useRef(null) const handleReload = () => { @@ -73,8 +73,3 @@ Demo.propTypes = { args: PropTypes.string, height: PropTypes.string, } - -Demo.defaultProps = { - args: '', - height: '100px', -}