asterui 0.12.78 → 0.12.79

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,189 +1,178 @@
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";
1
+ import { jsxs as w, jsx as t } from "react/jsx-runtime";
2
+ import { useState as X, useEffect as x, useMemo as N } from "react";
3
+ import { useConfig as Z } from "../providers/ConfigProvider.js";
4
+ import { Button as K } from "./Button.js";
5
+ import { Flex as O } from "./Flex.js";
6
+ import { InputNumber as I } from "./InputNumber.js";
7
7
  import { Select as C } from "./Select.js";
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.";
8
+ import { Space as ee } from "./Space.js";
9
+ const re = Array.from({ length: 12 }, (n, o) => String(o + 1));
10
+ function te(n = {}) {
11
+ const o = n.message ?? "Please select a complete date of birth.";
12
12
  return {
13
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;
14
+ rules: [({ isSubmitAttempted: s }) => ({
15
+ validate: (h) => {
16
+ const l = h ?? {};
17
+ return !!!(l.month || l.day || l.year) && !s() || l.month && l.day && l.year ? !0 : o;
18
18
  }
19
19
  })]
20
20
  };
21
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))
22
+ function ne(n, o) {
23
+ const d = new Intl.DateTimeFormat(n, { month: o });
24
+ return re.map((s, h) => ({
25
+ value: s,
26
+ label: d.format(new Date(2020, h, 1))
27
27
  }));
28
28
  }
