Skip to content

Commit 0e9ca9b

Browse files
montezumekodiakhq[bot]
authored andcommitted
feat(localized-money-input): support isReadOnly prop (#1158)
* feat(localized-money-input): support isReadOnly prop * chore: update readme
1 parent 798b95e commit 0e9ca9b

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

src/components/inputs/localized-money-input/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { LocalizedMoneyInput } from '@commercetools-frontend/ui-kit';
3333
| `hideCurrencyExpansionControls` | `bool` | - | - | `false` | Will hide the currency toggle controls when set to `true`. It always shows all currencies instead. |
3434
| `defaultExpandCurrencies` | `bool` | - | - | `false` | Controls whether one or all currencies are visible by default. Pass `true` to show all currencies by default. |
3535
| `isDisabled` | `bool` | - | - | `false` | Disables all input fields. |
36+
| `isReadOnly` | `bool` | - | - | `false` | Makes all input fields readonly. |
3637
| `placeholder` | `object` | - | - | - | Placeholders for each currency. Object of the same shape as `value`. |
3738
| `horizontalConstraint` | `object` | - | `m`, `l`, `xl`, `scale` | `scale` | Horizontal size limit of the input fields. |
3839
| `hasError` | `bool` | - | - | - | Will apply the error state to each input without showing any error message. |

src/components/inputs/localized-money-input/localized-money-input.js

+4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const LocalizedInput = props => {
6868
onChange={handleChange}
6969
onBlur={props.onBlur}
7070
isDisabled={props.isDisabled}
71+
isReadOnly={props.isReadOnly}
7172
placeholder={props.placeholder}
7273
hasError={props.hasError}
7374
hasWarning={props.hasWarning}
@@ -110,6 +111,7 @@ LocalizedInput.propTypes = {
110111
onBlur: PropTypes.func,
111112
onFocus: PropTypes.func,
112113
isDisabled: PropTypes.bool,
114+
isReadOnly: PropTypes.bool,
113115
currenciesControl: PropTypes.node,
114116
hasError: PropTypes.bool,
115117
hasWarning: PropTypes.bool,
@@ -188,6 +190,7 @@ const LocalizedMoneyInput = props => {
188190
onBlur={props.onBlur}
189191
onFocus={props.onFocus}
190192
isDisabled={props.isDisabled}
193+
isReadOnly={props.isReadOnly}
191194
currenciesControl={(() => {
192195
if (
193196
!hasRemainingCurrencies ||
@@ -269,6 +272,7 @@ LocalizedMoneyInput.propTypes = {
269272
return PropTypes.bool(props, propName, componentName, ...rest);
270273
},
271274
isDisabled: PropTypes.bool,
275+
isReadOnly: PropTypes.bool,
272276
placeholder: PropTypes.objectOf(PropTypes.string),
273277
horizontalConstraint: PropTypes.oneOf(['m', 'l', 'xl', 'scale']),
274278
hasError: PropTypes.bool,

src/components/inputs/localized-money-input/localized-money-input.story.js

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ storiesOf('Components|Inputs', module)
7373
defaultExpandCurrencies || undefined
7474
}
7575
isDisabled={boolean('isDisabled', false)}
76+
isReadOnly={boolean('isReadOnly', false)}
7677
placeholder={object('placeholder', { EUR: '', USD: '' })}
7778
horizontalConstraint={select(
7879
'horizontalConstraint',

src/components/inputs/localized-money-input/localized-money-input.visualroute.js

+19
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,25 @@ export const component = () => (
6464
isDisabled={true}
6565
/>
6666
</Spec>
67+
<Spec label="when readonly and open">
68+
<LocalizedMoneyInput
69+
value={value}
70+
onChange={() => {}}
71+
selectedCurrency="CAD"
72+
horizontalConstraint="m"
73+
isReadOnly={true}
74+
defaultExpandCurrencies={true}
75+
/>
76+
</Spec>
77+
<Spec label="when readonly and closed">
78+
<LocalizedMoneyInput
79+
value={value}
80+
onChange={() => {}}
81+
selectedCurrency="CAD"
82+
horizontalConstraint="m"
83+
isReadOnly={true}
84+
/>
85+
</Spec>
6786
<Spec label="when there is an error for a specific currency (first one)">
6887
<LocalizedMoneyInput
6988
value={value}

0 commit comments

Comments
 (0)