@yeverlibs/ds 1.1.27 → 1.1.29

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.mjs CHANGED
@@ -9020,17 +9020,48 @@ var Input = forwardRef(
9020
9020
  maxLength: $charactersLimit,
9021
9021
  value,
9022
9022
  onChange: (e14) => {
9023
- const inputValue = e14.target.value;
9023
+ let inputValue = e14.target.value;
9024
+ if (type === "number") {
9025
+ inputValue = inputValue.replace(/[^0-9]/g, "");
9026
+ }
9024
9027
  const newValue = $formatValue ? $formatValue(inputValue) : inputValue;
9025
- setValue(newValue);
9028
+ const finalValue = $charactersLimit ? newValue.slice(0, $charactersLimit) : newValue;
9029
+ setValue(finalValue);
9026
9030
  onChange?.({
9027
9031
  ...e14,
9028
9032
  target: {
9029
9033
  ...e14.target,
9030
- value: newValue
9034
+ value: finalValue
9031
9035
  }
9032
9036
  });
9033
9037
  },
9038
+ onKeyDown: (e14) => {
9039
+ if (type === "number") {
9040
+ const allowedKeys = [
9041
+ "Backspace",
9042
+ "Delete",
9043
+ "Tab",
9044
+ "Escape",
9045
+ "Enter",
9046
+ "ArrowLeft",
9047
+ "ArrowRight",
9048
+ "ArrowUp",
9049
+ "ArrowDown",
9050
+ "Home",
9051
+ "End"
9052
+ ];
9053
+ const isAllowedKey = allowedKeys.includes(e14.key);
9054
+ const isNumberKey = /^[0-9]$/.test(e14.key);
9055
+ const isCtrlA = e14.ctrlKey && e14.key === "a";
9056
+ const isCtrlC = e14.ctrlKey && e14.key === "c";
9057
+ const isCtrlV = e14.ctrlKey && e14.key === "v";
9058
+ const isCtrlX = e14.ctrlKey && e14.key === "x";
9059
+ if (!isAllowedKey && !isNumberKey && !isCtrlA && !isCtrlC && !isCtrlV && !isCtrlX) {
9060
+ e14.preventDefault();
9061
+ }
9062
+ }
9063
+ rest.onKeyDown?.(e14);
9064
+ },
9034
9065
  $inputClassName,
9035
9066
  ...rest
9036
9067
  }
@@ -9051,18 +9082,49 @@ var Input = forwardRef(
9051
9082
  maxLength: $charactersLimit,
9052
9083
  value: field.value || "",
9053
9084
  onChange: (e14) => {
9054
- const inputValue = e14.target.value;
9085
+ let inputValue = e14.target.value;
9086
+ if (type === "number") {
9087
+ inputValue = inputValue.replace(/[^0-9]/g, "");
9088
+ }
9055
9089
  const newValue = $formatValue ? $formatValue(inputValue) : inputValue;
9056
- setValue(newValue);
9057
- field.onChange(newValue);
9090
+ const finalValue = $charactersLimit ? newValue.slice(0, $charactersLimit) : newValue;
9091
+ setValue(finalValue);
9092
+ field.onChange(finalValue);
9058
9093
  onChange?.({
9059
9094
  ...e14,
9060
9095
  target: {
9061
9096
  ...e14.target,
9062
- value: newValue
9097
+ value: finalValue
9063
9098
  }
9064
9099
  });
9065
9100
  },
9101
+ onKeyDown: (e14) => {
9102
+ if (type === "number") {
9103
+ const allowedKeys = [
9104
+ "Backspace",
9105
+ "Delete",
9106
+ "Tab",
9107
+ "Escape",
9108
+ "Enter",
9109
+ "ArrowLeft",
9110
+ "ArrowRight",
9111
+ "ArrowUp",
9112
+ "ArrowDown",
9113
+ "Home",
9114
+ "End"
9115
+ ];
9116
+ const isAllowedKey = allowedKeys.includes(e14.key);
9117
+ const isNumberKey = /^[0-9]$/.test(e14.key);
9118
+ const isCtrlA = e14.ctrlKey && e14.key === "a";
9119
+ const isCtrlC = e14.ctrlKey && e14.key === "c";
9120
+ const isCtrlV = e14.ctrlKey && e14.key === "v";
9121
+ const isCtrlX = e14.ctrlKey && e14.key === "x";
9122
+ if (!isAllowedKey && !isNumberKey && !isCtrlA && !isCtrlC && !isCtrlV && !isCtrlX) {
9123
+ e14.preventDefault();
9124
+ }
9125
+ }
9126
+ rest.onKeyDown?.(e14);
9127
+ },
9066
9128
  $inputClassName,
9067
9129
  ...rest
9068
9130
  }
