@transferwise/components 0.0.0-experimental-c654bc3 → 0.0.0-experimental-a7e0e6f
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/build/index.esm.js +47 -141
- package/build/index.esm.js.map +1 -1
- package/build/index.js +47 -141
- package/build/index.js.map +1 -1
- package/build/main.css +7 -5
- package/build/styles/dimmer/Dimmer.css +0 -3
- package/build/styles/drawer/Drawer.css +3 -0
- package/build/styles/main.css +7 -5
- package/build/styles/modal/Modal.css +4 -2
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +98 -57
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/typeahead/index.d.ts +3 -2
- package/build/types/typeahead/index.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts +23 -41
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadOption/TypeaheadOption.d.ts +9 -17
- package/build/types/typeahead/typeaheadOption/TypeaheadOption.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/dimmer/Dimmer.css +0 -3
- package/src/dimmer/Dimmer.less +0 -4
- package/src/drawer/Drawer.css +3 -0
- package/src/drawer/Drawer.less +4 -0
- package/src/index.ts +2 -1
- package/src/main.css +7 -5
- package/src/modal/Modal.css +4 -2
- package/src/modal/Modal.less +5 -1
- package/src/modal/Modal.story.tsx +4 -2
- package/src/typeahead/Typeahead.spec.js +1 -1
- package/src/typeahead/{Typeahead.story.js → Typeahead.story.tsx} +8 -7
- package/src/typeahead/{Typeahead.js → Typeahead.tsx} +105 -106
- package/src/typeahead/index.ts +4 -0
- package/src/typeahead/typeaheadInput/{TypeaheadInput.js → TypeaheadInput.tsx} +43 -42
- package/src/typeahead/typeaheadOption/{TypeaheadOption.js → TypeaheadOption.tsx} +10 -20
- package/src/typeahead/index.js +0 -3
package/build/index.js
CHANGED
|
@@ -12244,8 +12244,10 @@ const TextareaWithDisplayFormat = props => /*#__PURE__*/jsxRuntime.jsx(WithDispl
|
|
|
12244
12244
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
12245
12245
|
const DEFAULT_INPUT_MIN_WIDTH = 10;
|
|
12246
12246
|
class TypeaheadInput extends React.Component {
|
|
12247
|
-
|
|
12248
|
-
|
|
12247
|
+
inputRef = null;
|
|
12248
|
+
sizerRef = null;
|
|
12249
|
+
constructor(props) {
|
|
12250
|
+
super(props);
|
|
12249
12251
|
this.state = {
|
|
12250
12252
|
inputWidth: DEFAULT_INPUT_MIN_WIDTH
|
|
12251
12253
|
};
|
|
@@ -12255,7 +12257,7 @@ class TypeaheadInput extends React.Component {
|
|
|
12255
12257
|
autoFocus
|
|
12256
12258
|
} = this.props;
|
|
12257
12259
|
if (autoFocus) {
|
|
12258
|
-
this.inputRef
|
|
12260
|
+
this.inputRef?.focus();
|
|
12259
12261
|
}
|
|
12260
12262
|
}
|
|
12261
12263
|
componentDidUpdate(previousProps) {
|
|
@@ -12266,19 +12268,19 @@ class TypeaheadInput extends React.Component {
|
|
|
12266
12268
|
recalculateWidth = () => {
|
|
12267
12269
|
requestAnimationFrame(() => {
|
|
12268
12270
|
this.setState({
|
|
12269
|
-
inputWidth: Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.scrollWidth + 10)
|
|
12271
|
+
inputWidth: this.sizerRef ? Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.scrollWidth + 10) : DEFAULT_INPUT_MIN_WIDTH
|
|
12270
12272
|
});
|
|
12271
12273
|
});
|
|
12272
12274
|
};
|
|
12273
12275
|
renderInput = () => {
|
|
12274
12276
|
const {
|
|
12275
12277
|
typeaheadId,
|
|
12276
|
-
autoFocus,
|
|
12278
|
+
autoFocus = false,
|
|
12277
12279
|
multiple,
|
|
12278
12280
|
name,
|
|
12279
|
-
optionsShown,
|
|
12280
|
-
placeholder,
|
|
12281
|
-
selected,
|
|
12281
|
+
optionsShown = false,
|
|
12282
|
+
placeholder = '',
|
|
12283
|
+
selected = [],
|
|
12282
12284
|
value,
|
|
12283
12285
|
onChange,
|
|
12284
12286
|
onKeyDown,
|
|
@@ -12319,18 +12321,18 @@ class TypeaheadInput extends React.Component {
|
|
|
12319
12321
|
render() {
|
|
12320
12322
|
const {
|
|
12321
12323
|
multiple,
|
|
12322
|
-
selected,
|
|
12324
|
+
selected = [],
|
|
12323
12325
|
value,
|
|
12324
|
-
maxHeight,
|
|
12326
|
+
maxHeight = null,
|
|
12325
12327
|
renderChip
|
|
12326
12328
|
} = this.props;
|
|
12327
12329
|
return multiple ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
12328
12330
|
className: "form-control typeahead__input-container",
|
|
12329
|
-
style:
|
|
12330
|
-
maxHeight
|
|
12331
|
+
style: {
|
|
12332
|
+
maxHeight: maxHeight ?? undefined
|
|
12331
12333
|
},
|
|
12332
12334
|
onClick: () => {
|
|
12333
|
-
this.inputRef
|
|
12335
|
+
this.inputRef?.focus();
|
|
12334
12336
|
},
|
|
12335
12337
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
12336
12338
|
className: "typeahead__input-wrapper",
|
|
@@ -12347,30 +12349,6 @@ class TypeaheadInput extends React.Component {
|
|
|
12347
12349
|
}) : this.renderInput();
|
|
12348
12350
|
}
|
|
12349
12351
|
}
|
|
12350
|
-
TypeaheadInput.propTypes = {
|
|
12351
|
-
typeaheadId: PropTypes__default.default.string.isRequired,
|
|
12352
|
-
name: PropTypes__default.default.string.isRequired,
|
|
12353
|
-
autoFocus: PropTypes__default.default.bool,
|
|
12354
|
-
multiple: PropTypes__default.default.bool.isRequired,
|
|
12355
|
-
value: PropTypes__default.default.string.isRequired,
|
|
12356
|
-
selected: PropTypes__default.default.arrayOf(PropTypes__default.default.object),
|
|
12357
|
-
placeholder: PropTypes__default.default.string,
|
|
12358
|
-
optionsShown: PropTypes__default.default.bool,
|
|
12359
|
-
maxHeight: PropTypes__default.default.number,
|
|
12360
|
-
autoComplete: PropTypes__default.default.string.isRequired,
|
|
12361
|
-
onChange: PropTypes__default.default.func.isRequired,
|
|
12362
|
-
renderChip: PropTypes__default.default.func.isRequired,
|
|
12363
|
-
onKeyDown: PropTypes__default.default.func.isRequired,
|
|
12364
|
-
onFocus: PropTypes__default.default.func.isRequired,
|
|
12365
|
-
onPaste: PropTypes__default.default.func.isRequired
|
|
12366
|
-
};
|
|
12367
|
-
TypeaheadInput.defaultProps = {
|
|
12368
|
-
autoFocus: false,
|
|
12369
|
-
maxHeight: null,
|
|
12370
|
-
placeholder: '',
|
|
12371
|
-
optionsShown: false,
|
|
12372
|
-
selected: []
|
|
12373
|
-
};
|
|
12374
12352
|
|
|
12375
12353
|
function highlight(value, query) {
|
|
12376
12354
|
if (value && query) {
|
|
@@ -12391,9 +12369,9 @@ function highlight(value, query) {
|
|
|
12391
12369
|
const Option = props => {
|
|
12392
12370
|
const {
|
|
12393
12371
|
option,
|
|
12394
|
-
selected,
|
|
12395
|
-
onClick,
|
|
12396
|
-
query
|
|
12372
|
+
selected = false,
|
|
12373
|
+
onClick = () => {},
|
|
12374
|
+
query = ''
|
|
12397
12375
|
} = props;
|
|
12398
12376
|
const {
|
|
12399
12377
|
label,
|
|
@@ -12423,30 +12401,32 @@ const Option = props => {
|
|
|
12423
12401
|
})
|
|
12424
12402
|
});
|
|
12425
12403
|
};
|
|
12426
|
-
Option.propTypes = {
|
|
12427
|
-
option: PropTypes__default.default.shape({
|
|
12428
|
-
label: PropTypes__default.default.string.isRequired,
|
|
12429
|
-
note: PropTypes__default.default.string,
|
|
12430
|
-
secondary: PropTypes__default.default.string
|
|
12431
|
-
}).isRequired,
|
|
12432
|
-
query: PropTypes__default.default.string,
|
|
12433
|
-
selected: PropTypes__default.default.bool,
|
|
12434
|
-
onClick: PropTypes__default.default.func
|
|
12435
|
-
};
|
|
12436
|
-
Option.defaultProps = {
|
|
12437
|
-
selected: false,
|
|
12438
|
-
query: '',
|
|
12439
|
-
onClick: () => {}
|
|
12440
|
-
};
|
|
12441
|
-
var TypeaheadOption = Option;
|
|
12442
12404
|
|
|
12443
12405
|
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
12444
12406
|
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
12445
12407
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
12446
|
-
|
|
12447
12408
|
const DEFAULT_MIN_QUERY_LENGTH = 3;
|
|
12448
12409
|
const SEARCH_DELAY = 200;
|
|
12449
12410
|
class Typeahead extends React.Component {
|
|
12411
|
+
static defaultProps = {
|
|
12412
|
+
addon: null,
|
|
12413
|
+
allowNew: false,
|
|
12414
|
+
autoFillOnBlur: true,
|
|
12415
|
+
autoFocus: false,
|
|
12416
|
+
chipSeparators: [],
|
|
12417
|
+
clearable: true,
|
|
12418
|
+
footer: null,
|
|
12419
|
+
initialValue: [],
|
|
12420
|
+
inputAutoComplete: 'new-password',
|
|
12421
|
+
maxHeight: null,
|
|
12422
|
+
minQueryLength: DEFAULT_MIN_QUERY_LENGTH,
|
|
12423
|
+
multiple: false,
|
|
12424
|
+
searchDelay: SEARCH_DELAY,
|
|
12425
|
+
showSuggestions: true,
|
|
12426
|
+
showNewEntry: true,
|
|
12427
|
+
size: exports.Size.MEDIUM,
|
|
12428
|
+
validateChip: () => true
|
|
12429
|
+
};
|
|
12450
12430
|
constructor(props) {
|
|
12451
12431
|
super(props);
|
|
12452
12432
|
const {
|
|
@@ -12463,6 +12443,7 @@ class Typeahead extends React.Component {
|
|
|
12463
12443
|
keyboardFocusedOptionIndex: null
|
|
12464
12444
|
};
|
|
12465
12445
|
}
|
|
12446
|
+
handleSearchDebounced;
|
|
12466
12447
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
12467
12448
|
if (nextProps.multiple !== this.props.multiple) {
|
|
12468
12449
|
this.setState(previousState => {
|
|
@@ -12476,7 +12457,8 @@ class Typeahead extends React.Component {
|
|
|
12476
12457
|
};
|
|
12477
12458
|
}
|
|
12478
12459
|
return {
|
|
12479
|
-
query: ''
|
|
12460
|
+
query: '',
|
|
12461
|
+
selected: previousState.selected
|
|
12480
12462
|
};
|
|
12481
12463
|
});
|
|
12482
12464
|
}
|
|
@@ -12485,13 +12467,8 @@ class Typeahead extends React.Component {
|
|
|
12485
12467
|
this.handleSearchDebounced.cancel();
|
|
12486
12468
|
}
|
|
12487
12469
|
handleOnFocus = () => {
|
|
12488
|
-
const {
|
|
12489
|
-
onFocus
|
|
12490
|
-
} = this.props;
|
|
12491
12470
|
this.showMenu();
|
|
12492
|
-
|
|
12493
|
-
this.props.onFocus();
|
|
12494
|
-
}
|
|
12471
|
+
this.props.onFocus?.();
|
|
12495
12472
|
};
|
|
12496
12473
|
onOptionSelected = (event, item) => {
|
|
12497
12474
|
event.preventDefault();
|
|
@@ -12574,7 +12551,7 @@ class Typeahead extends React.Component {
|
|
|
12574
12551
|
break;
|
|
12575
12552
|
case 'Enter':
|
|
12576
12553
|
event.preventDefault();
|
|
12577
|
-
if (options[keyboardFocusedOptionIndex]) {
|
|
12554
|
+
if (keyboardFocusedOptionIndex && options[keyboardFocusedOptionIndex]) {
|
|
12578
12555
|
this.selectItem(options[keyboardFocusedOptionIndex]);
|
|
12579
12556
|
} else if (allowNew && query.trim()) {
|
|
12580
12557
|
this.selectItem({
|
|
@@ -12626,13 +12603,6 @@ class Typeahead extends React.Component {
|
|
|
12626
12603
|
query
|
|
12627
12604
|
});
|
|
12628
12605
|
};
|
|
12629
|
-
stopPropagation = event => {
|
|
12630
|
-
event.stopPropagation();
|
|
12631
|
-
event.preventDefault();
|
|
12632
|
-
if (event.nativeEvent && event.nativeEvent.stopImmediatePropagation) {
|
|
12633
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
12634
|
-
}
|
|
12635
|
-
};
|
|
12636
12606
|
handleSearch = query => {
|
|
12637
12607
|
const {
|
|
12638
12608
|
onSearch
|
|
@@ -12717,7 +12687,7 @@ class Typeahead extends React.Component {
|
|
|
12717
12687
|
}
|
|
12718
12688
|
};
|
|
12719
12689
|
renderChip = (option, idx) => {
|
|
12720
|
-
const valid = this.props.validateChip(option);
|
|
12690
|
+
const valid = this.props.validateChip?.(option);
|
|
12721
12691
|
return /*#__PURE__*/jsxRuntime.jsx(Chip, {
|
|
12722
12692
|
label: option.label,
|
|
12723
12693
|
className: classNames__default.default('m-t-1', {
|
|
@@ -12752,7 +12722,7 @@ class Typeahead extends React.Component {
|
|
|
12752
12722
|
className: "dropdown-menu",
|
|
12753
12723
|
role: "menu",
|
|
12754
12724
|
"aria-labelledby": "dropdownMenu1",
|
|
12755
|
-
children: [optionsToRender.map((option, idx) => /*#__PURE__*/jsxRuntime.jsx(
|
|
12725
|
+
children: [optionsToRender.map((option, idx) => /*#__PURE__*/jsxRuntime.jsx(Option, {
|
|
12756
12726
|
query: query,
|
|
12757
12727
|
option: option,
|
|
12758
12728
|
selected: keyboardFocusedOptionIndex === idx,
|
|
@@ -12795,6 +12765,7 @@ class Typeahead extends React.Component {
|
|
|
12795
12765
|
const menu = this.renderMenu({
|
|
12796
12766
|
footer,
|
|
12797
12767
|
options,
|
|
12768
|
+
id,
|
|
12798
12769
|
keyboardFocusedOptionIndex,
|
|
12799
12770
|
query,
|
|
12800
12771
|
allowNew,
|
|
@@ -12813,7 +12784,7 @@ class Typeahead extends React.Component {
|
|
|
12813
12784
|
'typeahead--multiple': multiple,
|
|
12814
12785
|
open: dropdownOpen
|
|
12815
12786
|
}),
|
|
12816
|
-
onClick:
|
|
12787
|
+
onClick: stopPropagation$1,
|
|
12817
12788
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
12818
12789
|
className: classNames__default.default('form-group', {
|
|
12819
12790
|
'has-error': hasError,
|
|
@@ -12834,6 +12805,7 @@ class Typeahead extends React.Component {
|
|
|
12834
12805
|
placeholder,
|
|
12835
12806
|
selected,
|
|
12836
12807
|
maxHeight,
|
|
12808
|
+
id: id,
|
|
12837
12809
|
name: name,
|
|
12838
12810
|
value: query,
|
|
12839
12811
|
typeaheadId: id,
|
|
@@ -12860,72 +12832,6 @@ class Typeahead extends React.Component {
|
|
|
12860
12832
|
});
|
|
12861
12833
|
}
|
|
12862
12834
|
}
|
|
12863
|
-
Typeahead.propTypes = {
|
|
12864
|
-
id: PropTypes__default.default.string.isRequired,
|
|
12865
|
-
name: PropTypes__default.default.string.isRequired,
|
|
12866
|
-
options: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
12867
|
-
label: PropTypes__default.default.string.isRequired,
|
|
12868
|
-
note: PropTypes__default.default.string,
|
|
12869
|
-
secondary: PropTypes__default.default.string,
|
|
12870
|
-
value: PropTypes__default.default.object
|
|
12871
|
-
})).isRequired,
|
|
12872
|
-
initialValue: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
12873
|
-
label: PropTypes__default.default.string.isRequired,
|
|
12874
|
-
note: PropTypes__default.default.string,
|
|
12875
|
-
secondary: PropTypes__default.default.string
|
|
12876
|
-
})),
|
|
12877
|
-
onChange: PropTypes__default.default.func.isRequired,
|
|
12878
|
-
allowNew: PropTypes__default.default.bool,
|
|
12879
|
-
autoFocus: PropTypes__default.default.bool,
|
|
12880
|
-
clearable: PropTypes__default.default.bool,
|
|
12881
|
-
multiple: PropTypes__default.default.bool,
|
|
12882
|
-
showSuggestions: PropTypes__default.default.bool,
|
|
12883
|
-
showNewEntry: PropTypes__default.default.bool,
|
|
12884
|
-
searchDelay: PropTypes__default.default.number,
|
|
12885
|
-
maxHeight: PropTypes__default.default.number,
|
|
12886
|
-
minQueryLength: PropTypes__default.default.number,
|
|
12887
|
-
addon: PropTypes__default.default.node,
|
|
12888
|
-
placeholder: PropTypes__default.default.string,
|
|
12889
|
-
alert: PropTypes__default.default.shape({
|
|
12890
|
-
message: PropTypes__default.default.string.isRequired,
|
|
12891
|
-
type: PropTypes__default.default.oneOf(['error', 'warning', 'neutral']).isRequired
|
|
12892
|
-
}),
|
|
12893
|
-
footer: PropTypes__default.default.node,
|
|
12894
|
-
validateChip: PropTypes__default.default.func,
|
|
12895
|
-
onSearch: PropTypes__default.default.func,
|
|
12896
|
-
onBlur: PropTypes__default.default.func,
|
|
12897
|
-
onInputChange: PropTypes__default.default.func,
|
|
12898
|
-
onFocus: PropTypes__default.default.func,
|
|
12899
|
-
chipSeparators: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
|
|
12900
|
-
size: PropTypes__default.default.oneOf(['md', 'lg']),
|
|
12901
|
-
inputAutoComplete: PropTypes__default.default.string,
|
|
12902
|
-
autoFillOnBlur: PropTypes__default.default.bool
|
|
12903
|
-
};
|
|
12904
|
-
Typeahead.defaultProps = {
|
|
12905
|
-
allowNew: false,
|
|
12906
|
-
autoFocus: false,
|
|
12907
|
-
clearable: true,
|
|
12908
|
-
multiple: false,
|
|
12909
|
-
maxHeight: null,
|
|
12910
|
-
showSuggestions: true,
|
|
12911
|
-
showNewEntry: true,
|
|
12912
|
-
searchDelay: SEARCH_DELAY,
|
|
12913
|
-
minQueryLength: DEFAULT_MIN_QUERY_LENGTH,
|
|
12914
|
-
addon: null,
|
|
12915
|
-
placeholder: null,
|
|
12916
|
-
alert: null,
|
|
12917
|
-
footer: null,
|
|
12918
|
-
size: exports.Size.MEDIUM,
|
|
12919
|
-
chipSeparators: [],
|
|
12920
|
-
initialValue: [],
|
|
12921
|
-
onSearch: null,
|
|
12922
|
-
onBlur: null,
|
|
12923
|
-
onInputChange: null,
|
|
12924
|
-
onFocus: null,
|
|
12925
|
-
validateChip: () => true,
|
|
12926
|
-
inputAutoComplete: 'new-password',
|
|
12927
|
-
autoFillOnBlur: true
|
|
12928
|
-
};
|
|
12929
12835
|
|
|
12930
12836
|
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
12931
12837
|
exports.UploadStep = void 0;
|