asterui 0.12.71 → 0.12.73

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.
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { FormItemProps } from './Form';
2
3
  export type DateOfBirthOrder = 'mdy' | 'dmy' | 'ymd';
3
4
  export type DateOfBirthMonthStyle = 'select' | 'grid';
4
5
  export type DateOfBirthYearStyle = 'select' | 'input';
@@ -26,4 +27,13 @@ export interface DateOfBirthProps extends Omit<React.HTMLAttributes<HTMLDivEleme
26
27
  /** Test ID prefix for child elements */
27
28
  'data-testid'?: string;
28
29
  }
29
- export declare const DateOfBirth: React.FC<DateOfBirthProps>;
30
+ export interface DateOfBirthRequiredOptions {
31
+ message?: string;
32
+ }
33
+ export type DateOfBirthRequiredProps = Pick<FormItemProps, 'rules' | 'validateTrigger'>;
34
+ export declare function dateOfBirthRequired(options?: DateOfBirthRequiredOptions): DateOfBirthRequiredProps;
35
+ type DateOfBirthComponent = React.FC<DateOfBirthProps> & {
36
+ required: (options?: DateOfBirthRequiredOptions) => DateOfBirthRequiredProps;
37
+ };
38
+ export declare const DateOfBirth: DateOfBirthComponent;
39
+ export {};
@@ -1,157 +1,189 @@
1
- import { jsxs as f, jsx as n } from "react/jsx-runtime";
2
- import { useState as Q, useEffect as _, useMemo as M } from "react";
3
- import { useConfig as X } from "../providers/ConfigProvider.js";
4
- import { Button as Z } from "./Button.js";
5
- import { Flex as A } from "./Flex.js";
6
- import { InputNumber as P } from "./InputNumber.js";
1
+ import { jsxs as y, jsx as n } from "react/jsx-runtime";
2
+ import { useState as Z, useEffect as O, useMemo as B } from "react";
3
+ import { useConfig as K } from "../providers/ConfigProvider.js";
4
+ import { Button as I } from "./Button.js";
5
+ import { Flex as _ } from "./Flex.js";
6
+ import { InputNumber as ee } from "./InputNumber.js";
7
7
  import { Select as C } from "./Select.js";
