@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.esm.js
CHANGED
|
@@ -12210,8 +12210,10 @@ const TextareaWithDisplayFormat = props => /*#__PURE__*/jsx(WithDisplayFormat, {
|
|
|
12210
12210
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
12211
12211
|
const DEFAULT_INPUT_MIN_WIDTH = 10;
|
|
12212
12212
|
class TypeaheadInput extends Component {
|
|
12213
|
-
|
|
12214
|
-
|
|
12213
|
+
inputRef = null;
|
|
12214
|
+
sizerRef = null;
|
|
12215
|
+
constructor(props) {
|
|
12216
|
+
super(props);
|
|
12215
12217
|
this.state = {
|
|
12216
12218
|
inputWidth: DEFAULT_INPUT_MIN_WIDTH
|
|
12217
12219
|
};
|
|
@@ -12221,7 +12223,7 @@ class TypeaheadInput extends Component {
|
|
|
12221
12223
|
autoFocus
|
|
12222
12224
|
} = this.props;
|
|
12223
12225
|
if (autoFocus) {
|
|
12224
|
-
this.inputRef
|
|
12226
|
+
this.inputRef?.focus();
|
|
12225
12227
|
}
|
|
12226
12228
|
}
|
|
12227
12229
|
componentDidUpdate(previousProps) {
|
|
@@ -12232,19 +12234,19 @@ class TypeaheadInput extends Component {
|
|
|
12232
12234
|
recalculateWidth = () => {
|
|
12233
12235
|
requestAnimationFrame(() => {
|
|
12234
12236
|
this.setState({
|
|
12235
|
-
inputWidth: Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.scrollWidth + 10)
|
|
12237
|
+
inputWidth: this.sizerRef ? Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.scrollWidth + 10) : DEFAULT_INPUT_MIN_WIDTH
|
|
12236
12238
|
});
|
|
12237
12239
|
});
|
|
12238
12240
|
};
|
|
12239
12241
|
renderInput = () => {
|
|
12240
12242
|
const {
|
|
12241
12243
|
typeaheadId,
|
|
12242
|
-
autoFocus,
|
|
12244
|
+
autoFocus = false,
|
|
12243
12245
|
multiple,
|
|
12244
12246
|
name,
|
|
12245
|
-
optionsShown,
|
|
12246
|
-
placeholder,
|
|
12247
|
-
selected,
|
|
12247
|
+
optionsShown = false,
|
|
12248
|
+
placeholder = '',
|
|
12249
|
+
selected = [],
|
|
12248
12250
|
value,
|
|
12249
12251
|
onChange,
|
|
12250
12252
|
onKeyDown,
|
|
@@ -12285,18 +12287,18 @@ class TypeaheadInput extends Component {
|
|
|
12285
12287
|
render() {
|
|
12286
12288
|
const {
|
|
12287
12289
|
multiple,
|
|
12288
|
-
selected,
|
|
12290
|
+
selected = [],
|
|
12289
12291
|
value,
|
|
12290
|
-
maxHeight,
|
|
12292
|
+
maxHeight = null,
|
|
12291
12293
|
renderChip
|
|
12292
12294
|
} = this.props;
|
|
12293
12295
|
return multiple ? /*#__PURE__*/jsxs("div", {
|
|
12294
12296
|
className: "form-control typeahead__input-container",
|
|
12295
|
-
style:
|
|
12296
|
-
maxHeight
|
|
12297
|
+
style: {
|
|
12298
|
+
maxHeight: maxHeight ?? undefined
|
|
12297
12299
|
},
|
|
12298
12300
|
onClick: () => {
|
|
12299
|
-
this.inputRef
|
|
12301
|
+
this.inputRef?.focus();
|
|
12300
12302
|
},
|
|
12301
12303
|
children: [/*#__PURE__*/jsxs("div", {
|
|
12302
12304
|
className: "typeahead__input-wrapper",
|
|
@@ -12313,30 +12315,6 @@ class TypeaheadInput extends Component {
|
|
|
12313
12315
|
}) : this.renderInput();
|
|
12314
12316
|
}
|
|
12315
12317
|
}
|
|
12316
|
-
TypeaheadInput.propTypes = {
|
|
12317
|
-
typeaheadId: PropTypes.string.isRequired,
|
|
12318
|
-
name: PropTypes.string.isRequired,
|
|
12319
|
-
autoFocus: PropTypes.bool,
|
|
12320
|
-
multiple: PropTypes.bool.isRequired,
|
|
12321
|
-
value: PropTypes.string.isRequired,
|
|
12322
|
-
selected: PropTypes.arrayOf(PropTypes.object),
|
|
12323
|
-
placeholder: PropTypes.string,
|
|
12324
|
-
optionsShown: PropTypes.bool,
|
|
12325
|
-
maxHeight: PropTypes.number,
|
|
12326
|
-
autoComplete: PropTypes.string.isRequired,
|
|
12327
|
-
onChange: PropTypes.func.isRequired,
|
|
12328
|
-
renderChip: PropTypes.func.isRequired,
|
|
12329
|
-
onKeyDown: PropTypes.func.isRequired,
|
|
12330
|
-
onFocus: PropTypes.func.isRequired,
|
|
12331
|
-
onPaste: PropTypes.func.isRequired
|
|
12332
|
-
};
|
|
12333
|
-
TypeaheadInput.defaultProps = {
|
|
12334
|
-
autoFocus: false,
|
|
12335
|
-
maxHeight: null,
|
|
12336
|
-
placeholder: '',
|
|
12337
|
-
optionsShown: false,
|
|
12338
|
-
selected: []
|
|
12339
|
-
};
|
|
12340
12318
|
|
|
12341
12319
|
function highlight(value, query) {
|
|
12342
12320
|
if (value && query) {
|
|
@@ -12357,9 +12335,9 @@ function highlight(value, query) {
|
|
|
12357
12335
|
const Option = props => {
|
|
12358
12336
|
const {
|
|
12359
12337
|
option,
|
|
12360
|
-
selected,
|
|
12361
|
-
onClick,
|
|
12362
|
-
query
|
|
12338
|
+
selected = false,
|
|
12339
|
+
onClick = () => {},
|
|
12340
|
+
query = ''
|
|
12363
12341
|
} = props;
|
|
12364
12342
|
const {
|
|
12365
12343
|
label,
|
|
@@ -12389,30 +12367,32 @@ const Option = props => {
|
|
|
12389
12367
|
})
|
|
12390
12368
|
});
|
|
12391
12369
|
};
|
|
12392
|
-
Option.propTypes = {
|
|
12393
|
-
option: PropTypes.shape({
|
|
12394
|
-
label: PropTypes.string.isRequired,
|
|
12395
|
-
note: PropTypes.string,
|
|
12396
|
-
secondary: PropTypes.string
|
|
12397
|
-
}).isRequired,
|
|
12398
|
-
query: PropTypes.string,
|
|
12399
|
-
selected: PropTypes.bool,
|
|
12400
|
-
onClick: PropTypes.func
|
|
12401
|
-
};
|
|
12402
|
-
Option.defaultProps = {
|
|
12403
|
-
selected: false,
|
|
12404
|
-
query: '',
|
|
12405
|
-
onClick: () => {}
|
|
12406
|
-
};
|
|
12407
|
-
var TypeaheadOption = Option;
|
|
12408
12370
|
|
|
12409
12371
|
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
12410
12372
|
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
12411
12373
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
12412
|
-
|
|
12413
12374
|
const DEFAULT_MIN_QUERY_LENGTH = 3;
|
|
12414
12375
|
const SEARCH_DELAY = 200;
|
|
12415
12376
|
class Typeahead extends Component {
|
|
12377
|
+
static defaultProps = {
|
|
12378
|
+
addon: null,
|
|
12379
|
+
allowNew: false,
|
|
12380
|
+
autoFillOnBlur: true,
|
|
12381
|
+
autoFocus: false,
|
|
12382
|
+
chipSeparators: [],
|
|
12383
|
+
clearable: true,
|
|
12384
|
+
footer: null,
|
|
12385
|
+
initialValue: [],
|
|
12386
|
+
inputAutoComplete: 'new-password',
|
|
12387
|
+
maxHeight: null,
|
|
12388
|
+
minQueryLength: DEFAULT_MIN_QUERY_LENGTH,
|
|
12389
|
+
multiple: false,
|
|
12390
|
+
searchDelay: SEARCH_DELAY,
|
|
12391
|
+
showSuggestions: true,
|
|
12392
|
+
showNewEntry: true,
|
|
12393
|
+
size: Size.MEDIUM,
|
|
12394
|
+
validateChip: () => true
|
|
12395
|
+
};
|
|
12416
12396
|
constructor(props) {
|
|
12417
12397
|
super(props);
|
|
12418
12398
|
const {
|
|
@@ -12429,6 +12409,7 @@ class Typeahead extends Component {
|
|
|
12429
12409
|
keyboardFocusedOptionIndex: null
|
|
12430
12410
|
};
|
|
12431
12411
|
}
|
|
12412
|
+
handleSearchDebounced;
|
|
12432
12413
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
12433
12414
|
if (nextProps.multiple !== this.props.multiple) {
|
|
12434
12415
|
this.setState(previousState => {
|
|
@@ -12442,7 +12423,8 @@ class Typeahead extends Component {
|
|
|
12442
12423
|
};
|
|
12443
12424
|
}
|
|
12444
12425
|
return {
|
|
12445
|
-
query: ''
|
|
12426
|
+
query: '',
|
|
12427
|
+
selected: previousState.selected
|
|
12446
12428
|
};
|
|
12447
12429
|
});
|
|
12448
12430
|
}
|
|
@@ -12451,13 +12433,8 @@ class Typeahead extends Component {
|
|
|
12451
12433
|
this.handleSearchDebounced.cancel();
|
|
12452
12434
|
}
|
|
12453
12435
|
handleOnFocus = () => {
|
|
12454
|
-
const {
|
|
12455
|
-
onFocus
|
|
12456
|
-
} = this.props;
|
|
12457
12436
|
this.showMenu();
|
|
12458
|
-
|
|
12459
|
-
this.props.onFocus();
|
|
12460
|
-
}
|
|
12437
|
+
this.props.onFocus?.();
|
|
12461
12438
|
};
|
|
12462
12439
|
onOptionSelected = (event, item) => {
|
|
12463
12440
|
event.preventDefault();
|
|
@@ -12540,7 +12517,7 @@ class Typeahead extends Component {
|
|
|
12540
12517
|
break;
|
|
12541
12518
|
case 'Enter':
|
|
12542
12519
|
event.preventDefault();
|
|
12543
|
-
if (options[keyboardFocusedOptionIndex]) {
|
|
12520
|
+
if (keyboardFocusedOptionIndex && options[keyboardFocusedOptionIndex]) {
|
|
12544
12521
|
this.selectItem(options[keyboardFocusedOptionIndex]);
|
|
12545
12522
|
} else if (allowNew && query.trim()) {
|
|
12546
12523
|
this.selectItem({
|
|
@@ -12592,13 +12569,6 @@ class Typeahead extends Component {
|
|
|
12592
12569
|
query
|
|
12593
12570
|
});
|
|
12594
12571
|
};
|
|
12595
|
-
stopPropagation = event => {
|
|
12596
|
-
event.stopPropagation();
|
|
12597
|
-
event.preventDefault();
|
|
12598
|
-
if (event.nativeEvent && event.nativeEvent.stopImmediatePropagation) {
|
|
12599
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
12600
|
-
}
|
|
12601
|
-
};
|
|
12602
12572
|
handleSearch = query => {
|
|
12603
12573
|
const {
|
|
12604
12574
|
onSearch
|
|
@@ -12683,7 +12653,7 @@ class Typeahead extends Component {
|
|
|
12683
12653
|
}
|
|
12684
12654
|
};
|
|
12685
12655
|
renderChip = (option, idx) => {
|
|
12686
|
-
const valid = this.props.validateChip(option);
|
|
12656
|
+
const valid = this.props.validateChip?.(option);
|
|
12687
12657
|
return /*#__PURE__*/jsx(Chip, {
|
|
12688
12658
|
label: option.label,
|
|
12689
12659
|
className: classNames('m-t-1', {
|
|
@@ -12718,7 +12688,7 @@ class Typeahead extends Component {
|
|
|
12718
12688
|
className: "dropdown-menu",
|
|
12719
12689
|
role: "menu",
|
|
12720
12690
|
"aria-labelledby": "dropdownMenu1",
|
|
12721
|
-
children: [optionsToRender.map((option, idx) => /*#__PURE__*/jsx(
|
|
12691
|
+
children: [optionsToRender.map((option, idx) => /*#__PURE__*/jsx(Option, {
|
|
12722
12692
|
query: query,
|
|
12723
12693
|
option: option,
|
|
12724
12694
|
selected: keyboardFocusedOptionIndex === idx,
|
|
@@ -12761,6 +12731,7 @@ class Typeahead extends Component {
|
|
|
12761
12731
|
const menu = this.renderMenu({
|
|
12762
12732
|
footer,
|
|
12763
12733
|
options,
|
|
12734
|
+
id,
|
|
12764
12735
|
keyboardFocusedOptionIndex,
|
|
12765
12736
|
query,
|
|
12766
12737
|
allowNew,
|
|
@@ -12779,7 +12750,7 @@ class Typeahead extends Component {
|
|
|
12779
12750
|
'typeahead--multiple': multiple,
|
|
12780
12751
|
open: dropdownOpen
|
|
12781
12752
|
}),
|
|
12782
|
-
onClick:
|
|
12753
|
+
onClick: stopPropagation$1,
|
|
12783
12754
|
children: /*#__PURE__*/jsxs("div", {
|
|
12784
12755
|
className: classNames('form-group', {
|
|
12785
12756
|
'has-error': hasError,
|
|
@@ -12800,6 +12771,7 @@ class Typeahead extends Component {
|
|
|
12800
12771
|
placeholder,
|
|
12801
12772
|
selected,
|
|
12802
12773
|
maxHeight,
|
|
12774
|
+
id: id,
|
|
12803
12775
|
name: name,
|
|
12804
12776
|
value: query,
|
|
12805
12777
|
typeaheadId: id,
|
|
@@ -12826,72 +12798,6 @@ class Typeahead extends Component {
|
|
|
12826
12798
|
});
|
|
12827
12799
|
}
|
|
12828
12800
|
}
|
|
12829
|
-
Typeahead.propTypes = {
|
|
12830
|
-
id: PropTypes.string.isRequired,
|
|
12831
|
-
name: PropTypes.string.isRequired,
|
|
12832
|
-
options: PropTypes.arrayOf(PropTypes.shape({
|
|
12833
|
-
label: PropTypes.string.isRequired,
|
|
12834
|
-
note: PropTypes.string,
|
|
12835
|
-
secondary: PropTypes.string,
|
|
12836
|
-
value: PropTypes.object
|
|
12837
|
-
})).isRequired,
|
|
12838
|
-
initialValue: PropTypes.arrayOf(PropTypes.shape({
|
|
12839
|
-
label: PropTypes.string.isRequired,
|
|
12840
|
-
note: PropTypes.string,
|
|
12841
|
-
secondary: PropTypes.string
|
|
12842
|
-
})),
|
|
12843
|
-
onChange: PropTypes.func.isRequired,
|
|
12844
|
-
allowNew: PropTypes.bool,
|
|
12845
|
-
autoFocus: PropTypes.bool,
|
|
12846
|
-
clearable: PropTypes.bool,
|
|
12847
|
-
multiple: PropTypes.bool,
|
|
12848
|
-
showSuggestions: PropTypes.bool,
|
|
12849
|
-
showNewEntry: PropTypes.bool,
|
|
12850
|
-
searchDelay: PropTypes.number,
|
|
12851
|
-
maxHeight: PropTypes.number,
|
|
12852
|
-
minQueryLength: PropTypes.number,
|
|
12853
|
-
addon: PropTypes.node,
|
|
12854
|
-
placeholder: PropTypes.string,
|
|
12855
|
-
alert: PropTypes.shape({
|
|
12856
|
-
message: PropTypes.string.isRequired,
|
|
12857
|
-
type: PropTypes.oneOf(['error', 'warning', 'neutral']).isRequired
|
|
12858
|
-
}),
|
|
12859
|
-
footer: PropTypes.node,
|
|
12860
|
-
validateChip: PropTypes.func,
|
|
12861
|
-
onSearch: PropTypes.func,
|
|
12862
|
-
onBlur: PropTypes.func,
|
|
12863
|
-
onInputChange: PropTypes.func,
|
|
12864
|
-
onFocus: PropTypes.func,
|
|
12865
|
-
chipSeparators: PropTypes.arrayOf(PropTypes.string),
|
|
12866
|
-
size: PropTypes.oneOf(['md', 'lg']),
|
|
12867
|
-
inputAutoComplete: PropTypes.string,
|
|
12868
|
-
autoFillOnBlur: PropTypes.bool
|
|
12869
|
-
};
|
|
12870
|
-
Typeahead.defaultProps = {
|
|
12871
|
-
allowNew: false,
|
|
12872
|
-
autoFocus: false,
|
|
12873
|
-
clearable: true,
|
|
12874
|
-
multiple: false,
|
|
12875
|
-
maxHeight: null,
|
|
12876
|
-
showSuggestions: true,
|
|
12877
|
-
showNewEntry: true,
|
|
12878
|
-
searchDelay: SEARCH_DELAY,
|
|
12879
|
-
minQueryLength: DEFAULT_MIN_QUERY_LENGTH,
|
|
12880
|
-
addon: null,
|
|
12881
|
-
placeholder: null,
|
|
12882
|
-
alert: null,
|
|
12883
|
-
footer: null,
|
|
12884
|
-
size: Size.MEDIUM,
|
|
12885
|
-
chipSeparators: [],
|
|
12886
|
-
initialValue: [],
|
|
12887
|
-
onSearch: null,
|
|
12888
|
-
onBlur: null,
|
|
12889
|
-
onInputChange: null,
|
|
12890
|
-
onFocus: null,
|
|
12891
|
-
validateChip: () => true,
|
|
12892
|
-
inputAutoComplete: 'new-password',
|
|
12893
|
-
autoFillOnBlur: true
|
|
12894
|
-
};
|
|
12895
12801
|
|
|
12896
12802
|
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
12897
12803
|
var UploadStep;
|