eai-frontend-components 2.0.18 → 2.0.20
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.ts +97 -12
- package/dist/index.esm.js +106 -57
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +108 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -382,22 +382,21 @@ const CarouselNext = React__namespace.forwardRef(({ className, variant = "outlin
|
|
|
382
382
|
});
|
|
383
383
|
CarouselNext.displayName = "CarouselNext";
|
|
384
384
|
|
|
385
|
-
|
|
386
|
-
const THEMES = { light: "", dark: ".dark" };
|
|
385
|
+
const THEMES = { light: '', dark: '.dark' };
|
|
387
386
|
const ChartContext = React__namespace.createContext(null);
|
|
388
387
|
function useChart() {
|
|
389
388
|
const context = React__namespace.useContext(ChartContext);
|
|
390
389
|
if (!context) {
|
|
391
|
-
throw new Error(
|
|
390
|
+
throw new Error('useChart must be used within a <ChartContainer />');
|
|
392
391
|
}
|
|
393
392
|
return context;
|
|
394
393
|
}
|
|
395
394
|
const ChartContainer = React__namespace.forwardRef(({ id, className, children, config, ...props }, ref) => {
|
|
396
395
|
const uniqueId = React__namespace.useId();
|
|
397
|
-
const chartId = `chart-${id || uniqueId.replace(/:/g,
|
|
396
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`;
|
|
398
397
|
return (jsxRuntime.jsx(ChartContext.Provider, { value: { config }, children: jsxRuntime.jsxs("div", { "data-chart": chartId, ref: ref, className: cn("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none", className), ...props, children: [jsxRuntime.jsx(ChartStyle, { id: chartId, config: config }), jsxRuntime.jsx(RechartsPrimitive__namespace.ResponsiveContainer, { children: children })] }) }));
|
|
399
398
|
});
|
|
400
|
-
ChartContainer.displayName =
|
|
399
|
+
ChartContainer.displayName = 'Chart';
|
|
401
400
|
const ChartStyle = ({ id, config }) => {
|
|
402
401
|
const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color);
|
|
403
402
|
if (!colorConfig.length) {
|
|
@@ -411,103 +410,83 @@ const ChartStyle = ({ id, config }) => {
|
|
|
411
410
|
${prefix} [data-chart=${id}] {
|
|
412
411
|
${colorConfig
|
|
413
412
|
.map(([key, itemConfig]) => {
|
|
414
|
-
const color = itemConfig.theme?.[theme] ||
|
|
415
|
-
itemConfig.color;
|
|
413
|
+
const color = itemConfig.theme?.[theme] || itemConfig.color;
|
|
416
414
|
return color ? ` --color-${key}: ${color};` : null;
|
|
417
415
|
})
|
|
418
|
-
.join(
|
|
416
|
+
.join('\n')}
|
|
419
417
|
}
|
|
420
418
|
`)
|
|
421
|
-
.join(
|
|
419
|
+
.join('\n'),
|
|
422
420
|
} }));
|
|
423
421
|
};
|
|
424
422
|
const ChartTooltip = RechartsPrimitive__namespace.Tooltip;
|
|
425
|
-
const ChartTooltipContent = React__namespace.forwardRef(({ active, payload, className, indicator =
|
|
423
|
+
const ChartTooltipContent = React__namespace.forwardRef(({ active, payload, className, indicator = 'dot', hideLabel = false, hideIndicator = false, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }, ref) => {
|
|
426
424
|
const { config } = useChart();
|
|
427
425
|
const tooltipLabel = React__namespace.useMemo(() => {
|
|
428
426
|
if (hideLabel || !payload?.length) {
|
|
429
427
|
return null;
|
|
430
428
|
}
|
|
431
429
|
const [item] = payload;
|
|
432
|
-
const key = `${labelKey || item.dataKey || item.name ||
|
|
430
|
+
const key = `${labelKey || item.dataKey || item.name || 'value'}`;
|
|
433
431
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
434
|
-
const value = !labelKey && typeof label ===
|
|
435
|
-
? config[label]?.label || label
|
|
436
|
-
: itemConfig?.label;
|
|
432
|
+
const value = !labelKey && typeof label === 'string' ? config[label]?.label || label : itemConfig?.label;
|
|
437
433
|
if (labelFormatter) {
|
|
438
|
-
return
|
|
434
|
+
return jsxRuntime.jsx("div", { className: cn('font-medium', labelClassName), children: labelFormatter(value, payload) });
|
|
439
435
|
}
|
|
440
436
|
if (!value) {
|
|
441
437
|
return null;
|
|
442
438
|
}
|
|
443
|
-
return jsxRuntime.jsx("div", { className: cn(
|
|
444
|
-
}, [
|
|
445
|
-
label,
|
|
446
|
-
labelFormatter,
|
|
447
|
-
payload,
|
|
448
|
-
hideLabel,
|
|
449
|
-
labelClassName,
|
|
450
|
-
config,
|
|
451
|
-
labelKey,
|
|
452
|
-
]);
|
|
439
|
+
return jsxRuntime.jsx("div", { className: cn('font-medium', labelClassName), children: value });
|
|
440
|
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
|
453
441
|
if (!active || !payload?.length) {
|
|
454
442
|
return null;
|
|
455
443
|
}
|
|
456
|
-
const nestLabel = payload.length === 1 && indicator !==
|
|
457
|
-
return (jsxRuntime.jsxs("div", { ref: ref, className: cn(
|
|
458
|
-
const key = `${nameKey || item.name || item.dataKey ||
|
|
444
|
+
const nestLabel = payload.length === 1 && indicator !== 'dot';
|
|
445
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: cn('grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl', className), children: [!nestLabel ? tooltipLabel : null, jsxRuntime.jsx("div", { className: 'grid gap-1.5', children: payload.map((item, index) => {
|
|
446
|
+
const key = `${nameKey || item.name || item.dataKey || 'value'}`;
|
|
459
447
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
460
448
|
const indicatorColor = color || item.payload.fill || item.color;
|
|
461
|
-
return (jsxRuntime.jsx("div", { className: cn(
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
449
|
+
return (jsxRuntime.jsx("div", { className: cn('flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground', indicator === 'dot' && 'items-center'), children: formatter && item?.value !== undefined && item.name ? (formatter(item.value, item.name, item, index, item.payload)) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [itemConfig?.icon ? (jsxRuntime.jsx(itemConfig.icon, {})) : (!hideIndicator && (jsxRuntime.jsx("div", { className: cn('shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]', {
|
|
450
|
+
'h-2.5 w-2.5': indicator === 'dot',
|
|
451
|
+
'w-1': indicator === 'line',
|
|
452
|
+
'w-0 border-[1.5px] border-dashed bg-transparent': indicator === 'dashed',
|
|
453
|
+
'my-0.5': nestLabel && indicator === 'dashed',
|
|
466
454
|
}), style: {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
} }))), jsxRuntime.jsxs("div", { className: cn(
|
|
455
|
+
'--color-bg': indicatorColor,
|
|
456
|
+
'--color-border': indicatorColor,
|
|
457
|
+
} }))), jsxRuntime.jsxs("div", { className: cn('flex flex-1 justify-between leading-none', nestLabel ? 'items-end' : 'items-center'), children: [jsxRuntime.jsxs("div", { className: 'grid gap-1.5', children: [nestLabel ? tooltipLabel : null, jsxRuntime.jsx("span", { className: 'text-muted-foreground', children: itemConfig?.label || item.name })] }), item.value && (jsxRuntime.jsx("span", { className: 'font-mono font-medium tabular-nums text-foreground', children: item.value.toLocaleString() }))] })] })) }, item.dataKey));
|
|
470
458
|
}) })] }));
|
|
471
459
|
});
|
|
472
|
-
ChartTooltipContent.displayName =
|
|
460
|
+
ChartTooltipContent.displayName = 'ChartTooltip';
|
|
473
461
|
const ChartLegend = RechartsPrimitive__namespace.Legend;
|
|
474
|
-
const ChartLegendContent = React__namespace.forwardRef(({ className, hideIcon = false, payload, verticalAlign =
|
|
462
|
+
const ChartLegendContent = React__namespace.forwardRef(({ className, hideIcon = false, payload, verticalAlign = 'bottom', nameKey }, ref) => {
|
|
475
463
|
const { config } = useChart();
|
|
476
464
|
if (!payload?.length) {
|
|
477
465
|
return null;
|
|
478
466
|
}
|
|
479
|
-
return (jsxRuntime.jsx("div", { ref: ref, className: cn(
|
|
480
|
-
const key = `${nameKey || item.dataKey ||
|
|
467
|
+
return (jsxRuntime.jsx("div", { ref: ref, className: cn('flex items-center justify-center gap-4', verticalAlign === 'top' ? 'pb-3' : 'pt-3', className), children: payload.map((item) => {
|
|
468
|
+
const key = `${nameKey || item.dataKey || 'value'}`;
|
|
481
469
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
482
|
-
return (jsxRuntime.jsxs("div", { className: cn(
|
|
470
|
+
return (jsxRuntime.jsxs("div", { className: cn('flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground'), children: [itemConfig?.icon && !hideIcon ? (jsxRuntime.jsx(itemConfig.icon, {})) : (jsxRuntime.jsx("div", { className: 'h-2 w-2 shrink-0 rounded-[2px]', style: {
|
|
483
471
|
backgroundColor: item.color,
|
|
484
472
|
} })), itemConfig?.label] }, item.value));
|
|
485
473
|
}) }));
|
|
486
474
|
});
|
|
487
|
-
ChartLegendContent.displayName =
|
|
475
|
+
ChartLegendContent.displayName = 'ChartLegend';
|
|
488
476
|
// Helper to extract item config from a payload.
|
|
489
477
|
function getPayloadConfigFromPayload(config, payload, key) {
|
|
490
|
-
if (typeof payload !==
|
|
478
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
491
479
|
return undefined;
|
|
492
480
|
}
|
|
493
|
-
const payloadPayload =
|
|
494
|
-
typeof payload.payload === "object" &&
|
|
495
|
-
payload.payload !== null
|
|
496
|
-
? payload.payload
|
|
497
|
-
: undefined;
|
|
481
|
+
const payloadPayload = 'payload' in payload && typeof payload.payload === 'object' && payload.payload !== null ? payload.payload : undefined;
|
|
498
482
|
let configLabelKey = key;
|
|
499
|
-
if (key in payload &&
|
|
500
|
-
typeof payload[key] === "string") {
|
|
483
|
+
if (key in payload && typeof payload[key] === 'string') {
|
|
501
484
|
configLabelKey = payload[key];
|
|
502
485
|
}
|
|
503
|
-
else if (payloadPayload &&
|
|
504
|
-
key in payloadPayload &&
|
|
505
|
-
typeof payloadPayload[key] === "string") {
|
|
486
|
+
else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === 'string') {
|
|
506
487
|
configLabelKey = payloadPayload[key];
|
|
507
488
|
}
|
|
508
|
-
return configLabelKey in config
|
|
509
|
-
? config[configLabelKey]
|
|
510
|
-
: config[key];
|
|
489
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
511
490
|
}
|
|
512
491
|
|
|
513
492
|
const Checkbox = React__namespace.forwardRef(({ className, value, ...props }, ref) => (jsxRuntime.jsx(CheckboxPrimitive__namespace.Root, { ref: ref, checked: !!value, className: cn('peer h-4 w-4 shrink-0 rounded-sm border ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-background-primary data-[state=checked]:text-primary-foreground', className), ...props, children: jsxRuntime.jsx(CheckboxPrimitive__namespace.Indicator, { className: cn('flex items-center justify-center text-current'), children: jsxRuntime.jsx(lucideReact.Check, { className: 'h-4 w-4' }) }) })));
|
|
@@ -719,28 +698,98 @@ const HoverCardTrigger = HoverCardPrimitive__namespace.Trigger;
|
|
|
719
698
|
const HoverCardContent = React__namespace.forwardRef(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (jsxRuntime.jsx(HoverCardPrimitive__namespace.Content, { ref: ref, align: align, sideOffset: sideOffset, className: cn('z-50 w-auto mr-20 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-2', className), ...props })));
|
|
720
699
|
HoverCardContent.displayName = HoverCardPrimitive__namespace.Content.displayName;
|
|
721
700
|
|
|
701
|
+
/**
|
|
702
|
+
* Modify function for phone number input mask.
|
|
703
|
+
* Automatically adjusts between landline and mobile phone formats.
|
|
704
|
+
*
|
|
705
|
+
* @param value - Current input value
|
|
706
|
+
* @param data - New input data
|
|
707
|
+
* @param selectionStart - Cursor start position
|
|
708
|
+
* @param selectionEnd - Cursor end position
|
|
709
|
+
* @returns Mask configuration object
|
|
710
|
+
*/
|
|
722
711
|
const modifyPhone = ({ value, data, selectionStart, selectionEnd }) => {
|
|
723
712
|
const _value = value.slice(0, selectionStart) + (data ?? '') + value.slice(selectionEnd);
|
|
724
713
|
_value ? _value.replace(/[\D]+/g, '').length : 0;
|
|
725
714
|
return maskPhone(_value);
|
|
726
715
|
};
|
|
716
|
+
/**
|
|
717
|
+
* Creates a phone number mask based on the input length.
|
|
718
|
+
* - Landline: (XX) XXXX-XXXX
|
|
719
|
+
* - Mobile: (XX) X XXXX-XXXX
|
|
720
|
+
*
|
|
721
|
+
* @param value - Phone number string (can be null)
|
|
722
|
+
* @returns Mask configuration object with pattern and replacement rules
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```tsx
|
|
726
|
+
* const mask = maskPhone('11987654321');
|
|
727
|
+
* // Returns: { mask: '(__) _ ____-____', replacement: { _: /\d/ } }
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
727
730
|
function maskPhone(value) {
|
|
728
731
|
const len = value ? value.replace(/[\D]+/g, '').length : 0;
|
|
729
732
|
if (len > 10)
|
|
730
733
|
return { mask: '(__) _ ____-____', replacement: { _: /\d/ } };
|
|
731
734
|
return { mask: '(__) ____-_____', replacement: { _: /\d/ } };
|
|
732
735
|
}
|
|
736
|
+
/**
|
|
737
|
+
* Modify function for CPF/CNPJ input mask.
|
|
738
|
+
* Automatically switches between CPF and CNPJ formats based on input length.
|
|
739
|
+
*
|
|
740
|
+
* @param value - Current input value
|
|
741
|
+
* @param data - New input data
|
|
742
|
+
* @param selectionStart - Cursor start position
|
|
743
|
+
* @param selectionEnd - Cursor end position
|
|
744
|
+
* @returns Mask configuration object
|
|
745
|
+
*/
|
|
733
746
|
const modifyCpfCnpj = ({ value, data, selectionStart, selectionEnd }) => {
|
|
734
747
|
const _value = value.slice(0, selectionStart) + (data ?? '') + value.slice(selectionEnd);
|
|
735
748
|
_value ? _value.replace(/[\D]+/g, '').length : 0;
|
|
736
749
|
return maskCpfCnpj(_value);
|
|
737
750
|
};
|
|
751
|
+
/**
|
|
752
|
+
* Creates a CPF or CNPJ mask based on the input length.
|
|
753
|
+
* - CPF: XXX.XXX.XXX-XX (up to 11 digits)
|
|
754
|
+
* - CNPJ: XX.XXX.XXX/XXXX-XX (12+ digits)
|
|
755
|
+
*
|
|
756
|
+
* @param value - CPF/CNPJ string (can be null)
|
|
757
|
+
* @returns Mask configuration object with pattern and replacement rules
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```tsx
|
|
761
|
+
* const cpfMask = maskCpfCnpj('12345678901');
|
|
762
|
+
* // Returns: { mask: '___.___.___-___', replacement: { _: /\d/ } }
|
|
763
|
+
*
|
|
764
|
+
* const cnpjMask = maskCpfCnpj('12345678000195');
|
|
765
|
+
* // Returns: { mask: '__.___.___/____-__', replacement: { _: /\d/ } }
|
|
766
|
+
* ```
|
|
767
|
+
*/
|
|
738
768
|
function maskCpfCnpj(value) {
|
|
739
769
|
const len = value ? value.replace(/[\D]+/g, '').length : 0;
|
|
740
770
|
if (len > 11)
|
|
741
771
|
return { mask: '__.___.___/____-__', replacement: { _: /\d/ } };
|
|
742
772
|
return { mask: '___.___.___-___', replacement: { _: /\d/ } };
|
|
743
773
|
}
|
|
774
|
+
/**
|
|
775
|
+
* Removes all non-numeric characters from a string.
|
|
776
|
+
* Useful for extracting only digits from masked inputs.
|
|
777
|
+
*
|
|
778
|
+
* @param value - String with potential mask characters
|
|
779
|
+
* @returns String containing only numeric characters
|
|
780
|
+
*
|
|
781
|
+
* @example
|
|
782
|
+
* ```tsx
|
|
783
|
+
* const cleaned = removeMaskNumber('(11) 9 8765-4321');
|
|
784
|
+
* // Returns: '11987654321'
|
|
785
|
+
*
|
|
786
|
+
* const cleanCpf = removeMaskNumber('123.456.789-01');
|
|
787
|
+
* // Returns: '12345678901'
|
|
788
|
+
* ```
|
|
789
|
+
*/
|
|
790
|
+
const removeMaskNumber = (value) => {
|
|
791
|
+
return value?.replace(/\D/g, '');
|
|
792
|
+
};
|
|
744
793
|
|
|
745
794
|
// PHONE
|
|
746
795
|
function formatPhone(telefone, removerCountryCode = true) {
|
|
@@ -3686,8 +3735,11 @@ exports.getFirstDayOfCurrentMonth = getFirstDayOfCurrentMonth;
|
|
|
3686
3735
|
exports.getTailwindColorShades = getTailwindColorShades;
|
|
3687
3736
|
exports.invertDate = invertDate;
|
|
3688
3737
|
exports.isUUIDv4 = isUUIDv4;
|
|
3738
|
+
exports.maskCpfCnpj = maskCpfCnpj;
|
|
3739
|
+
exports.maskPhone = maskPhone;
|
|
3689
3740
|
exports.modifyCpfCnpj = modifyCpfCnpj;
|
|
3690
3741
|
exports.modifyPhone = modifyPhone;
|
|
3742
|
+
exports.removeMaskNumber = removeMaskNumber;
|
|
3691
3743
|
exports.replaceThemeTailwindColors = replaceThemeTailwindColors;
|
|
3692
3744
|
exports.roundNumber = roundNumber;
|
|
3693
3745
|
exports.stringDateToDate = stringDateToDate;
|