@lets-events/react 12.8.5 → 12.9.0
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 +46 -10
- package/dist/index.mjs +46 -10
- package/package.json +1 -1
- package/src/components/Calendar/index.tsx +4 -1
- package/src/components/FormFields/DateAndTimeFormField.tsx +40 -3
- package/src/components/TimePicker.tsx +4 -1
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.0 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
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
15
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m414.81 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 532ms
|
|
15
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m399.34 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 533ms
|
|
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 9136ms
|
|
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,7 +8196,8 @@ function Calendar(_a) {
|
|
|
8194
8196
|
inputMode: "numeric",
|
|
8195
8197
|
textAlign: "right",
|
|
8196
8198
|
color: hasError ? "error" : "default",
|
|
8197
|
-
|
|
8199
|
+
disabled,
|
|
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
|
)
|
|
8200
8203
|
}
|
|
@@ -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,7 +8744,8 @@ function TimePicker({
|
|
|
8740
8744
|
typography: "labelSmall",
|
|
8741
8745
|
fontWeight: "regular",
|
|
8742
8746
|
color: hasError ? "error" : "default",
|
|
8743
|
-
|
|
8747
|
+
disabled,
|
|
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
|
)
|
|
8746
8751
|
}
|
|
@@ -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,37 @@ 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
|
+
message: disabledInfo
|
|
13422
|
+
});
|
|
13423
|
+
},
|
|
13424
|
+
[addToast, disabled, disabledInfo]
|
|
13425
|
+
);
|
|
13426
|
+
const handleDisabledMouseDown = (0, import_react28.useCallback)(
|
|
13427
|
+
(event) => {
|
|
13428
|
+
if (!disabled) return;
|
|
13429
|
+
event.preventDefault();
|
|
13430
|
+
event.stopPropagation();
|
|
13431
|
+
},
|
|
13432
|
+
[disabled]
|
|
13433
|
+
);
|
|
13434
|
+
const disabledInteractionProps = disabled ? {
|
|
13435
|
+
onClickCapture: handleDisabledClick,
|
|
13436
|
+
onMouseDownCapture: handleDisabledMouseDown
|
|
13437
|
+
} : void 0;
|
|
13404
13438
|
const handleValidate = (0, import_react28.useCallback)(
|
|
13405
13439
|
(value) => {
|
|
13406
13440
|
var _a2;
|
|
@@ -13477,7 +13511,7 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13477
13511
|
}
|
|
13478
13512
|
),
|
|
13479
13513
|
/* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Flex, { gap: 12, align: "start", children: [
|
|
13480
|
-
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Flex, { direction: "column", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
13514
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Flex, __spreadProps(__spreadValues({ direction: "column" }, disabledInteractionProps != null ? disabledInteractionProps : {}), { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
13481
13515
|
Calendar,
|
|
13482
13516
|
__spreadValues({
|
|
13483
13517
|
selected: draftDate,
|
|
@@ -13488,10 +13522,11 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13488
13522
|
hasError: haveError,
|
|
13489
13523
|
allowPastDates,
|
|
13490
13524
|
maxYearsFromNow,
|
|
13491
|
-
maxDate
|
|
13525
|
+
maxDate,
|
|
13526
|
+
disabled
|
|
13492
13527
|
}, props)
|
|
13493
|
-
) }),
|
|
13494
|
-
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Flex, { direction: "column", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
13528
|
+
) })),
|
|
13529
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Flex, __spreadProps(__spreadValues({ direction: "column" }, disabledInteractionProps != null ? disabledInteractionProps : {}), { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
13495
13530
|
TimePicker,
|
|
13496
13531
|
__spreadValues({
|
|
13497
13532
|
selected: draftTime,
|
|
@@ -13499,9 +13534,10 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13499
13534
|
const time = typeof value === "function" ? value(draftTime) : value;
|
|
13500
13535
|
handleTimeChange(time);
|
|
13501
13536
|
},
|
|
13537
|
+
disabled,
|
|
13502
13538
|
hasError: haveError
|
|
13503
13539
|
}, props)
|
|
13504
|
-
) })
|
|
13540
|
+
) }))
|
|
13505
13541
|
] }),
|
|
13506
13542
|
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(ErrorFormMessage, { message: errorMsg })
|
|
13507
13543
|
] });
|
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,7 +8080,8 @@ function Calendar(_a) {
|
|
|
8078
8080
|
inputMode: "numeric",
|
|
8079
8081
|
textAlign: "right",
|
|
8080
8082
|
color: hasError ? "error" : "default",
|
|
8081
|
-
|
|
8083
|
+
disabled,
|
|
8084
|
+
children: /* @__PURE__ */ jsx15(TextFieldSlot, { children: /* @__PURE__ */ jsx15(Icon_default, { name: "calendar", size: "xl", color: "#4C4F54" }) })
|
|
8082
8085
|
}
|
|
8083
8086
|
)
|
|
8084
8087
|
}
|
|
@@ -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,7 +8628,8 @@ function TimePicker({
|
|
|
8624
8628
|
typography: "labelSmall",
|
|
8625
8629
|
fontWeight: "regular",
|
|
8626
8630
|
color: hasError ? "error" : "default",
|
|
8627
|
-
|
|
8631
|
+
disabled,
|
|
8632
|
+
children: /* @__PURE__ */ jsx18(TextFieldSlot, { children: /* @__PURE__ */ jsx18(Icon_default, { name: "clock", size: "xl", color: "#4C4F54" }) })
|
|
8628
8633
|
}
|
|
8629
8634
|
)
|
|
8630
8635
|
}
|
|
@@ -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,37 @@ 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
|
+
message: disabledInfo
|
|
13315
|
+
});
|
|
13316
|
+
},
|
|
13317
|
+
[addToast, disabled, disabledInfo]
|
|
13318
|
+
);
|
|
13319
|
+
const handleDisabledMouseDown = useCallback8(
|
|
13320
|
+
(event) => {
|
|
13321
|
+
if (!disabled) return;
|
|
13322
|
+
event.preventDefault();
|
|
13323
|
+
event.stopPropagation();
|
|
13324
|
+
},
|
|
13325
|
+
[disabled]
|
|
13326
|
+
);
|
|
13327
|
+
const disabledInteractionProps = disabled ? {
|
|
13328
|
+
onClickCapture: handleDisabledClick,
|
|
13329
|
+
onMouseDownCapture: handleDisabledMouseDown
|
|
13330
|
+
} : void 0;
|
|
13297
13331
|
const handleValidate = useCallback8(
|
|
13298
13332
|
(value) => {
|
|
13299
13333
|
var _a2;
|
|
@@ -13370,7 +13404,7 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13370
13404
|
}
|
|
13371
13405
|
),
|
|
13372
13406
|
/* @__PURE__ */ jsxs33(Flex, { gap: 12, align: "start", children: [
|
|
13373
|
-
/* @__PURE__ */ jsx59(Flex, { direction: "column", children: /* @__PURE__ */ jsx59(
|
|
13407
|
+
/* @__PURE__ */ jsx59(Flex, __spreadProps(__spreadValues({ direction: "column" }, disabledInteractionProps != null ? disabledInteractionProps : {}), { children: /* @__PURE__ */ jsx59(
|
|
13374
13408
|
Calendar,
|
|
13375
13409
|
__spreadValues({
|
|
13376
13410
|
selected: draftDate,
|
|
@@ -13381,10 +13415,11 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13381
13415
|
hasError: haveError,
|
|
13382
13416
|
allowPastDates,
|
|
13383
13417
|
maxYearsFromNow,
|
|
13384
|
-
maxDate
|
|
13418
|
+
maxDate,
|
|
13419
|
+
disabled
|
|
13385
13420
|
}, props)
|
|
13386
|
-
) }),
|
|
13387
|
-
/* @__PURE__ */ jsx59(Flex, { direction: "column", children: /* @__PURE__ */ jsx59(
|
|
13421
|
+
) })),
|
|
13422
|
+
/* @__PURE__ */ jsx59(Flex, __spreadProps(__spreadValues({ direction: "column" }, disabledInteractionProps != null ? disabledInteractionProps : {}), { children: /* @__PURE__ */ jsx59(
|
|
13388
13423
|
TimePicker,
|
|
13389
13424
|
__spreadValues({
|
|
13390
13425
|
selected: draftTime,
|
|
@@ -13392,9 +13427,10 @@ var DateAndTimeFormField = (_a) => {
|
|
|
13392
13427
|
const time = typeof value === "function" ? value(draftTime) : value;
|
|
13393
13428
|
handleTimeChange(time);
|
|
13394
13429
|
},
|
|
13430
|
+
disabled,
|
|
13395
13431
|
hasError: haveError
|
|
13396
13432
|
}, props)
|
|
13397
|
-
) })
|
|
13433
|
+
) }))
|
|
13398
13434
|
] }),
|
|
13399
13435
|
/* @__PURE__ */ jsx59(ErrorFormMessage, { message: errorMsg })
|
|
13400
13436
|
] });
|
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,9 +119,10 @@ 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
|
-
<Icon name="calendar" size={"xl"} />
|
|
125
|
+
<Icon name="calendar" size={"xl"} color="#4C4F54" />
|
|
123
126
|
</TextFieldSlot>
|
|
124
127
|
</TextField>
|
|
125
128
|
</CalendarButtonStyled>
|
|
@@ -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,43 @@ 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
|
+
message: disabledInfo,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
[addToast, disabled, disabledInfo]
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const handleDisabledMouseDown = useCallback(
|
|
63
|
+
(event: SyntheticEvent) => {
|
|
64
|
+
if (!disabled) return;
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
event.stopPropagation();
|
|
67
|
+
},
|
|
68
|
+
[disabled]
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const disabledInteractionProps = disabled
|
|
72
|
+
? {
|
|
73
|
+
onClickCapture: handleDisabledClick,
|
|
74
|
+
onMouseDownCapture: handleDisabledMouseDown,
|
|
75
|
+
}
|
|
76
|
+
: undefined;
|
|
42
77
|
const handleValidate = useCallback(
|
|
43
78
|
(value?: string) => {
|
|
44
79
|
if (value === undefined || value === null || value === "") {
|
|
@@ -131,7 +166,7 @@ export const DateAndTimeFormField = ({
|
|
|
131
166
|
)}
|
|
132
167
|
|
|
133
168
|
<Flex gap={12} align="start">
|
|
134
|
-
<Flex direction="column">
|
|
169
|
+
<Flex direction="column" {...(disabledInteractionProps ?? {})}>
|
|
135
170
|
<Calendar
|
|
136
171
|
selected={draftDate}
|
|
137
172
|
setSelected={(date) => {
|
|
@@ -142,17 +177,19 @@ export const DateAndTimeFormField = ({
|
|
|
142
177
|
allowPastDates={allowPastDates}
|
|
143
178
|
maxYearsFromNow={maxYearsFromNow}
|
|
144
179
|
maxDate={maxDate}
|
|
180
|
+
disabled={disabled}
|
|
145
181
|
{...(props as Omit<CalendarProps, "selected" | "setSelected">)}
|
|
146
182
|
/>
|
|
147
183
|
</Flex>
|
|
148
184
|
|
|
149
|
-
<Flex direction="column">
|
|
185
|
+
<Flex direction="column" {...(disabledInteractionProps ?? {})}>
|
|
150
186
|
<TimePicker
|
|
151
187
|
selected={draftTime}
|
|
152
188
|
setSelected={(value) => {
|
|
153
189
|
const time = typeof value === "function" ? value(draftTime) : value;
|
|
154
190
|
handleTimeChange(time);
|
|
155
191
|
}}
|
|
192
|
+
disabled={disabled}
|
|
156
193
|
hasError={haveError}
|
|
157
194
|
{...(props as Omit<TimePickerProps, "selected" | "setSelected">)}
|
|
158
195
|
/>
|
|
@@ -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,9 +222,10 @@ 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
|
-
<Icon name="clock" size="xl" />
|
|
228
|
+
<Icon name="clock" size="xl" color="#4C4F54" />
|
|
226
229
|
</TextFieldSlot>
|
|
227
230
|
</TextField>
|
|
228
231
|
</TimePickerButtonStyled>
|