@yeverlibs/ds 1.1.28 → 1.1.30

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
@@ -580,10 +580,9 @@ type CounterInputProps$2<T extends FieldValues = FieldValues> = {
580
580
  id?: string
581
581
  defaultValue?: string | number
582
582
  name?: Path<T>
583
- minValue?: number
584
583
  } & React.InputHTMLAttributes<HTMLInputElement>
585
584
 
586
- declare const Counter: <T extends FieldValues = FieldValues>({ label, hasDisabled, redeemablePoints, tooltip, full, type, wrapperClassName, methods, onChange, id, minValue, ...rest }: CounterInputProps$2<T>) => react_jsx_runtime.JSX.Element;
585
+ declare const Counter: <T extends FieldValues = FieldValues>({ label, hasDisabled, redeemablePoints, tooltip, full, type, wrapperClassName, methods, onChange, id, ...rest }: CounterInputProps$2<T>) => react_jsx_runtime.JSX.Element;
587
586
 
588
587
  type CurrencyInputProps<T extends FieldValues = FieldValues> = {
589
588
  label?: string
@@ -663,6 +662,7 @@ declare const FormWrapper: <T extends FieldValues>({ children, onSubmit, default
663
662
 
664
663
  type InputProps$1 = {
665
664
  $charactersLimit?: number
665
+ $showCharactersLimit?: boolean
666
666
  $iconName?: IconName
667
667
  $labelText?: string
668
668
  $iconDirection?: 'left' | 'right'
@@ -718,9 +718,9 @@ type SelectProps = {
718
718
  label?: string
719
719
  placeholder?: string
720
720
  options: SelectOption[]
721
- onSelect: (option: SelectOption) => void
721
+ onSelect: (option: SelectOption | null) => void
722
722
  className?: string
723
- value?: SelectOption
723
+ value?: SelectOption | null
724
724
  tooltip?: string
725
725
  isClearable?: boolean
726
726
  }
@@ -794,10 +794,10 @@ type CounterInputProps$1 = {
794
794
  form: UseFormReturn
795
795
  } & React.InputHTMLAttributes<HTMLInputElement>
796
796
 
797
- declare const TimerCounter: React.FC<CounterInputProps$1>;
798
-
799
797
  declare const formatTime$1: (time: string | number) => string;
800
798
 
799
+ declare const TimerCounter: React.FC<CounterInputProps$1>;
800
+
801
801
  type CounterInputProps = {
802
802
  label?: string
803
803
  tooltip?: string
package/dist/index.d.ts CHANGED
@@ -580,10 +580,9 @@ type CounterInputProps$2<T extends FieldValues = FieldValues> = {
580
580
  id?: string
581
581
  defaultValue?: string | number
582
582
  name?: Path<T>
583
- minValue?: number
584
583
  } & React.InputHTMLAttributes<HTMLInputElement>
585
584
 
586
- declare const Counter: <T extends FieldValues = FieldValues>({ label, hasDisabled, redeemablePoints, tooltip, full, type, wrapperClassName, methods, onChange, id, minValue, ...rest }: CounterInputProps$2<T>) => react_jsx_runtime.JSX.Element;
585
+ declare const Counter: <T extends FieldValues = FieldValues>({ label, hasDisabled, redeemablePoints, tooltip, full, type, wrapperClassName, methods, onChange, id, ...rest }: CounterInputProps$2<T>) => react_jsx_runtime.JSX.Element;
587
586
 
588
587
  type CurrencyInputProps<T extends FieldValues = FieldValues> = {
589
588
  label?: string
@@ -663,6 +662,7 @@ declare const FormWrapper: <T extends FieldValues>({ children, onSubmit, default
663
662
 
664
663
  type InputProps$1 = {
665
664
  $charactersLimit?: number
665
+ $showCharactersLimit?: boolean
666
666
  $iconName?: IconName
667
667
  $labelText?: string
668
668
  $iconDirection?: 'left' | 'right'
@@ -718,9 +718,9 @@ type SelectProps = {
718
718
  label?: string
719
719
  placeholder?: string
720
720
  options: SelectOption[]
721
- onSelect: (option: SelectOption) => void
721
+ onSelect: (option: SelectOption | null) => void
722
722
  className?: string
723
- value?: SelectOption
723
+ value?: SelectOption | null
724
724
  tooltip?: string
725
725
  isClearable?: boolean
726
726
  }
@@ -794,10 +794,10 @@ type CounterInputProps$1 = {
794
794
  form: UseFormReturn
795
795
  } & React.InputHTMLAttributes<HTMLInputElement>
796
796
 
797
- declare const TimerCounter: React.FC<CounterInputProps$1>;
798
-
799
797
  declare const formatTime$1: (time: string | number) => string;
800
798
 
799
+ declare const TimerCounter: React.FC<CounterInputProps$1>;
800
+
801
801
  type CounterInputProps = {
802
802
  label?: string
803
803
  tooltip?: string
package/dist/index.js CHANGED
@@ -8976,6 +8976,7 @@ var Input = React107.forwardRef(
8976
8976
  $errorMessage,
8977
8977
  type = "text",
8978
8978
  $charactersLimit,
8979
+ $showCharactersLimit = true,
8979
8980
  $description,
8980
8981
  isNotProvided = false,
8981
8982
  wrapperClassName,
@@ -9030,7 +9031,7 @@ var Input = React107.forwardRef(
9030
9031
  ]
9031
9032
  }
9032
9033
  ),
9033
- $charactersLimit && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-gray-600", children: [
9034
+ $charactersLimit && $showCharactersLimit && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-gray-600", children: [
9034
9035
  value.length,
9035
9036
  " de ",
9036
9037
  $charactersLimit,
@@ -9050,17 +9051,48 @@ var Input = React107.forwardRef(
9050
9051
  maxLength: $charactersLimit,
9051
9052
  value,
9052
9053
  onChange: (e14) => {
9053
- const inputValue = e14.target.value;
9054
+ let inputValue = e14.target.value;
9055
+ if (type === "number") {
9056
+ inputValue = inputValue.replace(/[^0-9]/g, "");
9057
+ }
9054
9058
  const newValue = $formatValue ? $formatValue(inputValue) : inputValue;
9055
- setValue(newValue);
9059
+ const finalValue = $charactersLimit ? newValue.slice(0, $charactersLimit) : newValue;
9060
+ setValue(finalValue);
9056
9061
  onChange?.({
9057
9062
  ...e14,
9058
9063
  target: {
9059
9064
  ...e14.target,
9060
- value: newValue
9065
+ value: finalValue
9061
9066
  }
9062
9067
  });
9063
9068
  },
9069
+ onKeyDown: (e14) => {
9070
+ if (type === "number") {
9071
+ const allowedKeys = [
9072
+ "Backspace",
9073
+ "Delete",
9074
+ "Tab",
9075
+ "Escape",
9076
+ "Enter",
9077
+ "ArrowLeft",
9078
+ "ArrowRight",
9079
+ "ArrowUp",
9080
+ "ArrowDown",
9081
+ "Home",
9082
+ "End"
9083
+ ];
9084
+ const isAllowedKey = allowedKeys.includes(e14.key);
9085
+ const isNumberKey = /^[0-9]$/.test(e14.key);
9086
+ const isCtrlA = e14.ctrlKey && e14.key === "a";
9087
+ const isCtrlC = e14.ctrlKey && e14.key === "c";
9088
+ const isCtrlV = e14.ctrlKey && e14.key === "v";
9089
+ const isCtrlX = e14.ctrlKey && e14.key === "x";
9090
+ if (!isAllowedKey && !isNumberKey && !isCtrlA && !isCtrlC && !isCtrlV && !isCtrlX) {
9091
+ e14.preventDefault();
9092
+ }
9093
+ }
9094
+ rest.onKeyDown?.(e14);
9095
+ },
9064
9096
  $inputClassName,
9065
9097
  ...rest
9066
9098
  }
@@ -9081,18 +9113,49 @@ var Input = React107.forwardRef(
9081
9113
  maxLength: $charactersLimit,
9082
9114
  value: field.value || "",
9083
9115
  onChange: (e14) => {
9084
- const inputValue = e14.target.value;
9116
+ let inputValue = e14.target.value;
9117
+ if (type === "number") {
9118
+ inputValue = inputValue.replace(/[^0-9]/g, "");
9119
+ }
9085
9120
  const newValue = $formatValue ? $formatValue(inputValue) : inputValue;
9086
- setValue(newValue);
9087
- field.onChange(newValue);
9121
+ const finalValue = $charactersLimit ? newValue.slice(0, $charactersLimit) : newValue;
9122
+ setValue(finalValue);
9123
+ field.onChange(finalValue);
9088
9124
  onChange?.({
9089
9125
  ...e14,
9090
9126
  target: {
9091
9127
  ...e14.target,
9092
- value: newValue
9128
+ value: finalValue
9093
9129
  }
9094
9130
  });
9095
9131
  },
9132
+ onKeyDown: (e14) => {
9133
+ if (type === "number") {
9134
+ const allowedKeys = [
9135
+ "Backspace",
9136
+ "Delete",
9137
+ "Tab",
9138
+ "Escape",
9139
+ "Enter",
9140
+ "ArrowLeft",
9141
+ "ArrowRight",
9142
+ "ArrowUp",
9143
+ "ArrowDown",
9144
+ "Home",
9145
+ "End"
9146
+ ];
9147
+ const isAllowedKey = allowedKeys.includes(e14.key);
9148
+ const isNumberKey = /^[0-9]$/.test(e14.key);
9149
+ const isCtrlA = e14.ctrlKey && e14.key === "a";
9150
+ const isCtrlC = e14.ctrlKey && e14.key === "c";
9151
+ const isCtrlV = e14.ctrlKey && e14.key === "v";
9152
+ const isCtrlX = e14.ctrlKey && e14.key === "x";
9153
+ if (!isAllowedKey && !isNumberKey && !isCtrlA && !isCtrlC && !isCtrlV && !isCtrlX) {
9154
+ e14.preventDefault();
9155
+ }
9156
+ }
9157
+ rest.onKeyDown?.(e14);
9158
+ },
9096
9159
  $inputClassName,
9097
9160
  ...rest
9098
9161
  }
@@ -11257,27 +11320,24 @@ var Counter = ({
11257
11320
  methods,
11258
11321
  onChange,
11259
11322
  id,
11260
- minValue = 0,
11261
11323
  ...rest
11262
11324
  }) => {
11263
11325
  const form = reactHookForm.useForm();
11264
11326
  const { setValue, getValues, control } = methods || form;
11265
11327
  const fieldName = rest.name || "counter";
11266
- const defaultValue = rest.defaultValue ? Math.max(Number(rest.defaultValue), minValue) : minValue;
11328
+ const defaultValue = rest.defaultValue ? Number(rest.defaultValue) : 0;
11267
11329
  const handleIncrement = () => {
11268
11330
  if (!hasDisabled) {
11269
- const currentValue = getValues(fieldName);
11270
- const numericValue = currentValue !== void 0 && currentValue !== null ? Number(currentValue) : minValue;
11271
- const newValue = Math.max(numericValue, minValue) + 1;
11331
+ const currentValue = getValues(fieldName) || 0;
11332
+ const newValue = Number(currentValue) + 1;
11272
11333
  setValue(fieldName, newValue);
11273
11334
  onChange?.(newValue);
11274
11335
  }
11275
11336
  };
11276
11337
  const handleDecrement = () => {
11277
11338
  if (!hasDisabled) {
11278
- const currentValue = getValues(fieldName);
11279
- const numericValue = currentValue !== void 0 && currentValue !== null ? Number(currentValue) : minValue;
11280
- const newValue = Math.max(numericValue, minValue) > minValue ? Math.max(numericValue, minValue) - 1 : minValue;
11339
+ const currentValue = getValues(fieldName) || 0;
11340
+ const newValue = Number(currentValue) > 0 ? Number(currentValue) - 1 : 0;
11281
11341
  setValue(fieldName, newValue);
11282
11342
  onChange?.(newValue);
11283
11343
  }
@@ -11325,11 +11385,11 @@ var Counter = ({
11325
11385
  ...fieldWithoutDefaultValue,
11326
11386
  id: fieldName,
11327
11387
  type: "number",
11328
- min: minValue,
11329
- value: field.value !== void 0 && field.value !== null ? Math.max(Number(field.value), minValue) : minValue,
11388
+ min: 1,
11389
+ value: field.value || 1,
11330
11390
  onChange: (e14) => {
11331
11391
  const newValue = Number(e14.target.value);
11332
- if (newValue >= minValue) {
11392
+ if (newValue >= 0) {
11333
11393
  field.onChange(newValue);
11334
11394
  onChange?.(newValue);
11335
11395
  }
@@ -11688,9 +11748,7 @@ var CustomSelect = ({
11688
11748
  isClearable = true
11689
11749
  }) => {
11690
11750
  const handleChange = (option) => {
11691
- if (option) {
11692
- onSelect(option);
11693
- }
11751
+ onSelect(option);
11694
11752
  };
11695
11753
  const formatOptionLabel = (option) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
11696
11754
  option.icon && /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(Image3__default.default, { src: option.icon, alt: option.label, fill: true, className: "p-1", quality: 100 }) }),
@@ -12023,6 +12081,8 @@ var TimeInput = ({
12023
12081
  ] })
12024
12082
  ] });
12025
12083
  };
12084
+
12085
+ // src/_design-system/helpers/formatTime.ts
12026
12086
  var formatTime = (time2) => {
12027
12087
  let timeInSeconds = 0;
12028
12088
  if (typeof time2 === "string") {
@@ -12171,26 +12231,7 @@ var TimerCounter = ({
12171
12231
  description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-gray-700", children: description })
12172
12232
  ] });
12173
12233
  };
12174
-
12175
- // src/_design-system/helpers/formatTime.ts
12176
12234
  var formatTime2 = (time2) => {
12177
- let timeInSeconds = 0;
12178
- if (typeof time2 === "string") {
12179
- if (time2.includes(":")) {
12180
- const [hours3, minutes3, seconds4] = time2.split(":").map(Number);
12181
- timeInSeconds = hours3 * 3600 + minutes3 * 60 + seconds4;
12182
- } else {
12183
- timeInSeconds = parseInt(time2, 10) || 0;
12184
- }
12185
- } else {
12186
- timeInSeconds = time2 || 0;
12187
- }
12188
- const hours2 = Math.floor(timeInSeconds / 3600);
12189
- const minutes2 = Math.floor(timeInSeconds % 3600 / 60);
12190
- const seconds3 = timeInSeconds % 60;
12191
- return `${hours2.toString().padStart(2, "0")}:${minutes2.toString().padStart(2, "0")}:${seconds3.toString().padStart(2, "0")}`;
12192
- };
12193
- var formatTime3 = (time2) => {
12194
12235
  let timeInSeconds = 0;
12195
12236
  if (typeof time2 === "string") {
12196
12237
  if (time2.includes(":")) {
@@ -12220,7 +12261,7 @@ var TimerCounterWithoutSeconds = ({
12220
12261
  const fieldName = rest.name || "timer";
12221
12262
  const { control, setValue, watch } = form;
12222
12263
  const rawValue = watch(fieldName, defaultValue || "00:00");
12223
- const displayValue = typeof rawValue === "number" ? formatTime3(rawValue) : rawValue || "00:00";
12264
+ const displayValue = typeof rawValue === "number" ? formatTime2(rawValue) : rawValue || "00:00";
12224
12265
  const parseTime = (timeString) => {
12225
12266
  if (!timeString) return 0;
12226
12267
  const [hours2, minutes2] = timeString.split(":").map(Number);
@@ -12234,7 +12275,7 @@ var TimerCounterWithoutSeconds = ({
12234
12275
  setValue(fieldName, "00:00", { shouldValidate: true, shouldDirty: true, shouldTouch: true });
12235
12276
  return;
12236
12277
  }
12237
- setValue(fieldName, formatTime3(newSeconds), { shouldValidate: true, shouldDirty: true, shouldTouch: true });
12278
+ setValue(fieldName, formatTime2(newSeconds), { shouldValidate: true, shouldDirty: true, shouldTouch: true });
12238
12279
  }
12239
12280
  };
12240
12281
  const handleDecrement = () => {
@@ -12242,7 +12283,7 @@ var TimerCounterWithoutSeconds = ({
12242
12283
  const currentSeconds = parseTime(displayValue);
12243
12284
  if (currentSeconds <= 0) return;
12244
12285
  const newSeconds = Math.max(0, currentSeconds - 3600);
12245
- setValue(fieldName, formatTime3(newSeconds), { shouldValidate: true, shouldDirty: true, shouldTouch: true });
12286
+ setValue(fieldName, formatTime2(newSeconds), { shouldValidate: true, shouldDirty: true, shouldTouch: true });
12246
12287
  }
12247
12288
  };
12248
12289
  const handleChanges = (e14) => {
@@ -12374,8 +12415,8 @@ function FileUploadComponent({
12374
12415
  const isImagePreview = React107.useCallback((preview) => {
12375
12416
  if (!preview || typeof preview !== "string") return false;
12376
12417
  if (preview.startsWith("data:image/")) return true;
12377
- if (preview.startsWith("http") && preview.match(/\.(jpg|jpeg|png|gif|webp|svg|avif|bmp|tiff)/i)) return true;
12378
- if (preview.match(/\.(jpg|jpeg|png|gif|webp|svg|avif|bmp|tiff)$/i)) return true;
12418
+ if (preview.startsWith("http") && preview.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp|tiff)/i)) return true;
12419
+ if (preview.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp|tiff)$/i)) return true;
12379
12420
  return false;
12380
12421
  }, []);
12381
12422
  React107.useEffect(() => {
@@ -26746,8 +26787,8 @@ exports.formatNumberToCurrency = formatNumberToCurrency;
26746
26787
  exports.formatPhone = formatPhone;
26747
26788
  exports.formatPostalCode = formatPostalCode;
26748
26789
  exports.formatRawDigitsToCurrency = formatRawDigitsToCurrency;
26749
- exports.formatTime = formatTime2;
26750
- exports.formatTimeWithoutSeconds = formatTime3;
26790
+ exports.formatTime = formatTime;
26791
+ exports.formatTimeWithoutSeconds = formatTime2;
26751
26792
  exports.getDates = getDates;
26752
26793
  exports.handleFormSubmission = handleFormSubmission;
26753
26794
  exports.iconList = iconList;