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.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.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 5069205c0b..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, }, } @@ -242,7 +249,10 @@ const RenderOptionCode = () => ( ) -const StatefulTemplateCustomRenderOption = ({ initiallySelected = [], ...args }) => { +const StatefulTemplateCustomRenderOption = ({ + initiallySelected = [], + ...args +}) => { const [selected, setSelected] = useState(initiallySelected) const onChange = (payload) => setSelected(payload.selected) 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', -}