@bbl-digital/snorre 3.0.7 → 3.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +23 -35
- package/esm/core/Autocomplete/hooks/useAutocomplete.js +2 -13
- package/esm/core/Autocomplete/index.js +3 -4
- package/esm/core/Autocomplete/styles.js +18 -18
- package/lib/core/Autocomplete/hooks/useAutocomplete.d.ts +0 -1
- package/lib/core/Autocomplete/hooks/useAutocomplete.d.ts.map +1 -1
- package/lib/core/Autocomplete/hooks/useAutocomplete.js +2 -13
- package/lib/core/Autocomplete/index.d.ts.map +1 -1
- package/lib/core/Autocomplete/index.interfaces.d.ts +4 -3
- package/lib/core/Autocomplete/index.interfaces.d.ts.map +1 -1
- package/lib/core/Autocomplete/index.js +3 -4
- package/lib/core/Autocomplete/styles.d.ts.map +1 -1
- package/lib/core/Autocomplete/styles.js +18 -18
- package/package.json +1 -1
@@ -11,7 +11,6 @@ declare const useAutocomplete: (props: IProps) => {
|
|
11
11
|
handleCustomOnKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
12
12
|
handleOnInputClick: () => void;
|
13
13
|
onFuzzyBlur: (e: React.FocusEvent<HTMLInputElement, Element>) => void;
|
14
|
-
onFuzzyFocus: () => void;
|
15
14
|
value: string;
|
16
15
|
highlightedIndex: number | null;
|
17
16
|
showValues: boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAutocomplete.d.ts","sourceRoot":"","sources":["../../../../src/packages/core/Autocomplete/hooks/useAutocomplete.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAE1D,QAAA,MAAM,eAAe,UAAW,MAAM;;;;;;uBAuBV,MAAM,WAAW,CAAC,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"useAutocomplete.d.ts","sourceRoot":"","sources":["../../../../src/packages/core/Autocomplete/hooks/useAutocomplete.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAE1D,QAAA,MAAM,eAAe,UAAW,MAAM;;;;;;uBAuBV,MAAM,WAAW,CAAC,gBAAgB,CAAC;yBA6IjC,mBAAmB,CAAC,gBAAgB,CAAC;+BAZ/B,mBAAmB,CAAC,gBAAgB,CAAC;;qBAhH/C,gBAAgB,CAAC,gBAAgB,EAAE,OAAO,CAAC;;;;;CAyMpE,CAAA;AAED,eAAe,eAAe,CAAA"}
|
@@ -12,8 +12,8 @@ const useAutocomplete = props => {
|
|
12
12
|
const [inputValues, setInputValues] = useState(props.values);
|
13
13
|
|
14
14
|
const handleValueClick = value => {
|
15
|
-
props.onSelectItem?.(value);
|
16
15
|
setShowValues(false);
|
16
|
+
props.onSelectItem?.(value);
|
17
17
|
};
|
18
18
|
|
19
19
|
const clearSelectedItem = () => handleValueClick({
|
@@ -38,8 +38,6 @@ const useAutocomplete = props => {
|
|
38
38
|
const onFuzzyBlur = e => {
|
39
39
|
// If the value of the input is changed, and does not match the value of the values array,
|
40
40
|
// we should revert back the input value to the original value
|
41
|
-
//What
|
42
|
-
// if (!e.target.value.length) clearSelectedItem()
|
43
41
|
if (e.target.value === props.value) return; // If target value is the same as a value from the values array, we should set the value for the user
|
44
42
|
|
45
43
|
if (inputValues?.length) {
|
@@ -50,18 +48,10 @@ const useAutocomplete = props => {
|
|
50
48
|
setValueChanged(val);
|
51
49
|
handleValueClick(valueInInputValues);
|
52
50
|
return;
|
53
|
-
}
|
54
|
-
|
55
|
-
|
56
|
-
setValueChanged(props.value ?? '');
|
51
|
+
}
|
57
52
|
}
|
58
53
|
};
|
59
54
|
|
60
|
-
const onFuzzyFocus = () => {
|
61
|
-
setValueChanged('');
|
62
|
-
if (props.values?.length) setShowValues(true);
|
63
|
-
};
|
64
|
-
|
65
55
|
const renderedValues = useMemo(() => {
|
66
56
|
if (!props.values?.length) return [];
|
67
57
|
|
@@ -231,7 +221,6 @@ const useAutocomplete = props => {
|
|
231
221
|
handleCustomOnKeyDown,
|
232
222
|
handleOnInputClick,
|
233
223
|
onFuzzyBlur,
|
234
|
-
onFuzzyFocus,
|
235
224
|
value,
|
236
225
|
highlightedIndex,
|
237
226
|
showValues,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Autocomplete/index.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAa,YAAY,EAAE,MAAM,OAAO,CAAA;AAQtD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAG3C,oBAAY,GAAG,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAA;AAEhD,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Autocomplete/index.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAa,YAAY,EAAE,MAAM,OAAO,CAAA;AAQtD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAG3C,oBAAY,GAAG,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAA;AAEhD,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAoLjC,CAAA;AAEF,eAAe,YAAY,CAAA"}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { SerializedStyles } from '@emotion/react';
|
2
2
|
import { ReactNode } from 'react';
|
3
3
|
export interface IValuesProps {
|
4
|
-
key
|
5
|
-
label
|
4
|
+
/** The default key name is key */
|
5
|
+
/** The default display name is label */
|
6
|
+
/** When setting any other than label/key as default, use labelFromValues and keyFromValues for this */
|
6
7
|
[x: string]: string;
|
7
8
|
}
|
8
9
|
export interface IProps {
|
@@ -53,7 +54,7 @@ export interface IProps {
|
|
53
54
|
/** Sets a spinner on the input */
|
54
55
|
loading?: boolean;
|
55
56
|
/** Sets actions on the end of the input field */
|
56
|
-
actions
|
57
|
+
actions?: ReactNode;
|
57
58
|
/** Renders options shown under input */
|
58
59
|
renderOptions?: ReactNode[] | ReactNode;
|
59
60
|
/** Places values dynamically to the input field, defaults to being placed under the input field */
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.interfaces.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Autocomplete/index.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,MAAM,WAAW,YAAY;IAC3B,
|
1
|
+
{"version":3,"file":"index.interfaces.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Autocomplete/index.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAGlC,wCAAwC;IAGxC,uGAAuG;IACvG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,MAAM;IACrB,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kEAAkE;IAClE,cAAc,CAAC,EAAE,SAAS,CAAA;IAC1B,gBAAgB;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gBAAgB;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gCAAgC;IAChC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IACxD,iCAAiC;IACjC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAA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AA;IAC/B,kCAAkC;IAClC,sBAAsB,CAAC,EAAE,SAAS,CAAA;IAClC,sDAAsD;IACtD,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC,yBAAyB;IACzB,MAAM,CAAC,EAAE,YAAY,EAAE,CAAA;IACvB,wDAAwD;IACxD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,oCAAoC;IACpC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,sCAAsC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,uBAAuB;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,uBAAuB;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB"}
|
@@ -37,8 +37,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(({
|
|
37
37
|
handleOnKeyDown,
|
38
38
|
handleValueClick,
|
39
39
|
onInputChange,
|
40
|
-
onFuzzyBlur
|
41
|
-
onFuzzyFocus
|
40
|
+
onFuzzyBlur
|
42
41
|
} = useAutocomplete(props);
|
43
42
|
useEffect(() => {
|
44
43
|
const handleClickOutside = e => {
|
@@ -60,8 +59,8 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(({
|
|
60
59
|
return _jsxs(_Fragment, {
|
61
60
|
children: [_jsxs("label", {
|
62
61
|
ref: inputWrapperRef,
|
63
|
-
css: theme => [styles.default(theme), (props.invalid || props.invalidMessage) && styles.invalid(theme), props.validation && styles.validation, props.onLabelClick && styles.clickableLabel, height && styles.height(height), css && css],
|
64
62
|
onClick: props.onLabelClick ? e => e.preventDefault() : undefined,
|
63
|
+
css: theme => [styles.default(theme), (props.invalid || props.invalidMessage) && styles.invalid(theme), props.validation && styles.validation, props.onLabelClick && styles.clickableLabel, height && styles.height(height), css && css],
|
65
64
|
children: [_jsxs("span", {
|
66
65
|
css: styles.label,
|
67
66
|
children: [props.label && (props.onLabelClick ? _jsx(Link, {
|
@@ -83,7 +82,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(({
|
|
83
82
|
disabled: props.disabled,
|
84
83
|
autoFocus: props.focus,
|
85
84
|
onBlur: props.fuzzy ? onFuzzyBlur : props.onBlur,
|
86
|
-
onFocus: props.
|
85
|
+
onFocus: props.onFocus,
|
87
86
|
onChange: onInputChange,
|
88
87
|
onKeyDown: props.onKeyDown ? handleCustomOnKeyDown : handleOnKeyDown,
|
89
88
|
onClick: handleOnInputClick,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Autocomplete/styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAIjD,QAAA,MAAM,MAAM;qBACO,SAAS;;;0BA2DJ,SAAS;;;;kBAuCjB,SAAS;
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Autocomplete/styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAIjD,QAAA,MAAM,MAAM;qBACO,SAAS;;;0BA2DJ,SAAS;;;;kBAuCjB,SAAS;6BA2BE,SAAS;yBAGb,MAAM;iCAOE,MAAM;kCAGL,MAAM;qBAGnB,SAAS;4BAYF,SAAS;qBA4BhB,MAAM;sBAKL,SAAS;CAM5B,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,SAAS,8CAM5C,CAAA;AAED,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;UAcjB,CAAA;AAED,eAAe,MAAM,CAAA;AAErB,OAAO,EAAE,MAAM,EAAE,CAAA"}
|