myoperator-mcp 0.2.382 → 0.2.384
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.js +172 -104
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3473,12 +3473,23 @@ import {
|
|
|
3473
3473
|
type Strategy,
|
|
3474
3474
|
} from "@floating-ui/react-dom";
|
|
3475
3475
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
3476
|
-
import {
|
|
3476
|
+
import {
|
|
3477
|
+
ChevronDown,
|
|
3478
|
+
ChevronLeft,
|
|
3479
|
+
ChevronRight,
|
|
3480
|
+
Clock2,
|
|
3481
|
+
X,
|
|
3482
|
+
} from "lucide-react";
|
|
3477
3483
|
|
|
3478
3484
|
import { cn } from "@/lib/utils";
|
|
3479
3485
|
|
|
3480
3486
|
const DEFAULT_START_TIME = "10:30:00";
|
|
3481
|
-
|
|
3487
|
+
/**
|
|
3488
|
+
* What the time columns show while no time is selected. Clearing the value
|
|
3489
|
+
* returns the picker to this state, so an unset time always reads 12:00 AM
|
|
3490
|
+
* rather than re-proposing the sample default.
|
|
3491
|
+
*/
|
|
3492
|
+
const UNSET_TIME = "00:00:00";
|
|
3482
3493
|
const DEFAULT_MINUTE_STEP = 5;
|
|
3483
3494
|
const DEFAULT_SECOND_STEP = 5;
|
|
3484
3495
|
const TIME_COLUMN_MAX_HEIGHT = 168;
|
|
@@ -3553,7 +3564,9 @@ const dateTimePickerTriggerVariants = cva(
|
|
|
3553
3564
|
|
|
3554
3565
|
export interface DateTimePickerValue {
|
|
3555
3566
|
date?: Date;
|
|
3567
|
+
/** Empty string until a time is explicitly selected */
|
|
3556
3568
|
startTime: string;
|
|
3569
|
+
/** Empty string until a time is explicitly selected */
|
|
3557
3570
|
endTime: string;
|
|
3558
3571
|
}
|
|
3559
3572
|
|
|
@@ -3562,8 +3575,8 @@ export interface DateTimePickerProps
|
|
|
3562
3575
|
Omit<React.HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange">,
|
|
3563
3576
|
VariantProps<typeof dateTimePickerVariants>,
|
|
3564
3577
|
Pick<VariantProps<typeof dateTimePickerTriggerVariants>, "state"> {
|
|
3565
|
-
value?: DateTimePickerValue
|
|
3566
|
-
defaultValue?: DateTimePickerValue
|
|
3578
|
+
value?: Partial<DateTimePickerValue>;
|
|
3579
|
+
defaultValue?: Partial<DateTimePickerValue>;
|
|
3567
3580
|
onValueChange?: (value: DateTimePickerValue) => void;
|
|
3568
3581
|
/** Label text displayed above the trigger */
|
|
3569
3582
|
label?: string;
|
|
@@ -3571,6 +3584,10 @@ export interface DateTimePickerProps
|
|
|
3571
3584
|
required?: boolean;
|
|
3572
3585
|
/** Additional class for the label */
|
|
3573
3586
|
labelClassName?: string;
|
|
3587
|
+
/** Helper text displayed below the picker */
|
|
3588
|
+
helperText?: string;
|
|
3589
|
+
/** Error message \u2014 shows red text below and drives state="error" */
|
|
3590
|
+
error?: string;
|
|
3574
3591
|
placeholder?: string;
|
|
3575
3592
|
disabled?: boolean;
|
|
3576
3593
|
readOnly?: boolean;
|
|
@@ -3608,8 +3625,8 @@ function normalizeValue(
|
|
|
3608
3625
|
): DateTimePickerValue {
|
|
3609
3626
|
return {
|
|
3610
3627
|
date: value?.date,
|
|
3611
|
-
startTime: value?.startTime ??
|
|
3612
|
-
endTime: value?.endTime ??
|
|
3628
|
+
startTime: value?.startTime ?? "",
|
|
3629
|
+
endTime: value?.endTime ?? "",
|
|
3613
3630
|
};
|
|
3614
3631
|
}
|
|
3615
3632
|
|
|
@@ -3886,7 +3903,6 @@ function formatValueForDisplay(
|
|
|
3886
3903
|
value: DateTimePickerValue,
|
|
3887
3904
|
variant: DateTimePickerVariant,
|
|
3888
3905
|
showEndTime: boolean,
|
|
3889
|
-
hasTimeValue: boolean,
|
|
3890
3906
|
showSeconds: boolean
|
|
3891
3907
|
) {
|
|
3892
3908
|
if (variant === "date-only") {
|
|
@@ -3894,14 +3910,21 @@ function formatValueForDisplay(
|
|
|
3894
3910
|
}
|
|
3895
3911
|
|
|
3896
3912
|
if (variant === "time-only") {
|
|
3897
|
-
if (!
|
|
3913
|
+
if (!value.startTime && !value.endTime) return "";
|
|
3898
3914
|
|
|
3899
3915
|
return showEndTime
|
|
3900
|
-
? \`\${formatTimeForDisplay(value.startTime, showSeconds)} - \${formatTimeForDisplay(value.endTime, showSeconds)}\`
|
|
3901
|
-
: formatTimeForDisplay(value.startTime, showSeconds);
|
|
3916
|
+
? \`\${formatTimeForDisplay(value.startTime || UNSET_TIME, showSeconds)} - \${formatTimeForDisplay(value.endTime || UNSET_TIME, showSeconds)}\`
|
|
3917
|
+
: formatTimeForDisplay(value.startTime || UNSET_TIME, showSeconds);
|
|
3902
3918
|
}
|
|
3903
3919
|
|
|
3904
|
-
|
|
3920
|
+
const datePart = formatDateOnlyForDisplay(value.date);
|
|
3921
|
+
const timePart = value.startTime
|
|
3922
|
+
? formatTimeForDisplay(value.startTime, showSeconds)
|
|
3923
|
+
: "";
|
|
3924
|
+
|
|
3925
|
+
if (!datePart && !timePart) return "";
|
|
3926
|
+
|
|
3927
|
+
return [datePart, timePart].filter(Boolean).join(" ");
|
|
3905
3928
|
}
|
|
3906
3929
|
|
|
3907
3930
|
function getDefaultPlaceholder(
|
|
@@ -4088,10 +4111,7 @@ function splitTypedDateInput(value: string) {
|
|
|
4088
4111
|
dateSource.split(/[/-]/);
|
|
4089
4112
|
const dayResult = consumeDigits(dayPart, 2);
|
|
4090
4113
|
const monthResult = consumeDigits(\`\${dayResult.rest}\${monthPart}\`, 2);
|
|
4091
|
-
const yearResult = consumeDigits(
|
|
4092
|
-
\`\${monthResult.rest}\${yearPart}\`,
|
|
4093
|
-
4
|
|
4094
|
-
);
|
|
4114
|
+
const yearResult = consumeDigits(\`\${monthResult.rest}\${yearPart}\`, 4);
|
|
4095
4115
|
const day = dayResult.digits;
|
|
4096
4116
|
const month = monthResult.digits;
|
|
4097
4117
|
const year = yearResult.digits;
|
|
@@ -4129,7 +4149,10 @@ function splitTypedDateInput(value: string) {
|
|
|
4129
4149
|
};
|
|
4130
4150
|
}
|
|
4131
4151
|
|
|
4132
|
-
function isPotentiallyValidTimeDigits(
|
|
4152
|
+
function isPotentiallyValidTimeDigits(
|
|
4153
|
+
timeDigits: string,
|
|
4154
|
+
showSeconds: boolean
|
|
4155
|
+
) {
|
|
4133
4156
|
const hourValue = timeDigits.slice(0, 2);
|
|
4134
4157
|
const minuteValue = timeDigits.slice(2, 4);
|
|
4135
4158
|
const secondValue = showSeconds ? timeDigits.slice(4, 6) : "";
|
|
@@ -4163,7 +4186,10 @@ function formatTimeInput(restValue: string, showSeconds: boolean) {
|
|
|
4163
4186
|
const meridiem = formatMeridiemInput(meridiemLetters.slice(0, 2));
|
|
4164
4187
|
|
|
4165
4188
|
if (!timeDigits && !meridiem) return "";
|
|
4166
|
-
if (
|
|
4189
|
+
if (
|
|
4190
|
+
!isPotentiallyValidTimeDigits(timeDigits, showSeconds) ||
|
|
4191
|
+
meridiem === null
|
|
4192
|
+
) {
|
|
4167
4193
|
return null;
|
|
4168
4194
|
}
|
|
4169
4195
|
|
|
@@ -4183,7 +4209,8 @@ function sanitizeTypedDateInput(value: string, previousValue: string) {
|
|
|
4183
4209
|
if (/^[A-Za-z]/.test(trimmedValue)) return previousValue;
|
|
4184
4210
|
|
|
4185
4211
|
const normalizedValue = value.toUpperCase().replace(/[^0-9\\s/-]/g, "");
|
|
4186
|
-
const { dateDigits, dateValue, isValid } =
|
|
4212
|
+
const { dateDigits, dateValue, isValid } =
|
|
4213
|
+
splitTypedDateInput(normalizedValue);
|
|
4187
4214
|
const limitedDateDigits = dateDigits.slice(0, 8);
|
|
4188
4215
|
|
|
4189
4216
|
if (!limitedDateDigits) return "";
|
|
@@ -4217,9 +4244,7 @@ function sanitizeTypedDateTimeInput(
|
|
|
4217
4244
|
const trimmedValue = value.trimStart();
|
|
4218
4245
|
if (/^[A-Za-z]/.test(trimmedValue)) return previousValue;
|
|
4219
4246
|
|
|
4220
|
-
const normalizedValue = value
|
|
4221
|
-
.toUpperCase()
|
|
4222
|
-
.replace(/[^0-9\\s/:APM-]/g, "");
|
|
4247
|
+
const normalizedValue = value.toUpperCase().replace(/[^0-9\\s/:APM-]/g, "");
|
|
4223
4248
|
const { dateDigits, dateValue, isComplete, isValid, restValue } =
|
|
4224
4249
|
splitTypedDateInput(normalizedValue);
|
|
4225
4250
|
const limitedDateDigits = dateDigits.slice(0, 8);
|
|
@@ -4227,7 +4252,9 @@ function sanitizeTypedDateTimeInput(
|
|
|
4227
4252
|
if (!limitedDateDigits) return "";
|
|
4228
4253
|
if (!isValid) return previousValue;
|
|
4229
4254
|
|
|
4230
|
-
const formattedTime = isComplete
|
|
4255
|
+
const formattedTime = isComplete
|
|
4256
|
+
? formatTimeInput(restValue, showSeconds)
|
|
4257
|
+
: "";
|
|
4231
4258
|
if (formattedTime === null) return previousValue;
|
|
4232
4259
|
|
|
4233
4260
|
return [dateValue, formattedTime].filter(Boolean).join(" ");
|
|
@@ -4303,7 +4330,11 @@ function stepDateTimeInputValue(
|
|
|
4303
4330
|
const [hourValue = "0", minuteValue = "0", secondValue = "00"] = (
|
|
4304
4331
|
typedDateTime.startTime ?? fallbackTime
|
|
4305
4332
|
).split(":");
|
|
4306
|
-
nextDate.setHours(
|
|
4333
|
+
nextDate.setHours(
|
|
4334
|
+
Number(hourValue),
|
|
4335
|
+
Number(minuteValue),
|
|
4336
|
+
Number(secondValue)
|
|
4337
|
+
);
|
|
4307
4338
|
|
|
4308
4339
|
if (segment === "day") {
|
|
4309
4340
|
nextDate.setDate(nextDate.getDate() + direction);
|
|
@@ -4347,10 +4378,7 @@ function stepDateTimeInputValue(
|
|
|
4347
4378
|
.padStart(2, "0")}:\${nextDate
|
|
4348
4379
|
.getMinutes()
|
|
4349
4380
|
.toString()
|
|
4350
|
-
.padStart(2, "0")}:\${nextDate
|
|
4351
|
-
.getSeconds()
|
|
4352
|
-
.toString()
|
|
4353
|
-
.padStart(2, "0")}\`;
|
|
4381
|
+
.padStart(2, "0")}:\${nextDate.getSeconds().toString().padStart(2, "0")}\`;
|
|
4354
4382
|
|
|
4355
4383
|
return {
|
|
4356
4384
|
date: startOfDay(nextDate),
|
|
@@ -4433,13 +4461,15 @@ function parseTypedDate(value: string) {
|
|
|
4433
4461
|
function formatHiddenValue(
|
|
4434
4462
|
value: DateTimePickerValue,
|
|
4435
4463
|
variant: DateTimePickerVariant,
|
|
4436
|
-
showEndTime: boolean
|
|
4437
|
-
hasTimeValue: boolean
|
|
4464
|
+
showEndTime: boolean
|
|
4438
4465
|
) {
|
|
4466
|
+
const startTime = value.startTime || UNSET_TIME;
|
|
4467
|
+
const endTime = value.endTime || UNSET_TIME;
|
|
4468
|
+
|
|
4439
4469
|
if (variant === "time-only") {
|
|
4440
|
-
if (!
|
|
4470
|
+
if (!value.startTime && !value.endTime) return "";
|
|
4441
4471
|
|
|
4442
|
-
return showEndTime ? \`\${
|
|
4472
|
+
return showEndTime ? \`\${startTime}/\${endTime}\` : startTime;
|
|
4443
4473
|
}
|
|
4444
4474
|
|
|
4445
4475
|
if (!value.date) return "";
|
|
@@ -4456,6 +4486,8 @@ function formatHiddenValue(
|
|
|
4456
4486
|
const day = value.date.getDate().toString().padStart(2, "0");
|
|
4457
4487
|
const year = value.date.getFullYear();
|
|
4458
4488
|
|
|
4489
|
+
if (!value.startTime) return \`\${year}-\${month}-\${day}\`;
|
|
4490
|
+
|
|
4459
4491
|
return \`\${year}-\${month}-\${day}T\${value.startTime}\`;
|
|
4460
4492
|
}
|
|
4461
4493
|
|
|
@@ -4479,6 +4511,26 @@ function FigmaCalendarIcon({ className }: { className?: string }) {
|
|
|
4479
4511
|
);
|
|
4480
4512
|
}
|
|
4481
4513
|
|
|
4514
|
+
function FigmaClockIcon({ className }: { className?: string }) {
|
|
4515
|
+
return (
|
|
4516
|
+
<svg
|
|
4517
|
+
viewBox="0 0 18 18"
|
|
4518
|
+
fill="none"
|
|
4519
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4520
|
+
className={className}
|
|
4521
|
+
aria-hidden="true"
|
|
4522
|
+
>
|
|
4523
|
+
<path
|
|
4524
|
+
d="M9 4.5V9L11.25 11.25M15.75 9C15.75 12.7279 12.7279 15.75 9 15.75C5.27208 15.75 2.25 12.7279 2.25 9C2.25 5.27208 5.27208 2.25 9 2.25C12.7279 2.25 15.75 5.27208 15.75 9Z"
|
|
4525
|
+
stroke="currentColor"
|
|
4526
|
+
strokeWidth="1.5"
|
|
4527
|
+
strokeLinecap="round"
|
|
4528
|
+
strokeLinejoin="round"
|
|
4529
|
+
/>
|
|
4530
|
+
</svg>
|
|
4531
|
+
);
|
|
4532
|
+
}
|
|
4533
|
+
|
|
4482
4534
|
function CalendarDropdown({
|
|
4483
4535
|
id,
|
|
4484
4536
|
label,
|
|
@@ -4775,7 +4827,9 @@ function TimeField({
|
|
|
4775
4827
|
ariaLabel={\`\${label} hours\`}
|
|
4776
4828
|
options={hourOptions}
|
|
4777
4829
|
onSelect={(key) =>
|
|
4778
|
-
onChange(
|
|
4830
|
+
onChange(
|
|
4831
|
+
composeTime(Number(key), minute, effectiveSecond, meridiem)
|
|
4832
|
+
)
|
|
4779
4833
|
}
|
|
4780
4834
|
/>
|
|
4781
4835
|
<TimeColumn
|
|
@@ -4783,7 +4837,9 @@ function TimeField({
|
|
|
4783
4837
|
ariaLabel={\`\${label} minutes\`}
|
|
4784
4838
|
options={minuteOptions}
|
|
4785
4839
|
onSelect={(key) =>
|
|
4786
|
-
onChange(
|
|
4840
|
+
onChange(
|
|
4841
|
+
composeTime(hour12, Number(key), effectiveSecond, meridiem)
|
|
4842
|
+
)
|
|
4787
4843
|
}
|
|
4788
4844
|
/>
|
|
4789
4845
|
{showSeconds && (
|
|
@@ -4826,6 +4882,8 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
4826
4882
|
label,
|
|
4827
4883
|
required,
|
|
4828
4884
|
labelClassName,
|
|
4885
|
+
helperText,
|
|
4886
|
+
error,
|
|
4829
4887
|
placeholder: placeholderProp,
|
|
4830
4888
|
disabled = false,
|
|
4831
4889
|
readOnly = false,
|
|
@@ -4853,6 +4911,7 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
4853
4911
|
const generatedId = React.useId();
|
|
4854
4912
|
const triggerId = id ?? generatedId;
|
|
4855
4913
|
const pickerVariant = variant ?? "date-time";
|
|
4914
|
+
const resolvedState = error ? "error" : state;
|
|
4856
4915
|
const showCalendar = pickerVariant !== "time-only";
|
|
4857
4916
|
const showTimeFields = pickerVariant !== "date-only";
|
|
4858
4917
|
const resolvedShowEndTime = showTimeFields && showEndTime;
|
|
@@ -4861,22 +4920,19 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
4861
4920
|
const [internalValue, setInternalValue] = React.useState(() =>
|
|
4862
4921
|
normalizeValue(defaultValue)
|
|
4863
4922
|
);
|
|
4864
|
-
const [internalHasTimeValue, setInternalHasTimeValue] = React.useState(() =>
|
|
4865
|
-
Boolean(defaultValue?.date || defaultValue?.startTime || defaultValue?.endTime)
|
|
4866
|
-
);
|
|
4867
4923
|
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
4868
4924
|
const currentValue = normalizeValue(
|
|
4869
4925
|
isValueControlled ? value : internalValue
|
|
4870
4926
|
);
|
|
4871
|
-
const
|
|
4872
|
-
|
|
4873
|
-
: internalHasTimeValue;
|
|
4927
|
+
const resolvedStartTime = currentValue.startTime || UNSET_TIME;
|
|
4928
|
+
const resolvedEndTime = currentValue.endTime || UNSET_TIME;
|
|
4874
4929
|
const resolvedShowSeconds =
|
|
4875
4930
|
showSeconds ??
|
|
4876
4931
|
(timeHasVisibleSeconds(currentValue.startTime) ||
|
|
4877
4932
|
(resolvedShowEndTime && timeHasVisibleSeconds(currentValue.endTime)));
|
|
4878
4933
|
const placeholder =
|
|
4879
|
-
placeholderProp ??
|
|
4934
|
+
placeholderProp ??
|
|
4935
|
+
getDefaultPlaceholder(pickerVariant, resolvedShowSeconds);
|
|
4880
4936
|
const open = isOpenControlled ? controlledOpen : internalOpen;
|
|
4881
4937
|
const [visibleMonth, setVisibleMonth] = React.useState(() =>
|
|
4882
4938
|
startOfMonth(currentValue.date ?? new Date())
|
|
@@ -4886,7 +4942,6 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
4886
4942
|
currentValue,
|
|
4887
4943
|
pickerVariant,
|
|
4888
4944
|
resolvedShowEndTime,
|
|
4889
|
-
hasTimeValue,
|
|
4890
4945
|
resolvedShowSeconds
|
|
4891
4946
|
)
|
|
4892
4947
|
);
|
|
@@ -4918,7 +4973,10 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
4918
4973
|
const maxWidth = Math.min(MAX_POPOVER_WIDTH, availableWidth);
|
|
4919
4974
|
const width = Math.max(
|
|
4920
4975
|
1,
|
|
4921
|
-
Math.min(
|
|
4976
|
+
Math.min(
|
|
4977
|
+
Math.max(rects.reference.width, MIN_POPOVER_WIDTH),
|
|
4978
|
+
maxWidth
|
|
4979
|
+
)
|
|
4922
4980
|
);
|
|
4923
4981
|
elements.floating.style.setProperty(
|
|
4924
4982
|
POPOVER_SCROLL_HEIGHT_VAR,
|
|
@@ -4946,11 +5004,13 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
4946
5004
|
() => getCalendarDays(visibleMonth),
|
|
4947
5005
|
[visibleMonth]
|
|
4948
5006
|
);
|
|
5007
|
+
const errorId = \`\${triggerId}-error\`;
|
|
5008
|
+
const helperId = \`\${triggerId}-helper\`;
|
|
5009
|
+
const describedBy = error ? errorId : helperText ? helperId : undefined;
|
|
4949
5010
|
const displayValue = formatValueForDisplay(
|
|
4950
5011
|
currentValue,
|
|
4951
5012
|
pickerVariant,
|
|
4952
5013
|
resolvedShowEndTime,
|
|
4953
|
-
hasTimeValue,
|
|
4954
5014
|
resolvedShowSeconds
|
|
4955
5015
|
);
|
|
4956
5016
|
const effectiveMinDate = React.useMemo(() => {
|
|
@@ -5041,15 +5101,9 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5041
5101
|
}, [open, setOpen]);
|
|
5042
5102
|
|
|
5043
5103
|
const updateValue = React.useCallback(
|
|
5044
|
-
(
|
|
5045
|
-
nextValue: DateTimePickerValue,
|
|
5046
|
-
options?: { hasTimeValue?: boolean }
|
|
5047
|
-
) => {
|
|
5104
|
+
(nextValue: DateTimePickerValue) => {
|
|
5048
5105
|
if (!isValueControlled) {
|
|
5049
5106
|
setInternalValue(nextValue);
|
|
5050
|
-
if (options?.hasTimeValue !== undefined) {
|
|
5051
|
-
setInternalHasTimeValue(options.hasTimeValue);
|
|
5052
|
-
}
|
|
5053
5107
|
}
|
|
5054
5108
|
|
|
5055
5109
|
onValueChange?.(nextValue);
|
|
@@ -5062,11 +5116,14 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5062
5116
|
if (readOnly) return;
|
|
5063
5117
|
|
|
5064
5118
|
setDateInputValue("");
|
|
5119
|
+
setOpenTimeField(null);
|
|
5120
|
+
setOpenCalendarDropdown(null);
|
|
5121
|
+
setVisibleMonth(startOfMonth(new Date()));
|
|
5065
5122
|
updateValue({
|
|
5066
5123
|
date: undefined,
|
|
5067
|
-
startTime:
|
|
5068
|
-
endTime:
|
|
5069
|
-
}
|
|
5124
|
+
startTime: "",
|
|
5125
|
+
endTime: "",
|
|
5126
|
+
});
|
|
5070
5127
|
};
|
|
5071
5128
|
|
|
5072
5129
|
const yearOptions = React.useMemo(
|
|
@@ -5125,13 +5182,7 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5125
5182
|
updateValue({ ...currentValue, date: nextSelectedDate });
|
|
5126
5183
|
}
|
|
5127
5184
|
},
|
|
5128
|
-
[
|
|
5129
|
-
currentValue,
|
|
5130
|
-
effectiveMinDate,
|
|
5131
|
-
maxDate,
|
|
5132
|
-
pickerVariant,
|
|
5133
|
-
updateValue,
|
|
5134
|
-
]
|
|
5185
|
+
[currentValue, effectiveMinDate, maxDate, pickerVariant, updateValue]
|
|
5135
5186
|
);
|
|
5136
5187
|
|
|
5137
5188
|
const handleTypedDateChange = (
|
|
@@ -5155,18 +5206,12 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5155
5206
|
|
|
5156
5207
|
const typedTime = parseTimePart(nextInputValue);
|
|
5157
5208
|
if (typedTime === undefined) {
|
|
5158
|
-
updateValue({ ...currentValue,
|
|
5209
|
+
updateValue({ ...currentValue, startTime: "" });
|
|
5159
5210
|
return;
|
|
5160
5211
|
}
|
|
5161
5212
|
|
|
5162
5213
|
if (typedTime) {
|
|
5163
|
-
updateValue(
|
|
5164
|
-
{
|
|
5165
|
-
...currentValue,
|
|
5166
|
-
startTime: typedTime,
|
|
5167
|
-
},
|
|
5168
|
-
{ hasTimeValue: true }
|
|
5169
|
-
);
|
|
5214
|
+
updateValue({ ...currentValue, startTime: typedTime });
|
|
5170
5215
|
}
|
|
5171
5216
|
|
|
5172
5217
|
return;
|
|
@@ -5236,7 +5281,7 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5236
5281
|
updateValue({
|
|
5237
5282
|
...currentValue,
|
|
5238
5283
|
date: typedDateTime.date,
|
|
5239
|
-
startTime: typedDateTime.startTime
|
|
5284
|
+
startTime: typedDateTime.startTime || currentValue.startTime,
|
|
5240
5285
|
});
|
|
5241
5286
|
updateVisibleMonth(typedDateTime.date);
|
|
5242
5287
|
}
|
|
@@ -5256,7 +5301,7 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5256
5301
|
dateInputValue,
|
|
5257
5302
|
cursorPosition,
|
|
5258
5303
|
direction,
|
|
5259
|
-
|
|
5304
|
+
resolvedStartTime,
|
|
5260
5305
|
resolvedShowSeconds
|
|
5261
5306
|
);
|
|
5262
5307
|
|
|
@@ -5308,7 +5353,6 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5308
5353
|
currentValue,
|
|
5309
5354
|
pickerVariant,
|
|
5310
5355
|
resolvedShowEndTime,
|
|
5311
|
-
hasTimeValue,
|
|
5312
5356
|
resolvedShowSeconds
|
|
5313
5357
|
)
|
|
5314
5358
|
);
|
|
@@ -5324,7 +5368,9 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5324
5368
|
ref={setPopoverRef}
|
|
5325
5369
|
role="dialog"
|
|
5326
5370
|
aria-modal="false"
|
|
5327
|
-
aria-labelledby={
|
|
5371
|
+
aria-labelledby={
|
|
5372
|
+
showCalendar ? \`\${triggerId}-calendar-heading\` : undefined
|
|
5373
|
+
}
|
|
5328
5374
|
aria-label={showCalendar ? undefined : "Time picker"}
|
|
5329
5375
|
className={cn(
|
|
5330
5376
|
"rounded-lg border border-solid border-semantic-border-layout bg-semantic-bg-primary shadow-lg flex flex-col min-h-0 overflow-y-auto overflow-x-hidden overscroll-contain pointer-events-auto",
|
|
@@ -5414,11 +5460,7 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5414
5460
|
}))}
|
|
5415
5461
|
onValueChange={(nextYear) => {
|
|
5416
5462
|
syncCalendarMonthAndValue(
|
|
5417
|
-
new Date(
|
|
5418
|
-
Number(nextYear),
|
|
5419
|
-
visibleMonth.getMonth(),
|
|
5420
|
-
1
|
|
5421
|
-
)
|
|
5463
|
+
new Date(Number(nextYear), visibleMonth.getMonth(), 1)
|
|
5422
5464
|
);
|
|
5423
5465
|
}}
|
|
5424
5466
|
/>
|
|
@@ -5510,7 +5552,7 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5510
5552
|
<TimeField
|
|
5511
5553
|
id={\`\${triggerId}-start-time\`}
|
|
5512
5554
|
label={startTimeLabel}
|
|
5513
|
-
value={
|
|
5555
|
+
value={resolvedStartTime}
|
|
5514
5556
|
showSeconds={resolvedShowSeconds}
|
|
5515
5557
|
minuteStep={minuteStep}
|
|
5516
5558
|
secondStep={secondStep}
|
|
@@ -5521,10 +5563,7 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5521
5563
|
setOpenTimeField(nextOpen ? "start" : null)
|
|
5522
5564
|
}
|
|
5523
5565
|
onChange={(startTime) =>
|
|
5524
|
-
updateValue(
|
|
5525
|
-
{ ...currentValue, startTime },
|
|
5526
|
-
{ hasTimeValue: true }
|
|
5527
|
-
)
|
|
5566
|
+
updateValue({ ...currentValue, startTime })
|
|
5528
5567
|
}
|
|
5529
5568
|
/>
|
|
5530
5569
|
|
|
@@ -5532,7 +5571,7 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5532
5571
|
<TimeField
|
|
5533
5572
|
id={\`\${triggerId}-end-time\`}
|
|
5534
5573
|
label={endTimeLabel}
|
|
5535
|
-
value={
|
|
5574
|
+
value={resolvedEndTime}
|
|
5536
5575
|
showSeconds={resolvedShowSeconds}
|
|
5537
5576
|
minuteStep={minuteStep}
|
|
5538
5577
|
secondStep={secondStep}
|
|
@@ -5543,15 +5582,13 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5543
5582
|
setOpenTimeField(nextOpen ? "end" : null)
|
|
5544
5583
|
}
|
|
5545
5584
|
onChange={(endTime) =>
|
|
5546
|
-
updateValue(
|
|
5547
|
-
{ ...currentValue, endTime },
|
|
5548
|
-
{ hasTimeValue: true }
|
|
5549
|
-
)
|
|
5585
|
+
updateValue({ ...currentValue, endTime })
|
|
5550
5586
|
}
|
|
5551
5587
|
/>
|
|
5552
5588
|
)}
|
|
5553
5589
|
</div>
|
|
5554
5590
|
)}
|
|
5591
|
+
|
|
5555
5592
|
</div>,
|
|
5556
5593
|
portalMount
|
|
5557
5594
|
);
|
|
@@ -5578,8 +5615,7 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5578
5615
|
value={formatHiddenValue(
|
|
5579
5616
|
currentValue,
|
|
5580
5617
|
pickerVariant,
|
|
5581
|
-
resolvedShowEndTime
|
|
5582
|
-
hasTimeValue
|
|
5618
|
+
resolvedShowEndTime
|
|
5583
5619
|
)}
|
|
5584
5620
|
/>
|
|
5585
5621
|
)}
|
|
@@ -5600,9 +5636,9 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5600
5636
|
<div
|
|
5601
5637
|
ref={setTriggerRef}
|
|
5602
5638
|
className={cn(
|
|
5603
|
-
dateTimePickerTriggerVariants({ size, state }),
|
|
5639
|
+
dateTimePickerTriggerVariants({ size, state: resolvedState }),
|
|
5604
5640
|
open &&
|
|
5605
|
-
|
|
5641
|
+
resolvedState !== "error" &&
|
|
5606
5642
|
"border-semantic-border-input-focus/50 shadow-[0_0_0_1px_rgba(43,188,202,0.15)]",
|
|
5607
5643
|
!displayValue && "text-semantic-text-placeholder",
|
|
5608
5644
|
disabled &&
|
|
@@ -5618,6 +5654,8 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5618
5654
|
placeholder={placeholder}
|
|
5619
5655
|
aria-haspopup="dialog"
|
|
5620
5656
|
aria-expanded={open}
|
|
5657
|
+
aria-invalid={error ? true : undefined}
|
|
5658
|
+
aria-describedby={describedBy}
|
|
5621
5659
|
aria-label={
|
|
5622
5660
|
pickerVariant === "date-only"
|
|
5623
5661
|
? "Date"
|
|
@@ -5635,16 +5673,19 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5635
5673
|
onKeyDown={handleTypedDateKeyDown}
|
|
5636
5674
|
onBlur={handleTypedDateBlur}
|
|
5637
5675
|
/>
|
|
5638
|
-
{showClear &&
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5676
|
+
{showClear &&
|
|
5677
|
+
(displayValue || dateInputValue) &&
|
|
5678
|
+
!disabled &&
|
|
5679
|
+
!readOnly && (
|
|
5680
|
+
<button
|
|
5681
|
+
type="button"
|
|
5682
|
+
aria-label="Clear date"
|
|
5683
|
+
className="inline-flex size-5 items-center justify-center rounded text-semantic-text-muted hover:bg-semantic-bg-hover hover:text-semantic-text-primary"
|
|
5684
|
+
onClick={clearValue}
|
|
5685
|
+
>
|
|
5686
|
+
<X className="size-4" aria-hidden="true" />
|
|
5687
|
+
</button>
|
|
5688
|
+
)}
|
|
5648
5689
|
<button
|
|
5649
5690
|
type="button"
|
|
5650
5691
|
disabled={disabled || readOnly}
|
|
@@ -5652,12 +5693,39 @@ const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(
|
|
|
5652
5693
|
className="inline-flex shrink-0 items-center justify-center rounded text-semantic-text-muted hover:bg-semantic-bg-hover hover:text-semantic-text-primary disabled:cursor-not-allowed"
|
|
5653
5694
|
onClick={() => setOpen(!open)}
|
|
5654
5695
|
>
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5696
|
+
{showCalendar ? (
|
|
5697
|
+
<FigmaCalendarIcon
|
|
5698
|
+
className={cn(size === "sm" ? "size-4" : "size-[18px]")}
|
|
5699
|
+
/>
|
|
5700
|
+
) : (
|
|
5701
|
+
<FigmaClockIcon
|
|
5702
|
+
className={cn(size === "sm" ? "size-4" : "size-[18px]")}
|
|
5703
|
+
/>
|
|
5704
|
+
)}
|
|
5658
5705
|
</button>
|
|
5659
5706
|
</div>
|
|
5660
5707
|
|
|
5708
|
+
{(error || helperText) && (
|
|
5709
|
+
<div className="mt-1">
|
|
5710
|
+
{error ? (
|
|
5711
|
+
<span
|
|
5712
|
+
id={errorId}
|
|
5713
|
+
role="alert"
|
|
5714
|
+
className="text-sm text-semantic-error-primary"
|
|
5715
|
+
>
|
|
5716
|
+
{error}
|
|
5717
|
+
</span>
|
|
5718
|
+
) : (
|
|
5719
|
+
<span
|
|
5720
|
+
id={helperId}
|
|
5721
|
+
className="text-sm text-semantic-text-muted"
|
|
5722
|
+
>
|
|
5723
|
+
{helperText}
|
|
5724
|
+
</span>
|
|
5725
|
+
)}
|
|
5726
|
+
</div>
|
|
5727
|
+
)}
|
|
5728
|
+
|
|
5661
5729
|
{popover}
|
|
5662
5730
|
</div>
|
|
5663
5731
|
);
|
package/package.json
CHANGED