@grazziotin/react-components-next 1.0.1 → 2.1.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.
- package/dist/accessibility/index.d.mts +136 -0
- package/dist/accessibility/index.d.ts +136 -0
- package/dist/accessibility/index.js +138 -0
- package/dist/accessibility/index.js.map +1 -0
- package/dist/accessibility/index.mjs +127 -0
- package/dist/accessibility/index.mjs.map +1 -0
- package/dist/{chunk-4DIPDYEU.mjs → chunk-BWW3F4R4.mjs} +42 -3
- package/dist/chunk-BWW3F4R4.mjs.map +1 -0
- package/dist/functions/index.d.mts +36 -1
- package/dist/functions/index.d.ts +36 -1
- package/dist/functions/index.js +36 -0
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/ui/index.d.mts +210 -4
- package/dist/ui/index.d.ts +210 -4
- package/dist/ui/index.js +500 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +888 -2
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +8 -9
- package/dist/chunk-4DIPDYEU.mjs.map +0 -1
- package/dist/chunk-XNWAGZVV.mjs +0 -467
- package/dist/chunk-XNWAGZVV.mjs.map +0 -1
- package/dist/index.d.mts +0 -10
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -582
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -29
- package/dist/index.mjs.map +0 -1
package/dist/ui/index.js
CHANGED
|
@@ -11,6 +11,10 @@ var DialogActions = require('@mui/material/DialogActions');
|
|
|
11
11
|
var DialogContent = require('@mui/material/DialogContent');
|
|
12
12
|
var locales = require('@mui/x-data-grid/locales');
|
|
13
13
|
var xDataGrid = require('@mui/x-data-grid');
|
|
14
|
+
var react = require('react');
|
|
15
|
+
var md = require('react-icons/md');
|
|
16
|
+
var Autocomplete = require('@mui/material/Autocomplete');
|
|
17
|
+
var fa = require('react-icons/fa');
|
|
14
18
|
|
|
15
19
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
20
|
|
|
@@ -18,6 +22,7 @@ var DialogMui__default = /*#__PURE__*/_interopDefault(DialogMui);
|
|
|
18
22
|
var DialogTitle__default = /*#__PURE__*/_interopDefault(DialogTitle);
|
|
19
23
|
var DialogActions__default = /*#__PURE__*/_interopDefault(DialogActions);
|
|
20
24
|
var DialogContent__default = /*#__PURE__*/_interopDefault(DialogContent);
|
|
25
|
+
var Autocomplete__default = /*#__PURE__*/_interopDefault(Autocomplete);
|
|
21
26
|
|
|
22
27
|
var __defProp = Object.defineProperty;
|
|
23
28
|
var __defProps = Object.defineProperties;
|
|
@@ -53,6 +58,78 @@ var __objRest = (source, exclude) => {
|
|
|
53
58
|
function cn(...values) {
|
|
54
59
|
return tailwindMerge.twMerge(clsx.clsx(values));
|
|
55
60
|
}
|
|
61
|
+
|
|
62
|
+
// src/core/remove-digits.ts
|
|
63
|
+
function removeDigits(value) {
|
|
64
|
+
return value.replace(/\D/g, "");
|
|
65
|
+
}
|
|
66
|
+
function removeNonDigits(value) {
|
|
67
|
+
return value.replaceAll(/\d/g, "");
|
|
68
|
+
}
|
|
69
|
+
function removeTextOnly(value) {
|
|
70
|
+
return value.replaceAll(/[^\p{L}]/gu, "");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/functions/format-cpf-cnpj/format-cpf-cnpj.ts
|
|
74
|
+
function formatCpfCnpj(data) {
|
|
75
|
+
if (!data) return "";
|
|
76
|
+
const value = removeDigits(data);
|
|
77
|
+
if (!value) return "";
|
|
78
|
+
if (value.length <= 11) {
|
|
79
|
+
const cpf = value.slice(0, 11);
|
|
80
|
+
return cpf.replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d{1,2})$/, "$1-$2");
|
|
81
|
+
}
|
|
82
|
+
const cnpj = value.slice(0, 14);
|
|
83
|
+
return cnpj.replace(/^(\d{2})(\d)/, "$1.$2").replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3").replace(/\.(\d{3})(\d)/, ".$1/$2").replace(/(\d{4})(\d)/, "$1-$2");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/functions/format-phone-br/format-phone-br.ts
|
|
87
|
+
function formatPhoneBr(phone) {
|
|
88
|
+
if (!phone) return "";
|
|
89
|
+
const digits = removeDigits(phone).slice(0, 11);
|
|
90
|
+
if (!digits) return "";
|
|
91
|
+
if (digits.length <= 2) return digits;
|
|
92
|
+
if (digits.length <= 6) {
|
|
93
|
+
return digits.replace(/(\d{2})(\d+)/, "($1) $2");
|
|
94
|
+
}
|
|
95
|
+
if (digits.length <= 10) {
|
|
96
|
+
return digits.replace(/(\d{2})(\d{4})(\d+)/, "($1) $2-$3");
|
|
97
|
+
}
|
|
98
|
+
return digits.replace(/(\d{2})(\d{5})(\d+)/, "($1) $2-$3");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/functions/format-price-brl/format-price-brl.ts
|
|
102
|
+
function formatPriceBrl(value) {
|
|
103
|
+
if (value === void 0 || value === null) return "";
|
|
104
|
+
if (typeof value === "string") {
|
|
105
|
+
const digits = removeDigits(value);
|
|
106
|
+
if (!digits) return "";
|
|
107
|
+
const price = Number(digits) / 100;
|
|
108
|
+
if (Number.isNaN(price)) return "";
|
|
109
|
+
return price.toLocaleString("pt-BR", {
|
|
110
|
+
style: "currency",
|
|
111
|
+
currency: "BRL"
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (Number.isNaN(value)) return "";
|
|
115
|
+
return value.toLocaleString("pt-BR", { style: "currency", currency: "BRL" });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// src/functions/format-item-170/format-item-170.ts
|
|
119
|
+
function formatItem170(item) {
|
|
120
|
+
if (!item) return "";
|
|
121
|
+
const digits = removeDigits(item).slice(0, 12);
|
|
122
|
+
if (!digits) return "";
|
|
123
|
+
return digits.replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{2})\.(\d)(\d{1,3})$/, "$1.$2.$3");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/functions/format-item-150/format-item-150.ts
|
|
127
|
+
function formatItem150(item) {
|
|
128
|
+
if (!item) return "";
|
|
129
|
+
const digits = removeDigits(item).slice(0, 10);
|
|
130
|
+
if (!digits) return "";
|
|
131
|
+
return digits.replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{2})\.(\d)(\d{1,3})$/, "$1.$2.$3");
|
|
132
|
+
}
|
|
56
133
|
function Card({
|
|
57
134
|
margin,
|
|
58
135
|
onClick,
|
|
@@ -506,10 +583,433 @@ var Tab = material.styled(material.Tab, {
|
|
|
506
583
|
})
|
|
507
584
|
);
|
|
508
585
|
|
|
586
|
+
// src/core/css-var.ts
|
|
587
|
+
function withCssVar(style, name, value) {
|
|
588
|
+
if (value == null || value === "") return style;
|
|
589
|
+
return __spreadProps(__spreadValues({}, style), { [name]: value });
|
|
590
|
+
}
|
|
591
|
+
var DEFAULT_ACCENT = "var(--primary-color)";
|
|
592
|
+
var accent = "var(--primary-color)";
|
|
593
|
+
var errorColor = "#D32F2F";
|
|
594
|
+
var focusLabel = { color: accent };
|
|
595
|
+
var errorLabel = { color: errorColor };
|
|
596
|
+
var borderAccent = { borderColor: accent };
|
|
597
|
+
var borderError = { borderColor: errorColor };
|
|
598
|
+
var underlineAccent = { borderBottomColor: accent };
|
|
599
|
+
var underlineError = { borderBottomColor: errorColor };
|
|
600
|
+
var disabledText = { color: "#9E9E9E", cursor: "not-allowed" };
|
|
601
|
+
var disabledBorder = { borderColor: "#9E9E9E", cursor: "not-allowed" };
|
|
602
|
+
var input = {
|
|
603
|
+
color: "#333",
|
|
604
|
+
fontSize: "13px !important",
|
|
605
|
+
fontFamily: "var(--font-poppins) !important"
|
|
606
|
+
};
|
|
607
|
+
var InputTextField = material.styled(material.TextField)({
|
|
608
|
+
fontFamily: "var(--font-poppins) !important",
|
|
609
|
+
"& input": input,
|
|
610
|
+
"& label": input,
|
|
611
|
+
"& label.Mui-focused": focusLabel,
|
|
612
|
+
"& label.Mui-error": errorLabel,
|
|
613
|
+
"& .MuiInput-underline:after": underlineAccent,
|
|
614
|
+
"& .MuiInput-underline.Mui-error:after": underlineError,
|
|
615
|
+
"& .MuiOutlinedInput-root": {
|
|
616
|
+
"& fieldset": borderAccent,
|
|
617
|
+
"&:hover fieldset": borderAccent,
|
|
618
|
+
"&.Mui-disabled fieldset": disabledBorder,
|
|
619
|
+
"&.Mui-focused fieldset": borderAccent,
|
|
620
|
+
"&.Mui-error fieldset": borderError,
|
|
621
|
+
"&.Mui-error:hover fieldset": borderError,
|
|
622
|
+
"&.Mui-error.Mui-focused fieldset": borderError
|
|
623
|
+
},
|
|
624
|
+
"& .MuiFilledInput-root": {
|
|
625
|
+
backgroundColor: "#F9FAFB",
|
|
626
|
+
"&:after": underlineAccent,
|
|
627
|
+
"&:before": underlineAccent,
|
|
628
|
+
"&:hover:before": underlineAccent,
|
|
629
|
+
"&.Mui-error:after": underlineError,
|
|
630
|
+
"&.Mui-error:before": underlineError,
|
|
631
|
+
"&:hover": { backgroundColor: "#F5F5F5" },
|
|
632
|
+
"&.Mui-error:hover:before": underlineError,
|
|
633
|
+
fontFamily: "var(--font-poppins) !important",
|
|
634
|
+
"&.Mui-disabled": __spreadProps(__spreadValues({}, disabledText), { backgroundColor: "#F9FAFB" })
|
|
635
|
+
},
|
|
636
|
+
"& .MuiInputBase-input": __spreadProps(__spreadValues({}, input), { "&.Mui-disabled": disabledText }),
|
|
637
|
+
"& .MuiFormHelperText-root": {
|
|
638
|
+
fontSize: "11px",
|
|
639
|
+
marginLeft: 2,
|
|
640
|
+
fontFamily: "var(--font-poppins) !important"
|
|
641
|
+
},
|
|
642
|
+
"& .MuiFormHelperText-root.Mui-error": { color: errorColor },
|
|
643
|
+
"& .Mui-disabled": disabledText
|
|
644
|
+
});
|
|
645
|
+
var css_default = react.memo(InputTextField);
|
|
646
|
+
function useInputMasker({ type, onChange }) {
|
|
647
|
+
const formatValue = react.useCallback(
|
|
648
|
+
(v) => {
|
|
649
|
+
if (!v) return "";
|
|
650
|
+
switch (type) {
|
|
651
|
+
case "cpf-cnpj":
|
|
652
|
+
return formatCpfCnpj(v);
|
|
653
|
+
case "numeric":
|
|
654
|
+
return removeDigits(v);
|
|
655
|
+
case "tel":
|
|
656
|
+
return formatPhoneBr(v);
|
|
657
|
+
case "price":
|
|
658
|
+
return formatPriceBrl(v);
|
|
659
|
+
case "text-only":
|
|
660
|
+
return removeTextOnly(v);
|
|
661
|
+
case "text-no-number":
|
|
662
|
+
return removeNonDigits(v);
|
|
663
|
+
case "item-170":
|
|
664
|
+
return formatItem170(v);
|
|
665
|
+
case "item-150":
|
|
666
|
+
return formatItem150(v);
|
|
667
|
+
default:
|
|
668
|
+
return v;
|
|
669
|
+
}
|
|
670
|
+
},
|
|
671
|
+
[type]
|
|
672
|
+
);
|
|
673
|
+
const handleChange = (e) => {
|
|
674
|
+
const newValue = e.target.value;
|
|
675
|
+
onChange == null ? void 0 : onChange(__spreadProps(__spreadValues({}, e), {
|
|
676
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: formatValue(newValue) })
|
|
677
|
+
}));
|
|
678
|
+
};
|
|
679
|
+
return { handleChange };
|
|
680
|
+
}
|
|
681
|
+
function withPasswordToggle({
|
|
682
|
+
showPwd,
|
|
683
|
+
canToggle,
|
|
684
|
+
slotProps,
|
|
685
|
+
setShowPwd,
|
|
686
|
+
color = DEFAULT_ACCENT
|
|
687
|
+
}) {
|
|
688
|
+
if (!canToggle) return slotProps;
|
|
689
|
+
const Icon = showPwd ? md.MdVisibilityOff : md.MdVisibility;
|
|
690
|
+
return __spreadProps(__spreadValues({}, slotProps), {
|
|
691
|
+
input: __spreadProps(__spreadValues({}, slotProps == null ? void 0 : slotProps.input), {
|
|
692
|
+
endAdornment: /* @__PURE__ */ jsxRuntime.jsx(material.InputAdornment, { position: "end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
693
|
+
material.IconButton,
|
|
694
|
+
{
|
|
695
|
+
edge: "end",
|
|
696
|
+
size: "small",
|
|
697
|
+
sx: { color },
|
|
698
|
+
onClick: () => setShowPwd((prev) => !prev),
|
|
699
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 20 })
|
|
700
|
+
}
|
|
701
|
+
) })
|
|
702
|
+
})
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
function buildSlotProps(args) {
|
|
706
|
+
return withPasswordToggle(args);
|
|
707
|
+
}
|
|
708
|
+
var CUSTOM_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
709
|
+
"cpf-cnpj",
|
|
710
|
+
"numeric",
|
|
711
|
+
"price",
|
|
712
|
+
"item-170",
|
|
713
|
+
"item-150",
|
|
714
|
+
"text-only",
|
|
715
|
+
"text-no-number"
|
|
716
|
+
]);
|
|
717
|
+
function resolveHtmlInputType(type) {
|
|
718
|
+
if (!type || CUSTOM_INPUT_TYPES.has(type)) return "text";
|
|
719
|
+
return type;
|
|
720
|
+
}
|
|
721
|
+
var Input = (_a) => {
|
|
722
|
+
var _b = _a, {
|
|
723
|
+
color,
|
|
724
|
+
onChange,
|
|
725
|
+
isPassword,
|
|
726
|
+
type = "text",
|
|
727
|
+
size = "small"
|
|
728
|
+
} = _b, rest = __objRest(_b, [
|
|
729
|
+
"color",
|
|
730
|
+
"onChange",
|
|
731
|
+
"isPassword",
|
|
732
|
+
"type",
|
|
733
|
+
"size"
|
|
734
|
+
]);
|
|
735
|
+
const [showPwd, setShowPwd] = react.useState(false);
|
|
736
|
+
const isPwd = type === "password";
|
|
737
|
+
const canToggle = isPwd && isPassword;
|
|
738
|
+
const htmlType = resolveHtmlInputType(type);
|
|
739
|
+
const inputType = canToggle && showPwd ? "text" : htmlType;
|
|
740
|
+
const style = react.useMemo(
|
|
741
|
+
() => withCssVar(rest.style, "--primary-color", color),
|
|
742
|
+
[color, rest.style]
|
|
743
|
+
);
|
|
744
|
+
const slotProps = react.useMemo(
|
|
745
|
+
() => buildSlotProps({
|
|
746
|
+
color,
|
|
747
|
+
showPwd,
|
|
748
|
+
canToggle,
|
|
749
|
+
setShowPwd,
|
|
750
|
+
slotProps: rest.slotProps
|
|
751
|
+
}),
|
|
752
|
+
[canToggle, color, showPwd, rest.slotProps]
|
|
753
|
+
);
|
|
754
|
+
const { handleChange } = useInputMasker({ type, onChange });
|
|
755
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
756
|
+
css_default,
|
|
757
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
758
|
+
size,
|
|
759
|
+
style,
|
|
760
|
+
type: inputType,
|
|
761
|
+
slotProps,
|
|
762
|
+
onChange: handleChange,
|
|
763
|
+
className: cn("select-none", rest.className)
|
|
764
|
+
})
|
|
765
|
+
);
|
|
766
|
+
};
|
|
767
|
+
var input_default = Input;
|
|
768
|
+
|
|
769
|
+
// src/components/ui/input-select/utils/css.ts
|
|
770
|
+
var optionText = {
|
|
771
|
+
fontSize: "13px !important",
|
|
772
|
+
fontFamily: "var(--font-poppins) !important"
|
|
773
|
+
};
|
|
774
|
+
var selectMui = {
|
|
775
|
+
"& .MuiAutocomplete-option": __spreadProps(__spreadValues({
|
|
776
|
+
padding: "8px 12px"
|
|
777
|
+
}, optionText), {
|
|
778
|
+
lineHeight: "25px !important"
|
|
779
|
+
}),
|
|
780
|
+
"& .MuiAutocomplete-noOptions": optionText,
|
|
781
|
+
"& .MuiAutocomplete-listbox": { padding: "5px" }
|
|
782
|
+
};
|
|
783
|
+
function InputSelect(_a) {
|
|
784
|
+
var _b = _a, {
|
|
785
|
+
multiple,
|
|
786
|
+
optionLabel,
|
|
787
|
+
onChange,
|
|
788
|
+
input: input2
|
|
789
|
+
} = _b, rest = __objRest(_b, [
|
|
790
|
+
"multiple",
|
|
791
|
+
"optionLabel",
|
|
792
|
+
"onChange",
|
|
793
|
+
"input"
|
|
794
|
+
]);
|
|
795
|
+
const handleChange = (event, value, reason, details) => {
|
|
796
|
+
onChange == null ? void 0 : onChange(event, value, reason, details);
|
|
797
|
+
};
|
|
798
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
799
|
+
Autocomplete__default.default,
|
|
800
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
801
|
+
size: "small",
|
|
802
|
+
multiple,
|
|
803
|
+
onChange: handleChange,
|
|
804
|
+
slotProps: { paper: { sx: selectMui } },
|
|
805
|
+
getOptionLabel: (option) => typeof option === "string" ? "" : optionLabel(option),
|
|
806
|
+
isOptionEqualToValue: (option, value) => JSON.stringify(option) === JSON.stringify(value),
|
|
807
|
+
renderInput: (params) => {
|
|
808
|
+
var _a2;
|
|
809
|
+
return /* @__PURE__ */ jsxRuntime.jsx(input_default, __spreadProps(__spreadValues(__spreadValues({}, params), input2), { size: (_a2 = input2 == null ? void 0 : input2.size) != null ? _a2 : "small" }));
|
|
810
|
+
}
|
|
811
|
+
})
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
var input_select_default = InputSelect;
|
|
815
|
+
var FilterCard = ({
|
|
816
|
+
title,
|
|
817
|
+
setOpen,
|
|
818
|
+
renderFilter
|
|
819
|
+
}) => {
|
|
820
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-15 flex items-center w-full bg-white mb-2 rounded-md shadow-[0_2px_6px_-1px_rgba(0,0,0,.16),0_6px_18px_-1px_rgba(0,0,0,.06)]", children: [
|
|
821
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-2 bg-(--primary-color) rounded-tl-md rounded-bl-md" }),
|
|
822
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex justify-between items-center p-3", children: [
|
|
823
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "font-medium text-lg whitespace-nowrap text-ellipsis overflow-hidden ml-1 text-black/80", children: title }),
|
|
824
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-4", children: renderFilter && /* @__PURE__ */ jsxRuntime.jsx(
|
|
825
|
+
core.Tooltip,
|
|
826
|
+
{
|
|
827
|
+
withArrow: true,
|
|
828
|
+
arrowSize: 4,
|
|
829
|
+
color: "#00b2a6",
|
|
830
|
+
arrowOffset: 20,
|
|
831
|
+
label: "Ver filtros",
|
|
832
|
+
className: "text-xs!",
|
|
833
|
+
transitionProps: { transition: "pop", duration: 300 },
|
|
834
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
835
|
+
core.ActionIcon,
|
|
836
|
+
{
|
|
837
|
+
size: 40,
|
|
838
|
+
radius: "md",
|
|
839
|
+
"aria-label": "Ver filtros",
|
|
840
|
+
color: "var(--primary-color)",
|
|
841
|
+
onClick: () => setOpen(true),
|
|
842
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(fa.FaFilter, { className: "h-5 w-5 text-white" })
|
|
843
|
+
}
|
|
844
|
+
) })
|
|
845
|
+
}
|
|
846
|
+
) })
|
|
847
|
+
] })
|
|
848
|
+
] });
|
|
849
|
+
};
|
|
850
|
+
var card_default2 = FilterCard;
|
|
851
|
+
|
|
852
|
+
// src/components/ui/filter/utils/constants.ts
|
|
853
|
+
var FILTER_DEFAULT_ORDER = 99;
|
|
854
|
+
var FILTER_DRAWER_PAPER_SX = {
|
|
855
|
+
["& .MuiDrawer-paper"]: { borderRadius: "0px 0px 20px 20px" }
|
|
856
|
+
};
|
|
857
|
+
function hasFilterFields(inputs, inputSelect) {
|
|
858
|
+
var _a, _b;
|
|
859
|
+
return ((_a = inputs == null ? void 0 : inputs.length) != null ? _a : 0) > 0 || ((_b = inputSelect == null ? void 0 : inputSelect.length) != null ? _b : 0) > 0;
|
|
860
|
+
}
|
|
861
|
+
function isInputSelect(field) {
|
|
862
|
+
return "options" in field;
|
|
863
|
+
}
|
|
864
|
+
function filterInputSelect(props) {
|
|
865
|
+
return props;
|
|
866
|
+
}
|
|
867
|
+
function sortFilterFields(fields) {
|
|
868
|
+
return [...fields].sort(
|
|
869
|
+
(a, b) => {
|
|
870
|
+
var _a, _b;
|
|
871
|
+
return ((_a = a.order) != null ? _a : FILTER_DEFAULT_ORDER) - ((_b = b.order) != null ? _b : FILTER_DEFAULT_ORDER);
|
|
872
|
+
}
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
function mergeFilterFields(inputs, inputSelect) {
|
|
876
|
+
return sortFilterFields([...inputs, ...inputSelect]);
|
|
877
|
+
}
|
|
878
|
+
function getFilterGridColumns(isMobile, isTablet) {
|
|
879
|
+
if (isMobile) return 1;
|
|
880
|
+
if (isTablet) return 3;
|
|
881
|
+
return 7;
|
|
882
|
+
}
|
|
883
|
+
var FilterDrawer = ({
|
|
884
|
+
open,
|
|
885
|
+
setOpen,
|
|
886
|
+
onClear,
|
|
887
|
+
onSubmit,
|
|
888
|
+
inputs = [],
|
|
889
|
+
inputSelect = []
|
|
890
|
+
}) => {
|
|
891
|
+
const m640 = material.useMediaQuery("(max-width:640px)");
|
|
892
|
+
const m1120 = material.useMediaQuery("(max-width:1120px)");
|
|
893
|
+
const allInputs = mergeFilterFields(inputs, inputSelect);
|
|
894
|
+
const renderField = (field, index) => {
|
|
895
|
+
var _a, _b, _c;
|
|
896
|
+
if (isInputSelect(field)) {
|
|
897
|
+
if (field.multiple) {
|
|
898
|
+
return /* @__PURE__ */ jsxRuntime.jsx(material.Grid, { size: (_a = field.xs) != null ? _a : 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
899
|
+
input_select_default,
|
|
900
|
+
__spreadProps(__spreadValues({}, field), {
|
|
901
|
+
id: `inputSM${index}`,
|
|
902
|
+
fullWidth: true
|
|
903
|
+
})
|
|
904
|
+
) }, `inputSelect-${index}`);
|
|
905
|
+
}
|
|
906
|
+
return /* @__PURE__ */ jsxRuntime.jsx(material.Grid, { size: (_b = field.xs) != null ? _b : 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
907
|
+
input_select_default,
|
|
908
|
+
__spreadProps(__spreadValues({}, field), {
|
|
909
|
+
id: `inputSM${index}`,
|
|
910
|
+
fullWidth: true
|
|
911
|
+
})
|
|
912
|
+
) }, `inputSelect-${index}`);
|
|
913
|
+
}
|
|
914
|
+
return /* @__PURE__ */ jsxRuntime.jsx(material.Grid, { size: (_c = field.xs) != null ? _c : 1, children: /* @__PURE__ */ jsxRuntime.jsx(input_default, __spreadProps(__spreadValues({}, field), { fullWidth: true })) }, `input-${index}`);
|
|
915
|
+
};
|
|
916
|
+
const handleSubmit = (event) => {
|
|
917
|
+
event.preventDefault();
|
|
918
|
+
if (!onSubmit) return;
|
|
919
|
+
onSubmit(event);
|
|
920
|
+
setOpen(false);
|
|
921
|
+
};
|
|
922
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
923
|
+
material.Drawer,
|
|
924
|
+
{
|
|
925
|
+
open,
|
|
926
|
+
anchor: "top",
|
|
927
|
+
onClose: () => setOpen(false),
|
|
928
|
+
sx: FILTER_DRAWER_PAPER_SX,
|
|
929
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
930
|
+
"form",
|
|
931
|
+
{
|
|
932
|
+
onSubmit: handleSubmit,
|
|
933
|
+
className: "flex w-full select-none flex-col py-4 pl-5",
|
|
934
|
+
children: [
|
|
935
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-medium text-system-900", children: "Filtros" }),
|
|
936
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pb-5 pt-1 text-sm text-black/80", children: "Para que possamos apresentar dados espec\xEDficos, por favor, preencha os campos abaixo." }),
|
|
937
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
938
|
+
material.Grid,
|
|
939
|
+
{
|
|
940
|
+
container: true,
|
|
941
|
+
rowSpacing: 2,
|
|
942
|
+
className: "pr-5",
|
|
943
|
+
columnSpacing: 1,
|
|
944
|
+
columns: getFilterGridColumns(Boolean(m640), Boolean(m1120)),
|
|
945
|
+
children: allInputs.map((field, index) => renderField(field, index))
|
|
946
|
+
}
|
|
947
|
+
),
|
|
948
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end space-x-4 pr-4 pt-4", children: [
|
|
949
|
+
onClear && /* @__PURE__ */ jsxRuntime.jsx(
|
|
950
|
+
core.Button,
|
|
951
|
+
{
|
|
952
|
+
radius: "sm",
|
|
953
|
+
color: "#253E56",
|
|
954
|
+
variant: "outline",
|
|
955
|
+
onClick: onClear,
|
|
956
|
+
size: "xs",
|
|
957
|
+
children: "LIMPAR FILTROS"
|
|
958
|
+
}
|
|
959
|
+
),
|
|
960
|
+
onSubmit && /* @__PURE__ */ jsxRuntime.jsx(
|
|
961
|
+
core.Button,
|
|
962
|
+
{
|
|
963
|
+
size: "xs",
|
|
964
|
+
radius: "sm",
|
|
965
|
+
type: "submit",
|
|
966
|
+
variant: "filled",
|
|
967
|
+
color: "var(--primary-color)",
|
|
968
|
+
children: "PESQUISAR"
|
|
969
|
+
}
|
|
970
|
+
)
|
|
971
|
+
] })
|
|
972
|
+
]
|
|
973
|
+
}
|
|
974
|
+
)
|
|
975
|
+
}
|
|
976
|
+
);
|
|
977
|
+
};
|
|
978
|
+
var filter_default = FilterDrawer;
|
|
979
|
+
var Filter = ({
|
|
980
|
+
title,
|
|
981
|
+
inputs,
|
|
982
|
+
onClear,
|
|
983
|
+
onSubmit,
|
|
984
|
+
inputSelect
|
|
985
|
+
}) => {
|
|
986
|
+
const [open, setOpen] = react.useState(false);
|
|
987
|
+
const hasFields = hasFilterFields(inputs, inputSelect);
|
|
988
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
989
|
+
/* @__PURE__ */ jsxRuntime.jsx(card_default2, { title, setOpen, renderFilter: hasFields }),
|
|
990
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
991
|
+
filter_default,
|
|
992
|
+
{
|
|
993
|
+
open,
|
|
994
|
+
inputs,
|
|
995
|
+
setOpen,
|
|
996
|
+
onClear,
|
|
997
|
+
onSubmit,
|
|
998
|
+
inputSelect
|
|
999
|
+
}
|
|
1000
|
+
)
|
|
1001
|
+
] });
|
|
1002
|
+
};
|
|
1003
|
+
var filter_default2 = Filter;
|
|
1004
|
+
|
|
509
1005
|
exports.Card = card_default;
|
|
510
1006
|
exports.DataTable = data_table_default;
|
|
511
1007
|
exports.Dialog = dialog_default;
|
|
1008
|
+
exports.Filter = filter_default2;
|
|
1009
|
+
exports.Input = input_default;
|
|
1010
|
+
exports.InputSelect = input_select_default;
|
|
512
1011
|
exports.Tab = Tab;
|
|
513
1012
|
exports.Tabs = Tabs;
|
|
1013
|
+
exports.filterInputSelect = filterInputSelect;
|
|
514
1014
|
//# sourceMappingURL=index.js.map
|
|
515
1015
|
//# sourceMappingURL=index.js.map
|