@redneckz/wildless-cms-uni-blocks 0.14.909 → 0.14.910
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/bundle/bundle.umd.js +85 -69
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/ui-kit/Select/Select.d.ts +6 -0
- package/bundle/ui-kit/Select/SelectPopup.d.ts +1 -0
- package/bundle/ui-kit/Select/filterOptions.d.ts +1 -1
- package/bundle/ui-kit/Select/renderIcon.d.ts +2 -0
- package/bundle/ui-kit/Select/renderOptionText.d.ts +9 -0
- package/bundle/ui-kit/Select/renderSearchInput.d.ts +9 -0
- package/bundle/ui-kit/Select/renderSelectContainer.d.ts +15 -0
- package/bundle/ui-kit/Select/useSelectPopup.d.ts +2 -1
- package/dist/ui-kit/FormField/Fields/InnDadataField.js +5 -2
- package/dist/ui-kit/FormField/Fields/InnDadataField.js.map +1 -1
- package/dist/ui-kit/Select/Select.d.ts +6 -0
- package/dist/ui-kit/Select/Select.js +31 -40
- package/dist/ui-kit/Select/Select.js.map +1 -1
- package/dist/ui-kit/Select/SelectPopup.d.ts +1 -0
- package/dist/ui-kit/Select/SelectPopup.js +1 -1
- package/dist/ui-kit/Select/SelectPopup.js.map +1 -1
- package/dist/ui-kit/Select/filterOptions.d.ts +1 -1
- package/dist/ui-kit/Select/filterOptions.js +2 -2
- package/dist/ui-kit/Select/filterOptions.js.map +1 -1
- package/dist/ui-kit/Select/renderIcon.d.ts +2 -0
- package/dist/ui-kit/Select/renderIcon.js +8 -0
- package/dist/ui-kit/Select/renderIcon.js.map +1 -0
- package/dist/ui-kit/Select/renderOptionText.d.ts +9 -0
- package/dist/ui-kit/Select/renderOptionText.js +11 -0
- package/dist/ui-kit/Select/renderOptionText.js.map +1 -0
- package/dist/ui-kit/Select/renderSearchInput.d.ts +9 -0
- package/dist/ui-kit/Select/renderSearchInput.js +7 -0
- package/dist/ui-kit/Select/renderSearchInput.js.map +1 -0
- package/dist/ui-kit/Select/renderSelectContainer.d.ts +15 -0
- package/dist/ui-kit/Select/renderSelectContainer.js +18 -0
- package/dist/ui-kit/Select/renderSelectContainer.js.map +1 -0
- package/dist/ui-kit/Select/useSelectPopup.d.ts +2 -1
- package/dist/ui-kit/Select/useSelectPopup.js +6 -5
- package/dist/ui-kit/Select/useSelectPopup.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/ui-kit/FormField/Fields/InnDadataField.js +5 -2
- package/lib/ui-kit/FormField/Fields/InnDadataField.js.map +1 -1
- package/lib/ui-kit/Select/Select.d.ts +6 -0
- package/lib/ui-kit/Select/Select.js +32 -41
- package/lib/ui-kit/Select/Select.js.map +1 -1
- package/lib/ui-kit/Select/SelectPopup.d.ts +1 -0
- package/lib/ui-kit/Select/SelectPopup.js +1 -1
- package/lib/ui-kit/Select/SelectPopup.js.map +1 -1
- package/lib/ui-kit/Select/filterOptions.d.ts +1 -1
- package/lib/ui-kit/Select/filterOptions.js +2 -2
- package/lib/ui-kit/Select/filterOptions.js.map +1 -1
- package/lib/ui-kit/Select/renderIcon.d.ts +2 -0
- package/lib/ui-kit/Select/renderIcon.js +5 -0
- package/lib/ui-kit/Select/renderIcon.js.map +1 -0
- package/lib/ui-kit/Select/renderOptionText.d.ts +9 -0
- package/lib/ui-kit/Select/renderOptionText.js +8 -0
- package/lib/ui-kit/Select/renderOptionText.js.map +1 -0
- package/lib/ui-kit/Select/renderSearchInput.d.ts +9 -0
- package/lib/ui-kit/Select/renderSearchInput.js +4 -0
- package/lib/ui-kit/Select/renderSearchInput.js.map +1 -0
- package/lib/ui-kit/Select/renderSelectContainer.d.ts +15 -0
- package/lib/ui-kit/Select/renderSelectContainer.js +15 -0
- package/lib/ui-kit/Select/renderSelectContainer.js.map +1 -0
- package/lib/ui-kit/Select/useSelectPopup.d.ts +2 -1
- package/lib/ui-kit/Select/useSelectPopup.js +6 -5
- package/lib/ui-kit/Select/useSelectPopup.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +85 -69
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/ui-kit/Select/Select.d.ts +6 -0
- package/mobile/bundle/ui-kit/Select/SelectPopup.d.ts +1 -0
- package/mobile/bundle/ui-kit/Select/filterOptions.d.ts +1 -1
- package/mobile/bundle/ui-kit/Select/renderIcon.d.ts +2 -0
- package/mobile/bundle/ui-kit/Select/renderOptionText.d.ts +9 -0
- package/mobile/bundle/ui-kit/Select/renderSearchInput.d.ts +9 -0
- package/mobile/bundle/ui-kit/Select/renderSelectContainer.d.ts +15 -0
- package/mobile/bundle/ui-kit/Select/useSelectPopup.d.ts +2 -1
- package/mobile/dist/ui-kit/FormField/Fields/InnDadataField.js +5 -2
- package/mobile/dist/ui-kit/FormField/Fields/InnDadataField.js.map +1 -1
- package/mobile/dist/ui-kit/Select/Select.d.ts +6 -0
- package/mobile/dist/ui-kit/Select/Select.js +31 -40
- package/mobile/dist/ui-kit/Select/Select.js.map +1 -1
- package/mobile/dist/ui-kit/Select/SelectPopup.d.ts +1 -0
- package/mobile/dist/ui-kit/Select/SelectPopup.js +1 -1
- package/mobile/dist/ui-kit/Select/SelectPopup.js.map +1 -1
- package/mobile/dist/ui-kit/Select/filterOptions.d.ts +1 -1
- package/mobile/dist/ui-kit/Select/filterOptions.js +2 -2
- package/mobile/dist/ui-kit/Select/filterOptions.js.map +1 -1
- package/mobile/dist/ui-kit/Select/renderIcon.d.ts +2 -0
- package/mobile/dist/ui-kit/Select/renderIcon.js +8 -0
- package/mobile/dist/ui-kit/Select/renderIcon.js.map +1 -0
- package/mobile/dist/ui-kit/Select/renderOptionText.d.ts +9 -0
- package/mobile/dist/ui-kit/Select/renderOptionText.js +11 -0
- package/mobile/dist/ui-kit/Select/renderOptionText.js.map +1 -0
- package/mobile/dist/ui-kit/Select/renderSearchInput.d.ts +9 -0
- package/mobile/dist/ui-kit/Select/renderSearchInput.js +7 -0
- package/mobile/dist/ui-kit/Select/renderSearchInput.js.map +1 -0
- package/mobile/dist/ui-kit/Select/renderSelectContainer.d.ts +15 -0
- package/mobile/dist/ui-kit/Select/renderSelectContainer.js +18 -0
- package/mobile/dist/ui-kit/Select/renderSelectContainer.js.map +1 -0
- package/mobile/dist/ui-kit/Select/useSelectPopup.d.ts +2 -1
- package/mobile/dist/ui-kit/Select/useSelectPopup.js +6 -5
- package/mobile/dist/ui-kit/Select/useSelectPopup.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/InnDadataField.js +5 -2
- package/mobile/lib/ui-kit/FormField/Fields/InnDadataField.js.map +1 -1
- package/mobile/lib/ui-kit/Select/Select.d.ts +6 -0
- package/mobile/lib/ui-kit/Select/Select.js +32 -41
- package/mobile/lib/ui-kit/Select/Select.js.map +1 -1
- package/mobile/lib/ui-kit/Select/SelectPopup.d.ts +1 -0
- package/mobile/lib/ui-kit/Select/SelectPopup.js +1 -1
- package/mobile/lib/ui-kit/Select/SelectPopup.js.map +1 -1
- package/mobile/lib/ui-kit/Select/filterOptions.d.ts +1 -1
- package/mobile/lib/ui-kit/Select/filterOptions.js +2 -2
- package/mobile/lib/ui-kit/Select/filterOptions.js.map +1 -1
- package/mobile/lib/ui-kit/Select/renderIcon.d.ts +2 -0
- package/mobile/lib/ui-kit/Select/renderIcon.js +5 -0
- package/mobile/lib/ui-kit/Select/renderIcon.js.map +1 -0
- package/mobile/lib/ui-kit/Select/renderOptionText.d.ts +9 -0
- package/mobile/lib/ui-kit/Select/renderOptionText.js +8 -0
- package/mobile/lib/ui-kit/Select/renderOptionText.js.map +1 -0
- package/mobile/lib/ui-kit/Select/renderSearchInput.d.ts +9 -0
- package/mobile/lib/ui-kit/Select/renderSearchInput.js +4 -0
- package/mobile/lib/ui-kit/Select/renderSearchInput.js.map +1 -0
- package/mobile/lib/ui-kit/Select/renderSelectContainer.d.ts +15 -0
- package/mobile/lib/ui-kit/Select/renderSelectContainer.js +15 -0
- package/mobile/lib/ui-kit/Select/renderSelectContainer.js.map +1 -0
- package/mobile/lib/ui-kit/Select/useSelectPopup.d.ts +2 -1
- package/mobile/lib/ui-kit/Select/useSelectPopup.js +6 -5
- package/mobile/lib/ui-kit/Select/useSelectPopup.js.map +1 -1
- package/mobile/src/ui-kit/FormField/Fields/InnDadataField.tsx +7 -2
- package/mobile/src/ui-kit/Select/Select.tsx +46 -105
- package/mobile/src/ui-kit/Select/SelectPopup.tsx +12 -2
- package/mobile/src/ui-kit/Select/filterOptions.ts +6 -2
- package/mobile/src/ui-kit/Select/renderIcon.tsx +13 -0
- package/mobile/src/ui-kit/Select/renderOptionText.tsx +22 -0
- package/mobile/src/ui-kit/Select/renderSearchInput.tsx +28 -0
- package/mobile/src/ui-kit/Select/renderSelectContainer.tsx +60 -0
- package/mobile/src/ui-kit/Select/useSelectPopup.tsx +11 -7
- package/package.json +1 -1
- package/src/ui-kit/FormField/Fields/InnDadataField.tsx +7 -2
- package/src/ui-kit/Select/Select.tsx +46 -105
- package/src/ui-kit/Select/SelectPopup.tsx +12 -2
- package/src/ui-kit/Select/filterOptions.ts +6 -2
- package/src/ui-kit/Select/renderIcon.tsx +13 -0
- package/src/ui-kit/Select/renderOptionText.tsx +22 -0
- package/src/ui-kit/Select/renderSearchInput.tsx +28 -0
- package/src/ui-kit/Select/renderSelectContainer.tsx +60 -0
- package/src/ui-kit/Select/useSelectPopup.tsx +11 -7
package/bundle/bundle.umd.js
CHANGED
|
@@ -1886,8 +1886,6 @@
|
|
|
1886
1886
|
return debouncedCallback;
|
|
1887
1887
|
};
|
|
1888
1888
|
|
|
1889
|
-
const formatOption = (_) => _?.text || _?.key || '';
|
|
1890
|
-
|
|
1891
1889
|
function useEventListener(target, type, listener, options) {
|
|
1892
1890
|
useEffect(() => {
|
|
1893
1891
|
if (!target || !listener) {
|
|
@@ -1911,16 +1909,59 @@
|
|
|
1911
1909
|
return targetRef;
|
|
1912
1910
|
}
|
|
1913
1911
|
|
|
1912
|
+
const InputWrapper = JSX(({ className, label, value = '', error, errors, type, isInteger, placeholder, maxLength, inputRef, isOpen, onOpen, onClose, onChange = noop, ...rest }) => {
|
|
1913
|
+
const popupRef = useOutsideClick(onClose);
|
|
1914
|
+
const handleChange = useCallback((v) => {
|
|
1915
|
+
const isOverMax = maxLength && v.length > maxLength;
|
|
1916
|
+
!isOpen && onOpen();
|
|
1917
|
+
if (!isOverMax) {
|
|
1918
|
+
onChange(normalizeInteger(v, isInteger));
|
|
1919
|
+
}
|
|
1920
|
+
}, [isOpen, onChange]);
|
|
1921
|
+
return (jsxs("div", { className: style('shrink-0 w-full', className), ref: popupRef, onBlur: onClose, onFocus: onOpen, children: [jsx("div", { ref: inputRef, children: jsx(Input, { type: type || 'text', "aria-label": label, label: getRequiredLabel({ label, errors }), valid: Boolean(!error), onChange: handleChange, placeholder: getPlaceholder({ placeholder, errors, label }), value: value, ...rest }) }), renderErrorText(error)] }));
|
|
1922
|
+
});
|
|
1923
|
+
const normalizeInteger = (val = '', isInteger = false) => isInteger && val ? val.replace(/[^\d]+/g, '') : val;
|
|
1924
|
+
const getPlaceholder = ({ placeholder, errors, label }) => errors && !label ? `${placeholder}*` : placeholder;
|
|
1925
|
+
|
|
1926
|
+
const InputControl = JSX((props) => {
|
|
1927
|
+
const [isOpen, { setFalse: close, setTrue: open }] = useBool();
|
|
1928
|
+
return jsx(InputWrapper, { isOpen: isOpen, onOpen: open, onClose: close, ...props });
|
|
1929
|
+
});
|
|
1930
|
+
|
|
1931
|
+
const renderSearchInput = ({ query, isDisabled, onChangeQuery, inputProps, }) => (jsx("div", { className: "absolute top-0 w-full z-20", children: jsx(InputControl, { type: "text", value: query, autoFocus: true, disabled: isDisabled, onChange: (value) => onChangeQuery(value), maxLength: inputProps?.maxLength, isInteger: inputProps?.isInteger ?? false }) }));
|
|
1932
|
+
|
|
1933
|
+
const renderIcon$1 = (isOpen, iconVersion) => (jsx(Icon, { className: style('absolute right-0 flex self-center', { 'rotate-180': !isOpen }), iconVersion: iconVersion, name: "ArrowUpIcon", width: "16", height: "16" }));
|
|
1934
|
+
|
|
1935
|
+
const formatOption = (_) => _?.text || _?.key || '';
|
|
1936
|
+
|
|
1937
|
+
const renderOptionText = ({ isManualInput, query, value, placeholder, }) => {
|
|
1938
|
+
if (isManualInput && query) {
|
|
1939
|
+
return query;
|
|
1940
|
+
}
|
|
1941
|
+
return formatOption(value) || placeholder;
|
|
1942
|
+
};
|
|
1943
|
+
|
|
1944
|
+
const renderSelectContainer = ({ isBorder = true, valid = true, isDisabled = false, isOpen = false, onOpen, onClose, isManualInput = false, query = '', value, placeholder = '', iconVersion = 'black', options = [], }) => {
|
|
1945
|
+
const isIconHidden = getIconHidden(isManualInput, options, query);
|
|
1946
|
+
return (jsxs("div", { className: style({ 'border rounded-md': isBorder }, { 'hover:border-primary-hover': isBorder && !isDisabled }, isDisabled ? 'bg-main-divider' : 'cursor-pointer ', valid ? 'border-gray' : 'border-error', 'h-14 [&>*]:p-m pr-6 text-l flex items-center justify-between text-primary-text relative z-10 overflow-hidden'), onClick: isOpen ? onClose : onOpen, children: [jsx("p", { className: "line-clamp-2 text-ellipsis", children: renderOptionText({ isManualInput, query, value, placeholder }) }), isIconHidden ? '' : renderIcon$1(isOpen, iconVersion)] }));
|
|
1947
|
+
};
|
|
1948
|
+
const getIconHidden = (isManualInput, options, query) => {
|
|
1949
|
+
if (isManualInput && query?.length) {
|
|
1950
|
+
return true;
|
|
1951
|
+
}
|
|
1952
|
+
return isManualInput && !options.length;
|
|
1953
|
+
};
|
|
1954
|
+
|
|
1914
1955
|
const usePopupManager = () => useEmitterWithActions(defaultEventBus.emitter, 'popup');
|
|
1915
1956
|
|
|
1916
|
-
const filterOptions = (options, query) => {
|
|
1917
|
-
if (!options?.length || !query?.trim()) {
|
|
1957
|
+
const filterOptions = (options, query, disableFilterOptions) => {
|
|
1958
|
+
if (!options?.length || !query?.trim() || disableFilterOptions) {
|
|
1918
1959
|
return options;
|
|
1919
1960
|
}
|
|
1920
1961
|
return options.filter((_) => _.text?.toLocaleLowerCase().includes(query?.trim().toLocaleLowerCase()));
|
|
1921
1962
|
};
|
|
1922
1963
|
|
|
1923
|
-
const SelectPopup = JSX(({ popupRef, options, value, query,
|
|
1964
|
+
const SelectPopup = JSX(({ popupRef, options, value, query, iconVersion, disableFilterOptions, onChange, onChangeQuery, }) => options?.length ? (jsx("div", { className: "bg-white text-l max-h-64 overflow-y-auto overflow-x-hidden rounded-md shadow-2xl", role: "list", ref: popupRef, children: filterOptions(options, query, disableFilterOptions).map((option) => (jsxs("div", { className: "flex px-m py-s cursor-pointer hover:bg-main-divider pr-5xl relative", role: "listitem", "aria-selected": option.key === value?.key, onClick: (e) => {
|
|
1924
1965
|
e.stopPropagation();
|
|
1925
1966
|
if (onChange) {
|
|
1926
1967
|
onChangeQuery?.('');
|
|
@@ -1930,16 +1971,16 @@
|
|
|
1930
1971
|
hidden: option.key !== value?.key,
|
|
1931
1972
|
}) })] }, option.key))) })) : null);
|
|
1932
1973
|
|
|
1933
|
-
function useSelectPopup({ isOpen, options, value, query, onChange, onClose, iconVersion, onChangeQuery, }) {
|
|
1974
|
+
function useSelectPopup({ isOpen, options, value, query, onChange = noop, onClose = noop, iconVersion, disableFilterOptions = false, onChangeQuery = noop, }) {
|
|
1934
1975
|
const popup = usePopupManager();
|
|
1935
1976
|
const close = useCallback(() => {
|
|
1936
1977
|
popup.close();
|
|
1937
|
-
onClose
|
|
1978
|
+
onClose();
|
|
1938
1979
|
}, [onClose]);
|
|
1939
1980
|
const handleChange = useCallback((option) => {
|
|
1940
1981
|
close();
|
|
1941
|
-
onChange
|
|
1942
|
-
onChangeQuery
|
|
1982
|
+
onChange(option);
|
|
1983
|
+
onChangeQuery('');
|
|
1943
1984
|
}, [close, onChange]);
|
|
1944
1985
|
const inputRef = useRef(null);
|
|
1945
1986
|
const popupRef = useOutsideClick(close);
|
|
@@ -1950,7 +1991,7 @@
|
|
|
1950
1991
|
const inputElement = inputRef.current;
|
|
1951
1992
|
const { top, left, width, height } = inputElement.getBoundingClientRect();
|
|
1952
1993
|
popup.open({
|
|
1953
|
-
popup: (jsx(SelectPopup, { popupRef: popupRef, options: options, value: value, query: query,
|
|
1994
|
+
popup: (jsx(SelectPopup, { popupRef: popupRef, options: options, value: value, query: query, iconVersion: iconVersion, disableFilterOptions: disableFilterOptions, onChange: handleChange, onChangeQuery: onChangeQuery })),
|
|
1954
1995
|
top: top + window.scrollY + height,
|
|
1955
1996
|
left,
|
|
1956
1997
|
width,
|
|
@@ -1959,56 +2000,47 @@
|
|
|
1959
2000
|
return inputRef;
|
|
1960
2001
|
}
|
|
1961
2002
|
|
|
1962
|
-
const Select = JSX(({ className, label, options = [], value,
|
|
2003
|
+
const Select = JSX(({ className, label, options = [], value, isSearch = false, isManualInput = false, disabled = false, iconVersion = 'black', onChange, onSearchQuery = noop, inputProps, disableFilterOptions = false, ...rest }) => {
|
|
1963
2004
|
const [isOpen, { setFalse: close, setTrue: open }] = useBool();
|
|
1964
2005
|
const [query, setQuery] = useState('');
|
|
1965
|
-
const isDisabled =
|
|
1966
|
-
const
|
|
1967
|
-
const hasOpen = isOpen && !isDisabled;
|
|
1968
|
-
const debouncedOnSearchQuery = useMemo(() => onSearchQuery && getDebouncedSearchQuery(onSearchQuery), [onSearchQuery]);
|
|
2006
|
+
const isDisabled = disabled || (!isManualInput && options.length === 0);
|
|
2007
|
+
const debouncedOnSearchQuery = useMemo(() => debounce((searchValue) => onSearchQuery(searchValue), 300), [onSearchQuery]);
|
|
1969
2008
|
const handleOpen = useCallback(() => {
|
|
1970
|
-
|
|
1971
|
-
return;
|
|
1972
|
-
}
|
|
1973
|
-
open();
|
|
2009
|
+
isDisabled ? noop() : open();
|
|
1974
2010
|
}, [isDisabled]);
|
|
1975
|
-
const handleChangeQuery = (newQuery) => {
|
|
1976
|
-
setQuery(newQuery);
|
|
1977
|
-
isManualInput && setOption(newQuery, onChange);
|
|
1978
|
-
debouncedOnSearchQuery && debouncedOnSearchQuery(newQuery);
|
|
1979
|
-
};
|
|
1980
2011
|
const handleClose = useCallback(() => {
|
|
1981
2012
|
!isManualInput && setQuery('');
|
|
1982
2013
|
close();
|
|
1983
|
-
}, []);
|
|
2014
|
+
}, [isManualInput]);
|
|
2015
|
+
const handleChangeQuery = useCallback((newQuery) => {
|
|
2016
|
+
setQuery(newQuery);
|
|
2017
|
+
isManualInput && onChange?.({ key: newQuery, text: newQuery, innDaData: {} });
|
|
2018
|
+
debouncedOnSearchQuery?.(newQuery);
|
|
2019
|
+
}, [isManualInput, onChange, debouncedOnSearchQuery]);
|
|
2020
|
+
const selectState = { query, value, options, isOpen, iconVersion };
|
|
1984
2021
|
const inputRef = useSelectPopup({
|
|
1985
|
-
isOpen,
|
|
1986
|
-
options,
|
|
1987
|
-
value,
|
|
1988
|
-
query,
|
|
1989
2022
|
onChange,
|
|
1990
2023
|
onClose: handleClose,
|
|
1991
|
-
|
|
2024
|
+
disableFilterOptions,
|
|
1992
2025
|
onChangeQuery: setQuery,
|
|
2026
|
+
...selectState,
|
|
1993
2027
|
});
|
|
1994
|
-
return (jsxs("div", { className: style('space-y-xs', className), children: [renderLabel$1(label), jsxs("div", { className: style('relative',
|
|
2028
|
+
return (jsxs("div", { className: style('space-y-xs', className), children: [renderLabel$1(label), jsxs("div", { className: style('relative', isOpen ? 'z-20' : 'z-10'), ref: inputRef, children: [renderSelectContainer({
|
|
2029
|
+
isDisabled,
|
|
2030
|
+
onClose: handleClose,
|
|
2031
|
+
onOpen: handleOpen,
|
|
2032
|
+
isManualInput,
|
|
2033
|
+
...selectState,
|
|
2034
|
+
...rest,
|
|
2035
|
+
}), isSearch && isOpen
|
|
2036
|
+
? renderSearchInput({
|
|
2037
|
+
query,
|
|
2038
|
+
isDisabled,
|
|
2039
|
+
inputProps,
|
|
2040
|
+
onChangeQuery: handleChangeQuery,
|
|
2041
|
+
})
|
|
2042
|
+
: null] })] }));
|
|
1995
2043
|
});
|
|
1996
|
-
const useRenderOptionText = (data) => useMemo(() => {
|
|
1997
|
-
if (data.isManualInput && data.query) {
|
|
1998
|
-
return data.query;
|
|
1999
|
-
}
|
|
2000
|
-
return formatOption(data.value) || data.placeholder;
|
|
2001
|
-
}, [data.isManualInput, data.query, data.value, data.placeholder]);
|
|
2002
|
-
const renderSearchInput = (query, isDisabled, onChangeQuery) => (jsx("div", { className: style('absolute top-0 w-full z-20'), children: jsx(Input, { type: "text", value: query, autoFocus: true, disabled: isDisabled, onChange: (value) => onChangeQuery(value) }) }));
|
|
2003
|
-
const renderIcon$1 = (isOpen, iconVersion) => (jsx(Icon, { className: style('absolute right-0 flex self-center', { 'rotate-180': !isOpen }), iconVersion: iconVersion, name: "ArrowUpIcon", width: "16", height: "16" }));
|
|
2004
|
-
const getStyle = (isBorder, valid, disabled) => style(isBorder ? 'border rounded-md ' : '', isBorder && !disabled ? 'hover:border-primary-hover' : '', disabled ? 'bg-main-divider' : 'cursor-pointer ', valid ? 'border-gray' : 'border-error');
|
|
2005
|
-
// TODO Нужен рефактор и декомпозиция компонента getDisabled, setOption, getIconHidden
|
|
2006
|
-
const getDisabled = (disabled, length, isManualInput) => disabled || (!isManualInput && length === 0);
|
|
2007
|
-
const setOption = (query, onChange) => {
|
|
2008
|
-
onChange && query.trim() !== '' && onChange({ key: query, text: query, innDaData: {} });
|
|
2009
|
-
};
|
|
2010
|
-
const getIconHidden = (isManualInput, options) => isManualInput && !options.length;
|
|
2011
|
-
const getDebouncedSearchQuery = (onSearchQuery) => debounce((searchValue) => onSearchQuery(searchValue), 300);
|
|
2012
2044
|
|
|
2013
2045
|
const SelectControl = JSX(({ className = '', label, error, errors, ...rest }) => (jsxs("div", { className: className, children: [jsx(Select, { ...rest, valid: !error, label: getRequiredLabel({ label, errors }) }), renderErrorText(error)] })));
|
|
2014
2046
|
|
|
@@ -2205,25 +2237,6 @@
|
|
|
2205
2237
|
const ITEMS_CREDIT_AMOUNT = ['От 1 000 ₽', 'До 1 000 000 000 ₽'];
|
|
2206
2238
|
const AmountField = JSX(({ field, input }) => (jsx(InputRange, { title: "\u0421\u0443\u043C\u043C\u0430, \u20BD", items: ITEMS_CREDIT_AMOUNT, min: MIN_CREDIT_AMOUNT, max: MAX_CREDIT_AMOUNT, ...field(input?.name ?? '') })));
|
|
2207
2239
|
|
|
2208
|
-
const InputWrapper = JSX(({ className, label, value = '', error, errors, type, isInteger, placeholder, maxLength, inputRef, isOpen, onOpen, onClose, onChange = noop, ...rest }) => {
|
|
2209
|
-
const popupRef = useOutsideClick(onClose);
|
|
2210
|
-
const handleChange = useCallback((v) => {
|
|
2211
|
-
const isOverMax = maxLength && v.length > maxLength;
|
|
2212
|
-
!isOpen && onOpen();
|
|
2213
|
-
if (!isOverMax) {
|
|
2214
|
-
onChange(normalizeInteger(v, isInteger));
|
|
2215
|
-
}
|
|
2216
|
-
}, [isOpen, onChange]);
|
|
2217
|
-
return (jsxs("div", { className: style('shrink-0 w-full', className), ref: popupRef, onBlur: onClose, onFocus: onOpen, children: [jsx("div", { ref: inputRef, children: jsx(Input, { type: type || 'text', "aria-label": label, label: getRequiredLabel({ label, errors }), valid: Boolean(!error), onChange: handleChange, placeholder: getPlaceholder({ placeholder, errors, label }), value: value, ...rest }) }), renderErrorText(error)] }));
|
|
2218
|
-
});
|
|
2219
|
-
const normalizeInteger = (val = '', isInteger = false) => isInteger && val ? val.replace(/[^\d]+/g, '') : val;
|
|
2220
|
-
const getPlaceholder = ({ placeholder, errors, label }) => errors && !label ? `${placeholder}*` : placeholder;
|
|
2221
|
-
|
|
2222
|
-
const InputControl = JSX((props) => {
|
|
2223
|
-
const [isOpen, { setFalse: close, setTrue: open }] = useBool();
|
|
2224
|
-
return jsx(InputWrapper, { isOpen: isOpen, onOpen: open, onClose: close, ...props });
|
|
2225
|
-
});
|
|
2226
|
-
|
|
2227
2240
|
const AnnualRevenueField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0413\u043E\u0434\u043E\u0432\u0430\u044F \u0432\u044B\u0440\u0443\u0447\u043A\u0430, \u20BD", ...field(input?.name ?? '') })));
|
|
2228
2241
|
|
|
2229
2242
|
const ApplicationDateField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0414\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F \u043E\u0431\u0440\u0430\u0449\u0435\u043D\u0438\u044F \u0432 \u0411\u0430\u043D\u043A", ...field(input?.name ?? '') })));
|
|
@@ -2638,7 +2651,7 @@
|
|
|
2638
2651
|
inn: _?.data?.inn,
|
|
2639
2652
|
}));
|
|
2640
2653
|
|
|
2641
|
-
const InnDadataField = JSX(({ field, input }) => {
|
|
2654
|
+
const InnDadataField = JSX(({ field, input = {} }) => {
|
|
2642
2655
|
const [options, setOptions] = useState([]);
|
|
2643
2656
|
const [searchQuery, setSearchQuery] = useState('');
|
|
2644
2657
|
useAsyncEffect(async () => {
|
|
@@ -2656,7 +2669,10 @@
|
|
|
2656
2669
|
},
|
|
2657
2670
|
}));
|
|
2658
2671
|
}, [options]);
|
|
2659
|
-
return (jsx(SelectControl, { label: "\u0418\u041D\u041D", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0418\u041D\u041D", options: getOptions, ...field(input
|
|
2672
|
+
return (jsx(SelectControl, { label: "\u0418\u041D\u041D", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0418\u041D\u041D", options: getOptions, ...field(input.name ?? ''), isSearch: true, isManualInput: true, inputProps: {
|
|
2673
|
+
isInteger: true,
|
|
2674
|
+
maxLength: 12,
|
|
2675
|
+
}, disableFilterOptions: true, onSearchQuery: setSearchQuery }));
|
|
2660
2676
|
});
|
|
2661
2677
|
|
|
2662
2678
|
const InnField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u0418\u041D\u041D", isInteger: true, maxLength: 12, ...input, ...field(input?.name ?? '') })));
|
|
@@ -11998,7 +12014,7 @@
|
|
|
11998
12014
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
11999
12015
|
});
|
|
12000
12016
|
|
|
12001
|
-
const packageVersion = "0.14.
|
|
12017
|
+
const packageVersion = "0.14.909";
|
|
12002
12018
|
|
|
12003
12019
|
exports.Blocks = Blocks;
|
|
12004
12020
|
exports.ContentPage = ContentPage;
|