8
- import { Space as K } from "./Space.js";
9
- const I = Array.from({ length: 12 }, (r, o) => String(o + 1));
10
- function ee(r, o) {
11
- const c = new Intl.DateTimeFormat(r, { month: o });
12
- return I.map((m, s) => ({
13
- value: m,
14
- label: c.format(new Date(2020, s, 1))
8
+ import { Space as te } from "./Space.js";
9
+ const re = Array.from({ length: 12 }, (r, a) => String(a + 1));
10
+ function ne(r = {}) {
11
+ const a = r.message ?? "Please select a complete date of birth.";
12
+ return {
13
+ validateTrigger: ["onBlur", "onSubmit"],
14
+ rules: [({ isSubmitAttempted: d }) => ({
15
+ validate: (s) => {
16
+ const i = s ?? {};
17
+ return !!!(i.month || i.day || i.year) && !d() || i.month && i.day && i.year ? !0 : a;
18
+ }
19
+ })]
20
+ };
21
+ }
22
+ function ae(r, a) {
23
+ const u = new Intl.DateTimeFormat(r, { month: a });
24
+ return re.map((d, s) => ({
25
+ value: d,
26
+ label: u.format(new Date(2020, s, 1))
15
27
  }));
16
28
  }
17
- function te(r, o) {
18
- return new Date(r, o, 0).getDate();
29
+ function oe(r, a) {
30
+ return new Date(r, a, 0).getDate();
19
31
  }
20
- function re(r, o, c) {
32
+ function ie(r, a, u) {
21
33
  if (!r.year || !r.month || !r.day) return !0;
22
- const m = Number(r.year), s = Number(r.month) - 1, N = Number(r.day), l = new Date(m, s, N);
34
+ const d = Number(r.year), s = Number(r.month) - 1, i = Number(r.day), l = new Date(d, s, i);
23
35
  if (Number.isNaN(l.getTime())) return !1;
24
- const i = /* @__PURE__ */ new Date();
25
- let u = i.getFullYear() - l.getFullYear();
26
- return i.getMonth() > l.getMonth() || i.getMonth() === l.getMonth() && i.getDate() >= l.getDate() || (u -= 1), !(o !== void 0 && u < o || c !== void 0 && u > c);
36
+ const c = /* @__PURE__ */ new Date();
37
+ let f = c.getFullYear() - l.getFullYear();
38
+ return c.getMonth() > l.getMonth() || c.getMonth() === l.getMonth() && c.getDate() >= l.getDate() || (f -= 1), !(a !== void 0 && f < a || u !== void 0 && f > u);
27
39
  }
28
- const ne = ({
40
+ const q = ({
29
41
  value: r,
30
- defaultValue: o,
31
- onChange: c,
32
- yearSpan: m = 120,
42
+ defaultValue: a,
43
+ onChange: u,
44
+ yearSpan: d = 120,
33
45
  minAge: s = 13,
34
- maxAge: N,
46
+ maxAge: i,
35
47
  order: l = "mdy",
36
- monthStyle: i = "select",
37
- yearStyle: u = "select",
38
- monthPlaceholder: z = "Month",
39
- dayPlaceholder: O = "Day",
40
- yearPlaceholder: F = "Year",
41
- disabled: h = !1,
48
+ monthStyle: c = "select",
49
+ yearStyle: f = "select",
50
+ monthPlaceholder: F = "Month",
51
+ dayPlaceholder: E = "Day",
52
+ yearPlaceholder: S = "Year",
53
+ disabled: p = !1,
42
54
  size: H,
43
55
  className: L = "",
44
- "data-testid": a,
45
- ...j
56
+ "data-testid": o,
57
+ onBlur: j,
58
+ onFocus: R,
59
+ ...U
46
60
  }) => {
47
- const { locale: E, componentSize: U } = X(), p = H ?? U ?? "md", v = r !== void 0, [W, S] = Q(
48
- r ?? o ?? {}
61
+ const { locale: W, componentSize: k } = K(), v = H ?? k ?? "md", b = r !== void 0, [V, T] = Z(
62
+ r ?? a ?? {}
49
63
  );
50
- _(() => {
51
- v && S(r ?? {});
52
- }, [v, r]);
53
- const t = v ? r ?? {} : W, Y = E?.locale ?? "en-US", $ = M(
54
- () => ee(Y, i === "grid" ? "short" : "long"),
55
- [Y, i]
56
- ), y = M(() => {
64
+ O(() => {
65
+ b && T(r ?? {});
66
+ }, [b, r]);
67
+ const t = b ? r ?? {} : V, z = W?.locale ?? "en-US", A = B(
68
+ () => ae(z, c === "grid" ? "short" : "long"),
69
+ [z, c]
70
+ ), N = B(() => {
57
71
  const e = (/* @__PURE__ */ new Date()).getFullYear();
58
- return Array.from({ length: m }, (g, b) => String(e - b));
59
- }, [m]), D = M(() => {
60
- if (!t.month) return Array.from({ length: 31 }, (J, w) => String(w + 1));
61
- const e = Number(t.month), g = t.year ? Number(t.year) : 2e3, b = te(g, e);
62
- return Array.from({ length: b }, (J, w) => String(w + 1));
72
+ return Array.from({ length: d }, (m, g) => String(e - g));
73
+ }, [d]), w = B(() => {
74
+ if (!t.month) return Array.from({ length: 31 }, (D, M) => String(M + 1));
75
+ const e = Number(t.month), m = t.year ? Number(t.year) : 2e3, g = oe(m, e);
76
+ return Array.from({ length: g }, (D, M) => String(M + 1));
63
77
  }, [t.month, t.year]);
64
- _(() => {
65
- t.day && !D.includes(t.day) && d({ ...t, day: void 0 });
66
- }, [t.day, D]);
67
- const d = (e) => {
68
- v || S(e), c?.(e);
69
- }, x = () => i === "grid" ? /* @__PURE__ */ n("div", { className: "grid grid-cols-3 gap-2", children: $.map((e) => {
70
- const g = t.month === e.value;
78
+ O(() => {
79
+ t.day && !w.includes(t.day) && h({ ...t, day: void 0 });
80
+ }, [t.day, w]);
81
+ const h = (e) => {
82
+ b || T(e), u?.(e);
83
+ }, Y = () => c === "grid" ? /* @__PURE__ */ n("div", { className: "grid grid-cols-3 gap-2", children: A.map((e) => {
84
+ const m = t.month === e.value;
71
85
  return /* @__PURE__ */ n(
72
- Z,
86
+ I,
73
87
  {
74
88
  htmlType: "button",
75
89
  size: "sm",
76
- color: g ? "primary" : void 0,
77
- variant: g ? "solid" : "ghost",
78
- disabled: h,
79
- onClick: () => d({ ...t, month: e.value }),
80
- "data-testid": a ? `${a}-month-${e.value}` : void 0,
90
+ color: m ? "primary" : void 0,
91
+ variant: m ? "solid" : "ghost",
92
+ disabled: p,
93
+ onClick: () => h({ ...t, month: e.value }),
94
+ "data-testid": o ? `${o}-month-${e.value}` : void 0,
81
95
  children: e.label
82
96
  },
83
97
  e.value
84
98
  );
85
- }) }) : /* @__PURE__ */ f(
99
+ }) }) : /* @__PURE__ */ y(
86
100
  C,
87
101
  {
88
102
  value: t.month ?? "",
89
- onChange: (e) => d({ ...t, month: e.target.value }),
90
- disabled: h,
91
- size: p,
92
- "data-testid": a ? `${a}-month` : void 0,
103
+ onChange: (e) => h({ ...t, month: e.target.value }),
104
+ disabled: p,
105
+ size: v,
106
+ "data-testid": o ? `${o}-month` : void 0,
93
107
  children: [
94
- /* @__PURE__ */ n("option", { value: "", children: z }),
95
- $.map((e) => /* @__PURE__ */ n("option", { value: e.value, children: e.label }, e.value))
108
+ /* @__PURE__ */ n("option", { value: "", children: F }),
109
+ A.map((e) => /* @__PURE__ */ n("option", { value: e.value, children: e.label }, e.value))
96
110
  ]
97
111
  }
98
- ), k = () => /* @__PURE__ */ f(
112
+ ), G = () => /* @__PURE__ */ y(
99
113
  C,
100
114
  {
101
115
  value: t.day ?? "",
102
- onChange: (e) => d({ ...t, day: e.target.value }),
103
- disabled: h,
104
- size: p,
105
- "data-testid": a ? `${a}-day` : void 0,
116
+ onChange: (e) => h({ ...t, day: e.target.value }),
117
+ disabled: p,
118
+ size: v,
119
+ "data-testid": o ? `${o}-day` : void 0,
106
120
  children: [
107
- /* @__PURE__ */ n("option", { value: "", children: O }),
108
- D.map((e) => /* @__PURE__ */ n("option", { value: e, children: e }, e))
121
+ /* @__PURE__ */ n("option", { value: "", children: E }),
122
+ w.map((e) => /* @__PURE__ */ n("option", { value: e, children: e }, e))
109
123
  ]
110
124
  }
111
- ), R = () => u === "input" ? /* @__PURE__ */ n(
112
- P,
125
+ ), J = () => f === "input" ? /* @__PURE__ */ n(
126
+ ee,
113
127
  {
114
128
  value: t.year ? Number(t.year) : void 0,
115
- min: Number(y[y.length - 1]),
116
- max: Number(y[0]),
117
- placeholder: F,
118
- disabled: h,
119
- size: p,
120
- onChange: (e) => d({ ...t, year: e ? String(e) : void 0 }),
121
- "data-testid": a ? `${a}-year` : void 0
129
+ min: Number(N[N.length - 1]),
130
+ max: Number(N[0]),
131
+ placeholder: S,
132
+ disabled: p,
133
+ size: v,
134
+ onChange: (e) => h({ ...t, year: e ? String(e) : void 0 }),
135
+ "data-testid": o ? `${o}-year` : void 0
122
136
  }
123
- ) : /* @__PURE__ */ f(
137
+ ) : /* @__PURE__ */ y(
124
138
  C,
125
139
  {
126
140
  value: t.year ?? "",
127
- onChange: (e) => d({ ...t, year: e.target.value }),
128
- disabled: h,
129
- size: p,
130
- "data-testid": a ? `${a}-year` : void 0,
141
+ onChange: (e) => h({ ...t, year: e.target.value }),
142
+ disabled: p,
143
+ size: v,
144
+ "data-testid": o ? `${o}-year` : void 0,
131
145
  children: [
132
- /* @__PURE__ */ n("option", { value: "", children: F }),
133
- y.map((e) => /* @__PURE__ */ n("option", { value: e, children: e }, e))
146
+ /* @__PURE__ */ n("option", { value: "", children: S }),
147
+ N.map((e) => /* @__PURE__ */ n("option", { value: e, children: e }, e))
134
148
  ]
135
149
  }
136
- ), B = {
137
- m: x(),
138
- d: k(),
139
- y: R()
140
- }, V = l.split("").map((e) => e), q = l.split("").filter((e) => e !== "m").map((e) => e), T = {
150
+ ), $ = {
151
+ m: Y(),
152
+ d: G(),
153
+ y: J()
154
+ }, P = l.split("").map((e) => e), Q = l.split("").filter((e) => e !== "m").map((e) => e), x = {
141
155
  m: "w-full sm:w-[7rem]",
142
156
  d: "w-full sm:w-[5rem]",
143
157
  y: "w-full sm:w-[5rem]"
144
- }, G = t.year && t.month && t.day && !re(t, s, N);
145
- return /* @__PURE__ */ f("div", { className: L, "data-testid": a, ...j, children: [
146
- i === "grid" ? /* @__PURE__ */ f(K, { direction: "vertical", size: "sm", children: [
147
- x(),
148
- /* @__PURE__ */ n(A, { gap: "sm", children: q.map((e) => /* @__PURE__ */ n("div", { className: T[e], children: B[e] }, e)) })
149
- ] }) : /* @__PURE__ */ n(A, { wrap: "wrap", gap: "sm", children: V.map((e) => /* @__PURE__ */ n("div", { className: T[e], children: B[e] }, e)) }),
150
- G && /* @__PURE__ */ n("div", { className: "text-xs text-error mt-2", children: s ? `You must be at least ${s} years old.` : "Date of birth is not valid." })
151
- ] });
158
+ }, X = t.year && t.month && t.day && !ie(t, s, i);
159
+ return /* @__PURE__ */ y(
160
+ "div",
161
+ {
162
+ className: L,
163
+ "data-testid": o,
164
+ onBlur: (e) => {
165
+ const m = e.currentTarget, g = e.relatedTarget;
166
+ g && m.contains(g) || requestAnimationFrame(() => {
167
+ const D = document.activeElement;
168
+ D && m.contains(D) || j?.(e);
169
+ });
170
+ },
171
+ onFocus: R,
172
+ ...U,
173
+ children: [
174
+ c === "grid" ? /* @__PURE__ */ y(te, { direction: "vertical", size: "sm", children: [
175
+ Y(),
176
+ /* @__PURE__ */ n(_, { gap: "sm", children: Q.map((e) => /* @__PURE__ */ n("div", { className: x[e], children: $[e] }, e)) })
177
+ ] }) : /* @__PURE__ */ n(_, { wrap: "wrap", gap: "sm", children: P.map((e) => /* @__PURE__ */ n("div", { className: x[e], children: $[e] }, e)) }),
178
+ X && /* @__PURE__ */ n("div", { className: "text-xs text-error mt-2", children: s ? `You must be at least ${s} years old.` : "Date of birth is not valid." })
179
+ ]
180
+ }
181
+ );
152
182
  };
153
- ne.displayName = "DateOfBirth";
183
+ q.required = ne;
184
+ q.displayName = "DateOfBirth";
154
185
  export {
155
- ne as DateOfBirth
186
+ q as DateOfBirth,
187
+ ne as dateOfBirthRequired
156
188
  };
157
189
  //# sourceMappingURL=DateOfBirth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateOfBirth.js","sources":["../../src/components/DateOfBirth.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react'\nimport { useConfig } from '../providers/ConfigProvider'\nimport { Button } from './Button'\nimport { Flex } from './Flex'\nimport { InputNumber } from './InputNumber'\nimport { Select } from './Select'\nimport { Space } from './Space'\n\nexport type DateOfBirthOrder = 'mdy' | 'dmy' | 'ymd'\nexport type DateOfBirthMonthStyle = 'select' | 'grid'\nexport type DateOfBirthYearStyle = 'select' | 'input'\n\nexport interface DateOfBirthValue {\n month?: string\n day?: string\n year?: string\n}\n\nexport interface DateOfBirthProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n value?: DateOfBirthValue\n defaultValue?: DateOfBirthValue\n onChange?: (value: DateOfBirthValue) => void\n yearSpan?: number\n minAge?: number\n maxAge?: number\n order?: DateOfBirthOrder\n monthStyle?: DateOfBirthMonthStyle\n yearStyle?: DateOfBirthYearStyle\n monthPlaceholder?: string\n dayPlaceholder?: string\n yearPlaceholder?: string\n disabled?: boolean\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n className?: string\n /** Test ID prefix for child elements */\n 'data-testid'?: string\n}\n\nconst DEFAULT_MONTHS = Array.from({ length: 12 }, (_, index) => String(index + 1))\n\nfunction getMonthLabels(locale: string, format: 'long' | 'short') {\n const formatter = new Intl.DateTimeFormat(locale, { month: format })\n return DEFAULT_MONTHS.map((value, index) => ({\n value,\n label: formatter.format(new Date(2020, index, 1)),\n }))\n}\n\nfunction getDaysInMonth(year: number, month: number) {\n return new Date(year, month, 0).getDate()\n}\n\nfunction validateAge(value: DateOfBirthValue, minAge?: number, maxAge?: number) {\n if (!value.year || !value.month || !value.day) return true\n const year = Number(value.year)\n const month = Number(value.month) - 1\n const day = Number(value.day)\n const birthDate = new Date(year, month, day)\n if (Number.isNaN(birthDate.getTime())) return false\n const today = new Date()\n let age = today.getFullYear() - birthDate.getFullYear()\n const hasHadBirthday =\n today.getMonth() > birthDate.getMonth() ||\n (today.getMonth() === birthDate.getMonth() && today.getDate() >= birthDate.getDate())\n if (!hasHadBirthday) age -= 1\n if (minAge !== undefined && age < minAge) return false\n if (maxAge !== undefined && age > maxAge) return false\n return true\n}\n\nexport const DateOfBirth: React.FC<DateOfBirthProps> = ({\n value,\n defaultValue,\n onChange,\n yearSpan = 120,\n minAge = 13,\n maxAge,\n order = 'mdy',\n monthStyle = 'select',\n yearStyle = 'select',\n monthPlaceholder = 'Month',\n dayPlaceholder = 'Day',\n yearPlaceholder = 'Year',\n disabled = false,\n size,\n className = '',\n 'data-testid': testId,\n ...rest\n}) => {\n const { locale, componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n const isControlled = value !== undefined\n const [internalValue, setInternalValue] = useState<DateOfBirthValue>(\n value ?? defaultValue ?? {}\n )\n\n useEffect(() => {\n if (isControlled) {\n setInternalValue(value ?? {})\n }\n }, [isControlled, value])\n\n const currentValue = isControlled ? (value ?? {}) : internalValue\n const localeCode = locale?.locale ?? 'en-US'\n const monthLabels = useMemo(\n () => getMonthLabels(localeCode, monthStyle === 'grid' ? 'short' : 'long'),\n [localeCode, monthStyle]\n )\n\n const yearRange = useMemo(() => {\n const currentYear = new Date().getFullYear()\n return Array.from({ length: yearSpan }, (_, i) => String(currentYear - i))\n }, [yearSpan])\n\n const dayOptions = useMemo(() => {\n if (!currentValue.month) return Array.from({ length: 31 }, (_, i) => String(i + 1))\n const month = Number(currentValue.month)\n const year = currentValue.year ? Number(currentValue.year) : 2000\n const daysInMonth = getDaysInMonth(year, month)\n return Array.from({ length: daysInMonth }, (_, i) => String(i + 1))\n }, [currentValue.month, currentValue.year])\n\n useEffect(() => {\n if (currentValue.day && !dayOptions.includes(currentValue.day)) {\n handleChange({ ...currentValue, day: undefined })\n }\n }, [currentValue.day, dayOptions])\n\n const handleChange = (nextValue: DateOfBirthValue) => {\n if (!isControlled) {\n setInternalValue(nextValue)\n }\n onChange?.(nextValue)\n }\n\n const renderMonth = () => {\n if (monthStyle === 'grid') {\n return (\n <div className=\"grid grid-cols-3 gap-2\">\n {monthLabels.map((month) => {\n const isActive = currentValue.month === month.value\n return (\n <Button\n key={month.value}\n htmlType=\"button\"\n size=\"sm\"\n color={isActive ? 'primary' : undefined}\n variant={isActive ? 'solid' : 'ghost'}\n disabled={disabled}\n onClick={() => handleChange({ ...currentValue, month: month.value })}\n data-testid={testId ? `${testId}-month-${month.value}` : undefined}\n >\n {month.label}\n </Button>\n )\n })}\n </div>\n )\n }\n\n return (\n <Select\n value={currentValue.month ?? ''}\n onChange={(e) => handleChange({ ...currentValue, month: e.target.value })}\n disabled={disabled}\n size={effectiveSize}\n data-testid={testId ? `${testId}-month` : undefined}\n >\n <option value=\"\">{monthPlaceholder}</option>\n {monthLabels.map((month) => (\n <option key={month.value} value={month.value}>\n {month.label}\n </option>\n ))}\n </Select>\n )\n }\n\n const renderDay = () => (\n <Select\n value={currentValue.day ?? ''}\n onChange={(e) => handleChange({ ...currentValue, day: e.target.value })}\n disabled={disabled}\n size={effectiveSize}\n data-testid={testId ? `${testId}-day` : undefined}\n >\n <option value=\"\">{dayPlaceholder}</option>\n {dayOptions.map((day) => (\n <option key={day} value={day}>{day}</option>\n ))}\n </Select>\n )\n\n const renderYear = () => {\n if (yearStyle === 'input') {\n return (\n <InputNumber\n value={currentValue.year ? Number(currentValue.year) : undefined}\n min={Number(yearRange[yearRange.length - 1])}\n max={Number(yearRange[0])}\n placeholder={yearPlaceholder}\n disabled={disabled}\n size={effectiveSize}\n onChange={(nextValue) => handleChange({ ...currentValue, year: nextValue ? String(nextValue) : undefined })}\n data-testid={testId ? `${testId}-year` : undefined}\n />\n )\n }\n\n return (\n <Select\n value={currentValue.year ?? ''}\n onChange={(e) => handleChange({ ...currentValue, year: e.target.value })}\n disabled={disabled}\n size={effectiveSize}\n data-testid={testId ? `${testId}-year` : undefined}\n >\n <option value=\"\">{yearPlaceholder}</option>\n {yearRange.map((year) => (\n <option key={year} value={year}>{year}</option>\n ))}\n </Select>\n )\n }\n\n const fieldMap = {\n m: renderMonth(),\n d: renderDay(),\n y: renderYear(),\n }\n\n const orderedFields = order.split('').map((key) => key as keyof typeof fieldMap)\n const gridFields = order\n .split('')\n .filter((key) => key !== 'm')\n .map((key) => key as keyof typeof fieldMap)\n const fieldWidths: Record<'m' | 'd' | 'y', string> = {\n m: 'w-full sm:w-[7rem]',\n d: 'w-full sm:w-[5rem]',\n y: 'w-full sm:w-[5rem]',\n }\n\n const showAgeWarning = currentValue.year && currentValue.month && currentValue.day && !validateAge(currentValue, minAge, maxAge)\n\n return (\n <div className={className} data-testid={testId} {...rest}>\n {monthStyle === 'grid' ? (\n <Space direction=\"vertical\" size=\"sm\">\n {renderMonth()}\n <Flex gap=\"sm\">\n {gridFields.map((fieldKey) => (\n <div key={fieldKey} className={fieldWidths[fieldKey]}>\n {fieldMap[fieldKey]}\n </div>\n ))}\n </Flex>\n </Space>\n ) : (\n <Flex wrap=\"wrap\" gap=\"sm\">\n {orderedFields.map((fieldKey) => (\n <div key={fieldKey} className={fieldWidths[fieldKey]}>\n {fieldMap[fieldKey]}\n </div>\n ))}\n </Flex>\n )}\n\n {showAgeWarning && (\n <div className=\"text-xs text-error mt-2\">\n {minAge ? `You must be at least ${minAge} years old.` : 'Date of birth is not valid.'}\n </div>\n )}\n </div>\n )\n}\n\nDateOfBirth.displayName = 'DateOfBirth'\n"],"names":["DEFAULT_MONTHS","_","index","getMonthLabels","locale","format","formatter","value","getDaysInMonth","year","month","validateAge","minAge","maxAge","day","birthDate","today","age","DateOfBirth","defaultValue","onChange","yearSpan","order","monthStyle","yearStyle","monthPlaceholder","dayPlaceholder","yearPlaceholder","disabled","size","className","testId","rest","componentSize","useConfig","effectiveSize","isControlled","internalValue","setInternalValue","useState","useEffect","currentValue","localeCode","monthLabels","useMemo","yearRange","currentYear","i","dayOptions","daysInMonth","handleChange","nextValue","renderMonth","isActive","jsx","Button","jsxs","Select","renderDay","renderYear","InputNumber","fieldMap","orderedFields","key","gridFields","fieldWidths","showAgeWarning","Space","Flex","fieldKey"],"mappings":";;;;;;;;AAsCA,MAAMA,IAAiB,MAAM,KAAK,EAAE,QAAQ,GAAA,GAAM,CAACC,GAAGC,MAAU,OAAOA,IAAQ,CAAC,CAAC;AAEjF,SAASC,GAAeC,GAAgBC,GAA0B;AAChE,QAAMC,IAAY,IAAI,KAAK,eAAeF,GAAQ,EAAE,OAAOC,GAAQ;AACnE,SAAOL,EAAe,IAAI,CAACO,GAAOL,OAAW;AAAA,IAC3C,OAAAK;AAAA,IACA,OAAOD,EAAU,OAAO,IAAI,KAAK,MAAMJ,GAAO,CAAC,CAAC;AAAA,EAAA,EAChD;AACJ;AAEA,SAASM,GAAeC,GAAcC,GAAe;AACnD,SAAO,IAAI,KAAKD,GAAMC,GAAO,CAAC,EAAE,QAAA;AAClC;AAEA,SAASC,GAAYJ,GAAyBK,GAAiBC,GAA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,GAAGC,EAAA;AAAA,EAAW,GAGVG,IAAgBxC,EAAM,MAAM,EAAE,EAAE,IAAI,CAACyC,MAAQA,CAA4B,GACzEC,IAAa1C,EAChB,MAAM,EAAE,EACR,OAAO,CAACyC,MAAQA,MAAQ,GAAG,EAC3B,IAAI,CAACA,MAAQA,CAA4B,GACtCE,IAA+C;AAAA,IACnD,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,EAAA,GAGCC,IAAiBzB,EAAa,QAAQA,EAAa,SAASA,EAAa,OAAO,CAAC9B,GAAY8B,GAAc7B,GAAQC,CAAM;AAE/H,2BACG,OAAA,EAAI,WAAAiB,GAAsB,eAAaC,GAAS,GAAGC,GACjD,UAAA;AAAA,IAAAT,MAAe,SACd,gBAAAiC,EAACW,GAAA,EAAM,WAAU,YAAW,MAAK,MAC9B,UAAA;AAAA,MAAAf,EAAA;AAAA,wBACAgB,GAAA,EAAK,KAAI,MACP,UAAAJ,EAAW,IAAI,CAACK,MACf,gBAAAf,EAAC,SAAmB,WAAWW,EAAYI,CAAQ,GAChD,UAAAR,EAASQ,CAAQ,EAAA,GADVA,CAEV,CACD,EAAA,CACH;AAAA,IAAA,EAAA,CACF,sBAECD,GAAA,EAAK,MAAK,QAAO,KAAI,MACnB,UAAAN,EAAc,IAAI,CAACO,wBACjB,OAAA,EAAmB,WAAWJ,EAAYI,CAAQ,GAChD,YAASA,CAAQ,EAAA,GADVA,CAEV,CACD,EAAA,CACH;AAAA,IAGDH,uBACE,OAAA,EAAI,WAAU,2BACZ,UAAAtD,IAAS,wBAAwBA,CAAM,gBAAgB,8BAAA,CAC1D;AAAA,EAAA,GAEJ;AAEJ;AAEAM,GAAY,cAAc;"}
1
+ {"version":3,"file":"DateOfBirth.js","sources":["../../src/components/DateOfBirth.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react'\nimport { useConfig } from '../providers/ConfigProvider'\nimport { Button } from './Button'\nimport { Flex } from './Flex'\nimport { InputNumber } from './InputNumber'\nimport { Select } from './Select'\nimport { Space } from './Space'\nimport type { FormItemProps, FormRuleInput } from './Form'\n\nexport type DateOfBirthOrder = 'mdy' | 'dmy' | 'ymd'\nexport type DateOfBirthMonthStyle = 'select' | 'grid'\nexport type DateOfBirthYearStyle = 'select' | 'input'\n\nexport interface DateOfBirthValue {\n month?: string\n day?: string\n year?: string\n}\n\nexport interface DateOfBirthProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n value?: DateOfBirthValue\n defaultValue?: DateOfBirthValue\n onChange?: (value: DateOfBirthValue) => void\n yearSpan?: number\n minAge?: number\n maxAge?: number\n order?: DateOfBirthOrder\n monthStyle?: DateOfBirthMonthStyle\n yearStyle?: DateOfBirthYearStyle\n monthPlaceholder?: string\n dayPlaceholder?: string\n yearPlaceholder?: string\n disabled?: boolean\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n className?: string\n /** Test ID prefix for child elements */\n 'data-testid'?: string\n}\n\nconst DEFAULT_MONTHS = Array.from({ length: 12 }, (_, index) => String(index + 1))\n\nexport interface DateOfBirthRequiredOptions {\n message?: string\n}\n\nexport type DateOfBirthRequiredProps = Pick<FormItemProps, 'rules' | 'validateTrigger'>\n\nexport function dateOfBirthRequired(options: DateOfBirthRequiredOptions = {}): DateOfBirthRequiredProps {\n const message = options.message ?? 'Please select a complete date of birth.'\n\n const rules: FormRuleInput[] = [({ isSubmitAttempted }) => ({\n validate: (value: DateOfBirthValue | undefined) => {\n const dob = value ?? {}\n const hasAny = !!(dob.month || dob.day || dob.year)\n if (!hasAny && !isSubmitAttempted()) {\n return true\n }\n return dob.month && dob.day && dob.year ? true : message\n },\n })]\n\n return {\n validateTrigger: ['onBlur', 'onSubmit'],\n rules,\n }\n}\n\ntype DateOfBirthComponent = React.FC<DateOfBirthProps> & {\n required: (options?: DateOfBirthRequiredOptions) => DateOfBirthRequiredProps\n}\n\nfunction getMonthLabels(locale: string, format: 'long' | 'short') {\n const formatter = new Intl.DateTimeFormat(locale, { month: format })\n return DEFAULT_MONTHS.map((value, index) => ({\n value,\n label: formatter.format(new Date(2020, index, 1)),\n }))\n}\n\nfunction getDaysInMonth(year: number, month: number) {\n return new Date(year, month, 0).getDate()\n}\n\nfunction validateAge(value: DateOfBirthValue, minAge?: number, maxAge?: number) {\n if (!value.year || !value.month || !value.day) return true\n const year = Number(value.year)\n const month = Number(value.month) - 1\n const day = Number(value.day)\n const birthDate = new Date(year, month, day)\n if (Number.isNaN(birthDate.getTime())) return false\n const today = new Date()\n let age = today.getFullYear() - birthDate.getFullYear()\n const hasHadBirthday =\n today.getMonth() > birthDate.getMonth() ||\n (today.getMonth() === birthDate.getMonth() && today.getDate() >= birthDate.getDate())\n if (!hasHadBirthday) age -= 1\n if (minAge !== undefined && age < minAge) return false\n if (maxAge !== undefined && age > maxAge) return false\n return true\n}\n\nexport const DateOfBirth: DateOfBirthComponent = ({\n value,\n defaultValue,\n onChange,\n yearSpan = 120,\n minAge = 13,\n maxAge,\n order = 'mdy',\n monthStyle = 'select',\n yearStyle = 'select',\n monthPlaceholder = 'Month',\n dayPlaceholder = 'Day',\n yearPlaceholder = 'Year',\n disabled = false,\n size,\n className = '',\n 'data-testid': testId,\n onBlur,\n onFocus,\n ...rest\n}) => {\n const { locale, componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n const isControlled = value !== undefined\n const [internalValue, setInternalValue] = useState<DateOfBirthValue>(\n value ?? defaultValue ?? {}\n )\n\n useEffect(() => {\n if (isControlled) {\n setInternalValue(value ?? {})\n }\n }, [isControlled, value])\n\n const currentValue = isControlled ? (value ?? {}) : internalValue\n const localeCode = locale?.locale ?? 'en-US'\n const monthLabels = useMemo(\n () => getMonthLabels(localeCode, monthStyle === 'grid' ? 'short' : 'long'),\n [localeCode, monthStyle]\n )\n\n const yearRange = useMemo(() => {\n const currentYear = new Date().getFullYear()\n return Array.from({ length: yearSpan }, (_, i) => String(currentYear - i))\n }, [yearSpan])\n\n const dayOptions = useMemo(() => {\n if (!currentValue.month) return Array.from({ length: 31 }, (_, i) => String(i + 1))\n const month = Number(currentValue.month)\n const year = currentValue.year ? Number(currentValue.year) : 2000\n const daysInMonth = getDaysInMonth(year, month)\n return Array.from({ length: daysInMonth }, (_, i) => String(i + 1))\n }, [currentValue.month, currentValue.year])\n\n useEffect(() => {\n if (currentValue.day && !dayOptions.includes(currentValue.day)) {\n handleChange({ ...currentValue, day: undefined })\n }\n }, [currentValue.day, dayOptions])\n\n const handleChange = (nextValue: DateOfBirthValue) => {\n if (!isControlled) {\n setInternalValue(nextValue)\n }\n onChange?.(nextValue)\n }\n\n const renderMonth = () => {\n if (monthStyle === 'grid') {\n return (\n <div className=\"grid grid-cols-3 gap-2\">\n {monthLabels.map((month) => {\n const isActive = currentValue.month === month.value\n return (\n <Button\n key={month.value}\n htmlType=\"button\"\n size=\"sm\"\n color={isActive ? 'primary' : undefined}\n variant={isActive ? 'solid' : 'ghost'}\n disabled={disabled}\n onClick={() => handleChange({ ...currentValue, month: month.value })}\n data-testid={testId ? `${testId}-month-${month.value}` : undefined}\n >\n {month.label}\n </Button>\n )\n })}\n </div>\n )\n }\n\n return (\n <Select\n value={currentValue.month ?? ''}\n onChange={(e) => handleChange({ ...currentValue, month: e.target.value })}\n disabled={disabled}\n size={effectiveSize}\n data-testid={testId ? `${testId}-month` : undefined}\n >\n <option value=\"\">{monthPlaceholder}</option>\n {monthLabels.map((month) => (\n <option key={month.value} value={month.value}>\n {month.label}\n </option>\n ))}\n </Select>\n )\n }\n\n const renderDay = () => (\n <Select\n value={currentValue.day ?? ''}\n onChange={(e) => handleChange({ ...currentValue, day: e.target.value })}\n disabled={disabled}\n size={effectiveSize}\n data-testid={testId ? `${testId}-day` : undefined}\n >\n <option value=\"\">{dayPlaceholder}</option>\n {dayOptions.map((day) => (\n <option key={day} value={day}>{day}</option>\n ))}\n </Select>\n )\n\n const renderYear = () => {\n if (yearStyle === 'input') {\n return (\n <InputNumber\n value={currentValue.year ? Number(currentValue.year) : undefined}\n min={Number(yearRange[yearRange.length - 1])}\n max={Number(yearRange[0])}\n placeholder={yearPlaceholder}\n disabled={disabled}\n size={effectiveSize}\n onChange={(nextValue) => handleChange({ ...currentValue, year: nextValue ? String(nextValue) : undefined })}\n data-testid={testId ? `${testId}-year` : undefined}\n />\n )\n }\n\n return (\n <Select\n value={currentValue.year ?? ''}\n onChange={(e) => handleChange({ ...currentValue, year: e.target.value })}\n disabled={disabled}\n size={effectiveSize}\n data-testid={testId ? `${testId}-year` : undefined}\n >\n <option value=\"\">{yearPlaceholder}</option>\n {yearRange.map((year) => (\n <option key={year} value={year}>{year}</option>\n ))}\n </Select>\n )\n }\n\n const fieldMap = {\n m: renderMonth(),\n d: renderDay(),\n y: renderYear(),\n }\n\n const orderedFields = order.split('').map((key) => key as keyof typeof fieldMap)\n const gridFields = order\n .split('')\n .filter((key) => key !== 'm')\n .map((key) => key as keyof typeof fieldMap)\n const fieldWidths: Record<'m' | 'd' | 'y', string> = {\n m: 'w-full sm:w-[7rem]',\n d: 'w-full sm:w-[5rem]',\n y: 'w-full sm:w-[5rem]',\n }\n\n const showAgeWarning = currentValue.year && currentValue.month && currentValue.day && !validateAge(currentValue, minAge, maxAge)\n\n const handleBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n const currentTarget = event.currentTarget\n const next = event.relatedTarget as Node | null\n if (next && currentTarget.contains(next)) return\n requestAnimationFrame(() => {\n const active = document.activeElement\n if (active && currentTarget.contains(active)) return\n onBlur?.(event)\n })\n }\n\n return (\n <div\n className={className}\n data-testid={testId}\n onBlur={handleBlur}\n onFocus={onFocus}\n {...rest}\n >\n {monthStyle === 'grid' ? (\n <Space direction=\"vertical\" size=\"sm\">\n {renderMonth()}\n <Flex gap=\"sm\">\n {gridFields.map((fieldKey) => (\n <div key={fieldKey} className={fieldWidths[fieldKey]}>\n {fieldMap[fieldKey]}\n </div>\n ))}\n </Flex>\n </Space>\n ) : (\n <Flex wrap=\"wrap\" gap=\"sm\">\n {orderedFields.map((fieldKey) => (\n <div key={fieldKey} className={fieldWidths[fieldKey]}>\n {fieldMap[fieldKey]}\n </div>\n ))}\n </Flex>\n )}\n\n {showAgeWarning && (\n <div className=\"text-xs text-error mt-2\">\n {minAge ? `You must be at least ${minAge} years old.` : 'Date of birth is not valid.'}\n </div>\n )}\n </div>\n )\n}\n\nDateOfBirth.required = dateOfBirthRequired\n\nDateOfBirth.displayName = 'DateOfBirth'\n"],"names":["DEFAULT_MONTHS","_","index","dateOfBirthRequired","options","message","isSubmitAttempted","value","dob","getMonthLabels","locale","format","formatter","getDaysInMonth","year","month","validateAge","minAge","maxAge","day","birthDate","today","age","DateOfBirth","defaultValue","onChange","yearSpan","order","monthStyle","yearStyle","monthPlaceholder","dayPlaceholder","yearPlaceholder","disabled","size","className","testId","onBlur","onFocus","rest","componentSize","useConfig","effectiveSize","isControlled","internalValue","setInternalValue","useState","useEffect","currentValue","localeCode","monthLabels","useMemo","yearRange","currentYear","i","dayOptions","daysInMonth","handleChange","nextValue","renderMonth","isActive","jsx","Button","jsxs","Select","renderDay","renderYear","InputNumber","fieldMap","orderedFields","key","gridFields","fieldWidths","showAgeWarning","event","currentTarget","next","active","Space","Flex","fieldKey"],"mappings":";;;;;;;;AAuCA,MAAMA,KAAiB,MAAM,KAAK,EAAE,QAAQ,GAAA,GAAM,CAACC,GAAGC,MAAU,OAAOA,IAAQ,CAAC,CAAC;AAQ1E,SAASC,GAAoBC,IAAsC,IAA8B;AACtG,QAAMC,IAAUD,EAAQ,WAAW;AAanC,SAAO;AAAA,IACL,iBAAiB,CAAC,UAAU,UAAU;AAAA,IACtC,OAb6B,CAAC,CAAC,EAAE,mBAAAE,SAAyB;AAAA,MAC1D,UAAU,CAACC,MAAwC;AACjD,cAAMC,IAAMD,KAAS,CAAA;AAErB,eAAI,CADW,CAAC,EAAEC,EAAI,SAASA,EAAI,OAAOA,EAAI,SAC/B,CAACF,OAGTE,EAAI,SAASA,EAAI,OAAOA,EAAI,OAF1B,K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