@lets-events/react 10.1.0 → 10.1.1
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/.turbo/turbo-build.log +7 -8
- package/CHANGELOG.md +6 -0
- package/dist/index.js +55 -12
- package/dist/index.mjs +55 -12
- package/package.json +1 -1
- package/src/components/TimePicker.tsx +54 -13
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @lets-events/react@10.1.
|
|
3
|
+
> @lets-events/react@10.1.1 build
|
|
4
4
|
> tsup src/index.tsx --format esm,cjs --dts --external react
|
|
5
5
|
|
|
6
|
-
[
|
|
6
|
+
[34mCLI[39m Building entry: src/index.tsx
|
|
7
7
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
8
|
[34mCLI[39m tsup v8.4.0
|
|
9
9
|
[34mCLI[39m Target: es6
|
|
10
10
|
[34mESM[39m Build start
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
12
|
+
[32mCJS[39m [1mdist/index.js [22m[32m283.08 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 11472ms
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m274.71 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 11473ms
|
|
16
16
|
DTS Build start
|
|
17
|
-
DTS ⚡️ Build success in
|
|
17
|
+
DTS ⚡️ Build success in -4645ms
|
|
18
18
|
DTS dist/index.d.mts 338.38 KB
|
|
19
19
|
DTS dist/index.d.ts 338.38 KB
|
|
20
|
-
[1G[0K⠙[1G[0K
|
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -7974,8 +7974,21 @@ var InputStyled = styled("input", {
|
|
|
7974
7974
|
color: "$dark400",
|
|
7975
7975
|
border: "1px solid $dark200",
|
|
7976
7976
|
cursor: "not-allowed"
|
|
7977
|
+
},
|
|
7978
|
+
inputMode: "numeric",
|
|
7979
|
+
"&::-webkit-inner-spin-button": {
|
|
7980
|
+
WebkitAppearance: "none",
|
|
7981
|
+
margin: 0
|
|
7982
|
+
},
|
|
7983
|
+
"&::-webkit-outer-spin-button": {
|
|
7984
|
+
WebkitAppearance: "none",
|
|
7985
|
+
margin: 0
|
|
7986
|
+
},
|
|
7987
|
+
"&[type='number']": {
|
|
7988
|
+
MozAppearance: "textfield"
|
|
7977
7989
|
}
|
|
7978
7990
|
});
|
|
7991
|
+
var pad = (num) => String(num).padStart(2, "0");
|
|
7979
7992
|
function TimePicker({
|
|
7980
7993
|
selected,
|
|
7981
7994
|
setSelected,
|
|
@@ -7983,25 +7996,21 @@ function TimePicker({
|
|
|
7983
7996
|
}) {
|
|
7984
7997
|
const [hours, setHours] = (0, import_react5.useState)("00");
|
|
7985
7998
|
const [minutes, setMinutes] = (0, import_react5.useState)("00");
|
|
7999
|
+
const [rawHours, setRawHours] = (0, import_react5.useState)("00");
|
|
8000
|
+
const [rawMinutes, setRawMinutes] = (0, import_react5.useState)("00");
|
|
7986
8001
|
const [isOpen, setIsOpen] = (0, import_react5.useState)(false);
|
|
7987
8002
|
const dropdownRef = (0, import_react5.useRef)(null);
|
|
7988
8003
|
useOnClickOutside(dropdownRef, () => setIsOpen(false));
|
|
7989
|
-
const pad = (num) => String(num).padStart(2, "0");
|
|
7990
|
-
const handleInputValue = (0, import_react5.useCallback)(
|
|
7991
|
-
(time) => {
|
|
7992
|
-
setSelected(time);
|
|
7993
|
-
setIsOpen(false);
|
|
7994
|
-
},
|
|
7995
|
-
[setSelected]
|
|
7996
|
-
);
|
|
7997
8004
|
const handleIncrement = (0, import_react5.useCallback)(
|
|
7998
8005
|
(type) => {
|
|
7999
8006
|
if (type === "hours") {
|
|
8000
8007
|
const next = (parseInt(hours) + 1) % 24;
|
|
8001
8008
|
setHours(pad(next));
|
|
8009
|
+
setRawHours(pad(next));
|
|
8002
8010
|
} else {
|
|
8003
8011
|
const next = (parseInt(minutes) + 1) % 60;
|
|
8004
8012
|
setMinutes(pad(next));
|
|
8013
|
+
setRawMinutes(pad(next));
|
|
8005
8014
|
}
|
|
8006
8015
|
},
|
|
8007
8016
|
[hours, minutes]
|
|
@@ -8011,9 +8020,11 @@ function TimePicker({
|
|
|
8011
8020
|
if (type === "hours") {
|
|
8012
8021
|
const prev = (parseInt(hours) - 1 + 24) % 24;
|
|
8013
8022
|
setHours(pad(prev));
|
|
8023
|
+
setRawHours(pad(prev));
|
|
8014
8024
|
} else {
|
|
8015
8025
|
const prev = (parseInt(minutes) - 1 + 60) % 60;
|
|
8016
8026
|
setMinutes(pad(prev));
|
|
8027
|
+
setRawMinutes(pad(prev));
|
|
8017
8028
|
}
|
|
8018
8029
|
},
|
|
8019
8030
|
[hours, minutes]
|
|
@@ -8084,10 +8095,39 @@ function TimePicker({
|
|
|
8084
8095
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
8085
8096
|
InputStyled,
|
|
8086
8097
|
{
|
|
8087
|
-
|
|
8088
|
-
|
|
8098
|
+
inputMode: "numeric",
|
|
8099
|
+
pattern: "[0-9]*",
|
|
8089
8100
|
type: "text",
|
|
8090
|
-
placeholder: "00"
|
|
8101
|
+
placeholder: "00",
|
|
8102
|
+
value: unit === "hours" ? rawHours : rawMinutes,
|
|
8103
|
+
onChange: (e) => {
|
|
8104
|
+
const rawValue = e.target.value.replace(/\D/g, "");
|
|
8105
|
+
if (unit === "hours") {
|
|
8106
|
+
setRawHours(rawValue);
|
|
8107
|
+
} else {
|
|
8108
|
+
setRawMinutes(rawValue);
|
|
8109
|
+
}
|
|
8110
|
+
},
|
|
8111
|
+
onBlur: () => {
|
|
8112
|
+
let num = 0;
|
|
8113
|
+
if (unit === "hours") {
|
|
8114
|
+
num = Math.min(parseInt(rawHours || "0", 10), 23);
|
|
8115
|
+
const padded = pad(num);
|
|
8116
|
+
setHours(padded);
|
|
8117
|
+
setRawHours(padded);
|
|
8118
|
+
} else {
|
|
8119
|
+
num = Math.min(parseInt(rawMinutes || "0", 10), 59);
|
|
8120
|
+
const padded = pad(num);
|
|
8121
|
+
setMinutes(padded);
|
|
8122
|
+
setRawMinutes(padded);
|
|
8123
|
+
}
|
|
8124
|
+
},
|
|
8125
|
+
onPaste: (e) => {
|
|
8126
|
+
const paste = e.clipboardData.getData("Text");
|
|
8127
|
+
if (!/^\d{1,2}$/.test(paste)) {
|
|
8128
|
+
e.preventDefault();
|
|
8129
|
+
}
|
|
8130
|
+
}
|
|
8091
8131
|
}
|
|
8092
8132
|
),
|
|
8093
8133
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
@@ -8136,7 +8176,10 @@ function TimePicker({
|
|
|
8136
8176
|
type: "button",
|
|
8137
8177
|
variant: "text",
|
|
8138
8178
|
color: "brand",
|
|
8139
|
-
onClick: () =>
|
|
8179
|
+
onClick: () => {
|
|
8180
|
+
setSelected(`${hours}:${minutes}`);
|
|
8181
|
+
setIsOpen(false);
|
|
8182
|
+
},
|
|
8140
8183
|
typography: "buttonMedium",
|
|
8141
8184
|
fontWeight: "medium",
|
|
8142
8185
|
children: "Aplicar"
|
package/dist/index.mjs
CHANGED
|
@@ -7888,8 +7888,21 @@ var InputStyled = styled("input", {
|
|
|
7888
7888
|
color: "$dark400",
|
|
7889
7889
|
border: "1px solid $dark200",
|
|
7890
7890
|
cursor: "not-allowed"
|
|
7891
|
+
},
|
|
7892
|
+
inputMode: "numeric",
|
|
7893
|
+
"&::-webkit-inner-spin-button": {
|
|
7894
|
+
WebkitAppearance: "none",
|
|
7895
|
+
margin: 0
|
|
7896
|
+
},
|
|
7897
|
+
"&::-webkit-outer-spin-button": {
|
|
7898
|
+
WebkitAppearance: "none",
|
|
7899
|
+
margin: 0
|
|
7900
|
+
},
|
|
7901
|
+
"&[type='number']": {
|
|
7902
|
+
MozAppearance: "textfield"
|
|
7891
7903
|
}
|
|
7892
7904
|
});
|
|
7905
|
+
var pad = (num) => String(num).padStart(2, "0");
|
|
7893
7906
|
function TimePicker({
|
|
7894
7907
|
selected,
|
|
7895
7908
|
setSelected,
|
|
@@ -7897,25 +7910,21 @@ function TimePicker({
|
|
|
7897
7910
|
}) {
|
|
7898
7911
|
const [hours, setHours] = useState2("00");
|
|
7899
7912
|
const [minutes, setMinutes] = useState2("00");
|
|
7913
|
+
const [rawHours, setRawHours] = useState2("00");
|
|
7914
|
+
const [rawMinutes, setRawMinutes] = useState2("00");
|
|
7900
7915
|
const [isOpen, setIsOpen] = useState2(false);
|
|
7901
7916
|
const dropdownRef = useRef2(null);
|
|
7902
7917
|
useOnClickOutside(dropdownRef, () => setIsOpen(false));
|
|
7903
|
-
const pad = (num) => String(num).padStart(2, "0");
|
|
7904
|
-
const handleInputValue = useCallback(
|
|
7905
|
-
(time) => {
|
|
7906
|
-
setSelected(time);
|
|
7907
|
-
setIsOpen(false);
|
|
7908
|
-
},
|
|
7909
|
-
[setSelected]
|
|
7910
|
-
);
|
|
7911
7918
|
const handleIncrement = useCallback(
|
|
7912
7919
|
(type) => {
|
|
7913
7920
|
if (type === "hours") {
|
|
7914
7921
|
const next = (parseInt(hours) + 1) % 24;
|
|
7915
7922
|
setHours(pad(next));
|
|
7923
|
+
setRawHours(pad(next));
|
|
7916
7924
|
} else {
|
|
7917
7925
|
const next = (parseInt(minutes) + 1) % 60;
|
|
7918
7926
|
setMinutes(pad(next));
|
|
7927
|
+
setRawMinutes(pad(next));
|
|
7919
7928
|
}
|
|
7920
7929
|
},
|
|
7921
7930
|
[hours, minutes]
|
|
@@ -7925,9 +7934,11 @@ function TimePicker({
|
|
|
7925
7934
|
if (type === "hours") {
|
|
7926
7935
|
const prev = (parseInt(hours) - 1 + 24) % 24;
|
|
7927
7936
|
setHours(pad(prev));
|
|
7937
|
+
setRawHours(pad(prev));
|
|
7928
7938
|
} else {
|
|
7929
7939
|
const prev = (parseInt(minutes) - 1 + 60) % 60;
|
|
7930
7940
|
setMinutes(pad(prev));
|
|
7941
|
+
setRawMinutes(pad(prev));
|
|
7931
7942
|
}
|
|
7932
7943
|
},
|
|
7933
7944
|
[hours, minutes]
|
|
@@ -7998,10 +8009,39 @@ function TimePicker({
|
|
|
7998
8009
|
/* @__PURE__ */ jsx15(
|
|
7999
8010
|
InputStyled,
|
|
8000
8011
|
{
|
|
8001
|
-
|
|
8002
|
-
|
|
8012
|
+
inputMode: "numeric",
|
|
8013
|
+
pattern: "[0-9]*",
|
|
8003
8014
|
type: "text",
|
|
8004
|
-
placeholder: "00"
|
|
8015
|
+
placeholder: "00",
|
|
8016
|
+
value: unit === "hours" ? rawHours : rawMinutes,
|
|
8017
|
+
onChange: (e) => {
|
|
8018
|
+
const rawValue = e.target.value.replace(/\D/g, "");
|
|
8019
|
+
if (unit === "hours") {
|
|
8020
|
+
setRawHours(rawValue);
|
|
8021
|
+
} else {
|
|
8022
|
+
setRawMinutes(rawValue);
|
|
8023
|
+
}
|
|
8024
|
+
},
|
|
8025
|
+
onBlur: () => {
|
|
8026
|
+
let num = 0;
|
|
8027
|
+
if (unit === "hours") {
|
|
8028
|
+
num = Math.min(parseInt(rawHours || "0", 10), 23);
|
|
8029
|
+
const padded = pad(num);
|
|
8030
|
+
setHours(padded);
|
|
8031
|
+
setRawHours(padded);
|
|
8032
|
+
} else {
|
|
8033
|
+
num = Math.min(parseInt(rawMinutes || "0", 10), 59);
|
|
8034
|
+
const padded = pad(num);
|
|
8035
|
+
setMinutes(padded);
|
|
8036
|
+
setRawMinutes(padded);
|
|
8037
|
+
}
|
|
8038
|
+
},
|
|
8039
|
+
onPaste: (e) => {
|
|
8040
|
+
const paste = e.clipboardData.getData("Text");
|
|
8041
|
+
if (!/^\d{1,2}$/.test(paste)) {
|
|
8042
|
+
e.preventDefault();
|
|
8043
|
+
}
|
|
8044
|
+
}
|
|
8005
8045
|
}
|
|
8006
8046
|
),
|
|
8007
8047
|
/* @__PURE__ */ jsx15(
|
|
@@ -8050,7 +8090,10 @@ function TimePicker({
|
|
|
8050
8090
|
type: "button",
|
|
8051
8091
|
variant: "text",
|
|
8052
8092
|
color: "brand",
|
|
8053
|
-
onClick: () =>
|
|
8093
|
+
onClick: () => {
|
|
8094
|
+
setSelected(`${hours}:${minutes}`);
|
|
8095
|
+
setIsOpen(false);
|
|
8096
|
+
},
|
|
8054
8097
|
typography: "buttonMedium",
|
|
8055
8098
|
fontWeight: "medium",
|
|
8056
8099
|
children: "Aplicar"
|
package/package.json
CHANGED
|
@@ -81,6 +81,18 @@ export const InputStyled = styled("input", {
|
|
|
81
81
|
border: "1px solid $dark200",
|
|
82
82
|
cursor: "not-allowed",
|
|
83
83
|
},
|
|
84
|
+
inputMode: "numeric",
|
|
85
|
+
"&::-webkit-inner-spin-button": {
|
|
86
|
+
WebkitAppearance: "none",
|
|
87
|
+
margin: 0,
|
|
88
|
+
},
|
|
89
|
+
"&::-webkit-outer-spin-button": {
|
|
90
|
+
WebkitAppearance: "none",
|
|
91
|
+
margin: 0,
|
|
92
|
+
},
|
|
93
|
+
"&[type='number']": {
|
|
94
|
+
MozAppearance: "textfield",
|
|
95
|
+
},
|
|
84
96
|
});
|
|
85
97
|
|
|
86
98
|
export type TimePickerProps = {
|
|
@@ -88,6 +100,7 @@ export type TimePickerProps = {
|
|
|
88
100
|
setSelected: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
89
101
|
position?: "bottom" | "top";
|
|
90
102
|
};
|
|
103
|
+
const pad = (num: number) => String(num).padStart(2, "0");
|
|
91
104
|
|
|
92
105
|
export function TimePicker({
|
|
93
106
|
selected,
|
|
@@ -96,29 +109,23 @@ export function TimePicker({
|
|
|
96
109
|
}: TimePickerProps) {
|
|
97
110
|
const [hours, setHours] = useState("00");
|
|
98
111
|
const [minutes, setMinutes] = useState("00");
|
|
112
|
+
const [rawHours, setRawHours] = useState("00");
|
|
113
|
+
const [rawMinutes, setRawMinutes] = useState("00");
|
|
99
114
|
const [isOpen, setIsOpen] = useState(false);
|
|
100
115
|
const dropdownRef = useRef(null);
|
|
101
116
|
|
|
102
117
|
useOnClickOutside(dropdownRef, () => setIsOpen(false));
|
|
103
118
|
|
|
104
|
-
const pad = (num: number) => String(num).padStart(2, "0");
|
|
105
|
-
|
|
106
|
-
const handleInputValue = useCallback(
|
|
107
|
-
(time: string) => {
|
|
108
|
-
setSelected(time);
|
|
109
|
-
setIsOpen(false);
|
|
110
|
-
},
|
|
111
|
-
[setSelected]
|
|
112
|
-
);
|
|
113
|
-
|
|
114
119
|
const handleIncrement = useCallback(
|
|
115
120
|
(type: "hours" | "minutes") => {
|
|
116
121
|
if (type === "hours") {
|
|
117
122
|
const next = (parseInt(hours) + 1) % 24;
|
|
118
123
|
setHours(pad(next));
|
|
124
|
+
setRawHours(pad(next));
|
|
119
125
|
} else {
|
|
120
126
|
const next = (parseInt(minutes) + 1) % 60;
|
|
121
127
|
setMinutes(pad(next));
|
|
128
|
+
setRawMinutes(pad(next));
|
|
122
129
|
}
|
|
123
130
|
},
|
|
124
131
|
[hours, minutes]
|
|
@@ -128,9 +135,11 @@ export function TimePicker({
|
|
|
128
135
|
if (type === "hours") {
|
|
129
136
|
const prev = (parseInt(hours) - 1 + 24) % 24;
|
|
130
137
|
setHours(pad(prev));
|
|
138
|
+
setRawHours(pad(prev));
|
|
131
139
|
} else {
|
|
132
140
|
const prev = (parseInt(minutes) - 1 + 60) % 60;
|
|
133
141
|
setMinutes(pad(prev));
|
|
142
|
+
setRawMinutes(pad(prev));
|
|
134
143
|
}
|
|
135
144
|
},
|
|
136
145
|
[hours, minutes]
|
|
@@ -189,10 +198,39 @@ export function TimePicker({
|
|
|
189
198
|
</svg>
|
|
190
199
|
</Button>
|
|
191
200
|
<InputStyled
|
|
192
|
-
|
|
193
|
-
|
|
201
|
+
inputMode="numeric"
|
|
202
|
+
pattern="[0-9]*"
|
|
194
203
|
type="text"
|
|
195
204
|
placeholder="00"
|
|
205
|
+
value={unit === "hours" ? rawHours : rawMinutes}
|
|
206
|
+
onChange={(e) => {
|
|
207
|
+
const rawValue = e.target.value.replace(/\D/g, "");
|
|
208
|
+
if (unit === "hours") {
|
|
209
|
+
setRawHours(rawValue);
|
|
210
|
+
} else {
|
|
211
|
+
setRawMinutes(rawValue);
|
|
212
|
+
}
|
|
213
|
+
}}
|
|
214
|
+
onBlur={() => {
|
|
215
|
+
let num = 0;
|
|
216
|
+
if (unit === "hours") {
|
|
217
|
+
num = Math.min(parseInt(rawHours || "0", 10), 23);
|
|
218
|
+
const padded = pad(num);
|
|
219
|
+
setHours(padded);
|
|
220
|
+
setRawHours(padded);
|
|
221
|
+
} else {
|
|
222
|
+
num = Math.min(parseInt(rawMinutes || "0", 10), 59);
|
|
223
|
+
const padded = pad(num);
|
|
224
|
+
setMinutes(padded);
|
|
225
|
+
setRawMinutes(padded);
|
|
226
|
+
}
|
|
227
|
+
}}
|
|
228
|
+
onPaste={(e) => {
|
|
229
|
+
const paste = e.clipboardData.getData("Text");
|
|
230
|
+
if (!/^\d{1,2}$/.test(paste)) {
|
|
231
|
+
e.preventDefault();
|
|
232
|
+
}
|
|
233
|
+
}}
|
|
196
234
|
/>
|
|
197
235
|
<Button
|
|
198
236
|
type="button"
|
|
@@ -225,7 +263,10 @@ export function TimePicker({
|
|
|
225
263
|
type="button"
|
|
226
264
|
variant="text"
|
|
227
265
|
color="brand"
|
|
228
|
-
onClick={() =>
|
|
266
|
+
onClick={() => {
|
|
267
|
+
setSelected(`${hours}:${minutes}`);
|
|
268
|
+
setIsOpen(false);
|
|
269
|
+
}}
|
|
229
270
|
typography="buttonMedium"
|
|
230
271
|
fontWeight="medium"
|
|
231
272
|
>
|