@yeverlibs/ds 1.1.6 → 1.1.7

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 CHANGED
@@ -907,6 +907,50 @@ interface ChartProps extends Omit<Partial<PieSvgProps<{
907
907
  }
908
908
  declare const PieChart: React.FC<ChartProps>;
909
909
 
910
+ type LoadingActions = {
911
+ setLoading: (loading: boolean) => void
912
+ }
913
+
914
+ type UseLoadingReturn = {
915
+ loadingActions: LoadingActions
916
+ }
917
+
918
+ type FetchProps = {
919
+ url: string
920
+ method: 'get' | 'post' | 'put' | 'patch' | 'delete'
921
+ onSuccess?: (data: string | number | boolean | null | undefined | object) => void
922
+ onError?: (error: string | number | boolean | null | undefined | object) => void
923
+ successMessage?: string
924
+ errorMessage?: string
925
+ filtersAllowed?: string[]
926
+ filters?: { [key: string]: string }
927
+ isFiltersFromUrl?: boolean
928
+ config?: any
929
+ noError?: boolean
930
+ useLoading?: () => UseLoadingReturn
931
+ }
932
+
933
+ declare function useFetchClientSide<T = string | number | boolean | null | undefined | object>({ url, method, onSuccess, onError, successMessage, errorMessage, filtersAllowed, filters, isFiltersFromUrl, config, noError, useLoading, }: Omit<FetchProps, 'onSuccess'> & {
934
+ onSuccess?: (data: T) => void;
935
+ }): {
936
+ state: {
937
+ errors: {
938
+ [key: string]: string | number | boolean | null | undefined | object;
939
+ } | null;
940
+ data: object | null;
941
+ loading: boolean;
942
+ };
943
+ operations: {
944
+ submit: (body?: object | null, customHandlers?: {
945
+ customUrl?: string;
946
+ customMethod?: 'get' | 'post' | 'put' | 'patch' | 'delete';
947
+ customSuccessMessage?: string;
948
+ signal?: AbortSignal;
949
+ }) => Promise<void>;
950
+ setLoading: (loading: boolean) => void;
951
+ };
952
+ };
953
+
910
954
  declare function Configuracoes(props: React$1.SVGProps<SVGSVGElement>): react_jsx_runtime.JSX.Element;
911
955
  declare const MemoConfiguracoes: React$1.MemoExoticComponent<typeof Configuracoes>;
912
956
 
@@ -1459,4 +1503,4 @@ declare const useCopyToClipboard: (successMessage?: string) => {
1459
1503
  copyToClipboard: (initialText: string) => void;
1460
1504
  };
1461
1505
 