@@ -11227,24 +11289,27 @@ var Counter = ({
11227
11289
  methods,
11228
11290
  onChange,
11229
11291
  id,
11292
+ minValue = 0,
11230
11293
  ...rest
11231
11294
  }) => {
11232
11295
  const form = useForm();
11233
11296
  const { setValue, getValues, control } = methods || form;
11234
11297
  const fieldName = rest.name || "counter";
11235
- const defaultValue = rest.defaultValue ? Number(rest.defaultValue) : 0;
11298
+ const defaultValue = rest.defaultValue ? Math.max(Number(rest.defaultValue), minValue) : minValue;
11236
11299
  const handleIncrement = () => {
11237
11300
  if (!hasDisabled) {
11238
- const currentValue = getValues(fieldName) || 0;
11239
- const newValue = Number(currentValue) + 1;
11301
+ const currentValue = getValues(fieldName);
11302
+ const numericValue = currentValue !== void 0 && currentValue !== null ? Number(currentValue) : minValue;
11303
+ const newValue = Math.max(numericValue, minValue) + 1;
11240
11304
  setValue(fieldName, newValue);
11241
11305
  onChange?.(newValue);
11242
11306
  }
11243
11307
  };
11244
11308
  const handleDecrement = () => {
11245
11309
  if (!hasDisabled) {
11246
- const currentValue = getValues(fieldName) || 0;
11247
- const newValue = Number(currentValue) > 0 ? Number(currentValue) - 1 : 0;
11310
+ const currentValue = getValues(fieldName);
11311
+ const numericValue = currentValue !== void 0 && currentValue !== null ? Number(currentValue) : minValue;
11312
+ const newValue = Math.max(numericValue, minValue) > minValue ? Math.max(numericValue, minValue) - 1 : minValue;
11248
11313
  setValue(fieldName, newValue);
11249
11314
  onChange?.(newValue);
11250
11315
  }
@@ -11292,11 +11357,11 @@ var Counter = ({
11292
11357
  ...fieldWithoutDefaultValue,
11293
11358
  id: fieldName,
11294
11359
  type: "number",
11295
- min: 1,
11296
- value: field.value || 1,
11360
+ min: minValue,
11361
+ value: field.value !== void 0 && field.value !== null ? Math.max(Number(field.value), minValue) : minValue,
11297
11362
  onChange: (e14) => {
11298
11363
  const newValue = Number(e14.target.value);
11299
- if (newValue >= 0) {
11364
+ if (newValue >= minValue) {
11300
11365
  field.onChange(newValue);
11301
11366
  onChange?.(newValue);
11302
11367
  }
@@ -11655,7 +11720,9 @@ var CustomSelect = ({
11655
11720
  isClearable = true
11656
11721
  }) => {
11657
11722
  const handleChange = (option) => {
11658
- onSelect(option);
11723
+ if (option) {
11724
+ onSelect(option);
11725
+ }
11659
11726
  };
11660
11727
  const formatOptionLabel = (option) => /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
11661
11728
  option.icon && /* @__PURE__ */ jsx("div", { className: "relative mr-2 flex h-[24px] max-h-[24px] w-[24px] max-w-[24px] items-center justify-center rounded border border-gray-300", children: /* @__PURE__ */ jsx(Image3, { src: option.icon, alt: option.label, fill: true, className: "p-1", quality: 100 }) }),
@@ -11988,8 +12055,6 @@ var TimeInput = ({
11988
12055
  ] })
11989
12056
  ] });
11990
12057
  };
11991
-
11992
- // src/_design-system/helpers/formatTime.ts
11993
12058
  var formatTime = (time2) => {
11994
12059
  let timeInSeconds = 0;
11995
12060
  if (typeof time2 === "string") {
@@ -12138,7 +12203,26 @@ var TimerCounter = ({
12138
12203
  description && /* @__PURE__ */ jsx("span", { className: "text-xs text-gray-700", children: description })
12139
12204
  ] });
12140
12205
  };
12206
+
12207
+ // src/_design-system/helpers/formatTime.ts
12141
12208
  var formatTime2 = (time2) => {
12209
+ let timeInSeconds = 0;
12210
+ if (typeof time2 === "string") {
12211
+ if (time2.includes(":")) {
12212
+ const [hours3, minutes3, seconds4] = time2.split(":").map(Number);
12213
+ timeInSeconds = hours3 * 3600 + minutes3 * 60 + seconds4;
12214
+ } else {
12215
+ timeInSeconds = parseInt(time2, 10) || 0;
12216
+ }
12217
+ } else {
12218
+ timeInSeconds = time2 || 0;
12219
+ }
12220
+ const hours2 = Math.floor(timeInSeconds / 3600);
12221
+ const minutes2 = Math.floor(timeInSeconds % 3600 / 60);
12222
+ const seconds3 = timeInSeconds % 60;
12223
+ return `${hours2.toString().padStart(2, "0")}:${minutes2.toString().padStart(2, "0")}:${seconds3.toString().padStart(2, "0")}`;
12224
+ };
12225
+ var formatTime3 = (time2) => {
12142
12226
  let timeInSeconds = 0;
12143
12227
  if (typeof time2 === "string") {
12144
12228
  if (time2.includes(":")) {
@@ -12168,7 +12252,7 @@ var TimerCounterWithoutSeconds = ({
12168
12252
  const fieldName = rest.name || "timer";
12169
12253
  const { control, setValue, watch } = form;
12170
12254
  const rawValue = watch(fieldName, defaultValue || "00:00");
12171
- const displayValue = typeof rawValue === "number" ? formatTime2(rawValue) : rawValue || "00:00";
12255
+ const displayValue = typeof rawValue === "number" ? formatTime3(rawValue) : rawValue || "00:00";
12172
12256
  const parseTime = (timeString) => {
12173
12257
  if (!timeString) return 0;
12174
12258
  const [hours2, minutes2] = timeString.split(":").map(Number);
@@ -12182,7 +12266,7 @@ var TimerCounterWithoutSeconds = ({
12182
12266
  setValue(fieldName, "00:00", { shouldValidate: true, shouldDirty: true, shouldTouch: true });
12183
12267
  return;
12184
12268
  }
12185
- setValue(fieldName, formatTime2(newSeconds), { shouldValidate: true, shouldDirty: true, shouldTouch: true });
12269
+ setValue(fieldName, formatTime3(newSeconds), { shouldValidate: true, shouldDirty: true, shouldTouch: true });
12186
12270
  }
12187
12271
  };
12188
12272
  const handleDecrement = () => {
@@ -12190,7 +12274,7 @@ var TimerCounterWithoutSeconds = ({
12190
12274
  const currentSeconds = parseTime(displayValue);
12191
12275
  if (currentSeconds <= 0) return;
12192
12276
  const newSeconds = Math.max(0, currentSeconds - 3600);
12193
- setValue(fieldName, formatTime2(newSeconds), { shouldValidate: true, shouldDirty: true, shouldTouch: true });
12277
+ setValue(fieldName, formatTime3(newSeconds), { shouldValidate: true, shouldDirty: true, shouldTouch: true });
12194
12278
  }
12195
12279
  };
12196
12280
  const handleChanges = (e14) => {
@@ -12322,8 +12406,8 @@ function FileUploadComponent({
12322
12406
  const isImagePreview = useCallback((preview) => {
12323
12407
  if (!preview || typeof preview !== "string") return false;
12324
12408
  if (preview.startsWith("data:image/")) return true;
12325
- if (preview.startsWith("http") && preview.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp|tiff)/i)) return true;
12326
- if (preview.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp|tiff)$/i)) return true;
12409
+ if (preview.startsWith("http") && preview.match(/\.(jpg|jpeg|png|gif|webp|svg|avif|bmp|tiff)/i)) return true;
12410
+ if (preview.match(/\.(jpg|jpeg|png|gif|webp|svg|avif|bmp|tiff)$/i)) return true;
12327
12411
  return false;
12328
12412
  }, []);
12329
12413
  useEffect(() => {
@@ -26503,6 +26587,6 @@ object-assign/index.js:
26503
26587
  *)
26504
26588
  */
26505
26589
 
26506
- export { Alert, AlertDefault_default as AlertDefault, AlertError_default as AlertError, AlertGuard_default as AlertGuard, AlertInfo_default as AlertInfo, AlertWarning_default as AlertWarning, Api_default as Api, ArrowLeft_default as ArrowLeft, ArrowNarrowUpRight_default as ArrowNarrowUpRight, Avatar, BarChart, Boleto_default as Boleto, Box, Button, button_toggle_group_default as ButtonToggleGroup, CSV_default as CSV, Calendar_default as Calendar, Card_default as Card, CarrFree_default as CarrFree, CarretDown_default as CarretDown, CarretSingleRight_default as CarretSingleRight, CarrinhoAbandonado_default as CarrinhoAbandonado, Cart_default as Cart, Chargeback_default as Chargeback, Check_default as Check, Checkbox, checkbox_group_default as CheckboxGroup, Checkout_default as Checkout, ChevronDown_default as ChevronDown, ChevronLeftDouble_default as ChevronLeftDouble, CloseCheckbox_default as CloseCheckbox, CloseIcon_default as CloseIcon, Cloud_default as Cloud, CodeCircle_default as CodeCircle, Configuracoes_default as Configuracoes, Copy_default as Copy, CopyLink_default as CopyLink, Counter, CreditCard_default as CreditCard, Cupom_default as Cupom, CurrencyInput, CustomSelect, Dashboard_default as Dashboard, datapicker_default as DatePicker, Delivery_default as Delivery, Depoimentos_default as Depoimentos, Distribuicao_default as Distribuicao, Distribution_default as Distribution, Dominios_default as Dominios, DownloadArrow_default as DownloadArrow, Drag_default as Drag, DropdownContext, DropdownItens, DropdownTrigger, DrowpdownButton, Edit_default as Edit, Emails_default as Emails, Extrato_default as Extrato, EyeInput_default as EyeInput, EyeOff_default as EyeOff, FeedbackBadge, FileMinus_default as FileMinus, FileUploadWithDisplayName as FileUpload, FilterDrawer, FilterLines_default as FilterLines, FilterList, FilterListContext, FilterTrigger, Financeiro_default as Financeiro, FormWrapper, Frete_default as Frete, FreteGratis_default as FreteGratis, GeneralPageLinks, Gestao_default as Gestao, Globe_default as Globe, GlobeVariant_default as GlobeVariant, Grid, GridColumn, Guard_default as Guard, Heading, Headphones_default as Headphones, Help_default as Help, HelpCircle_default as HelpCircle, Home_default as Home, InfoCircle_default as InfoCircle, Input, Integracoes_default as Integracoes, LineChart, Link4 as Link, Link_default as LinkIcon, LoadingSpinner_default as LoadingSpinner, Lock_default as Lock, LockInput_default as LockInput, Logistica_default as Logistica, Loja_default as Loja, LojaAlert_default as LojaAlert, LojaAlertSuccess_default as LojaAlertSuccess, Mail_default as Mail, MailInput_default as MailInput, MarkerPin_default as MarkerPin, Marketing_default as Marketing, MediumRisk_default as MediumRisk, Message_default as Message, Modal, Money_default as Money, MultiSelect, icones_default as NewIcons, NewMessage_default as NewMessage, NewNotification_default as NewNotification, Notificacoes_default as Notificacoes, Notification_default as Notification, NotificationItem, Notifications_default as Notifications, OrderBump_default as OrderBump, PageContainer, PaymentCard, PermissaoDeAcesso_default as PermissaoDeAcesso, PhoneCall_default as PhoneCall, PieChart, Pix_default as Pix, Pixels_default as Pixels, Planilha_default as Planilha, Plus_default as Plus, Prechargeback_default as Prechargeback, PrefetchLink, PreviewPhone, PriceSkeleton, Produto_default as Produto, Produtos_default as Produtos, Promocoes_default as Promocoes, RecuperacaoDeCarrinho_default as RecuperacaoDeCarrinho, Refresh_default as Refresh, Relatorios_default as Relatorios, RestricaoDeAcesso_default as RestricaoDeAcesso, Ribbon, Risco_default as Risco, Sac_default as Sac, SearchMd_default as SearchMd, SelectableOption, Separator, Signout_default as Signout, SliderInput, SlidingPanel, Spinner2 as Spinner, Spinner_default as SpinnerIcon, StatusBadge, Store_default as Store, Switch2 as Switch, Switch_default as SwitchIcon, Table, Tabs, Text, Textarea, TimeInput, TimerCounter, TimerCounterWithoutSeconds, Tooltip, Transfer_default as Transfer, Trash_default as Trash, Truck_default as Truck, Upsell_default as Upsell, User_default as User, Users_default as Users, VerticalPoints_default as VerticalPoints, Warning_default as Warning, Webhook_default2 as Webhook, Webhook_default as WebhookConfig, Whatsapp_default as Whatsapp, Xlsx_default as Xlsx, Yever_default as Yever, calculateCurrencyOperation, cn, colors_default2 as colors, font_family_default as fontFamily, formatCNPJ, formatCNPJCPF, formatCPF, formatCurrency, formatCurrencyShort, formatDate, formatDateAndReturnPassedHours, formatDateGeneric, formatDateInPassedDays, formatDateTime, formatDateToISO, formatIP, formatName, formatNumberToCurrency, formatPhone, formatPostalCode, formatRawDigitsToCurrency, formatTime, formatTime2 as formatTimeWithoutSeconds, getDates, handleFormSubmission, iconList, nextReplaceUrl, parseFormattedCurrency, parseParametersIntoUrl, searchParamsToUrl, shadow_default as shadow, transformDateToAmericanFormat, transformToCurrency, transformToNumber, transformToPercentage, truncateString, useCopyToClipboard, useFetchClientSide };
26590
+ export { Alert, AlertDefault_default as AlertDefault, AlertError_default as AlertError, AlertGuard_default as AlertGuard, AlertInfo_default as AlertInfo, AlertWarning_default as AlertWarning, Api_default as Api, ArrowLeft_default as ArrowLeft, ArrowNarrowUpRight_default as ArrowNarrowUpRight, Avatar, BarChart, Boleto_default as Boleto, Box, Button, button_toggle_group_default as ButtonToggleGroup, CSV_default as CSV, Calendar_default as Calendar, Card_default as Card, CarrFree_default as CarrFree, CarretDown_default as CarretDown, CarretSingleRight_default as CarretSingleRight, CarrinhoAbandonado_default as CarrinhoAbandonado, Cart_default as Cart, Chargeback_default as Chargeback, Check_default as Check, Checkbox, checkbox_group_default as CheckboxGroup, Checkout_default as Checkout, ChevronDown_default as ChevronDown, ChevronLeftDouble_default as ChevronLeftDouble, CloseCheckbox_default as CloseCheckbox, CloseIcon_default as CloseIcon, Cloud_default as Cloud, CodeCircle_default as CodeCircle, Configuracoes_default as Configuracoes, Copy_default as Copy, CopyLink_default as CopyLink, Counter, CreditCard_default as CreditCard, Cupom_default as Cupom, CurrencyInput, CustomSelect, Dashboard_default as Dashboard, datapicker_default as DatePicker, Delivery_default as Delivery, Depoimentos_default as Depoimentos, Distribuicao_default as Distribuicao, Distribution_default as Distribution, Dominios_default as Dominios, DownloadArrow_default as DownloadArrow, Drag_default as Drag, DropdownContext, DropdownItens, DropdownTrigger, DrowpdownButton, Edit_default as Edit, Emails_default as Emails, Extrato_default as Extrato, EyeInput_default as EyeInput, EyeOff_default as EyeOff, FeedbackBadge, FileMinus_default as FileMinus, FileUploadWithDisplayName as FileUpload, FilterDrawer, FilterLines_default as FilterLines, FilterList, FilterListContext, FilterTrigger, Financeiro_default as Financeiro, FormWrapper, Frete_default as Frete, FreteGratis_default as FreteGratis, GeneralPageLinks, Gestao_default as Gestao, Globe_default as Globe, GlobeVariant_default as GlobeVariant, Grid, GridColumn, Guard_default as Guard, Heading, Headphones_default as Headphones, Help_default as Help, HelpCircle_default as HelpCircle, Home_default as Home, InfoCircle_default as InfoCircle, Input, Integracoes_default as Integracoes, LineChart, Link4 as Link, Link_default as LinkIcon, LoadingSpinner_default as LoadingSpinner, Lock_default as Lock, LockInput_default as LockInput, Logistica_default as Logistica, Loja_default as Loja, LojaAlert_default as LojaAlert, LojaAlertSuccess_default as LojaAlertSuccess, Mail_default as Mail, MailInput_default as MailInput, MarkerPin_default as MarkerPin, Marketing_default as Marketing, MediumRisk_default as MediumRisk, Message_default as Message, Modal, Money_default as Money, MultiSelect, icones_default as NewIcons, NewMessage_default as NewMessage, NewNotification_default as NewNotification, Notificacoes_default as Notificacoes, Notification_default as Notification, NotificationItem, Notifications_default as Notifications, OrderBump_default as OrderBump, PageContainer, PaymentCard, PermissaoDeAcesso_default as PermissaoDeAcesso, PhoneCall_default as PhoneCall, PieChart, Pix_default as Pix, Pixels_default as Pixels, Planilha_default as Planilha, Plus_default as Plus, Prechargeback_default as Prechargeback, PrefetchLink, PreviewPhone, PriceSkeleton, Produto_default as Produto, Produtos_default as Produtos, Promocoes_default as Promocoes, RecuperacaoDeCarrinho_default as RecuperacaoDeCarrinho, Refresh_default as Refresh, Relatorios_default as Relatorios, RestricaoDeAcesso_default as RestricaoDeAcesso, Ribbon, Risco_default as Risco, Sac_default as Sac, SearchMd_default as SearchMd, SelectableOption, Separator, Signout_default as Signout, SliderInput, SlidingPanel, Spinner2 as Spinner, Spinner_default as SpinnerIcon, StatusBadge, Store_default as Store, Switch2 as Switch, Switch_default as SwitchIcon, Table, Tabs, Text, Textarea, TimeInput, TimerCounter, TimerCounterWithoutSeconds, Tooltip, Transfer_default as Transfer, Trash_default as Trash, Truck_default as Truck, Upsell_default as Upsell, User_default as User, Users_default as Users, VerticalPoints_default as VerticalPoints, Warning_default as Warning, Webhook_default2 as Webhook, Webhook_default as WebhookConfig, Whatsapp_default as Whatsapp, Xlsx_default as Xlsx, Yever_default as Yever, calculateCurrencyOperation, cn, colors_default2 as colors, font_family_default as fontFamily, formatCNPJ, formatCNPJCPF, formatCPF, formatCurrency, formatCurrencyShort, formatDate, formatDateAndReturnPassedHours, formatDateGeneric, formatDateInPassedDays, formatDateTime, formatDateToISO, formatIP, formatName, formatNumberToCurrency, formatPhone, formatPostalCode, formatRawDigitsToCurrency, formatTime2 as formatTime, formatTime3 as formatTimeWithoutSeconds, getDates, handleFormSubmission, iconList, nextReplaceUrl, parseFormattedCurrency, parseParametersIntoUrl, searchParamsToUrl, shadow_default as shadow, transformDateToAmericanFormat, transformToCurrency, transformToNumber, transformToPercentage, truncateString, useCopyToClipboard, useFetchClientSide };
26507
26591
  //# sourceMappingURL=index.mjs.map
26508
26592
  //# sourceMappingURL=index.mjs.map