onekijs-ui 0.19.7 → 0.19.8
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/components/password/components/PasswordComponent.d.ts +2 -2
- package/dist/components/select/components/ControlledSelectComponent.d.ts +1 -1
- package/dist/components/select/typings.d.ts +1 -0
- package/dist/index.js +45 -30
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +45 -30
- package/dist/index.module.js.map +1 -1
- package/dist/styles/typography.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/password/components/PasswordComponent.tsx +17 -2
- package/src/components/select/components/ControlledSelectComponent.tsx +30 -24
- package/src/components/select/components/SelectInputComponent.tsx +1 -1
- package/src/components/select/components/SelectOptionComponent.tsx +1 -0
- package/src/components/select/typings.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { PasswordProps } from '../typings';
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const _default: import("styled-components").StyledComponent<React.FC<PasswordProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ControllerSelectProps, SelectController, SelectItem, SelectState } from '../typings';
|
|
3
|
-
declare const ControlledSelectComponent: <T = any, I extends SelectItem<T> = SelectItem<T>, S extends SelectState<T, I> = SelectState<T, I>, C extends SelectController<T, I, S> = SelectController<T, I, S>>({ attachDropdownToBody, className, placeholder, controller, InputComponent, IconComponent, OptionContentComponent, OptionComponent, OptionLoadingComponent, MultiOptionsComponent, NotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height, multiple, status, size, nullable, minChars, openOnFocus, searchable, dropdownWidthModifier, preload, increment, animationMs, disabled, defaultValue, defaultValueLoading, required, sameWidth, overscan, clickable, ListComponent, autoCompleteSearch, maxDisplayTokens, }: ControllerSelectProps<T, I, S, C>) => React.JSX.Element;
|
|
3
|
+
declare const ControlledSelectComponent: <T = any, I extends SelectItem<T> = SelectItem<T>, S extends SelectState<T, I> = SelectState<T, I>, C extends SelectController<T, I, S> = SelectController<T, I, S>>({ attachDropdownToBody, className, placeholder, controller, InputComponent, IconComponent, OptionContentComponent, OptionComponent, OptionLoadingComponent, MultiOptionsComponent, NotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height, multiple, status, size, nullable, minChars, openOnFocus, searchable, dropdownWidthModifier, preload, increment, animationMs, disabled, defaultValue, defaultValueLoading, required, sameWidth, overscan, clickable, ListComponent, autoCompleteSearch, maxDisplayTokens, validateValue, }: ControllerSelectProps<T, I, S, C>) => React.JSX.Element;
|
|
4
4
|
export default ControlledSelectComponent;
|
|
@@ -118,6 +118,7 @@ export type SelectConfig<T = any, I extends SelectItem<T> = SelectItem<T>> = Omi
|
|
|
118
118
|
ListComponent?: React.FC<SelectListComponentProps<T, I>>;
|
|
119
119
|
autoCompleteSearch?: boolean;
|
|
120
120
|
maxDisplayTokens?: number;
|
|
121
|
+
validateValue?: boolean;
|
|
121
122
|
};
|
|
122
123
|
export type SelectListComponentProps<T = any, I extends SelectItem<T> = SelectItem<T>> = CollectionListProps<T, I> & {
|
|
123
124
|
optionsRef: React.RefObject<HTMLDivElement>;
|
package/dist/index.js
CHANGED
|
@@ -4089,9 +4089,19 @@ const PasswordComponent = ({ className, value }) => {
|
|
|
4089
4089
|
React.createElement(HideIcon, { onClick: () => setShow(false) })));
|
|
4090
4090
|
}
|
|
4091
4091
|
return (React.createElement("span", { className: addClassname('o-password o-password-obfuscated', className) },
|
|
4092
|
-
React.createElement("span", { className: "o-password-text" },
|
|
4092
|
+
React.createElement("span", { className: "o-password-text" }, "************"),
|
|
4093
4093
|
React.createElement(ShowIcon, { onClick: () => setShow(true) })));
|
|
4094
4094
|
};
|
|
4095
|
+
var PasswordComponent$1 = styled(PasswordComponent) `
|
|
4096
|
+
${display('flex')}
|
|
4097
|
+
${alignItems('center')}
|
|
4098
|
+
.o-icon-show, .o-icon-hide {
|
|
4099
|
+
${color('primary')}
|
|
4100
|
+
${marginLeft('sm')}
|
|
4101
|
+
${cursor('pointer')}
|
|
4102
|
+
}
|
|
4103
|
+
|
|
4104
|
+
`;
|
|
4095
4105
|
|
|
4096
4106
|
const passwordStyle = () => {
|
|
4097
4107
|
return styled.css `
|
|
@@ -4109,7 +4119,7 @@ const passwordStyle = () => {
|
|
|
4109
4119
|
`;
|
|
4110
4120
|
};
|
|
4111
4121
|
|
|
4112
|
-
const Password = styled(PasswordComponent) `
|
|
4122
|
+
const Password = styled(PasswordComponent$1) `
|
|
4113
4123
|
${passwordStyle}
|
|
4114
4124
|
`;
|
|
4115
4125
|
|
|
@@ -6549,7 +6559,7 @@ const SelectInputComponent = ({ setOpen, open, placeholder, loading, fetching, I
|
|
|
6549
6559
|
multiple && React.createElement(SelectTokensComponent$1, { tokens: tokens, onRemove: onRemove, maxDisplayTokens: maxDisplayTokens }),
|
|
6550
6560
|
React.createElement("div", { className: "o-select-input-wrapper" },
|
|
6551
6561
|
React.createElement("span", { ref: autoSizeRef, className: "o-select-input-auto-sizer" }),
|
|
6552
|
-
React.createElement("input", { ref: inputRef, placeholder: placeholder, className: "o-select-input", onFocus: onFocus, onBlur: onBlur, onChange: handleChange, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, value: searchable ? proxyValue : '', onClick: onClick, autoCapitalize: "none", autoComplete: "
|
|
6562
|
+
React.createElement("input", { ref: inputRef, placeholder: placeholder, className: "o-select-input", onFocus: onFocus, onBlur: onBlur, onChange: handleChange, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, value: searchable ? proxyValue : '', onClick: onClick, autoCapitalize: "none", autoComplete: "one-time-code", autoCorrect: "off", spellCheck: "false", disabled: disabled }),
|
|
6553
6563
|
!searchable && (React.createElement("span", { className: "o-select-input o-select-input-text", onClick: onClick }, multiple ? '' : proxyValue || '')))),
|
|
6554
6564
|
!multiple && nullable && value && !disabled && (React.createElement("div", { className: "o-select-remover", onClick: onNullify }, "\u2716")),
|
|
6555
6565
|
React.createElement(IconComponent, { onClick: onIconClick, open: open, loading: loading, fetching: fetching })));
|
|
@@ -6625,7 +6635,7 @@ const SelectOptionComponent = (props) => {
|
|
|
6625
6635
|
displayGroup && React.createElement(OptionGroupComponent, { ...props, key: "group" }),
|
|
6626
6636
|
React.createElement("div", { className: classNames, onClick: () => onItemClick(item, index), onMouseEnter: () => hoverable && onMouseEnter && item && onMouseEnter(item, index), onMouseLeave: () => hoverable && onMouseLeave && item && onMouseLeave(item, index), key: "content" },
|
|
6627
6637
|
React.createElement("div", { style: { display: 'flex' }, ref: ref },
|
|
6628
|
-
service.config?.multiple && (React.createElement(Checkbox, { value: item?.selected ? true : false, onChange: () => onItemClick(item, index), color: "currentColor", className: "o-select-option-multiple-checkbox", key: "checkbox" })),
|
|
6638
|
+
service.config?.multiple && (React.createElement(Checkbox, { value: item?.selected ? true : false, onChange: () => onItemClick(item, index), color: "currentColor", className: "o-select-option-multiple-checkbox", key: "checkbox", disabled: item?.disabled })),
|
|
6629
6639
|
React.createElement(OptionContentComponent, { ...props, onClick: () => onItemClick(item, index), key: "option_content" })))));
|
|
6630
6640
|
};
|
|
6631
6641
|
SelectOptionComponent.displayName = 'SelectOptionComponent';
|
|
@@ -6642,7 +6652,7 @@ const DefaultSelectListComponent = (props) => {
|
|
|
6642
6652
|
});
|
|
6643
6653
|
return (React.createElement(ListBodyComponent, { ...props, className: "o-select-options", bodyRef: props.optionsRef, items: selectItems, totalSize: totalSize, virtualItems: isVirtual ? virtualItems : undefined, scrollToIndex: scrollToIndex, keyboardNavigable: true, service: props.controller?.asService(), state: props.controller.state }));
|
|
6644
6654
|
};
|
|
6645
|
-
const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '', placeholder, controller, InputComponent = SelectInputComponent$1, IconComponent, OptionContentComponent = SelectOptionContent, OptionComponent = SelectOptionComponent$1, OptionLoadingComponent = LoadingItem$1, MultiOptionsComponent = SelectOptionComponent$1, NotFoundComponent = SelectNotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height = 220, multiple = false, status = onekijsFramework.ValidationStatus.None, size = 'medium', nullable, minChars = 0, openOnFocus = false, searchable = true, dropdownWidthModifier = 'min', preload = 50, increment = 50, animationMs = 200, disabled, defaultValue, defaultValueLoading, required = false, sameWidth = true, overscan, clickable = true, ListComponent = DefaultSelectListComponent, autoCompleteSearch = true, maxDisplayTokens, }) => {
|
|
6655
|
+
const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '', placeholder, controller, InputComponent = SelectInputComponent$1, IconComponent, OptionContentComponent = SelectOptionContent, OptionComponent = SelectOptionComponent$1, OptionLoadingComponent = LoadingItem$1, MultiOptionsComponent = SelectOptionComponent$1, NotFoundComponent = SelectNotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height = 220, multiple = false, status = onekijsFramework.ValidationStatus.None, size = 'medium', nullable, minChars = 0, openOnFocus = false, searchable = true, dropdownWidthModifier = 'min', preload = 50, increment = 50, animationMs = 200, disabled, defaultValue, defaultValueLoading, required = false, sameWidth = true, overscan, clickable = true, ListComponent = DefaultSelectListComponent, autoCompleteSearch = true, maxDisplayTokens, validateValue = true, }) => {
|
|
6646
6656
|
if (nullable === undefined) {
|
|
6647
6657
|
nullable = !required;
|
|
6648
6658
|
}
|
|
@@ -6687,6 +6697,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
|
|
|
6687
6697
|
overscan,
|
|
6688
6698
|
autoCompleteSearch,
|
|
6689
6699
|
maxDisplayTokens,
|
|
6700
|
+
validateValue,
|
|
6690
6701
|
};
|
|
6691
6702
|
}
|
|
6692
6703
|
else {
|
|
@@ -6726,6 +6737,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
|
|
|
6726
6737
|
overscan,
|
|
6727
6738
|
autoCompleteSearch,
|
|
6728
6739
|
maxDisplayTokens,
|
|
6740
|
+
validateValue,
|
|
6729
6741
|
};
|
|
6730
6742
|
}
|
|
6731
6743
|
const id = React.useId();
|
|
@@ -6884,36 +6896,38 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
|
|
|
6884
6896
|
// Manage the result of a check after a change of the value from the outside
|
|
6885
6897
|
// if the selected item is invalid, do a onChange to remove the value
|
|
6886
6898
|
React.useEffect(() => {
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
if (
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6899
|
+
if (validateValue) {
|
|
6900
|
+
const search = service.getSearch();
|
|
6901
|
+
const invalidItems = service.state.invalidItems || [];
|
|
6902
|
+
if (!search && invalidItems.length > 0) {
|
|
6903
|
+
if (multiple) {
|
|
6904
|
+
const validTokens = [];
|
|
6905
|
+
tokens.forEach((t) => {
|
|
6906
|
+
const invalidToken = invalidItems.find((i) => t.uid === i.uid);
|
|
6907
|
+
if (!invalidToken) {
|
|
6908
|
+
validTokens.push(t);
|
|
6909
|
+
}
|
|
6910
|
+
});
|
|
6911
|
+
if (validTokens.length !== tokens.length && onChange) {
|
|
6912
|
+
let validData = validTokens.map((t) => t.data);
|
|
6913
|
+
if (validData.length === 0 && Array.isArray(service.state.validDefaultValue)) {
|
|
6914
|
+
validData = service.state.validDefaultValue;
|
|
6915
|
+
}
|
|
6916
|
+
onChange(validData);
|
|
6896
6917
|
}
|
|
6897
|
-
}
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
if (
|
|
6901
|
-
|
|
6918
|
+
}
|
|
6919
|
+
else {
|
|
6920
|
+
const currentItem = service.adapt(value);
|
|
6921
|
+
if (invalidItems.find((i) => i.id === currentItem.id)) {
|
|
6922
|
+
// set the defaultValue if it's a valid value otherwise set null
|
|
6923
|
+
onChange && onChange(service.state.validDefaultValue || null);
|
|
6902
6924
|
}
|
|
6903
|
-
onChange(validData);
|
|
6904
6925
|
}
|
|
6905
6926
|
}
|
|
6906
|
-
else {
|
|
6907
|
-
|
|
6908
|
-
if (invalidItems.find((i) => i.id === currentItem.id)) {
|
|
6909
|
-
// set the defaultValue if it's a valid value otherwise set null
|
|
6910
|
-
onChange && onChange(service.state.validDefaultValue || null);
|
|
6911
|
-
}
|
|
6927
|
+
else if (!search && !nullable && !value && service.state.validDefaultValue) {
|
|
6928
|
+
onChange && onChange(service.state.validDefaultValue);
|
|
6912
6929
|
}
|
|
6913
6930
|
}
|
|
6914
|
-
else if (!search && !nullable && !value && service.state.validDefaultValue) {
|
|
6915
|
-
onChange && onChange(service.state.validDefaultValue);
|
|
6916
|
-
}
|
|
6917
6931
|
}, [
|
|
6918
6932
|
service,
|
|
6919
6933
|
multiple,
|
|
@@ -6923,6 +6937,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
|
|
|
6923
6937
|
service.state.invalidItems,
|
|
6924
6938
|
service.state.validDefaultValue,
|
|
6925
6939
|
nullable,
|
|
6940
|
+
validateValue,
|
|
6926
6941
|
]);
|
|
6927
6942
|
const onInputChange = (nextValue) => {
|
|
6928
6943
|
showActiveRef.current = false;
|
|
@@ -12357,7 +12372,7 @@ exports.NotificationComponent = NotificationComponent;
|
|
|
12357
12372
|
exports.Notifications = Notifications;
|
|
12358
12373
|
exports.NotificationsComponent = NotificationsComponent;
|
|
12359
12374
|
exports.Password = Password;
|
|
12360
|
-
exports.PasswordComponent = PasswordComponent;
|
|
12375
|
+
exports.PasswordComponent = PasswordComponent$1;
|
|
12361
12376
|
exports.Properties = Properties;
|
|
12362
12377
|
exports.PropertiesComponent = PropertiesComponent;
|
|
12363
12378
|
exports.Property = Property;
|