shadcn-zod-formkit 1.31.0 → 1.34.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/dist/index.cjs CHANGED
@@ -27,6 +27,7 @@ var sonner = require('sonner');
27
27
  var SwitchPrimitive = require('@radix-ui/react-switch');
28
28
  var TooltipPrimitive = require('@radix-ui/react-tooltip');
29
29
  var cmdk = require('cmdk');
30
+ var dateFns = require('date-fns');
30
31
  var TabsPrimitive = require('@radix-ui/react-tabs');
31
32
  var SliderPrimitive = require('@radix-ui/react-slider');
32
33
  var core = require('@dnd-kit/core');
@@ -461,8 +462,8 @@ var buttonVariants = classVarianceAuthority.cva(
461
462
  );
462
463
  function Button({
463
464
  className,
464
- variant,
465
- size,
465
+ variant = "default",
466
+ size = "default",
466
467
  asChild = false,
467
468
  ...props
468
469
  }) {
@@ -471,6 +472,8 @@ function Button({
471
472
  Comp,
472
473
  {
473
474
  "data-slot": "button",
475
+ "data-variant": variant,
476
+ "data-size": size,
474
477
  className: cn(buttonVariants({ variant, size, className })),
475
478
  ...props
476
479
  }
@@ -482,7 +485,7 @@ function Calendar({
482
485
  showOutsideDays = true,
483
486
  captionLayout = "label",
484
487
  buttonVariant = "ghost",
485
- formatters: formatters2,
488
+ formatters,
486
489
  components,
487
490
  ...props
488
491
  }) {
@@ -500,7 +503,7 @@ function Calendar({
500
503
  captionLayout,
501
504
  formatters: {
502
505
  formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }),
503
- ...formatters2
506
+ ...formatters
504
507
  },
505
508
  classNames: {
506
509
  root: cn("w-fit", defaultClassNames.root),
@@ -560,7 +563,8 @@ function Calendar({
560
563
  defaultClassNames.week_number
561
564
  ),
562
565
  day: cn(
563
- "relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
566
+ "relative w-full h-full p-0 text-center [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
567
+ props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md" : "[&:first-child[data-selected=true]_button]:rounded-l-md",
564
568
  defaultClassNames.day
565
569
  ),
566
570
  range_start: cn(
@@ -2615,7 +2619,7 @@ var FieldCurrency = ({ form, input, isSubmitting }) => {
2615
2619
  const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
2616
2620
  const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
2617
2621
  const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
2618
- const [isValid2, setIsValid] = React3.useState(() => {
2622
+ const [isValid, setIsValid] = React3.useState(() => {
2619
2623
  const value = form.getValues(input.name);
2620
2624
  const fieldState = form.getFieldState(input.name);
2621
2625
  return !fieldState.error && value !== void 0 && value !== "";
@@ -2675,7 +2679,7 @@ var FieldCurrency = ({ form, input, isSubmitting }) => {
2675
2679
  name: input.name,
2676
2680
  render: ({ field, fieldState }) => {
2677
2681
  const validNow = !fieldState.error && field.value !== void 0 && field.value !== "";
2678
- if (validNow !== isValid2) setIsValid(validNow);
2682
+ if (validNow !== isValid) setIsValid(validNow);
2679
2683
  return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
2680
2684
  /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
2681
2685
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { children: [
@@ -2712,7 +2716,7 @@ var FieldCurrency = ({ form, input, isSubmitting }) => {
2712
2716
  /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
2713
2717
  /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: currencyFormat.currency }),
2714
2718
  input.inputGroupConfig?.textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: input.inputGroupConfig.textRight }),
2715
- autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
2719
+ autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid ? iconValidState : iconInvalidState })
2716
2720
  ] })
2717
2721
  ] }) }),
2718
2722
  /* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
@@ -2721,1562 +2725,6 @@ var FieldCurrency = ({ form, input, isSubmitting }) => {
2721
2725
  }
2722
2726
  );
2723
2727
  };
2724
- var millisecondsInWeek = 6048e5;
2725
- var millisecondsInDay = 864e5;
2726
- var constructFromSymbol = Symbol.for("constructDateFrom");
2727
-
2728
- // node_modules/date-fns/constructFrom.js
2729
- function constructFrom(date, value) {
2730
- if (typeof date === "function") return date(value);
2731
- if (date && typeof date === "object" && constructFromSymbol in date)
2732
- return date[constructFromSymbol](value);
2733
- if (date instanceof Date) return new date.constructor(value);
2734
- return new Date(value);
2735
- }
2736
-
2737
- // node_modules/date-fns/toDate.js
2738
- function toDate(argument, context) {
2739
- return constructFrom(context || argument, argument);
2740
- }
2741
-
2742
- // node_modules/date-fns/_lib/defaultOptions.js
2743
- var defaultOptions = {};
2744
- function getDefaultOptions() {
2745
- return defaultOptions;
2746
- }
2747
-
2748
- // node_modules/date-fns/startOfWeek.js
2749
- function startOfWeek(date, options) {
2750
- const defaultOptions2 = getDefaultOptions();
2751
- const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
2752
- const _date = toDate(date, options?.in);
2753
- const day = _date.getDay();
2754
- const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
2755
- _date.setDate(_date.getDate() - diff);
2756
- _date.setHours(0, 0, 0, 0);
2757
- return _date;
2758
- }
2759
-
2760
- // node_modules/date-fns/startOfISOWeek.js
2761
- function startOfISOWeek(date, options) {
2762
- return startOfWeek(date, { ...options, weekStartsOn: 1 });
2763
- }
2764
-
2765
- // node_modules/date-fns/getISOWeekYear.js
2766
- function getISOWeekYear(date, options) {
2767
- const _date = toDate(date, options?.in);
2768
- const year = _date.getFullYear();
2769
- const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
2770
- fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
2771
- fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
2772
- const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
2773
- const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
2774
- fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
2775
- fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
2776
- const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
2777
- if (_date.getTime() >= startOfNextYear.getTime()) {
2778
- return year + 1;
2779
- } else if (_date.getTime() >= startOfThisYear.getTime()) {
2780
- return year;
2781
- } else {
2782
- return year - 1;
2783
- }
2784
- }
2785
-
2786
- // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
2787
- function getTimezoneOffsetInMilliseconds(date) {
2788
- const _date = toDate(date);
2789
- const utcDate = new Date(
2790
- Date.UTC(
2791
- _date.getFullYear(),
2792
- _date.getMonth(),
2793
- _date.getDate(),
2794
- _date.getHours(),
2795
- _date.getMinutes(),
2796
- _date.getSeconds(),
2797
- _date.getMilliseconds()
2798
- )
2799
- );
2800
- utcDate.setUTCFullYear(_date.getFullYear());
2801
- return +date - +utcDate;
2802
- }
2803
-
2804
- // node_modules/date-fns/_lib/normalizeDates.js
2805
- function normalizeDates(context, ...dates) {
2806
- const normalize = constructFrom.bind(
2807
- null,
2808
- dates.find((date) => typeof date === "object")
2809
- );
2810
- return dates.map(normalize);
2811
- }
2812
-
2813
- // node_modules/date-fns/startOfDay.js
2814
- function startOfDay(date, options) {
2815
- const _date = toDate(date, options?.in);
2816
- _date.setHours(0, 0, 0, 0);
2817
- return _date;
2818
- }
2819
-
2820
- // node_modules/date-fns/differenceInCalendarDays.js
2821
- function differenceInCalendarDays(laterDate, earlierDate, options) {
2822
- const [laterDate_, earlierDate_] = normalizeDates(
2823
- options?.in,
2824
- laterDate,
2825
- earlierDate
2826
- );
2827
- const laterStartOfDay = startOfDay(laterDate_);
2828
- const earlierStartOfDay = startOfDay(earlierDate_);
2829
- const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
2830
- const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
2831
- return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
2832
- }
2833
-
2834
- // node_modules/date-fns/startOfISOWeekYear.js
2835
- function startOfISOWeekYear(date, options) {
2836
- const year = getISOWeekYear(date, options);
2837
- const fourthOfJanuary = constructFrom(date, 0);
2838
- fourthOfJanuary.setFullYear(year, 0, 4);
2839
- fourthOfJanuary.setHours(0, 0, 0, 0);
2840
- return startOfISOWeek(fourthOfJanuary);
2841
- }
2842
-
2843
- // node_modules/date-fns/isDate.js
2844
- function isDate(value) {
2845
- return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
2846
- }
2847
-
2848
- // node_modules/date-fns/isValid.js
2849
- function isValid(date) {
2850
- return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
2851
- }
2852
-
2853
- // node_modules/date-fns/startOfYear.js
2854
- function startOfYear(date, options) {
2855
- const date_ = toDate(date, options?.in);
2856
- date_.setFullYear(date_.getFullYear(), 0, 1);
2857
- date_.setHours(0, 0, 0, 0);
2858
- return date_;
2859
- }
2860
-
2861
- // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
2862
- var formatDistanceLocale = {
2863
- lessThanXSeconds: {
2864
- one: "less than a second",
2865
- other: "less than {{count}} seconds"
2866
- },
2867
- xSeconds: {
2868
- one: "1 second",
2869
- other: "{{count}} seconds"
2870
- },
2871
- halfAMinute: "half a minute",
2872
- lessThanXMinutes: {
2873
- one: "less than a minute",
2874
- other: "less than {{count}} minutes"
2875
- },
2876
- xMinutes: {
2877
- one: "1 minute",
2878
- other: "{{count}} minutes"
2879
- },
2880
- aboutXHours: {
2881
- one: "about 1 hour",
2882
- other: "about {{count}} hours"
2883
- },
2884
- xHours: {
2885
- one: "1 hour",
2886
- other: "{{count}} hours"
2887
- },
2888
- xDays: {
2889
- one: "1 day",
2890
- other: "{{count}} days"
2891
- },
2892
- aboutXWeeks: {
2893
- one: "about 1 week",
2894
- other: "about {{count}} weeks"
2895
- },
2896
- xWeeks: {
2897
- one: "1 week",
2898
- other: "{{count}} weeks"
2899
- },
2900
- aboutXMonths: {
2901
- one: "about 1 month",
2902
- other: "about {{count}} months"
2903
- },
2904
- xMonths: {
2905
- one: "1 month",
2906
- other: "{{count}} months"
2907
- },
2908
- aboutXYears: {
2909
- one: "about 1 year",
2910
- other: "about {{count}} years"
2911
- },
2912
- xYears: {
2913
- one: "1 year",
2914
- other: "{{count}} years"
2915
- },
2916
- overXYears: {
2917
- one: "over 1 year",
2918
- other: "over {{count}} years"
2919
- },
2920
- almostXYears: {
2921
- one: "almost 1 year",
2922
- other: "almost {{count}} years"
2923
- }
2924
- };
2925
- var formatDistance = (token, count, options) => {
2926
- let result;
2927
- const tokenValue = formatDistanceLocale[token];
2928
- if (typeof tokenValue === "string") {
2929
- result = tokenValue;
2930
- } else if (count === 1) {
2931
- result = tokenValue.one;
2932
- } else {
2933
- result = tokenValue.other.replace("{{count}}", count.toString());
2934
- }
2935
- if (options?.addSuffix) {
2936
- if (options.comparison && options.comparison > 0) {
2937
- return "in " + result;
2938
- } else {
2939
- return result + " ago";
2940
- }
2941
- }
2942
- return result;
2943
- };
2944
-
2945
- // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
2946
- function buildFormatLongFn(args) {
2947
- return (options = {}) => {
2948
- const width = options.width ? String(options.width) : args.defaultWidth;
2949
- const format2 = args.formats[width] || args.formats[args.defaultWidth];
2950
- return format2;
2951
- };
2952
- }
2953
-
2954
- // node_modules/date-fns/locale/en-US/_lib/formatLong.js
2955
- var dateFormats = {
2956
- full: "EEEE, MMMM do, y",
2957
- long: "MMMM do, y",
2958
- medium: "MMM d, y",
2959
- short: "MM/dd/yyyy"
2960
- };
2961
- var timeFormats = {
2962
- full: "h:mm:ss a zzzz",
2963
- long: "h:mm:ss a z",
2964
- medium: "h:mm:ss a",
2965
- short: "h:mm a"
2966
- };
2967
- var dateTimeFormats = {
2968
- full: "{{date}} 'at' {{time}}",
2969
- long: "{{date}} 'at' {{time}}",
2970
- medium: "{{date}}, {{time}}",
2971
- short: "{{date}}, {{time}}"
2972
- };
2973
- var formatLong = {
2974
- date: buildFormatLongFn({
2975
- formats: dateFormats,
2976
- defaultWidth: "full"
2977
- }),
2978
- time: buildFormatLongFn({
2979
- formats: timeFormats,
2980
- defaultWidth: "full"
2981
- }),
2982
- dateTime: buildFormatLongFn({
2983
- formats: dateTimeFormats,
2984
- defaultWidth: "full"
2985
- })
2986
- };
2987
-
2988
- // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
2989
- var formatRelativeLocale = {
2990
- lastWeek: "'last' eeee 'at' p",
2991
- yesterday: "'yesterday at' p",
2992
- today: "'today at' p",
2993
- tomorrow: "'tomorrow at' p",
2994
- nextWeek: "eeee 'at' p",
2995
- other: "P"
2996
- };
2997
- var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
2998
-
2999
- // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
3000
- function buildLocalizeFn(args) {
3001
- return (value, options) => {
3002
- const context = options?.context ? String(options.context) : "standalone";
3003
- let valuesArray;
3004
- if (context === "formatting" && args.formattingValues) {
3005
- const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
3006
- const width = options?.width ? String(options.width) : defaultWidth;
3007
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
3008
- } else {
3009
- const defaultWidth = args.defaultWidth;
3010
- const width = options?.width ? String(options.width) : args.defaultWidth;
3011
- valuesArray = args.values[width] || args.values[defaultWidth];
3012
- }
3013
- const index = args.argumentCallback ? args.argumentCallback(value) : value;
3014
- return valuesArray[index];
3015
- };
3016
- }
3017
-
3018
- // node_modules/date-fns/locale/en-US/_lib/localize.js
3019
- var eraValues = {
3020
- narrow: ["B", "A"],
3021
- abbreviated: ["BC", "AD"],
3022
- wide: ["Before Christ", "Anno Domini"]
3023
- };
3024
- var quarterValues = {
3025
- narrow: ["1", "2", "3", "4"],
3026
- abbreviated: ["Q1", "Q2", "Q3", "Q4"],
3027
- wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
3028
- };
3029
- var monthValues = {
3030
- narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
3031
- abbreviated: [
3032
- "Jan",
3033
- "Feb",
3034
- "Mar",
3035
- "Apr",
3036
- "May",
3037
- "Jun",
3038
- "Jul",
3039
- "Aug",
3040
- "Sep",
3041
- "Oct",
3042
- "Nov",
3043
- "Dec"
3044
- ],
3045
- wide: [
3046
- "January",
3047
- "February",
3048
- "March",
3049
- "April",
3050
- "May",
3051
- "June",
3052
- "July",
3053
- "August",
3054
- "September",
3055
- "October",
3056
- "November",
3057
- "December"
3058
- ]
3059
- };
3060
- var dayValues = {
3061
- narrow: ["S", "M", "T", "W", "T", "F", "S"],
3062
- short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
3063
- abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
3064
- wide: [
3065
- "Sunday",
3066
- "Monday",
3067
- "Tuesday",
3068
- "Wednesday",
3069
- "Thursday",
3070
- "Friday",
3071
- "Saturday"
3072
- ]
3073
- };
3074
- var dayPeriodValues = {
3075
- narrow: {
3076
- am: "a",
3077
- pm: "p",
3078
- midnight: "mi",
3079
- noon: "n",
3080
- morning: "morning",
3081
- afternoon: "afternoon",
3082
- evening: "evening",
3083
- night: "night"
3084
- },
3085
- abbreviated: {
3086
- am: "AM",
3087
- pm: "PM",
3088
- midnight: "midnight",
3089
- noon: "noon",
3090
- morning: "morning",
3091
- afternoon: "afternoon",
3092
- evening: "evening",
3093
- night: "night"
3094
- },
3095
- wide: {
3096
- am: "a.m.",
3097
- pm: "p.m.",
3098
- midnight: "midnight",
3099
- noon: "noon",
3100
- morning: "morning",
3101
- afternoon: "afternoon",
3102
- evening: "evening",
3103
- night: "night"
3104
- }
3105
- };
3106
- var formattingDayPeriodValues = {
3107
- narrow: {
3108
- am: "a",
3109
- pm: "p",
3110
- midnight: "mi",
3111
- noon: "n",
3112
- morning: "in the morning",
3113
- afternoon: "in the afternoon",
3114
- evening: "in the evening",
3115
- night: "at night"
3116
- },
3117
- abbreviated: {
3118
- am: "AM",
3119
- pm: "PM",
3120
- midnight: "midnight",
3121
- noon: "noon",
3122
- morning: "in the morning",
3123
- afternoon: "in the afternoon",
3124
- evening: "in the evening",
3125
- night: "at night"
3126
- },
3127
- wide: {
3128
- am: "a.m.",
3129
- pm: "p.m.",
3130
- midnight: "midnight",
3131
- noon: "noon",
3132
- morning: "in the morning",
3133
- afternoon: "in the afternoon",
3134
- evening: "in the evening",
3135
- night: "at night"
3136
- }
3137
- };
3138
- var ordinalNumber = (dirtyNumber, _options) => {
3139
- const number = Number(dirtyNumber);
3140
- const rem100 = number % 100;
3141
- if (rem100 > 20 || rem100 < 10) {
3142
- switch (rem100 % 10) {
3143
- case 1:
3144
- return number + "st";
3145
- case 2:
3146
- return number + "nd";
3147
- case 3:
3148
- return number + "rd";
3149
- }
3150
- }
3151
- return number + "th";
3152
- };
3153
- var localize = {
3154
- ordinalNumber,
3155
- era: buildLocalizeFn({
3156
- values: eraValues,
3157
- defaultWidth: "wide"
3158
- }),
3159
- quarter: buildLocalizeFn({
3160
- values: quarterValues,
3161
- defaultWidth: "wide",
3162
- argumentCallback: (quarter) => quarter - 1
3163
- }),
3164
- month: buildLocalizeFn({
3165
- values: monthValues,
3166
- defaultWidth: "wide"
3167
- }),
3168
- day: buildLocalizeFn({
3169
- values: dayValues,
3170
- defaultWidth: "wide"
3171
- }),
3172
- dayPeriod: buildLocalizeFn({
3173
- values: dayPeriodValues,
3174
- defaultWidth: "wide",
3175
- formattingValues: formattingDayPeriodValues,
3176
- defaultFormattingWidth: "wide"
3177
- })
3178
- };
3179
-
3180
- // node_modules/date-fns/locale/_lib/buildMatchFn.js
3181
- function buildMatchFn(args) {
3182
- return (string, options = {}) => {
3183
- const width = options.width;
3184
- const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
3185
- const matchResult = string.match(matchPattern);
3186
- if (!matchResult) {
3187
- return null;
3188
- }
3189
- const matchedString = matchResult[0];
3190
- const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
3191
- const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
3192
- // [TODO] -- I challenge you to fix the type
3193
- findKey(parsePatterns, (pattern) => pattern.test(matchedString))
3194
- );
3195
- let value;
3196
- value = args.valueCallback ? args.valueCallback(key) : key;
3197
- value = options.valueCallback ? (
3198
- // [TODO] -- I challenge you to fix the type
3199
- options.valueCallback(value)
3200
- ) : value;
3201
- const rest = string.slice(matchedString.length);
3202
- return { value, rest };
3203
- };
3204
- }
3205
- function findKey(object, predicate) {
3206
- for (const key in object) {
3207
- if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
3208
- return key;
3209
- }
3210
- }
3211
- return void 0;
3212
- }
3213
- function findIndex(array, predicate) {
3214
- for (let key = 0; key < array.length; key++) {
3215
- if (predicate(array[key])) {
3216
- return key;
3217
- }
3218
- }
3219
- return void 0;
3220
- }
3221
-
3222
- // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
3223
- function buildMatchPatternFn(args) {
3224
- return (string, options = {}) => {
3225
- const matchResult = string.match(args.matchPattern);
3226
- if (!matchResult) return null;
3227
- const matchedString = matchResult[0];
3228
- const parseResult = string.match(args.parsePattern);
3229
- if (!parseResult) return null;
3230
- let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
3231
- value = options.valueCallback ? options.valueCallback(value) : value;
3232
- const rest = string.slice(matchedString.length);
3233
- return { value, rest };
3234
- };
3235
- }
3236
-
3237
- // node_modules/date-fns/locale/en-US/_lib/match.js
3238
- var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
3239
- var parseOrdinalNumberPattern = /\d+/i;
3240
- var matchEraPatterns = {
3241
- narrow: /^(b|a)/i,
3242
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
3243
- wide: /^(before christ|before common era|anno domini|common era)/i
3244
- };
3245
- var parseEraPatterns = {
3246
- any: [/^b/i, /^(a|c)/i]
3247
- };
3248
- var matchQuarterPatterns = {
3249
- narrow: /^[1234]/i,
3250
- abbreviated: /^q[1234]/i,
3251
- wide: /^[1234](th|st|nd|rd)? quarter/i
3252
- };
3253
- var parseQuarterPatterns = {
3254
- any: [/1/i, /2/i, /3/i, /4/i]
3255
- };
3256
- var matchMonthPatterns = {
3257
- narrow: /^[jfmasond]/i,
3258
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
3259
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
3260
- };
3261
- var parseMonthPatterns = {
3262
- narrow: [
3263
- /^j/i,
3264
- /^f/i,
3265
- /^m/i,
3266
- /^a/i,
3267
- /^m/i,
3268
- /^j/i,
3269
- /^j/i,
3270
- /^a/i,
3271
- /^s/i,
3272
- /^o/i,
3273
- /^n/i,
3274
- /^d/i
3275
- ],
3276
- any: [
3277
- /^ja/i,
3278
- /^f/i,
3279
- /^mar/i,
3280
- /^ap/i,
3281
- /^may/i,
3282
- /^jun/i,
3283
- /^jul/i,
3284
- /^au/i,
3285
- /^s/i,
3286
- /^o/i,
3287
- /^n/i,
3288
- /^d/i
3289
- ]
3290
- };
3291
- var matchDayPatterns = {
3292
- narrow: /^[smtwf]/i,
3293
- short: /^(su|mo|tu|we|th|fr|sa)/i,
3294
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
3295
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
3296
- };
3297
- var parseDayPatterns = {
3298
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
3299
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
3300
- };
3301
- var matchDayPeriodPatterns = {
3302
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
3303
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
3304
- };
3305
- var parseDayPeriodPatterns = {
3306
- any: {
3307
- am: /^a/i,
3308
- pm: /^p/i,
3309
- midnight: /^mi/i,
3310
- noon: /^no/i,
3311
- morning: /morning/i,
3312
- afternoon: /afternoon/i,
3313
- evening: /evening/i,
3314
- night: /night/i
3315
- }
3316
- };
3317
- var match = {
3318
- ordinalNumber: buildMatchPatternFn({
3319
- matchPattern: matchOrdinalNumberPattern,
3320
- parsePattern: parseOrdinalNumberPattern,
3321
- valueCallback: (value) => parseInt(value, 10)
3322
- }),
3323
- era: buildMatchFn({
3324
- matchPatterns: matchEraPatterns,
3325
- defaultMatchWidth: "wide",
3326
- parsePatterns: parseEraPatterns,
3327
- defaultParseWidth: "any"
3328
- }),
3329
- quarter: buildMatchFn({
3330
- matchPatterns: matchQuarterPatterns,
3331
- defaultMatchWidth: "wide",
3332
- parsePatterns: parseQuarterPatterns,
3333
- defaultParseWidth: "any",
3334
- valueCallback: (index) => index + 1
3335
- }),
3336
- month: buildMatchFn({
3337
- matchPatterns: matchMonthPatterns,
3338
- defaultMatchWidth: "wide",
3339
- parsePatterns: parseMonthPatterns,
3340
- defaultParseWidth: "any"
3341
- }),
3342
- day: buildMatchFn({
3343
- matchPatterns: matchDayPatterns,
3344
- defaultMatchWidth: "wide",
3345
- parsePatterns: parseDayPatterns,
3346
- defaultParseWidth: "any"
3347
- }),
3348
- dayPeriod: buildMatchFn({
3349
- matchPatterns: matchDayPeriodPatterns,
3350
- defaultMatchWidth: "any",
3351
- parsePatterns: parseDayPeriodPatterns,
3352
- defaultParseWidth: "any"
3353
- })
3354
- };
3355
-
3356
- // node_modules/date-fns/locale/en-US.js
3357
- var enUS = {
3358
- code: "en-US",
3359
- formatDistance,
3360
- formatLong,
3361
- formatRelative,
3362
- localize,
3363
- match,
3364
- options: {
3365
- weekStartsOn: 0,
3366
- firstWeekContainsDate: 1
3367
- }
3368
- };
3369
-
3370
- // node_modules/date-fns/getDayOfYear.js
3371
- function getDayOfYear(date, options) {
3372
- const _date = toDate(date, options?.in);
3373
- const diff = differenceInCalendarDays(_date, startOfYear(_date));
3374
- const dayOfYear = diff + 1;
3375
- return dayOfYear;
3376
- }
3377
-
3378
- // node_modules/date-fns/getISOWeek.js
3379
- function getISOWeek(date, options) {
3380
- const _date = toDate(date, options?.in);
3381
- const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
3382
- return Math.round(diff / millisecondsInWeek) + 1;
3383
- }
3384
-
3385
- // node_modules/date-fns/getWeekYear.js
3386
- function getWeekYear(date, options) {
3387
- const _date = toDate(date, options?.in);
3388
- const year = _date.getFullYear();
3389
- const defaultOptions2 = getDefaultOptions();
3390
- const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
3391
- const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
3392
- firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
3393
- firstWeekOfNextYear.setHours(0, 0, 0, 0);
3394
- const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
3395
- const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
3396
- firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
3397
- firstWeekOfThisYear.setHours(0, 0, 0, 0);
3398
- const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
3399
- if (+_date >= +startOfNextYear) {
3400
- return year + 1;
3401
- } else if (+_date >= +startOfThisYear) {
3402
- return year;
3403
- } else {
3404
- return year - 1;
3405
- }
3406
- }
3407
-
3408
- // node_modules/date-fns/startOfWeekYear.js
3409
- function startOfWeekYear(date, options) {
3410
- const defaultOptions2 = getDefaultOptions();
3411
- const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
3412
- const year = getWeekYear(date, options);
3413
- const firstWeek = constructFrom(options?.in || date, 0);
3414
- firstWeek.setFullYear(year, 0, firstWeekContainsDate);
3415
- firstWeek.setHours(0, 0, 0, 0);
3416
- const _date = startOfWeek(firstWeek, options);
3417
- return _date;
3418
- }
3419
-
3420
- // node_modules/date-fns/getWeek.js
3421
- function getWeek(date, options) {
3422
- const _date = toDate(date, options?.in);
3423
- const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
3424
- return Math.round(diff / millisecondsInWeek) + 1;
3425
- }
3426
-
3427
- // node_modules/date-fns/_lib/addLeadingZeros.js
3428
- function addLeadingZeros(number, targetLength) {
3429
- const sign = number < 0 ? "-" : "";
3430
- const output = Math.abs(number).toString().padStart(targetLength, "0");
3431
- return sign + output;
3432
- }
3433
-
3434
- // node_modules/date-fns/_lib/format/lightFormatters.js
3435
- var lightFormatters = {
3436
- // Year
3437
- y(date, token) {
3438
- const signedYear = date.getFullYear();
3439
- const year = signedYear > 0 ? signedYear : 1 - signedYear;
3440
- return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
3441
- },
3442
- // Month
3443
- M(date, token) {
3444
- const month = date.getMonth();
3445
- return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
3446
- },
3447
- // Day of the month
3448
- d(date, token) {
3449
- return addLeadingZeros(date.getDate(), token.length);
3450
- },
3451
- // AM or PM
3452
- a(date, token) {
3453
- const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
3454
- switch (token) {
3455
- case "a":
3456
- case "aa":
3457
- return dayPeriodEnumValue.toUpperCase();
3458
- case "aaa":
3459
- return dayPeriodEnumValue;
3460
- case "aaaaa":
3461
- return dayPeriodEnumValue[0];
3462
- case "aaaa":
3463
- default:
3464
- return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
3465
- }
3466
- },
3467
- // Hour [1-12]
3468
- h(date, token) {
3469
- return addLeadingZeros(date.getHours() % 12 || 12, token.length);
3470
- },
3471
- // Hour [0-23]
3472
- H(date, token) {
3473
- return addLeadingZeros(date.getHours(), token.length);
3474
- },
3475
- // Minute
3476
- m(date, token) {
3477
- return addLeadingZeros(date.getMinutes(), token.length);
3478
- },
3479
- // Second
3480
- s(date, token) {
3481
- return addLeadingZeros(date.getSeconds(), token.length);
3482
- },
3483
- // Fraction of second
3484
- S(date, token) {
3485
- const numberOfDigits = token.length;
3486
- const milliseconds = date.getMilliseconds();
3487
- const fractionalSeconds = Math.trunc(
3488
- milliseconds * Math.pow(10, numberOfDigits - 3)
3489
- );
3490
- return addLeadingZeros(fractionalSeconds, token.length);
3491
- }
3492
- };
3493
-
3494
- // node_modules/date-fns/_lib/format/formatters.js
3495
- var dayPeriodEnum = {
3496
- midnight: "midnight",
3497
- noon: "noon",
3498
- morning: "morning",
3499
- afternoon: "afternoon",
3500
- evening: "evening",
3501
- night: "night"
3502
- };
3503
- var formatters = {
3504
- // Era
3505
- G: function(date, token, localize2) {
3506
- const era = date.getFullYear() > 0 ? 1 : 0;
3507
- switch (token) {
3508
- // AD, BC
3509
- case "G":
3510
- case "GG":
3511
- case "GGG":
3512
- return localize2.era(era, { width: "abbreviated" });
3513
- // A, B
3514
- case "GGGGG":
3515
- return localize2.era(era, { width: "narrow" });
3516
- // Anno Domini, Before Christ
3517
- case "GGGG":
3518
- default:
3519
- return localize2.era(era, { width: "wide" });
3520
- }
3521
- },
3522
- // Year
3523
- y: function(date, token, localize2) {
3524
- if (token === "yo") {
3525
- const signedYear = date.getFullYear();
3526
- const year = signedYear > 0 ? signedYear : 1 - signedYear;
3527
- return localize2.ordinalNumber(year, { unit: "year" });
3528
- }
3529
- return lightFormatters.y(date, token);
3530
- },
3531
- // Local week-numbering year
3532
- Y: function(date, token, localize2, options) {
3533
- const signedWeekYear = getWeekYear(date, options);
3534
- const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
3535
- if (token === "YY") {
3536
- const twoDigitYear = weekYear % 100;
3537
- return addLeadingZeros(twoDigitYear, 2);
3538
- }
3539
- if (token === "Yo") {
3540
- return localize2.ordinalNumber(weekYear, { unit: "year" });
3541
- }
3542
- return addLeadingZeros(weekYear, token.length);
3543
- },
3544
- // ISO week-numbering year
3545
- R: function(date, token) {
3546
- const isoWeekYear = getISOWeekYear(date);
3547
- return addLeadingZeros(isoWeekYear, token.length);
3548
- },
3549
- // Extended year. This is a single number designating the year of this calendar system.
3550
- // The main difference between `y` and `u` localizers are B.C. years:
3551
- // | Year | `y` | `u` |
3552
- // |------|-----|-----|
3553
- // | AC 1 | 1 | 1 |
3554
- // | BC 1 | 1 | 0 |
3555
- // | BC 2 | 2 | -1 |
3556
- // Also `yy` always returns the last two digits of a year,
3557
- // while `uu` pads single digit years to 2 characters and returns other years unchanged.
3558
- u: function(date, token) {
3559
- const year = date.getFullYear();
3560
- return addLeadingZeros(year, token.length);
3561
- },
3562
- // Quarter
3563
- Q: function(date, token, localize2) {
3564
- const quarter = Math.ceil((date.getMonth() + 1) / 3);
3565
- switch (token) {
3566
- // 1, 2, 3, 4
3567
- case "Q":
3568
- return String(quarter);
3569
- // 01, 02, 03, 04
3570
- case "QQ":
3571
- return addLeadingZeros(quarter, 2);
3572
- // 1st, 2nd, 3rd, 4th
3573
- case "Qo":
3574
- return localize2.ordinalNumber(quarter, { unit: "quarter" });
3575
- // Q1, Q2, Q3, Q4
3576
- case "QQQ":
3577
- return localize2.quarter(quarter, {
3578
- width: "abbreviated",
3579
- context: "formatting"
3580
- });
3581
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
3582
- case "QQQQQ":
3583
- return localize2.quarter(quarter, {
3584
- width: "narrow",
3585
- context: "formatting"
3586
- });
3587
- // 1st quarter, 2nd quarter, ...
3588
- case "QQQQ":
3589
- default:
3590
- return localize2.quarter(quarter, {
3591
- width: "wide",
3592
- context: "formatting"
3593
- });
3594
- }
3595
- },
3596
- // Stand-alone quarter
3597
- q: function(date, token, localize2) {
3598
- const quarter = Math.ceil((date.getMonth() + 1) / 3);
3599
- switch (token) {
3600
- // 1, 2, 3, 4
3601
- case "q":
3602
- return String(quarter);
3603
- // 01, 02, 03, 04
3604
- case "qq":
3605
- return addLeadingZeros(quarter, 2);
3606
- // 1st, 2nd, 3rd, 4th
3607
- case "qo":
3608
- return localize2.ordinalNumber(quarter, { unit: "quarter" });
3609
- // Q1, Q2, Q3, Q4
3610
- case "qqq":
3611
- return localize2.quarter(quarter, {
3612
- width: "abbreviated",
3613
- context: "standalone"
3614
- });
3615
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
3616
- case "qqqqq":
3617
- return localize2.quarter(quarter, {
3618
- width: "narrow",
3619
- context: "standalone"
3620
- });
3621
- // 1st quarter, 2nd quarter, ...
3622
- case "qqqq":
3623
- default:
3624
- return localize2.quarter(quarter, {
3625
- width: "wide",
3626
- context: "standalone"
3627
- });
3628
- }
3629
- },
3630
- // Month
3631
- M: function(date, token, localize2) {
3632
- const month = date.getMonth();
3633
- switch (token) {
3634
- case "M":
3635
- case "MM":
3636
- return lightFormatters.M(date, token);
3637
- // 1st, 2nd, ..., 12th
3638
- case "Mo":
3639
- return localize2.ordinalNumber(month + 1, { unit: "month" });
3640
- // Jan, Feb, ..., Dec
3641
- case "MMM":
3642
- return localize2.month(month, {
3643
- width: "abbreviated",
3644
- context: "formatting"
3645
- });
3646
- // J, F, ..., D
3647
- case "MMMMM":
3648
- return localize2.month(month, {
3649
- width: "narrow",
3650
- context: "formatting"
3651
- });
3652
- // January, February, ..., December
3653
- case "MMMM":
3654
- default:
3655
- return localize2.month(month, { width: "wide", context: "formatting" });
3656
- }
3657
- },
3658
- // Stand-alone month
3659
- L: function(date, token, localize2) {
3660
- const month = date.getMonth();
3661
- switch (token) {
3662
- // 1, 2, ..., 12
3663
- case "L":
3664
- return String(month + 1);
3665
- // 01, 02, ..., 12
3666
- case "LL":
3667
- return addLeadingZeros(month + 1, 2);
3668
- // 1st, 2nd, ..., 12th
3669
- case "Lo":
3670
- return localize2.ordinalNumber(month + 1, { unit: "month" });
3671
- // Jan, Feb, ..., Dec
3672
- case "LLL":
3673
- return localize2.month(month, {
3674
- width: "abbreviated",
3675
- context: "standalone"
3676
- });
3677
- // J, F, ..., D
3678
- case "LLLLL":
3679
- return localize2.month(month, {
3680
- width: "narrow",
3681
- context: "standalone"
3682
- });
3683
- // January, February, ..., December
3684
- case "LLLL":
3685
- default:
3686
- return localize2.month(month, { width: "wide", context: "standalone" });
3687
- }
3688
- },
3689
- // Local week of year
3690
- w: function(date, token, localize2, options) {
3691
- const week = getWeek(date, options);
3692
- if (token === "wo") {
3693
- return localize2.ordinalNumber(week, { unit: "week" });
3694
- }
3695
- return addLeadingZeros(week, token.length);
3696
- },
3697
- // ISO week of year
3698
- I: function(date, token, localize2) {
3699
- const isoWeek = getISOWeek(date);
3700
- if (token === "Io") {
3701
- return localize2.ordinalNumber(isoWeek, { unit: "week" });
3702
- }
3703
- return addLeadingZeros(isoWeek, token.length);
3704
- },
3705
- // Day of the month
3706
- d: function(date, token, localize2) {
3707
- if (token === "do") {
3708
- return localize2.ordinalNumber(date.getDate(), { unit: "date" });
3709
- }
3710
- return lightFormatters.d(date, token);
3711
- },
3712
- // Day of year
3713
- D: function(date, token, localize2) {
3714
- const dayOfYear = getDayOfYear(date);
3715
- if (token === "Do") {
3716
- return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
3717
- }
3718
- return addLeadingZeros(dayOfYear, token.length);
3719
- },
3720
- // Day of week
3721
- E: function(date, token, localize2) {
3722
- const dayOfWeek = date.getDay();
3723
- switch (token) {
3724
- // Tue
3725
- case "E":
3726
- case "EE":
3727
- case "EEE":
3728
- return localize2.day(dayOfWeek, {
3729
- width: "abbreviated",
3730
- context: "formatting"
3731
- });
3732
- // T
3733
- case "EEEEE":
3734
- return localize2.day(dayOfWeek, {
3735
- width: "narrow",
3736
- context: "formatting"
3737
- });
3738
- // Tu
3739
- case "EEEEEE":
3740
- return localize2.day(dayOfWeek, {
3741
- width: "short",
3742
- context: "formatting"
3743
- });
3744
- // Tuesday
3745
- case "EEEE":
3746
- default:
3747
- return localize2.day(dayOfWeek, {
3748
- width: "wide",
3749
- context: "formatting"
3750
- });
3751
- }
3752
- },
3753
- // Local day of week
3754
- e: function(date, token, localize2, options) {
3755
- const dayOfWeek = date.getDay();
3756
- const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
3757
- switch (token) {
3758
- // Numerical value (Nth day of week with current locale or weekStartsOn)
3759
- case "e":
3760
- return String(localDayOfWeek);
3761
- // Padded numerical value
3762
- case "ee":
3763
- return addLeadingZeros(localDayOfWeek, 2);
3764
- // 1st, 2nd, ..., 7th
3765
- case "eo":
3766
- return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
3767
- case "eee":
3768
- return localize2.day(dayOfWeek, {
3769
- width: "abbreviated",
3770
- context: "formatting"
3771
- });
3772
- // T
3773
- case "eeeee":
3774
- return localize2.day(dayOfWeek, {
3775
- width: "narrow",
3776
- context: "formatting"
3777
- });
3778
- // Tu
3779
- case "eeeeee":
3780
- return localize2.day(dayOfWeek, {
3781
- width: "short",
3782
- context: "formatting"
3783
- });
3784
- // Tuesday
3785
- case "eeee":
3786
- default:
3787
- return localize2.day(dayOfWeek, {
3788
- width: "wide",
3789
- context: "formatting"
3790
- });
3791
- }
3792
- },
3793
- // Stand-alone local day of week
3794
- c: function(date, token, localize2, options) {
3795
- const dayOfWeek = date.getDay();
3796
- const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
3797
- switch (token) {
3798
- // Numerical value (same as in `e`)
3799
- case "c":
3800
- return String(localDayOfWeek);
3801
- // Padded numerical value
3802
- case "cc":
3803
- return addLeadingZeros(localDayOfWeek, token.length);
3804
- // 1st, 2nd, ..., 7th
3805
- case "co":
3806
- return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
3807
- case "ccc":
3808
- return localize2.day(dayOfWeek, {
3809
- width: "abbreviated",
3810
- context: "standalone"
3811
- });
3812
- // T
3813
- case "ccccc":
3814
- return localize2.day(dayOfWeek, {
3815
- width: "narrow",
3816
- context: "standalone"
3817
- });
3818
- // Tu
3819
- case "cccccc":
3820
- return localize2.day(dayOfWeek, {
3821
- width: "short",
3822
- context: "standalone"
3823
- });
3824
- // Tuesday
3825
- case "cccc":
3826
- default:
3827
- return localize2.day(dayOfWeek, {
3828
- width: "wide",
3829
- context: "standalone"
3830
- });
3831
- }
3832
- },
3833
- // ISO day of week
3834
- i: function(date, token, localize2) {
3835
- const dayOfWeek = date.getDay();
3836
- const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
3837
- switch (token) {
3838
- // 2
3839
- case "i":
3840
- return String(isoDayOfWeek);
3841
- // 02
3842
- case "ii":
3843
- return addLeadingZeros(isoDayOfWeek, token.length);
3844
- // 2nd
3845
- case "io":
3846
- return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
3847
- // Tue
3848
- case "iii":
3849
- return localize2.day(dayOfWeek, {
3850
- width: "abbreviated",
3851
- context: "formatting"
3852
- });
3853
- // T
3854
- case "iiiii":
3855
- return localize2.day(dayOfWeek, {
3856
- width: "narrow",
3857
- context: "formatting"
3858
- });
3859
- // Tu
3860
- case "iiiiii":
3861
- return localize2.day(dayOfWeek, {
3862
- width: "short",
3863
- context: "formatting"
3864
- });
3865
- // Tuesday
3866
- case "iiii":
3867
- default:
3868
- return localize2.day(dayOfWeek, {
3869
- width: "wide",
3870
- context: "formatting"
3871
- });
3872
- }
3873
- },
3874
- // AM or PM
3875
- a: function(date, token, localize2) {
3876
- const hours = date.getHours();
3877
- const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
3878
- switch (token) {
3879
- case "a":
3880
- case "aa":
3881
- return localize2.dayPeriod(dayPeriodEnumValue, {
3882
- width: "abbreviated",
3883
- context: "formatting"
3884
- });
3885
- case "aaa":
3886
- return localize2.dayPeriod(dayPeriodEnumValue, {
3887
- width: "abbreviated",
3888
- context: "formatting"
3889
- }).toLowerCase();
3890
- case "aaaaa":
3891
- return localize2.dayPeriod(dayPeriodEnumValue, {
3892
- width: "narrow",
3893
- context: "formatting"
3894
- });
3895
- case "aaaa":
3896
- default:
3897
- return localize2.dayPeriod(dayPeriodEnumValue, {
3898
- width: "wide",
3899
- context: "formatting"
3900
- });
3901
- }
3902
- },
3903
- // AM, PM, midnight, noon
3904
- b: function(date, token, localize2) {
3905
- const hours = date.getHours();
3906
- let dayPeriodEnumValue;
3907
- if (hours === 12) {
3908
- dayPeriodEnumValue = dayPeriodEnum.noon;
3909
- } else if (hours === 0) {
3910
- dayPeriodEnumValue = dayPeriodEnum.midnight;
3911
- } else {
3912
- dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
3913
- }
3914
- switch (token) {
3915
- case "b":
3916
- case "bb":
3917
- return localize2.dayPeriod(dayPeriodEnumValue, {
3918
- width: "abbreviated",
3919
- context: "formatting"
3920
- });
3921
- case "bbb":
3922
- return localize2.dayPeriod(dayPeriodEnumValue, {
3923
- width: "abbreviated",
3924
- context: "formatting"
3925
- }).toLowerCase();
3926
- case "bbbbb":
3927
- return localize2.dayPeriod(dayPeriodEnumValue, {
3928
- width: "narrow",
3929
- context: "formatting"
3930
- });
3931
- case "bbbb":
3932
- default:
3933
- return localize2.dayPeriod(dayPeriodEnumValue, {
3934
- width: "wide",
3935
- context: "formatting"
3936
- });
3937
- }
3938
- },
3939
- // in the morning, in the afternoon, in the evening, at night
3940
- B: function(date, token, localize2) {
3941
- const hours = date.getHours();
3942
- let dayPeriodEnumValue;
3943
- if (hours >= 17) {
3944
- dayPeriodEnumValue = dayPeriodEnum.evening;
3945
- } else if (hours >= 12) {
3946
- dayPeriodEnumValue = dayPeriodEnum.afternoon;
3947
- } else if (hours >= 4) {
3948
- dayPeriodEnumValue = dayPeriodEnum.morning;
3949
- } else {
3950
- dayPeriodEnumValue = dayPeriodEnum.night;
3951
- }
3952
- switch (token) {
3953
- case "B":
3954
- case "BB":
3955
- case "BBB":
3956
- return localize2.dayPeriod(dayPeriodEnumValue, {
3957
- width: "abbreviated",
3958
- context: "formatting"
3959
- });
3960
- case "BBBBB":
3961
- return localize2.dayPeriod(dayPeriodEnumValue, {
3962
- width: "narrow",
3963
- context: "formatting"
3964
- });
3965
- case "BBBB":
3966
- default:
3967
- return localize2.dayPeriod(dayPeriodEnumValue, {
3968
- width: "wide",
3969
- context: "formatting"
3970
- });
3971
- }
3972
- },
3973
- // Hour [1-12]
3974
- h: function(date, token, localize2) {
3975
- if (token === "ho") {
3976
- let hours = date.getHours() % 12;
3977
- if (hours === 0) hours = 12;
3978
- return localize2.ordinalNumber(hours, { unit: "hour" });
3979
- }
3980
- return lightFormatters.h(date, token);
3981
- },
3982
- // Hour [0-23]
3983
- H: function(date, token, localize2) {
3984
- if (token === "Ho") {
3985
- return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
3986
- }
3987
- return lightFormatters.H(date, token);
3988
- },
3989
- // Hour [0-11]
3990
- K: function(date, token, localize2) {
3991
- const hours = date.getHours() % 12;
3992
- if (token === "Ko") {
3993
- return localize2.ordinalNumber(hours, { unit: "hour" });
3994
- }
3995
- return addLeadingZeros(hours, token.length);
3996
- },
3997
- // Hour [1-24]
3998
- k: function(date, token, localize2) {
3999
- let hours = date.getHours();
4000
- if (hours === 0) hours = 24;
4001
- if (token === "ko") {
4002
- return localize2.ordinalNumber(hours, { unit: "hour" });
4003
- }
4004
- return addLeadingZeros(hours, token.length);
4005
- },
4006
- // Minute
4007
- m: function(date, token, localize2) {
4008
- if (token === "mo") {
4009
- return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
4010
- }
4011
- return lightFormatters.m(date, token);
4012
- },
4013
- // Second
4014
- s: function(date, token, localize2) {
4015
- if (token === "so") {
4016
- return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
4017
- }
4018
- return lightFormatters.s(date, token);
4019
- },
4020
- // Fraction of second
4021
- S: function(date, token) {
4022
- return lightFormatters.S(date, token);
4023
- },
4024
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
4025
- X: function(date, token, _localize) {
4026
- const timezoneOffset = date.getTimezoneOffset();
4027
- if (timezoneOffset === 0) {
4028
- return "Z";
4029
- }
4030
- switch (token) {
4031
- // Hours and optional minutes
4032
- case "X":
4033
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
4034
- // Hours, minutes and optional seconds without `:` delimiter
4035
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
4036
- // so this token always has the same output as `XX`
4037
- case "XXXX":
4038
- case "XX":
4039
- return formatTimezone(timezoneOffset);
4040
- // Hours, minutes and optional seconds with `:` delimiter
4041
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
4042
- // so this token always has the same output as `XXX`
4043
- case "XXXXX":
4044
- case "XXX":
4045
- // Hours and minutes with `:` delimiter
4046
- default:
4047
- return formatTimezone(timezoneOffset, ":");
4048
- }
4049
- },
4050
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
4051
- x: function(date, token, _localize) {
4052
- const timezoneOffset = date.getTimezoneOffset();
4053
- switch (token) {
4054
- // Hours and optional minutes
4055
- case "x":
4056
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
4057
- // Hours, minutes and optional seconds without `:` delimiter
4058
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
4059
- // so this token always has the same output as `xx`
4060
- case "xxxx":
4061
- case "xx":
4062
- return formatTimezone(timezoneOffset);
4063
- // Hours, minutes and optional seconds with `:` delimiter
4064
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
4065
- // so this token always has the same output as `xxx`
4066
- case "xxxxx":
4067
- case "xxx":
4068
- // Hours and minutes with `:` delimiter
4069
- default:
4070
- return formatTimezone(timezoneOffset, ":");
4071
- }
4072
- },
4073
- // Timezone (GMT)
4074
- O: function(date, token, _localize) {
4075
- const timezoneOffset = date.getTimezoneOffset();
4076
- switch (token) {
4077
- // Short
4078
- case "O":
4079
- case "OO":
4080
- case "OOO":
4081
- return "GMT" + formatTimezoneShort(timezoneOffset, ":");
4082
- // Long
4083
- case "OOOO":
4084
- default:
4085
- return "GMT" + formatTimezone(timezoneOffset, ":");
4086
- }
4087
- },
4088
- // Timezone (specific non-location)
4089
- z: function(date, token, _localize) {
4090
- const timezoneOffset = date.getTimezoneOffset();
4091
- switch (token) {
4092
- // Short
4093
- case "z":
4094
- case "zz":
4095
- case "zzz":
4096
- return "GMT" + formatTimezoneShort(timezoneOffset, ":");
4097
- // Long
4098
- case "zzzz":
4099
- default:
4100
- return "GMT" + formatTimezone(timezoneOffset, ":");
4101
- }
4102
- },
4103
- // Seconds timestamp
4104
- t: function(date, token, _localize) {
4105
- const timestamp = Math.trunc(+date / 1e3);
4106
- return addLeadingZeros(timestamp, token.length);
4107
- },
4108
- // Milliseconds timestamp
4109
- T: function(date, token, _localize) {
4110
- return addLeadingZeros(+date, token.length);
4111
- }
4112
- };
4113
- function formatTimezoneShort(offset, delimiter = "") {
4114
- const sign = offset > 0 ? "-" : "+";
4115
- const absOffset = Math.abs(offset);
4116
- const hours = Math.trunc(absOffset / 60);
4117
- const minutes = absOffset % 60;
4118
- if (minutes === 0) {
4119
- return sign + String(hours);
4120
- }
4121
- return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
4122
- }
4123
- function formatTimezoneWithOptionalMinutes(offset, delimiter) {
4124
- if (offset % 60 === 0) {
4125
- const sign = offset > 0 ? "-" : "+";
4126
- return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
4127
- }
4128
- return formatTimezone(offset, delimiter);
4129
- }
4130
- function formatTimezone(offset, delimiter = "") {
4131
- const sign = offset > 0 ? "-" : "+";
4132
- const absOffset = Math.abs(offset);
4133
- const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
4134
- const minutes = addLeadingZeros(absOffset % 60, 2);
4135
- return sign + hours + delimiter + minutes;
4136
- }
4137
-
4138
- // node_modules/date-fns/_lib/format/longFormatters.js
4139
- var dateLongFormatter = (pattern, formatLong2) => {
4140
- switch (pattern) {
4141
- case "P":
4142
- return formatLong2.date({ width: "short" });
4143
- case "PP":
4144
- return formatLong2.date({ width: "medium" });
4145
- case "PPP":
4146
- return formatLong2.date({ width: "long" });
4147
- case "PPPP":
4148
- default:
4149
- return formatLong2.date({ width: "full" });
4150
- }
4151
- };
4152
- var timeLongFormatter = (pattern, formatLong2) => {
4153
- switch (pattern) {
4154
- case "p":
4155
- return formatLong2.time({ width: "short" });
4156
- case "pp":
4157
- return formatLong2.time({ width: "medium" });
4158
- case "ppp":
4159
- return formatLong2.time({ width: "long" });
4160
- case "pppp":
4161
- default:
4162
- return formatLong2.time({ width: "full" });
4163
- }
4164
- };
4165
- var dateTimeLongFormatter = (pattern, formatLong2) => {
4166
- const matchResult = pattern.match(/(P+)(p+)?/) || [];
4167
- const datePattern = matchResult[1];
4168
- const timePattern = matchResult[2];
4169
- if (!timePattern) {
4170
- return dateLongFormatter(pattern, formatLong2);
4171
- }
4172
- let dateTimeFormat;
4173
- switch (datePattern) {
4174
- case "P":
4175
- dateTimeFormat = formatLong2.dateTime({ width: "short" });
4176
- break;
4177
- case "PP":
4178
- dateTimeFormat = formatLong2.dateTime({ width: "medium" });
4179
- break;
4180
- case "PPP":
4181
- dateTimeFormat = formatLong2.dateTime({ width: "long" });
4182
- break;
4183
- case "PPPP":
4184
- default:
4185
- dateTimeFormat = formatLong2.dateTime({ width: "full" });
4186
- break;
4187
- }
4188
- return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
4189
- };
4190
- var longFormatters = {
4191
- p: timeLongFormatter,
4192
- P: dateTimeLongFormatter
4193
- };
4194
-
4195
- // node_modules/date-fns/_lib/protectedTokens.js
4196
- var dayOfYearTokenRE = /^D+$/;
4197
- var weekYearTokenRE = /^Y+$/;
4198
- var throwTokens = ["D", "DD", "YY", "YYYY"];
4199
- function isProtectedDayOfYearToken(token) {
4200
- return dayOfYearTokenRE.test(token);
4201
- }
4202
- function isProtectedWeekYearToken(token) {
4203
- return weekYearTokenRE.test(token);
4204
- }
4205
- function warnOrThrowProtectedError(token, format2, input) {
4206
- const _message = message(token, format2, input);
4207
- console.warn(_message);
4208
- if (throwTokens.includes(token)) throw new RangeError(_message);
4209
- }
4210
- function message(token, format2, input) {
4211
- const subject = token[0] === "Y" ? "years" : "days of the month";
4212
- return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format2}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
4213
- }
4214
-
4215
- // node_modules/date-fns/format.js
4216
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
4217
- var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
4218
- var escapedStringRegExp = /^'([^]*?)'?$/;
4219
- var doubleQuoteRegExp = /''/g;
4220
- var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
4221
- function format(date, formatStr, options) {
4222
- const defaultOptions2 = getDefaultOptions();
4223
- const locale = defaultOptions2.locale ?? enUS;
4224
- const firstWeekContainsDate = defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
4225
- const weekStartsOn = defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
4226
- const originalDate = toDate(date, options?.in);
4227
- if (!isValid(originalDate)) {
4228
- throw new RangeError("Invalid time value");
4229
- }
4230
- let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
4231
- const firstCharacter = substring[0];
4232
- if (firstCharacter === "p" || firstCharacter === "P") {
4233
- const longFormatter = longFormatters[firstCharacter];
4234
- return longFormatter(substring, locale.formatLong);
4235
- }
4236
- return substring;
4237
- }).join("").match(formattingTokensRegExp).map((substring) => {
4238
- if (substring === "''") {
4239
- return { isToken: false, value: "'" };
4240
- }
4241
- const firstCharacter = substring[0];
4242
- if (firstCharacter === "'") {
4243
- return { isToken: false, value: cleanEscapedString(substring) };
4244
- }
4245
- if (formatters[firstCharacter]) {
4246
- return { isToken: true, value: substring };
4247
- }
4248
- if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
4249
- throw new RangeError(
4250
- "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
4251
- );
4252
- }
4253
- return { isToken: false, value: substring };
4254
- });
4255
- if (locale.localize.preprocessor) {
4256
- parts = locale.localize.preprocessor(originalDate, parts);
4257
- }
4258
- const formatterOptions = {
4259
- firstWeekContainsDate,
4260
- weekStartsOn,
4261
- locale
4262
- };
4263
- return parts.map((part) => {
4264
- if (!part.isToken) return part.value;
4265
- const token = part.value;
4266
- if (isProtectedWeekYearToken(token) || isProtectedDayOfYearToken(token)) {
4267
- warnOrThrowProtectedError(token, formatStr, String(date));
4268
- }
4269
- const formatter = formatters[token[0]];
4270
- return formatter(originalDate, token, locale.localize, formatterOptions);
4271
- }).join("");
4272
- }
4273
- function cleanEscapedString(input) {
4274
- const matched = input.match(escapedStringRegExp);
4275
- if (!matched) {
4276
- return input;
4277
- }
4278
- return matched[1].replace(doubleQuoteRegExp, "'");
4279
- }
4280
2728
  var DateInput = class extends BaseInput {
4281
2729
  render() {
4282
2730
  const { input, form, isSubmitting } = this;
@@ -4284,7 +2732,8 @@ var DateInput = class extends BaseInput {
4284
2732
  }
4285
2733
  };
4286
2734
  var FieldTimeInput = ({ form, input, isSubmitting }) => {
4287
- const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
2735
+ const [isValid, setIsValid] = React3.useState(isValidField(input, form));
2736
+ const infoTooltip = input?.infoTooltip;
4288
2737
  const groupConfig = input.inputGroupConfig;
4289
2738
  const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
4290
2739
  const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
@@ -4317,33 +2766,42 @@ var FieldTimeInput = ({ form, input, isSubmitting }) => {
4317
2766
  return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { children: [
4318
2767
  /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
4319
2768
  /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
4320
- /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(InputGroup, { className: "flex flex-row gap-1", children: /* @__PURE__ */ jsxRuntime.jsxs(
4321
- Button,
4322
- {
4323
- variant: "outline",
4324
- className: cn(
4325
- "w-full justify-start text-left py-0.5 ",
4326
- !date && "text-muted-foreground"
4327
- ),
4328
- children: [
4329
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 items-center gap-1 justify-start text-left ", children: [
4330
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, {}),
4331
- date ? format(date, "PPP") : /* @__PURE__ */ jsxRuntime.jsx("span", { children: input.placeHolder ?? "Fecha" })
4332
- ] }),
4333
- (iconsRight.length > 0 || textRight || autoValidate) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4334
- textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
4335
- iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 24, className: "w-6! h-6!" }, index)),
4336
- autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
4337
- ] })
4338
- ]
4339
- }
4340
- ) }) }) }),
4341
- /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
2769
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { className: "flex flex-row gap-1", children: [
2770
+ infoTooltip && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
2771
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { size: 20 }) }),
2772
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: infoTooltip }) })
2773
+ ] }),
2774
+ /* @__PURE__ */ jsxRuntime.jsxs(
2775
+ Button,
2776
+ {
2777
+ variant: "outline",
2778
+ type: "button",
2779
+ className: cn(
2780
+ "w-full justify-start text-left py-0.5 ",
2781
+ !date && "text-muted-foreground"
2782
+ ),
2783
+ children: [
2784
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 items-center gap-1 justify-start text-left ", children: [
2785
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, {}),
2786
+ date ? dateFns.format(date, "PPP") : /* @__PURE__ */ jsxRuntime.jsx("span", { children: input.placeHolder ?? "Fecha" })
2787
+ ] }),
2788
+ (iconsRight.length > 0 || textRight || autoValidate) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2789
+ textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
2790
+ iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 24, className: "w-6! h-6!" }, index)),
2791
+ autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid ? iconValidState : iconInvalidState })
2792
+ ] })
2793
+ ]
2794
+ }
2795
+ )
2796
+ ] }) }) }),
2797
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(
4342
2798
  Calendar,
4343
2799
  {
4344
2800
  mode: "single",
2801
+ defaultMonth: date,
4345
2802
  selected: date,
4346
2803
  onSelect: handleSelect,
2804
+ captionLayout: "dropdown",
4347
2805
  initialFocus: true
4348
2806
  }
4349
2807
  ) })
