@mlw-packages/react-components 1.7.1 → 1.7.2
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 +108 -2
- package/dist/index.d.ts +108 -2
- package/dist/index.js +955 -12
- package/dist/index.mjs +960 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -544,6 +544,7 @@ __export(index_exports, {
|
|
|
544
544
|
CommandSeparatorBase: () => CommandSeparatorBase,
|
|
545
545
|
CommandShortcutBase: () => CommandShortcutBase,
|
|
546
546
|
CopyButton: () => CopyButton,
|
|
547
|
+
DateTimePicker: () => DateTimePicker,
|
|
547
548
|
DeleteButton: () => DeleteButton,
|
|
548
549
|
DestructiveDialog: () => DestructiveDialog,
|
|
549
550
|
DialogBase: () => DialogBase,
|
|
@@ -635,6 +636,7 @@ __export(index_exports, {
|
|
|
635
636
|
ProgressCirclesBase: () => ProgressCirclesBase,
|
|
636
637
|
ProgressPanelsBase: () => ProgressPanelsBase,
|
|
637
638
|
ProgressSegmentsBase: () => ProgressSegmentsBase,
|
|
639
|
+
RangePicker: () => RangePicker,
|
|
638
640
|
RefreshButton: () => RefreshButton,
|
|
639
641
|
SaveButton: () => SaveButton,
|
|
640
642
|
ScrollAreaBase: () => ScrollAreaBase,
|
|
@@ -704,6 +706,8 @@ __export(index_exports, {
|
|
|
704
706
|
TabsTriggerBase: () => TabsTriggerBase,
|
|
705
707
|
TextAreaBase: () => TextAreaBase,
|
|
706
708
|
ThemeProviderBase: () => ThemeProviderBase,
|
|
709
|
+
TimePicker: () => TimePicker,
|
|
710
|
+
TimePickerInput: () => TimePickerInput,
|
|
707
711
|
Toaster: () => Toaster,
|
|
708
712
|
TooltipBase: () => TooltipBase,
|
|
709
713
|
TooltipContentBase: () => TooltipContentBase,
|
|
@@ -720,14 +724,34 @@ __export(index_exports, {
|
|
|
720
724
|
badgeVariants: () => badgeVariants,
|
|
721
725
|
buttonVariantsBase: () => buttonVariantsBase,
|
|
722
726
|
compactTick: () => compactTick,
|
|
727
|
+
convert12HourTo24Hour: () => convert12HourTo24Hour,
|
|
723
728
|
detectDataFields: () => detectDataFields,
|
|
724
729
|
detectXAxis: () => detectXAxis,
|
|
730
|
+
display12HourValue: () => display12HourValue,
|
|
725
731
|
formatFieldName: () => formatFieldName,
|
|
726
732
|
generateAdditionalColors: () => generateAdditionalColors,
|
|
733
|
+
getArrowByType: () => getArrowByType,
|
|
734
|
+
getDateByType: () => getDateByType,
|
|
735
|
+
getValid12Hour: () => getValid12Hour,
|
|
736
|
+
getValidArrow12Hour: () => getValidArrow12Hour,
|
|
737
|
+
getValidArrowHour: () => getValidArrowHour,
|
|
738
|
+
getValidArrowMinuteOrSecond: () => getValidArrowMinuteOrSecond,
|
|
739
|
+
getValidArrowNumber: () => getValidArrowNumber,
|
|
740
|
+
getValidHour: () => getValidHour,
|
|
741
|
+
getValidMinuteOrSecond: () => getValidMinuteOrSecond,
|
|
742
|
+
getValidNumber: () => getValidNumber,
|
|
743
|
+
isValid12Hour: () => isValid12Hour,
|
|
744
|
+
isValidHour: () => isValidHour,
|
|
745
|
+
isValidMinuteOrSecond: () => isValidMinuteOrSecond,
|
|
727
746
|
niceCeil: () => niceCeil,
|
|
728
747
|
renderPillLabel: () => pillLabelRenderer_default,
|
|
729
748
|
resolveChartMargins: () => resolveChartMargins,
|
|
730
749
|
resolveContainerPaddingLeft: () => resolveContainerPaddingLeft,
|
|
750
|
+
set12Hours: () => set12Hours,
|
|
751
|
+
setDateByType: () => setDateByType,
|
|
752
|
+
setHours: () => setHours,
|
|
753
|
+
setMinutes: () => setMinutes,
|
|
754
|
+
setSeconds: () => setSeconds,
|
|
731
755
|
toast: () => toast2,
|
|
732
756
|
useChartHighlights: () => useChartHighlights,
|
|
733
757
|
useDrag: () => useDrag,
|
|
@@ -10041,14 +10065,933 @@ var UniversalTooltipRenderer = ({
|
|
|
10041
10065
|
] });
|
|
10042
10066
|
};
|
|
10043
10067
|
|
|
10068
|
+
// src/components/picker/DateTimePicker.tsx
|
|
10069
|
+
var import_date_fns = require("date-fns");
|
|
10070
|
+
|
|
10071
|
+
// src/components/picker/calendar.tsx
|
|
10072
|
+
var React39 = __toESM(require("react"));
|
|
10073
|
+
var import_react_day_picker2 = require("react-day-picker");
|
|
10074
|
+
var import_react40 = require("@phosphor-icons/react");
|
|
10075
|
+
var import_framer_motion14 = require("framer-motion");
|
|
10076
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
10077
|
+
function CalendarBase2({
|
|
10078
|
+
className,
|
|
10079
|
+
classNames,
|
|
10080
|
+
showOutsideDays = true,
|
|
10081
|
+
...props
|
|
10082
|
+
}) {
|
|
10083
|
+
const [month, setMonth] = React39.useState(
|
|
10084
|
+
props.month || props.defaultMonth || /* @__PURE__ */ new Date()
|
|
10085
|
+
);
|
|
10086
|
+
const [direction, setDirection] = React39.useState(1);
|
|
10087
|
+
const handleMonthChange = (newMonth) => {
|
|
10088
|
+
const isNext = newMonth > month ? 1 : -1;
|
|
10089
|
+
setDirection(isNext);
|
|
10090
|
+
setMonth(newMonth);
|
|
10091
|
+
props.onMonthChange?.(newMonth);
|
|
10092
|
+
};
|
|
10093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
10094
|
+
"div",
|
|
10095
|
+
{
|
|
10096
|
+
className: cn(
|
|
10097
|
+
"rounded-md border bg-background p-2 overflow-hidden flex flex-col",
|
|
10098
|
+
className
|
|
10099
|
+
),
|
|
10100
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "relative flex-1 flex flex-col min-h-0", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_framer_motion14.AnimatePresence, { initial: false, mode: "wait", custom: direction, children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
10101
|
+
"div",
|
|
10102
|
+
{
|
|
10103
|
+
className: "w-full h-full flex flex-col",
|
|
10104
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
10105
|
+
import_react_day_picker2.DayPicker,
|
|
10106
|
+
{
|
|
10107
|
+
showOutsideDays,
|
|
10108
|
+
month,
|
|
10109
|
+
onMonthChange: handleMonthChange,
|
|
10110
|
+
className: "w-full h-full min-w-0 flex flex-col",
|
|
10111
|
+
classNames: {
|
|
10112
|
+
months: "flex items-center flex-col sm:flex-row space-y-2 sm:space-x-2 sm:space-y-0 flex-1",
|
|
10113
|
+
month: "space-y-2 min-w-0 flex-1 flex flex-col",
|
|
10114
|
+
caption: "flex justify-center pt-1 relative items-center h-[10%] min-h-[2rem] mb-2",
|
|
10115
|
+
caption_label: "text-[clamp(0.875rem,2.5vw,1.25rem)] font-semibold truncate px-10 tracking-tight",
|
|
10116
|
+
nav: "space-x-1 flex items-center",
|
|
10117
|
+
nav_button: cn(
|
|
10118
|
+
buttonVariantsBase({ variant: "outline" }),
|
|
10119
|
+
"h-8 w-8 bg-background p-0 opacity-60 hover:opacity-100 hover:bg-muted flex-shrink-0 touch-manipulation transition-all duration-200 ease-out hover:scale-105 active:scale-95",
|
|
10120
|
+
"[@media(min-width:400px)]:h-9 [@media(min-width:400px)]:w-9"
|
|
10121
|
+
),
|
|
10122
|
+
nav_button_previous: "absolute left-0",
|
|
10123
|
+
nav_button_next: "absolute right-0",
|
|
10124
|
+
table: "w-full border-collapse min-w-0 flex-1 flex flex-col",
|
|
10125
|
+
head_row: "flex w-full gap-1 mb-1",
|
|
10126
|
+
head_cell: "text-muted-foreground rounded-md flex-1 min-w-0 font-semibold text-[clamp(0.625rem,1.5vw,0.75rem)] text-center pb-1 uppercase tracking-wider",
|
|
10127
|
+
row: "flex w-full flex-1 gap-1",
|
|
10128
|
+
cell: cn(
|
|
10129
|
+
"flex-1 min-w-0 aspect-square text-center p-0 relative",
|
|
10130
|
+
"[&:has([aria-selected].day-range-end)]:rounded-r-lg",
|
|
10131
|
+
"[&:has([aria-selected].day-range-start)]:rounded-l-lg",
|
|
10132
|
+
"[&:has([aria-selected].day-outside)]:bg-muted/50",
|
|
10133
|
+
"[&:has([aria-selected])]:bg-muted",
|
|
10134
|
+
"first:[&:has([aria-selected])]:rounded-l-lg",
|
|
10135
|
+
"last:[&:has([aria-selected])]:rounded-r-lg",
|
|
10136
|
+
"focus-within:relative focus-within:z-20"
|
|
10137
|
+
),
|
|
10138
|
+
day: cn(
|
|
10139
|
+
buttonVariantsBase({ variant: "ghost" }),
|
|
10140
|
+
"w-full h-full p-0",
|
|
10141
|
+
"aria-selected:opacity-100 hover:bg-muted flex items-center justify-center",
|
|
10142
|
+
" transition-all duration-200 ease-out hover:scale-105 active:scale-95"
|
|
10143
|
+
),
|
|
10144
|
+
day_selected: "bg-primary text-primary-foreground hover:bg-primary/90 focus:bg-primary/90 font-semibold hover:text-white",
|
|
10145
|
+
day_today: "bg-muted text-foreground font-bold ring-2 ring-primary/30 ring-inset",
|
|
10146
|
+
day_outside: "day-outside text-muted-foreground/40 opacity-40 aria-selected:bg-muted/50 aria-selected:text-foreground",
|
|
10147
|
+
day_disabled: "text-muted-foreground/30 opacity-40 cursor-not-allowed",
|
|
10148
|
+
day_range_middle: "aria-selected:bg-muted aria-selected:text-foreground",
|
|
10149
|
+
day_hidden: "invisible",
|
|
10150
|
+
...classNames
|
|
10151
|
+
},
|
|
10152
|
+
components: {
|
|
10153
|
+
IconLeft: () => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react40.CaretLeftIcon, { className: "h-4 w-4" }),
|
|
10154
|
+
IconRight: () => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react40.CaretRightIcon, { className: "h-4 w-4" })
|
|
10155
|
+
},
|
|
10156
|
+
...props
|
|
10157
|
+
}
|
|
10158
|
+
)
|
|
10159
|
+
},
|
|
10160
|
+
month.toISOString()
|
|
10161
|
+
) }) })
|
|
10162
|
+
}
|
|
10163
|
+
);
|
|
10164
|
+
}
|
|
10165
|
+
CalendarBase2.displayName = "CalendarBase";
|
|
10166
|
+
|
|
10167
|
+
// src/components/picker/DateTimePicker.tsx
|
|
10168
|
+
var import_locale = require("date-fns/locale");
|
|
10169
|
+
var import_react43 = require("react");
|
|
10170
|
+
|
|
10171
|
+
// src/components/picker/TimePicker.tsx
|
|
10172
|
+
var import_framer_motion15 = require("framer-motion");
|
|
10173
|
+
var React41 = __toESM(require("react"));
|
|
10174
|
+
|
|
10175
|
+
// src/components/picker/TimePickerInput.tsx
|
|
10176
|
+
var import_react41 = require("@phosphor-icons/react");
|
|
10177
|
+
var import_react42 = __toESM(require("react"));
|
|
10178
|
+
|
|
10179
|
+
// src/components/picker/utils/time-picker-utils.ts
|
|
10180
|
+
function isValidHour(value) {
|
|
10181
|
+
return /^(0[0-9]|1[0-9]|2[0-3])$/.test(value);
|
|
10182
|
+
}
|
|
10183
|
+
function isValid12Hour(value) {
|
|
10184
|
+
return /^(0[1-9]|1[0-2])$/.test(value);
|
|
10185
|
+
}
|
|
10186
|
+
function isValidMinuteOrSecond(value) {
|
|
10187
|
+
return /^[0-5][0-9]$/.test(value);
|
|
10188
|
+
}
|
|
10189
|
+
function getValidNumber(value, { max, min = 0, loop = false }) {
|
|
10190
|
+
let numericValue = parseInt(value, 10);
|
|
10191
|
+
if (!isNaN(numericValue)) {
|
|
10192
|
+
if (!loop) {
|
|
10193
|
+
if (numericValue > max) numericValue = max;
|
|
10194
|
+
if (numericValue < min) numericValue = min;
|
|
10195
|
+
} else {
|
|
10196
|
+
if (numericValue > max) numericValue = min;
|
|
10197
|
+
if (numericValue < min) numericValue = max;
|
|
10198
|
+
}
|
|
10199
|
+
return numericValue.toString().padStart(2, "0");
|
|
10200
|
+
}
|
|
10201
|
+
return "00";
|
|
10202
|
+
}
|
|
10203
|
+
function getValidHour(value) {
|
|
10204
|
+
if (isValidHour(value)) return value;
|
|
10205
|
+
return getValidNumber(value, { max: 23 });
|
|
10206
|
+
}
|
|
10207
|
+
function getValid12Hour(value) {
|
|
10208
|
+
if (isValid12Hour(value)) return value;
|
|
10209
|
+
return getValidNumber(value, { min: 1, max: 12 });
|
|
10210
|
+
}
|
|
10211
|
+
function getValidMinuteOrSecond(value) {
|
|
10212
|
+
if (isValidMinuteOrSecond(value)) return value;
|
|
10213
|
+
return getValidNumber(value, { max: 59 });
|
|
10214
|
+
}
|
|
10215
|
+
function getValidArrowNumber(value, { min, max, step }) {
|
|
10216
|
+
let numericValue = parseInt(value, 10);
|
|
10217
|
+
if (!isNaN(numericValue)) {
|
|
10218
|
+
numericValue += step;
|
|
10219
|
+
return getValidNumber(String(numericValue), { min, max, loop: true });
|
|
10220
|
+
}
|
|
10221
|
+
return "00";
|
|
10222
|
+
}
|
|
10223
|
+
function getValidArrowHour(value, step) {
|
|
10224
|
+
return getValidArrowNumber(value, { min: 0, max: 23, step });
|
|
10225
|
+
}
|
|
10226
|
+
function getValidArrow12Hour(value, step) {
|
|
10227
|
+
return getValidArrowNumber(value, { min: 1, max: 12, step });
|
|
10228
|
+
}
|
|
10229
|
+
function getValidArrowMinuteOrSecond(value, step) {
|
|
10230
|
+
return getValidArrowNumber(value, { min: 0, max: 59, step });
|
|
10231
|
+
}
|
|
10232
|
+
function setMinutes(date, value) {
|
|
10233
|
+
const minutes = getValidMinuteOrSecond(value);
|
|
10234
|
+
date.setMinutes(parseInt(minutes, 10));
|
|
10235
|
+
return date;
|
|
10236
|
+
}
|
|
10237
|
+
function setSeconds(date, value) {
|
|
10238
|
+
const seconds = getValidMinuteOrSecond(value);
|
|
10239
|
+
date.setSeconds(parseInt(seconds, 10));
|
|
10240
|
+
return date;
|
|
10241
|
+
}
|
|
10242
|
+
function setHours(date, value) {
|
|
10243
|
+
const hours = getValidHour(value);
|
|
10244
|
+
date.setHours(parseInt(hours, 10));
|
|
10245
|
+
return date;
|
|
10246
|
+
}
|
|
10247
|
+
function set12Hours(date, value, period) {
|
|
10248
|
+
const hours = parseInt(getValid12Hour(value), 10);
|
|
10249
|
+
const convertedHours = convert12HourTo24Hour(hours, period);
|
|
10250
|
+
date.setHours(convertedHours);
|
|
10251
|
+
return date;
|
|
10252
|
+
}
|
|
10253
|
+
function setDateByType(date, value, type, period) {
|
|
10254
|
+
switch (type) {
|
|
10255
|
+
case "minutes":
|
|
10256
|
+
return setMinutes(date, value);
|
|
10257
|
+
case "seconds":
|
|
10258
|
+
return setSeconds(date, value);
|
|
10259
|
+
case "hours":
|
|
10260
|
+
return setHours(date, value);
|
|
10261
|
+
case "12hours": {
|
|
10262
|
+
if (!period) return date;
|
|
10263
|
+
return set12Hours(date, value, period);
|
|
10264
|
+
}
|
|
10265
|
+
default:
|
|
10266
|
+
return date;
|
|
10267
|
+
}
|
|
10268
|
+
}
|
|
10269
|
+
function getDateByType(date, type) {
|
|
10270
|
+
switch (type) {
|
|
10271
|
+
case "minutes":
|
|
10272
|
+
return getValidMinuteOrSecond(String(date.getMinutes()));
|
|
10273
|
+
case "seconds":
|
|
10274
|
+
return getValidMinuteOrSecond(String(date.getSeconds()));
|
|
10275
|
+
case "hours":
|
|
10276
|
+
return getValidHour(String(date.getHours()));
|
|
10277
|
+
case "12hours":
|
|
10278
|
+
const hours = display12HourValue(date.getHours());
|
|
10279
|
+
return getValid12Hour(String(hours));
|
|
10280
|
+
default:
|
|
10281
|
+
return "00";
|
|
10282
|
+
}
|
|
10283
|
+
}
|
|
10284
|
+
function getArrowByType(value, step, type) {
|
|
10285
|
+
switch (type) {
|
|
10286
|
+
case "minutes":
|
|
10287
|
+
return getValidArrowMinuteOrSecond(value, step);
|
|
10288
|
+
case "seconds":
|
|
10289
|
+
return getValidArrowMinuteOrSecond(value, step);
|
|
10290
|
+
case "hours":
|
|
10291
|
+
return getValidArrowHour(value, step);
|
|
10292
|
+
case "12hours":
|
|
10293
|
+
return getValidArrow12Hour(value, step);
|
|
10294
|
+
default:
|
|
10295
|
+
return "00";
|
|
10296
|
+
}
|
|
10297
|
+
}
|
|
10298
|
+
function convert12HourTo24Hour(hour, period) {
|
|
10299
|
+
if (period === "PM") {
|
|
10300
|
+
if (hour <= 11) {
|
|
10301
|
+
return hour + 12;
|
|
10302
|
+
} else {
|
|
10303
|
+
return hour;
|
|
10304
|
+
}
|
|
10305
|
+
} else if (period === "AM") {
|
|
10306
|
+
if (hour === 12) return 0;
|
|
10307
|
+
return hour;
|
|
10308
|
+
}
|
|
10309
|
+
return hour;
|
|
10310
|
+
}
|
|
10311
|
+
function display12HourValue(hours) {
|
|
10312
|
+
if (hours === 0 || hours === 12) return "12";
|
|
10313
|
+
if (hours >= 22) return `${hours - 12}`;
|
|
10314
|
+
if (hours % 12 > 9) return `${hours}`;
|
|
10315
|
+
return `0${hours % 12}`;
|
|
10316
|
+
}
|
|
10317
|
+
|
|
10318
|
+
// src/components/picker/TimePickerInput.tsx
|
|
10319
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
10320
|
+
var TimePickerInput = import_react42.default.forwardRef(
|
|
10321
|
+
({
|
|
10322
|
+
className,
|
|
10323
|
+
type = "tel",
|
|
10324
|
+
value,
|
|
10325
|
+
id,
|
|
10326
|
+
name,
|
|
10327
|
+
date = new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)),
|
|
10328
|
+
setDate,
|
|
10329
|
+
onChange,
|
|
10330
|
+
onKeyDown,
|
|
10331
|
+
picker,
|
|
10332
|
+
period,
|
|
10333
|
+
onLeftFocus,
|
|
10334
|
+
onRightFocus,
|
|
10335
|
+
showArrows = true,
|
|
10336
|
+
label,
|
|
10337
|
+
...props
|
|
10338
|
+
}, ref) => {
|
|
10339
|
+
const [flag, setFlag] = import_react42.default.useState(false);
|
|
10340
|
+
const [prevIntKey, setPrevIntKey] = import_react42.default.useState("0");
|
|
10341
|
+
const [isFocused, setIsFocused] = import_react42.default.useState(false);
|
|
10342
|
+
import_react42.default.useEffect(() => {
|
|
10343
|
+
if (flag) {
|
|
10344
|
+
const timer = setTimeout(() => {
|
|
10345
|
+
setFlag(false);
|
|
10346
|
+
}, 2e3);
|
|
10347
|
+
return () => clearTimeout(timer);
|
|
10348
|
+
}
|
|
10349
|
+
}, [flag]);
|
|
10350
|
+
const calculatedValue = import_react42.default.useMemo(() => {
|
|
10351
|
+
return getDateByType(date, picker);
|
|
10352
|
+
}, [date, picker]);
|
|
10353
|
+
const calculateNewValue = (key) => {
|
|
10354
|
+
if (picker === "12hours") {
|
|
10355
|
+
if (flag && calculatedValue.slice(1, 2) === "1" && prevIntKey === "0")
|
|
10356
|
+
return "0" + key;
|
|
10357
|
+
}
|
|
10358
|
+
return !flag ? "0" + key : calculatedValue.slice(1, 2) + key;
|
|
10359
|
+
};
|
|
10360
|
+
const handleArrowClick = (direction) => {
|
|
10361
|
+
const step = direction === "up" ? 1 : -1;
|
|
10362
|
+
const newValue = getArrowByType(calculatedValue, step, picker);
|
|
10363
|
+
if (flag) setFlag(false);
|
|
10364
|
+
const tempDate = new Date(date);
|
|
10365
|
+
setDate(setDateByType(tempDate, newValue, picker, period));
|
|
10366
|
+
};
|
|
10367
|
+
const handleKeyDown = (e) => {
|
|
10368
|
+
if (e.key === "Tab") return;
|
|
10369
|
+
e.preventDefault();
|
|
10370
|
+
if (e.key === "ArrowRight") onRightFocus?.();
|
|
10371
|
+
if (e.key === "ArrowLeft") onLeftFocus?.();
|
|
10372
|
+
if (["ArrowUp", "ArrowDown"].includes(e.key)) {
|
|
10373
|
+
const step = e.key === "ArrowUp" ? 1 : -1;
|
|
10374
|
+
const newValue = getArrowByType(calculatedValue, step, picker);
|
|
10375
|
+
if (flag) setFlag(false);
|
|
10376
|
+
const tempDate = new Date(date);
|
|
10377
|
+
setDate(setDateByType(tempDate, newValue, picker, period));
|
|
10378
|
+
}
|
|
10379
|
+
if (e.key >= "0" && e.key <= "9") {
|
|
10380
|
+
if (picker === "12hours") setPrevIntKey(e.key);
|
|
10381
|
+
const newValue = calculateNewValue(e.key);
|
|
10382
|
+
if (flag) onRightFocus?.();
|
|
10383
|
+
setFlag((prev) => !prev);
|
|
10384
|
+
const tempDate = new Date(date);
|
|
10385
|
+
setDate(setDateByType(tempDate, newValue, picker, period));
|
|
10386
|
+
}
|
|
10387
|
+
};
|
|
10388
|
+
const getPickerLabel = () => {
|
|
10389
|
+
if (label) return label;
|
|
10390
|
+
switch (picker) {
|
|
10391
|
+
case "hours":
|
|
10392
|
+
case "12hours":
|
|
10393
|
+
return "Horas";
|
|
10394
|
+
case "minutes":
|
|
10395
|
+
return "Minutos";
|
|
10396
|
+
case "seconds":
|
|
10397
|
+
return "Segundos";
|
|
10398
|
+
default:
|
|
10399
|
+
return "";
|
|
10400
|
+
}
|
|
10401
|
+
};
|
|
10402
|
+
const getAriaLabel = () => {
|
|
10403
|
+
const baseLabel = getPickerLabel();
|
|
10404
|
+
return `${baseLabel}, valor atual: ${calculatedValue}.`;
|
|
10405
|
+
};
|
|
10406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "relative group flex flex-col items-center", children: [
|
|
10407
|
+
getPickerLabel() && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
10408
|
+
"label",
|
|
10409
|
+
{
|
|
10410
|
+
htmlFor: id || picker,
|
|
10411
|
+
className: "text-xs sm:text-sm font-medium text-muted-foreground mb-1 sm:mb-2 select-none",
|
|
10412
|
+
children: getPickerLabel()
|
|
10413
|
+
}
|
|
10414
|
+
),
|
|
10415
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
10416
|
+
"div",
|
|
10417
|
+
{
|
|
10418
|
+
className: cn(
|
|
10419
|
+
"relative flex flex-col items-center",
|
|
10420
|
+
"transition-all duration-200"
|
|
10421
|
+
),
|
|
10422
|
+
children: [
|
|
10423
|
+
showArrows && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
10424
|
+
"button",
|
|
10425
|
+
{
|
|
10426
|
+
type: "button",
|
|
10427
|
+
onClick: () => handleArrowClick("up"),
|
|
10428
|
+
className: cn(
|
|
10429
|
+
"flex items-center justify-center w-10 sm:w-12 h-5 sm:h-6 mb-1",
|
|
10430
|
+
"rounded-t",
|
|
10431
|
+
"bg-background hover:bg-accent active:bg-accent/80 transition-colors",
|
|
10432
|
+
"text-muted-foreground hover:text-foreground",
|
|
10433
|
+
"focus:outline-none focus:ring-1 focus:ring-ring",
|
|
10434
|
+
"touch-manipulation",
|
|
10435
|
+
isFocused && "border-ring"
|
|
10436
|
+
),
|
|
10437
|
+
tabIndex: -1,
|
|
10438
|
+
"aria-label": `Incrementar ${getPickerLabel().toLowerCase()}`,
|
|
10439
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_react41.CaretUpIcon, { size: 14, className: "sm:w-4 sm:h-4" })
|
|
10440
|
+
}
|
|
10441
|
+
),
|
|
10442
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "relative", children: [
|
|
10443
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
10444
|
+
"input",
|
|
10445
|
+
{
|
|
10446
|
+
ref,
|
|
10447
|
+
id: id || picker,
|
|
10448
|
+
name: name || picker,
|
|
10449
|
+
className: cn(
|
|
10450
|
+
"w-16 sm:w-20 h-10 sm:h-12 text-center font-mono text-lg sm:text-xl font-semibold",
|
|
10451
|
+
"border-2 rounded-lg",
|
|
10452
|
+
"bg-background text-foreground",
|
|
10453
|
+
"transition-all duration-200",
|
|
10454
|
+
"focus:outline-none focus:ring-2 focus:ring-ring focus:border-ring",
|
|
10455
|
+
"selection:bg-primary selection:text-primary-foreground",
|
|
10456
|
+
"touch-manipulation",
|
|
10457
|
+
showArrows && "rounded-lg",
|
|
10458
|
+
isFocused && "ring-2 ring-ring border-ring shadow-md",
|
|
10459
|
+
className
|
|
10460
|
+
),
|
|
10461
|
+
value: value || calculatedValue,
|
|
10462
|
+
onChange: (e) => {
|
|
10463
|
+
e.preventDefault();
|
|
10464
|
+
onChange?.(e);
|
|
10465
|
+
},
|
|
10466
|
+
onFocus: (e) => {
|
|
10467
|
+
setIsFocused(true);
|
|
10468
|
+
props.onFocus?.(e);
|
|
10469
|
+
e.target.select();
|
|
10470
|
+
},
|
|
10471
|
+
onBlur: (e) => {
|
|
10472
|
+
setIsFocused(false);
|
|
10473
|
+
props.onBlur?.(e);
|
|
10474
|
+
},
|
|
10475
|
+
type,
|
|
10476
|
+
inputMode: "decimal",
|
|
10477
|
+
onKeyDown: (e) => {
|
|
10478
|
+
onKeyDown?.(e);
|
|
10479
|
+
handleKeyDown(e);
|
|
10480
|
+
},
|
|
10481
|
+
"aria-label": getAriaLabel(),
|
|
10482
|
+
"aria-describedby": `${id || picker}-help`,
|
|
10483
|
+
autoComplete: "off",
|
|
10484
|
+
spellCheck: false,
|
|
10485
|
+
...props
|
|
10486
|
+
}
|
|
10487
|
+
),
|
|
10488
|
+
isFocused && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "absolute inset-0 rounded-lg ring-2 ring-primary/20 pointer-events-none animate-pulse" })
|
|
10489
|
+
] }),
|
|
10490
|
+
showArrows && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
10491
|
+
"button",
|
|
10492
|
+
{
|
|
10493
|
+
type: "button",
|
|
10494
|
+
onClick: () => handleArrowClick("down"),
|
|
10495
|
+
className: cn(
|
|
10496
|
+
"flex items-center justify-center w-10 sm:w-12 h-5 sm:h-6 mt-1",
|
|
10497
|
+
"rounded-b",
|
|
10498
|
+
"bg-background hover:bg-accent active:bg-accent/80 transition-colors",
|
|
10499
|
+
"text-muted-foreground hover:text-foreground",
|
|
10500
|
+
"focus:outline-none focus:ring-1 focus:ring-ring",
|
|
10501
|
+
"touch-manipulation",
|
|
10502
|
+
isFocused && "border-ring"
|
|
10503
|
+
),
|
|
10504
|
+
tabIndex: -1,
|
|
10505
|
+
"aria-label": `Decrementar ${getPickerLabel().toLowerCase()}`,
|
|
10506
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_react41.CaretDownIcon, { size: 14, className: "sm:w-4 sm:h-4" })
|
|
10507
|
+
}
|
|
10508
|
+
)
|
|
10509
|
+
]
|
|
10510
|
+
}
|
|
10511
|
+
)
|
|
10512
|
+
] });
|
|
10513
|
+
}
|
|
10514
|
+
);
|
|
10515
|
+
TimePickerInput.displayName = "TimePickerInput";
|
|
10516
|
+
|
|
10517
|
+
// src/components/picker/TimePicker.tsx
|
|
10518
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
10519
|
+
function TimePicker({
|
|
10520
|
+
date,
|
|
10521
|
+
setDate,
|
|
10522
|
+
hideSeconds,
|
|
10523
|
+
enableButton
|
|
10524
|
+
}) {
|
|
10525
|
+
const minuteRef = React41.useRef(null);
|
|
10526
|
+
const hourRef = React41.useRef(null);
|
|
10527
|
+
const secondRef = React41.useRef(null);
|
|
10528
|
+
const containerVariants = {
|
|
10529
|
+
hidden: { opacity: 0, y: 10 },
|
|
10530
|
+
visible: {
|
|
10531
|
+
opacity: 1,
|
|
10532
|
+
y: 0,
|
|
10533
|
+
transition: {
|
|
10534
|
+
duration: 0.3,
|
|
10535
|
+
staggerChildren: 0.1
|
|
10536
|
+
}
|
|
10537
|
+
}
|
|
10538
|
+
};
|
|
10539
|
+
const itemVariants2 = {
|
|
10540
|
+
hidden: { opacity: 0, y: 10 },
|
|
10541
|
+
visible: { opacity: 1, y: 0 }
|
|
10542
|
+
};
|
|
10543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
10544
|
+
import_framer_motion15.motion.div,
|
|
10545
|
+
{
|
|
10546
|
+
variants: containerVariants,
|
|
10547
|
+
initial: "hidden",
|
|
10548
|
+
animate: "visible",
|
|
10549
|
+
className: "flex items-end justify-center gap-2 sm:gap-3 p-2 sm:p-3 md:p-4 rounded-lg bg-muted/20 border border-border/50 w-full max-w-full overflow-hidden",
|
|
10550
|
+
children: [
|
|
10551
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
10552
|
+
import_framer_motion15.motion.div,
|
|
10553
|
+
{
|
|
10554
|
+
variants: itemVariants2,
|
|
10555
|
+
className: "grid gap-1 sm:gap-2 text-center flex-shrink-0 min-w-0",
|
|
10556
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
10557
|
+
TimePickerInput,
|
|
10558
|
+
{
|
|
10559
|
+
picker: "hours",
|
|
10560
|
+
date,
|
|
10561
|
+
setDate,
|
|
10562
|
+
ref: hourRef,
|
|
10563
|
+
onRightFocus: () => minuteRef.current?.focus(),
|
|
10564
|
+
enableButton
|
|
10565
|
+
}
|
|
10566
|
+
)
|
|
10567
|
+
}
|
|
10568
|
+
),
|
|
10569
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
10570
|
+
import_framer_motion15.motion.div,
|
|
10571
|
+
{
|
|
10572
|
+
variants: itemVariants2,
|
|
10573
|
+
className: "grid gap-1 sm:gap-2 text-center flex-shrink-0 min-w-0",
|
|
10574
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
10575
|
+
TimePickerInput,
|
|
10576
|
+
{
|
|
10577
|
+
picker: "minutes",
|
|
10578
|
+
date,
|
|
10579
|
+
setDate,
|
|
10580
|
+
ref: minuteRef,
|
|
10581
|
+
onLeftFocus: () => hourRef.current?.focus(),
|
|
10582
|
+
onRightFocus: () => secondRef.current?.focus(),
|
|
10583
|
+
enableButton
|
|
10584
|
+
}
|
|
10585
|
+
)
|
|
10586
|
+
}
|
|
10587
|
+
),
|
|
10588
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_framer_motion15.AnimatePresence, { children: !hideSeconds && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_jsx_runtime65.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
10589
|
+
import_framer_motion15.motion.div,
|
|
10590
|
+
{
|
|
10591
|
+
variants: itemVariants2,
|
|
10592
|
+
initial: "hidden",
|
|
10593
|
+
animate: "visible",
|
|
10594
|
+
exit: "hidden",
|
|
10595
|
+
className: "grid gap-1 sm:gap-2 text-center flex-shrink-0 min-w-0",
|
|
10596
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
10597
|
+
TimePickerInput,
|
|
10598
|
+
{
|
|
10599
|
+
picker: "seconds",
|
|
10600
|
+
date,
|
|
10601
|
+
setDate,
|
|
10602
|
+
ref: secondRef,
|
|
10603
|
+
onLeftFocus: () => minuteRef.current?.focus(),
|
|
10604
|
+
enableButton
|
|
10605
|
+
}
|
|
10606
|
+
)
|
|
10607
|
+
}
|
|
10608
|
+
) }) })
|
|
10609
|
+
]
|
|
10610
|
+
}
|
|
10611
|
+
);
|
|
10612
|
+
}
|
|
10613
|
+
|
|
10614
|
+
// src/components/picker/DateTimePicker.tsx
|
|
10615
|
+
var import_react44 = require("@phosphor-icons/react");
|
|
10616
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
10617
|
+
function DateTimePicker({
|
|
10618
|
+
label,
|
|
10619
|
+
date,
|
|
10620
|
+
onChange,
|
|
10621
|
+
display,
|
|
10622
|
+
hideSeconds,
|
|
10623
|
+
hideHour,
|
|
10624
|
+
hideMinute,
|
|
10625
|
+
fromDate,
|
|
10626
|
+
toDate,
|
|
10627
|
+
disabled,
|
|
10628
|
+
className,
|
|
10629
|
+
error
|
|
10630
|
+
}) {
|
|
10631
|
+
const [internalDate, setInternalDate] = (0, import_react43.useState)(date);
|
|
10632
|
+
const [open, setOpen] = (0, import_react43.useState)(false);
|
|
10633
|
+
const [timePickerOpen, setTimePickerOpen] = (0, import_react43.useState)(false);
|
|
10634
|
+
const handleSelect = (newDay) => {
|
|
10635
|
+
if (!newDay) return;
|
|
10636
|
+
if (!internalDate) {
|
|
10637
|
+
setInternalDate(newDay);
|
|
10638
|
+
onChange(newDay);
|
|
10639
|
+
return;
|
|
10640
|
+
}
|
|
10641
|
+
const diff = newDay.getTime() - internalDate.getTime();
|
|
10642
|
+
const diffInDays = diff / (1e3 * 60 * 60 * 24);
|
|
10643
|
+
const newDateFull = (0, import_date_fns.add)(internalDate, { days: Math.ceil(diffInDays) });
|
|
10644
|
+
setInternalDate(newDateFull);
|
|
10645
|
+
onChange(newDateFull);
|
|
10646
|
+
};
|
|
10647
|
+
const handleTimeChange = (newDate) => {
|
|
10648
|
+
setInternalDate(newDate);
|
|
10649
|
+
onChange(newDate);
|
|
10650
|
+
};
|
|
10651
|
+
const getTimeFormat = () => {
|
|
10652
|
+
if (hideHour && hideMinute) return "";
|
|
10653
|
+
if (hideHour) return hideSeconds ? "mm" : "mm:ss";
|
|
10654
|
+
if (hideMinute) return hideSeconds ? "HH" : "HH':00'";
|
|
10655
|
+
return hideSeconds ? "HH:mm" : "HH:mm:ss";
|
|
10656
|
+
};
|
|
10657
|
+
const getDisplayFormat = () => {
|
|
10658
|
+
const timeFormat = getTimeFormat();
|
|
10659
|
+
if (!timeFormat) return "PPP";
|
|
10660
|
+
return `PPP - ${timeFormat}`;
|
|
10661
|
+
};
|
|
10662
|
+
(0, import_react43.useEffect)(() => {
|
|
10663
|
+
if (date) {
|
|
10664
|
+
setInternalDate(date);
|
|
10665
|
+
}
|
|
10666
|
+
}, [date, open]);
|
|
10667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: cn("space-y-2 w-full sm:w-auto", className), children: [
|
|
10668
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(LabelBase_default, { children: label }),
|
|
10669
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(PopoverBase, { open, onOpenChange: setOpen, children: [
|
|
10670
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(PopoverTriggerBase, { disabled, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
10671
|
+
ButtonBase,
|
|
10672
|
+
{
|
|
10673
|
+
variant: "outline",
|
|
10674
|
+
className: cn(
|
|
10675
|
+
"w-full justify-start text-left min-w-0 overflow-hidden",
|
|
10676
|
+
!date && "text-muted-foreground/"
|
|
10677
|
+
),
|
|
10678
|
+
children: [
|
|
10679
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { className: "truncate flex-1", children: date ? display ? (0, import_date_fns.format)(date, "dd/MM/yyyy") : (0, import_date_fns.format)(date, getDisplayFormat(), { locale: import_locale.ptBR }) : "Selecione uma Data" }),
|
|
10680
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_react44.CalendarBlankIcon, { className: "flex-shrink-0 w-5 h-5 sm:w-6 sm:h-6" })
|
|
10681
|
+
]
|
|
10682
|
+
}
|
|
10683
|
+
) }),
|
|
10684
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ErrorMessage_default, { error }),
|
|
10685
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
10686
|
+
PopoverContentBase,
|
|
10687
|
+
{
|
|
10688
|
+
className: "w-full p-0",
|
|
10689
|
+
align: "center",
|
|
10690
|
+
sideOffset: 4,
|
|
10691
|
+
side: "bottom",
|
|
10692
|
+
avoidCollisions: true,
|
|
10693
|
+
collisionPadding: 8,
|
|
10694
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "flex flex-col space-y-2 sm:space-y-3 p-2 sm:p-3 md:p-4 max-h-[calc(100vh-4rem)] overflow-y-auto", children: [
|
|
10695
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
10696
|
+
CalendarBase2,
|
|
10697
|
+
{
|
|
10698
|
+
mode: "single",
|
|
10699
|
+
locale: import_locale.ptBR,
|
|
10700
|
+
selected: internalDate,
|
|
10701
|
+
onSelect: (d) => handleSelect(d),
|
|
10702
|
+
initialFocus: true,
|
|
10703
|
+
fromDate,
|
|
10704
|
+
toDate,
|
|
10705
|
+
className: cn("w-full", hideHour && hideMinute && "border-0")
|
|
10706
|
+
}
|
|
10707
|
+
),
|
|
10708
|
+
!(hideHour && hideMinute) && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "flex justify-center w-full px-2", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
10709
|
+
PopoverBase,
|
|
10710
|
+
{
|
|
10711
|
+
open: timePickerOpen,
|
|
10712
|
+
onOpenChange: setTimePickerOpen,
|
|
10713
|
+
children: [
|
|
10714
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(PopoverTriggerBase, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
10715
|
+
ButtonBase,
|
|
10716
|
+
{
|
|
10717
|
+
variant: "outline",
|
|
10718
|
+
size: "default",
|
|
10719
|
+
className: cn(
|
|
10720
|
+
"flex items-center justify-center gap-1.5 sm:gap-2",
|
|
10721
|
+
"px-2 sm:px-3 py-1.5 sm:py-2",
|
|
10722
|
+
"text-sm sm:text-base font-semibold w-full max-w-xs",
|
|
10723
|
+
"border-2 border-primary/20 rounded-lg",
|
|
10724
|
+
"bg-background hover:bg-primary/10 hover:border-primary/30",
|
|
10725
|
+
"transition-all duration-200",
|
|
10726
|
+
"shadow-sm hover:shadow-md active:scale-[0.98]",
|
|
10727
|
+
"min-h-[36px] sm:min-h-[40px]"
|
|
10728
|
+
),
|
|
10729
|
+
children: [
|
|
10730
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_react44.ClockIcon, { className: "text-primary flex-shrink-0 w-4 h-4 sm:w-5 sm:h-5" }),
|
|
10731
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { className: "text-black truncate", children: internalDate ? (0, import_date_fns.format)(internalDate, getTimeFormat() || "HH:mm", {
|
|
10732
|
+
locale: import_locale.ptBR
|
|
10733
|
+
}) : "00:00" })
|
|
10734
|
+
]
|
|
10735
|
+
}
|
|
10736
|
+
) }),
|
|
10737
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
10738
|
+
PopoverContentBase,
|
|
10739
|
+
{
|
|
10740
|
+
className: "w-[calc(100vw-2rem)] max-w-sm p-3 sm:p-3 rounded-md",
|
|
10741
|
+
align: "center",
|
|
10742
|
+
side: "top",
|
|
10743
|
+
sideOffset: 8,
|
|
10744
|
+
avoidCollisions: true,
|
|
10745
|
+
collisionPadding: 8,
|
|
10746
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "flex flex-col items-center space-y-2 sm:space-y-3", children: [
|
|
10747
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("h4", { className: "text-sm sm:text-base font-medium text-center", children: "Alterar Hor\xE1rio" }),
|
|
10748
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
10749
|
+
TimePicker,
|
|
10750
|
+
{
|
|
10751
|
+
setDate: handleTimeChange,
|
|
10752
|
+
date: internalDate,
|
|
10753
|
+
hideSeconds
|
|
10754
|
+
}
|
|
10755
|
+
),
|
|
10756
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
10757
|
+
ButtonBase,
|
|
10758
|
+
{
|
|
10759
|
+
size: "sm",
|
|
10760
|
+
variant: "destructive",
|
|
10761
|
+
onClick: () => setTimePickerOpen(false),
|
|
10762
|
+
className: "w-full text-xs sm:text-sm min-h-[36px] sm:min-h-[40px]",
|
|
10763
|
+
children: "Fechar"
|
|
10764
|
+
}
|
|
10765
|
+
)
|
|
10766
|
+
] })
|
|
10767
|
+
}
|
|
10768
|
+
)
|
|
10769
|
+
]
|
|
10770
|
+
}
|
|
10771
|
+
) })
|
|
10772
|
+
] })
|
|
10773
|
+
}
|
|
10774
|
+
)
|
|
10775
|
+
] })
|
|
10776
|
+
] });
|
|
10777
|
+
}
|
|
10778
|
+
|
|
10779
|
+
// src/components/picker/RangePicker.tsx
|
|
10780
|
+
var React42 = __toESM(require("react"));
|
|
10781
|
+
var import_react_day_picker3 = require("react-day-picker");
|
|
10782
|
+
var import_react45 = require("@phosphor-icons/react");
|
|
10783
|
+
var import_framer_motion16 = require("framer-motion");
|
|
10784
|
+
var import_ssr7 = require("@phosphor-icons/react/dist/ssr");
|
|
10785
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
10786
|
+
function RangePicker({
|
|
10787
|
+
value,
|
|
10788
|
+
onChange,
|
|
10789
|
+
label = "Selecionar intervalo",
|
|
10790
|
+
minDate,
|
|
10791
|
+
maxDate,
|
|
10792
|
+
error
|
|
10793
|
+
}) {
|
|
10794
|
+
const [open, setOpen] = React42.useState(false);
|
|
10795
|
+
const [range, setRange] = React42.useState(value);
|
|
10796
|
+
const controls = (0, import_framer_motion16.useAnimation)();
|
|
10797
|
+
React42.useEffect(() => {
|
|
10798
|
+
setRange(value);
|
|
10799
|
+
}, [value]);
|
|
10800
|
+
const handleSelect = (selected) => {
|
|
10801
|
+
setRange(selected);
|
|
10802
|
+
onChange?.(selected);
|
|
10803
|
+
};
|
|
10804
|
+
const handleClear = () => {
|
|
10805
|
+
setRange(void 0);
|
|
10806
|
+
onChange?.(void 0);
|
|
10807
|
+
};
|
|
10808
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(PopoverBase, { open, onOpenChange: setOpen, children: [
|
|
10809
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(PopoverTriggerBase, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10810
|
+
import_framer_motion16.motion.div,
|
|
10811
|
+
{
|
|
10812
|
+
whileTap: { scale: 0.97 },
|
|
10813
|
+
whileHover: { scale: open ? 1.03 : 1.01 },
|
|
10814
|
+
transition: { type: "spring", stiffness: 300, damping: 20 },
|
|
10815
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
10816
|
+
ButtonBase,
|
|
10817
|
+
{
|
|
10818
|
+
variant: "outline",
|
|
10819
|
+
className: "flex gap-2 transition-all duration-200 min-w-[250px] text-left justify-between items-center",
|
|
10820
|
+
children: [
|
|
10821
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10822
|
+
import_framer_motion16.motion.span,
|
|
10823
|
+
{
|
|
10824
|
+
className: "text-sm font-medium",
|
|
10825
|
+
transition: { duration: 0.2 },
|
|
10826
|
+
animate: controls,
|
|
10827
|
+
children: range?.from && range?.to ? `${range.from.toLocaleDateString()} - ${range.to.toLocaleDateString()}` : label
|
|
10828
|
+
}
|
|
10829
|
+
),
|
|
10830
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10831
|
+
import_framer_motion16.motion.span,
|
|
10832
|
+
{
|
|
10833
|
+
animate: open ? { rotate: 8, scale: 1.15 } : { rotate: 0, scale: 1 },
|
|
10834
|
+
transition: { type: "spring", stiffness: 300, damping: 18 },
|
|
10835
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_react45.CalendarBlankIcon, { className: "w-4 h-4 transition-transform group-hover:scale-110" })
|
|
10836
|
+
}
|
|
10837
|
+
)
|
|
10838
|
+
]
|
|
10839
|
+
}
|
|
10840
|
+
)
|
|
10841
|
+
}
|
|
10842
|
+
) }),
|
|
10843
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ErrorMessage_default, { error }),
|
|
10844
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_framer_motion16.AnimatePresence, { children: open && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10845
|
+
PopoverContentBase,
|
|
10846
|
+
{
|
|
10847
|
+
asChild: true,
|
|
10848
|
+
className: "w-auto min-w-[250px] p-0 shadow-xl overflow-y-hidden",
|
|
10849
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
10850
|
+
import_framer_motion16.motion.div,
|
|
10851
|
+
{
|
|
10852
|
+
initial: { opacity: 0, y: 16 },
|
|
10853
|
+
animate: { opacity: 1, y: 0 },
|
|
10854
|
+
exit: { opacity: 0, y: 16 },
|
|
10855
|
+
transition: { duration: 0.18, ease: "easeOut" },
|
|
10856
|
+
children: [
|
|
10857
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "p-4", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10858
|
+
import_framer_motion16.motion.div,
|
|
10859
|
+
{
|
|
10860
|
+
initial: { opacity: 0, y: 8 },
|
|
10861
|
+
animate: { opacity: 1, y: 0 },
|
|
10862
|
+
exit: { opacity: 0, y: 8 },
|
|
10863
|
+
transition: { duration: 0.18 },
|
|
10864
|
+
className: "w-full",
|
|
10865
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10866
|
+
import_react_day_picker3.DayPicker,
|
|
10867
|
+
{
|
|
10868
|
+
mode: "range",
|
|
10869
|
+
selected: range,
|
|
10870
|
+
onSelect: handleSelect,
|
|
10871
|
+
showOutsideDays: true,
|
|
10872
|
+
fromDate: minDate,
|
|
10873
|
+
toDate: maxDate,
|
|
10874
|
+
className: "min-w-0 flex flex-col",
|
|
10875
|
+
classNames: {
|
|
10876
|
+
months: "flex items-center flex-col sm:flex-row space-y-2 sm:space-x-2 sm:space-y-0 flex-1",
|
|
10877
|
+
month: "space-y-2 min-w-0 flex-1 flex flex-col",
|
|
10878
|
+
caption: "flex justify-center pt-1 relative items-center h-[10%] min-h-[2rem] mb-2",
|
|
10879
|
+
caption_label: "text-[clamp(0.875rem,2.5vw,1.25rem)] font-semibold truncate px-10 tracking-tight",
|
|
10880
|
+
nav: "space-x-1 flex items-center",
|
|
10881
|
+
nav_button: cn(
|
|
10882
|
+
buttonVariantsBase({ variant: "outline" }),
|
|
10883
|
+
"h-8 w-8 bg-background p-0 opacity-60 hover:opacity-100 hover:bg-muted flex-shrink-0 touch-manipulation transition-all duration-200 ease-out hover:scale-105 active:scale-95",
|
|
10884
|
+
"[@media(min-width:400px)]:h-9 [@media(min-width:400px)]:w-9"
|
|
10885
|
+
),
|
|
10886
|
+
nav_button_previous: "absolute left-0",
|
|
10887
|
+
nav_button_next: "absolute right-0",
|
|
10888
|
+
table: "w-full border-collapse min-w-0 flex-1 flex flex-col",
|
|
10889
|
+
head_row: "flex w-full gap-1 mb-1",
|
|
10890
|
+
head_cell: "text-muted-foreground rounded-md flex-1 min-w-0 font-semibold text-[clamp(0.625rem,1.5vw,0.75rem)] text-center pb-1 uppercase tracking-wider",
|
|
10891
|
+
row: "flex w-full flex-1 gap-1",
|
|
10892
|
+
cell: cn(
|
|
10893
|
+
"flex-1 min-w-0 aspect-square text-center relative",
|
|
10894
|
+
"[&:has([aria-selected].day-range-end)]:rounded-r-lg",
|
|
10895
|
+
"[&:has([aria-selected].day-range-start)]:rounded-l-lg",
|
|
10896
|
+
"[&:has([aria-selected].day-outside)]:bg-muted/50",
|
|
10897
|
+
"[&:has([aria-selected])]:bg-muted",
|
|
10898
|
+
"first:[&:has([aria-selected])]:rounded-l-lg",
|
|
10899
|
+
"last:[&:has([aria-selected])]:rounded-r-lg",
|
|
10900
|
+
"focus-within:relative focus-within:z-20"
|
|
10901
|
+
),
|
|
10902
|
+
day: cn(
|
|
10903
|
+
buttonVariantsBase({ variant: "ghost" }),
|
|
10904
|
+
"w-full h-full min-w-9",
|
|
10905
|
+
"aria-selected:opacity-100 hover:bg-muted flex items-center justify-center p-1",
|
|
10906
|
+
"transition-all duration-200 ease-out !scale-100 aria-selected:!scale-100 hover:!scale-100 active:!scale-100"
|
|
10907
|
+
),
|
|
10908
|
+
day_selected: "bg-primary text-primary-foreground hover:bg-primary/90 focus:bg-primary/90 font-semibold hover:text-white !scale-100 p-1 !border-0 !outline-none",
|
|
10909
|
+
day_today: "bg-muted text-foreground font-bold ring-2 ring-primary/50 ring-inset p-1 !border-0 !outline-none",
|
|
10910
|
+
day_outside: "day-outside text-muted-foreground/40 opacity-40 aria-selected:bg-muted/50 aria-selected:text-foreground",
|
|
10911
|
+
day_disabled: "text-muted-foreground/30 opacity-40 cursor-not-allowed",
|
|
10912
|
+
day_range_middle: "aria-selected:bg-muted aria-selected:text-foreground",
|
|
10913
|
+
day_hidden: "invisible"
|
|
10914
|
+
},
|
|
10915
|
+
components: {
|
|
10916
|
+
IconLeft: () => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_react45.CaretLeftIcon, { className: "h-4 w-4" }),
|
|
10917
|
+
IconRight: () => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_react45.CaretRightIcon, { className: "h-4 w-4" })
|
|
10918
|
+
}
|
|
10919
|
+
}
|
|
10920
|
+
)
|
|
10921
|
+
}
|
|
10922
|
+
) }),
|
|
10923
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex justify-end gap-2 px-4 pb-4", children: [
|
|
10924
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { style: { display: "inline-block" }, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10925
|
+
import_framer_motion16.motion.div,
|
|
10926
|
+
{
|
|
10927
|
+
whileHover: { scale: 1.03 },
|
|
10928
|
+
whileTap: { scale: 0.95 },
|
|
10929
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10930
|
+
ButtonBase,
|
|
10931
|
+
{
|
|
10932
|
+
variant: "outline",
|
|
10933
|
+
onClick: () => {
|
|
10934
|
+
setRange({
|
|
10935
|
+
from: /* @__PURE__ */ new Date(),
|
|
10936
|
+
to: /* @__PURE__ */ new Date()
|
|
10937
|
+
});
|
|
10938
|
+
},
|
|
10939
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_ssr7.CalendarDotIcon, {})
|
|
10940
|
+
}
|
|
10941
|
+
)
|
|
10942
|
+
}
|
|
10943
|
+
) }),
|
|
10944
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { style: { display: "inline-block" }, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10945
|
+
import_framer_motion16.motion.div,
|
|
10946
|
+
{
|
|
10947
|
+
whileHover: { scale: 1.03 },
|
|
10948
|
+
whileTap: { scale: 0.95 },
|
|
10949
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10950
|
+
DeleteButton,
|
|
10951
|
+
{
|
|
10952
|
+
variant: "outline",
|
|
10953
|
+
onClick: handleClear,
|
|
10954
|
+
disabled: !range?.from && !range?.to,
|
|
10955
|
+
className: "hover:bg-destructive hover:text-white",
|
|
10956
|
+
children: "Limpar"
|
|
10957
|
+
}
|
|
10958
|
+
)
|
|
10959
|
+
}
|
|
10960
|
+
) }),
|
|
10961
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { style: { display: "inline-block", width: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10962
|
+
import_framer_motion16.motion.div,
|
|
10963
|
+
{
|
|
10964
|
+
whileHover: { scale: 1.02 },
|
|
10965
|
+
whileTap: { scale: 0.98 },
|
|
10966
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10967
|
+
ButtonBase,
|
|
10968
|
+
{
|
|
10969
|
+
className: "font-semibold w-full text-center",
|
|
10970
|
+
onClick: () => setOpen(false),
|
|
10971
|
+
disabled: !range?.from || !range?.to,
|
|
10972
|
+
children: "Selecionar"
|
|
10973
|
+
}
|
|
10974
|
+
)
|
|
10975
|
+
}
|
|
10976
|
+
) })
|
|
10977
|
+
] })
|
|
10978
|
+
]
|
|
10979
|
+
}
|
|
10980
|
+
)
|
|
10981
|
+
}
|
|
10982
|
+
) })
|
|
10983
|
+
] });
|
|
10984
|
+
}
|
|
10985
|
+
RangePicker.displayName = "RangePicker";
|
|
10986
|
+
|
|
10044
10987
|
// src/hooks/use-drag.tsx
|
|
10045
|
-
var
|
|
10988
|
+
var import_react46 = require("react");
|
|
10046
10989
|
var useDrag = (options = {}) => {
|
|
10047
|
-
const [isDragging, setIsDragging] = (0,
|
|
10048
|
-
const [positions, setPositions] = (0,
|
|
10049
|
-
const dragStartPos = (0,
|
|
10050
|
-
const dragId = (0,
|
|
10051
|
-
const handleMouseDown = (0,
|
|
10990
|
+
const [isDragging, setIsDragging] = (0, import_react46.useState)(null);
|
|
10991
|
+
const [positions, setPositions] = (0, import_react46.useState)({});
|
|
10992
|
+
const dragStartPos = (0, import_react46.useRef)(null);
|
|
10993
|
+
const dragId = (0, import_react46.useRef)(null);
|
|
10994
|
+
const handleMouseDown = (0, import_react46.useCallback)((id, e) => {
|
|
10052
10995
|
e.preventDefault();
|
|
10053
10996
|
const currentPosition = positions[id] || { top: 0, left: 0 };
|
|
10054
10997
|
dragStartPos.current = {
|
|
@@ -10061,7 +11004,7 @@ var useDrag = (options = {}) => {
|
|
|
10061
11004
|
setIsDragging(id);
|
|
10062
11005
|
options.onDragStart?.(id);
|
|
10063
11006
|
}, [positions, options]);
|
|
10064
|
-
const handleMouseMove = (0,
|
|
11007
|
+
const handleMouseMove = (0, import_react46.useCallback)((e) => {
|
|
10065
11008
|
if (!isDragging || !dragStartPos.current || !dragId.current) return;
|
|
10066
11009
|
const deltaX = e.clientX - dragStartPos.current.x;
|
|
10067
11010
|
const deltaY = e.clientY - dragStartPos.current.y;
|
|
@@ -10077,7 +11020,7 @@ var useDrag = (options = {}) => {
|
|
|
10077
11020
|
}));
|
|
10078
11021
|
options.onDrag?.(dragId.current, newPosition);
|
|
10079
11022
|
}, [isDragging, options]);
|
|
10080
|
-
const handleMouseUp = (0,
|
|
11023
|
+
const handleMouseUp = (0, import_react46.useCallback)(() => {
|
|
10081
11024
|
if (dragId.current) {
|
|
10082
11025
|
options.onDragEnd?.(dragId.current);
|
|
10083
11026
|
}
|
|
@@ -10085,7 +11028,7 @@ var useDrag = (options = {}) => {
|
|
|
10085
11028
|
dragStartPos.current = null;
|
|
10086
11029
|
dragId.current = null;
|
|
10087
11030
|
}, [options]);
|
|
10088
|
-
(0,
|
|
11031
|
+
(0, import_react46.useEffect)(() => {
|
|
10089
11032
|
if (isDragging) {
|
|
10090
11033
|
document.addEventListener("mousemove", handleMouseMove);
|
|
10091
11034
|
document.addEventListener("mouseup", handleMouseUp);
|
|
@@ -10097,16 +11040,16 @@ var useDrag = (options = {}) => {
|
|
|
10097
11040
|
};
|
|
10098
11041
|
}
|
|
10099
11042
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
10100
|
-
const setPosition = (0,
|
|
11043
|
+
const setPosition = (0, import_react46.useCallback)((id, position) => {
|
|
10101
11044
|
setPositions((prev) => ({
|
|
10102
11045
|
...prev,
|
|
10103
11046
|
[id]: position
|
|
10104
11047
|
}));
|
|
10105
11048
|
}, []);
|
|
10106
|
-
const getPosition = (0,
|
|
11049
|
+
const getPosition = (0, import_react46.useCallback)((id) => {
|
|
10107
11050
|
return positions[id] || { top: 0, left: 0 };
|
|
10108
11051
|
}, [positions]);
|
|
10109
|
-
const isElementDragging = (0,
|
|
11052
|
+
const isElementDragging = (0, import_react46.useCallback)((id) => {
|
|
10110
11053
|
return isDragging === id;
|
|
10111
11054
|
}, [isDragging]);
|
|
10112
11055
|
return {
|