29
- function oe(r, a) {
30
- return new Date(r, a, 0).getDate();
29
+ function ae(n, o) {
30
+ return new Date(n, o, 0).getDate();
31
31
  }
32
- function ie(r, a, u) {
33
- if (!r.year || !r.month || !r.day) return !0;
34
- const d = Number(r.year), s = Number(r.month) - 1, i = Number(r.day), l = new Date(d, s, i);
35
- if (Number.isNaN(l.getTime())) return !1;
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);
39
- }
40
- const q = ({
41
- value: r,
42
- defaultValue: a,
43
- onChange: u,
44
- yearSpan: d = 120,
45
- minAge: s = 13,
46
- maxAge: i,
47
- order: l = "mdy",
48
- monthStyle: c = "select",
49
- yearStyle: f = "select",
50
- monthPlaceholder: F = "Month",
32
+ const _ = ({
33
+ value: n,
34
+ defaultValue: o,
35
+ onChange: d,
36
+ yearSpan: s = 120,
37
+ minAge: h,
38
+ maxAge: l,
39
+ order: b = "mdy",
40
+ monthStyle: g = "select",
41
+ yearStyle: Y = "select",
42
+ monthPlaceholder: q = "Month",
51
43
  dayPlaceholder: E = "Day",
52
44
  yearPlaceholder: S = "Year",
53
- disabled: p = !1,
54
- size: H,
55
- className: L = "",
56
- "data-testid": o,
57
- onBlur: j,
58
- onFocus: R,
59
- ...U
45
+ disabled: u = !1,
46
+ size: L,
47
+ className: j = "",
48
+ "data-testid": a,
49
+ onBlur: R,
50
+ onFocus: U,
51
+ ...k
60
52
  }) => {
61
- const { locale: W, componentSize: k } = K(), v = H ?? k ?? "md", b = r !== void 0, [V, T] = Z(
62
- r ?? a ?? {}
53
+ const { locale: H, componentSize: V } = Z(), p = L ?? V ?? "md", f = n !== void 0, [W, z] = X(
54
+ n ?? o ?? {}
63
55
  );
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(() => {
56
+ x(() => {
57
+ f && z(n ?? {});
58
+ }, [f, n]);
59
+ const r = f ? n ?? {} : W, B = H?.locale ?? "en-US", M = N(
60
+ () => ne(B, g === "grid" ? "short" : "long"),
61
+ [B, g]
62
+ ), v = N(() => {
71
63
  const e = (/* @__PURE__ */ new Date()).getFullYear();
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));
77
- }, [t.month, t.year]);
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;
85
- return /* @__PURE__ */ n(
86
- I,
64
+ return Array.from({ length: s }, (i, m) => String(e - m));
65
+ }, [s]), A = N(() => {
66
+ if (!r.month) return Array.from({ length: 31 }, (y, D) => String(D + 1));
67
+ const e = Number(r.month), i = r.year ? Number(r.year) : 2e3, m = ae(i, e);
68
+ return Array.from({ length: m }, (y, D) => String(D + 1));
69
+ }, [r.month, r.year]);
70
+ x(() => {
71
+ r.day && !A.includes(r.day) && c({ ...r, day: void 0 });
72
+ }, [r.day, A]);
73
+ const c = (e) => {
74
+ f || z(e), d?.(e);
75
+ }, T = () => g === "grid" ? /* @__PURE__ */ t("div", { className: "grid grid-cols-3 gap-2", children: M.map((e) => {
76
+ const i = r.month === e.value;
77
+ return /* @__PURE__ */ t(
78
+ K,
87
79
  {
88
80
  htmlType: "button",
89
81
  size: "sm",
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,
82
+ color: i ? "primary" : void 0,
83
+ variant: i ? "solid" : "ghost",
84
+ disabled: u,
85
+ onClick: () => c({ ...r, month: e.value }),
86
+ "data-testid": a ? `${a}-month-${e.value}` : void 0,
95
87
  children: e.label
96
88
  },
97
89
  e.value
98
90
  );
99
- }) }) : /* @__PURE__ */ y(
91
+ }) }) : /* @__PURE__ */ w(
100
92
  C,
101
93
  {
102
- value: t.month ?? "",
103
- onChange: (e) => h({ ...t, month: e.target.value }),
104
- disabled: p,
105
- size: v,
106
- "data-testid": o ? `${o}-month` : void 0,
94
+ value: r.month ?? "",
95
+ onChange: (e) => c({ ...r, month: e.target.value }),
96
+ disabled: u,
97
+ size: p,
98
+ "data-testid": a ? `${a}-month` : void 0,
107
99
  children: [
108
- /* @__PURE__ */ n("option", { value: "", children: F }),
109
- A.map((e) => /* @__PURE__ */ n("option", { value: e.value, children: e.label }, e.value))
100
+ /* @__PURE__ */ t("option", { value: "", children: q }),
101
+ M.map((e) => /* @__PURE__ */ t("option", { value: e.value, children: e.label }, e.value))
110
102
  ]
111
103
  }
112
- ), G = () => /* @__PURE__ */ y(
104
+ ), G = () => /* @__PURE__ */ w(
113
105
  C,
114
106
  {
115
- value: t.day ?? "",
116
- onChange: (e) => h({ ...t, day: e.target.value }),
117
- disabled: p,
118
- size: v,
119
- "data-testid": o ? `${o}-day` : void 0,
107
+ value: r.day ?? "",
108
+ onChange: (e) => c({ ...r, day: e.target.value }),
109
+ disabled: u,
110
+ size: p,
111
+ "data-testid": a ? `${a}-day` : void 0,
120
112
  children: [
121
- /* @__PURE__ */ n("option", { value: "", children: E }),
122
- w.map((e) => /* @__PURE__ */ n("option", { value: e, children: e }, e))
113
+ /* @__PURE__ */ t("option", { value: "", children: E }),
114
+ A.map((e) => /* @__PURE__ */ t("option", { value: e, children: e }, e))
123
115
  ]
124
116
  }
125
- ), J = () => f === "input" ? /* @__PURE__ */ n(
126
- ee,
117
+ ), J = () => Y === "input" ? /* @__PURE__ */ t(
118
+ I,
127
119
  {
128
- value: t.year ? Number(t.year) : void 0,
129
- min: Number(N[N.length - 1]),
130
- max: Number(N[0]),
120
+ value: r.year ? Number(r.year) : void 0,
121
+ min: Number(v[v.length - 1]),
122
+ max: Number(v[0]),
131
123
  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
124
+ disabled: u,
125
+ size: p,
126
+ onChange: (e) => c({ ...r, year: e ? String(e) : void 0 }),
127
+ "data-testid": a ? `${a}-year` : void 0
136
128
  }
137
- ) : /* @__PURE__ */ y(
129
+ ) : /* @__PURE__ */ w(
138
130
  C,
139
131
  {
140
- value: t.year ?? "",
141
- onChange: (e) => h({ ...t, year: e.target.value }),
142
- disabled: p,
143
- size: v,
144
- "data-testid": o ? `${o}-year` : void 0,
132
+ value: r.year ?? "",
133
+ onChange: (e) => c({ ...r, year: e.target.value }),
134
+ disabled: u,
135
+ size: p,
136
+ "data-testid": a ? `${a}-year` : void 0,
145
137
  children: [
146
- /* @__PURE__ */ n("option", { value: "", children: S }),
147
- N.map((e) => /* @__PURE__ */ n("option", { value: e, children: e }, e))
138
+ /* @__PURE__ */ t("option", { value: "", children: S }),
139
+ v.map((e) => /* @__PURE__ */ t("option", { value: e, children: e }, e))
148
140
  ]
149
141
  }
150
- ), $ = {
151
- m: Y(),
142
+ ), F = {
143
+ m: T(),
152
144
  d: G(),
153
145
  y: J()
154
- }, P = l.split("").map((e) => e), Q = l.split("").filter((e) => e !== "m").map((e) => e), x = {
146
+ }, P = b.split("").map((e) => e), Q = b.split("").filter((e) => e !== "m").map((e) => e), $ = {
155
147
  m: "w-full sm:w-[7rem]",
156
148
  d: "w-full sm:w-[5rem]",
157
149
  y: "w-full sm:w-[5rem]"
158
- }, X = t.year && t.month && t.day && !ie(t, s, i);
159
- return /* @__PURE__ */ y(
150
+ };
151
+ return /* @__PURE__ */ t(
160
152
  "div",
161
153
  {
162
- className: L,
163
- "data-testid": o,
154
+ className: j,
155
+ "data-testid": a,
164
156
  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);
157
+ const i = e.currentTarget, m = e.relatedTarget;
158
+ m && i.contains(m) || requestAnimationFrame(() => {
159
+ const y = document.activeElement;
160
+ y && i.contains(y) || R?.(e);
169
161
  });
170
162
  },
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
- ]
163
+ onFocus: U,
164
+ ...k,
165
+ children: g === "grid" ? /* @__PURE__ */ w(ee, { direction: "vertical", size: "sm", children: [
166
+ T(),
167
+ /* @__PURE__ */ t(O, { gap: "sm", children: Q.map((e) => /* @__PURE__ */ t("div", { className: $[e], children: F[e] }, e)) })
168
+ ] }) : /* @__PURE__ */ t(O, { wrap: "wrap", gap: "sm", children: P.map((e) => /* @__PURE__ */ t("div", { className: $[e], children: F[e] }, e)) })
180
169
  }