1462
- export { Alert, MemoAlertDefault as AlertDefault, MemoAlertError as AlertError, MemoAlertGuard as AlertGuard, MemoAlertInfo as AlertInfo, MemoAlertWarning as AlertWarning, MemoApi as Api, MemoArrowLeft as ArrowLeft, MemoArrowNarrowUpRight as ArrowNarrowUpRight, Avatar, BarChart, MemoBoleto as Boleto, Box, Button, type ButtonProps, ButtonToggleGroup, type ButtonToggleGroupProps, CSV, MemoCalendar as Calendar, MemoCard as Card, MemoCarrFree as CarrFree, MemoCarretDown as CarretDown, MemoCarretSingleRight as CarretSingleRight, CarrinhoAbandonado, MemoCart as Cart, MemoChargeback as Chargeback, MemoCheck as Check, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxOption, MemoCheckout as Checkout, MemoChevronDown as ChevronDown, MemoChevronLeftDouble as ChevronLeftDouble, MemoCloseCheckbox as CloseCheckbox, MemoCloseIcon as CloseIcon, MemoCloud as Cloud, MemoCodeCircle as CodeCircle, type Column, MemoConfiguracoes as Configuracoes, MemoCopy as Copy, MemoCopyLink as CopyLink, Counter, MemoCreditCard as CreditCard, MemoCupom as Cupom, CurrencyInput, CustomSelect, MemoDashboard as Dashboard, DatePicker, type DatePickerProps, type DateStateProps, DeleteModal, MemoDelivery as Delivery, MemoDepoimentos as Depoimentos, MemoDistribuicao as Distribuicao, MemoDistribution as Distribution, MemoDominios as Dominios, MemoDownloadArrow as DownloadArrow, MemoDrag as Drag, DropdownContext, DropdownItens, DropdownTrigger, DrowpdownButton, MemoEdit as Edit, Emails, MemoExtrato as Extrato, MemoEyeInput as EyeInput, MemoEyeOff as EyeOff, FeedbackBadge, MemoFileMinus as FileMinus, FileUploadWithDisplayName as FileUpload, FilterDrawer, MemoFilterLines as FilterLines, FilterList, FilterListContext, FilterTrigger, MemoFinanceiro as Financeiro, FormWrapper, MemoFrete as Frete, MemoFreteGratis as FreteGratis, GeneralPageLinks, MemoGestao as Gestao, MemoGlobe as Globe, GlobeVariant, Grid, GridColumn, Guard, Heading, MemoHeadphones as Headphones, MemoHelp as Help, MemoHelpCircle as HelpCircle, Home, MemoInfoCircle as InfoCircle, Input, MemoIntegracoes as Integracoes, LineChart, Link$1 as Link, MemoLink as LinkIcon, type LinkProps, MemoLoadingSpinner as LoadingSpinner, MemoLock as Lock, MemoLockInput as LockInput, Logistica, MemoLoja as Loja, LojaAlert, LojaAlertSuccess, MemoMail as Mail, MemoMailInput as MailInput, MemoMarkerPin as MarkerPin, MemoMarketing as Marketing, MediumRisk, MemoMessage as Message, Modal, MemoMoney as Money, MultiSelect, NewIcons, MemoNewMessage as NewMessage, MemoNewNotification as NewNotification, MemoNotificacoes as Notificacoes, MemoNotification as Notification, NotificationItem, MemoNotifications as Notifications, type OpenAsBlobOptions, MemoOrderBump as OrderBump, PageContainer, PaginatedData, PaymentCard, MemoPermissaoDeAcesso as PermissaoDeAcesso, PhoneCall, PieChart, MemoPix as Pix, MemoPixels as Pixels, Planilha, MemoPlus as Plus, MemoPrechargeback as Prechargeback, PrefetchLink, PreviewPhone, MemoProduto as Produto, MemoProdutos as Produtos, MemoPromocoes as Promocoes, RecuperacaoDeCarrinho, MemoRefresh as Refresh, MemoRelatorios as Relatorios, MemoRestricaoDeAcesso as RestricaoDeAcesso, Ribbon, MemoRisco as Risco, MemoSac as Sac, MemoSearchMd as SearchMd, SelectableOption, Separator, MemoSignout as Signout, SliderInput, SlidingPanel, Spinner$1 as Spinner, MemoSpinner as SpinnerIcon, StatusBadge, MemoStore as Store, Switch$1 as Switch, MemoSwitch as SwitchIcon, type SwitchProps, Table, Tabs, Text, Textarea, TimeInput, TimerCounter, type CounterInputProps$1 as TimerCounterProps, TimerCounterWithoutSeconds, type CounterInputProps as TimerCounterWithoutSecondsProps, Tooltip, MemoTransfer as Transfer, MemoTrash as Trash, MemoTruck as Truck, MemoUpsell as Upsell, MemoUser as User, MemoUsers as Users, MemoVerticalPoints as VerticalPoints, MemoWarning as Warning, MemoWebhook as Webhook, MemoWebhook$1 as WebhookConfig, MemoWhatsapp as Whatsapp, Xlsx, MemoYever as Yever, calculateCurrencyOperation, cn, colors, fontFamily, formatCNPJ, formatCNPJCPF, formatCPF, formatCurrency, formatCurrencyShort, formatDate, formatDateAndReturnPassedHours, formatDateGeneric, formatDateInPassedDays, formatDateTime, formatDateToISO, formatIP, formatName, formatNumberToCurrency, formatPhone, formatPostalCode, formatRawDigitsToCurrency, formatTime$1 as formatTimeWithSeconds, formatTime as formatTimeWithoutSeconds, getDates, handleFormSubmission, nextReplaceUrl, parseFormattedCurrency, parseParametersIntoUrl, shadow, transformDateToAmericanFormat, transformToCurrency, transformToNumber, transformToPercentage, truncateString, useCopyToClipboard };
1506
+ export { Alert, MemoAlertDefault as AlertDefault, MemoAlertError as AlertError, MemoAlertGuard as AlertGuard, MemoAlertInfo as AlertInfo, MemoAlertWarning as AlertWarning, MemoApi as Api, MemoArrowLeft as ArrowLeft, MemoArrowNarrowUpRight as ArrowNarrowUpRight, Avatar, BarChart, MemoBoleto as Boleto, Box, Button, type ButtonProps, ButtonToggleGroup, type ButtonToggleGroupProps, CSV, MemoCalendar as Calendar, MemoCard as Card, MemoCarrFree as CarrFree, MemoCarretDown as CarretDown, MemoCarretSingleRight as CarretSingleRight, CarrinhoAbandonado, MemoCart as Cart, MemoChargeback as Chargeback, MemoCheck as Check, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxOption, MemoCheckout as Checkout, MemoChevronDown as ChevronDown, MemoChevronLeftDouble as ChevronLeftDouble, MemoCloseCheckbox as CloseCheckbox, MemoCloseIcon as CloseIcon, MemoCloud as Cloud, MemoCodeCircle as CodeCircle, type Column, MemoConfiguracoes as Configuracoes, MemoCopy as Copy, MemoCopyLink as CopyLink, Counter, MemoCreditCard as CreditCard, MemoCupom as Cupom, CurrencyInput, CustomSelect, MemoDashboard as Dashboard, DatePicker, type DatePickerProps, type DateStateProps, DeleteModal, MemoDelivery as Delivery, MemoDepoimentos as Depoimentos, MemoDistribuicao as Distribuicao, MemoDistribution as Distribution, MemoDominios as Dominios, MemoDownloadArrow as DownloadArrow, MemoDrag as Drag, DropdownContext, DropdownItens, DropdownTrigger, DrowpdownButton, MemoEdit as Edit, Emails, MemoExtrato as Extrato, MemoEyeInput as EyeInput, MemoEyeOff as EyeOff, FeedbackBadge, MemoFileMinus as FileMinus, FileUploadWithDisplayName as FileUpload, FilterDrawer, MemoFilterLines as FilterLines, FilterList, FilterListContext, FilterTrigger, MemoFinanceiro as Financeiro, FormWrapper, MemoFrete as Frete, MemoFreteGratis as FreteGratis, GeneralPageLinks, MemoGestao as Gestao, MemoGlobe as Globe, GlobeVariant, Grid, GridColumn, Guard, Heading, MemoHeadphones as Headphones, MemoHelp as Help, MemoHelpCircle as HelpCircle, Home, MemoInfoCircle as InfoCircle, Input, MemoIntegracoes as Integracoes, LineChart, Link$1 as Link, MemoLink as LinkIcon, type LinkProps, MemoLoadingSpinner as LoadingSpinner, MemoLock as Lock, MemoLockInput as LockInput, Logistica, MemoLoja as Loja, LojaAlert, LojaAlertSuccess, MemoMail as Mail, MemoMailInput as MailInput, MemoMarkerPin as MarkerPin, MemoMarketing as Marketing, MediumRisk, MemoMessage as Message, Modal, MemoMoney as Money, MultiSelect, NewIcons, MemoNewMessage as NewMessage, MemoNewNotification as NewNotification, MemoNotificacoes as Notificacoes, MemoNotification as Notification, NotificationItem, MemoNotifications as Notifications, type OpenAsBlobOptions, MemoOrderBump as OrderBump, PageContainer, PaginatedData, PaymentCard, MemoPermissaoDeAcesso as PermissaoDeAcesso, PhoneCall, PieChart, MemoPix as Pix, MemoPixels as Pixels, Planilha, MemoPlus as Plus, MemoPrechargeback as Prechargeback, PrefetchLink, PreviewPhone, MemoProduto as Produto, MemoProdutos as Produtos, MemoPromocoes as Promocoes, RecuperacaoDeCarrinho, MemoRefresh as Refresh, MemoRelatorios as Relatorios, MemoRestricaoDeAcesso as RestricaoDeAcesso, Ribbon, MemoRisco as Risco, MemoSac as Sac, MemoSearchMd as SearchMd, SelectableOption, Separator, MemoSignout as Signout, SliderInput, SlidingPanel, Spinner$1 as Spinner, MemoSpinner as SpinnerIcon, StatusBadge, MemoStore as Store, Switch$1 as Switch, MemoSwitch as SwitchIcon, type SwitchProps, Table, Tabs, Text, Textarea, TimeInput, TimerCounter, type CounterInputProps$1 as TimerCounterProps, TimerCounterWithoutSeconds, type CounterInputProps as TimerCounterWithoutSecondsProps, Tooltip, MemoTransfer as Transfer, MemoTrash as Trash, MemoTruck as Truck, MemoUpsell as Upsell, MemoUser as User, MemoUsers as Users, MemoVerticalPoints as VerticalPoints, MemoWarning as Warning, MemoWebhook as Webhook, MemoWebhook$1 as WebhookConfig, MemoWhatsapp as Whatsapp, Xlsx, MemoYever as Yever, calculateCurrencyOperation, cn, colors, fontFamily, formatCNPJ, formatCNPJCPF, formatCPF, formatCurrency, formatCurrencyShort, formatDate, formatDateAndReturnPassedHours, formatDateGeneric, formatDateInPassedDays, formatDateTime, formatDateToISO, formatIP, formatName, formatNumberToCurrency, formatPhone, formatPostalCode, formatRawDigitsToCurrency, formatTime$1 as formatTimeWithSeconds, formatTime as formatTimeWithoutSeconds, getDates, handleFormSubmission, nextReplaceUrl, parseFormattedCurrency, parseParametersIntoUrl, shadow, transformDateToAmericanFormat, transformToCurrency, transformToNumber, transformToPercentage, truncateString, useCopyToClipboard, useFetchClientSide };
package/dist/index.d.ts CHANGED
@@ -907,6 +907,50 @@ interface ChartProps extends Omit<Partial<PieSvgProps<{
907
907
  }
