@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.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +109 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -580,9 +580,10 @@ type CounterInputProps$2<T extends FieldValues = FieldValues> = {
|
|
|
580
580
|
id?: string
|
|
581
581
|
defaultValue?: string | number
|
|
582
582
|
name?: Path<T>
|
|
583
|
+
minValue?: number
|
|
583
584
|
} & React.InputHTMLAttributes<HTMLInputElement>
|
|
584
585
|
|
|
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;
|
|
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;
|
|
586
587
|
|
|
587
588
|
type CurrencyInputProps<T extends FieldValues = FieldValues> = {
|
|
588
589
|
label?: string
|
|
@@ -717,9 +718,9 @@ type SelectProps = {
|
|
|
717
718
|
label?: string
|
|
718
719
|
placeholder?: string
|
|
719
720
|
options: SelectOption[]
|
|
720
|
-
onSelect: (option: SelectOption
|
|
721
|
+
onSelect: (option: SelectOption) => void
|
|
721
722
|
className?: string
|
|
722
|
-
value?: SelectOption
|
|
723
|
+
value?: SelectOption
|
|
723
724
|
tooltip?: string
|
|
724
725
|
isClearable?: boolean
|
|
725
726
|
}
|
|
@@ -793,10 +794,10 @@ type CounterInputProps$1 = {
|
|
|
793
794
|
form: UseFormReturn
|
|
794
795
|
} & React.InputHTMLAttributes<HTMLInputElement>
|
|
795
796
|
|
|
796
|
-
declare const formatTime$1: (time: string | number) => string;
|
|
797
|
-
|
|
798
797
|
declare const TimerCounter: React.FC<CounterInputProps$1>;
|
|
799
798
|
|
|
799
|
+
declare const formatTime$1: (time: string | number) => string;
|
|
800
|
+
|
|
800
801
|
type CounterInputProps = {
|
|
801
802
|
label?: string
|
|
802
803
|
tooltip?: string
|
package/dist/index.d.ts
CHANGED
|
@@ -580,9 +580,10 @@ type CounterInputProps$2<T extends FieldValues = FieldValues> = {
|
|
|
580
580
|
id?: string
|
|
581
581
|
defaultValue?: string | number
|
|
582
582
|
name?: Path<T>
|
|
583
|
+
minValue?: number
|
|
583
584
|
} & React.InputHTMLAttributes<HTMLInputElement>
|
|
584
585
|
|
|
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;
|
|
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;
|
|
586
587
|
|
|
587
588
|
type CurrencyInputProps<T extends FieldValues = FieldValues> = {
|
|
588
589
|
label?: string
|
|
@@ -717,9 +718,9 @@ type SelectProps = {
|
|
|
717
718
|
label?: string
|
|
718
719
|
placeholder?: string
|
|
719
720
|
options: SelectOption[]
|
|
720
|
-
onSelect: (option: SelectOption
|
|
721
|
+
onSelect: (option: SelectOption) => void
|
|
721
722
|
className?: string
|
|
722
|
-
value?: SelectOption
|
|
723
|
+
value?: SelectOption
|
|
723
724
|
tooltip?: string
|
|
724
725
|
isClearable?: boolean
|
|
725
726
|
}
|
|
@@ -793,10 +794,10 @@ type CounterInputProps$1 = {
|
|
|
793
794
|
form: UseFormReturn
|
|
794
795
|
} & React.InputHTMLAttributes<HTMLInputElement>
|
|
795
796
|
|
|
796
|
-
declare const formatTime$1: (time: string | number) => string;
|
|
797
|
-
|
|
798
797
|
declare const TimerCounter: React.FC<CounterInputProps$1>;
|
|
799
798
|
|
|
799
|
+
declare const formatTime$1: (time: string | number) => string;
|
|
800
|
+
|
|
800
801
|
type CounterInputProps = {
|
|
801
802
|
label?: string
|
|
802
803
|
tooltip?: string
|
package/dist/index.js
CHANGED
|
@@ -9050,17 +9050,48 @@ var Input = React107.forwardRef(
|
|
|
9050
9050
|
maxLength: $charactersLimit,
|
|
9051
9051
|
value,
|
|
9052
9052
|
onChange: (e14) => {
|
|
9053
|
-
|
|
9053
|
+
let inputValue = e14.target.value;
|
|
9054
|
+
if (type === "number") {
|
|
9055
|
+
inputValue = inputValue.replace(/[^0-9]/g, "");
|
|
9056
|
+
}
|
|
9054
9057
|
const newValue = $formatValue ? $formatValue(inputValue) : inputValue;
|
|
9055
|
-
|
|
9058
|
+
const finalValue = $charactersLimit ? newValue.slice(0, $charactersLimit) : newValue;
|
|
9059
|
+
setValue(finalValue);
|
|
9056
9060
|
onChange?.({
|
|
9057
9061
|
...e14,
|
|
9058
9062
|
target: {
|
|
9059
9063
|
...e14.target,
|
|
9060
|
-
value:
|
|
9064
|
+
value: finalValue
|
|
9061
9065
|
}
|
|
9062
9066
|
});
|
|
9063
9067
|
},
|
|
9068
|
+
onKeyDown: (e14) => {
|
|
9069
|
+
if (type === "number") {
|
|
9070
|
+
const allowedKeys = [
|
|
9071
|
+
"Backspace",
|
|
9072
|
+
"Delete",
|
|
9073
|
+
"Tab",
|
|
9074
|
+
"Escape",
|
|
9075
|
+
"Enter",
|
|
9076
|
+
"ArrowLeft",
|
|
9077
|
+
"ArrowRight",
|
|
9078
|
+
"ArrowUp",
|
|
9079
|
+
"ArrowDown",
|
|
9080
|
+
"Home",
|
|
9081
|
+
"End"
|
|
9082
|
+
];
|
|
9083
|
+
const isAllowedKey = allowedKeys.includes(e14.key);
|
|
9084
|
+
const isNumberKey = /^[0-9]$/.test(e14.key);
|
|
9085
|
+
const isCtrlA = e14.ctrlKey && e14.key === "a";
|
|
9086
|
+
const isCtrlC = e14.ctrlKey && e14.key === "c";
|
|
9087
|
+
const isCtrlV = e14.ctrlKey && e14.key === "v";
|
|
9088
|
+
const isCtrlX = e14.ctrlKey && e14.key === "x";
|
|
9089
|
+
if (!isAllowedKey && !isNumberKey && !isCtrlA && !isCtrlC && !isCtrlV && !isCtrlX) {
|
|
9090
|
+
e14.preventDefault();
|
|
9091
|
+
}
|
|
9092
|
+
}
|
|
9093
|
+
rest.onKeyDown?.(e14);
|
|
9094
|
+
},
|
|
9064
9095
|
$inputClassName,
|
|
9065
9096
|
...rest
|
|
9066
9097
|
}
|
|
@@ -9081,18 +9112,49 @@ var Input = React107.forwardRef(
|
|
|
9081
9112
|
maxLength: $charactersLimit,
|
|
9082
9113
|
value: field.value || "",
|
|
9083
9114
|
onChange: (e14) => {
|
|
9084
|
-
|
|
9115
|
+
let inputValue = e14.target.value;
|
|
9116
|
+
if (type === "number") {
|
|
9117
|
+
inputValue = inputValue.replace(/[^0-9]/g, "");
|
|
9118
|
+
}
|
|
9085
9119
|
const newValue = $formatValue ? $formatValue(inputValue) : inputValue;
|
|
9086
|
-
|
|
9087
|
-
|
|
9120
|
+
const finalValue = $charactersLimit ? newValue.slice(0, $charactersLimit) : newValue;
|
|
9121
|
+
setValue(finalValue);
|
|
9122
|
+
field.onChange(finalValue);
|
|
9088
9123
|
onChange?.({
|
|
9089
9124
|
...e14,
|
|
9090
9125
|
target: {
|
|
9091
9126
|
...e14.target,
|
|
9092
|
-
value:
|
|
9127
|
+
value: finalValue
|
|
9093
9128
|
}
|
|
9094
9129
|
});
|
|
9095
9130
|
},
|
|
9131
|
+
onKeyDown: (e14) => {
|
|
9132
|
+
if (type === "number") {
|
|
9133
|
+
const allowedKeys = [
|
|
9134
|
+
"Backspace",
|
|
9135
|
+
"Delete",
|
|
9136
|
+
"Tab",
|
|
9137
|
+
"Escape",
|
|
9138
|
+
"Enter",
|
|
9139
|
+
"ArrowLeft",
|
|
9140
|
+
"ArrowRight",
|
|
9141
|
+
"ArrowUp",
|
|
9142
|
+
"ArrowDown",
|
|
9143
|
+
"Home",
|
|
9144
|
+
"End"
|
|
9145
|
+
];
|
|
9146
|
+
const isAllowedKey = allowedKeys.includes(e14.key);
|
|
9147
|
+
const isNumberKey = /^[0-9]$/.test(e14.key);
|
|
9148
|
+
const isCtrlA = e14.ctrlKey && e14.key === "a";
|
|
9149
|
+
const isCtrlC = e14.ctrlKey && e14.key === "c";
|
|
9150
|
+
const isCtrlV = e14.ctrlKey && e14.key === "v";
|
|
9151
|
+
const isCtrlX = e14.ctrlKey && e14.key === "x";
|
|
9152
|
+
if (!isAllowedKey && !isNumberKey && !isCtrlA && !isCtrlC && !isCtrlV && !isCtrlX) {
|
|
9153
|
+
e14.preventDefault();
|
|
9154
|
+
}
|
|
9155
|
+
}
|
|
9156
|
+
rest.onKeyDown?.(e14);
|
|
9157
|
+
},
|
|
9096
9158
|
$inputClassName,
|
|
9097
9159
|
...rest
|
|
9098
9160
|
}
|
|
@@ -11257,24 +11319,27 @@ var Counter = ({
|
|
|
11257
11319
|
methods,
|
|
11258
11320
|
onChange,
|
|
11259
11321
|
id,
|
|
11322
|
+
minValue = 0,
|
|
11260
11323
|
...rest
|
|
11261
11324
|
}) => {
|
|
11262
11325
|
const form = reactHookForm.useForm();
|
|
11263
11326
|
const { setValue, getValues, control } = methods || form;
|
|
11264
11327
|
const fieldName = rest.name || "counter";
|
|
11265
|
-
const defaultValue = rest.defaultValue ? Number(rest.defaultValue) :
|
|
11328
|
+
const defaultValue = rest.defaultValue ? Math.max(Number(rest.defaultValue), minValue) : minValue;
|
|
11266
11329
|
const handleIncrement = () => {
|
|
11267
11330
|
if (!hasDisabled) {
|
|
11268
|
-
const currentValue = getValues(fieldName)
|
|
11269
|
-
const
|
|
11331
|
+
const currentValue = getValues(fieldName);
|
|
11332
|
+
const numericValue = currentValue !== void 0 && currentValue !== null ? Number(currentValue) : minValue;
|
|
11333
|
+
const newValue = Math.max(numericValue, minValue) + 1;
|
|
11270
11334
|
setValue(fieldName, newValue);
|
|
11271
11335
|
onChange?.(newValue);
|
|
11272
11336
|
}
|
|
11273
11337
|
};
|
|
11274
11338
|
const handleDecrement = () => {
|
|
11275
11339
|
if (!hasDisabled) {
|
|
11276
|
-
const currentValue = getValues(fieldName)
|
|
11277
|
-
const
|
|
11340
|
+
const currentValue = getValues(fieldName);
|
|
11341
|
+
const numericValue = currentValue !== void 0 && currentValue !== null ? Number(currentValue) : minValue;
|
|
11342
|
+
const newValue = Math.max(numericValue, minValue) > minValue ? Math.max(numericValue, minValue) - 1 : minValue;
|
|
11278
11343
|
setValue(fieldName, newValue);
|
|
11279
11344
|
onChange?.(newValue);
|
|
11280
11345
|
}
|
|
@@ -11322,11 +11387,11 @@ var Counter = ({
|
|
|
11322
11387
|
...fieldWithoutDefaultValue,
|
|
11323
11388
|
id: fieldName,
|
|
11324
11389
|
type: "number",
|
|
11325
|
-
min:
|
|
11326
|
-
value: field.value
|
|
11390
|
+
min: minValue,
|
|
11391
|
+
value: field.value !== void 0 && field.value !== null ? Math.max(Number(field.value), minValue) : minValue,
|
|
11327
11392
|
onChange: (e14) => {
|
|
11328
11393
|
const newValue = Number(e14.target.value);
|
|
11329
|
-
if (newValue >=
|
|
11394
|
+
if (newValue >= minValue) {
|
|
11330
11395
|
field.onChange(newValue);
|
|
11331
11396
|
onChange?.(newValue);
|
|
11332
11397
|
}
|
|
@@ -11685,7 +11750,9 @@ var CustomSelect = ({
|
|
|
11685
11750
|
isClearable = true
|
|
11686
11751
|
}) => {
|
|
11687
11752
|
const handleChange = (option) => {
|
|
11688
|
-
|
|
11753
|
+
if (option) {
|
|
11754
|
+
onSelect(option);
|
|
11755
|
+
}
|
|
11689
11756
|
};
|
|
11690
11757
|
const formatOptionLabel = (option) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
|
|
11691
11758
|
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 }) }),
|
|
@@ -12018,8 +12085,6 @@ var TimeInput = ({
|
|
|
12018
12085
|
] })
|
|
12019
12086
|
] });
|
|
12020
12087
|
};
|
|
12021
|
-
|
|
12022
|
-
// src/_design-system/helpers/formatTime.ts
|
|
12023
12088
|
var formatTime = (time2) => {
|
|
12024
12089
|
let timeInSeconds = 0;
|
|
12025
12090
|
if (typeof time2 === "string") {
|
|
@@ -12168,7 +12233,26 @@ var TimerCounter = ({
|
|
|
12168
12233
|
description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-gray-700", children: description })
|
|
12169
12234
|
] });
|
|
12170
12235
|
};
|
|
12236
|
+
|
|
12237
|
+
// src/_design-system/helpers/formatTime.ts
|
|
12171
12238
|
var formatTime2 = (time2) => {
|
|
12239
|
+
let timeInSeconds = 0;
|
|
12240
|
+
if (typeof time2 === "string") {
|
|
12241
|
+
if (time2.includes(":")) {
|
|
12242
|
+
const [hours3, minutes3, seconds4] = time2.split(":").map(Number);
|
|
12243
|
+
timeInSeconds = hours3 * 3600 + minutes3 * 60 + seconds4;
|
|
12244
|
+
} else {
|
|
12245
|
+
timeInSeconds = parseInt(time2, 10) || 0;
|
|
12246
|
+
}
|
|
12247
|
+
} else {
|
|
12248
|
+
timeInSeconds = time2 || 0;
|
|
12249
|
+
}
|
|
12250
|
+
const hours2 = Math.floor(timeInSeconds / 3600);
|
|
12251
|
+
const minutes2 = Math.floor(timeInSeconds % 3600 / 60);
|
|
12252
|
+
const seconds3 = timeInSeconds % 60;
|
|
12253
|
+
return `${hours2.toString().padStart(2, "0")}:${minutes2.toString().padStart(2, "0")}:${seconds3.toString().padStart(2, "0")}`;
|
|
12254
|
+
};
|
|
12255
|
+
var formatTime3 = (time2) => {
|
|
12172
12256
|
let timeInSeconds = 0;
|
|
12173
12257
|
if (typeof time2 === "string") {
|
|
12174
12258
|
if (time2.includes(":")) {
|
|
@@ -12198,7 +12282,7 @@ var TimerCounterWithoutSeconds = ({
|
|
|
12198
12282
|
const fieldName = rest.name || "timer";
|
|
12199
12283
|
const { control, setValue, watch } = form;
|
|
12200
12284
|
const rawValue = watch(fieldName, defaultValue || "00:00");
|
|
12201
|
-
const displayValue = typeof rawValue === "number" ?
|
|
12285
|
+
const displayValue = typeof rawValue === "number" ? formatTime3(rawValue) : rawValue || "00:00";
|
|
12202
12286
|
const parseTime = (timeString) => {
|
|
12203
12287
|
if (!timeString) return 0;
|
|
12204
12288
|
const [hours2, minutes2] = timeString.split(":").map(Number);
|
|
@@ -12212,7 +12296,7 @@ var TimerCounterWithoutSeconds = ({
|
|
|
12212
12296
|
setValue(fieldName, "00:00", { shouldValidate: true, shouldDirty: true, shouldTouch: true });
|
|
12213
12297
|
return;
|
|
12214
12298
|
}
|
|
12215
|
-
setValue(fieldName,
|
|
12299
|
+
setValue(fieldName, formatTime3(newSeconds), { shouldValidate: true, shouldDirty: true, shouldTouch: true });
|
|
12216
12300
|
}
|
|
12217
12301
|
};
|
|
12218
12302
|
const handleDecrement = () => {
|
|
@@ -12220,7 +12304,7 @@ var TimerCounterWithoutSeconds = ({
|
|
|
12220
12304
|
const currentSeconds = parseTime(displayValue);
|
|
12221
12305
|
if (currentSeconds <= 0) return;
|
|
12222
12306
|
const newSeconds = Math.max(0, currentSeconds - 3600);
|
|
12223
|
-
setValue(fieldName,
|
|
12307
|
+
setValue(fieldName, formatTime3(newSeconds), { shouldValidate: true, shouldDirty: true, shouldTouch: true });
|
|
12224
12308
|
}
|
|
12225
12309
|
};
|
|
12226
12310
|
const handleChanges = (e14) => {
|
|
@@ -12352,8 +12436,8 @@ function FileUploadComponent({
|
|
|
12352
12436
|
const isImagePreview = React107.useCallback((preview) => {
|
|
12353
12437
|
if (!preview || typeof preview !== "string") return false;
|
|
12354
12438
|
if (preview.startsWith("data:image/")) return true;
|
|
12355
|
-
if (preview.startsWith("http") && preview.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp|tiff)/i)) return true;
|
|
12356
|
-
if (preview.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp|tiff)$/i)) return true;
|
|
12439
|
+
if (preview.startsWith("http") && preview.match(/\.(jpg|jpeg|png|gif|webp|svg|avif|bmp|tiff)/i)) return true;
|
|
12440
|
+
if (preview.match(/\.(jpg|jpeg|png|gif|webp|svg|avif|bmp|tiff)$/i)) return true;
|
|
12357
12441
|
return false;
|
|
12358
12442
|
}, []);
|
|
12359
12443
|
React107.useEffect(() => {
|
|
@@ -26724,8 +26808,8 @@ exports.formatNumberToCurrency = formatNumberToCurrency;
|
|
|
26724
26808
|
exports.formatPhone = formatPhone;
|
|
26725
26809
|
exports.formatPostalCode = formatPostalCode;
|
|
26726
26810
|
exports.formatRawDigitsToCurrency = formatRawDigitsToCurrency;
|
|
26727
|
-
exports.formatTime =
|
|
26728
|
-
exports.formatTimeWithoutSeconds =
|
|
26811
|
+
exports.formatTime = formatTime2;
|
|
26812
|
+
exports.formatTimeWithoutSeconds = formatTime3;
|
|
26729
26813
|
exports.getDates = getDates;
|
|
26730
26814
|
exports.handleFormSubmission = handleFormSubmission;
|
|
26731
26815
|
exports.iconList = iconList;
|