@typeolymp/ui-components 1.9.7 → 1.9.9

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/build/index.js CHANGED
@@ -1273,7 +1273,7 @@ var Key$1 = function (props) { return (jsxRuntime.jsxs(Container$c, __assign({},
1273
1273
  transform: "scale(2)",
1274
1274
  } }, { children: jsxRuntime.jsx("path", { d: "M0 4.5V1C0 0.447715 0.447715 0 1 0H2C2.55228 0 3 0.447715 3 1V4H25V1C25 0.447715 25.4477 0 26 0H27C27.5523 0 28 0.447715 28 1V4.5C28 5.88071 26.8807 7 25.5 7H2.5C1.11929 7 0 5.88071 0 4.5Z" }) }))) : (jsxRuntime.jsx(Heading, __assign({ type: "h1" }, { children: props.char })))] }))); };
1275
1275
 
1276
- var Wrapper$2 = styled__default["default"].a(templateObject_1$m || (templateObject_1$m = __makeTemplateObject(["\n width: fit-content;\n display: flex;\n align-items: center;\n cursor: pointer;\n text-decoration: none;\n\n > div {\n width: 19px;\n height: 19px;\n margin-right: ", ";\n margin-left: ", ";\n }\n"], ["\n width: fit-content;\n display: flex;\n align-items: center;\n cursor: pointer;\n text-decoration: none;\n\n > div {\n width: 19px;\n height: 19px;\n margin-right: ", ";\n margin-left: ", ";\n }\n"])), function (_a) {
1276
+ var Wrapper$2 = styled__default["default"].a(templateObject_1$m || (templateObject_1$m = __makeTemplateObject(["\n width: fit-content;\n display: flex;\n align-items: center;\n cursor: pointer;\n text-decoration: none;\n\n > div {\n width: 19px;\n height: 19px;\n margin-top: 3px;\n margin-right: ", ";\n margin-left: ", ";\n }\n"], ["\n width: fit-content;\n display: flex;\n align-items: center;\n cursor: pointer;\n text-decoration: none;\n\n > div {\n width: 19px;\n height: 19px;\n margin-top: 3px;\n margin-right: ", ";\n margin-left: ", ";\n }\n"])), function (_a) {
1277
1277
  var chevron = _a.chevron;
1278
1278
  return (chevron === "left" ? "4px" : "");
1279
1279
  }, function (_a) {
@@ -2143,15 +2143,21 @@ var Indicator = styled__default["default"].div(templateObject_3 || (templateObje
2143
2143
  var value = _a.value;
2144
2144
  return "".concat(value, "%");
2145
2145
  });
2146
- var Target = styled__default["default"].div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: fit-content;\n position: absolute;\n left: ", ";\n bottom: 40px;\n\n p {\n color: ", ";\n }\n"], ["\n width: fit-content;\n position: absolute;\n left: ", ";\n bottom: 40px;\n\n p {\n color: ", ";\n }\n"])), function (_a) {
2147
- var value = _a.value;
2148
- return "calc(".concat(value, "% - 6px)");
2146
+ var Target = styled__default["default"].div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: max-content;\n position: absolute;\n left: ", ";\n bottom: 40px;\n\n p {\n color: ", ";\n }\n"], ["\n width: max-content;\n position: absolute;\n left: ", ";\n bottom: 40px;\n\n p {\n color: ", ";\n }\n"])), function (_a) {
2147
+ var value = _a.value, width = _a.width;
2148
+ return "calc(".concat(value, "% - ").concat(width / 2, "px)");
2149
2149
  }, theme.colors.blue.darker);
2150
2150
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
2151
2151
 
2152
2152
  var Result = function (props) {
2153
+ var ref = React.useRef(null);
2154
+ var _a = React.useState(0), targetWidth = _a[0], setTargetWidth = _a[1];
2153
2155
  var isPassed = props.value >= props.target;
2154
- return (jsxRuntime.jsxs(Container, __assign({ passed: isPassed }, { children: [jsxRuntime.jsx(Icon, { type: isPassed ? "check" : "warning", color: isPassed ? "green" : "red", size: "large" }), jsxRuntime.jsx(Spacer, { horizontal: 15 }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Heading, __assign({ type: "h5" }, { children: props.title })), jsxRuntime.jsx(Paragraph, { children: props.subtitle })] }), props.progressBar && (jsxRuntime.jsxs(ProgressBarWrapper, { children: [jsxRuntime.jsx(Indicator, { value: (props.target / props.progressBar.max) * 100 }), jsxRuntime.jsx(Target, __assign({ value: (props.target / props.progressBar.max) * 100 }, { children: jsxRuntime.jsxs(Paragraph, __assign({ size: "small" }, { children: [props.target, props.progressBar.unit] })) })), jsxRuntime.jsx(ProgressBar, { percent: (props.value / props.progressBar.max) * 100, color: isPassed ? "green" : "red" }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs(Paragraph, __assign({ size: "small" }, { children: [props.progressBar.min, props.progressBar.unit] })), jsxRuntime.jsxs(Paragraph, __assign({ size: "small" }, { children: [props.progressBar.max, props.progressBar.unit] }))] })] }))] })));
2156
+ React.useEffect(function () {
2157
+ var _a;
2158
+ setTargetWidth((_a = ref.current) === null || _a === void 0 ? void 0 : _a.offsetWidth);
2159
+ }, [ref]);
2160
+ return (jsxRuntime.jsxs(Container, __assign({ passed: isPassed }, { children: [jsxRuntime.jsx(Icon, { type: isPassed ? "check" : "warning", color: isPassed ? "green" : "red", size: "large" }), jsxRuntime.jsx(Spacer, { horizontal: 15 }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Heading, __assign({ type: "h5" }, { children: props.title })), jsxRuntime.jsx(Paragraph, { children: props.subtitle })] }), props.progressBar && (jsxRuntime.jsxs(ProgressBarWrapper, { children: [jsxRuntime.jsx(Indicator, { value: (props.target / props.progressBar.max) * 100 }), jsxRuntime.jsx(Target, __assign({ value: (props.target / props.progressBar.max) * 100, width: targetWidth, ref: ref }, { children: jsxRuntime.jsxs(Paragraph, __assign({ size: "small" }, { children: [props.target, props.progressBar.unit] })) })), jsxRuntime.jsx(ProgressBar, { percent: (props.value / props.progressBar.max) * 100, color: isPassed ? "green" : "red" }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs(Paragraph, __assign({ size: "small" }, { children: [props.progressBar.min, props.progressBar.unit] })), jsxRuntime.jsxs(Paragraph, __assign({ size: "small" }, { children: [props.progressBar.max, props.progressBar.unit] }))] })] }))] })));
2155
2161
  };
2156
2162
 
2157
2163
  exports.Alert = Alert;