@charlesgomes/leafcode-shared-lib-react 1.0.57 → 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.css +5 -5
- package/dist/index.d.mts +168 -3
- package/dist/index.d.ts +168 -3
- package/dist/index.js +803 -130
- package/dist/index.mjs +803 -124
- package/dist/styles/base.css +20 -0
- package/dist/styles/button.css +41 -47
- package/dist/styles/input.css +246 -0
- package/dist/styles/modalBase.css +99 -0
- package/dist/styles/table.css +5 -5
- package/package.json +10 -2
package/dist/index.js
CHANGED
|
@@ -37,12 +37,18 @@ __export(index_exports, {
|
|
|
37
37
|
DateTimeFilterTemplate: () => DateTimeFilterTemplate,
|
|
38
38
|
FilterMatchMode: () => import_api5.FilterMatchMode,
|
|
39
39
|
FilterOperator: () => import_api5.FilterOperator,
|
|
40
|
+
Input: () => Input,
|
|
41
|
+
InputAutoComplete: () => InputAutoComplete,
|
|
42
|
+
InputSelect: () => InputSelect,
|
|
43
|
+
LeafcodeThemeProvider: () => LeafcodeThemeProvider,
|
|
40
44
|
ModalBase: () => ModalBase,
|
|
41
45
|
SelectFilterTemplate: () => SelectFilterTemplate,
|
|
46
|
+
TextArea: () => TextArea,
|
|
42
47
|
ValueFilterTemplate: () => ValueFilterTemplate,
|
|
43
48
|
buildDynamicCampoFilters: () => buildDynamicCampoFilters,
|
|
44
49
|
buildSortingWithFilters: () => buildSortingWithFilters,
|
|
45
50
|
customMatchModes: () => customMatchModes,
|
|
51
|
+
defaultTheme: () => defaultTheme,
|
|
46
52
|
getDefaultFilterMatchOptionsDate: () => getDefaultFilterMatchOptionsDate,
|
|
47
53
|
getDefaultFilterMatchOptionsEnum: () => getDefaultFilterMatchOptionsEnum,
|
|
48
54
|
getDefaultFilterMatchOptionsEnumNotNullable: () => getDefaultFilterMatchOptionsEnumNotNullable,
|
|
@@ -53,8 +59,92 @@ __export(index_exports, {
|
|
|
53
59
|
});
|
|
54
60
|
module.exports = __toCommonJS(index_exports);
|
|
55
61
|
|
|
56
|
-
// 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
|
|
57
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");
|
|
58
148
|
function Button({
|
|
59
149
|
disabled,
|
|
60
150
|
loading,
|
|
@@ -64,15 +154,32 @@ function Button({
|
|
|
64
154
|
title,
|
|
65
155
|
...rest
|
|
66
156
|
}) {
|
|
67
|
-
|
|
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)(
|
|
68
174
|
"button",
|
|
69
175
|
{
|
|
70
176
|
type,
|
|
71
|
-
|
|
177
|
+
style: styleVars,
|
|
178
|
+
className: `box-button ${disabled || loading ? "button-disabled" : color === "danger" ? "button-secundary" : "button-primary"}`,
|
|
72
179
|
onClick: !loading ? onClick : void 0,
|
|
73
180
|
disabled: disabled || loading,
|
|
74
181
|
...rest,
|
|
75
|
-
children: loading ? /* @__PURE__ */ (0,
|
|
182
|
+
children: loading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "box-loading", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
76
183
|
"svg",
|
|
77
184
|
{
|
|
78
185
|
className: "animate-spin",
|
|
@@ -80,7 +187,7 @@ function Button({
|
|
|
80
187
|
fill: "none",
|
|
81
188
|
viewBox: "0 0 24 24",
|
|
82
189
|
children: [
|
|
83
|
-
/* @__PURE__ */ (0,
|
|
190
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
84
191
|
"circle",
|
|
85
192
|
{
|
|
86
193
|
className: "opacity-01",
|
|
@@ -91,7 +198,7 @@ function Button({
|
|
|
91
198
|
strokeWidth: "4"
|
|
92
199
|
}
|
|
93
200
|
),
|
|
94
|
-
/* @__PURE__ */ (0,
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
95
202
|
"path",
|
|
96
203
|
{
|
|
97
204
|
className: "opacity-02",
|
|
@@ -101,23 +208,393 @@ function Button({
|
|
|
101
208
|
)
|
|
102
209
|
]
|
|
103
210
|
}
|
|
104
|
-
) }) : /* @__PURE__ */ (0,
|
|
211
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: title })
|
|
105
212
|
}
|
|
106
213
|
);
|
|
107
214
|
}
|
|
108
215
|
|
|
216
|
+
// src/components/Input/Input.tsx
|
|
217
|
+
var import_react4 = require("react");
|
|
218
|
+
|
|
219
|
+
// src/components/Tooltips/TooltipErrorInput.tsx
|
|
220
|
+
var import_react2 = require("@phosphor-icons/react");
|
|
221
|
+
var import_react3 = require("react");
|
|
222
|
+
var import_react_tooltip = require("react-tooltip");
|
|
223
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
224
|
+
function TooltipErrorInput({
|
|
225
|
+
error,
|
|
226
|
+
name,
|
|
227
|
+
isSelect = false,
|
|
228
|
+
isInvalid = false
|
|
229
|
+
}) {
|
|
230
|
+
const [isTooltipOpen, setIsTooltipOpen] = (0, import_react3.useState)(true);
|
|
231
|
+
const handleClose = () => setIsTooltipOpen(false);
|
|
232
|
+
(0, import_react3.useEffect)(() => {
|
|
233
|
+
setIsTooltipOpen(true);
|
|
234
|
+
}, [error]);
|
|
235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
236
|
+
"div",
|
|
237
|
+
{
|
|
238
|
+
className: `absolute ${isSelect ? isInvalid ? "right-[4.5rem]" : "right-11" : "right-2"} top-1/2 transform -translate-y-1/2 cursor-pointer z-20`,
|
|
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)(
|
|
241
|
+
"a",
|
|
242
|
+
{
|
|
243
|
+
"data-tooltip-id": name,
|
|
244
|
+
"data-tooltip-content": "",
|
|
245
|
+
"data-tooltip-place": "top-end",
|
|
246
|
+
onClick: () => setIsTooltipOpen(true),
|
|
247
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.WarningCircle, { size: 22, className: "text-red-400" })
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
251
|
+
import_react_tooltip.Tooltip,
|
|
252
|
+
{
|
|
253
|
+
className: "max-w-[15rem] relative z-50 tooltip-content cursor-default",
|
|
254
|
+
id: name,
|
|
255
|
+
style: {
|
|
256
|
+
backgroundColor: "#f87171",
|
|
257
|
+
color: "#fff",
|
|
258
|
+
padding: "8px 14px"
|
|
259
|
+
},
|
|
260
|
+
opacity: 1,
|
|
261
|
+
delayShow: 300,
|
|
262
|
+
delayHide: 150,
|
|
263
|
+
clickable: true,
|
|
264
|
+
openOnClick: true,
|
|
265
|
+
isOpen: isTooltipOpen,
|
|
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)(
|
|
269
|
+
"button",
|
|
270
|
+
{
|
|
271
|
+
onClick: handleClose,
|
|
272
|
+
className: "text-white hover:text-black",
|
|
273
|
+
style: {
|
|
274
|
+
border: "none",
|
|
275
|
+
background: "transparent",
|
|
276
|
+
cursor: "pointer"
|
|
277
|
+
},
|
|
278
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.X, { size: 16, weight: "bold" })
|
|
279
|
+
}
|
|
280
|
+
)
|
|
281
|
+
] })
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
] }) })
|
|
285
|
+
}
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/components/Input/Input.tsx
|
|
290
|
+
var import_react5 = require("@phosphor-icons/react");
|
|
291
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
292
|
+
var InputBase = ({
|
|
293
|
+
name,
|
|
294
|
+
label,
|
|
295
|
+
placeholder,
|
|
296
|
+
onFocus,
|
|
297
|
+
error = null,
|
|
298
|
+
disabled,
|
|
299
|
+
isUppercaseLabel = true,
|
|
300
|
+
isUppercaseText = false,
|
|
301
|
+
validationMode = "default",
|
|
302
|
+
showPasswordToggle = false,
|
|
303
|
+
onChange,
|
|
304
|
+
value,
|
|
305
|
+
...rest
|
|
306
|
+
}, ref) => {
|
|
307
|
+
const theme = useLeafcodeTheme();
|
|
308
|
+
const styleVars = {
|
|
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
|
|
328
|
+
};
|
|
329
|
+
const handleChange = (e) => {
|
|
330
|
+
let val = e.target.value;
|
|
331
|
+
if (validationMode === "restricted") {
|
|
332
|
+
val = val.replace(/[^a-zA-Z0-9_.-]/g, "");
|
|
333
|
+
val = val.replace(/^\.+/, "");
|
|
334
|
+
val = val.replace(/\.+$/, "");
|
|
335
|
+
val = val.replace(/\s+/g, "");
|
|
336
|
+
}
|
|
337
|
+
e.target.value = val;
|
|
338
|
+
onChange?.(e);
|
|
339
|
+
};
|
|
340
|
+
const [show, setShow] = (0, import_react4.useState)(false);
|
|
341
|
+
const handleClick = () => setShow(!show);
|
|
342
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
343
|
+
"div",
|
|
344
|
+
{
|
|
345
|
+
className: `input-wrapper ${disabled ? "is-disabled" : ""}`,
|
|
346
|
+
style: styleVars,
|
|
347
|
+
children: [
|
|
348
|
+
!!label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
349
|
+
"label",
|
|
350
|
+
{
|
|
351
|
+
className: `label-input ${isUppercaseLabel && "is-uppercase"}`,
|
|
352
|
+
htmlFor: name,
|
|
353
|
+
children: label
|
|
354
|
+
}
|
|
355
|
+
),
|
|
356
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { position: "relative", width: "100%" }, children: [
|
|
357
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
358
|
+
"input",
|
|
359
|
+
{
|
|
360
|
+
id: name,
|
|
361
|
+
name,
|
|
362
|
+
disabled,
|
|
363
|
+
type: show ? "text" : "password",
|
|
364
|
+
className: `input ${error && "input-error"} ${isUppercaseText && "is-uppercase"}`,
|
|
365
|
+
placeholder,
|
|
366
|
+
onFocus,
|
|
367
|
+
onChange: handleChange,
|
|
368
|
+
value,
|
|
369
|
+
ref,
|
|
370
|
+
...rest
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
showPasswordToggle && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
374
|
+
"div",
|
|
375
|
+
{
|
|
376
|
+
onClick: handleClick,
|
|
377
|
+
className: `password-toggle ${error ? "error" : "no-error"}`,
|
|
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 })
|
|
379
|
+
}
|
|
380
|
+
)
|
|
381
|
+
] }),
|
|
382
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TooltipErrorInput, { error, name })
|
|
383
|
+
]
|
|
384
|
+
}
|
|
385
|
+
);
|
|
386
|
+
};
|
|
387
|
+
var Input = (0, import_react4.forwardRef)(InputBase);
|
|
388
|
+
|
|
389
|
+
// src/components/Input/TextArea.tsx
|
|
390
|
+
var import_react6 = require("react");
|
|
391
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
392
|
+
var TextAreaBase = ({
|
|
393
|
+
name,
|
|
394
|
+
label,
|
|
395
|
+
placeholder,
|
|
396
|
+
isUppercaseText = false,
|
|
397
|
+
isUppercaseLabel = true,
|
|
398
|
+
disabled,
|
|
399
|
+
onFocus,
|
|
400
|
+
error,
|
|
401
|
+
...rest
|
|
402
|
+
}, ref) => {
|
|
403
|
+
const theme = useLeafcodeTheme();
|
|
404
|
+
const styleVars = {
|
|
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
|
|
424
|
+
};
|
|
425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
426
|
+
"div",
|
|
427
|
+
{
|
|
428
|
+
className: `input-wrapper ${disabled ? "is-disabled" : ""}`,
|
|
429
|
+
style: styleVars,
|
|
430
|
+
children: [
|
|
431
|
+
!!label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
432
|
+
"label",
|
|
433
|
+
{
|
|
434
|
+
className: `label-input ${isUppercaseLabel ? "is-uppercase" : ""}`,
|
|
435
|
+
htmlFor: name,
|
|
436
|
+
children: label
|
|
437
|
+
}
|
|
438
|
+
),
|
|
439
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { position: "relative", width: "100%" }, children: [
|
|
440
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
441
|
+
"textarea",
|
|
442
|
+
{
|
|
443
|
+
ref,
|
|
444
|
+
id: name,
|
|
445
|
+
name,
|
|
446
|
+
disabled,
|
|
447
|
+
className: `input textArea ${error ? "input-error" : ""} ${isUppercaseText ? "is-uppercase" : ""}`,
|
|
448
|
+
placeholder,
|
|
449
|
+
onFocus,
|
|
450
|
+
...rest
|
|
451
|
+
}
|
|
452
|
+
),
|
|
453
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "absolute top-6 right-1", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipErrorInput, { error, name }) })
|
|
454
|
+
] })
|
|
455
|
+
]
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
};
|
|
459
|
+
var TextArea = (0, import_react6.forwardRef)(
|
|
460
|
+
TextAreaBase
|
|
461
|
+
);
|
|
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
|
+
|
|
109
586
|
// src/components/ModalBase/ModalBase.tsx
|
|
110
|
-
var
|
|
587
|
+
var import_react8 = require("@phosphor-icons/react");
|
|
111
588
|
|
|
112
589
|
// src/components/ModalBase/FooterButtons.tsx
|
|
113
|
-
var
|
|
590
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
114
591
|
function FooterButtons({ children }) {
|
|
115
|
-
return /* @__PURE__ */ (0,
|
|
592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "modal-footer", children });
|
|
116
593
|
}
|
|
117
594
|
|
|
118
595
|
// src/components/ModalBase/ModalBase.tsx
|
|
119
|
-
var
|
|
120
|
-
var
|
|
596
|
+
var import_react9 = require("react");
|
|
597
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
121
598
|
function ModalBase({
|
|
122
599
|
show,
|
|
123
600
|
onHide,
|
|
@@ -127,9 +604,25 @@ function ModalBase({
|
|
|
127
604
|
loading,
|
|
128
605
|
btnCancel = "Cancel",
|
|
129
606
|
btnSuccess = "Save",
|
|
130
|
-
|
|
607
|
+
type = "button",
|
|
608
|
+
disabledBtnSuccess,
|
|
609
|
+
colors,
|
|
610
|
+
fonts,
|
|
611
|
+
modalMaxWidth
|
|
131
612
|
}) {
|
|
132
|
-
|
|
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)(() => {
|
|
133
626
|
const handleKeyDown = (event) => {
|
|
134
627
|
if (event.key === "Escape") {
|
|
135
628
|
onHide();
|
|
@@ -140,22 +633,15 @@ function ModalBase({
|
|
|
140
633
|
document.removeEventListener("keydown", handleKeyDown);
|
|
141
634
|
};
|
|
142
635
|
}, [onHide]);
|
|
143
|
-
return /* @__PURE__ */ (0,
|
|
144
|
-
/* @__PURE__ */ (0,
|
|
145
|
-
/* @__PURE__ */ (0,
|
|
146
|
-
/* @__PURE__ */ (0,
|
|
147
|
-
/* @__PURE__ */ (0,
|
|
148
|
-
"button",
|
|
149
|
-
{
|
|
150
|
-
className: "p-1 ml-auto mr-1 cursor-pointer",
|
|
151
|
-
onClick: onHide,
|
|
152
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react.X, { size: 18, color: "#ffffff" })
|
|
153
|
-
}
|
|
154
|
-
)
|
|
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" }) })
|
|
155
641
|
] }),
|
|
156
|
-
/* @__PURE__ */ (0,
|
|
157
|
-
/* @__PURE__ */ (0,
|
|
158
|
-
/* @__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)(
|
|
159
645
|
Button,
|
|
160
646
|
{
|
|
161
647
|
color: "danger",
|
|
@@ -164,10 +650,10 @@ function ModalBase({
|
|
|
164
650
|
onClick: onHide
|
|
165
651
|
}
|
|
166
652
|
),
|
|
167
|
-
/* @__PURE__ */ (0,
|
|
653
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
168
654
|
Button,
|
|
169
655
|
{
|
|
170
|
-
type
|
|
656
|
+
type,
|
|
171
657
|
title: btnSuccess,
|
|
172
658
|
onClick: onAction,
|
|
173
659
|
loading,
|
|
@@ -176,16 +662,197 @@ function ModalBase({
|
|
|
176
662
|
)
|
|
177
663
|
] })
|
|
178
664
|
] }) }) }),
|
|
179
|
-
/* @__PURE__ */ (0,
|
|
665
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "modal-backdrop" })
|
|
180
666
|
] }) : null });
|
|
181
667
|
}
|
|
182
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
|
+
|
|
183
850
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilter.tsx
|
|
184
|
-
var
|
|
851
|
+
var import_react19 = require("react");
|
|
185
852
|
|
|
186
853
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilterWrapper.tsx
|
|
187
|
-
var
|
|
188
|
-
var
|
|
854
|
+
var import_react17 = require("react");
|
|
855
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
189
856
|
|
|
190
857
|
// src/primereact-compat.ts
|
|
191
858
|
var import_datatable = require("primereact/datatable");
|
|
@@ -196,8 +863,8 @@ var import_calendar = require("primereact/calendar");
|
|
|
196
863
|
var import_api = require("primereact/api");
|
|
197
864
|
|
|
198
865
|
// src/components/DataTableAdvancedFilter/TableHeader.tsx
|
|
199
|
-
var
|
|
200
|
-
var
|
|
866
|
+
var import_react13 = require("@phosphor-icons/react");
|
|
867
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
201
868
|
var TableHeader = ({
|
|
202
869
|
globalFilterValue,
|
|
203
870
|
onGlobalFilterChange,
|
|
@@ -208,8 +875,8 @@ var TableHeader = ({
|
|
|
208
875
|
target: { value: "" }
|
|
209
876
|
});
|
|
210
877
|
};
|
|
211
|
-
return /* @__PURE__ */ (0,
|
|
212
|
-
/* @__PURE__ */ (0,
|
|
878
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { position: "relative" }, children: [
|
|
879
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
213
880
|
import_inputtext.InputText,
|
|
214
881
|
{
|
|
215
882
|
value: globalFilterValue,
|
|
@@ -218,16 +885,16 @@ var TableHeader = ({
|
|
|
218
885
|
className: "custom-input input-search"
|
|
219
886
|
}
|
|
220
887
|
),
|
|
221
|
-
/* @__PURE__ */ (0,
|
|
888
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react13.X, { size: 16, className: "close-search", onClick: limparCampo })
|
|
222
889
|
] });
|
|
223
890
|
};
|
|
224
891
|
var TableHeader_default = TableHeader;
|
|
225
892
|
|
|
226
893
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilterWrapper.tsx
|
|
227
|
-
var
|
|
894
|
+
var import_react18 = require("@phosphor-icons/react");
|
|
228
895
|
|
|
229
896
|
// src/components/DataTableAdvancedFilter/TableActions.tsx
|
|
230
|
-
var
|
|
897
|
+
var import_react14 = require("@phosphor-icons/react");
|
|
231
898
|
|
|
232
899
|
// src/utils/utils.ts
|
|
233
900
|
var import_clsx = require("clsx");
|
|
@@ -246,20 +913,20 @@ function centsToReal(value) {
|
|
|
246
913
|
}
|
|
247
914
|
|
|
248
915
|
// src/components/TooltipCustom.tsx
|
|
249
|
-
var
|
|
916
|
+
var import_react_tooltip2 = require("react-tooltip");
|
|
250
917
|
var import_react_dom = require("react-dom");
|
|
251
|
-
var
|
|
918
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
252
919
|
function TooltipCustom({ label, id }) {
|
|
253
920
|
return (0, import_react_dom.createPortal)(
|
|
254
|
-
/* @__PURE__ */ (0,
|
|
255
|
-
|
|
921
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
922
|
+
import_react_tooltip2.Tooltip,
|
|
256
923
|
{
|
|
257
924
|
anchorSelect: `#${id}`,
|
|
258
925
|
place: "top",
|
|
259
926
|
positionStrategy: "fixed",
|
|
260
927
|
className: "tooltip-icone",
|
|
261
928
|
style: { zIndex: 13 },
|
|
262
|
-
children: /* @__PURE__ */ (0,
|
|
929
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "tooltip-custom", children: label })
|
|
263
930
|
}
|
|
264
931
|
),
|
|
265
932
|
document.body
|
|
@@ -267,7 +934,7 @@ function TooltipCustom({ label, id }) {
|
|
|
267
934
|
}
|
|
268
935
|
|
|
269
936
|
// src/components/DataTableAdvancedFilter/TableActions.tsx
|
|
270
|
-
var
|
|
937
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
271
938
|
function TableActions({
|
|
272
939
|
onNew,
|
|
273
940
|
onEdit,
|
|
@@ -279,9 +946,9 @@ function TableActions({
|
|
|
279
946
|
const disableButtonsNotMultiplesSelecteds = selectedRows?.length !== 1 ? true : false;
|
|
280
947
|
const enableButtonsNotMultiplesSelecteds = selectedRows?.length > 0 ? true : false;
|
|
281
948
|
const resolvedCustomActions = typeof customActions === "function" ? customActions(selectedRows) : customActions;
|
|
282
|
-
return /* @__PURE__ */ (0,
|
|
283
|
-
onNew && /* @__PURE__ */ (0,
|
|
284
|
-
/* @__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)(
|
|
285
952
|
"button",
|
|
286
953
|
{
|
|
287
954
|
id: "add",
|
|
@@ -292,10 +959,10 @@ function TableActions({
|
|
|
292
959
|
enableButtonsNotMultiplesSelecteds && "disable-button-table-actions"
|
|
293
960
|
),
|
|
294
961
|
disabled: enableButtonsNotMultiplesSelecteds,
|
|
295
|
-
children: /* @__PURE__ */ (0,
|
|
962
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react14.Plus, { size: 18 })
|
|
296
963
|
}
|
|
297
964
|
),
|
|
298
|
-
/* @__PURE__ */ (0,
|
|
965
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
299
966
|
TooltipCustom,
|
|
300
967
|
{
|
|
301
968
|
id: "add",
|
|
@@ -303,7 +970,7 @@ function TableActions({
|
|
|
303
970
|
}
|
|
304
971
|
)
|
|
305
972
|
] }),
|
|
306
|
-
onEdit && /* @__PURE__ */ (0,
|
|
973
|
+
onEdit && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
307
974
|
"button",
|
|
308
975
|
{
|
|
309
976
|
id: "edit",
|
|
@@ -315,8 +982,8 @@ function TableActions({
|
|
|
315
982
|
),
|
|
316
983
|
disabled: disableButtonsNotMultiplesSelecteds,
|
|
317
984
|
children: [
|
|
318
|
-
/* @__PURE__ */ (0,
|
|
319
|
-
/* @__PURE__ */ (0,
|
|
985
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react14.PencilSimple, { size: 18 }),
|
|
986
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
320
987
|
TooltipCustom,
|
|
321
988
|
{
|
|
322
989
|
id: "edit",
|
|
@@ -326,7 +993,7 @@ function TableActions({
|
|
|
326
993
|
]
|
|
327
994
|
}
|
|
328
995
|
) }),
|
|
329
|
-
onDelete && /* @__PURE__ */ (0,
|
|
996
|
+
onDelete && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
330
997
|
"button",
|
|
331
998
|
{
|
|
332
999
|
id: "delete",
|
|
@@ -338,8 +1005,8 @@ function TableActions({
|
|
|
338
1005
|
),
|
|
339
1006
|
disabled: !enableButtonsNotMultiplesSelecteds,
|
|
340
1007
|
children: [
|
|
341
|
-
/* @__PURE__ */ (0,
|
|
342
|
-
/* @__PURE__ */ (0,
|
|
1008
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react14.Trash, { size: 18 }),
|
|
1009
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
343
1010
|
TooltipCustom,
|
|
344
1011
|
{
|
|
345
1012
|
id: "delete",
|
|
@@ -351,7 +1018,7 @@ function TableActions({
|
|
|
351
1018
|
) }),
|
|
352
1019
|
resolvedCustomActions?.map((action) => {
|
|
353
1020
|
const id = `action-table${phraseToId(action.label)}`;
|
|
354
|
-
return /* @__PURE__ */ (0,
|
|
1021
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
355
1022
|
"button",
|
|
356
1023
|
{
|
|
357
1024
|
id,
|
|
@@ -360,7 +1027,7 @@ function TableActions({
|
|
|
360
1027
|
className: cn("enable-button-table-actions", action.className),
|
|
361
1028
|
children: [
|
|
362
1029
|
action.icon,
|
|
363
|
-
/* @__PURE__ */ (0,
|
|
1030
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipCustom, { id, label: action.label })
|
|
364
1031
|
]
|
|
365
1032
|
},
|
|
366
1033
|
id
|
|
@@ -370,8 +1037,8 @@ function TableActions({
|
|
|
370
1037
|
}
|
|
371
1038
|
|
|
372
1039
|
// src/components/DataTableAdvancedFilter/ActionsColumn.tsx
|
|
373
|
-
var
|
|
374
|
-
var
|
|
1040
|
+
var import_react15 = require("@phosphor-icons/react");
|
|
1041
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
375
1042
|
function ActionsColumn({
|
|
376
1043
|
row,
|
|
377
1044
|
onEdit,
|
|
@@ -380,8 +1047,8 @@ function ActionsColumn({
|
|
|
380
1047
|
isLanguagePtBr
|
|
381
1048
|
}) {
|
|
382
1049
|
const resolvedCustomActions = typeof customActionsColums === "function" ? customActionsColums(row) : customActionsColums;
|
|
383
|
-
return /* @__PURE__ */ (0,
|
|
384
|
-
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)(
|
|
385
1052
|
"button",
|
|
386
1053
|
{
|
|
387
1054
|
id: "edit-column",
|
|
@@ -391,8 +1058,8 @@ function ActionsColumn({
|
|
|
391
1058
|
onEdit && onEdit([row]);
|
|
392
1059
|
},
|
|
393
1060
|
children: [
|
|
394
|
-
/* @__PURE__ */ (0,
|
|
395
|
-
/* @__PURE__ */ (0,
|
|
1061
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react15.PencilSimple, { size: 17, weight: "regular" }),
|
|
1062
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
396
1063
|
TooltipCustom,
|
|
397
1064
|
{
|
|
398
1065
|
id: "edit-column",
|
|
@@ -402,7 +1069,7 @@ function ActionsColumn({
|
|
|
402
1069
|
]
|
|
403
1070
|
}
|
|
404
1071
|
) }),
|
|
405
|
-
onDelete && /* @__PURE__ */ (0,
|
|
1072
|
+
onDelete && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
406
1073
|
"button",
|
|
407
1074
|
{
|
|
408
1075
|
id: "delete-column",
|
|
@@ -412,8 +1079,8 @@ function ActionsColumn({
|
|
|
412
1079
|
onDelete && onDelete([row]);
|
|
413
1080
|
},
|
|
414
1081
|
children: [
|
|
415
|
-
/* @__PURE__ */ (0,
|
|
416
|
-
/* @__PURE__ */ (0,
|
|
1082
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react15.Trash, { size: 17, weight: "regular" }),
|
|
1083
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
417
1084
|
TooltipCustom,
|
|
418
1085
|
{
|
|
419
1086
|
id: "delete-column",
|
|
@@ -425,7 +1092,7 @@ function ActionsColumn({
|
|
|
425
1092
|
) }),
|
|
426
1093
|
resolvedCustomActions?.map((action) => {
|
|
427
1094
|
const id = `action-colunm-${phraseToId(action.label)}`;
|
|
428
|
-
return /* @__PURE__ */ (0,
|
|
1095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
429
1096
|
"button",
|
|
430
1097
|
{
|
|
431
1098
|
id,
|
|
@@ -434,7 +1101,7 @@ function ActionsColumn({
|
|
|
434
1101
|
className: cn("btn-icone-actions-column", action.className),
|
|
435
1102
|
children: [
|
|
436
1103
|
action.icon,
|
|
437
|
-
/* @__PURE__ */ (0,
|
|
1104
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipCustom, { id, label: action.label })
|
|
438
1105
|
]
|
|
439
1106
|
},
|
|
440
1107
|
id
|
|
@@ -444,7 +1111,7 @@ function ActionsColumn({
|
|
|
444
1111
|
}
|
|
445
1112
|
|
|
446
1113
|
// src/components/DataTableAdvancedFilter/DynamicColumns.tsx
|
|
447
|
-
var
|
|
1114
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
448
1115
|
function DynamicColumns({
|
|
449
1116
|
columns,
|
|
450
1117
|
isMultiSelectionMode = true,
|
|
@@ -456,7 +1123,7 @@ function DynamicColumns({
|
|
|
456
1123
|
const array = [];
|
|
457
1124
|
if (isMultiSelectionMode) {
|
|
458
1125
|
array.push(
|
|
459
|
-
/* @__PURE__ */ (0,
|
|
1126
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
460
1127
|
import_column.Column,
|
|
461
1128
|
{
|
|
462
1129
|
selectionMode: "multiple",
|
|
@@ -473,7 +1140,7 @@ function DynamicColumns({
|
|
|
473
1140
|
const width = isActionsCol && col?.size ? col.size + "rem" : "6rem";
|
|
474
1141
|
const placeholder = isLanguagePtBr ? "Procurar" : "Search";
|
|
475
1142
|
array.push(
|
|
476
|
-
/* @__PURE__ */ (0,
|
|
1143
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
477
1144
|
import_column.Column,
|
|
478
1145
|
{
|
|
479
1146
|
field: isActionsCol ? void 0 : col.field,
|
|
@@ -491,7 +1158,7 @@ function DynamicColumns({
|
|
|
491
1158
|
resizeable: col.enableResizeable ?? true
|
|
492
1159
|
},
|
|
493
1160
|
style: isActionsCol ? { width, minWidth: width, position: "relative" } : {},
|
|
494
|
-
body: (rowData) => isActionsCol ? /* @__PURE__ */ (0,
|
|
1161
|
+
body: (rowData) => isActionsCol ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
495
1162
|
ActionsColumn,
|
|
496
1163
|
{
|
|
497
1164
|
row: rowData,
|
|
@@ -500,7 +1167,7 @@ function DynamicColumns({
|
|
|
500
1167
|
customActionsColums,
|
|
501
1168
|
isLanguagePtBr
|
|
502
1169
|
}
|
|
503
|
-
) : 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]) }),
|
|
504
1171
|
sortable: !isActionsCol ? col.enableSorting ?? true : false
|
|
505
1172
|
},
|
|
506
1173
|
`${String(col.field)}-${idx}`
|
|
@@ -511,10 +1178,10 @@ function DynamicColumns({
|
|
|
511
1178
|
}
|
|
512
1179
|
|
|
513
1180
|
// src/hooks/use-debounce.ts
|
|
514
|
-
var
|
|
1181
|
+
var import_react16 = require("react");
|
|
515
1182
|
var useDebounce = (value, delay) => {
|
|
516
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
517
|
-
(0,
|
|
1183
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react16.useState)(value);
|
|
1184
|
+
(0, import_react16.useEffect)(() => {
|
|
518
1185
|
const timer = setTimeout(() => {
|
|
519
1186
|
setDebouncedValue(value);
|
|
520
1187
|
}, delay || 500);
|
|
@@ -526,7 +1193,7 @@ var useDebounce = (value, delay) => {
|
|
|
526
1193
|
};
|
|
527
1194
|
|
|
528
1195
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilterWrapper.tsx
|
|
529
|
-
var
|
|
1196
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
530
1197
|
function DataTableAdvancedFilterWrapper({
|
|
531
1198
|
queryKey,
|
|
532
1199
|
mutationFn,
|
|
@@ -546,8 +1213,8 @@ function DataTableAdvancedFilterWrapper({
|
|
|
546
1213
|
state,
|
|
547
1214
|
onStateChange
|
|
548
1215
|
}) {
|
|
549
|
-
const [isClient, setIsClient] = (0,
|
|
550
|
-
(0,
|
|
1216
|
+
const [isClient, setIsClient] = (0, import_react17.useState)(false);
|
|
1217
|
+
(0, import_react17.useEffect)(() => {
|
|
551
1218
|
setIsClient(true);
|
|
552
1219
|
}, []);
|
|
553
1220
|
const initialState = state ?? {
|
|
@@ -557,31 +1224,31 @@ function DataTableAdvancedFilterWrapper({
|
|
|
557
1224
|
sortOrder: sortOrderInitial,
|
|
558
1225
|
filter: ""
|
|
559
1226
|
};
|
|
560
|
-
const [page, setPage] = (0,
|
|
561
|
-
const [rows, setRows] = (0,
|
|
562
|
-
const [first, setFirst] = (0,
|
|
563
|
-
const [sortField, setSortField] = (0,
|
|
564
|
-
const [sortOrder, setSortOrder] = (0,
|
|
565
|
-
const [searchText, setSearchText] = (0,
|
|
566
|
-
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)({
|
|
567
1234
|
...initFilters,
|
|
568
1235
|
global: { value: initialState.filter, matchMode: "contains" }
|
|
569
1236
|
});
|
|
570
|
-
const [selectedRowsData, setSelectedRowsData] = (0,
|
|
1237
|
+
const [selectedRowsData, setSelectedRowsData] = (0, import_react17.useState)([]);
|
|
571
1238
|
const debouncedSearch = useDebounce(searchText, 500);
|
|
572
|
-
const debouncedFilters = (0,
|
|
1239
|
+
const debouncedFilters = (0, import_react17.useMemo)(() => {
|
|
573
1240
|
const f = { ...filters };
|
|
574
1241
|
if (!f.global) f.global = { value: "", matchMode: "contains" };
|
|
575
1242
|
f.global.value = debouncedSearch;
|
|
576
1243
|
return f;
|
|
577
1244
|
}, [filters, debouncedSearch]);
|
|
578
1245
|
const filtersKey = JSON.stringify(debouncedFilters);
|
|
579
|
-
const globalFilterFields = (0,
|
|
1246
|
+
const globalFilterFields = (0, import_react17.useMemo)(() => {
|
|
580
1247
|
return columns?.filter(
|
|
581
1248
|
(col) => col.filterGlobal === true && (col.field !== "acoes" || col.field !== "actions")
|
|
582
1249
|
).map((col) => col.field) ?? [];
|
|
583
1250
|
}, [columns]);
|
|
584
|
-
const { data: customers, isLoading } = (0,
|
|
1251
|
+
const { data: customers, isLoading } = (0, import_react_query2.useQuery)({
|
|
585
1252
|
queryKey: [queryKey, { page, rows, sortField, sortOrder, filtersKey }],
|
|
586
1253
|
queryFn: () => mutationFn(
|
|
587
1254
|
page,
|
|
@@ -592,7 +1259,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
592
1259
|
globalFilterFields
|
|
593
1260
|
)
|
|
594
1261
|
});
|
|
595
|
-
(0,
|
|
1262
|
+
(0, import_react17.useEffect)(() => {
|
|
596
1263
|
if (!state) return;
|
|
597
1264
|
setPage(state.page);
|
|
598
1265
|
setRows(state.rows);
|
|
@@ -648,7 +1315,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
648
1315
|
filter: searchText
|
|
649
1316
|
});
|
|
650
1317
|
};
|
|
651
|
-
(0,
|
|
1318
|
+
(0, import_react17.useEffect)(() => {
|
|
652
1319
|
emitStateChange({
|
|
653
1320
|
page: 1,
|
|
654
1321
|
rows,
|
|
@@ -657,7 +1324,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
657
1324
|
filter: debouncedSearch
|
|
658
1325
|
});
|
|
659
1326
|
}, [debouncedSearch]);
|
|
660
|
-
(0,
|
|
1327
|
+
(0, import_react17.useEffect)(() => {
|
|
661
1328
|
if (customers?.items && selectedRowsData.length > 0) {
|
|
662
1329
|
const currentIds = new Set(customers.items.map((item) => item.id));
|
|
663
1330
|
const filteredSelection = selectedRowsData.filter(
|
|
@@ -668,9 +1335,9 @@ function DataTableAdvancedFilterWrapper({
|
|
|
668
1335
|
}
|
|
669
1336
|
}
|
|
670
1337
|
}, [customers?.items, selectedRowsData]);
|
|
671
|
-
const TableHeaderAndTableActions = (0,
|
|
672
|
-
() => /* @__PURE__ */ (0,
|
|
673
|
-
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)(
|
|
674
1341
|
TableHeader_default,
|
|
675
1342
|
{
|
|
676
1343
|
isLanguagePtBr,
|
|
@@ -678,7 +1345,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
678
1345
|
onGlobalFilterChange
|
|
679
1346
|
}
|
|
680
1347
|
),
|
|
681
|
-
/* @__PURE__ */ (0,
|
|
1348
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
682
1349
|
TableActions,
|
|
683
1350
|
{
|
|
684
1351
|
selectedRows: selectedRowsData,
|
|
@@ -701,9 +1368,9 @@ function DataTableAdvancedFilterWrapper({
|
|
|
701
1368
|
customActions
|
|
702
1369
|
]
|
|
703
1370
|
);
|
|
704
|
-
return /* @__PURE__ */ (0,
|
|
705
|
-
disablePagination && /* @__PURE__ */ (0,
|
|
706
|
-
/* @__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)(
|
|
707
1374
|
import_datatable.DataTable,
|
|
708
1375
|
{
|
|
709
1376
|
value: customers?.items ?? [],
|
|
@@ -729,7 +1396,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
729
1396
|
sortOrder,
|
|
730
1397
|
paginatorTemplate: {
|
|
731
1398
|
layout: "RowsPerPageDropdown PrevPageLink CurrentPageReport NextPageLink",
|
|
732
|
-
RowsPerPageDropdown: (options) => /* @__PURE__ */ (0,
|
|
1399
|
+
RowsPerPageDropdown: (options) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
733
1400
|
"select",
|
|
734
1401
|
{
|
|
735
1402
|
value: options.value,
|
|
@@ -738,20 +1405,20 @@ function DataTableAdvancedFilterWrapper({
|
|
|
738
1405
|
value: Number(e.target.value)
|
|
739
1406
|
}),
|
|
740
1407
|
className: "custom-input custom-select",
|
|
741
|
-
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))
|
|
742
1409
|
}
|
|
743
1410
|
),
|
|
744
|
-
PrevPageLink: (options) => /* @__PURE__ */ (0,
|
|
1411
|
+
PrevPageLink: (options) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
745
1412
|
"button",
|
|
746
1413
|
{
|
|
747
1414
|
type: "button",
|
|
748
1415
|
onClick: options.onClick,
|
|
749
1416
|
disabled: options.disabled,
|
|
750
1417
|
className: `PrevPage ${options.disabled ? "PrevPageDisabled" : "PrevPageEnabled"}`,
|
|
751
|
-
children: /* @__PURE__ */ (0,
|
|
1418
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react18.CaretLeft, { size: 18, color: "#fff" })
|
|
752
1419
|
}
|
|
753
1420
|
),
|
|
754
|
-
CurrentPageReport: (options) => /* @__PURE__ */ (0,
|
|
1421
|
+
CurrentPageReport: (options) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "pageReport", children: [
|
|
755
1422
|
isLanguagePtBr ? "Mostrando" : "Showing",
|
|
756
1423
|
" ",
|
|
757
1424
|
options.first,
|
|
@@ -764,21 +1431,21 @@ function DataTableAdvancedFilterWrapper({
|
|
|
764
1431
|
" ",
|
|
765
1432
|
options.totalRecords
|
|
766
1433
|
] }),
|
|
767
|
-
NextPageLink: (options) => /* @__PURE__ */ (0,
|
|
1434
|
+
NextPageLink: (options) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
768
1435
|
"button",
|
|
769
1436
|
{
|
|
770
1437
|
type: "button",
|
|
771
1438
|
onClick: options.onClick,
|
|
772
1439
|
disabled: options.disabled,
|
|
773
1440
|
className: `NextPage ${options.disabled ? "NextPageDisabled" : "NextPageEnabled"}`,
|
|
774
|
-
children: /* @__PURE__ */ (0,
|
|
1441
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react18.CaretRight, { size: 18, color: "#fff" })
|
|
775
1442
|
}
|
|
776
1443
|
)
|
|
777
1444
|
},
|
|
778
1445
|
paginatorPosition: "top",
|
|
779
|
-
paginatorLeft: /* @__PURE__ */ (0,
|
|
1446
|
+
paginatorLeft: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "paginatorLeft", children: TableHeaderAndTableActions }),
|
|
780
1447
|
currentPageReportTemplate: "Mostrando {first} a {last} de {totalRecords}",
|
|
781
|
-
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" }) }),
|
|
782
1449
|
onFilter: (e) => {
|
|
783
1450
|
const newFilters = { ...e.filters };
|
|
784
1451
|
Object.keys(filters).forEach((key) => {
|
|
@@ -977,7 +1644,7 @@ var localePtBr = {
|
|
|
977
1644
|
};
|
|
978
1645
|
|
|
979
1646
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilter.tsx
|
|
980
|
-
var
|
|
1647
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
981
1648
|
function DataTableAdvancedFilter({
|
|
982
1649
|
queryKey,
|
|
983
1650
|
mutationFn,
|
|
@@ -997,21 +1664,21 @@ function DataTableAdvancedFilter({
|
|
|
997
1664
|
state,
|
|
998
1665
|
onStateChange
|
|
999
1666
|
}) {
|
|
1000
|
-
const [isClient, setIsClient] = (0,
|
|
1001
|
-
(0,
|
|
1667
|
+
const [isClient, setIsClient] = (0, import_react19.useState)(false);
|
|
1668
|
+
(0, import_react19.useEffect)(() => {
|
|
1002
1669
|
(0, import_api2.addLocale)("pt", localePtBr);
|
|
1003
1670
|
}, []);
|
|
1004
|
-
(0,
|
|
1671
|
+
(0, import_react19.useEffect)(() => {
|
|
1005
1672
|
(0, import_api2.locale)(isLanguagePtBr ? "pt" : "en");
|
|
1006
1673
|
}, [isLanguagePtBr]);
|
|
1007
|
-
(0,
|
|
1674
|
+
(0, import_react19.useEffect)(() => {
|
|
1008
1675
|
setIsClient(true);
|
|
1009
1676
|
}, []);
|
|
1010
|
-
return /* @__PURE__ */ (0,
|
|
1677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isClient && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1011
1678
|
import_api2.PrimeReactProvider,
|
|
1012
1679
|
{
|
|
1013
1680
|
value: isLanguagePtBr ? { locale: "pt" } : { locale: "en" },
|
|
1014
|
-
children: /* @__PURE__ */ (0,
|
|
1681
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1015
1682
|
DataTableAdvancedFilterWrapper,
|
|
1016
1683
|
{
|
|
1017
1684
|
rowsPerPageOptions,
|
|
@@ -1038,13 +1705,13 @@ function DataTableAdvancedFilter({
|
|
|
1038
1705
|
}
|
|
1039
1706
|
|
|
1040
1707
|
// src/components/DataTableAdvancedFilter/FilterTemplates.tsx
|
|
1041
|
-
var
|
|
1708
|
+
var import_react_select2 = __toESM(require("react-select"));
|
|
1042
1709
|
var import_dropdown = require("primereact/dropdown");
|
|
1043
1710
|
var import_moment2 = __toESM(require("moment"));
|
|
1044
|
-
var
|
|
1711
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1045
1712
|
var DateFilterTemplate = (options, mask) => {
|
|
1046
1713
|
const parsedValue = options.value && typeof options.value === "string" ? /* @__PURE__ */ new Date(options.value + "T00:00:00") : options.value;
|
|
1047
|
-
return /* @__PURE__ */ (0,
|
|
1714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1048
1715
|
import_calendar.Calendar,
|
|
1049
1716
|
{
|
|
1050
1717
|
value: parsedValue,
|
|
@@ -1069,7 +1736,7 @@ var DateFilterTemplate = (options, mask) => {
|
|
|
1069
1736
|
};
|
|
1070
1737
|
var DateTimeFilterTemplate = (options, mask) => {
|
|
1071
1738
|
const value = typeof options.value === "string" ? (0, import_moment2.default)(options.value).toDate() : options.value ?? null;
|
|
1072
|
-
return /* @__PURE__ */ (0,
|
|
1739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1073
1740
|
import_calendar.Calendar,
|
|
1074
1741
|
{
|
|
1075
1742
|
value,
|
|
@@ -1103,7 +1770,7 @@ var ValueFilterTemplate = (options, mask) => {
|
|
|
1103
1770
|
const valueToFilter = mask ? mask(rawValue) : rawValue;
|
|
1104
1771
|
options.filterCallback(valueToFilter, options.index);
|
|
1105
1772
|
};
|
|
1106
|
-
return /* @__PURE__ */ (0,
|
|
1773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1107
1774
|
import_inputnumber.InputNumber,
|
|
1108
1775
|
{
|
|
1109
1776
|
value: parsedValue,
|
|
@@ -1122,8 +1789,8 @@ var SelectFilterTemplate = (options, isLanguagePtBr = true, items = []) => {
|
|
|
1122
1789
|
{ label: isLanguagePtBr ? "N\xE3o" : "No", value: false }
|
|
1123
1790
|
];
|
|
1124
1791
|
const currentValue = selectOptions.find((opt) => opt.value === options.value) || null;
|
|
1125
|
-
return /* @__PURE__ */ (0,
|
|
1126
|
-
|
|
1792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1793
|
+
import_react_select2.default,
|
|
1127
1794
|
{
|
|
1128
1795
|
options: selectOptions,
|
|
1129
1796
|
value: currentValue,
|
|
@@ -1181,7 +1848,7 @@ var CustomFilterElement = (options, isLanguagePtBr = true, items) => {
|
|
|
1181
1848
|
const currentMatchMode = rawFilter.matchMode ?? "contains";
|
|
1182
1849
|
const currentValue = typeof rawFilter.text === "string" ? rawFilter.text : "";
|
|
1183
1850
|
const isSpecial = currentMatchMode === customMatchModes.empty || currentMatchMode === customMatchModes.notEmpty;
|
|
1184
|
-
return /* @__PURE__ */ (0,
|
|
1851
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1185
1852
|
"div",
|
|
1186
1853
|
{
|
|
1187
1854
|
className: "filter-wrapper",
|
|
@@ -1192,7 +1859,7 @@ var CustomFilterElement = (options, isLanguagePtBr = true, items) => {
|
|
|
1192
1859
|
minWidth: "200px"
|
|
1193
1860
|
},
|
|
1194
1861
|
children: [
|
|
1195
|
-
/* @__PURE__ */ (0,
|
|
1862
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1196
1863
|
import_dropdown.Dropdown,
|
|
1197
1864
|
{
|
|
1198
1865
|
value: currentMatchMode,
|
|
@@ -1218,7 +1885,7 @@ var CustomFilterElement = (options, isLanguagePtBr = true, items) => {
|
|
|
1218
1885
|
}
|
|
1219
1886
|
}
|
|
1220
1887
|
),
|
|
1221
|
-
!isSpecial && /* @__PURE__ */ (0,
|
|
1888
|
+
!isSpecial && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1222
1889
|
import_inputtext.InputText,
|
|
1223
1890
|
{
|
|
1224
1891
|
value: currentValue,
|
|
@@ -1638,12 +2305,18 @@ var import_api5 = require("primereact/api");
|
|
|
1638
2305
|
DateTimeFilterTemplate,
|
|
1639
2306
|
FilterMatchMode,
|
|
1640
2307
|
FilterOperator,
|
|
2308
|
+
Input,
|
|
2309
|
+
InputAutoComplete,
|
|
2310
|
+
InputSelect,
|
|
2311
|
+
LeafcodeThemeProvider,
|
|
1641
2312
|
ModalBase,
|
|
1642
2313
|
SelectFilterTemplate,
|
|
2314
|
+
TextArea,
|
|
1643
2315
|
ValueFilterTemplate,
|
|
1644
2316
|
buildDynamicCampoFilters,
|
|
1645
2317
|
buildSortingWithFilters,
|
|
1646
2318
|
customMatchModes,
|
|
2319
|
+
defaultTheme,
|
|
1647
2320
|
getDefaultFilterMatchOptionsDate,
|
|
1648
2321
|
getDefaultFilterMatchOptionsEnum,
|
|
1649
2322
|
getDefaultFilterMatchOptionsEnumNotNullable,
|