@@ -4373,7 +2831,7 @@ var FieldDateTimeInput = ({ form, input, isSubmitting }) => {
4373
2831
  const iconsLeft = groupConfig?.iconsLeft ?? [];
4374
2832
  const textLeft = groupConfig?.textLeft;
4375
2833
  const textRight = groupConfig?.textRight;
4376
- const [isValid2, setIsValid] = React3.useState(() => {
2834
+ const [isValid, setIsValid] = React3.useState(() => {
4377
2835
  const value = form.getValues(input.name);
4378
2836
  const fieldState = form.getFieldState(input.name);
4379
2837
  return !fieldState.error && value !== void 0 && value !== "";
@@ -4394,7 +2852,7 @@ var FieldDateTimeInput = ({ form, input, isSubmitting }) => {
4394
2852
  name: input.name,
4395
2853
  render: ({ field, fieldState }) => {
4396
2854
  const validNow = !fieldState.error && field.value !== void 0 && field.value !== "";
4397
- if (validNow !== isValid2) setIsValid(validNow);
2855
+ if (validNow !== isValid) setIsValid(validNow);
4398
2856
  return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
4399
2857
  /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
4400
2858
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { className: "shadow-lg", children: /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { children: [
@@ -4417,7 +2875,7 @@ var FieldDateTimeInput = ({ form, input, isSubmitting }) => {
4417
2875
  (iconsRight.length > 0 || textRight || autoValidate) && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
4418
2876
  textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
4419
2877
  iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 24 }, index)),
4420
- autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
2878
+ autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid ? iconValidState : iconInvalidState })
4421
2879
  ] })
4422
2880
  ] }) }),
