webpack cannot handel <>

This commit is contained in:
andrelandgraf 2020-04-28 09:46:10 +02:00
parent 299513ec7a
commit 897d8a8e42
2 changed files with 70 additions and 70 deletions

View File

@ -6,29 +6,29 @@ import React, {
import './DataListInput.css'; import './DataListInput.css';
/** /**
* default function for matching the current input value (needle) * default function for matching the current input value (needle)
* and the values of the items array * and the values of the items array
* @param currentInput * @param currentInput
* @param item * @param item
* @returns {boolean} * @returns {boolean}
*/ */
const labelMatch = (currentInput, item) => item const labelMatch = (currentInput, item) => item
.label.substr(0, currentInput.length).toLowerCase() === currentInput.toLowerCase(); .label.substr(0, currentInput.length).toLowerCase() === currentInput.toLowerCase();
/** /**
* function for getting the index of the currentValue inside a value of the values array * function for getting the index of the currentValue inside a value of the values array
* @param currentInput * @param currentInput
* @param item * @param item
* @returns {number} * @returns {number}
*/ */
const indexOfMatch = (currentInput, item) => item const indexOfMatch = (currentInput, item) => item
.label.toLowerCase().indexOf(currentInput.toLowerCase()); .label.toLowerCase().indexOf(currentInput.toLowerCase());
/** /**
* index of item in items * index of item in items
* @param {*} item * @param {*} item
* @param {*} items * @param {*} items
*/ */
const indexOfItem = (item, items) => items const indexOfItem = (item, items) => items
.indexOf(items.find(i => i.key === item.key)); .indexOf(items.find(i => i.key === item.key));
@ -112,11 +112,11 @@ import React, {
}, [currentInput, visible, isMatchingDebounced, initialValue]); }, [currentInput, visible, isMatchingDebounced, initialValue]);
/** /**
* runs the matching process of the current input * runs the matching process of the current input
* and handles debouncing the different callback calls to reduce lag time * and handles debouncing the different callback calls to reduce lag time
* for bigger datasets or heavier matching algorithms * for bigger datasets or heavier matching algorithms
* @param nextInput * @param nextInput
*/ */
const debouncedMatchingUpdateStep = useCallback((nextInput) => { const debouncedMatchingUpdateStep = useCallback((nextInput) => {
// cleanup waiting update step // cleanup waiting update step
if (inputHappenedTimeout.current) { if (inputHappenedTimeout.current) {
@ -168,9 +168,9 @@ import React, {
onDropdownOpen, onDropdownClose, visible]); onDropdownOpen, onDropdownClose, visible]);
/** /**
* gets called when someone starts to write in the input field * gets called when someone starts to write in the input field
* @param value * @param value
*/ */
const onHandleInput = useCallback((event) => { const onHandleInput = useCallback((event) => {
const { value } = event.target; const { value } = event.target;
debouncedMatchingUpdateStep(value); debouncedMatchingUpdateStep(value);
@ -192,10 +192,10 @@ import React, {
}, [visible, currentInput, requiredInputLength, initialValue, debouncedMatchingUpdateStep]); }, [visible, currentInput, requiredInputLength, initialValue, debouncedMatchingUpdateStep]);
/** /**
* handleSelect is called onClickItem and onEnter upon an option of the drop down menu * handleSelect is called onClickItem and onEnter upon an option of the drop down menu
* does nothing if the key has not changed since the last onSelect event * does nothing if the key has not changed since the last onSelect event
* @param selectedItem * @param selectedItem
*/ */
const onHandleSelect = useCallback((selectedItem) => { const onHandleSelect = useCallback((selectedItem) => {
// block select call until last matching went through // block select call until last matching went through
if (isMatchingDebounced) return; if (isMatchingDebounced) return;
@ -219,9 +219,9 @@ import React, {
lastValidItem, isMatchingDebounced, onSelect]); lastValidItem, isMatchingDebounced, onSelect]);
/** /**
* handle key events * handle key events
* @param event * @param event
*/ */
const onHandleKeydown = useCallback((event) => { const onHandleKeydown = useCallback((event) => {
// only do something if drop-down div is visible // only do something if drop-down div is visible
if (!visible) return; if (!visible) return;
@ -252,20 +252,20 @@ import React, {
const index = indexOfMatch(currentInput, item); const index = indexOfMatch(currentInput, item);
const inputLength = currentInput.length; const inputLength = currentInput.length;
return ( return (
<> <React.Fragment>
{ index >= 0 && inputLength { index >= 0 && inputLength
// renders label with matching search string marked // renders label with matching search string marked
? ( ? (
<> <React.Fragment>
{item.label.substr(0, index) } {item.label.substr(0, index) }
<strong> <strong>
{ item.label.substr(index, inputLength) } { item.label.substr(index, inputLength) }
</strong> </strong>
{ item.label.substr(index + inputLength, item.label.length) } { item.label.substr(index + inputLength, item.label.length) }
</> </React.Fragment>
) )
: item.label } : item.label }
</> </React.Fragment>
); );
}, [currentInput]); }, [currentInput]);

View File

@ -6,29 +6,29 @@ import PropTypes from 'prop-types';
import './DataListInput.css'; import './DataListInput.css';
/** /**
* default function for matching the current input value (needle) * default function for matching the current input value (needle)
* and the values of the items array * and the values of the items array
* @param currentInput * @param currentInput
* @param item * @param item
* @returns {boolean} * @returns {boolean}
*/ */
const labelMatch = (currentInput, item) => item const labelMatch = (currentInput, item) => item
.label.substr(0, currentInput.length).toLowerCase() === currentInput.toLowerCase(); .label.substr(0, currentInput.length).toLowerCase() === currentInput.toLowerCase();
/** /**
* function for getting the index of the currentValue inside a value of the values array * function for getting the index of the currentValue inside a value of the values array
* @param currentInput * @param currentInput
* @param item * @param item
* @returns {number} * @returns {number}
*/ */
const indexOfMatch = (currentInput, item) => item const indexOfMatch = (currentInput, item) => item
.label.toLowerCase().indexOf(currentInput.toLowerCase()); .label.toLowerCase().indexOf(currentInput.toLowerCase());
/** /**
* index of item in items * index of item in items
* @param {*} item * @param {*} item
* @param {*} items * @param {*} items
*/ */
const indexOfItem = (item, items) => items const indexOfItem = (item, items) => items
.indexOf(items.find(i => i.key === item.key)); .indexOf(items.find(i => i.key === item.key));
@ -112,11 +112,11 @@ const DataListInput = ({
}, [currentInput, visible, isMatchingDebounced, initialValue]); }, [currentInput, visible, isMatchingDebounced, initialValue]);
/** /**
* runs the matching process of the current input * runs the matching process of the current input
* and handles debouncing the different callback calls to reduce lag time * and handles debouncing the different callback calls to reduce lag time
* for bigger datasets or heavier matching algorithms * for bigger datasets or heavier matching algorithms
* @param nextInput * @param nextInput
*/ */
const debouncedMatchingUpdateStep = useCallback((nextInput) => { const debouncedMatchingUpdateStep = useCallback((nextInput) => {
// cleanup waiting update step // cleanup waiting update step
if (inputHappenedTimeout.current) { if (inputHappenedTimeout.current) {
@ -168,9 +168,9 @@ const DataListInput = ({
onDropdownOpen, onDropdownClose, visible]); onDropdownOpen, onDropdownClose, visible]);
/** /**
* gets called when someone starts to write in the input field * gets called when someone starts to write in the input field
* @param value * @param value
*/ */
const onHandleInput = useCallback((event) => { const onHandleInput = useCallback((event) => {
const { value } = event.target; const { value } = event.target;
debouncedMatchingUpdateStep(value); debouncedMatchingUpdateStep(value);
@ -192,10 +192,10 @@ const DataListInput = ({
}, [visible, currentInput, requiredInputLength, initialValue, debouncedMatchingUpdateStep]); }, [visible, currentInput, requiredInputLength, initialValue, debouncedMatchingUpdateStep]);
/** /**
* handleSelect is called onClickItem and onEnter upon an option of the drop down menu * handleSelect is called onClickItem and onEnter upon an option of the drop down menu
* does nothing if the key has not changed since the last onSelect event * does nothing if the key has not changed since the last onSelect event
* @param selectedItem * @param selectedItem
*/ */
const onHandleSelect = useCallback((selectedItem) => { const onHandleSelect = useCallback((selectedItem) => {
// block select call until last matching went through // block select call until last matching went through
if (isMatchingDebounced) return; if (isMatchingDebounced) return;
@ -219,9 +219,9 @@ const DataListInput = ({
lastValidItem, isMatchingDebounced, onSelect]); lastValidItem, isMatchingDebounced, onSelect]);
/** /**
* handle key events * handle key events
* @param event * @param event
*/ */
const onHandleKeydown = useCallback((event) => { const onHandleKeydown = useCallback((event) => {
// only do something if drop-down div is visible // only do something if drop-down div is visible
if (!visible) return; if (!visible) return;
@ -252,20 +252,20 @@ const DataListInput = ({
const index = indexOfMatch(currentInput, item); const index = indexOfMatch(currentInput, item);
const inputLength = currentInput.length; const inputLength = currentInput.length;
return ( return (
<> <React.Fragment>
{ index >= 0 && inputLength { index >= 0 && inputLength
// renders label with matching search string marked // renders label with matching search string marked
? ( ? (
<> <React.Fragment>
{item.label.substr(0, index) } {item.label.substr(0, index) }
<strong> <strong>
{ item.label.substr(index, inputLength) } { item.label.substr(index, inputLength) }
</strong> </strong>
{ item.label.substr(index + inputLength, item.label.length) } { item.label.substr(index + inputLength, item.label.length) }
</> </React.Fragment>
) )
: item.label } : item.label }
</> </React.Fragment>
); );
}, [currentInput]); }, [currentInput]);