908
908
  declare const PieChart: React.FC<ChartProps>;
909
909
 
910
+ type LoadingActions = {
911
+ setLoading: (loading: boolean) => void
912
+ }
913
+
914
+ type UseLoadingReturn = {
915
+ loadingActions: LoadingActions
916
+ }
917
+
918
+ type FetchProps = {
919
+ url: string
920
+ method: 'get' | 'post' | 'put' | 'patch' | 'delete'
921
+ onSuccess?: (data: string | number | boolean | null | undefined | object) => void
922
+ onError?: (error: string | number | boolean | null | undefined | object) => void
923
+ successMessage?: string
924
+ errorMessage?: string
925
+ filtersAllowed?: string[]
926
+ filters?: { [key: string]: string }
927
+ isFiltersFromUrl?: boolean
928
+ config?: any
929
+ noError?: boolean
930
+ useLoading?: () => UseLoadingReturn
931
+ }
932
+
933
+ declare function useFetchClientSide<T = string | number | boolean | null | undefined | object>({ url, method, onSuccess, onError, successMessage, errorMessage, filtersAllowed, filters, isFiltersFromUrl, config, noError, useLoading, }: Omit<FetchProps, 'onSuccess'> & {
934
+ onSuccess?: (data: T) => void;
935
+ }): {
936
+ state: {
937
+ errors: {
938
+ [key: string]: string | number | boolean | null | undefined | object;
939
+ } | null;
940
+ data: object | null;
941
+ loading: boolean;
942
+ };
943
+ operations: {
944
+ submit: (body?: object | null, customHandlers?: {
945
+ customUrl?: string;
946
+ customMethod?: 'get' | 'post' | 'put' | 'patch' | 'delete';
947
+ customSuccessMessage?: string;
948
+ signal?: AbortSignal;
949
+ }) => Promise<void>;
950
+ setLoading: (loading: boolean) => void;
951
+ };
952
+ };
953
+
910
954
  declare function Configuracoes(props: React$1.SVGProps<SVGSVGElement>): react_jsx_runtime.JSX.Element;
911
955
  declare const MemoConfiguracoes: React$1.MemoExoticComponent<typeof Configuracoes>;
