-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add first version of simple transfer component
- Loading branch information
Showing
102 changed files
with
6,364 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
> :warning: | ||
> This is currently considered internal, please use `@dhis2/ui`. | ||
> | ||
> See the [Getting started | ||
> guide](https://github.com/dhis2/ui/blob/master/docs/getting-started.md) | ||
> for more information. | ||
For usage instructions see [the documentation for this component](https://ui.dhis2.nu/components/transfer). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
type: 'lib', | ||
entryPoints: { | ||
lib: 'src/index.js', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "@dhis2-ui/simple-transfer", | ||
"version": "9.12.0", | ||
"description": "UI Simple Transfer", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/dhis2/ui.git", | ||
"directory": "components/simple-transfer" | ||
}, | ||
"homepage": "https://github.com/dhis2/ui#readme", | ||
"license": "BSD-3-Clause", | ||
"private": false, | ||
"main": "./build/cjs/index.js", | ||
"module": "./build/es/index.js", | ||
"exports": { | ||
"types": "./types/index.d.ts", | ||
"import": "./build/es/index.js", | ||
"require": "./build/cjs/index.js" | ||
}, | ||
"sideEffects": false, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"start": "storybook dev -c ../../storybook/config --port 5000", | ||
"build": "d2-app-scripts build", | ||
"test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.13", | ||
"react-dom": "^16.13", | ||
"styled-jsx": "^4" | ||
}, | ||
"dependencies": { | ||
"@dhis2/prop-types": "^3.1.2", | ||
"@dhis2-ui/button": "9.12.0", | ||
"@dhis2-ui/field": "9.12.0", | ||
"@dhis2-ui/input": "9.12.0", | ||
"@dhis2-ui/intersection-detector": "9.12.0", | ||
"@dhis2-ui/loader": "9.12.0", | ||
"@dhis2/ui-constants": "9.12.0", | ||
"classnames": "^2.3.1", | ||
"prop-types": "^15.7.2" | ||
}, | ||
"files": [ | ||
"build", | ||
"types" | ||
], | ||
"devDependencies": { | ||
"react": "16.13", | ||
"react-dom": "16.13", | ||
"styled-jsx": "^4.0.1" | ||
}, | ||
"types": "types" | ||
} |
21 changes: 21 additions & 0 deletions
21
components/simple-transfer/src/__e2e__/add_remove-highlighted-options.e2e.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import { SimpleTransfer } from '../simple-transfer.js' | ||
import { options } from './common/options.js' | ||
import { statefulDecorator } from './common/stateful-decorator.js' | ||
|
||
export default { | ||
title: 'SimpleTransfer add & remove highlighted options', | ||
decorators: [statefulDecorator()], | ||
} | ||
|
||
export const HasSelected = (_, { onChange, selected }) => ( | ||
<SimpleTransfer onChange={onChange} selected={selected} options={options} /> | ||
) | ||
|
||
HasSelected.story = { | ||
decorators: [ | ||
statefulDecorator({ | ||
initialState: options.slice(0, 4).map(({ value }) => value), | ||
}), | ||
], | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
export const options = [ | ||
{ | ||
label: 'ANC 1st visit', | ||
value: 'anc_1st_visit', | ||
}, | ||
{ | ||
label: 'ANC 2nd visit', | ||
value: 'anc_2nd_visit', | ||
}, | ||
{ | ||
label: 'ANC 3rd visit', | ||
value: 'anc_3rd_visit', | ||
}, | ||
{ | ||
label: 'ANC 4th or more visits', | ||
value: 'anc_4th_or_more_visits', | ||
}, | ||
{ | ||
label: 'ARI treated with antibiotics (pneumonia) follow-up', | ||
value: 'ari_treated_with_antibiotics_(pneumonia)_follow-up', | ||
}, | ||
{ | ||
label: 'ARI treated with antibiotics (pneumonia) new', | ||
value: 'ari_treated_with_antibiotics_(pneumonia)_new', | ||
}, | ||
{ | ||
label: 'ARI treated with antibiotics (pneumonia) referrals', | ||
value: 'ari_treated_with_antibiotics_(pneumonia)_referrals', | ||
}, | ||
{ | ||
label: 'ARI treated without antibiotics (cough) follow-up', | ||
value: 'ari_treated_without_antibiotics_(cough)_follow-up', | ||
}, | ||
{ | ||
label: 'ARI treated without antibiotics (cough) new', | ||
value: 'ari_treated_without_antibiotics_(cough)_new', | ||
}, | ||
{ | ||
label: 'ARI treated without antibiotics (cough) referrals', | ||
value: 'ari_treated_without_antibiotics_(cough)_referrals', | ||
}, | ||
{ | ||
label: 'ART No clients who stopped TRT due to TRT failure', | ||
value: 'art_no_clients_who_stopped_trt_due_to_trt_failure', | ||
}, | ||
{ | ||
label: 'ART No clients who stopped TRT due to adverse clinical status/event', | ||
value: 'art_no_clients_who_stopped_trt_due_to_adverse_clinical_status/event', | ||
}, | ||
{ | ||
label: 'ART No clients with change of regimen due to drug toxicity', | ||
value: 'art_no_clients_with_change_of_regimen_due_to_drug_toxicity', | ||
}, | ||
{ | ||
label: 'ART No clients with new adverse drug reaction', | ||
value: 'art_no_clients_with_new_adverse_drug_reaction', | ||
}, | ||
{ | ||
label: 'ART No started Opportunist Infection prophylaxis', | ||
value: 'art_no_started_opportunist_infection_prophylaxis', | ||
}, | ||
{ | ||
label: 'ART clients with new adverse clinical event', | ||
value: 'art_clients_with_new_adverse_clinical_event', | ||
}, | ||
{ | ||
label: 'ART defaulters', | ||
value: 'art_defaulters', | ||
}, | ||
{ | ||
label: 'ART enrollment stage 1', | ||
value: 'art_enrollment_stage_1', | ||
}, | ||
{ | ||
label: 'ART enrollment stage 2', | ||
value: 'art_enrollment_stage_2', | ||
}, | ||
{ | ||
label: 'ART enrollment stage 3', | ||
value: 'art_enrollment_stage_3', | ||
}, | ||
{ | ||
label: 'ART enrollment stage 4', | ||
value: 'art_enrollment_stage_4', | ||
}, | ||
{ | ||
label: 'ART entry point: No PMTCT', | ||
value: 'art_entry_point:_no_pmtct', | ||
}, | ||
] |
33 changes: 33 additions & 0 deletions
33
components/simple-transfer/src/__e2e__/common/stateful-decorator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* eslint-disable react/display-name */ | ||
|
||
import React, { useState } from 'react' | ||
|
||
const WithState = ({ fn, initialState, initialSearchTerm, controlFilter }) => { | ||
const [selected, setSelected] = useState(initialState) | ||
const [searchTerm, setSearchTerm] = useState(initialSearchTerm) | ||
|
||
return fn({ | ||
selected, | ||
searchTerm: controlFilter ? searchTerm : undefined, | ||
onChange: (payload) => setSelected(payload.selected), | ||
onFilterChange: controlFilter | ||
? ({ value }) => setSearchTerm(value) | ||
: undefined, | ||
}) | ||
} | ||
|
||
export const statefulDecorator = | ||
({ | ||
initialState = [], | ||
controlFilter = false, | ||
initialSearchTerm = '', | ||
} = {}) => | ||
(fn) => | ||
( | ||
<WithState | ||
initialState={initialState} | ||
initialSearchTerm={initialSearchTerm} | ||
controlFilter={controlFilter} | ||
fn={fn} | ||
/> | ||
) |
49 changes: 49 additions & 0 deletions
49
components/simple-transfer/src/__e2e__/disabled-transfer-buttons.e2e.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react' | ||
import { SimpleTransfer } from '../simple-transfer.js' | ||
import { options } from './common/options.js' | ||
import { statefulDecorator } from './common/stateful-decorator.js' | ||
|
||
export default { | ||
title: 'SimpleTransfer Disabled SimpleTransfer Buttons', | ||
decorators: [statefulDecorator()], | ||
} | ||
|
||
export const NoOptions = (_, { selected, onChange }) => ( | ||
<SimpleTransfer selected={selected} onChange={onChange} options={[]} /> | ||
) | ||
|
||
export const HasOptions = (_, { selected, onChange }) => ( | ||
<SimpleTransfer selected={selected} onChange={onChange} options={options} /> | ||
) | ||
|
||
export const SomeOptionsSelected = (_, { selected, onChange }) => ( | ||
<SimpleTransfer selected={selected} onChange={onChange} options={options} /> | ||
) | ||
|
||
export const OnlyDisabledSourceOptions = (_, { selected, onChange }) => ( | ||
<SimpleTransfer | ||
selected={selected} | ||
onChange={onChange} | ||
options={[{ ...options[0], disabled: true }]} | ||
/> | ||
) | ||
|
||
SomeOptionsSelected.story = { | ||
decorators: [ | ||
statefulDecorator({ | ||
initialState: options.slice(0, 4).map(({ value }) => value), | ||
}), | ||
], | ||
} | ||
|
||
export const AllOptionsSelected = (_, { selected, onChange }) => ( | ||
<SimpleTransfer selected={selected} onChange={onChange} options={options} /> | ||
) | ||
|
||
AllOptionsSelected.story = { | ||
decorators: [ | ||
statefulDecorator({ | ||
initialState: options.map(({ value }) => value), | ||
}), | ||
], | ||
} |
21 changes: 21 additions & 0 deletions
21
components/simple-transfer/src/__e2e__/disabled-transfer-options.e2e.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import { SimpleTransfer } from '../simple-transfer.js' | ||
import { options } from './common/options.js' | ||
import { statefulDecorator } from './common/stateful-decorator.js' | ||
|
||
export default { | ||
title: 'Disabled Source Options', | ||
decorators: [statefulDecorator()], | ||
} | ||
|
||
export const OneDisabled = (_, { selected, onChange }) => ( | ||
<SimpleTransfer | ||
selected={selected} | ||
onChange={onChange} | ||
options={[ | ||
...options.slice(0, 3), | ||
{ ...options[3], disabled: true }, | ||
...options.slice(4), | ||
]} | ||
/> | ||
) |
24 changes: 24 additions & 0 deletions
24
components/simple-transfer/src/__e2e__/display-order.e2e.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import { SimpleTransfer } from '../simple-transfer.js' | ||
import { options } from './common/options.js' | ||
import { statefulDecorator } from './common/stateful-decorator.js' | ||
|
||
export default { title: 'SimpleTransfer Display Order' } | ||
|
||
window.options = options | ||
|
||
export const NoSelection = (_, { selected, onChange }) => ( | ||
<SimpleTransfer selected={selected} onChange={onChange} options={options} /> | ||
) | ||
|
||
export const SomeSelected = (_, { selected, onChange }) => ( | ||
<SimpleTransfer selected={selected} onChange={onChange} options={options} /> | ||
) | ||
|
||
SomeSelected.story = { | ||
decorators: [ | ||
statefulDecorator({ | ||
initialState: options.slice(0, 4).map(({ value }) => value), | ||
}), | ||
], | ||
} |
Oops, something went wrong.