@linzjs/lui 21.49.0 → 21.50.0
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/CHANGELOG.md +7 -0
- package/dist/components/LuiSearchBox/LuiSearchBox.d.ts +1 -0
- package/dist/components/LuiSearchInput/LuiPassiveSearchInput.d.ts +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +64 -6
- package/dist/index.js.map +1 -1
- package/dist/lui.css +22 -0
- package/dist/lui.css.map +1 -1
- package/dist/lui.esm.js +64 -7
- package/dist/lui.esm.js.map +1 -1
- package/dist/scss/Components/LuiSearchInput/LuiSearchInput.scss +20 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [21.50.0](https://github.com/linz/lui/compare/v21.49.0...v21.50.0) (2024-10-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* empty commit to release customized search input ([#1165](https://github.com/linz/lui/issues/1165)) ([d54a410](https://github.com/linz/lui/commit/d54a41024fabb92d2f805c78a507c160f601b665))
|
|
7
|
+
|
|
1
8
|
# [21.49.0](https://github.com/linz/lui/compare/v21.48.1...v21.49.0) (2024-10-16)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'react-loading-skeleton/dist/skeleton.css';
|
|
3
|
+
export interface InputValidationResult {
|
|
4
|
+
stopProgress: boolean;
|
|
5
|
+
userMessage?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface IPassiveSearchInputProps {
|
|
8
|
+
minCharactersForSearch: number;
|
|
9
|
+
placeholderText: string;
|
|
10
|
+
onSearch: (searchString: string) => void;
|
|
11
|
+
disclaimer?: string;
|
|
12
|
+
initialValue?: string;
|
|
13
|
+
inputTransformer?: (input: string) => string;
|
|
14
|
+
focusUpdate?: boolean;
|
|
15
|
+
onClearCallback?: () => void;
|
|
16
|
+
onClickInput?: () => void;
|
|
17
|
+
validateInput?: (input: string) => InputValidationResult | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare const LuiPassiveSearchInput: (props: React.PropsWithChildren<IPassiveSearchInputProps>) => JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export { LuiModal, LuiAlertModal, LuiAlertModalButtons, } from './components/Lui
|
|
|
40
40
|
export { LuiModalV2, type LuiModalV2Props, } from './components/LuiModal/LuiModalV2';
|
|
41
41
|
export { LuiAlertModalV2, type LuiAlertModalLevel, type LuiAlertModalV2Props, } from './components/LuiModal/LuiAlertModalV2';
|
|
42
42
|
export { type ISearchInputProps, LuiSearchInput, } from './components/LuiSearchInput/LuiSearchInput';
|
|
43
|
+
export { type IPassiveSearchInputProps, type InputValidationResult, LuiPassiveSearchInput, } from './components/LuiSearchInput/LuiPassiveSearchInput';
|
|
43
44
|
export { type ISearchGroupedResult, type ISearchResult, } from './components/LuiSearchInput/ResultsDisplay';
|
|
44
45
|
export { type ISearchMenuOption, type ILuiSearchBoxProps, LuiSearchBox, } from './components/LuiSearchBox/LuiSearchBox';
|
|
45
46
|
export { type ILuiSplitButtonProps, type ILuiSplitButtonMenuItemProps, LuiSplitButtonPosition, LuiSplitButtonMenuItem, LuiSplitButton, } from './components/LuiSplitButton/LuiSplitButton';
|
package/dist/index.js
CHANGED
|
@@ -42685,6 +42685,64 @@ var LuiSearchInput = function (props) {
|
|
|
42685
42685
|
React__default["default"].createElement("div", { "data-testid": "disclaimer", className: "LuiSearchInput-disclaimer" }, props.disclaimer)))));
|
|
42686
42686
|
};
|
|
42687
42687
|
|
|
42688
|
+
var LuiPassiveSearchInput = function (props) {
|
|
42689
|
+
var _a = React.useState(props.initialValue ? props.initialValue : ''), typedValue = _a[0], setTypedValue = _a[1];
|
|
42690
|
+
var _b = React.useState(), inputValidationResult = _b[0], setInputValidationResult = _b[1];
|
|
42691
|
+
var inputRef = React.useRef(null);
|
|
42692
|
+
// set focus to input box
|
|
42693
|
+
React.useEffect(function () {
|
|
42694
|
+
var _a;
|
|
42695
|
+
if (props.focusUpdate !== undefined)
|
|
42696
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
42697
|
+
}, [props.focusUpdate]);
|
|
42698
|
+
// validate input
|
|
42699
|
+
React.useEffect(function () {
|
|
42700
|
+
setInputValidationResult((props.validateInput && props.validateInput(typedValue)) || undefined);
|
|
42701
|
+
}, [typedValue]);
|
|
42702
|
+
function setInputValue(value) {
|
|
42703
|
+
setTypedValue(props.inputTransformer ? props.inputTransformer(value) : value);
|
|
42704
|
+
}
|
|
42705
|
+
function handleKeyDown(event) {
|
|
42706
|
+
switch (event.key) {
|
|
42707
|
+
case 'Enter':
|
|
42708
|
+
if (inputValidationResult &&
|
|
42709
|
+
inputValidationResult.stopProgress === true)
|
|
42710
|
+
return;
|
|
42711
|
+
props.onSearch(typedValue);
|
|
42712
|
+
}
|
|
42713
|
+
}
|
|
42714
|
+
var cancelIcon = typedValue !== '' ? (React__default["default"].createElement(LuiIcon, { alt: "clear", name: "ic_cancel_clear", size: "md", color: '#6b6966', spanProps: {
|
|
42715
|
+
onClick: function () {
|
|
42716
|
+
var _a;
|
|
42717
|
+
setInputValue('');
|
|
42718
|
+
(_a = props.onClearCallback) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
42719
|
+
}
|
|
42720
|
+
} })) : null;
|
|
42721
|
+
var searchIcon = typedValue === '' || (inputValidationResult === null || inputValidationResult === void 0 ? void 0 : inputValidationResult.stopProgress) === true ? (React__default["default"].createElement("div", { className: "LuiSearchInput-search-button-disabled" },
|
|
42722
|
+
React__default["default"].createElement(LuiIcon, { name: "ic_search", size: "md", alt: "search", color: '#989189' }))) : (React__default["default"].createElement("div", { onClick: function () { return props.onSearch(typedValue); }, className: "LuiSearchInput-search-button" },
|
|
42723
|
+
React__default["default"].createElement(LuiIcon, { name: "ic_search", size: "md", alt: "search", color: '#FFFFFF' })));
|
|
42724
|
+
return (React__default["default"].createElement("div", { className: "LuiSearchInput", onClick: props.onClickInput },
|
|
42725
|
+
React__default["default"].createElement("span", { className: "LuiSearchInput-inputWrapper" },
|
|
42726
|
+
React__default["default"].createElement("input", { type: "text", className: clsx('LuiSearchInput-input'), ref: inputRef, value: typedValue, placeholder: props.placeholderText, "aria-label": "Search", onChange: function (e) { return setInputValue(e.target.value); }, onKeyDown: handleKeyDown, onFocus: function (e) {
|
|
42727
|
+
e.target.select();
|
|
42728
|
+
}, style: { pointerEvents: 'auto' } }),
|
|
42729
|
+
React__default["default"].createElement("div", { style: {
|
|
42730
|
+
display: 'flex',
|
|
42731
|
+
flexDirection: 'row',
|
|
42732
|
+
paddingRight: '8px',
|
|
42733
|
+
gap: '14px',
|
|
42734
|
+
alignItems: 'center'
|
|
42735
|
+
} },
|
|
42736
|
+
cancelIcon,
|
|
42737
|
+
searchIcon)),
|
|
42738
|
+
inputValidationResult && inputValidationResult.userMessage && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
42739
|
+
React__default["default"].createElement("hr", { className: "LuiSearchInput-resultSeparator" }),
|
|
42740
|
+
React__default["default"].createElement("div", { "data-testid": "no-result-msg", className: "LuiSearchInput-disclaimer" }, inputValidationResult.userMessage))),
|
|
42741
|
+
props.disclaimer && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
42742
|
+
React__default["default"].createElement("hr", { className: "LuiSearchInput-resultSeparator" }),
|
|
42743
|
+
React__default["default"].createElement("div", { "data-testid": "disclaimer", className: "LuiSearchInput-disclaimer" }, props.disclaimer)))));
|
|
42744
|
+
};
|
|
42745
|
+
|
|
42688
42746
|
var resultStyle = { verticalAlign: 'middle' };
|
|
42689
42747
|
/**
|
|
42690
42748
|
* LuiSearchBox is a search input with select menu.
|
|
@@ -42758,12 +42816,11 @@ var LuiSearchBox = function (_a) {
|
|
|
42758
42816
|
React__default["default"].createElement("div", { className: clsx({
|
|
42759
42817
|
'LuiSearchBox-right': true,
|
|
42760
42818
|
'LuiSearchBox-right-stacked': showStacked
|
|
42761
|
-
}) },
|
|
42762
|
-
|
|
42763
|
-
|
|
42764
|
-
:
|
|
42765
|
-
|
|
42766
|
-
}, disclaimer: selectedMenuOption.disclaimer, focusUpdate: autoFocus && isFocus ? focusUpdate : undefined, externalSearch: externalSearch, initialValue: !!externalSearch ? searchString : undefined, onClickInput: onClickInput, onClearCallback: onClearInput }))));
|
|
42819
|
+
}) }, selectedMenuOption.customizedInput ? (selectedMenuOption.customizedInput) : (React__default["default"].createElement(LuiSearchInput, { name: selectedMenuOption.name ? selectedMenuOption.name : undefined, minCharactersForSearch: 2, placeholderText: selectedMenuOption.placeholderText, getOptions: selectedMenuOption.getOption, onSelectOption: selectedMenuOption.onSelectOption, renderItem: selectedMenuOption.renderItem
|
|
42820
|
+
? selectedMenuOption.renderItem
|
|
42821
|
+
: function (item) {
|
|
42822
|
+
return React__default["default"].createElement("span", { style: resultStyle }, item.description);
|
|
42823
|
+
}, disclaimer: selectedMenuOption.disclaimer, focusUpdate: autoFocus && isFocus ? focusUpdate : undefined, externalSearch: externalSearch, initialValue: !!externalSearch ? searchString : undefined, onClickInput: onClickInput, onClearCallback: onClearInput })))));
|
|
42767
42824
|
};
|
|
42768
42825
|
var LuiSearchBoxButton = React__default["default"].forwardRef(function (props, ref) {
|
|
42769
42826
|
var button = React.useMemo(function () {
|
|
@@ -60060,6 +60117,7 @@ exports.LuiMoneyInput = LuiMoneyInput;
|
|
|
60060
60117
|
exports.LuiMultiSwitch = LuiMultiSwitch;
|
|
60061
60118
|
exports.LuiMultiSwitchYesNo = LuiMultiSwitchYesNo;
|
|
60062
60119
|
exports.LuiPagination = LuiPagination;
|
|
60120
|
+
exports.LuiPassiveSearchInput = LuiPassiveSearchInput;
|
|
60063
60121
|
exports.LuiProgressBar = LuiProgressBar;
|
|
60064
60122
|
exports.LuiRadioInput = LuiRadioInput;
|
|
60065
60123
|
exports.LuiResizableLayout = LuiResizableLayout;
|