912
956
 
@@ -1459,4 +1503,4 @@ declare const useCopyToClipboard: (successMessage?: string) => {
1459
1503
  copyToClipboard: (initialText: string) => void;
1460
1504
  };
1461
1505
 
1462
- export { Alert, MemoAlertDefault as AlertDefault, MemoAlertError as AlertError, MemoAlertGuard as AlertGuard, MemoAlertInfo as AlertInfo, MemoAlertWarning as AlertWarning, MemoApi as Api, MemoArrowLeft as ArrowLeft, MemoArrowNarrowUpRight as ArrowNarrowUpRight, Avatar, BarChart, MemoBoleto as Boleto, Box, Button, type ButtonProps, ButtonToggleGroup, type ButtonToggleGroupProps, CSV, MemoCalendar as Calendar, MemoCard as Card, MemoCarrFree as CarrFree, MemoCarretDown as CarretDown, MemoCarretSingleRight as CarretSingleRight, CarrinhoAbandonado, MemoCart as Cart, MemoChargeback as Chargeback, MemoCheck as Check, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxOption, MemoCheckout as Checkout, MemoChevronDown as ChevronDown, MemoChevronLeftDouble as ChevronLeftDouble, MemoCloseCheckbox as CloseCheckbox, MemoCloseIcon as CloseIcon, MemoCloud as Cloud, MemoCodeCircle as CodeCircle, type Column, MemoConfiguracoes as Configuracoes, MemoCopy as Copy, MemoCopyLink as CopyLink, Counter, MemoCreditCard as CreditCard, MemoCupom as Cupom, CurrencyInput, CustomSelect, MemoDashboard as Dashboard, DatePicker, type DatePickerProps, type DateStateProps, DeleteModal, MemoDelivery as Delivery, MemoDepoimentos as Depoimentos, MemoDistribuicao as Distribuicao, MemoDistribution as Distribution, MemoDominios as Dominios, MemoDownloadArrow as DownloadArrow, MemoDrag as Drag, DropdownContext, DropdownItens, DropdownTrigger, DrowpdownButton, MemoEdit as Edit, Emails, MemoExtrato as Extrato, MemoEyeInput as EyeInput, MemoEyeOff as EyeOff, FeedbackBadge, MemoFileMinus as FileMinus, FileUploadWithDisplayName as FileUpload, FilterDrawer, MemoFilterLines as FilterLines, FilterList, FilterListContext, FilterTrigger, MemoFinanceiro as Financeiro, FormWrapper, MemoFrete as Frete, MemoFreteGratis as FreteGratis, GeneralPageLinks, MemoGestao as Gestao, MemoGlobe as Globe, GlobeVariant, Grid, GridColumn, Guard, Heading, MemoHeadphones as Headphones, MemoHelp as Help, MemoHelpCircle as HelpCircle, Home, MemoInfoCircle as InfoCircle, Input, MemoIntegracoes as Integracoes, LineChart, Link$1 as Link, MemoLink as LinkIcon, type LinkProps, MemoLoadingSpinner as LoadingSpinner, MemoLock as Lock, MemoLockInput as LockInput, Logistica, MemoLoja as Loja, LojaAlert, LojaAlertSuccess, MemoMail as Mail, MemoMailInput as MailInput, MemoMarkerPin as MarkerPin, MemoMarketing as Marketing, MediumRisk, MemoMessage as Message, Modal, MemoMoney as Money, MultiSelect, NewIcons, MemoNewMessage as NewMessage, MemoNewNotification as NewNotification, MemoNotificacoes as Notificacoes, MemoNotification as Notification, NotificationItem, MemoNotifications as Notifications, type OpenAsBlobOptions, MemoOrderBump as OrderBump, PageContainer, PaginatedData, PaymentCard, MemoPermissaoDeAcesso as PermissaoDeAcesso, PhoneCall, PieChart, MemoPix as Pix, MemoPixels as Pixels, Planilha, MemoPlus as Plus, MemoPrechargeback as Prechargeback, PrefetchLink, PreviewPhone, MemoProduto as Produto, MemoProdutos as Produtos, MemoPromocoes as Promocoes, RecuperacaoDeCarrinho, MemoRefresh as Refresh, MemoRelatorios as Relatorios, MemoRestricaoDeAcesso as RestricaoDeAcesso, Ribbon, MemoRisco as Risco, MemoSac as Sac, MemoSearchMd as SearchMd, SelectableOption, Separator, MemoSignout as Signout, SliderInput, SlidingPanel, Spinner$1 as Spinner, MemoSpinner as SpinnerIcon, StatusBadge, MemoStore as Store, Switch$1 as Switch, MemoSwitch as SwitchIcon, type SwitchProps, Table, Tabs, Text, Textarea, TimeInput, TimerCounter, type CounterInputProps$1 as TimerCounterProps, TimerCounterWithoutSeconds, type CounterInputProps as TimerCounterWithoutSecondsProps, Tooltip, MemoTransfer as Transfer, MemoTrash as Trash, MemoTruck as Truck, MemoUpsell as Upsell, MemoUser as User, MemoUsers as Users, MemoVerticalPoints as VerticalPoints, MemoWarning as Warning, MemoWebhook as Webhook, MemoWebhook$1 as WebhookConfig, MemoWhatsapp as Whatsapp, Xlsx, MemoYever as Yever, calculateCurrencyOperation, cn, colors, fontFamily, formatCNPJ, formatCNPJCPF, formatCPF, formatCurrency, formatCurrencyShort, formatDate, formatDateAndReturnPassedHours, formatDateGeneric, formatDateInPassedDays, formatDateTime, formatDateToISO, formatIP, formatName, formatNumberToCurrency, formatPhone, formatPostalCode, formatRawDigitsToCurrency, formatTime$1 as formatTimeWithSeconds, formatTime as formatTimeWithoutSeconds, getDates, handleFormSubmission, nextReplaceUrl, parseFormattedCurrency, parseParametersIntoUrl, shadow, transformDateToAmericanFormat, transformToCurrency, transformToNumber, transformToPercentage, truncateString, useCopyToClipboard };
1506
+ export { Alert, MemoAlertDefault as AlertDefault, MemoAlertError as AlertError, MemoAlertGuard as AlertGuard, MemoAlertInfo as AlertInfo, MemoAlertWarning as AlertWarning, MemoApi as Api, MemoArrowLeft as ArrowLeft, MemoArrowNarrowUpRight as ArrowNarrowUpRight, Avatar, BarChart, MemoBoleto as Boleto, Box, Button, type ButtonProps, ButtonToggleGroup, type ButtonToggleGroupProps, CSV, MemoCalendar as Calendar, MemoCard as Card, MemoCarrFree as CarrFree, MemoCarretDown as CarretDown, MemoCarretSingleRight as CarretSingleRight, CarrinhoAbandonado, MemoCart as Cart, MemoChargeback as Chargeback, MemoCheck as Check, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxOption, MemoCheckout as Checkout, MemoChevronDown as ChevronDown, MemoChevronLeftDouble as ChevronLeftDouble, MemoCloseCheckbox as CloseCheckbox, MemoCloseIcon as CloseIcon, MemoCloud as Cloud, MemoCodeCircle as CodeCircle, type Column, MemoConfiguracoes as Configuracoes, MemoCopy as Copy, MemoCopyLink as CopyLink, Counter, MemoCreditCard as CreditCard, MemoCupom as Cupom, CurrencyInput, CustomSelect, MemoDashboard as Dashboard, DatePicker, type DatePickerProps, type DateStateProps, DeleteModal, MemoDelivery as Delivery, MemoDepoimentos as Depoimentos, MemoDistribuicao as Distribuicao, MemoDistribution as Distribution, MemoDominios as Dominios, MemoDownloadArrow as DownloadArrow, MemoDrag as Drag, DropdownContext, DropdownItens, DropdownTrigger, DrowpdownButton, MemoEdit as Edit, Emails, MemoExtrato as Extrato, MemoEyeInput as EyeInput, MemoEyeOff as EyeOff, FeedbackBadge, MemoFileMinus as FileMinus, FileUploadWithDisplayName as FileUpload, FilterDrawer, MemoFilterLines as FilterLines, FilterList, FilterListContext, FilterTrigger, MemoFinanceiro as Financeiro, FormWrapper, MemoFrete as Frete, MemoFreteGratis as FreteGratis, GeneralPageLinks, MemoGestao as Gestao, MemoGlobe as Globe, GlobeVariant, Grid, GridColumn, Guard, Heading, MemoHeadphones as Headphones, MemoHelp as Help, MemoHelpCircle as HelpCircle, Home, MemoInfoCircle as InfoCircle, Input, MemoIntegracoes as Integracoes, LineChart, Link$1 as Link, MemoLink as LinkIcon, type LinkProps, MemoLoadingSpinner as LoadingSpinner, MemoLock as Lock, MemoLockInput as LockInput, Logistica, MemoLoja as Loja, LojaAlert, LojaAlertSuccess, MemoMail as Mail, MemoMailInput as MailInput, MemoMarkerPin as MarkerPin, MemoMarketing as Marketing, MediumRisk, MemoMessage as Message, Modal, MemoMoney as Money, MultiSelect, NewIcons, MemoNewMessage as NewMessage, MemoNewNotification as NewNotification, MemoNotificacoes as Notificacoes, MemoNotification as Notification, NotificationItem, MemoNotifications as Notifications, type OpenAsBlobOptions, MemoOrderBump as OrderBump, PageContainer, PaginatedData, PaymentCard, MemoPermissaoDeAcesso as PermissaoDeAcesso, PhoneCall, PieChart, MemoPix as Pix, MemoPixels as Pixels, Planilha, MemoPlus as Plus, MemoPrechargeback as Prechargeback, PrefetchLink, PreviewPhone, MemoProduto as Produto, MemoProdutos as Produtos, MemoPromocoes as Promocoes, RecuperacaoDeCarrinho, MemoRefresh as Refresh, MemoRelatorios as Relatorios, MemoRestricaoDeAcesso as RestricaoDeAcesso, Ribbon, MemoRisco as Risco, MemoSac as Sac, MemoSearchMd as SearchMd, SelectableOption, Separator, MemoSignout as Signout, SliderInput, SlidingPanel, Spinner$1 as Spinner, MemoSpinner as SpinnerIcon, StatusBadge, MemoStore as Store, Switch$1 as Switch, MemoSwitch as SwitchIcon, type SwitchProps, Table, Tabs, Text, Textarea, TimeInput, TimerCounter, type CounterInputProps$1 as TimerCounterProps, TimerCounterWithoutSeconds, type CounterInputProps as TimerCounterWithoutSecondsProps, Tooltip, MemoTransfer as Transfer, MemoTrash as Trash, MemoTruck as Truck, MemoUpsell as Upsell, MemoUser as User, MemoUsers as Users, MemoVerticalPoints as VerticalPoints, MemoWarning as Warning, MemoWebhook as Webhook, MemoWebhook$1 as WebhookConfig, MemoWhatsapp as Whatsapp, Xlsx, MemoYever as Yever, calculateCurrencyOperation, cn, colors, fontFamily, formatCNPJ, formatCNPJCPF, formatCPF, formatCurrency, formatCurrencyShort, formatDate, formatDateAndReturnPassedHours, formatDateGeneric, formatDateInPassedDays, formatDateTime, formatDateToISO, formatIP, formatName, formatNumberToCurrency, formatPhone, formatPostalCode, formatRawDigitsToCurrency, formatTime$1 as formatTimeWithSeconds, formatTime as formatTimeWithoutSeconds, getDates, handleFormSubmission, nextReplaceUrl, parseFormattedCurrency, parseParametersIntoUrl, shadow, transformDateToAmericanFormat, transformToCurrency, transformToNumber, transformToPercentage, truncateString, useCopyToClipboard, useFetchClientSide };
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ var Select2 = require('react-select');
19
19
  var bar = require('@nivo/bar');
