@charlesgomes/leafcode-shared-lib-react 1.0.58 → 1.0.59
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/index.d.mts +143 -48
- package/dist/index.d.ts +143 -48
- package/dist/index.js +624 -199
- package/dist/index.mjs +607 -177
- package/dist/styles/base.css +20 -0
- package/dist/styles/button.css +41 -47
- package/dist/styles/input.css +129 -11
- package/dist/styles/modalBase.css +99 -0
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -38,6 +38,9 @@ __export(index_exports, {
|
|
|
38
38
|
FilterMatchMode: () => import_api5.FilterMatchMode,
|
|
39
39
|
FilterOperator: () => import_api5.FilterOperator,
|
|
40
40
|
Input: () => Input,
|
|
41
|
+
InputAutoComplete: () => InputAutoComplete,
|
|
42
|
+
InputSelect: () => InputSelect,
|
|
43
|
+
LeafcodeThemeProvider: () => LeafcodeThemeProvider,
|
|
41
44
|
ModalBase: () => ModalBase,
|
|
42
45
|
SelectFilterTemplate: () => SelectFilterTemplate,
|
|
43
46
|
TextArea: () => TextArea,
|
|
@@ -45,6 +48,7 @@ __export(index_exports, {
|
|
|
45
48
|
buildDynamicCampoFilters: () => buildDynamicCampoFilters,
|
|
46
49
|
buildSortingWithFilters: () => buildSortingWithFilters,
|
|
47
50
|
customMatchModes: () => customMatchModes,
|
|
51
|
+
defaultTheme: () => defaultTheme,
|
|
48
52
|
getDefaultFilterMatchOptionsDate: () => getDefaultFilterMatchOptionsDate,
|
|
49
53
|
getDefaultFilterMatchOptionsEnum: () => getDefaultFilterMatchOptionsEnum,
|
|
50
54
|
getDefaultFilterMatchOptionsEnumNotNullable: () => getDefaultFilterMatchOptionsEnumNotNullable,
|
|
@@ -55,8 +59,92 @@ __export(index_exports, {
|
|
|
55
59
|
});
|
|
56
60
|
module.exports = __toCommonJS(index_exports);
|
|
57
61
|
|
|
58
|
-
// src/
|
|
62
|
+
// src/provider/ThemeProvider.tsx
|
|
63
|
+
var import_lodash = __toESM(require("lodash.merge"));
|
|
64
|
+
var import_react = require("react");
|
|
65
|
+
|
|
66
|
+
// src/provider/defaultTheme.ts
|
|
67
|
+
var defaultTheme = {
|
|
68
|
+
colors: {
|
|
69
|
+
primary: "#00875F",
|
|
70
|
+
danger: "#ED202E",
|
|
71
|
+
border: "#D4D4D8",
|
|
72
|
+
text: "#18181B",
|
|
73
|
+
light: "#FFFFFF",
|
|
74
|
+
background: "#FFFFFF"
|
|
75
|
+
},
|
|
76
|
+
fonts: {
|
|
77
|
+
body: "Roboto, sans-serif",
|
|
78
|
+
heading: "Roboto, sans-serif"
|
|
79
|
+
},
|
|
80
|
+
radius: {
|
|
81
|
+
sm: "4px",
|
|
82
|
+
md: "6px",
|
|
83
|
+
lg: "10px"
|
|
84
|
+
},
|
|
85
|
+
components: {
|
|
86
|
+
input: {
|
|
87
|
+
colors: {
|
|
88
|
+
border: "#D4D4D8",
|
|
89
|
+
focusBorder: "#00875F",
|
|
90
|
+
errorBorder: "#ED202E",
|
|
91
|
+
background: "#FFFFFF",
|
|
92
|
+
text: "#18181B",
|
|
93
|
+
placeholder: "#71717A",
|
|
94
|
+
passwordToggle: "#71717A"
|
|
95
|
+
},
|
|
96
|
+
fonts: {
|
|
97
|
+
label: "Roboto, sans-serif",
|
|
98
|
+
input: "Roboto, sans-serif",
|
|
99
|
+
labelSize: "12px",
|
|
100
|
+
inputSize: "14px",
|
|
101
|
+
labelWeight: 600,
|
|
102
|
+
inputWeight: 400
|
|
103
|
+
},
|
|
104
|
+
sizes: {
|
|
105
|
+
height: "44px",
|
|
106
|
+
heightTextArea: "6rem",
|
|
107
|
+
radius: "6px"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
button: {
|
|
111
|
+
colors: {
|
|
112
|
+
text: "#FFFFFF",
|
|
113
|
+
primaryBg: "#6366f1",
|
|
114
|
+
primaryHoverBg: "#4f46e5",
|
|
115
|
+
secondaryBg: "#bf1717",
|
|
116
|
+
secondaryHoverBg: "#f35353",
|
|
117
|
+
disabledBorder: "#a1a1aa",
|
|
118
|
+
disabledBg: "#d4d4d8"
|
|
119
|
+
},
|
|
120
|
+
fonts: {
|
|
121
|
+
family: '"Roboto", sans-serif',
|
|
122
|
+
weight: 600,
|
|
123
|
+
size: "13px"
|
|
124
|
+
},
|
|
125
|
+
sizes: {
|
|
126
|
+
height: "2.5rem",
|
|
127
|
+
minWidth: "8rem",
|
|
128
|
+
radius: "6px"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/provider/ThemeProvider.tsx
|
|
59
135
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
136
|
+
var ThemeContext = (0, import_react.createContext)(defaultTheme);
|
|
137
|
+
var LeafcodeThemeProvider = ({
|
|
138
|
+
children,
|
|
139
|
+
theme
|
|
140
|
+
}) => {
|
|
141
|
+
const mergedTheme = (0, import_lodash.default)({}, defaultTheme, theme);
|
|
142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: mergedTheme, children });
|
|
143
|
+
};
|
|
144
|
+
var useLeafcodeTheme = () => (0, import_react.useContext)(ThemeContext);
|
|
145
|
+
|
|
146
|
+
// src/components/Button/Button.tsx
|
|
147
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
60
148
|
function Button({
|
|
61
149
|
disabled,
|
|
62
150
|
loading,
|
|
@@ -66,15 +154,32 @@ function Button({
|
|
|
66
154
|
title,
|
|
67
155
|
...rest
|
|
68
156
|
}) {
|
|
69
|
-
|
|
157
|
+
const theme = useLeafcodeTheme();
|
|
158
|
+
const styleVars = {
|
|
159
|
+
"--button-font-family": theme.components.button.fonts.family,
|
|
160
|
+
"--button-font-weight": theme.components.button.fonts.weight,
|
|
161
|
+
"--button-font-size": theme.components.button.fonts.size,
|
|
162
|
+
"--button-text-color": theme.components.button.colors.text,
|
|
163
|
+
"--button-primary-bg": theme.components.button.colors.primaryBg,
|
|
164
|
+
"--button-primary-hover-bg": theme.components.button.colors.primaryHoverBg,
|
|
165
|
+
"--button-secondary-bg": theme.components.button.colors.secondaryBg,
|
|
166
|
+
"--button-secondary-hover-bg": theme.components.button.colors.secondaryHoverBg,
|
|
167
|
+
"--button-disabled-bg": theme.components.button.colors.disabledBg,
|
|
168
|
+
"--button-disabled-border": theme.components.button.colors.disabledBorder,
|
|
169
|
+
"--button-height": theme.components.button.sizes.height,
|
|
170
|
+
"--button-min-width": theme.components.button.sizes.minWidth,
|
|
171
|
+
"--button-border-radius": theme.components.button.sizes.radius
|
|
172
|
+
};
|
|
173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
70
174
|
"button",
|
|
71
175
|
{
|
|
72
176
|
type,
|
|
73
|
-
|
|
177
|
+
style: styleVars,
|
|
178
|
+
className: `box-button ${disabled || loading ? "button-disabled" : color === "danger" ? "button-secundary" : "button-primary"}`,
|
|
74
179
|
onClick: !loading ? onClick : void 0,
|
|
75
180
|
disabled: disabled || loading,
|
|
76
181
|
...rest,
|
|
77
|
-
children: loading ? /* @__PURE__ */ (0,
|
|
182
|
+
children: loading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "box-loading", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
78
183
|
"svg",
|
|
79
184
|
{
|
|
80
185
|
className: "animate-spin",
|
|
@@ -82,7 +187,7 @@ function Button({
|
|
|
82
187
|
fill: "none",
|
|
83
188
|
viewBox: "0 0 24 24",
|
|
84
189
|
children: [
|
|
85
|
-
/* @__PURE__ */ (0,
|
|
190
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
86
191
|
"circle",
|
|
87
192
|
{
|
|
88
193
|
className: "opacity-01",
|
|
@@ -93,7 +198,7 @@ function Button({
|
|
|
93
198
|
strokeWidth: "4"
|
|
94
199
|
}
|
|
95
200
|
),
|
|
96
|
-
/* @__PURE__ */ (0,
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
97
202
|
"path",
|
|
98
203
|
{
|
|
99
204
|
className: "opacity-02",
|
|
@@ -103,46 +208,46 @@ function Button({
|
|
|
103
208
|
)
|
|
104
209
|
]
|
|
105
210
|
}
|
|
106
|
-
) }) : /* @__PURE__ */ (0,
|
|
211
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: title })
|
|
107
212
|
}
|
|
108
213
|
);
|
|
109
214
|
}
|
|
110
215
|
|
|
111
216
|
// src/components/Input/Input.tsx
|
|
112
|
-
var
|
|
217
|
+
var import_react4 = require("react");
|
|
113
218
|
|
|
114
219
|
// src/components/Tooltips/TooltipErrorInput.tsx
|
|
115
|
-
var
|
|
116
|
-
var
|
|
220
|
+
var import_react2 = require("@phosphor-icons/react");
|
|
221
|
+
var import_react3 = require("react");
|
|
117
222
|
var import_react_tooltip = require("react-tooltip");
|
|
118
|
-
var
|
|
223
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
119
224
|
function TooltipErrorInput({
|
|
120
225
|
error,
|
|
121
226
|
name,
|
|
122
227
|
isSelect = false,
|
|
123
228
|
isInvalid = false
|
|
124
229
|
}) {
|
|
125
|
-
const [isTooltipOpen, setIsTooltipOpen] = (0,
|
|
230
|
+
const [isTooltipOpen, setIsTooltipOpen] = (0, import_react3.useState)(true);
|
|
126
231
|
const handleClose = () => setIsTooltipOpen(false);
|
|
127
|
-
(0,
|
|
232
|
+
(0, import_react3.useEffect)(() => {
|
|
128
233
|
setIsTooltipOpen(true);
|
|
129
234
|
}, [error]);
|
|
130
|
-
return /* @__PURE__ */ (0,
|
|
235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
131
236
|
"div",
|
|
132
237
|
{
|
|
133
238
|
className: `absolute ${isSelect ? isInvalid ? "right-[4.5rem]" : "right-11" : "right-2"} top-1/2 transform -translate-y-1/2 cursor-pointer z-20`,
|
|
134
|
-
children: /* @__PURE__ */ (0,
|
|
135
|
-
/* @__PURE__ */ (0,
|
|
239
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: error?.message && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
136
241
|
"a",
|
|
137
242
|
{
|
|
138
243
|
"data-tooltip-id": name,
|
|
139
244
|
"data-tooltip-content": "",
|
|
140
245
|
"data-tooltip-place": "top-end",
|
|
141
246
|
onClick: () => setIsTooltipOpen(true),
|
|
142
|
-
children: /* @__PURE__ */ (0,
|
|
247
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.WarningCircle, { size: 22, className: "text-red-400" })
|
|
143
248
|
}
|
|
144
249
|
),
|
|
145
|
-
/* @__PURE__ */ (0,
|
|
250
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
146
251
|
import_react_tooltip.Tooltip,
|
|
147
252
|
{
|
|
148
253
|
className: "max-w-[15rem] relative z-50 tooltip-content cursor-default",
|
|
@@ -158,9 +263,9 @@ function TooltipErrorInput({
|
|
|
158
263
|
clickable: true,
|
|
159
264
|
openOnClick: true,
|
|
160
265
|
isOpen: isTooltipOpen,
|
|
161
|
-
children: isTooltipOpen && /* @__PURE__ */ (0,
|
|
162
|
-
/* @__PURE__ */ (0,
|
|
163
|
-
/* @__PURE__ */ (0,
|
|
266
|
+
children: isTooltipOpen && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex justify-between gap-1 items-center font-Roboto text-[13px] leading-[125%] transition-all", children: [
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: error?.message }),
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
164
269
|
"button",
|
|
165
270
|
{
|
|
166
271
|
onClick: handleClose,
|
|
@@ -170,7 +275,7 @@ function TooltipErrorInput({
|
|
|
170
275
|
background: "transparent",
|
|
171
276
|
cursor: "pointer"
|
|
172
277
|
},
|
|
173
|
-
children: /* @__PURE__ */ (0,
|
|
278
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.X, { size: 16, weight: "bold" })
|
|
174
279
|
}
|
|
175
280
|
)
|
|
176
281
|
] })
|
|
@@ -182,8 +287,8 @@ function TooltipErrorInput({
|
|
|
182
287
|
}
|
|
183
288
|
|
|
184
289
|
// src/components/Input/Input.tsx
|
|
185
|
-
var
|
|
186
|
-
var
|
|
290
|
+
var import_react5 = require("@phosphor-icons/react");
|
|
291
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
187
292
|
var InputBase = ({
|
|
188
293
|
name,
|
|
189
294
|
label,
|
|
@@ -197,27 +302,29 @@ var InputBase = ({
|
|
|
197
302
|
showPasswordToggle = false,
|
|
198
303
|
onChange,
|
|
199
304
|
value,
|
|
200
|
-
colors,
|
|
201
|
-
fonts,
|
|
202
305
|
...rest
|
|
203
306
|
}, ref) => {
|
|
307
|
+
const theme = useLeafcodeTheme();
|
|
204
308
|
const styleVars = {
|
|
205
|
-
|
|
206
|
-
"--label-font-
|
|
207
|
-
"--
|
|
208
|
-
"--
|
|
209
|
-
"--
|
|
210
|
-
"--
|
|
211
|
-
"--input-
|
|
212
|
-
|
|
213
|
-
"--
|
|
214
|
-
"--input-
|
|
215
|
-
"--input-
|
|
216
|
-
"--input-
|
|
217
|
-
"--
|
|
218
|
-
"--
|
|
219
|
-
"--
|
|
220
|
-
"--color-password-toggle": colors
|
|
309
|
+
// Fonts
|
|
310
|
+
"--label-font-family": theme.components.input.fonts.label,
|
|
311
|
+
"--label-font-weight": theme.components.input.fonts.labelWeight,
|
|
312
|
+
"--label-font-size": theme.components.input.fonts.labelSize,
|
|
313
|
+
"--input-font-family": theme.components.input.fonts.input,
|
|
314
|
+
"--input-font-weight": theme.components.input.fonts.inputWeight,
|
|
315
|
+
"--input-font-size": theme.components.input.fonts.inputSize,
|
|
316
|
+
// Colors
|
|
317
|
+
"--label-color": theme.components.input.colors.text,
|
|
318
|
+
"--input-border": theme.components.input.colors.border,
|
|
319
|
+
"--input-bg": theme.components.input.colors.background,
|
|
320
|
+
"--input-text-color": theme.components.input.colors.text,
|
|
321
|
+
"--input-placeholder": theme.components.input.colors.placeholder,
|
|
322
|
+
"--input-focus-border": theme.components.input.colors.focusBorder,
|
|
323
|
+
"--input-error-border": theme.components.input.colors.errorBorder,
|
|
324
|
+
"--color-password-toggle": theme.components.input.colors.passwordToggle,
|
|
325
|
+
// Sizes
|
|
326
|
+
"--input-height": theme.components.input.sizes.height,
|
|
327
|
+
"--input-border-radius": theme.components.input.sizes.radius
|
|
221
328
|
};
|
|
222
329
|
const handleChange = (e) => {
|
|
223
330
|
let val = e.target.value;
|
|
@@ -230,15 +337,15 @@ var InputBase = ({
|
|
|
230
337
|
e.target.value = val;
|
|
231
338
|
onChange?.(e);
|
|
232
339
|
};
|
|
233
|
-
const [show, setShow] = (0,
|
|
340
|
+
const [show, setShow] = (0, import_react4.useState)(false);
|
|
234
341
|
const handleClick = () => setShow(!show);
|
|
235
|
-
return /* @__PURE__ */ (0,
|
|
342
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
236
343
|
"div",
|
|
237
344
|
{
|
|
238
345
|
className: `input-wrapper ${disabled ? "is-disabled" : ""}`,
|
|
239
346
|
style: styleVars,
|
|
240
347
|
children: [
|
|
241
|
-
!!label && /* @__PURE__ */ (0,
|
|
348
|
+
!!label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
242
349
|
"label",
|
|
243
350
|
{
|
|
244
351
|
className: `label-input ${isUppercaseLabel && "is-uppercase"}`,
|
|
@@ -246,8 +353,8 @@ var InputBase = ({
|
|
|
246
353
|
children: label
|
|
247
354
|
}
|
|
248
355
|
),
|
|
249
|
-
/* @__PURE__ */ (0,
|
|
250
|
-
/* @__PURE__ */ (0,
|
|
356
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { position: "relative", width: "100%" }, children: [
|
|
357
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
251
358
|
"input",
|
|
252
359
|
{
|
|
253
360
|
id: name,
|
|
@@ -263,25 +370,25 @@ var InputBase = ({
|
|
|
263
370
|
...rest
|
|
264
371
|
}
|
|
265
372
|
),
|
|
266
|
-
showPasswordToggle && /* @__PURE__ */ (0,
|
|
373
|
+
showPasswordToggle && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
267
374
|
"div",
|
|
268
375
|
{
|
|
269
376
|
onClick: handleClick,
|
|
270
377
|
className: `password-toggle ${error ? "error" : "no-error"}`,
|
|
271
|
-
children: show ? /* @__PURE__ */ (0,
|
|
378
|
+
children: show ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.Eye, { size: 21 }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.EyeSlash, { size: 21 })
|
|
272
379
|
}
|
|
273
380
|
)
|
|
274
381
|
] }),
|
|
275
|
-
/* @__PURE__ */ (0,
|
|
382
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipErrorInput, { error, name })
|
|
276
383
|
]
|
|
277
384
|
}
|
|
278
385
|
);
|
|
279
386
|
};
|
|
280
|
-
var Input = (0,
|
|
387
|
+
var Input = (0, import_react4.forwardRef)(InputBase);
|
|
281
388
|
|
|
282
389
|
// src/components/Input/TextArea.tsx
|
|
283
|
-
var
|
|
284
|
-
var
|
|
390
|
+
var import_react6 = require("react");
|
|
391
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
285
392
|
var TextAreaBase = ({
|
|
286
393
|
name,
|
|
287
394
|
label,
|
|
@@ -291,36 +398,37 @@ var TextAreaBase = ({
|
|
|
291
398
|
disabled,
|
|
292
399
|
onFocus,
|
|
293
400
|
error,
|
|
294
|
-
colors,
|
|
295
|
-
fonts,
|
|
296
|
-
height,
|
|
297
401
|
...rest
|
|
298
402
|
}, ref) => {
|
|
403
|
+
const theme = useLeafcodeTheme();
|
|
299
404
|
const styleVars = {
|
|
300
|
-
|
|
301
|
-
"--label-font-
|
|
302
|
-
"--
|
|
303
|
-
"--
|
|
304
|
-
"--
|
|
305
|
-
"--
|
|
306
|
-
"--
|
|
307
|
-
|
|
308
|
-
"--
|
|
309
|
-
"--input-
|
|
310
|
-
"--input-
|
|
311
|
-
"--input-
|
|
312
|
-
"--input-
|
|
313
|
-
"--
|
|
314
|
-
"--
|
|
315
|
-
"--
|
|
405
|
+
// Fonts
|
|
406
|
+
"--label-font-family": theme.components.input.fonts.label,
|
|
407
|
+
"--label-font-weight": theme.components.input.fonts.labelWeight,
|
|
408
|
+
"--label-font-size": theme.components.input.fonts.labelSize,
|
|
409
|
+
"--input-font-family": theme.components.input.fonts.input,
|
|
410
|
+
"--input-font-weight": theme.components.input.fonts.inputWeight,
|
|
411
|
+
"--input-font-size": theme.components.input.fonts.inputSize,
|
|
412
|
+
// Colors
|
|
413
|
+
"--label-color": theme.components.input.colors.text,
|
|
414
|
+
"--input-border": theme.components.input.colors.border,
|
|
415
|
+
"--input-bg": theme.components.input.colors.background,
|
|
416
|
+
"--input-text-color": theme.components.input.colors.text,
|
|
417
|
+
"--input-placeholder": theme.components.input.colors.placeholder,
|
|
418
|
+
"--input-focus-border": theme.components.input.colors.focusBorder,
|
|
419
|
+
"--input-error-border": theme.components.input.colors.errorBorder,
|
|
420
|
+
"--color-password-toggle": theme.components.input.colors.passwordToggle,
|
|
421
|
+
// Sizes
|
|
422
|
+
"--input-height-text-area": theme.components.input.sizes.heightTextArea,
|
|
423
|
+
"--input-border-radius": theme.components.input.sizes.radius
|
|
316
424
|
};
|
|
317
|
-
return /* @__PURE__ */ (0,
|
|
425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
318
426
|
"div",
|
|
319
427
|
{
|
|
320
428
|
className: `input-wrapper ${disabled ? "is-disabled" : ""}`,
|
|
321
429
|
style: styleVars,
|
|
322
430
|
children: [
|
|
323
|
-
!!label && /* @__PURE__ */ (0,
|
|
431
|
+
!!label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
324
432
|
"label",
|
|
325
433
|
{
|
|
326
434
|
className: `label-input ${isUppercaseLabel ? "is-uppercase" : ""}`,
|
|
@@ -328,8 +436,8 @@ var TextAreaBase = ({
|
|
|
328
436
|
children: label
|
|
329
437
|
}
|
|
330
438
|
),
|
|
331
|
-
/* @__PURE__ */ (0,
|
|
332
|
-
/* @__PURE__ */ (0,
|
|
439
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { position: "relative", width: "100%" }, children: [
|
|
440
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
333
441
|
"textarea",
|
|
334
442
|
{
|
|
335
443
|
ref,
|
|
@@ -342,28 +450,151 @@ var TextAreaBase = ({
|
|
|
342
450
|
...rest
|
|
343
451
|
}
|
|
344
452
|
),
|
|
345
|
-
/* @__PURE__ */ (0,
|
|
453
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "absolute top-6 right-1", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipErrorInput, { error, name }) })
|
|
346
454
|
] })
|
|
347
455
|
]
|
|
348
456
|
}
|
|
349
457
|
);
|
|
350
458
|
};
|
|
351
|
-
var TextArea = (0,
|
|
459
|
+
var TextArea = (0, import_react6.forwardRef)(
|
|
352
460
|
TextAreaBase
|
|
353
461
|
);
|
|
354
462
|
|
|
463
|
+
// src/components/Input/InputSelect.tsx
|
|
464
|
+
var import_react7 = require("react");
|
|
465
|
+
var import_react_hook_form = require("react-hook-form");
|
|
466
|
+
var import_react_select = __toESM(require("react-select"));
|
|
467
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
468
|
+
var NoOptionsMessage = (props) => {
|
|
469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_select.components.NoOptionsMessage, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "", children: "Nenhuma op\xE7\xE3o" }) });
|
|
470
|
+
};
|
|
471
|
+
var InputBase2 = ({
|
|
472
|
+
name,
|
|
473
|
+
control,
|
|
474
|
+
options,
|
|
475
|
+
isMulti,
|
|
476
|
+
closeMenuOnSelect,
|
|
477
|
+
isClearable = true,
|
|
478
|
+
label,
|
|
479
|
+
placeholder,
|
|
480
|
+
error = null,
|
|
481
|
+
disabled,
|
|
482
|
+
onSelect,
|
|
483
|
+
isUppercaseLabel = true
|
|
484
|
+
}, ref) => {
|
|
485
|
+
const theme = useLeafcodeTheme();
|
|
486
|
+
const styleVars = {
|
|
487
|
+
// Fonts
|
|
488
|
+
"--label-font-family": theme.components.input.fonts.label,
|
|
489
|
+
"--label-font-weight": theme.components.input.fonts.labelWeight,
|
|
490
|
+
"--label-font-size": theme.components.input.fonts.labelSize,
|
|
491
|
+
"--input-font-family": theme.components.input.fonts.input,
|
|
492
|
+
"--input-font-weight": theme.components.input.fonts.inputWeight,
|
|
493
|
+
"--input-font-size": theme.components.input.fonts.inputSize,
|
|
494
|
+
// Colors
|
|
495
|
+
"--label-color": theme.components.input.colors.text,
|
|
496
|
+
"--input-border": theme.components.input.colors.border,
|
|
497
|
+
"--input-bg": theme.components.input.colors.background,
|
|
498
|
+
"--input-text-color": theme.colors.light,
|
|
499
|
+
"--input-placeholder": theme.components.input.colors.placeholder,
|
|
500
|
+
"--input-focus-border": theme.components.input.colors.focusBorder,
|
|
501
|
+
"--input-error-border": theme.components.input.colors.errorBorder,
|
|
502
|
+
"--color-password-toggle": theme.components.input.colors.passwordToggle,
|
|
503
|
+
// Sizes
|
|
504
|
+
"--input-height": theme.components.input.sizes.height,
|
|
505
|
+
"--input-border-radius": theme.components.input.sizes.radius
|
|
506
|
+
};
|
|
507
|
+
const [menuPortalTarget, setMenuPortalTarget] = (0, import_react7.useState)(
|
|
508
|
+
null
|
|
509
|
+
);
|
|
510
|
+
(0, import_react7.useEffect)(() => {
|
|
511
|
+
setMenuPortalTarget(document.body);
|
|
512
|
+
}, []);
|
|
513
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "input-wrapper", style: styleVars, children: [
|
|
514
|
+
!!label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
515
|
+
"label",
|
|
516
|
+
{
|
|
517
|
+
className: `label-input ${isUppercaseLabel && "is-uppercase"}`,
|
|
518
|
+
htmlFor: name,
|
|
519
|
+
children: label
|
|
520
|
+
}
|
|
521
|
+
),
|
|
522
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
523
|
+
import_react_hook_form.Controller,
|
|
524
|
+
{
|
|
525
|
+
name,
|
|
526
|
+
control,
|
|
527
|
+
render: ({ field: { onChange, ref: ref2, value } }) => {
|
|
528
|
+
const selectedOption = options.find(
|
|
529
|
+
(option) => option.value === value
|
|
530
|
+
);
|
|
531
|
+
const displayValue = value?.label ? value : selectedOption || { label: value, value };
|
|
532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
533
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
534
|
+
import_react_select.default,
|
|
535
|
+
{
|
|
536
|
+
ref: ref2,
|
|
537
|
+
id: "long-value-select",
|
|
538
|
+
instanceId: "long-value-select",
|
|
539
|
+
placeholder,
|
|
540
|
+
isClearable,
|
|
541
|
+
closeMenuOnSelect,
|
|
542
|
+
menuPortalTarget,
|
|
543
|
+
isMulti,
|
|
544
|
+
isSearchable: false,
|
|
545
|
+
menuPlacement: "auto",
|
|
546
|
+
className: "react-select-container",
|
|
547
|
+
components: { NoOptionsMessage },
|
|
548
|
+
classNamePrefix: "react-select",
|
|
549
|
+
isDisabled: disabled,
|
|
550
|
+
options,
|
|
551
|
+
value: displayValue.label !== null && displayValue.label !== void 0 ? displayValue : null,
|
|
552
|
+
onChange: (e) => {
|
|
553
|
+
onChange(e);
|
|
554
|
+
onSelect && onSelect();
|
|
555
|
+
},
|
|
556
|
+
styles: {
|
|
557
|
+
control: (baseStyles) => ({
|
|
558
|
+
...baseStyles,
|
|
559
|
+
boxShadow: "none"
|
|
560
|
+
}),
|
|
561
|
+
menuPortal: (base) => ({
|
|
562
|
+
...base,
|
|
563
|
+
zIndex: 99,
|
|
564
|
+
...styleVars
|
|
565
|
+
})
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
),
|
|
569
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
570
|
+
TooltipErrorInput,
|
|
571
|
+
{
|
|
572
|
+
error,
|
|
573
|
+
name,
|
|
574
|
+
isSelect: true,
|
|
575
|
+
isInvalid: value && error?.message
|
|
576
|
+
}
|
|
577
|
+
)
|
|
578
|
+
] });
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
)
|
|
582
|
+
] });
|
|
583
|
+
};
|
|
584
|
+
var InputSelect = (0, import_react7.forwardRef)(InputBase2);
|
|
585
|
+
|
|
355
586
|
// src/components/ModalBase/ModalBase.tsx
|
|
356
|
-
var
|
|
587
|
+
var import_react8 = require("@phosphor-icons/react");
|
|
357
588
|
|
|
358
589
|
// src/components/ModalBase/FooterButtons.tsx
|
|
359
|
-
var
|
|
590
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
360
591
|
function FooterButtons({ children }) {
|
|
361
|
-
return /* @__PURE__ */ (0,
|
|
592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "modal-footer", children });
|
|
362
593
|
}
|
|
363
594
|
|
|
364
595
|
// src/components/ModalBase/ModalBase.tsx
|
|
365
|
-
var
|
|
366
|
-
var
|
|
596
|
+
var import_react9 = require("react");
|
|
597
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
367
598
|
function ModalBase({
|
|
368
599
|
show,
|
|
369
600
|
onHide,
|
|
@@ -373,9 +604,25 @@ function ModalBase({
|
|
|
373
604
|
loading,
|
|
374
605
|
btnCancel = "Cancel",
|
|
375
606
|
btnSuccess = "Save",
|
|
376
|
-
|
|
607
|
+
type = "button",
|
|
608
|
+
disabledBtnSuccess,
|
|
609
|
+
colors,
|
|
610
|
+
fonts,
|
|
611
|
+
modalMaxWidth
|
|
377
612
|
}) {
|
|
378
|
-
|
|
613
|
+
const styleVars = {
|
|
614
|
+
"--modal-title-font-weight": fonts?.modalTitleFontWeight,
|
|
615
|
+
"--modal-title-font-size": fonts?.modalTitleFontSize,
|
|
616
|
+
"--modal-title-font-family": fonts?.modalTitleFontFamily,
|
|
617
|
+
"--modal-body-font-family": fonts?.modalBodyFontFamily,
|
|
618
|
+
"--modal-body-font-size": fonts?.modalBodyFontSize,
|
|
619
|
+
"--modal-bg-color": colors?.modalBgColor,
|
|
620
|
+
"--modal-title-color": colors?.modalTitleColor,
|
|
621
|
+
"--modal-body-color": colors?.modalBodyColor,
|
|
622
|
+
"--modal-close-color": colors?.modalCloseColor,
|
|
623
|
+
"--modal-max-width": modalMaxWidth?.modalMaxWidth
|
|
624
|
+
};
|
|
625
|
+
(0, import_react9.useEffect)(() => {
|
|
379
626
|
const handleKeyDown = (event) => {
|
|
380
627
|
if (event.key === "Escape") {
|
|
381
628
|
onHide();
|
|
@@ -386,22 +633,15 @@ function ModalBase({
|
|
|
386
633
|
document.removeEventListener("keydown", handleKeyDown);
|
|
387
634
|
};
|
|
388
635
|
}, [onHide]);
|
|
389
|
-
return /* @__PURE__ */ (0,
|
|
390
|
-
/* @__PURE__ */ (0,
|
|
391
|
-
/* @__PURE__ */ (0,
|
|
392
|
-
/* @__PURE__ */ (0,
|
|
393
|
-
/* @__PURE__ */ (0,
|
|
394
|
-
"button",
|
|
395
|
-
{
|
|
396
|
-
className: "p-1 ml-auto mr-1 cursor-pointer",
|
|
397
|
-
onClick: onHide,
|
|
398
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react6.X, { size: 18, color: "#ffffff" })
|
|
399
|
-
}
|
|
400
|
-
)
|
|
636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: show ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
637
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "modal-overlay", style: styleVars, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "modal-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "modal-content", children: [
|
|
638
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "modal-header", children: [
|
|
639
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { className: "modal-title", children: title }),
|
|
640
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "modal-close", type: "button", onClick: onHide, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react8.X, { size: 18, className: "button-close" }) })
|
|
401
641
|
] }),
|
|
402
|
-
/* @__PURE__ */ (0,
|
|
403
|
-
/* @__PURE__ */ (0,
|
|
404
|
-
/* @__PURE__ */ (0,
|
|
642
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "modal-body", children }),
|
|
643
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(FooterButtons, { children: [
|
|
644
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
405
645
|
Button,
|
|
406
646
|
{
|
|
407
647
|
color: "danger",
|
|
@@ -410,10 +650,10 @@ function ModalBase({
|
|
|
410
650
|
onClick: onHide
|
|
411
651
|
}
|
|
412
652
|
),
|
|
413
|
-
/* @__PURE__ */ (0,
|
|
653
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
414
654
|
Button,
|
|
415
655
|
{
|
|
416
|
-
type
|
|
656
|
+
type,
|
|
417
657
|
title: btnSuccess,
|
|
418
658
|
onClick: onAction,
|
|
419
659
|
loading,
|
|
@@ -422,16 +662,197 @@ function ModalBase({
|
|
|
422
662
|
)
|
|
423
663
|
] })
|
|
424
664
|
] }) }) }),
|
|
425
|
-
/* @__PURE__ */ (0,
|
|
665
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "modal-backdrop" })
|
|
426
666
|
] }) : null });
|
|
427
667
|
}
|
|
428
668
|
|
|
669
|
+
// src/components/Input/InputAutocomplete.tsx
|
|
670
|
+
var import_react11 = require("@phosphor-icons/react");
|
|
671
|
+
var import_lodash2 = __toESM(require("lodash"));
|
|
672
|
+
var import_react12 = require("react");
|
|
673
|
+
var import_react_query = require("@tanstack/react-query");
|
|
674
|
+
|
|
675
|
+
// src/components/Loading/Loading.tsx
|
|
676
|
+
var import_react10 = require("react");
|
|
677
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
678
|
+
var LoadingSpinner = (0, import_react10.memo)(
|
|
679
|
+
({ size = 24, color = "#00875F" }) => {
|
|
680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
681
|
+
"span",
|
|
682
|
+
{
|
|
683
|
+
style: {
|
|
684
|
+
width: size,
|
|
685
|
+
height: size,
|
|
686
|
+
border: `3px solid ${color}33`,
|
|
687
|
+
borderTopColor: color,
|
|
688
|
+
borderRadius: "50%",
|
|
689
|
+
display: "inline-block",
|
|
690
|
+
animation: "leafcode-spin 0.8s linear infinite"
|
|
691
|
+
},
|
|
692
|
+
"aria-label": "Carregando"
|
|
693
|
+
}
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
);
|
|
697
|
+
LoadingSpinner.displayName = "LoadingSpinner";
|
|
698
|
+
|
|
699
|
+
// src/components/Input/InputAutocomplete.tsx
|
|
700
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
701
|
+
var PAGE_SIZE = 10;
|
|
702
|
+
var InputBase3 = ({
|
|
703
|
+
name,
|
|
704
|
+
label,
|
|
705
|
+
error,
|
|
706
|
+
onSelect,
|
|
707
|
+
defaultValue,
|
|
708
|
+
inputAutocompleteActive,
|
|
709
|
+
queryKey,
|
|
710
|
+
mutationFn,
|
|
711
|
+
renderOption,
|
|
712
|
+
disabled,
|
|
713
|
+
placeholder,
|
|
714
|
+
isUppercaseLabel = true,
|
|
715
|
+
...rest
|
|
716
|
+
}, ref) => {
|
|
717
|
+
const theme = useLeafcodeTheme();
|
|
718
|
+
const styleVars = {
|
|
719
|
+
"--label-font-family": theme.components.input.fonts.label,
|
|
720
|
+
"--label-font-weight": theme.components.input.fonts.labelWeight,
|
|
721
|
+
"--label-font-size": theme.components.input.fonts.labelSize,
|
|
722
|
+
"--dropdown-empty-color": theme.components.input.colors.text,
|
|
723
|
+
"--dropdown-item-hover-bg-color": theme.colors.primary,
|
|
724
|
+
"--label-color": theme.components.input.colors.text,
|
|
725
|
+
"--input-border": theme.components.input.colors.border,
|
|
726
|
+
"--input-bg": theme.components.input.colors.background,
|
|
727
|
+
"--input-text-color": theme.components.input.colors.text,
|
|
728
|
+
"--input-focus-border": theme.components.input.colors.focusBorder,
|
|
729
|
+
"--dropdown-item-hover-color": theme.colors.light,
|
|
730
|
+
"--input-height": theme.components.input.sizes.height,
|
|
731
|
+
"--input-border-radius": theme.components.input.sizes.radius
|
|
732
|
+
};
|
|
733
|
+
const [value, setValue] = (0, import_react12.useState)("");
|
|
734
|
+
const [items, setItems] = (0, import_react12.useState)([]);
|
|
735
|
+
const [pageNumber, setPageNumber] = (0, import_react12.useState)(1);
|
|
736
|
+
const [search, setSearch] = (0, import_react12.useState)("");
|
|
737
|
+
const [isOpen, setIsOpen] = (0, import_react12.useState)(false);
|
|
738
|
+
const listRef = (0, import_react12.useRef)(null);
|
|
739
|
+
const { data, isLoading } = (0, import_react_query.useQuery)({
|
|
740
|
+
queryKey: [queryKey, pageNumber, search],
|
|
741
|
+
queryFn: () => mutationFn(pageNumber, PAGE_SIZE, search),
|
|
742
|
+
enabled: isOpen
|
|
743
|
+
});
|
|
744
|
+
(0, import_react12.useEffect)(() => {
|
|
745
|
+
if (!data?.items) return;
|
|
746
|
+
setItems(
|
|
747
|
+
(prev) => pageNumber === 1 ? data.items : [...prev, ...data.items]
|
|
748
|
+
);
|
|
749
|
+
}, [data, pageNumber]);
|
|
750
|
+
(0, import_react12.useEffect)(() => {
|
|
751
|
+
const debounced = import_lodash2.default.debounce(() => {
|
|
752
|
+
setPageNumber(1);
|
|
753
|
+
setItems([]);
|
|
754
|
+
setSearch(value);
|
|
755
|
+
}, 600);
|
|
756
|
+
debounced();
|
|
757
|
+
return () => debounced.cancel();
|
|
758
|
+
}, [value]);
|
|
759
|
+
(0, import_react12.useEffect)(() => {
|
|
760
|
+
if (!defaultValue) return;
|
|
761
|
+
setValue(defaultValue.label ?? defaultValue);
|
|
762
|
+
}, [defaultValue]);
|
|
763
|
+
const handleScroll = () => {
|
|
764
|
+
if (!listRef.current || !data) return;
|
|
765
|
+
const { scrollTop, clientHeight, scrollHeight } = listRef.current;
|
|
766
|
+
if (scrollTop + clientHeight >= scrollHeight - 10 && pageNumber < data.totalPages && !isLoading) {
|
|
767
|
+
setPageNumber((prev) => prev + 1);
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
const handleSelect = (item) => {
|
|
771
|
+
setValue(item.nome);
|
|
772
|
+
setIsOpen(false);
|
|
773
|
+
onSelect(item);
|
|
774
|
+
};
|
|
775
|
+
const renderDropdown = () => {
|
|
776
|
+
if (!isOpen) return null;
|
|
777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "dropdown-container", style: styleVars, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("ul", { ref: listRef, onScroll: handleScroll, className: "dropdown-list", children: [
|
|
778
|
+
items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
779
|
+
"li",
|
|
780
|
+
{
|
|
781
|
+
onClick: () => handleSelect(item),
|
|
782
|
+
className: "dropdown-item",
|
|
783
|
+
children: renderOption(item)
|
|
784
|
+
},
|
|
785
|
+
item.id
|
|
786
|
+
)),
|
|
787
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { className: "dropdown-loading", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LoadingSpinner, { size: 24 }) }),
|
|
788
|
+
!isLoading && items.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { className: "dropdown-empty", children: "N\xE3o encontrado" })
|
|
789
|
+
] }) });
|
|
790
|
+
};
|
|
791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
792
|
+
"div",
|
|
793
|
+
{
|
|
794
|
+
className: "input-wrapper",
|
|
795
|
+
style: styleVars,
|
|
796
|
+
tabIndex: -1,
|
|
797
|
+
onBlur: (e) => e.relatedTarget === null && setIsOpen(false),
|
|
798
|
+
children: [
|
|
799
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
800
|
+
"label",
|
|
801
|
+
{
|
|
802
|
+
htmlFor: name,
|
|
803
|
+
className: `label-input ${isUppercaseLabel && "is-uppercase"}`,
|
|
804
|
+
children: label
|
|
805
|
+
}
|
|
806
|
+
),
|
|
807
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: { position: "relative", width: "100%" }, children: [
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
809
|
+
"input",
|
|
810
|
+
{
|
|
811
|
+
ref,
|
|
812
|
+
id: name,
|
|
813
|
+
name,
|
|
814
|
+
disabled,
|
|
815
|
+
placeholder,
|
|
816
|
+
autoComplete: "off",
|
|
817
|
+
className: "input",
|
|
818
|
+
value,
|
|
819
|
+
onChange: (e) => {
|
|
820
|
+
setValue(e.target.value);
|
|
821
|
+
setIsOpen(true);
|
|
822
|
+
},
|
|
823
|
+
onFocus: () => setIsOpen(true),
|
|
824
|
+
...rest
|
|
825
|
+
}
|
|
826
|
+
),
|
|
827
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
828
|
+
"button",
|
|
829
|
+
{
|
|
830
|
+
type: "button",
|
|
831
|
+
onClick: () => {
|
|
832
|
+
setValue("");
|
|
833
|
+
setItems([]);
|
|
834
|
+
setPageNumber(1);
|
|
835
|
+
onSelect(null);
|
|
836
|
+
},
|
|
837
|
+
className: "dropdown-clear",
|
|
838
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react11.X, { size: 16, className: "icone-clear" })
|
|
839
|
+
}
|
|
840
|
+
),
|
|
841
|
+
renderDropdown()
|
|
842
|
+
] }),
|
|
843
|
+
!value && !isOpen && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipErrorInput, { error, name })
|
|
844
|
+
]
|
|
845
|
+
}
|
|
846
|
+
);
|
|
847
|
+
};
|
|
848
|
+
var InputAutoComplete = (0, import_react12.forwardRef)(InputBase3);
|
|
849
|
+
|
|
429
850
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilter.tsx
|
|
430
|
-
var
|
|
851
|
+
var import_react19 = require("react");
|
|
431
852
|
|
|
432
853
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilterWrapper.tsx
|
|
433
|
-
var
|
|
434
|
-
var
|
|
854
|
+
var import_react17 = require("react");
|
|
855
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
435
856
|
|
|
436
857
|
// src/primereact-compat.ts
|
|
437
858
|
var import_datatable = require("primereact/datatable");
|
|
@@ -442,8 +863,8 @@ var import_calendar = require("primereact/calendar");
|
|
|
442
863
|
var import_api = require("primereact/api");
|
|
443
864
|
|
|
444
865
|
// src/components/DataTableAdvancedFilter/TableHeader.tsx
|
|
445
|
-
var
|
|
446
|
-
var
|
|
866
|
+
var import_react13 = require("@phosphor-icons/react");
|
|
867
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
447
868
|
var TableHeader = ({
|
|
448
869
|
globalFilterValue,
|
|
449
870
|
onGlobalFilterChange,
|
|
@@ -454,8 +875,8 @@ var TableHeader = ({
|
|
|
454
875
|
target: { value: "" }
|
|
455
876
|
});
|
|
456
877
|
};
|
|
457
|
-
return /* @__PURE__ */ (0,
|
|
458
|
-
/* @__PURE__ */ (0,
|
|
878
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { position: "relative" }, children: [
|
|
879
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
459
880
|
import_inputtext.InputText,
|
|
460
881
|
{
|
|
461
882
|
value: globalFilterValue,
|
|
@@ -464,16 +885,16 @@ var TableHeader = ({
|
|
|
464
885
|
className: "custom-input input-search"
|
|
465
886
|
}
|
|
466
887
|
),
|
|
467
|
-
/* @__PURE__ */ (0,
|
|
888
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react13.X, { size: 16, className: "close-search", onClick: limparCampo })
|
|
468
889
|
] });
|
|
469
890
|
};
|
|
470
891
|
var TableHeader_default = TableHeader;
|
|
471
892
|
|
|
472
893
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilterWrapper.tsx
|
|
473
|
-
var
|
|
894
|
+
var import_react18 = require("@phosphor-icons/react");
|
|
474
895
|
|
|
475
896
|
// src/components/DataTableAdvancedFilter/TableActions.tsx
|
|
476
|
-
var
|
|
897
|
+
var import_react14 = require("@phosphor-icons/react");
|
|
477
898
|
|
|
478
899
|
// src/utils/utils.ts
|
|
479
900
|
var import_clsx = require("clsx");
|
|
@@ -494,10 +915,10 @@ function centsToReal(value) {
|
|
|
494
915
|
// src/components/TooltipCustom.tsx
|
|
495
916
|
var import_react_tooltip2 = require("react-tooltip");
|
|
496
917
|
var import_react_dom = require("react-dom");
|
|
497
|
-
var
|
|
918
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
498
919
|
function TooltipCustom({ label, id }) {
|
|
499
920
|
return (0, import_react_dom.createPortal)(
|
|
500
|
-
/* @__PURE__ */ (0,
|
|
921
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
501
922
|
import_react_tooltip2.Tooltip,
|
|
502
923
|
{
|
|
503
924
|
anchorSelect: `#${id}`,
|
|
@@ -505,7 +926,7 @@ function TooltipCustom({ label, id }) {
|
|
|
505
926
|
positionStrategy: "fixed",
|
|
506
927
|
className: "tooltip-icone",
|
|
507
928
|
style: { zIndex: 13 },
|
|
508
|
-
children: /* @__PURE__ */ (0,
|
|
929
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "tooltip-custom", children: label })
|
|
509
930
|
}
|
|
510
931
|
),
|
|
511
932
|
document.body
|
|
@@ -513,7 +934,7 @@ function TooltipCustom({ label, id }) {
|
|
|
513
934
|
}
|
|
514
935
|
|
|
515
936
|
// src/components/DataTableAdvancedFilter/TableActions.tsx
|
|
516
|
-
var
|
|
937
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
517
938
|
function TableActions({
|
|
518
939
|
onNew,
|
|
519
940
|
onEdit,
|
|
@@ -525,9 +946,9 @@ function TableActions({
|
|
|
525
946
|
const disableButtonsNotMultiplesSelecteds = selectedRows?.length !== 1 ? true : false;
|
|
526
947
|
const enableButtonsNotMultiplesSelecteds = selectedRows?.length > 0 ? true : false;
|
|
527
948
|
const resolvedCustomActions = typeof customActions === "function" ? customActions(selectedRows) : customActions;
|
|
528
|
-
return /* @__PURE__ */ (0,
|
|
529
|
-
onNew && /* @__PURE__ */ (0,
|
|
530
|
-
/* @__PURE__ */ (0,
|
|
949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "box-icones-table-actions", children: [
|
|
950
|
+
onNew && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
951
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
531
952
|
"button",
|
|
532
953
|
{
|
|
533
954
|
id: "add",
|
|
@@ -538,10 +959,10 @@ function TableActions({
|
|
|
538
959
|
enableButtonsNotMultiplesSelecteds && "disable-button-table-actions"
|
|
539
960
|
),
|
|
540
961
|
disabled: enableButtonsNotMultiplesSelecteds,
|
|
541
|
-
children: /* @__PURE__ */ (0,
|
|
962
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react14.Plus, { size: 18 })
|
|
542
963
|
}
|
|
543
964
|
),
|
|
544
|
-
/* @__PURE__ */ (0,
|
|
965
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
545
966
|
TooltipCustom,
|
|
546
967
|
{
|
|
547
968
|
id: "add",
|
|
@@ -549,7 +970,7 @@ function TableActions({
|
|
|
549
970
|
}
|
|
550
971
|
)
|
|
551
972
|
] }),
|
|
552
|
-
onEdit && /* @__PURE__ */ (0,
|
|
973
|
+
onEdit && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
553
974
|
"button",
|
|
554
975
|
{
|
|
555
976
|
id: "edit",
|
|
@@ -561,8 +982,8 @@ function TableActions({
|
|
|
561
982
|
),
|
|
562
983
|
disabled: disableButtonsNotMultiplesSelecteds,
|
|
563
984
|
children: [
|
|
564
|
-
/* @__PURE__ */ (0,
|
|
565
|
-
/* @__PURE__ */ (0,
|
|
985
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react14.PencilSimple, { size: 18 }),
|
|
986
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
566
987
|
TooltipCustom,
|
|
567
988
|
{
|
|
568
989
|
id: "edit",
|
|
@@ -572,7 +993,7 @@ function TableActions({
|
|
|
572
993
|
]
|
|
573
994
|
}
|
|
574
995
|
) }),
|
|
575
|
-
onDelete && /* @__PURE__ */ (0,
|
|
996
|
+
onDelete && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
576
997
|
"button",
|
|
577
998
|
{
|
|
578
999
|
id: "delete",
|
|
@@ -584,8 +1005,8 @@ function TableActions({
|
|
|
584
1005
|
),
|
|
585
1006
|
disabled: !enableButtonsNotMultiplesSelecteds,
|
|
586
1007
|
children: [
|
|
587
|
-
/* @__PURE__ */ (0,
|
|
588
|
-
/* @__PURE__ */ (0,
|
|
1008
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react14.Trash, { size: 18 }),
|
|
1009
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
589
1010
|
TooltipCustom,
|
|
590
1011
|
{
|
|
591
1012
|
id: "delete",
|
|
@@ -597,7 +1018,7 @@ function TableActions({
|
|
|
597
1018
|
) }),
|
|
598
1019
|
resolvedCustomActions?.map((action) => {
|
|
599
1020
|
const id = `action-table${phraseToId(action.label)}`;
|
|
600
|
-
return /* @__PURE__ */ (0,
|
|
1021
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
601
1022
|
"button",
|
|
602
1023
|
{
|
|
603
1024
|
id,
|
|
@@ -606,7 +1027,7 @@ function TableActions({
|
|
|
606
1027
|
className: cn("enable-button-table-actions", action.className),
|
|
607
1028
|
children: [
|
|
608
1029
|
action.icon,
|
|
609
|
-
/* @__PURE__ */ (0,
|
|
1030
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipCustom, { id, label: action.label })
|
|
610
1031
|
]
|
|
611
1032
|
},
|
|
612
1033
|
id
|
|
@@ -616,8 +1037,8 @@ function TableActions({
|
|
|
616
1037
|
}
|
|
617
1038
|
|
|
618
1039
|
// src/components/DataTableAdvancedFilter/ActionsColumn.tsx
|
|
619
|
-
var
|
|
620
|
-
var
|
|
1040
|
+
var import_react15 = require("@phosphor-icons/react");
|
|
1041
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
621
1042
|
function ActionsColumn({
|
|
622
1043
|
row,
|
|
623
1044
|
onEdit,
|
|
@@ -626,8 +1047,8 @@ function ActionsColumn({
|
|
|
626
1047
|
isLanguagePtBr
|
|
627
1048
|
}) {
|
|
628
1049
|
const resolvedCustomActions = typeof customActionsColums === "function" ? customActionsColums(row) : customActionsColums;
|
|
629
|
-
return /* @__PURE__ */ (0,
|
|
630
|
-
onEdit && /* @__PURE__ */ (0,
|
|
1050
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "box-icones-actions-column", children: [
|
|
1051
|
+
onEdit && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
631
1052
|
"button",
|
|
632
1053
|
{
|
|
633
1054
|
id: "edit-column",
|
|
@@ -637,8 +1058,8 @@ function ActionsColumn({
|
|
|
637
1058
|
onEdit && onEdit([row]);
|
|
638
1059
|
},
|
|
639
1060
|
children: [
|
|
640
|
-
/* @__PURE__ */ (0,
|
|
641
|
-
/* @__PURE__ */ (0,
|
|
1061
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react15.PencilSimple, { size: 17, weight: "regular" }),
|
|
1062
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
642
1063
|
TooltipCustom,
|
|
643
1064
|
{
|
|
644
1065
|
id: "edit-column",
|
|
@@ -648,7 +1069,7 @@ function ActionsColumn({
|
|
|
648
1069
|
]
|
|
649
1070
|
}
|
|
650
1071
|
) }),
|
|
651
|
-
onDelete && /* @__PURE__ */ (0,
|
|
1072
|
+
onDelete && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
652
1073
|
"button",
|
|
653
1074
|
{
|
|
654
1075
|
id: "delete-column",
|
|
@@ -658,8 +1079,8 @@ function ActionsColumn({
|
|
|
658
1079
|
onDelete && onDelete([row]);
|
|
659
1080
|
},
|
|
660
1081
|
children: [
|
|
661
|
-
/* @__PURE__ */ (0,
|
|
662
|
-
/* @__PURE__ */ (0,
|
|
1082
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react15.Trash, { size: 17, weight: "regular" }),
|
|
1083
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
663
1084
|
TooltipCustom,
|
|
664
1085
|
{
|
|
665
1086
|
id: "delete-column",
|
|
@@ -671,7 +1092,7 @@ function ActionsColumn({
|
|
|
671
1092
|
) }),
|
|
672
1093
|
resolvedCustomActions?.map((action) => {
|
|
673
1094
|
const id = `action-colunm-${phraseToId(action.label)}`;
|
|
674
|
-
return /* @__PURE__ */ (0,
|
|
1095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
675
1096
|
"button",
|
|
676
1097
|
{
|
|
677
1098
|
id,
|
|
@@ -680,7 +1101,7 @@ function ActionsColumn({
|
|
|
680
1101
|
className: cn("btn-icone-actions-column", action.className),
|
|
681
1102
|
children: [
|
|
682
1103
|
action.icon,
|
|
683
|
-
/* @__PURE__ */ (0,
|
|
1104
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipCustom, { id, label: action.label })
|
|
684
1105
|
]
|
|
685
1106
|
},
|
|
686
1107
|
id
|
|
@@ -690,7 +1111,7 @@ function ActionsColumn({
|
|
|
690
1111
|
}
|
|
691
1112
|
|
|
692
1113
|
// src/components/DataTableAdvancedFilter/DynamicColumns.tsx
|
|
693
|
-
var
|
|
1114
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
694
1115
|
function DynamicColumns({
|
|
695
1116
|
columns,
|
|
696
1117
|
isMultiSelectionMode = true,
|
|
@@ -702,7 +1123,7 @@ function DynamicColumns({
|
|
|
702
1123
|
const array = [];
|
|
703
1124
|
if (isMultiSelectionMode) {
|
|
704
1125
|
array.push(
|
|
705
|
-
/* @__PURE__ */ (0,
|
|
1126
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
706
1127
|
import_column.Column,
|
|
707
1128
|
{
|
|
708
1129
|
selectionMode: "multiple",
|
|
@@ -719,7 +1140,7 @@ function DynamicColumns({
|
|
|
719
1140
|
const width = isActionsCol && col?.size ? col.size + "rem" : "6rem";
|
|
720
1141
|
const placeholder = isLanguagePtBr ? "Procurar" : "Search";
|
|
721
1142
|
array.push(
|
|
722
|
-
/* @__PURE__ */ (0,
|
|
1143
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
723
1144
|
import_column.Column,
|
|
724
1145
|
{
|
|
725
1146
|
field: isActionsCol ? void 0 : col.field,
|
|
@@ -737,7 +1158,7 @@ function DynamicColumns({
|
|
|
737
1158
|
resizeable: col.enableResizeable ?? true
|
|
738
1159
|
},
|
|
739
1160
|
style: isActionsCol ? { width, minWidth: width, position: "relative" } : {},
|
|
740
|
-
body: (rowData) => isActionsCol ? /* @__PURE__ */ (0,
|
|
1161
|
+
body: (rowData) => isActionsCol ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
741
1162
|
ActionsColumn,
|
|
742
1163
|
{
|
|
743
1164
|
row: rowData,
|
|
@@ -746,7 +1167,7 @@ function DynamicColumns({
|
|
|
746
1167
|
customActionsColums,
|
|
747
1168
|
isLanguagePtBr
|
|
748
1169
|
}
|
|
749
|
-
) : col.body ? col.body(rowData) : /* @__PURE__ */ (0,
|
|
1170
|
+
) : col.body ? col.body(rowData) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: String(rowData[col.field]) }),
|
|
750
1171
|
sortable: !isActionsCol ? col.enableSorting ?? true : false
|
|
751
1172
|
},
|
|
752
1173
|
`${String(col.field)}-${idx}`
|
|
@@ -757,10 +1178,10 @@ function DynamicColumns({
|
|
|
757
1178
|
}
|
|
758
1179
|
|
|
759
1180
|
// src/hooks/use-debounce.ts
|
|
760
|
-
var
|
|
1181
|
+
var import_react16 = require("react");
|
|
761
1182
|
var useDebounce = (value, delay) => {
|
|
762
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
763
|
-
(0,
|
|
1183
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react16.useState)(value);
|
|
1184
|
+
(0, import_react16.useEffect)(() => {
|
|
764
1185
|
const timer = setTimeout(() => {
|
|
765
1186
|
setDebouncedValue(value);
|
|
766
1187
|
}, delay || 500);
|
|
@@ -772,7 +1193,7 @@ var useDebounce = (value, delay) => {
|
|
|
772
1193
|
};
|
|
773
1194
|
|
|
774
1195
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilterWrapper.tsx
|
|
775
|
-
var
|
|
1196
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
776
1197
|
function DataTableAdvancedFilterWrapper({
|
|
777
1198
|
queryKey,
|
|
778
1199
|
mutationFn,
|
|
@@ -792,8 +1213,8 @@ function DataTableAdvancedFilterWrapper({
|
|
|
792
1213
|
state,
|
|
793
1214
|
onStateChange
|
|
794
1215
|
}) {
|
|
795
|
-
const [isClient, setIsClient] = (0,
|
|
796
|
-
(0,
|
|
1216
|
+
const [isClient, setIsClient] = (0, import_react17.useState)(false);
|
|
1217
|
+
(0, import_react17.useEffect)(() => {
|
|
797
1218
|
setIsClient(true);
|
|
798
1219
|
}, []);
|
|
799
1220
|
const initialState = state ?? {
|
|
@@ -803,31 +1224,31 @@ function DataTableAdvancedFilterWrapper({
|
|
|
803
1224
|
sortOrder: sortOrderInitial,
|
|
804
1225
|
filter: ""
|
|
805
1226
|
};
|
|
806
|
-
const [page, setPage] = (0,
|
|
807
|
-
const [rows, setRows] = (0,
|
|
808
|
-
const [first, setFirst] = (0,
|
|
809
|
-
const [sortField, setSortField] = (0,
|
|
810
|
-
const [sortOrder, setSortOrder] = (0,
|
|
811
|
-
const [searchText, setSearchText] = (0,
|
|
812
|
-
const [filters, setFilters] = (0,
|
|
1227
|
+
const [page, setPage] = (0, import_react17.useState)(initialState.page);
|
|
1228
|
+
const [rows, setRows] = (0, import_react17.useState)(initialState.rows);
|
|
1229
|
+
const [first, setFirst] = (0, import_react17.useState)((initialState.page - 1) * initialState.rows);
|
|
1230
|
+
const [sortField, setSortField] = (0, import_react17.useState)(initialState.sortField);
|
|
1231
|
+
const [sortOrder, setSortOrder] = (0, import_react17.useState)(initialState.sortOrder ?? 1);
|
|
1232
|
+
const [searchText, setSearchText] = (0, import_react17.useState)(initialState.filter ?? "");
|
|
1233
|
+
const [filters, setFilters] = (0, import_react17.useState)({
|
|
813
1234
|
...initFilters,
|
|
814
1235
|
global: { value: initialState.filter, matchMode: "contains" }
|
|
815
1236
|
});
|
|
816
|
-
const [selectedRowsData, setSelectedRowsData] = (0,
|
|
1237
|
+
const [selectedRowsData, setSelectedRowsData] = (0, import_react17.useState)([]);
|
|
817
1238
|
const debouncedSearch = useDebounce(searchText, 500);
|
|
818
|
-
const debouncedFilters = (0,
|
|
1239
|
+
const debouncedFilters = (0, import_react17.useMemo)(() => {
|
|
819
1240
|
const f = { ...filters };
|
|
820
1241
|
if (!f.global) f.global = { value: "", matchMode: "contains" };
|
|
821
1242
|
f.global.value = debouncedSearch;
|
|
822
1243
|
return f;
|
|
823
1244
|
}, [filters, debouncedSearch]);
|
|
824
1245
|
const filtersKey = JSON.stringify(debouncedFilters);
|
|
825
|
-
const globalFilterFields = (0,
|
|
1246
|
+
const globalFilterFields = (0, import_react17.useMemo)(() => {
|
|
826
1247
|
return columns?.filter(
|
|
827
1248
|
(col) => col.filterGlobal === true && (col.field !== "acoes" || col.field !== "actions")
|
|
828
1249
|
).map((col) => col.field) ?? [];
|
|
829
1250
|
}, [columns]);
|
|
830
|
-
const { data: customers, isLoading } = (0,
|
|
1251
|
+
const { data: customers, isLoading } = (0, import_react_query2.useQuery)({
|
|
831
1252
|
queryKey: [queryKey, { page, rows, sortField, sortOrder, filtersKey }],
|
|
832
1253
|
queryFn: () => mutationFn(
|
|
833
1254
|
page,
|
|
@@ -838,7 +1259,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
838
1259
|
globalFilterFields
|
|
839
1260
|
)
|
|
840
1261
|
});
|
|
841
|
-
(0,
|
|
1262
|
+
(0, import_react17.useEffect)(() => {
|
|
842
1263
|
if (!state) return;
|
|
843
1264
|
setPage(state.page);
|
|
844
1265
|
setRows(state.rows);
|
|
@@ -894,7 +1315,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
894
1315
|
filter: searchText
|
|
895
1316
|
});
|
|
896
1317
|
};
|
|
897
|
-
(0,
|
|
1318
|
+
(0, import_react17.useEffect)(() => {
|
|
898
1319
|
emitStateChange({
|
|
899
1320
|
page: 1,
|
|
900
1321
|
rows,
|
|
@@ -903,7 +1324,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
903
1324
|
filter: debouncedSearch
|
|
904
1325
|
});
|
|
905
1326
|
}, [debouncedSearch]);
|
|
906
|
-
(0,
|
|
1327
|
+
(0, import_react17.useEffect)(() => {
|
|
907
1328
|
if (customers?.items && selectedRowsData.length > 0) {
|
|
908
1329
|
const currentIds = new Set(customers.items.map((item) => item.id));
|
|
909
1330
|
const filteredSelection = selectedRowsData.filter(
|
|
@@ -914,9 +1335,9 @@ function DataTableAdvancedFilterWrapper({
|
|
|
914
1335
|
}
|
|
915
1336
|
}
|
|
916
1337
|
}, [customers?.items, selectedRowsData]);
|
|
917
|
-
const TableHeaderAndTableActions = (0,
|
|
918
|
-
() => /* @__PURE__ */ (0,
|
|
919
|
-
globalFilterFields.length > 0 && /* @__PURE__ */ (0,
|
|
1338
|
+
const TableHeaderAndTableActions = (0, import_react17.useMemo)(
|
|
1339
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
1340
|
+
globalFilterFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
920
1341
|
TableHeader_default,
|
|
921
1342
|
{
|
|
922
1343
|
isLanguagePtBr,
|
|
@@ -924,7 +1345,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
924
1345
|
onGlobalFilterChange
|
|
925
1346
|
}
|
|
926
1347
|
),
|
|
927
|
-
/* @__PURE__ */ (0,
|
|
1348
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
928
1349
|
TableActions,
|
|
929
1350
|
{
|
|
930
1351
|
selectedRows: selectedRowsData,
|
|
@@ -947,9 +1368,9 @@ function DataTableAdvancedFilterWrapper({
|
|
|
947
1368
|
customActions
|
|
948
1369
|
]
|
|
949
1370
|
);
|
|
950
|
-
return /* @__PURE__ */ (0,
|
|
951
|
-
disablePagination && /* @__PURE__ */ (0,
|
|
952
|
-
/* @__PURE__ */ (0,
|
|
1371
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: isClient && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { children: [
|
|
1372
|
+
disablePagination && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "disablePagination", children: TableHeaderAndTableActions }),
|
|
1373
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
953
1374
|
import_datatable.DataTable,
|
|
954
1375
|
{
|
|
955
1376
|
value: customers?.items ?? [],
|
|
@@ -975,7 +1396,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
975
1396
|
sortOrder,
|
|
976
1397
|
paginatorTemplate: {
|
|
977
1398
|
layout: "RowsPerPageDropdown PrevPageLink CurrentPageReport NextPageLink",
|
|
978
|
-
RowsPerPageDropdown: (options) => /* @__PURE__ */ (0,
|
|
1399
|
+
RowsPerPageDropdown: (options) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
979
1400
|
"select",
|
|
980
1401
|
{
|
|
981
1402
|
value: options.value,
|
|
@@ -984,20 +1405,20 @@ function DataTableAdvancedFilterWrapper({
|
|
|
984
1405
|
value: Number(e.target.value)
|
|
985
1406
|
}),
|
|
986
1407
|
className: "custom-input custom-select",
|
|
987
|
-
children: options.options.map((opt) => /* @__PURE__ */ (0,
|
|
1408
|
+
children: options.options.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
|
|
988
1409
|
}
|
|
989
1410
|
),
|
|
990
|
-
PrevPageLink: (options) => /* @__PURE__ */ (0,
|
|
1411
|
+
PrevPageLink: (options) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
991
1412
|
"button",
|
|
992
1413
|
{
|
|
993
1414
|
type: "button",
|
|
994
1415
|
onClick: options.onClick,
|
|
995
1416
|
disabled: options.disabled,
|
|
996
1417
|
className: `PrevPage ${options.disabled ? "PrevPageDisabled" : "PrevPageEnabled"}`,
|
|
997
|
-
children: /* @__PURE__ */ (0,
|
|
1418
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react18.CaretLeft, { size: 18, color: "#fff" })
|
|
998
1419
|
}
|
|
999
1420
|
),
|
|
1000
|
-
CurrentPageReport: (options) => /* @__PURE__ */ (0,
|
|
1421
|
+
CurrentPageReport: (options) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "pageReport", children: [
|
|
1001
1422
|
isLanguagePtBr ? "Mostrando" : "Showing",
|
|
1002
1423
|
" ",
|
|
1003
1424
|
options.first,
|
|
@@ -1010,21 +1431,21 @@ function DataTableAdvancedFilterWrapper({
|
|
|
1010
1431
|
" ",
|
|
1011
1432
|
options.totalRecords
|
|
1012
1433
|
] }),
|
|
1013
|
-
NextPageLink: (options) => /* @__PURE__ */ (0,
|
|
1434
|
+
NextPageLink: (options) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1014
1435
|
"button",
|
|
1015
1436
|
{
|
|
1016
1437
|
type: "button",
|
|
1017
1438
|
onClick: options.onClick,
|
|
1018
1439
|
disabled: options.disabled,
|
|
1019
1440
|
className: `NextPage ${options.disabled ? "NextPageDisabled" : "NextPageEnabled"}`,
|
|
1020
|
-
children: /* @__PURE__ */ (0,
|
|
1441
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react18.CaretRight, { size: 18, color: "#fff" })
|
|
1021
1442
|
}
|
|
1022
1443
|
)
|
|
1023
1444
|
},
|
|
1024
1445
|
paginatorPosition: "top",
|
|
1025
|
-
paginatorLeft: /* @__PURE__ */ (0,
|
|
1446
|
+
paginatorLeft: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "paginatorLeft", children: TableHeaderAndTableActions }),
|
|
1026
1447
|
currentPageReportTemplate: "Mostrando {first} a {last} de {totalRecords}",
|
|
1027
|
-
emptyMessage: /* @__PURE__ */ (0,
|
|
1448
|
+
emptyMessage: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "mensagem-nenhum-dado", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { children: isLanguagePtBr ? "Nenhum dado encontrado" : "No data found" }) }),
|
|
1028
1449
|
onFilter: (e) => {
|
|
1029
1450
|
const newFilters = { ...e.filters };
|
|
1030
1451
|
Object.keys(filters).forEach((key) => {
|
|
@@ -1223,7 +1644,7 @@ var localePtBr = {
|
|
|
1223
1644
|
};
|
|
1224
1645
|
|
|
1225
1646
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilter.tsx
|
|
1226
|
-
var
|
|
1647
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1227
1648
|
function DataTableAdvancedFilter({
|
|
1228
1649
|
queryKey,
|
|
1229
1650
|
mutationFn,
|
|
@@ -1243,21 +1664,21 @@ function DataTableAdvancedFilter({
|
|
|
1243
1664
|
state,
|
|
1244
1665
|
onStateChange
|
|
1245
1666
|
}) {
|
|
1246
|
-
const [isClient, setIsClient] = (0,
|
|
1247
|
-
(0,
|
|
1667
|
+
const [isClient, setIsClient] = (0, import_react19.useState)(false);
|
|
1668
|
+
(0, import_react19.useEffect)(() => {
|
|
1248
1669
|
(0, import_api2.addLocale)("pt", localePtBr);
|
|
1249
1670
|
}, []);
|
|
1250
|
-
(0,
|
|
1671
|
+
(0, import_react19.useEffect)(() => {
|
|
1251
1672
|
(0, import_api2.locale)(isLanguagePtBr ? "pt" : "en");
|
|
1252
1673
|
}, [isLanguagePtBr]);
|
|
1253
|
-
(0,
|
|
1674
|
+
(0, import_react19.useEffect)(() => {
|
|
1254
1675
|
setIsClient(true);
|
|
1255
1676
|
}, []);
|
|
1256
|
-
return /* @__PURE__ */ (0,
|
|
1677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isClient && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1257
1678
|
import_api2.PrimeReactProvider,
|
|
1258
1679
|
{
|
|
1259
1680
|
value: isLanguagePtBr ? { locale: "pt" } : { locale: "en" },
|
|
1260
|
-
children: /* @__PURE__ */ (0,
|
|
1681
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1261
1682
|
DataTableAdvancedFilterWrapper,
|
|
1262
1683
|
{
|
|
1263
1684
|
rowsPerPageOptions,
|
|
@@ -1284,13 +1705,13 @@ function DataTableAdvancedFilter({
|
|
|
1284
1705
|
}
|
|
1285
1706
|
|
|
1286
1707
|
// src/components/DataTableAdvancedFilter/FilterTemplates.tsx
|
|
1287
|
-
var
|
|
1708
|
+
var import_react_select2 = __toESM(require("react-select"));
|
|
1288
1709
|
var import_dropdown = require("primereact/dropdown");
|
|
1289
1710
|
var import_moment2 = __toESM(require("moment"));
|
|
1290
|
-
var
|
|
1711
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1291
1712
|
var DateFilterTemplate = (options, mask) => {
|
|
1292
1713
|
const parsedValue = options.value && typeof options.value === "string" ? /* @__PURE__ */ new Date(options.value + "T00:00:00") : options.value;
|
|
1293
|
-
return /* @__PURE__ */ (0,
|
|
1714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1294
1715
|
import_calendar.Calendar,
|
|
1295
1716
|
{
|
|
1296
1717
|
value: parsedValue,
|
|
@@ -1315,7 +1736,7 @@ var DateFilterTemplate = (options, mask) => {
|
|
|
1315
1736
|
};
|
|
1316
1737
|
var DateTimeFilterTemplate = (options, mask) => {
|
|
1317
1738
|
const value = typeof options.value === "string" ? (0, import_moment2.default)(options.value).toDate() : options.value ?? null;
|
|
1318
|
-
return /* @__PURE__ */ (0,
|
|
1739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1319
1740
|
import_calendar.Calendar,
|
|
1320
1741
|
{
|
|
1321
1742
|
value,
|
|
@@ -1349,7 +1770,7 @@ var ValueFilterTemplate = (options, mask) => {
|
|
|
1349
1770
|
const valueToFilter = mask ? mask(rawValue) : rawValue;
|
|
1350
1771
|
options.filterCallback(valueToFilter, options.index);
|
|
1351
1772
|
};
|
|
1352
|
-
return /* @__PURE__ */ (0,
|
|
1773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1353
1774
|
import_inputnumber.InputNumber,
|
|
1354
1775
|
{
|
|
1355
1776
|
value: parsedValue,
|
|
@@ -1368,8 +1789,8 @@ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
|
|
|
1368
1789
|
{ label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
|
|
1369
1790
|
];
|
|
1370
1791
|
const currentValue = selectOptions.find((opt) => opt.value === options.value) || null;
|
|
1371
|
-
return /* @__PURE__ */ (0,
|
|
1372
|
-
|
|
1792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1793
|
+
import_react_select2.default,
|
|
1373
1794
|
{
|
|
1374
1795
|
options: selectOptions,
|
|
1375
1796
|
value: currentValue,
|
|
@@ -1427,7 +1848,7 @@ var CustomFilterElement = (options, isLanguagePtBr = true, items) => {
|
|
|
1427
1848
|
const currentMatchMode = rawFilter.matchMode ?? "contains";
|
|
1428
1849
|
const currentValue = typeof rawFilter.text === "string" ? rawFilter.text : "";
|
|
1429
1850
|
const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
|
|
1430
|
-
return /* @__PURE__ */ (0,
|
|
1851
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1431
1852
|
"div",
|
|
1432
1853
|
{
|
|
1433
1854
|
className: "filter-wrapper",
|
|
@@ -1438,7 +1859,7 @@ var CustomFilterElement = (options, isLanguagePtBr = true, items) => {
|
|
|
1438
1859
|
minWidth: "200px"
|
|
1439
1860
|
},
|
|
1440
1861
|
children: [
|
|
1441
|
-
/* @__PURE__ */ (0,
|
|
1862
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1442
1863
|
import_dropdown.Dropdown,
|
|
1443
1864
|
{
|
|
1444
1865
|
value: currentMatchMode,
|
|
@@ -1464,7 +1885,7 @@ var CustomFilterElement = (options, isLanguagePtBr = true, items) => {
|
|
|
1464
1885
|
}
|
|
1465
1886
|
}
|
|
1466
1887
|
),
|
|
1467
|
-
!isSpecial && /* @__PURE__ */ (0,
|
|
1888
|
+
!isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1468
1889
|
import_inputtext.InputText,
|
|
1469
1890
|
{
|
|
1470
1891
|
value: currentValue,
|
|
@@ -1885,6 +2306,9 @@ var import_api5 = require("primereact/api");
|
|
|
1885
2306
|
FilterMatchMode,
|
|
1886
2307
|
FilterOperator,
|
|
1887
2308
|
Input,
|
|
2309
|
+
InputAutoComplete,
|
|
2310
|
+
InputSelect,
|
|
2311
|
+
LeafcodeThemeProvider,
|
|
1888
2312
|
ModalBase,
|
|
1889
2313
|
SelectFilterTemplate,
|
|
1890
2314
|
TextArea,
|
|
@@ -1892,6 +2316,7 @@ var import_api5 = require("primereact/api");
|
|
|
1892
2316
|
buildDynamicCampoFilters,
|
|
1893
2317
|
buildSortingWithFilters,
|
|
1894
2318
|
customMatchModes,
|
|
2319
|
+
defaultTheme,
|
|
1895
2320
|
getDefaultFilterMatchOptionsDate,
|
|
1896
2321
|
getDefaultFilterMatchOptionsEnum,
|
|
1897
2322
|
getDefaultFilterMatchOptionsEnumNotNullable,
|