4423
2881
  input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
@@ -4520,7 +2978,7 @@ var FieldFileMultiUpload = ({ input, form, isSubmitting }) => {
4520
2978
  control: form.control,
4521
2979
  name: input.name,
4522
2980
  render: ({ field, fieldState }) => {
4523
- const isValid2 = !fieldState.error && files.length > 0;
2981
+ const isValid = !fieldState.error && files.length > 0;
4524
2982
  return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
4525
2983
  /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
4526
2984
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4573,7 +3031,7 @@ var FieldFileMultiUpload = ({ input, form, isSubmitting }) => {
4573
3031
  )
4574
3032
  ] }, idx)) }),
4575
3033
  input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
4576
- autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState }),
3034
+ autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: isSubmitting ? iconLoadingState : isValid ? iconValidState : iconInvalidState }),
4577
3035
  /* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
4578
3036
  ] });
4579
3037
  }
@@ -4589,7 +3047,7 @@ var TextInputGroup = class extends BaseInput {
4589
3047
  }
4590
3048
  };
4591
3049
  var FieldTextGroup = ({ form, input, isSubmitting }) => {
4592
- const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
3050
+ const [isValid, setIsValid] = React3.useState(isValidField(input, form));
4593
3051
  const formField = /* @__PURE__ */ jsxRuntime.jsx(
4594
3052
  FormField,
4595
3053
  {
@@ -4604,7 +3062,7 @@ var FieldTextGroup = ({ form, input, isSubmitting }) => {
4604
3062
  isSubmitting,
4605
3063
  field,
4606
3064
  form,
4607
- isValid: isValid2
3065
+ isValid
4608
3066
  }) }),
