@homecode/ui 4.18.62 → 4.18.64
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/dist/esm/src/components/Icon/Icon.js +3 -1
- package/dist/esm/src/components/Input/Input.js +3 -3
- package/dist/esm/src/components/InputFile/InputFile.js +1 -1
- package/dist/esm/src/components/Select/Select.js +23 -18
- package/dist/esm/types/src/components/Icon/Icon.types.d.ts +2 -1
- package/dist/esm/types/src/components/Select/Select.d.ts +2 -2
- package/dist/esm/types/src/components/Select/Select.types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -6,12 +6,14 @@ import ICONS from './icons/index.js';
|
|
|
6
6
|
|
|
7
7
|
const icons = ICONS;
|
|
8
8
|
function Icon(props) {
|
|
9
|
-
const { className, type, size, ...rest } = props;
|
|
9
|
+
const { className, icon: CustomIcon, type, size, ...rest } = props;
|
|
10
10
|
const iconProps = {
|
|
11
11
|
className: cn(S.root, S[`size-${size}`], className),
|
|
12
12
|
role: 'img',
|
|
13
13
|
...rest,
|
|
14
14
|
};
|
|
15
|
+
if (CustomIcon)
|
|
16
|
+
return jsx(CustomIcon, { ...iconProps });
|
|
15
17
|
const localIcon = ICONS[type];
|
|
16
18
|
if (!localIcon) {
|
|
17
19
|
console.warn(`Icon: type="${type}" is unknown`);
|
|
@@ -14,12 +14,12 @@ import { generateUID } from '../../tools/uid.js';
|
|
|
14
14
|
import S from './Input.styl.js';
|
|
15
15
|
import '../ButtonGroup/ButtonGroup.styl.js';
|
|
16
16
|
import '../Calendar/Calendar.styl.js';
|
|
17
|
-
import '
|
|
18
|
-
import 'lodash.pick';
|
|
17
|
+
import '../../tools/dom.js';
|
|
19
18
|
import 'timen';
|
|
20
19
|
import '../Portal/Portal.js';
|
|
21
20
|
import '../Paranja/Paranja.styl.js';
|
|
22
|
-
import '
|
|
21
|
+
import 'compareq';
|
|
22
|
+
import 'lodash.pick';
|
|
23
23
|
import debounce from '../../tools/debounce.js';
|
|
24
24
|
import '../Popup/Popup.styl.js';
|
|
25
25
|
import '../../tools/queryParams.js';
|
|
@@ -21,9 +21,9 @@ import 'lodash.omit';
|
|
|
21
21
|
import '../RequiredStar/RequiredStar.styl.js';
|
|
22
22
|
import 'nanoid';
|
|
23
23
|
import '../Input/Input.styl.js';
|
|
24
|
+
import '../../tools/dom.js';
|
|
24
25
|
import '../Portal/Portal.js';
|
|
25
26
|
import '../Paranja/Paranja.styl.js';
|
|
26
|
-
import '../../tools/dom.js';
|
|
27
27
|
import '../Popup/Popup.styl.js';
|
|
28
28
|
import '../../tools/queryParams.js';
|
|
29
29
|
import '../Select/Select.styl.js';
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import * as Select_helpers from './Select.helpers.js';
|
|
3
|
+
import { mapById, buildOptionsTree, isMultiple, renderLabel } from './Select.helpers.js';
|
|
2
4
|
import { Component, createRef } from 'react';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import pick from 'lodash.pick';
|
|
6
|
-
import omit from 'lodash.omit';
|
|
7
|
-
import { createStore } from 'justorm/react';
|
|
8
|
-
import Time from 'timen';
|
|
9
|
-
import { Icon } from '../Icon/Icon.js';
|
|
5
|
+
import { INTERACTION_MODE, getInteractionMode } from '../../tools/dom.js';
|
|
6
|
+
import { AssistiveText } from '../AssistiveText/AssistiveText.js';
|
|
10
7
|
import { Button } from '../Button/Button.js';
|
|
8
|
+
import { Icon } from '../Icon/Icon.js';
|
|
11
9
|
import { Input } from '../Input/Input.js';
|
|
12
10
|
import { Label } from '../Label/Label.js';
|
|
13
11
|
import { Popup } from '../Popup/Popup.js';
|
|
14
|
-
import { Scroll } from '../Scroll/Scroll.js';
|
|
15
12
|
import { RequiredStar } from '../RequiredStar/RequiredStar.js';
|
|
16
|
-
import { AssistiveText } from '../AssistiveText/AssistiveText.js';
|
|
17
|
-
import { INTERACTION_MODE, getInteractionMode } from '../../tools/dom.js';
|
|
18
|
-
import throttle from '../../tools/throttle.js';
|
|
19
|
-
import * as Select_helpers from './Select.helpers.js';
|
|
20
|
-
import { mapById, buildOptionsTree, isMultiple, renderLabel } from './Select.helpers.js';
|
|
21
13
|
import S from './Select.styl.js';
|
|
14
|
+
import { Scroll } from '../Scroll/Scroll.js';
|
|
15
|
+
import Time from 'timen';
|
|
16
|
+
import cn from 'classnames';
|
|
17
|
+
import compare from 'compareq';
|
|
18
|
+
import { createStore } from 'justorm/react';
|
|
19
|
+
import omit from 'lodash.omit';
|
|
20
|
+
import pick from 'lodash.pick';
|
|
21
|
+
import throttle from '../../tools/throttle.js';
|
|
22
22
|
|
|
23
23
|
const SelectHelpers = Select_helpers;
|
|
24
24
|
class Select extends Component {
|
|
@@ -61,10 +61,13 @@ class Select extends Component {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
componentDidUpdate(prevProps) {
|
|
64
|
-
const { options, value } = this.props;
|
|
64
|
+
const { options, value, searchValue } = this.props;
|
|
65
65
|
if (!compare(value, prevProps.value)) {
|
|
66
66
|
this.store.selected = this.getDefaultSelected();
|
|
67
67
|
}
|
|
68
|
+
if (!compare(searchValue, prevProps.searchValue)) {
|
|
69
|
+
this.setSearchVal(searchValue);
|
|
70
|
+
}
|
|
68
71
|
if (!compare(options, prevProps.options)) {
|
|
69
72
|
this.onOptionsChange();
|
|
70
73
|
}
|
|
@@ -193,7 +196,6 @@ class Select extends Component {
|
|
|
193
196
|
unDocumentClick = () => document.removeEventListener('click', this.onDocumentClick);
|
|
194
197
|
onFocus = e => {
|
|
195
198
|
const { onFocus } = this.props;
|
|
196
|
-
this.setSearchVal('');
|
|
197
199
|
this.store.isFocused = true;
|
|
198
200
|
onFocus?.(e);
|
|
199
201
|
};
|
|
@@ -374,9 +376,10 @@ class Select extends Component {
|
|
|
374
376
|
return null;
|
|
375
377
|
}
|
|
376
378
|
getInputVal() {
|
|
377
|
-
const { isFocused,
|
|
378
|
-
|
|
379
|
-
|
|
379
|
+
const { isFocused, selected } = this.store;
|
|
380
|
+
const searchValue = this.props.searchValue ?? this.store.searchVal;
|
|
381
|
+
if (isFocused)
|
|
382
|
+
return searchValue ?? '';
|
|
380
383
|
const selectedPlain = Object.entries(selected).reduce((acc, entry) => {
|
|
381
384
|
const parentId = this.coerceType(entry[0]);
|
|
382
385
|
const val = entry[1];
|
|
@@ -390,6 +393,8 @@ class Select extends Component {
|
|
|
390
393
|
}
|
|
391
394
|
return acc;
|
|
392
395
|
}, []);
|
|
396
|
+
if (selectedPlain.length === 0)
|
|
397
|
+
return searchValue;
|
|
393
398
|
return selectedPlain.map(id => this.getItem(id)?.label).join(', ');
|
|
394
399
|
}
|
|
395
400
|
getLabel(id) {
|
|
@@ -3,6 +3,7 @@ import CUSTOM_ICONS from './icons';
|
|
|
3
3
|
export type IconSize = 'xs' | Size;
|
|
4
4
|
export type IconType = keyof typeof CUSTOM_ICONS;
|
|
5
5
|
export type Props = ComponentType & {
|
|
6
|
-
|
|
6
|
+
icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
7
|
+
type?: IconType;
|
|
7
8
|
size: IconSize;
|
|
8
9
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import * as H from './Select.helpers';
|
|
2
|
+
import * as T from './Select.types';
|
|
1
3
|
import { Component, ReactNode } from 'react';
|
|
2
4
|
import { Input } from 'uilib/components/Input/Input';
|
|
3
|
-
import * as T from './Select.types';
|
|
4
|
-
import * as H from './Select.helpers';
|
|
5
5
|
export declare const SelectHelpers: typeof H;
|
|
6
6
|
export declare class Select extends Component<T.Props, T.State> {
|
|
7
7
|
store: any;
|
|
@@ -44,6 +44,7 @@ export type Props = FormControl<Value> & InheritedInputProps & {
|
|
|
44
44
|
clearButton?: boolean;
|
|
45
45
|
selectAllButton?: boolean;
|
|
46
46
|
value?: Value;
|
|
47
|
+
searchValue?: string;
|
|
47
48
|
expandSelected?: boolean;
|
|
48
49
|
onChange: (value: Value) => void;
|
|
49
50
|
onSeachChange?: (value: string) => void;
|