181
170
  );
182
171
  };
183
- q.required = ne;
184
- q.displayName = "DateOfBirth";
172
+ _.required = te;
173
+ _.displayName = "DateOfBirth";
185
174
  export {
186
- q as DateOfBirth,
187
- ne as dateOfBirthRequired
175
+ _ as DateOfBirth,
176
+ te as dateOfBirthRequired
188
177
  };
189
178
  //# 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'\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,I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sC,MAA4C;AAC9D,cAAMC,IAAgBD,EAAM,eACtBE,IAAOF,EAAM;AACnB,QAAIE,KAAQD,EAAc,SAASC,CAAI,KACvC,sBAAsB,MAAM;AAC1B,gBAAMC,IAAS,SAAS;AACxB,UAAIA,KAAUF,EAAc,SAASE,CAAM,KAC3CxC,IAASqC,CAAK;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,MAOI,SAAApC;AAAA,MACC,GAAGC;AAAA,MAEH,UAAA;AAAA,QAAAX,MAAe,SACd,gBAAAmC,EAACe,IAAA,EAAM,WAAU,YAAW,MAAK,MAC9B,UAAA;AAAA,UAAAnB,EAAA;AAAA,4BACAoB,GAAA,EAAK,KAAI,MACP,UAAAR,EAAW,IAAI,CAACS,MACf,gBAAAnB,EAAC,SAAmB,WAAWW,EAAYQ,CAAQ,GAChD,UAAAZ,EAASY,CAAQ,EAAA,GADVA,CAEV,CACD,EAAA,CACH;AAAA,QAAA,EAAA,CACF,sBAECD,GAAA,EAAK,MAAK,QAAO,KAAI,MACnB,UAAAV,EAAc,IAAI,CAACW,wBACjB,OAAA,EAAmB,WAAWR,EAAYQ,CAAQ,GAChD,YAASA,CAAQ,EAAA,GADVA,CAEV,CACD,EAAA,CACH;AAAA,QAGDP,uBACE,OAAA,EAAI,WAAU,2BACZ,UAAAxD,IAAS,wBAAwBA,CAAM,gBAAgB,8BAAA,CAC1D;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;AAEAM,EAAY,WAAWpB;AAEvBoB,EAAY,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\nexport const DateOfBirth: DateOfBirthComponent = ({\n value,\n defaultValue,\n onChange,\n yearSpan = 120,\n minAge,\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 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 </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","DateOfBirth","defaultValue","onChange","yearSpan","minAge","maxAge","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","day","renderYear","InputNumber","fieldMap","orderedFields","key","gridFields","fieldWidths","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,KAEwCH;AAAA,MACnD;AAAA,IAAA,EACA;AAAA,EAIA;AAEJ;AAMA,SAASI,GAAeC,GAAgBC,GAA0B;AAChE,QAAMC,IAAY,IAAI,KAAK,eAAeF,GAAQ,EAAE,OAAOC,GAAQ;AACnE,SAAOX,GAAe,IAAI,CAACO,GAAOL,OAAW;AAAA,IAC3C,OAAAK;AAAA,IACA,OAAOK,EAAU,OAAO,IAAI,KAAK,MAAMV,GAAO,CAAC,CAAC;AAAA,EAAA,EAChD;AACJ;AAEA,SAASW,GAAeC,GAAcC,GAAe;AACnD,SAAO,IAAI,KAAKD,GAAMC,GAAO,CAAC,EAAE,QAAA;AAClC;AAEO,MAAMC,IAAoC,CAAC;AAAA,EAChD,OAAAT;AAAA,EACA,cAAAU;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,YAAAC,IAAa;AAAA,EACb,WAAAC,IAAY;AAAA,EACZ,kBAAAC,IAAmB;AAAA,EACnB,gBAAAC,IAAiB;AAAA,EACjB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AnB,EAAC,SAAmB,WAAWY,EAAYO,CAAQ,GAChD,UAAAX,EAASW,CAAQ,EAAA,GADVA,CAEV,CACD,EAAA,CACH;AAAA,MAAA,EAAA,CACF,sBAECD,GAAA,EAAK,MAAK,QAAO,KAAI,MACnB,UAAAT,EAAc,IAAI,CAACU,wBACjB,OAAA,EAAmB,WAAWP,EAAYO,CAAQ,GAChD,YAASA,CAAQ,KADVA,CAEV,CACD,EAAA,CACH;AAAA,IAAA;AAAA,EAAA;AAIR;AAEA3D,EAAY,WAAWb;AAEvBa,EAAY,cAAc;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asterui",
3
- "version": "0.12.78",
3
+ "version": "0.12.79",
4
4
  "description": "React UI component library with DaisyUI",
5
5
  "homepage": "https://asterui.com",
6
6
  "repository": {