4609
3067
  input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
4610
3068
  /* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
@@ -4622,7 +3080,7 @@ var CustomInputGroup = ({
4622
3080
  form,
4623
3081
  isSubmitting,
4624
3082
  onChange,
4625
- isValid: isValid2
3083
+ isValid
4626
3084
  }) => {
4627
3085
  const groupConfig = input.inputGroupConfig;
4628
3086
  const infoTooltip = input?.infoTooltip;
@@ -4683,7 +3141,7 @@ var CustomInputGroup = ({
4683
3141
  children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { size: 20 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { size: 20 })
4684
3142
  }
4685
3143
  ),
4686
- autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
3144
+ autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid ? iconValidState : iconInvalidState })
4687
3145
  ] })
4688
3146
  ] });
4689
3147
  };
@@ -5012,7 +3470,7 @@ var FieldRepeater = ({ form, input, isSubmitting }) => {
5012
3470
  });
5013
3471
  const canAdd = !input.maxItems || fields.length < input.maxItems;
5014
3472
  const canRemove = fields.length > (input.minItems ?? 0);
5015
- const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
3473
+ const [isValid, setIsValid] = React3.useState(isValidField(input, form));
5016
3474
  React3.useEffect(() => {
5017
3475
  setIsValid(isValidField(input, form));
5018
3476
  }, [input]);
@@ -5049,7 +3507,7 @@ var FieldRepeater = ({ form, input, isSubmitting }) => {
5049
3507
  autoValidate: true,
5050
3508
  value: field.value,
5051
3509
  input: subField,
5052
- isValid: isValid2,
3510
+ isValid,
5053
3511
  field,
5054
3512
  form
5055
3513
  }
@@ -5656,7 +4114,7 @@ var StringValueListInput = class extends BaseInput {
5656
4114
  var FieldStringValueList = ({ form, input, isSubmitting }) => {
5657
4115
  const fieldName = input.name;
5658
4116
  const withAddBtn = input.withAddBtn ?? false;
5659
- const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
4117
+ const [isValid, setIsValid] = React3.useState(isValidField(input, form));
5660
4118
  React3.useEffect(() => {
5661
4119
  setIsValid(isValidField(input, form));
5662
4120
  }, [input]);
@@ -5705,7 +4163,7 @@ var FieldStringValueList = ({ form, input, isSubmitting }) => {
5705
4163
  autoValidate: true,
5706
4164
  value,
5707
4165
  input,
5708
- isValid: isValid2,
4166
+ isValid,
5709
4167
  onChange: (e) => handleChange(index, e.target.value),
5710
4168
  form
5711
4169
  }
@@ -5974,7 +4432,7 @@ var FieldTimeInput2 = ({ form, input, isSubmitting }) => {
5974
4432
  const iconsLeft = groupConfig?.iconsLeft ?? [];
5975
4433
  const textLeft = groupConfig?.textLeft;
5976
4434
  const textRight = groupConfig?.textRight;
5977
- const [isValid2, setIsValid] = React3.useState(() => {
4435
+ const [isValid, setIsValid] = React3.useState(() => {
5978
4436
  const value = form.getValues(input.name);
5979
4437
  const fieldState = form.getFieldState(input.name);
5980
4438
  return !fieldState.error && value !== void 0 && value !== "";
@@ -5991,7 +4449,7 @@ var FieldTimeInput2 = ({ form, input, isSubmitting }) => {
5991
4449
  name: input.name,
5992
4450
  render: ({ field, fieldState }) => {
5993
4451
  const validNow = !fieldState.error && field.value !== void 0 && field.value !== "";
5994
- if (validNow !== isValid2) setIsValid(validNow);
4452
+ if (validNow !== isValid) setIsValid(validNow);
5995
4453
  const handleChange = (val) => {
5996
4454
  setTime(val);
5997
4455
  handleOnChage(val, input, field);
@@ -6016,7 +4474,7 @@ var FieldTimeInput2 = ({ form, input, isSubmitting }) => {
6016
4474
  (iconsRight.length > 0 || textRight || autoValidate) && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
6017
4475
  textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
6018
4476
  iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index)),
6019
- autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
4477
+ autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid ? iconValidState : iconInvalidState })
6020
4478
  ] })
6021
4479
  ] }) }),
6022
4480
  input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
@@ -6257,7 +4715,10 @@ var DynamicForm = ({
6257
4715
  withFormWrapper = true,
6258
4716
  btnGroupDirection = "flex-end",
6259
4717
  withSubmitBtn = true,
6260
- debug = false
4718
+ debug = false,
4719
+ isWrapInWizard = false,
4720
+ totalSteps = 0,
4721
+ currentStep = 1
6261
4722
  }) => {
6262
4723
  const [isPending, startTransition] = React3.useTransition();
6263
4724
  const schema = React3.useMemo(() => {
@@ -6282,8 +4743,8 @@ var DynamicForm = ({
6282
4743
  };
6283
4744
  const handleClick = async () => {
6284
4745
  if (!onClick) return;
6285
- const isValid2 = await form.trigger();
6286
- if (!isValid2) return;
4746
+ const isValid = await form.trigger();
4747
+ if (!isValid) return;
6287
4748
  const data = form.watch();
6288
4749
  const resp = { data, form };
6289
4750
  onClick(resp);
@@ -6328,11 +4789,11 @@ var DynamicForm = ({
6328
4789
  disabled: isPending,
6329
4790
  onClick: onClick ? handleClick : void 0,
6330
4791
  children: isPending ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6331
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-5 w-5 mr-2 animate-spin" }),
6332
- submitBtnLabelSubmiting
4792
+ submitBtnLabelSubmiting,
4793
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-5 w-5 mr-2 animate-spin" })
6333
4794
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6334
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "h-5 w-5 mr-2" }),
6335
- submitBtnLabel
4795
+ submitBtnLabel,
4796
+ (totalSteps == 0 || totalSteps == currentStep) && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "h-5 w-5 mr-2" })
6336
4797
  ] })
6337
4798
  }
6338
4799
  )
@@ -6356,7 +4817,15 @@ var DynamicForm = ({
6356
4817
  fields
6357
4818
  }
6358
4819
  ),
6359
- withFormWrapper && /* @__PURE__ */ jsxRuntime.jsx(FormWrapper, { form, handleSubmit, children: formBody }),
4820
+ withFormWrapper && /* @__PURE__ */ jsxRuntime.jsx(
4821
+ FormWrapper,
4822
+ {
4823
+ form,
4824
+ isWrapInWizard,
4825
+ handleSubmit,
4826
+ children: formBody
4827
+ }
4828
+ ),
6360
4829
  !withFormWrapper && formBody,
