pge-front-common 14.0.50 → 14.0.51
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/lib/index.esm.js +62 -14
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +62 -14
- package/lib/index.js.map +1 -1
- package/lib/utils/useDarkMode.d.ts +1 -0
- package/lib/utils/useIsMobile.d.ts +1 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -8568,26 +8568,71 @@ var SelectMult = function (_a) {
|
|
|
8568
8568
|
!hasError && message && React.createElement("p", { className: styles$g.message }, message)));
|
|
8569
8569
|
};
|
|
8570
8570
|
|
|
8571
|
-
var css_248z$f = ".styles-module__selectContainer___uFP2d {\r\n width: 100%;\r\n display: flex;\r\n flex-direction: column;\r\n gap: 8px;\r\n}\r\n\r\n.styles-module__selectContainer___uFP2d label {\r\n font-size: var(--font-size-16);\r\n font-weight: 700;\r\n line-height: 24px;\r\n color: var(--color-label);\r\n}\r\n\r\n@media (max-width: 480px) {\r\n .styles-module__selectContainer___uFP2d label {\r\n font-size: var(--font-size-
|
|
8571
|
+
var css_248z$f = ".styles-module__selectContainer___uFP2d {\r\n width: 100%;\r\n display: flex;\r\n flex-direction: column;\r\n gap: 8px;\r\n}\r\n\r\n.styles-module__selectContainer___uFP2d label {\r\n font-size: var(--font-size-16);\r\n font-weight: 700;\r\n line-height: 24px;\r\n color: var(--color-label);\r\n}\r\n\r\n@media (max-width: 480px) {\r\n .styles-module__selectContainer___uFP2d label {\r\n font-size: var(--font-size-12);\r\n }\r\n}\r\n\r\n.styles-module__errorText___grCcq {\r\n font-size: var(--font-size-12);\r\n font-weight: 700;\r\n line-height: 15px;\r\n text-align: left;\r\n color: var(--color-danger);\r\n margin-left: 8px;\r\n}\r\n\r\n.styles-module__errorRequired___PNeLN {\r\n font-size: var(--font-size-16);\r\n font-weight: 700;\r\n line-height: 24px;\r\n text-align: left;\r\n color: var(--color-danger);\r\n}\r\n\r\n.styles-module__contentIcon___SAMFM {\r\n display: flex;\r\n align-items: center;\r\n padding: 8px;\r\n}\r\n\r\n.styles-module__iconChefron___Cp81j {\r\n color: var(--color-label);\r\n}\r\n";
|
|
8572
8572
|
var styles$f = {"selectContainer":"styles-module__selectContainer___uFP2d","errorText":"styles-module__errorText___grCcq","errorRequired":"styles-module__errorRequired___PNeLN","contentIcon":"styles-module__contentIcon___SAMFM","iconChefron":"styles-module__iconChefron___Cp81j"};
|
|
8573
8573
|
styleInject(css_248z$f);
|
|
8574
8574
|
|
|
8575
|
-
|
|
8575
|
+
function useDarkMode() {
|
|
8576
|
+
var isClient = typeof document !== 'undefined';
|
|
8577
|
+
var _a = React.useState(function () { return isClient && document.body.classList.contains('dark-mode'); }), isDarkMode = _a[0], setIsDarkMode = _a[1];
|
|
8578
|
+
React.useEffect(function () {
|
|
8579
|
+
if (!isClient)
|
|
8580
|
+
return;
|
|
8581
|
+
var updateDarkMode = function (mutationsList) {
|
|
8582
|
+
for (var _i = 0, mutationsList_1 = mutationsList; _i < mutationsList_1.length; _i++) {
|
|
8583
|
+
var mutation = mutationsList_1[_i];
|
|
8584
|
+
if (mutation.type === 'attributes' &&
|
|
8585
|
+
mutation.attributeName === 'class') {
|
|
8586
|
+
setIsDarkMode(document.body.classList.contains('dark-mode'));
|
|
8587
|
+
}
|
|
8588
|
+
}
|
|
8589
|
+
};
|
|
8590
|
+
var observer = new MutationObserver(updateDarkMode);
|
|
8591
|
+
observer.observe(document.body, {
|
|
8592
|
+
attributes: true,
|
|
8593
|
+
attributeFilter: ['class'],
|
|
8594
|
+
});
|
|
8595
|
+
return function () { return observer.disconnect(); };
|
|
8596
|
+
}, [isClient]);
|
|
8597
|
+
return isDarkMode;
|
|
8598
|
+
}
|
|
8599
|
+
|
|
8600
|
+
function useIsMobile(breakpoint) {
|
|
8601
|
+
if (breakpoint === void 0) { breakpoint = 480; }
|
|
8602
|
+
var _a = React.useState(function () {
|
|
8603
|
+
if (typeof window === 'undefined')
|
|
8604
|
+
return false;
|
|
8605
|
+
return window.innerWidth <= breakpoint;
|
|
8606
|
+
}), isMobile = _a[0], setIsMobile = _a[1];
|
|
8607
|
+
React.useEffect(function () {
|
|
8608
|
+
function handleResize() {
|
|
8609
|
+
setIsMobile(window.innerWidth <= breakpoint);
|
|
8610
|
+
}
|
|
8611
|
+
window.addEventListener('resize', handleResize);
|
|
8612
|
+
handleResize();
|
|
8613
|
+
return function () { return window.removeEventListener('resize', handleResize); };
|
|
8614
|
+
}, [breakpoint]);
|
|
8615
|
+
return isMobile;
|
|
8616
|
+
}
|
|
8617
|
+
|
|
8618
|
+
var selectColourStyles$1 = function (isInvalid, isDarkMode, isMobile) { return ({
|
|
8576
8619
|
control: function (styles, _a) {
|
|
8577
8620
|
var isFocused = _a.isFocused;
|
|
8578
8621
|
return (__assign(__assign({}, styles), { alignItems: "center", cursor: "pointer", display: "flex", flexWrap: "wrap", justifyContent: "space-between", minHeight: "48px", outline: "0", position: "relative", transition: "all 100ms", borderColor: isInvalid ? "#CB0A0A" : isFocused ? "#1a95b0" : "#cfcfcffc", borderRadius: "9px", borderStyle: "solid", borderWidth: "1px", boxSizing: "border-box", boxShadow: isInvalid
|
|
8579
8622
|
? "0px 0px 0px 2px #DC354580"
|
|
8580
8623
|
: isFocused
|
|
8581
8624
|
? "0px 0px 0px 2px #0091ea80"
|
|
8582
|
-
: "0px hsl(0, 0%, 96%)", backgroundColor: "
|
|
8625
|
+
: "0px hsl(0, 0%, 96%)", backgroundColor: isDarkMode ? "#2D2D2E" : "#fff" }));
|
|
8583
8626
|
},
|
|
8584
8627
|
option: function (styles, _a) {
|
|
8585
|
-
var isDisabled = _a.isDisabled,
|
|
8586
|
-
return (__assign(__assign({}, styles), { cursor: isDisabled ? "not-allowed" : "default", color: isDisabled ? "white" : "#303030CC", backgroundColor:
|
|
8587
|
-
? "#
|
|
8588
|
-
:
|
|
8589
|
-
|
|
8590
|
-
: "
|
|
8628
|
+
var isDisabled = _a.isDisabled, isFocused = _a.isFocused;
|
|
8629
|
+
return (__assign(__assign({}, styles), { cursor: isDisabled ? "not-allowed" : "default", color: isDisabled ? "white" : isDarkMode ? "#fff" : "#303030CC", backgroundColor: isDarkMode
|
|
8630
|
+
? isFocused ? "#303030" : "#4B4B4C"
|
|
8631
|
+
: isFocused ? "#005A921A" : "#fff", fontSize: isMobile ? "12px" : "14px", ":hover": {
|
|
8632
|
+
backgroundColor: isDarkMode
|
|
8633
|
+
? isFocused ? "#303030" : "#4B4B4C"
|
|
8634
|
+
: isFocused ? "#005A921A" : "#fff",
|
|
8635
|
+
} }));
|
|
8591
8636
|
},
|
|
8592
8637
|
multiValue: function (styles) { return (__assign(__assign({}, styles), { backgroundColor: "#005a921a", borderRadius: "9px" })); },
|
|
8593
8638
|
multiValueLabel: function (styles) { return (__assign(__assign({}, styles), { color: "#30303090" })); },
|
|
@@ -8595,24 +8640,27 @@ var selectColourStyles$1 = function (isInvalid) { return ({
|
|
|
8595
8640
|
backgroundColor: "#005a921a",
|
|
8596
8641
|
color: "#30303090",
|
|
8597
8642
|
} })); },
|
|
8598
|
-
placeholder: function (styles) { return (__assign(__assign({}, styles), { color: isInvalid ? "#CB0A0A" : "#30303066", fontSize: "14px", fontWeight: "700", lineHeight: "24px" })); },
|
|
8599
|
-
singleValue: function (styles) { return (__assign(__assign({}, styles), { color: isInvalid ? "#CB0A0A" : "#303030CC", fontSize: "14px", fontWeight: "700", lineHeight: "24px" })); },
|
|
8643
|
+
placeholder: function (styles) { return (__assign(__assign({}, styles), { color: isInvalid ? "#CB0A0A" : isDarkMode ? "#fff" : "#30303066", fontSize: isMobile ? "12px" : "14px", fontWeight: "700", lineHeight: "24px" })); },
|
|
8644
|
+
singleValue: function (styles) { return (__assign(__assign({}, styles), { color: isInvalid ? "#CB0A0A" : isDarkMode ? "#fff" : "#303030CC", fontSize: isMobile ? "12px" : "14px", fontWeight: "700", lineHeight: "24px" })); },
|
|
8600
8645
|
indicatorSeparator: function (styles, _a) {
|
|
8601
8646
|
var hasValue = _a.hasValue;
|
|
8602
8647
|
return (__assign(__assign({}, styles), { display: hasValue ? "block" : "none" }));
|
|
8603
8648
|
},
|
|
8649
|
+
menu: function (base) { return (__assign(__assign({}, base), { backgroundColor: isDarkMode ? "#2D2D2E" : "#fff", borderRadius: "8px" })); },
|
|
8650
|
+
menuList: function (base) { return (__assign(__assign({}, base), { backgroundColor: isDarkMode ? "#4B4B4C" : "#fff", padding: "0.5rem 0", borderRadius: "8px" })); },
|
|
8604
8651
|
}); };
|
|
8605
8652
|
var BasicSelect = function (_a) {
|
|
8606
8653
|
var name = _a.name, optionsSelect = _a.optionsSelect, placeholder = _a.placeholder, _b = _a.isDisabled, isDisabled = _b === void 0 ? false : _b, label = _a.label, _c = _a.hasError, hasError = _c === void 0 ? false : _c, handleChange = _a.handleChange, isRequired = _a.isRequired, value = _a.value;
|
|
8654
|
+
var isDarkMode = useDarkMode();
|
|
8655
|
+
var isMobile = useIsMobile();
|
|
8607
8656
|
var CustomDropdownIndicator = function () { return (React__namespace.createElement("div", { className: styles$f.contentIcon },
|
|
8608
8657
|
React__namespace.createElement(IconTriangleRecall, { className: styles$f.iconChefron }))); };
|
|
8609
8658
|
return (React__namespace.createElement("div", { className: "".concat(styles$f.selectContainer) },
|
|
8610
|
-
label && (React__namespace.createElement("label", { htmlFor: name },
|
|
8659
|
+
label && (React__namespace.createElement("label", { htmlFor: name, className: styles$f.labelText },
|
|
8611
8660
|
label,
|
|
8612
|
-
" ",
|
|
8613
8661
|
isRequired ? React__namespace.createElement("span", { className: styles$f.errorRequired }, "*") : null)),
|
|
8614
8662
|
React__namespace.createElement("div", { className: styles$f.selectElement },
|
|
8615
|
-
React__namespace.createElement(StateManagedSelect$1, { inputId: name, isMulti: false, isDisabled: isDisabled, options: optionsSelect, value: optionsSelect.find(function (opt) { return opt.value === value; }) || value, onChange: handleChange, placeholder: placeholder, styles: selectColourStyles$1(hasError), isClearable: true, isSearchable: true, noOptionsMessage: function () { return "Nenhuma opção disponível"; }, components: { DropdownIndicator: CustomDropdownIndicator }, "aria-label": typeof label === 'string' ? label : (placeholder || "Campo para seleção") })),
|
|
8663
|
+
React__namespace.createElement(StateManagedSelect$1, { inputId: name, isMulti: false, isDisabled: isDisabled, options: optionsSelect, value: optionsSelect.find(function (opt) { return opt.value === value; }) || value, onChange: handleChange, placeholder: placeholder, styles: selectColourStyles$1(hasError, isDarkMode, isMobile), isClearable: true, isSearchable: true, noOptionsMessage: function () { return "Nenhuma opção disponível"; }, components: { DropdownIndicator: CustomDropdownIndicator }, "aria-label": typeof label === 'string' ? label : (placeholder || "Campo para seleção") })),
|
|
8616
8664
|
hasError && (React__namespace.createElement("span", { className: styles$f.errorText }, "Campo obrigat\u00F3rio ou inv\u00E1lido"))));
|
|
8617
8665
|
};
|
|
8618
8666
|
|