@typeolymp/ui-components 2.1.15 → 2.2.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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { Locale } from "@typeolymp/utils/enums";
|
|
3
3
|
export declare type PropsType = {
|
|
4
|
-
|
|
4
|
+
iconOnly?: boolean;
|
|
5
|
+
reverse?: boolean;
|
|
5
6
|
locales: Locale[];
|
|
6
7
|
defaultValue: Locale;
|
|
7
8
|
onChange(locale: Locale): void;
|
package/build/index.es.js
CHANGED
|
@@ -4225,13 +4225,13 @@ var StyledInput = styled.input(templateObject_3$f || (templateObject_3$f = __mak
|
|
|
4225
4225
|
var disabled = _a.disabled;
|
|
4226
4226
|
return disabled ? theme.colors.darkGray.light : theme.colors.darkGray.base;
|
|
4227
4227
|
}, theme.fonts.paragraph, theme.paragraph.medium.fontSize, theme.paragraph.medium.lineHeight, theme.colors.lightGray.darker, theme.colors.blue.dark, "0 0 0 1px ".concat(theme.colors.blue.dark));
|
|
4228
|
-
var HelperContainer = styled.div(templateObject_4$
|
|
4228
|
+
var HelperContainer = styled.div(templateObject_4$6 || (templateObject_4$6 = __makeTemplateObject$1(["\n margin-top: 5px;\n padding-left: 5px;\n"], ["\n margin-top: 5px;\n padding-left: 5px;\n"])));
|
|
4229
4229
|
var fadeIn = keyframes$1(templateObject_5$3 || (templateObject_5$3 = __makeTemplateObject$1(["\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n"], ["\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n"])));
|
|
4230
4230
|
var Helper = styled(StyledParagraph)(templateObject_6$3 || (templateObject_6$3 = __makeTemplateObject$1(["\n font-weight: 400;\n font-size: 14px;\n color: ", ";\n animation: ", " 0.3s linear;\n"], ["\n font-weight: 400;\n font-size: 14px;\n color: ", ";\n animation: ", " 0.3s linear;\n"])), function (_a) {
|
|
4231
4231
|
var isOk = _a.isOk;
|
|
4232
4232
|
return isOk ? theme.colors.green.base : theme.colors.darkGray.light;
|
|
4233
4233
|
}, fadeIn);
|
|
4234
|
-
var templateObject_1$N, templateObject_2$B, templateObject_3$f, templateObject_4$
|
|
4234
|
+
var templateObject_1$N, templateObject_2$B, templateObject_3$f, templateObject_4$6, templateObject_5$3, templateObject_6$3;
|
|
4235
4235
|
|
|
4236
4236
|
var expressions = {};
|
|
4237
4237
|
|
|
@@ -14686,11 +14686,11 @@ htmlReactParser.Text;
|
|
|
14686
14686
|
var Fieldset$1 = styled.fieldset(templateObject_1$A || (templateObject_1$A = __makeTemplateObject$1(["\n border: 0;\n margin: 0;\n padding: 0;\n"], ["\n border: 0;\n margin: 0;\n padding: 0;\n"])));
|
|
14687
14687
|
var CheckboxContainer = styled.div(templateObject_2$w || (templateObject_2$w = __makeTemplateObject$1(["\n margin-top: 5px;\n"], ["\n margin-top: 5px;\n"])));
|
|
14688
14688
|
var CheckboxWrapper = styled.div(templateObject_3$d || (templateObject_3$d = __makeTemplateObject$1(["\n display: flex;\n align-items: center;\n\n > div:first-child {\n margin-right: 10px;\n }\n\n :not(:last-child) {\n margin-bottom: 20px;\n }\n"], ["\n display: flex;\n align-items: center;\n\n > div:first-child {\n margin-right: 10px;\n }\n\n :not(:last-child) {\n margin-bottom: 20px;\n }\n"])));
|
|
14689
|
-
var Label$b = styled(StyledParagraph)(templateObject_4$
|
|
14689
|
+
var Label$b = styled(StyledParagraph)(templateObject_4$5 || (templateObject_4$5 = __makeTemplateObject$1(["\n font-weight: ", ";\n color: ", ";\n display: flex;\n flex-wrap: wrap;\n gap: 0 6px;\n align-items: center;\n cursor: pointer;\n\n a {\n color: ", ";\n }\n"], ["\n font-weight: ", ";\n color: ", ";\n display: flex;\n flex-wrap: wrap;\n gap: 0 6px;\n align-items: center;\n cursor: pointer;\n\n a {\n color: ", ";\n }\n"])), function (_a) {
|
|
14690
14690
|
var weight = _a.weight;
|
|
14691
14691
|
return weight || 500;
|
|
14692
14692
|
}, theme.colors.darkGray.base, theme.colors.blue.base);
|
|
14693
|
-
var templateObject_1$A, templateObject_2$w, templateObject_3$d, templateObject_4$
|
|
14693
|
+
var templateObject_1$A, templateObject_2$w, templateObject_3$d, templateObject_4$5;
|
|
14694
14694
|
|
|
14695
14695
|
var Checkboxes = function (props) {
|
|
14696
14696
|
var _a = useState(props.defaultValue || []), values = _a[0], setValues = _a[1];
|
|
@@ -17690,43 +17690,54 @@ __exportStar(getPricing$1, exports);
|
|
|
17690
17690
|
|
|
17691
17691
|
}(mappers));
|
|
17692
17692
|
|
|
17693
|
-
var Container$d = styled.div(templateObject_1$o || (templateObject_1$o = __makeTemplateObject$1(["\n
|
|
17694
|
-
var
|
|
17695
|
-
if (
|
|
17696
|
-
|
|
17697
|
-
|
|
17698
|
-
|
|
17699
|
-
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
|
|
17703
|
-
|
|
17704
|
-
|
|
17705
|
-
|
|
17706
|
-
|
|
17707
|
-
|
|
17708
|
-
var
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
var LocaleWrapper = styled.div(templateObject_4$5 || (templateObject_4$5 = __makeTemplateObject$1(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 10px 15px;\n\n :not(:last-child) {\n border-bottom: 1px solid ", ";\n }\n\n > div:first-child {\n display: flex;\n align-items: center;\n margin-right: 10px;\n }\n\n p {\n white-space: nowrap;\n }\n\n :hover {\n cursor: pointer;\n background-color: ", ";\n\n p {\n color: ", ";\n }\n svg {\n fill: ", ";\n }\n }\n"], ["\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 10px 15px;\n\n :not(:last-child) {\n border-bottom: 1px solid ", ";\n }\n\n > div:first-child {\n display: flex;\n align-items: center;\n margin-right: 10px;\n }\n\n p {\n white-space: nowrap;\n }\n\n :hover {\n cursor: pointer;\n background-color: ", ";\n\n p {\n color: ", ";\n }\n svg {\n fill: ", ";\n }\n }\n"])), theme.colors.lightGray.darker, theme.colors.lightGray.base, theme.colors.blue.base, theme.colors.blue.base);
|
|
17718
|
-
var templateObject_1$o, templateObject_2$m, templateObject_3$a, templateObject_4$5;
|
|
17693
|
+
var Container$d = styled.div(templateObject_1$o || (templateObject_1$o = __makeTemplateObject$1(["\n background-color: ", ";\n border-radius: 6px;\n border: ", ";\n box-shadow: ", ";\n overflow: hidden;\n\n display: flex;\n flex-direction: ", ";\n\n > button:first-child {\n all: unset;\n width: 100%;\n display: flex;\n align-items: center;\n gap: 10px;\n\n padding: 10px 15px;\n\n svg {\n pointer-events: none;\n }\n\n > div:last-child {\n transition: transform 0.3s ease;\n transform: ", ";\n }\n\n :hover {\n cursor: pointer;\n background-color: ", ";\n }\n }\n"], ["\n background-color: ", ";\n border-radius: 6px;\n border: ", ";\n box-shadow: ", ";\n overflow: hidden;\n\n display: flex;\n flex-direction: ", ";\n\n > button:first-child {\n all: unset;\n width: 100%;\n display: flex;\n align-items: center;\n gap: 10px;\n\n padding: 10px 15px;\n\n svg {\n pointer-events: none;\n }\n\n > div:last-child {\n transition: transform 0.3s ease;\n transform: ", ";\n }\n\n :hover {\n cursor: pointer;\n background-color: ", ";\n }\n }\n"])), function (_a) {
|
|
17694
|
+
var borderless = _a.borderless;
|
|
17695
|
+
if (borderless)
|
|
17696
|
+
return "transparent";
|
|
17697
|
+
return theme.colors.lightGray.light;
|
|
17698
|
+
}, function (_a) {
|
|
17699
|
+
var borderless = _a.borderless;
|
|
17700
|
+
return borderless ? "" : "1px solid ".concat(theme.colors.lightGray.dark);
|
|
17701
|
+
}, function (_a) {
|
|
17702
|
+
var borderless = _a.borderless;
|
|
17703
|
+
return borderless ? "" : "0px 2px 0px rgb(0 0 0 / 10%)";
|
|
17704
|
+
}, function (_a) {
|
|
17705
|
+
var reverse = _a.reverse;
|
|
17706
|
+
return reverse ? "column-reverse" : "column";
|
|
17707
|
+
}, function (_a) {
|
|
17708
|
+
var open = _a.open;
|
|
17709
|
+
return (open ? "rotate(180deg)" : "");
|
|
17710
|
+
}, theme.colors.lightGray.base);
|
|
17711
|
+
var LocalesList = styled.ul(templateObject_2$m || (templateObject_2$m = __makeTemplateObject$1(["\n list-style: none;\n margin: 0;\n padding: 0;\n\n // background-color: ", ";\n // border: 1px solid ", ";\n // border-radius: 0 0 6px 6px;\n // box-shadow: 0px 2px 0px rgb(0 0 0 / 10%);\n\n // overflow: hidden;\n"], ["\n list-style: none;\n margin: 0;\n padding: 0;\n\n // background-color: ", ";\n // border: 1px solid ", ";\n // border-radius: 0 0 6px 6px;\n // box-shadow: 0px 2px 0px rgb(0 0 0 / 10%);\n\n // overflow: hidden;\n"])), theme.colors.lightGray.light, theme.colors.lightGray.dark);
|
|
17712
|
+
var LocalesListItem = styled.li(templateObject_3$a || (templateObject_3$a = __makeTemplateObject$1(["\n // min-width: max-content;\n\n display: ", ";\n align-items: center;\n gap: 10px;\n\n // background-color: ", ";\n\n padding: 13px 15px;\n cursor: pointer;\n\n :hover {\n background-color: ", ";\n }\n"], ["\n // min-width: max-content;\n\n display: ", ";\n align-items: center;\n gap: 10px;\n\n // background-color: ", ";\n\n padding: 13px 15px;\n cursor: pointer;\n\n :hover {\n background-color: ", ";\n }\n"])), function (_a) {
|
|
17713
|
+
var hidden = _a.hidden;
|
|
17714
|
+
return (hidden ? "none" : "flex");
|
|
17715
|
+
}, theme.colors.lightGray.light, theme.colors.lightGray.base);
|
|
17716
|
+
var templateObject_1$o, templateObject_2$m, templateObject_3$a;
|
|
17719
17717
|
|
|
17720
17718
|
var LocaleSelect = function (props) {
|
|
17721
|
-
var
|
|
17722
|
-
var
|
|
17719
|
+
var containerRef = useRef(null);
|
|
17720
|
+
var _a = useState(props.defaultValue), selectedLocale = _a[0], setSelectedLocale = _a[1];
|
|
17721
|
+
var _b = useState(false), open = _b[0], setOpen = _b[1];
|
|
17722
|
+
var handleClickOutside = useCallback(function (event) {
|
|
17723
|
+
return open &&
|
|
17724
|
+
containerRef.current &&
|
|
17725
|
+
!containerRef.current.contains(event.target)
|
|
17726
|
+
? setOpen(false)
|
|
17727
|
+
: null;
|
|
17728
|
+
}, [open, containerRef]);
|
|
17729
|
+
useEffect(function () {
|
|
17730
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
17731
|
+
return function () {
|
|
17732
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
17733
|
+
};
|
|
17734
|
+
}, [handleClickOutside]);
|
|
17723
17735
|
var onSelectLocale = function (locale) {
|
|
17724
|
-
|
|
17736
|
+
setSelectedLocale(locale);
|
|
17725
17737
|
props.onChange(locale);
|
|
17738
|
+
setOpen(false);
|
|
17726
17739
|
};
|
|
17727
|
-
return (jsxs(Container$d, __assign$2({
|
|
17728
|
-
.filter(function (l) { return l !== locale; })
|
|
17729
|
-
.map(function (locale) { return (jsxs(LocaleWrapper, __assign$2({ onClick: function () { return onSelectLocale(locale); } }, { children: [jsxs("div", { children: [jsx$1(Flag, { locale: locale }), jsx$1(Spacer, { horizontal: 10 }), jsx$1(Paragraph, __assign$2({ size: "small", weight: "regular", color: "darkGray" }, { children: mappers.getNativeLanguageByLocale(locale) }))] }), jsx$1(Icon, { type: "chevronRight", size: "small", color: "darkGray" })] }), locale)); }) })))] })));
|
|
17740
|
+
return (jsxs(Container$d, __assign$2({ open: open, reverse: props.reverse, ref: containerRef }, { children: [jsxs("button", __assign$2({ "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": "locales", onClick: function () { return setOpen(!open); } }, { children: [jsx$1(Flag, { locale: selectedLocale }), !props.iconOnly && (jsx$1(Heading, __assign$2({ type: "h6", as: "span" }, { children: mappers.getNativeLanguageByLocale(selectedLocale) }))), jsx$1(Icon, { type: props.reverse ? "chevronUp" : "chevronDown", size: "small", color: "lightGray" })] })), jsx$1(LocalesList, __assign$2({ hidden: !open, "aria-label": "submenu", "aria-hidden": !open, role: "listbox", id: "locales" }, { children: props.locales.map(function (locale) { return (jsxs(LocalesListItem, __assign$2({ onClick: function () { return onSelectLocale(locale); }, "data-value": locale, "aria-selected": locale === selectedLocale, hidden: locale === selectedLocale, role: "option" }, { children: [jsx$1(Flag, { locale: locale }), !props.iconOnly && (jsx$1(Heading, __assign$2({ type: "h6", as: "span" }, { children: mappers.getNativeLanguageByLocale(locale) })))] }), locale)); }) }))] })));
|
|
17730
17741
|
};
|
|
17731
17742
|
|
|
17732
17743
|
var Wrapper$1 = styled.div(templateObject_1$n || (templateObject_1$n = __makeTemplateObject$1(["\n width: 100%;\n min-width: 200px;\n display: flex;\n justify-content: space-between;\n\n > div {\n display: flex;\n align-items: center;\n }\n"], ["\n width: 100%;\n min-width: 200px;\n display: flex;\n justify-content: space-between;\n\n > div {\n display: flex;\n align-items: center;\n }\n"])));
|