@lets-events/react 12.8.6 → 12.9.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 +8 -8
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +85 -30
- package/dist/index.mjs +85 -30
- package/package.json +1 -1
- package/src/components/Calendar/index.tsx +3 -0
- package/src/components/FormFields/DateAndTimeFormField.tsx +52 -2
- package/src/components/TimePicker.tsx +3 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @lets-events/react@12.
|
|
3
|
+
> @lets-events/react@12.9.1 build
|
|
4
4
|
> tsup src/index.tsx --format esm,cjs --dts --external react
|
|
5
5
|
|
|
6
6
|
[1G[0K[34mCLI[39m Building entry: src/index.tsx
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
[34mCLI[39m Target: es6
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
14
|
-
[32mESM[39m ⚡️ Build success in
|
|
15
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
16
|
-
[32mCJS[39m ⚡️ Build success in
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m399.64 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 505ms
|
|
15
|
+
[32mCJS[39m [1mdist/index.js [22m[32m415.12 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 506ms
|
|
17
17
|
DTS Build start
|
|
18
|
-
DTS ⚡️ Build success in
|
|
19
|
-
DTS dist/index.d.mts 404.
|
|
20
|
-
DTS dist/index.d.ts 404.
|
|
18
|
+
DTS ⚡️ Build success in 9204ms
|
|
19
|
+
DTS dist/index.d.mts 404.35 KB
|
|
20
|
+
DTS dist/index.d.ts 404.35 KB
|
|
21
21
|
[1G[0K⠙[1G[0K
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -4728,8 +4728,9 @@ type CalendarProps = ComponentProps<typeof CalendarStyled> & {
|
|
|
4728
4728
|
allowPastDates?: boolean;
|
|
4729
4729
|
maxDate?: Date;
|
|
4730
4730
|
maxYearsFromNow?: number;
|
|
4731
|
+
disabled?: boolean;
|
|
4731
4732
|
};
|
|
4732
|
-
declare function Calendar({ action, actionText, actionAlign, calendarLayout, selected, setSelected, position, hasError, expand, allowPastDates, maxDate, maxYearsFromNow, ...props }: CalendarProps): react_jsx_runtime.JSX.Element;
|
|
4733
|
+
declare function Calendar({ action, actionText, actionAlign, calendarLayout, selected, setSelected, position, hasError, expand, allowPastDates, maxDate, maxYearsFromNow, disabled, ...props }: CalendarProps): react_jsx_runtime.JSX.Element;
|
|
4733
4734
|
|
|
4734
4735
|
type DateRange = {
|
|
4735
4736
|
from?: Date;
|
|
@@ -7770,8 +7771,9 @@ type TimePickerProps = {
|
|
|
7770
7771
|
position?: "bottom" | "top" | "top-right" | "bottom-right";
|
|
7771
7772
|
hasError?: boolean;
|
|
7772
7773
|
expand?: boolean;
|
|
7774
|
+
disabled?: boolean;
|
|
7773
7775
|
};
|
|
7774
|
-
declare function TimePicker({ selected, setSelected, position, hasError, expand, }: TimePickerProps): react_jsx_runtime.JSX.Element;
|
|
7776
|
+
declare function TimePicker({ selected, setSelected, position, hasError, expand, disabled, }: TimePickerProps): react_jsx_runtime.JSX.Element;
|
|
7775
7777
|
|
|
7776
7778
|
declare const AlertDialogSimpleStyled: _stitches_react_types_styled_component.StyledComponent<React$1.ForwardRefExoticComponent<AlertDialog.ContentProps & React$1.RefAttributes<HTMLDivElement>>, {
|
|
7777
7779
|
color?: "info" | "warning" | "error" | "success" | undefined;
|
|
@@ -15369,11 +15371,13 @@ type DateAndTimeFormFieldProps = Omit<CalendarProps, "selected" | "setSelected">
|
|
|
15369
15371
|
validate?: (value: string | undefined) => boolean | string;
|
|
15370
15372
|
validationErrorMessage?: string;
|
|
15371
15373
|
rules?: Omit<RegisterOptions<FieldValues, string>, "valueAsNumber" | "valueAsDate" | "setValueAs" | "disabled">;
|
|
15374
|
+
disabled?: boolean;
|
|
15375
|
+
disabledInfo?: string;
|
|
15372
15376
|
allowPastDates?: boolean;
|
|
15373
15377
|
maxYearsFromNow?: number;
|
|
15374
15378
|
maxDate?: Date;
|
|
15375
15379
|
};
|
|
15376
|
-
declare const DateAndTimeFormField: ({ name, label, required, validate, validationErrorMessage, rules, allowPastDates, maxYearsFromNow, maxDate, ...props }: DateAndTimeFormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
15380
|
+
declare const DateAndTimeFormField: ({ name, label, required, validate, validationErrorMessage, rules, disabled, disabledInfo, allowPastDates, maxYearsFromNow, maxDate, ...props }: DateAndTimeFormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
15377
15381
|
|
|
15378
15382
|
interface UploadConfig {
|
|
15379
15383
|
apiUrl: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -4728,8 +4728,9 @@ type CalendarProps = ComponentProps<typeof CalendarStyled> & {
|
|
|
4728
4728
|
allowPastDates?: boolean;
|
|
4729
4729
|
maxDate?: Date;
|
|
4730
4730
|
maxYearsFromNow?: number;
|
|
4731
|
+
disabled?: boolean;
|
|
4731
4732
|
};
|
|
4732
|
-
declare function Calendar({ action, actionText, actionAlign, calendarLayout, selected, setSelected, position, hasError, expand, allowPastDates, maxDate, maxYearsFromNow, ...props }: CalendarProps): react_jsx_runtime.JSX.Element;
|
|
4733
|
+
declare function Calendar({ action, actionText, actionAlign, calendarLayout, selected, setSelected, position, hasError, expand, allowPastDates, maxDate, maxYearsFromNow, disabled, ...props }: CalendarProps): react_jsx_runtime.JSX.Element;
|
|
4733
4734
|
|
|
4734
4735
|
type DateRange = {
|
|
4735
4736
|
from?: Date;
|
|
@@ -7770,8 +7771,9 @@ type TimePickerProps = {
|
|
|
7770
7771
|
position?: "bottom" | "top" | "top-right" | "bottom-right";
|
|
7771
7772
|
hasError?: boolean;
|
|
7772
7773
|
expand?: boolean;
|
|
7774
|
+
disabled?: boolean;
|
|
7773
7775
|
};
|
|
7774
|
-
declare function TimePicker({ selected, setSelected, position, hasError, expand, }: TimePickerProps): react_jsx_runtime.JSX.Element;
|
|
7776
|
+
declare function TimePicker({ selected, setSelected, position, hasError, expand, disabled, }: TimePickerProps): react_jsx_runtime.JSX.Element;
|
|
7775
7777
|
|
|
7776
7778
|
declare const AlertDialogSimpleStyled: _stitches_react_types_styled_component.StyledComponent<React$1.ForwardRefExoticComponent<AlertDialog.ContentProps & React$1.RefAttributes<HTMLDivElement>>, {
|
|
7777
7779
|
color?: "info" | "warning" | "error" | "success" | undefined;
|
|
@@ -15369,11 +15371,13 @@ type DateAndTimeFormFieldProps = Omit<CalendarProps, "selected" | "setSelected">
|
|
|
15369
15371
|
validate?: (value: string | undefined) => boolean | string;
|
|
15370
15372
|
validationErrorMessage?: string;
|
|
15371
15373
|
rules?: Omit<RegisterOptions<FieldValues, string>, "valueAsNumber" | "valueAsDate" | "setValueAs" | "disabled">;
|
|
15374
|
+
disabled?: boolean;
|
|
15375
|
+
disabledInfo?: string;
|
|
15372
15376
|
allowPastDates?: boolean;
|
|
15373
15377
|
maxYearsFromNow?: number;
|
|
15374
15378
|
maxDate?: Date;
|
|
15375
15379
|
};
|
|
15376
|
-
declare const DateAndTimeFormField: ({ name, label, required, validate, validationErrorMessage, rules, allowPastDates, maxYearsFromNow, maxDate, ...props }: DateAndTimeFormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
15380
|
+
declare const DateAndTimeFormField: ({ name, label, required, validate, validationErrorMessage, rules, disabled, disabledInfo, allowPastDates, maxYearsFromNow, maxDate, ...props }: DateAndTimeFormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
15377
15381
|
|
|
15378
15382
|
interface UploadConfig {
|
|
15379
15383
|
apiUrl: string;
|
package/dist/index.js
CHANGED
|
@@ -8122,7 +8122,8 @@ function Calendar(_a) {
|
|
|
8122
8122
|
expand,
|
|
8123
8123
|
allowPastDates = false,
|
|
8124
8124
|
maxDate,
|
|
8125
|
-
maxYearsFromNow
|
|
8125
|
+
maxYearsFromNow,
|
|
8126
|
+
disabled = false
|
|
8126
8127
|
} = _b, props = __objRest(_b, [
|
|
8127
8128
|
"action",
|
|
8128
8129
|
"actionText",
|
|
@@ -8135,7 +8136,8 @@ function Calendar(_a) {
|
|
|
8135
8136
|
"expand",
|
|
8136
8137
|
"allowPastDates",
|
|
8137
8138
|
"maxDate",
|
|
8138
|
-
"maxYearsFromNow"
|
|
8139
|
+
"maxYearsFromNow",
|
|
8140
|
+
"disabled"
|
|
8139
8141
|
]);
|
|
8140
8142
|
const [inputValue, setInputValue] = (0, import_react8.useState)("");
|
|
8141
8143
|
const [showContainer, setShowCalendar] = (0, import_react8.useState)(false);
|
|
@@ -8194,6 +8196,7 @@ function Calendar(_a) {
|
|
|
8194
8196
|
inputMode: "numeric",
|
|
8195
8197
|
textAlign: "right",
|
|
8196
8198
|
color: hasError ? "error" : "default",
|
|
8199
|
+
disabled,
|
|
8197
8200
|
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TextFieldSlot, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Icon_default, { name: "calendar", size: "xl", color: "#4C4F54" }) })
|
|
8198
8201
|
}
|
|
8199
8202
|
)
|
|
@@ -8679,7 +8682,8 @@ function TimePicker({
|
|
|
8679
8682
|
setSelected,
|
|
8680
8683
|
position = "bottom",
|
|
8681
8684
|
hasError,
|
|
8682
|
-
expand = false
|
|
8685
|
+
expand = false,
|
|
8686
|
+
disabled = false
|
|
8683
8687
|
}) {
|
|
8684
8688
|
const [hours, setHours] = (0, import_react11.useState)("00");
|
|
8685
8689
|
const [minutes, setMinutes] = (0, import_react11.useState)("00");
|
|
@@ -8740,6 +8744,7 @@ function TimePicker({
|
|
|
8740
8744
|
typography: "labelSmall",
|
|
8741
8745
|
fontWeight: "regular",
|
|
8742
8746
|
color: hasError ? "error" : "default",
|
|
8747
|
+
disabled,
|
|
8743
8748
|
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextFieldSlot, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Icon_default, { name: "clock", size: "xl", color: "#4C4F54" }) })
|
|
8744
8749
|
}
|
|
8745
8750
|
)
|
|
@@ -13387,6 +13392,8 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13387
13392
|
validate,
|
|
13388
13393
|
validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
|
|
13389
13394
|
rules,
|
|
13395
|
+
disabled = false,
|
|
13396
|
+
disabledInfo = "Este campo est\xE1 desabilitado.",
|
|
13390
13397
|
allowPastDates,
|
|
13391
13398
|
maxYearsFromNow = 20,
|
|
13392
13399
|
maxDate
|
|
@@ -13397,10 +13404,34 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13397
13404
|
"validate",
|
|
13398
13405
|
"validationErrorMessage",
|
|
13399
13406
|
"rules",
|
|
13407
|
+
"disabled",
|
|
13408
|
+
"disabledInfo",
|
|
13400
13409
|
"allowPastDates",
|
|
13401
13410
|
"maxYearsFromNow",
|
|
13402
13411
|
"maxDate"
|
|
13403
13412
|
]);
|
|
13413
|
+
const { addToast } = useToast();
|
|
13414
|
+
const handleDisabledClick = (0, import_react28.useCallback)(
|
|
13415
|
+
(event) => {
|
|
13416
|
+
if (!disabled) return;
|
|
13417
|
+
event.preventDefault();
|
|
13418
|
+
event.stopPropagation();
|
|
13419
|
+
addToast({
|
|
13420
|
+
type: "error",
|
|
13421
|
+
icon: "xmark-circle",
|
|
13422
|
+
message: disabledInfo
|
|
13423
|
+
});
|
|
13424
|
+
},
|
|
13425
|
+
[addToast, disabled, disabledInfo]
|
|
13426
|
+
);
|
|
13427
|
+
const handleDisabledMouseDown = (0, import_react28.useCallback)(
|
|
13428
|
+
(event) => {
|
|
13429
|
+
if (!disabled) return;
|
|
13430
|
+
event.preventDefault();
|
|
13431
|
+
event.stopPropagation();
|
|
13432
|
+
},
|
|
13433
|
+
[disabled]
|
|
13434
|
+
);
|
|
13404
13435
|
const handleValidate = (0, import_react28.useCallback)(
|
|
13405
13436
|
(value) => {
|
|
13406
13437
|
var _a2;
|
|
@@ -13476,33 +13507,57 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13476
13507
|
haveError
|
|
13477
13508
|
}
|
|
13478
13509
|
),
|
|
13479
|
-
/* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13510
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
|
|
13511
|
+
Flex,
|
|
13512
|
+
{
|
|
13513
|
+
gap: 12,
|
|
13514
|
+
align: "start",
|
|
13515
|
+
style: disabled ? { position: "relative" } : void 0,
|
|
13516
|
+
children: [
|
|
13517
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Flex, { direction: "column", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
13518
|
+
Calendar,
|
|
13519
|
+
__spreadValues({
|
|
13520
|
+
selected: draftDate,
|
|
13521
|
+
setSelected: (date) => {
|
|
13522
|
+
const d = typeof date === "function" ? date(draftDate) : date;
|
|
13523
|
+
handleDateChange(d);
|
|
13524
|
+
},
|
|
13525
|
+
hasError: haveError,
|
|
13526
|
+
allowPastDates,
|
|
13527
|
+
maxYearsFromNow,
|
|
13528
|
+
maxDate,
|
|
13529
|
+
disabled
|
|
13530
|
+
}, props)
|
|
13531
|
+
) }),
|
|
13532
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Flex, { direction: "column", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
13533
|
+
TimePicker,
|
|
13534
|
+
__spreadValues({
|
|
13535
|
+
selected: draftTime,
|
|
13536
|
+
setSelected: (value) => {
|
|
13537
|
+
const time = typeof value === "function" ? value(draftTime) : value;
|
|
13538
|
+
handleTimeChange(time);
|
|
13539
|
+
},
|
|
13540
|
+
disabled,
|
|
13541
|
+
hasError: haveError
|
|
13542
|
+
}, props)
|
|
13543
|
+
) }),
|
|
13544
|
+
disabled && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
13545
|
+
"div",
|
|
13546
|
+
{
|
|
13547
|
+
"aria-hidden": true,
|
|
13548
|
+
style: {
|
|
13549
|
+
position: "absolute",
|
|
13550
|
+
inset: 0,
|
|
13551
|
+
zIndex: 1,
|
|
13552
|
+
cursor: "not-allowed"
|
|
13553
|
+
},
|
|
13554
|
+
onClick: handleDisabledClick,
|
|
13555
|
+
onMouseDown: handleDisabledMouseDown
|
|
13556
|
+
}
|
|
13557
|
+
)
|
|
13558
|
+
]
|
|
13559
|
+
}
|
|
13560
|
+
),
|
|
13506
13561
|
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(ErrorFormMessage, { message: errorMsg })
|
|
13507
13562
|
] });
|
|
13508
13563
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -8006,7 +8006,8 @@ function Calendar(_a) {
|
|
|
8006
8006
|
expand,
|
|
8007
8007
|
allowPastDates = false,
|
|
8008
8008
|
maxDate,
|
|
8009
|
-
maxYearsFromNow
|
|
8009
|
+
maxYearsFromNow,
|
|
8010
|
+
disabled = false
|
|
8010
8011
|
} = _b, props = __objRest(_b, [
|
|
8011
8012
|
"action",
|
|
8012
8013
|
"actionText",
|
|
@@ -8019,7 +8020,8 @@ function Calendar(_a) {
|
|
|
8019
8020
|
"expand",
|
|
8020
8021
|
"allowPastDates",
|
|
8021
8022
|
"maxDate",
|
|
8022
|
-
"maxYearsFromNow"
|
|
8023
|
+
"maxYearsFromNow",
|
|
8024
|
+
"disabled"
|
|
8023
8025
|
]);
|
|
8024
8026
|
const [inputValue, setInputValue] = useState2("");
|
|
8025
8027
|
const [showContainer, setShowCalendar] = useState2(false);
|
|
@@ -8078,6 +8080,7 @@ function Calendar(_a) {
|
|
|
8078
8080
|
inputMode: "numeric",
|
|
8079
8081
|
textAlign: "right",
|
|
8080
8082
|
color: hasError ? "error" : "default",
|
|
8083
|
+
disabled,
|
|
8081
8084
|
children: /* @__PURE__ */ jsx15(TextFieldSlot, { children: /* @__PURE__ */ jsx15(Icon_default, { name: "calendar", size: "xl", color: "#4C4F54" }) })
|
|
8082
8085
|
}
|
|
8083
8086
|
)
|
|
@@ -8563,7 +8566,8 @@ function TimePicker({
|
|
|
8563
8566
|
setSelected,
|
|
8564
8567
|
position = "bottom",
|
|
8565
8568
|
hasError,
|
|
8566
|
-
expand = false
|
|
8569
|
+
expand = false,
|
|
8570
|
+
disabled = false
|
|
8567
8571
|
}) {
|
|
8568
8572
|
const [hours, setHours] = useState4("00");
|
|
8569
8573
|
const [minutes, setMinutes] = useState4("00");
|
|
@@ -8624,6 +8628,7 @@ function TimePicker({
|
|
|
8624
8628
|
typography: "labelSmall",
|
|
8625
8629
|
fontWeight: "regular",
|
|
8626
8630
|
color: hasError ? "error" : "default",
|
|
8631
|
+
disabled,
|
|
8627
8632
|
children: /* @__PURE__ */ jsx18(TextFieldSlot, { children: /* @__PURE__ */ jsx18(Icon_default, { name: "clock", size: "xl", color: "#4C4F54" }) })
|
|
8628
8633
|
}
|
|
8629
8634
|
)
|
|
@@ -13280,6 +13285,8 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13280
13285
|
validate,
|
|
13281
13286
|
validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
|
|
13282
13287
|
rules,
|
|
13288
|
+
disabled = false,
|
|
13289
|
+
disabledInfo = "Este campo est\xE1 desabilitado.",
|
|
13283
13290
|
allowPastDates,
|
|
13284
13291
|
maxYearsFromNow = 20,
|
|
13285
13292
|
maxDate
|
|
@@ -13290,10 +13297,34 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13290
13297
|
"validate",
|
|
13291
13298
|
"validationErrorMessage",
|
|
13292
13299
|
"rules",
|
|
13300
|
+
"disabled",
|
|
13301
|
+
"disabledInfo",
|
|
13293
13302
|
"allowPastDates",
|
|
13294
13303
|
"maxYearsFromNow",
|
|
13295
13304
|
"maxDate"
|
|
13296
13305
|
]);
|
|
13306
|
+
const { addToast } = useToast();
|
|
13307
|
+
const handleDisabledClick = useCallback8(
|
|
13308
|
+
(event) => {
|
|
13309
|
+
if (!disabled) return;
|
|
13310
|
+
event.preventDefault();
|
|
13311
|
+
event.stopPropagation();
|
|
13312
|
+
addToast({
|
|
13313
|
+
type: "error",
|
|
13314
|
+
icon: "xmark-circle",
|
|
13315
|
+
message: disabledInfo
|
|
13316
|
+
});
|
|
13317
|
+
},
|
|
13318
|
+
[addToast, disabled, disabledInfo]
|
|
13319
|
+
);
|
|
13320
|
+
const handleDisabledMouseDown = useCallback8(
|
|
13321
|
+
(event) => {
|
|
13322
|
+
if (!disabled) return;
|
|
13323
|
+
event.preventDefault();
|
|
13324
|
+
event.stopPropagation();
|
|
13325
|
+
},
|
|
13326
|
+
[disabled]
|
|
13327
|
+
);
|
|
13297
13328
|
const handleValidate = useCallback8(
|
|
13298
13329
|
(value) => {
|
|
13299
13330
|
var _a2;
|
|
@@ -13369,33 +13400,57 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13369
13400
|
haveError
|
|
13370
13401
|
}
|
|
13371
13402
|
),
|
|
13372
|
-
/* @__PURE__ */ jsxs33(
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13403
|
+
/* @__PURE__ */ jsxs33(
|
|
13404
|
+
Flex,
|
|
13405
|
+
{
|
|
13406
|
+
gap: 12,
|
|
13407
|
+
align: "start",
|
|
13408
|
+
style: disabled ? { position: "relative" } : void 0,
|
|
13409
|
+
children: [
|
|
13410
|
+
/* @__PURE__ */ jsx59(Flex, { direction: "column", children: /* @__PURE__ */ jsx59(
|
|
13411
|
+
Calendar,
|
|
13412
|
+
__spreadValues({
|
|
13413
|
+
selected: draftDate,
|
|
13414
|
+
setSelected: (date) => {
|
|
13415
|
+
const d = typeof date === "function" ? date(draftDate) : date;
|
|
13416
|
+
handleDateChange(d);
|
|
13417
|
+
},
|
|
13418
|
+
hasError: haveError,
|
|
13419
|
+
allowPastDates,
|
|
13420
|
+
maxYearsFromNow,
|
|
13421
|
+
maxDate,
|
|
13422
|
+
disabled
|
|
13423
|
+
}, props)
|
|
13424
|
+
) }),
|
|
13425
|
+
/* @__PURE__ */ jsx59(Flex, { direction: "column", children: /* @__PURE__ */ jsx59(
|
|
13426
|
+
TimePicker,
|
|
13427
|
+
__spreadValues({
|
|
13428
|
+
selected: draftTime,
|
|
13429
|
+
setSelected: (value) => {
|
|
13430
|
+
const time = typeof value === "function" ? value(draftTime) : value;
|
|
13431
|
+
handleTimeChange(time);
|
|
13432
|
+
},
|
|
13433
|
+
disabled,
|
|
13434
|
+
hasError: haveError
|
|
13435
|
+
}, props)
|
|
13436
|
+
) }),
|
|
13437
|
+
disabled && /* @__PURE__ */ jsx59(
|
|
13438
|
+
"div",
|
|
13439
|
+
{
|
|
13440
|
+
"aria-hidden": true,
|
|
13441
|
+
style: {
|
|
13442
|
+
position: "absolute",
|
|
13443
|
+
inset: 0,
|
|
13444
|
+
zIndex: 1,
|
|
13445
|
+
cursor: "not-allowed"
|
|
13446
|
+
},
|
|
13447
|
+
onClick: handleDisabledClick,
|
|
13448
|
+
onMouseDown: handleDisabledMouseDown
|
|
13449
|
+
}
|
|
13450
|
+
)
|
|
13451
|
+
]
|
|
13452
|
+
}
|
|
13453
|
+
),
|
|
13399
13454
|
/* @__PURE__ */ jsx59(ErrorFormMessage, { message: errorMsg })
|
|
13400
13455
|
] });
|
|
13401
13456
|
};
|
package/package.json
CHANGED
|
@@ -28,6 +28,7 @@ export type CalendarProps = ComponentProps<typeof CalendarStyled> & {
|
|
|
28
28
|
allowPastDates?: boolean;
|
|
29
29
|
maxDate?: Date;
|
|
30
30
|
maxYearsFromNow?: number;
|
|
31
|
+
disabled?: boolean;
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
function formatToDateMask(value: string): string {
|
|
@@ -51,6 +52,7 @@ export function Calendar({
|
|
|
51
52
|
allowPastDates = false,
|
|
52
53
|
maxDate,
|
|
53
54
|
maxYearsFromNow,
|
|
55
|
+
disabled = false,
|
|
54
56
|
...props
|
|
55
57
|
}: CalendarProps) {
|
|
56
58
|
const [inputValue, setInputValue] = useState("");
|
|
@@ -117,6 +119,7 @@ export function Calendar({
|
|
|
117
119
|
inputMode="numeric"
|
|
118
120
|
textAlign={"right"}
|
|
119
121
|
color={hasError ? "error" : "default"}
|
|
122
|
+
disabled={disabled}
|
|
120
123
|
>
|
|
121
124
|
<TextFieldSlot>
|
|
122
125
|
<Icon name="calendar" size={"xl"} color="#4C4F54" />
|
|
@@ -4,7 +4,8 @@ import { FormLabel } from "./subComponents/FormLabel";
|
|
|
4
4
|
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
5
|
import { Calendar, CalendarProps } from "../Calendar";
|
|
6
6
|
import { TimePicker, TimePickerProps } from "../TimePicker";
|
|
7
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
|
+
import { useCallback, useEffect, useMemo, useState, type SyntheticEvent } from "react";
|
|
8
|
+
import { useToast } from "../Toast/hooks/useToast";
|
|
8
9
|
|
|
9
10
|
export type DateAndTimeFormFieldProps = Omit<
|
|
10
11
|
CalendarProps,
|
|
@@ -22,6 +23,8 @@ export type DateAndTimeFormFieldProps = Omit<
|
|
|
22
23
|
RegisterOptions<FieldValues, string>,
|
|
23
24
|
"valueAsNumber" | "valueAsDate" | "setValueAs" | "disabled"
|
|
24
25
|
>;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
disabledInfo?: string;
|
|
25
28
|
allowPastDates?: boolean;
|
|
26
29
|
maxYearsFromNow?: number;
|
|
27
30
|
maxDate?: Date;
|
|
@@ -34,11 +37,38 @@ export const DateAndTimeFormField = ({
|
|
|
34
37
|
validate,
|
|
35
38
|
validationErrorMessage = "Este campo é obrigatório.",
|
|
36
39
|
rules,
|
|
40
|
+
disabled = false,
|
|
41
|
+
disabledInfo = "Este campo está desabilitado.",
|
|
37
42
|
allowPastDates,
|
|
38
43
|
maxYearsFromNow = 20,
|
|
39
44
|
maxDate,
|
|
40
45
|
...props
|
|
41
46
|
}: DateAndTimeFormFieldProps) => {
|
|
47
|
+
const { addToast } = useToast();
|
|
48
|
+
|
|
49
|
+
const handleDisabledClick = useCallback(
|
|
50
|
+
(event: SyntheticEvent) => {
|
|
51
|
+
if (!disabled) return;
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
addToast({
|
|
55
|
+
type: "error",
|
|
56
|
+
icon: "xmark-circle",
|
|
57
|
+
message: disabledInfo,
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
[addToast, disabled, disabledInfo]
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const handleDisabledMouseDown = useCallback(
|
|
64
|
+
(event: SyntheticEvent) => {
|
|
65
|
+
if (!disabled) return;
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
},
|
|
69
|
+
[disabled]
|
|
70
|
+
);
|
|
71
|
+
|
|
42
72
|
const handleValidate = useCallback(
|
|
43
73
|
(value?: string) => {
|
|
44
74
|
if (value === undefined || value === null || value === "") {
|
|
@@ -130,7 +160,11 @@ export const DateAndTimeFormField = ({
|
|
|
130
160
|
/>
|
|
131
161
|
)}
|
|
132
162
|
|
|
133
|
-
<Flex
|
|
163
|
+
<Flex
|
|
164
|
+
gap={12}
|
|
165
|
+
align="start"
|
|
166
|
+
style={disabled ? { position: "relative" } : undefined}
|
|
167
|
+
>
|
|
134
168
|
<Flex direction="column">
|
|
135
169
|
<Calendar
|
|
136
170
|
selected={draftDate}
|
|
@@ -142,6 +176,7 @@ export const DateAndTimeFormField = ({
|
|
|
142
176
|
allowPastDates={allowPastDates}
|
|
143
177
|
maxYearsFromNow={maxYearsFromNow}
|
|
144
178
|
maxDate={maxDate}
|
|
179
|
+
disabled={disabled}
|
|
145
180
|
{...(props as Omit<CalendarProps, "selected" | "setSelected">)}
|
|
146
181
|
/>
|
|
147
182
|
</Flex>
|
|
@@ -153,10 +188,25 @@ export const DateAndTimeFormField = ({
|
|
|
153
188
|
const time = typeof value === "function" ? value(draftTime) : value;
|
|
154
189
|
handleTimeChange(time);
|
|
155
190
|
}}
|
|
191
|
+
disabled={disabled}
|
|
156
192
|
hasError={haveError}
|
|
157
193
|
{...(props as Omit<TimePickerProps, "selected" | "setSelected">)}
|
|
158
194
|
/>
|
|
159
195
|
</Flex>
|
|
196
|
+
|
|
197
|
+
{disabled && (
|
|
198
|
+
<div
|
|
199
|
+
aria-hidden
|
|
200
|
+
style={{
|
|
201
|
+
position: "absolute",
|
|
202
|
+
inset: 0,
|
|
203
|
+
zIndex: 1,
|
|
204
|
+
cursor: "not-allowed",
|
|
205
|
+
}}
|
|
206
|
+
onClick={handleDisabledClick}
|
|
207
|
+
onMouseDown={handleDisabledMouseDown}
|
|
208
|
+
/>
|
|
209
|
+
)}
|
|
160
210
|
</Flex>
|
|
161
211
|
|
|
162
212
|
<ErrorFormMessage message={errorMsg} />
|
|
@@ -131,6 +131,7 @@ export type TimePickerProps = {
|
|
|
131
131
|
position?: "bottom" | "top" | "top-right" | "bottom-right";
|
|
132
132
|
hasError?: boolean;
|
|
133
133
|
expand?: boolean;
|
|
134
|
+
disabled?: boolean;
|
|
134
135
|
};
|
|
135
136
|
const pad = (num: number) => String(num).padStart(2, "0");
|
|
136
137
|
|
|
@@ -158,6 +159,7 @@ export function TimePicker({
|
|
|
158
159
|
position = "bottom",
|
|
159
160
|
hasError,
|
|
160
161
|
expand = false,
|
|
162
|
+
disabled = false,
|
|
161
163
|
}: TimePickerProps) {
|
|
162
164
|
const [hours, setHours] = useState("00");
|
|
163
165
|
const [minutes, setMinutes] = useState("00");
|
|
@@ -220,6 +222,7 @@ export function TimePicker({
|
|
|
220
222
|
typography="labelSmall"
|
|
221
223
|
fontWeight="regular"
|
|
222
224
|
color={hasError ? "error" : "default"}
|
|
225
|
+
disabled={disabled}
|
|
223
226
|
>
|
|
224
227
|
<TextFieldSlot>
|
|
225
228
|
<Icon name="clock" size="xl" color="#4C4F54" />
|