6361
4830
  withErrorsAlert && errorAlertPosition === "down" && /* @__PURE__ */ jsxRuntime.jsx(
6362
4831
  FormErrorsAlert,
@@ -6369,7 +4838,7 @@ var DynamicForm = ({
6369
4838
  if (!withCard) return formContent;
6370
4839
  return /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsx(CardContent, { children: formContent }) });
6371
4840
  };
6372
- var FormWrapper = ({ form, handleSubmit, children, readOnly, debug }) => {
4841
+ var FormWrapper = ({ form, handleSubmit, children, readOnly, debug, isWrapInWizard }) => {
6373
4842
  const allValues = form.watch();
6374
4843
  return /* @__PURE__ */ jsxRuntime.jsx(Form, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs(
6375
4844
  "form",
@@ -6441,7 +4910,10 @@ function Stepper({ steps, currentStep, clickable = false, onStepClick }) {
6441
4910
  var WizardForm = ({
6442
4911
  fields,
6443
4912
  record,
6444
- onSubmit
4913
+ onSubmit,
4914
+ children,
4915
+ isWrapInWizard = true,
4916
+ skipSteps = false
6445
4917
  }) => {
6446
4918
  const [currentStep, setCurrentStep] = React3.useState(1);
6447
4919
  const flattenFields4 = (list) => list.flatMap((f) => Array.isArray(f) ? flattenFields4(f) : f);
@@ -6452,40 +4924,21 @@ var WizardForm = ({
6452
4924
  );
6453
4925
  const stepFields = allFields.filter((f) => (f.step ?? 1) === currentStep);
6454
4926
  return /* @__PURE__ */ jsxRuntime.jsxs(Card, { className: "flex flex-col gap-4 px-4", children: [
6455
- /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between mb-4 gap-2 px-4", children: [
6456
- /* @__PURE__ */ jsxRuntime.jsx(
6457
- Stepper,
6458
- {
6459
- steps: Array(totalSteps).fill({}),
6460
- currentStep,
6461
- clickable: true,
6462
- onStepClick: setCurrentStep
6463
- }
6464
- ),
6465
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-center space-x-4 gap-2", children: [
6466
- /* @__PURE__ */ jsxRuntime.jsx(
6467
- Button,
6468
- {
6469
- variant: "outline",
6470
- className: "w-32",
6471
- onClick: () => setCurrentStep((prev) => prev - 1),
6472
- disabled: currentStep === 1,
6473
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeftIcon, {})
6474
- }
6475
- ),
6476
- /* @__PURE__ */ jsxRuntime.jsx(
6477
- Button,
6478
- {
6479
- variant: "outline",
6480
- className: "w-32",
6481
- onClick: () => setCurrentStep((prev) => prev + 1),
6482
- disabled: currentStep > totalSteps,
6483
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRightIcon, {})
6484
- }
6485
- )
6486
- ] })
6487
- ] }) }),
6488
- /* @__PURE__ */ jsxRuntime.jsx(
4927
+ /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-between mb-4 gap-2 px-4", children: /* @__PURE__ */ jsxRuntime.jsx(
4928
+ Stepper,
4929
+ {
4930
+ steps: Array(totalSteps).fill({}),
4931
+ currentStep,
4932
+ clickable: skipSteps,
4933
+ onStepClick: setCurrentStep
4934
+ }
4935
+ ) }) }),
4936
+ children ? children({
4937
+ stepFields,
4938
+ currentStep,
4939
+ totalSteps,
4940
+ setCurrentStep
4941
+ }) : /* @__PURE__ */ jsxRuntime.jsx(
6489
4942
  DynamicForm,
6490
4943
  {
6491
4944
  record,
@@ -6494,7 +4947,10 @@ var WizardForm = ({
6494
4947
  withCard: false,
6495
4948
  errorAlertPosition: "down",
6496
4949
  fields: stepFields,
6497
- onSubmit
4950
+ onSubmit,
4951
+ isWrapInWizard: true,
4952
+ currentStep,
4953
+ totalSteps
6498
4954
  }
6499
4955
  )
6500
4956
  ] });