20
20
  var line = require('@nivo/line');
21
21
  var pie = require('@nivo/pie');
22
+ var Cookies = require('js-cookie');
22
23
  var currency = require('currency.js');
23
24
 
24
25
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -48,6 +49,7 @@ var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
48
49
  var dynamic__default = /*#__PURE__*/_interopDefault(dynamic);
49
50
  var Link2__default = /*#__PURE__*/_interopDefault(Link2);
50
51
  var Select2__default = /*#__PURE__*/_interopDefault(Select2);
52
+ var Cookies__default = /*#__PURE__*/_interopDefault(Cookies);
51
53
  var currency__default = /*#__PURE__*/_interopDefault(currency);
52
54
 
53
55
  // src/lib/utils.ts
@@ -8092,6 +8094,293 @@ var PieChart = ({
8092
8094
  }
8093
8095
  );
8094
8096
  };
8097
+ async function getCsrfToken() {
8098
+ const baseURL = process.env.NEXT_PUBLIC_API_URL ?? "";
8099
+ const response = await fetch(`${baseURL}/sanctum/csrf-cookie`, {
8100
+ credentials: "include",
8101
+ headers: {
8102
+ "X-Requested-With": "XMLHttpRequest"
8103
+ }
8104
+ });
8105
+ if (!response.ok) {
8106
+ throw new Error("Falha ao obter token CSRF");
8107
+ }
8108
+ await new Promise((resolve) => setTimeout(resolve, 100));
8109
+ }
8110
+ async function apiFetch(options) {
8111
+ const baseURL = process.env.NEXT_PUBLIC_API_URL ?? "";
8112
+ const isAbsolute = /^https?:\/\//i.test(options.url);
8113
+ const url = isAbsolute ? options.url : `${baseURL}${options.url}`;
8114
+ const method = (options.method ?? "GET").toString().toLowerCase();
8115
+ const needsCSRFToken = ["post", "put", "delete"].includes(method);
8116
+ const hasCSRFCookie = Cookies__default.default.get("XSRF-TOKEN");
8117
+ if (needsCSRFToken && !hasCSRFCookie) {
8118
+ await getCsrfToken();
8119
+ }
8120
+ const defaultHeaders = {
8121
+ "X-Requested-With": "XMLHttpRequest",
8122
+ Accept: "application/json"
8123
+ };
8124
+ if (!(options.body instanceof FormData)) {
8125
+ defaultHeaders["Content-Type"] = "application/json";
8126
+ }
8127
+ const finalHeaders = new Headers(defaultHeaders);
8128
+ if (options.headers) {
8129
+ if (options.headers instanceof Headers) {
8130
+ options.headers.forEach((v, k) => finalHeaders.set(k, v));
8131
+ } else {
8132
+ Object.entries(options.headers).forEach(([k, v]) => {
8133
+ if (v !== void 0) finalHeaders.set(k, v);
8134
+ });
8135
+ }
8136
+ }
8137
+ const csrfToken = Cookies__default.default.get("XSRF-TOKEN");
8138
+ if (csrfToken) {
8139
+ finalHeaders.set("X-XSRF-TOKEN", csrfToken);
8140
+ }
8141
+ let finalOptions = options;
8142
+ if (options.body) {
8143
+ finalOptions = {
8144
+ ...options,
8145
+ body: options.body instanceof FormData ? options.body : JSON.stringify(options.body)
8146
+ };
8147
+ }
8148
+ let response = await fetch(url, {
8149
+ credentials: "include",
8150
+ headers: finalHeaders,
8151
+ ...finalOptions
8152
+ });
8153
+ if (response.status === 419) {
8154
+ Cookies__default.default.remove("XSRF-TOKEN");
8155
+ await getCsrfToken();
8156
+ const newToken = Cookies__default.default.get("XSRF-TOKEN");
8157
+ if (newToken) {
8158
+ finalHeaders.set("X-XSRF-TOKEN", newToken);
8159
+ }
8160
+ response = await fetch(url, {
8161
+ credentials: "include",
8162
+ headers: finalHeaders,
8163
+ ...options
8164
+ });
8165
+ if (!response.ok) {
8166
+ Cookies__default.default.remove("XSRF-TOKEN");
8167
+ Cookies__default.default.remove("yeverClientUser");
8168
+ window.location.href = "/login";
8169
+ return Promise.reject(new Error("CSRF token expirado"));
8170
+ }
8171
+ }
8172
+ const headers = {};
8173
+ response.headers.forEach((value, key) => {
8174
+ headers[key] = value;
8175
+ });
8176
+ if (!response.ok) {
8177
+ const data2 = await response.json().catch(() => null);
8178
+ const errorMessage = typeof data2 === "object" && data2 !== null && "message" in data2 ? data2.message : "Request failed";
8179
+ const error = new Error(errorMessage);
8180
+ error.status = response.status;
8181
+ error.response = {
8182
+ data: data2,
8183
+ status: response.status
8184
+ };
8185
+ throw error;
8186
+ }
8187
+ let data = null;
8188
+ if (options.responseType === "blob") {
8189
+ data = await response.blob().catch(() => null);
8190
+ } else {
8191
+ data = await response.json().catch(() => null);
8192
+ }
8193
+ return {
8194
+ status: response.status,
8195
+ statusText: response.statusText,
8196
+ data,
8197
+ headers
8198
+ };
8199
+ }
8200
+
8201
+ // src/utils/parse-parameters-into-url/index.tsx
8202
+ var parseParametersIntoUrl = (url, query, filtersAllowed) => {
8203
+ let urlFiltered = url;
8204
+ for (const key in query) {
8205
+ if (query && Object.keys(query).length > 0) {
8206
+ urlFiltered = urlFiltered.replace(`/${key}/`, `/${query[key]}/`);
8207
+ urlFiltered = urlFiltered.replace(`/${key}`, `/${query[key]}`);
8208
+ if (filtersAllowed && filtersAllowed.includes(key)) {
8209
+ if (urlFiltered.includes("?")) {
8210
+ if (key === "searchNew") {
8211
+ urlFiltered = urlFiltered + `&${key}=${atob(query[key])}`;
8212
+ } else {
8213
+ urlFiltered = urlFiltered + `&${key}=${query[key]}`;
8214
+ }
8215
+ } else {
8216
+ if (key === "searchNew") {
8217
+ urlFiltered = urlFiltered + `?${key}=${atob(query[key])}`;
8218
+ } else {
8219
+ urlFiltered = urlFiltered + `?${key}=${query[key]}`;
8220
+ }
8221
+ }
8222
+ }
8223
+ }
8224
+ }
8225
+ return urlFiltered;
8226
+ };
8227
+
8228
+ // src/hooks/use-fetch-client-side/index.tsx
8229
+ var noopLoading = {
8230
+ loadingActions: {
8231
+ setLoading: () => {
8232
+ }
8233
+ }
8234
+ };
8235
+ var AUTH_COOKIE_USER_NAME = "yeverClientUser";
8236
+ async function getCsrfToken2() {
8237
+ const baseURL = process.env.NEXT_PUBLIC_API_URL ?? "";
8238
+ await fetch(`${baseURL}/sanctum/csrf-cookie`, {
8239
+ credentials: "include",
8240
+ headers: {
8241
+ "X-Requested-With": "XMLHttpRequest",
8242
+ Accept: "application/json"
8243
+ }
8244
+ });
8245
+ await new Promise((resolve) => setTimeout(resolve, 100));
8246
+ const token = Cookies__default.default.get("XSRF-TOKEN");
8247
+ if (!token) {
8248
+ throw new Error("Falha ao obter token CSRF");
8249
+ }
8250
+ return token;
8251
+ }
8252
+ function useFetchClientSide({
8253
+ url,
8254
+ method,
8255
+ onSuccess,
8256
+ onError,
8257
+ successMessage,
8258
+ errorMessage,
8259
+ filtersAllowed,
8260
+ filters,
8261
+ isFiltersFromUrl,
8262
+ config,
8263
+ noError = false,
8264
+ useLoading
8265
+ }) {
8266
+ const [errors, setErrors] = React107.useState(
8267
+ null
8268
+ );
8269
+ const [data, setData] = React107.useState(null);
8270
+ const [loading, setLoading] = React107.useState(false);
8271
+ const { loadingActions } = useLoading ? useLoading() : noopLoading;
8272
+ const submit = async (body, customHandlers) => {
8273
+ const { customUrl, customMethod, customSuccessMessage, signal } = customHandlers || {};
8274
+ setLoading(true);
8275
+ loadingActions.setLoading(true);
8276
+ try {
8277
+ const requestMethod = (customMethod || method).toLowerCase();
8278
+ const needsCSRFToken = ["post", "put", "delete"].includes(requestMethod);
8279
+ let csrfToken = Cookies__default.default.get("XSRF-TOKEN");
8280
+ if (needsCSRFToken && !csrfToken) {
8281
+ csrfToken = await getCsrfToken2();
8282
+ }
8283
+ const filtersFromUrl = Object.fromEntries(new URL(window.location.href).searchParams);
8284
+ const urlFiltered = filters || isFiltersFromUrl ? parseParametersIntoUrl(url, filters || filtersFromUrl, filtersAllowed) : url;
8285
+ const configHeaders = { ...config?.headers ?? {} };
8286
+ if (body instanceof FormData) {
8287
+ delete configHeaders["Content-Type"];
8288
+ }
8289
+ const headers = {
8290
+ "X-Requested-With": "XMLHttpRequest",
8291
+ Accept: "application/json",
8292
+ ...configHeaders
8293
+ };
8294
+ if (body && !(body instanceof FormData)) {
8295
+ headers["Content-Type"] = "application/json";
8296
+ }
8297
+ if (csrfToken) {
8298
+ headers["X-XSRF-TOKEN"] = decodeURIComponent(csrfToken);
8299
+ }
8300
+ const response = await apiFetch({
8301
+ url: customUrl || urlFiltered,
8302
+ method: customMethod || method,
8303
+ body,
8304
+ headers,
8305
+ credentials: "include",
8306
+ signal,
8307
+ responseType: config?.responseType
8308
+ });
8309
+ if (!noError && (customSuccessMessage || successMessage)) {
8310
+ sonner.toast.success(customSuccessMessage || successMessage, {
8311
+ duration: 8e3
8312
+ });
8313
+ }
8314
+ setData(response.data);
8315
+ onSuccess?.(response.data);
8316
+ } catch (error) {
8317
+ setData(null);
8318
+ if (error instanceof Error && error.name === "AbortError") {
8319
+ setLoading(false);
8320
+ loadingActions.setLoading(false);
8321
+ return;
8322
+ }
8323
+ if (error && typeof error === "object" && "status" in error && error.status === 419) {
8324
+ try {
8325
+ Cookies__default.default.remove("XSRF-TOKEN");
8326
+ await getCsrfToken2();
8327
+ return submit(body, customHandlers);
8328
+ } catch (retryError) {
8329
+ Cookies__default.default.remove("XSRF-TOKEN");
8330
+ Cookies__default.default.remove(AUTH_COOKIE_USER_NAME);
8331
+ window.location.href = "/login";
8332
+ return;
8333
+ }
8334
+ }
8335
+ const errorData = error && typeof error === "object" && "response" in error ? error.response?.data : null;
8336
+ setErrors(errorData?.errors || null);
8337
+ const message = errorMessage || errorData?.message || (error instanceof Error ? error.message : "") || "";
8338
+ if (!message && config?.responseType === "blob" && errorData) {
8339
+ const blobData = await errorData.text();
8340
+ const parsedError = JSON.parse(blobData);
8341
+ Object.keys(parsedError.errors).forEach((key) => {
8342
+ sonner.toast.error(parsedError.errors[key]);
8343
+ });
8344
+ }
8345
+ const shouldShowGeneralToast = !noError && message && (!errorData?.errors || error && typeof error === "object" && "status" in error && error.status !== 422);
8346
+ if (shouldShowGeneralToast) {
8347
+ sonner.toast.error(message);
8348
+ }
8349
+ switch (error && typeof error === "object" && "status" in error ? error.status : 0) {
8350
+ case 401:
8351
+ Cookies__default.default.remove(AUTH_COOKIE_USER_NAME);
8352
+ window.location.href = "/login";
8353
+ break;
8354
+ case 403:
8355
+ if (!noError) {
8356
+ sonner.toast.error("Voc\xEA n\xE3o tem permiss\xE3o para realizar essa a\xE7\xE3o");
8357
+ }
8358
+ break;
8359
+ case 422:
8360
+ if (!noError && errorData?.errors) {
8361
+ Object.values(errorData.errors).forEach((msg) => sonner.toast.error(String(msg)));
8362
+ }
8363
+ break;
8364
+ case 500:
8365
+ if (!noError) {
8366
+ sonner.toast.error("Identificamos um problema. Nossa equipe j\xE1 foi notificada.");
8367
+ }
8368
+ break;
8369
+ }
8370
+ onError?.(error);
8371
+ } finally {
8372
+ setLoading(false);
8373
+ loadingActions.setLoading(false);
8374
+ }
8375
+ };
8376
+ return {
8377
+ state: { errors, data, loading },
8378
+ operations: {
8379
+ submit,
8380
+ setLoading
8381
+ }
8382
+ };
8383
+ }
8095
8384
  var Dropshiping = (props) => {
8096
8385
  return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: 25, height: 25, viewBox: "0 0 25 25", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
8097
8386
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -9614,33 +9903,6 @@ var shadow = {
9614
9903
  store: "0px 4px 8px 3px rgba(0, 0, 0, 0.04)"
9615
9904
  };
9616
9905
  var shadow_default = shadow;
9617
-
9618
- // src/utils/parse-parameters-into-url/index.tsx
9619
- var parseParametersIntoUrl = (url, query, filtersAllowed) => {
9620
- let urlFiltered = url;
9621
- for (const key in query) {
9622
- if (query && Object.keys(query).length > 0) {
9623
- urlFiltered = urlFiltered.replace(`/${key}/`, `/${query[key]}/`);
9624
- urlFiltered = urlFiltered.replace(`/${key}`, `/${query[key]}`);
9625
- if (filtersAllowed && filtersAllowed.includes(key)) {
9626
- if (urlFiltered.includes("?")) {
9627
- if (key === "searchNew") {
9628
- urlFiltered = urlFiltered + `&${key}=${atob(query[key])}`;
9629
- } else {
9630
- urlFiltered = urlFiltered + `&${key}=${query[key]}`;
9631
- }
9632
- } else {
9633
- if (key === "searchNew") {
9634
- urlFiltered = urlFiltered + `?${key}=${atob(query[key])}`;
9635
- } else {
9636
- urlFiltered = urlFiltered + `?${key}=${query[key]}`;
9637
- }
9638
- }
9639
- }
9640
- }
9641
- }
9642
- return urlFiltered;
9643
- };
9644
9906
  var useCopyToClipboard = (successMessage) => {
9645
9907
  const copyToClipboard = (initialText) => {
9646
9908
  const textArea = document.createElement("textarea");
@@ -9859,5 +10121,6 @@ exports.transformToNumber = transformToNumber;
9859
10121
  exports.transformToPercentage = transformToPercentage;
9860
10122
  exports.truncateString = truncateString;
9861
10123
  exports.useCopyToClipboard = useCopyToClipboard;
10124
+ exports.useFetchClientSide = useFetchClientSide;
9862
10125
  //# sourceMappingURL=index.js.map
9863
10126
  //# sourceMappingURL=index.js.map