minerva-design 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/custom-elements.json +663 -0
- package/dist/angular/fesm2022/minerva-angular.mjs +1163 -34
- package/dist/angular/fesm2022/minerva-angular.mjs.map +1 -1
- package/dist/angular/types/minerva-angular.d.ts +237 -1
- package/dist/core/calendar-date.d.cts +5 -0
- package/dist/core/calendar-date.d.ts +5 -0
- package/dist/core/contracts.cjs +1 -1
- package/dist/core/contracts.cjs.map +1 -1
- package/dist/core/contracts.js +1 -1
- package/dist/core/contracts.js.map +1 -1
- package/dist/core/index.cjs +6 -6
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +671 -630
- package/dist/core/index.js.map +1 -1
- package/dist/core/styling-hooks/components/date-picker.d.cts +45 -0
- package/dist/core/styling-hooks/components/date-picker.d.ts +45 -0
- package/dist/core/styling-hooks/manifest.d.cts +44 -0
- package/dist/core/styling-hooks/manifest.d.ts +44 -0
- package/dist/core/styling-hooks.cjs +1 -1
- package/dist/core/styling-hooks.cjs.map +1 -1
- package/dist/core/styling-hooks.js +62 -0
- package/dist/core/styling-hooks.js.map +1 -1
- package/dist/native/components/Calendar/Calendar.cjs +1 -1
- package/dist/native/components/Calendar/Calendar.cjs.map +1 -1
- package/dist/native/components/Calendar/Calendar.d.cts +2 -0
- package/dist/native/components/Calendar/Calendar.d.ts +2 -0
- package/dist/native/components/Calendar/Calendar.js +115 -112
- package/dist/native/components/Calendar/Calendar.js.map +1 -1
- package/dist/native/components/Checkbox/Checkbox.cjs +1 -1
- package/dist/native/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/native/components/Checkbox/Checkbox.js +8 -8
- package/dist/native/components/Checkbox/CheckboxGroup.cjs +1 -1
- package/dist/native/components/Checkbox/CheckboxGroup.cjs.map +1 -1
- package/dist/native/components/Checkbox/CheckboxGroup.js +6 -6
- package/dist/native/components/DatePicker/DatePicker.cjs +2 -0
- package/dist/native/components/DatePicker/DatePicker.cjs.map +1 -0
- package/dist/native/components/DatePicker/DatePicker.d.cts +40 -0
- package/dist/native/components/DatePicker/DatePicker.d.ts +40 -0
- package/dist/native/components/DatePicker/DatePicker.js +110 -0
- package/dist/native/components/DatePicker/DatePicker.js.map +1 -0
- package/dist/native/components/DatePicker/index.cjs +1 -0
- package/dist/native/components/DatePicker/index.d.cts +2 -0
- package/dist/native/components/DatePicker/index.d.ts +2 -0
- package/dist/native/components/DatePicker/index.js +2 -0
- package/dist/native/components/Radio/RadioGroup.cjs +1 -1
- package/dist/native/components/Radio/RadioGroup.cjs.map +1 -1
- package/dist/native/components/Radio/RadioGroup.js +9 -9
- package/dist/native/components/Switch/Switch.cjs +1 -1
- package/dist/native/components/Switch/Switch.cjs.map +1 -1
- package/dist/native/components/Switch/Switch.js +23 -23
- package/dist/native/components/Switch/Switch.js.map +1 -1
- package/dist/native/index.cjs +1 -1
- package/dist/native/index.d.cts +1 -0
- package/dist/native/index.d.ts +1 -0
- package/dist/native/index.js +70 -68
- package/dist/native/source/components/Calendar/Calendar.tsx +14 -6
- package/dist/native/source/components/DatePicker/DatePicker.tsx +201 -0
- package/dist/native/source/components/DatePicker/index.ts +2 -0
- package/dist/native/source/index.ts +1 -0
- package/dist/native/source/manifest.ts +6 -0
- package/dist/react/components/DatePicker/DatePicker.cjs +2 -0
- package/dist/react/components/DatePicker/DatePicker.cjs.map +1 -0
- package/dist/react/components/DatePicker/DatePicker.d.cts +13 -0
- package/dist/react/components/DatePicker/DatePicker.d.ts +13 -0
- package/dist/react/components/DatePicker/DatePicker.js +315 -0
- package/dist/react/components/DatePicker/DatePicker.js.map +1 -0
- package/dist/react/components/DatePicker/datePicker.module.scss.cjs +2 -0
- package/dist/react/components/DatePicker/datePicker.module.scss.cjs.map +1 -0
- package/dist/react/components/DatePicker/datePicker.module.scss.js +23 -0
- package/dist/react/components/DatePicker/datePicker.module.scss.js.map +1 -0
- package/dist/react/components/DatePicker/index.cjs +1 -0
- package/dist/react/components/DatePicker/index.d.cts +5 -0
- package/dist/react/components/DatePicker/index.d.ts +5 -0
- package/dist/react/components/DatePicker/index.js +3 -0
- package/dist/react/components/DatePicker/types.d.cts +97 -0
- package/dist/react/components/DatePicker/types.d.ts +97 -0
- package/dist/react/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/react/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/react/components/Tooltip/Tooltip.js +5 -5
- package/dist/react/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/react/components/index.cjs +1 -1
- package/dist/react/components/index.d.cts +1 -0
- package/dist/react/components/index.d.ts +1 -0
- package/dist/react/components/index.js +3 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.js +7 -6
- package/dist/react/style.css +1 -0
- package/dist/react/styles/date-picker.css +7 -0
- package/dist/taro/date-picker.d.ts +20 -0
- package/dist/taro/index.d.ts +1 -0
- package/dist/taro/index.js +1155 -990
- package/dist/uni/DatePicker.vue +225 -0
- package/dist/uni/DatePicker.vue.d.ts +36 -0
- package/dist/uni/MonthCalendar.vue +2 -0
- package/dist/uni/MonthCalendar.vue.d.ts +2 -0
- package/dist/uni/index.d.ts +1 -0
- package/dist/uni/index.js +1 -0
- package/dist/uni/manifest.d.ts +7 -0
- package/dist/uni/manifest.js +8 -0
- package/dist/vue/components/DatePicker/DatePicker.vue.d.ts +36 -0
- package/dist/vue/components/DatePicker/DatePicker.vue.js +7 -0
- package/dist/vue/components/DatePicker/DatePicker.vue.js.map +1 -0
- package/dist/vue/components/DatePicker/DatePicker.vue_vue_type_script_setup_true_lang.js +380 -0
- package/dist/vue/components/DatePicker/DatePicker.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/vue/components/DatePicker/index.d.ts +2 -0
- package/dist/vue/components/DatePicker/index.js +2 -0
- package/dist/vue/components/DatePicker/types.d.ts +26 -0
- package/dist/vue/components/MonthCalendar/MonthCalendar.vue.d.ts +1 -1
- package/dist/vue/global.d.ts +108 -0
- package/dist/vue/groups/forms-pickers.d.ts +1 -0
- package/dist/vue/groups/forms-pickers.js +5 -2
- package/dist/vue/groups/forms-pickers.js.map +1 -1
- package/dist/vue/index.js +95 -94
- package/dist/weapp/controls.js +259 -76
- package/dist/weapp/date-picker/index.js +1 -0
- package/dist/weapp/date-picker/index.json +1 -0
- package/dist/weapp/date-picker/index.wxml +1 -0
- package/dist/weapp/date-picker/index.wxss +1 -0
- package/dist/weapp/types.d.ts +19 -0
- package/dist/web-components/cdn/minerva.js +461 -335
- package/dist/web-components/cdn/minerva.js.map +1 -1
- package/dist/web-components/components/date-picker/date-picker.d.ts +110 -0
- package/dist/web-components/components/date-picker/date-picker.js +378 -0
- package/dist/web-components/components/date-picker/date-picker.js.map +1 -0
- package/dist/web-components/elements/date-picker.d.ts +1 -0
- package/dist/web-components/elements/date-picker.js +8 -0
- package/dist/web-components/elements/date-picker.js.map +1 -0
- package/dist/web-components/html-custom-data.json +85 -0
- package/dist/web-components/index.d.ts +1 -0
- package/dist/web-components/index.js +8 -6
- package/dist/web-components/styles/DatePicker/datePicker.css.js +6 -0
- package/dist/web-components/styles/DatePicker/datePicker.css.js.map +1 -0
- package/dist/web-components/types/react.d.ts +12 -0
- package/dist/web-components/types/solid.d.ts +9 -0
- package/dist/web-components/types/svelte.d.ts +9 -0
- package/dist/web-components/types/vue.d.ts +10 -0
- package/package.json +9 -1
|
@@ -10,10 +10,10 @@ import { useOverlay as u } from "../../internal/useOverlay.js";
|
|
|
10
10
|
import { useControllable as d } from "../../internal/useControllable.js";
|
|
11
11
|
import { useMemo as f, useState as p } from "react";
|
|
12
12
|
import { Pressable as m, Text as h, View as g } from "react-native";
|
|
13
|
-
import { addDays as _, createSelectionMachine as v, dayKey as y, localDate as b, monthStart as x, sameMonth as
|
|
14
|
-
import { jsx as
|
|
13
|
+
import { addDays as _, createSelectionMachine as v, dayKey as y, localDate as b, monthStart as x, sameMonth as ee } from "../../../core/index.js";
|
|
14
|
+
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
15
15
|
//#region src/components/Calendar/Calendar.tsx
|
|
16
|
-
var
|
|
16
|
+
var te = [
|
|
17
17
|
"sun",
|
|
18
18
|
"mon",
|
|
19
19
|
"tue",
|
|
@@ -21,136 +21,136 @@ var T = [
|
|
|
21
21
|
"thu",
|
|
22
22
|
"fri",
|
|
23
23
|
"sat"
|
|
24
|
-
],
|
|
24
|
+
], w = {
|
|
25
25
|
small: "control-height-sm",
|
|
26
26
|
medium: "control-height-md",
|
|
27
27
|
large: "control-height-lg"
|
|
28
|
-
},
|
|
28
|
+
}, T = (e) => {
|
|
29
29
|
let [t, n, r] = e.split("-").map(Number);
|
|
30
30
|
return b(t, n - 1, r);
|
|
31
|
-
},
|
|
31
|
+
}, E = (e) => {
|
|
32
32
|
if (e !== void 0) return e === null ? [] : (Array.isArray(e) ? e : [e]).map(y);
|
|
33
33
|
};
|
|
34
|
-
function
|
|
34
|
+
function D(e) {
|
|
35
35
|
let t = e?.join("\0");
|
|
36
36
|
return f(() => t === void 0 ? void 0 : t === "" ? [] : t.split("\0"), [t]);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
return e.poppable ? /* @__PURE__ */
|
|
38
|
+
function O(e) {
|
|
39
|
+
return e.poppable ? /* @__PURE__ */ S(k, { ...e }) : /* @__PURE__ */ S(A, { ...e });
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
let { tokens:
|
|
41
|
+
function k({ open: l, defaultOpen: f = !1, onOpenChange: p, title: _, confirmText: v, onConfirm: y, onChange: b, value: x, defaultValue: ee = null, type: te = "single", ...w }) {
|
|
42
|
+
let { tokens: T, fonts: E } = t(), { t: D } = e(), O = u({
|
|
43
43
|
open: l,
|
|
44
44
|
defaultOpen: f,
|
|
45
45
|
onOpenChange: p
|
|
46
|
-
}), [
|
|
47
|
-
if (
|
|
48
|
-
let
|
|
49
|
-
return /* @__PURE__ */
|
|
46
|
+
}), [k, ne] = d(x, ee, b);
|
|
47
|
+
if (O.state.phase === "closed") return null;
|
|
48
|
+
let re = Array.isArray(k) ? k.length > 0 : k !== null, j = _ ?? D("calendar.title"), M = typeof j == "string" || typeof j == "number" ? String(j) : void 0;
|
|
49
|
+
return /* @__PURE__ */ C(c, {
|
|
50
50
|
component: "calendar",
|
|
51
|
-
phase:
|
|
52
|
-
onAnimationEnd:
|
|
53
|
-
onRequestClose:
|
|
51
|
+
phase: O.state.phase,
|
|
52
|
+
onAnimationEnd: O.onAnimationEnd,
|
|
53
|
+
onRequestClose: O.close,
|
|
54
54
|
placement: "bottom",
|
|
55
55
|
panelProps: {
|
|
56
56
|
role: "dialog",
|
|
57
|
-
accessibilityLabel:
|
|
57
|
+
accessibilityLabel: M
|
|
58
58
|
},
|
|
59
59
|
children: [
|
|
60
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ C(g, {
|
|
61
61
|
style: {
|
|
62
62
|
flexDirection: "row",
|
|
63
63
|
alignItems: "center",
|
|
64
64
|
justifyContent: "center",
|
|
65
|
-
paddingVertical:
|
|
66
|
-
paddingHorizontal:
|
|
65
|
+
paddingVertical: T.space[4],
|
|
66
|
+
paddingHorizontal: T.space[12]
|
|
67
67
|
},
|
|
68
68
|
...n("calendar", "header"),
|
|
69
|
-
children: [
|
|
69
|
+
children: [M === void 0 ? j : /* @__PURE__ */ S(h, {
|
|
70
70
|
accessibilityRole: "header",
|
|
71
|
-
style: [i(
|
|
71
|
+
style: [i(T, "lg", E.sans), { fontWeight: a(T, "semibold") }],
|
|
72
72
|
...n("calendar", "title"),
|
|
73
|
-
children:
|
|
74
|
-
}), /* @__PURE__ */
|
|
73
|
+
children: M
|
|
74
|
+
}), /* @__PURE__ */ S(m, {
|
|
75
75
|
accessibilityRole: "button",
|
|
76
|
-
accessibilityLabel:
|
|
77
|
-
hitSlop: r(
|
|
78
|
-
onPress: () =>
|
|
76
|
+
accessibilityLabel: D("modal.close"),
|
|
77
|
+
hitSlop: r(T, 28, 28),
|
|
78
|
+
onPress: () => O.close("close-button"),
|
|
79
79
|
style: ({ pressed: e }) => ({
|
|
80
80
|
position: "absolute",
|
|
81
|
-
right:
|
|
81
|
+
right: T.space[4],
|
|
82
82
|
width: 28,
|
|
83
83
|
height: 28,
|
|
84
84
|
borderRadius: 14,
|
|
85
85
|
alignItems: "center",
|
|
86
86
|
justifyContent: "center",
|
|
87
|
-
backgroundColor: e ?
|
|
87
|
+
backgroundColor: e ? T.colors["surface-muted-color"] : "transparent"
|
|
88
88
|
}),
|
|
89
89
|
...n("calendar", "close"),
|
|
90
|
-
children: /* @__PURE__ */
|
|
90
|
+
children: /* @__PURE__ */ S(s, {
|
|
91
91
|
name: "close",
|
|
92
92
|
size: 14,
|
|
93
|
-
color:
|
|
93
|
+
color: T.colors["text-muted-color"]
|
|
94
94
|
})
|
|
95
95
|
})]
|
|
96
96
|
}),
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
...
|
|
99
|
-
type:
|
|
100
|
-
value:
|
|
101
|
-
onChange:
|
|
102
|
-
style: [{ paddingHorizontal:
|
|
97
|
+
/* @__PURE__ */ S(A, {
|
|
98
|
+
...w,
|
|
99
|
+
type: te,
|
|
100
|
+
value: k,
|
|
101
|
+
onChange: ne,
|
|
102
|
+
style: [{ paddingHorizontal: T.space[2] }, w.style]
|
|
103
103
|
}),
|
|
104
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ S(g, {
|
|
105
105
|
style: {
|
|
106
|
-
padding:
|
|
107
|
-
paddingTop:
|
|
106
|
+
padding: T.space[4],
|
|
107
|
+
paddingTop: T.space[2]
|
|
108
108
|
},
|
|
109
109
|
...n("calendar", "footer"),
|
|
110
|
-
children: /* @__PURE__ */
|
|
110
|
+
children: /* @__PURE__ */ S(o, {
|
|
111
111
|
fullWidth: !0,
|
|
112
|
-
disabled: !
|
|
112
|
+
disabled: !re,
|
|
113
113
|
onPress: () => {
|
|
114
|
-
y?.(
|
|
114
|
+
y?.(k), O.close("confirm");
|
|
115
115
|
},
|
|
116
|
-
children: v ??
|
|
116
|
+
children: v ?? D("calendar.confirm")
|
|
117
117
|
})
|
|
118
118
|
})
|
|
119
119
|
]
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
let { tokens: L, fonts:
|
|
122
|
+
function A({ type: o = "single", value: c, defaultValue: u = null, onChange: O, onSelect: k, month: A, defaultMonth: ne, onMonthChange: re, minDate: j, maxDate: M, disabledDate: ie, firstDayOfWeek: N = 0, locale: P, size: F = "medium", disabled: I = !1, previousMonthLabel: ae, nextMonthLabel: oe, style: se, accessibilityLabel: ce, poppable: le, open: ue, defaultOpen: de, onOpenChange: fe, title: pe, confirmText: me, onConfirm: he, ...ge }) {
|
|
123
|
+
let { tokens: L, fonts: _e } = t(), { t: R, language: z } = e(), [B] = p(() => {
|
|
124
124
|
let e = /* @__PURE__ */ new Date();
|
|
125
125
|
return b(e.getFullYear(), e.getMonth(), e.getDate());
|
|
126
|
-
}),
|
|
126
|
+
}), ve = y(B), V = j ? y(j) : void 0, H = M ? y(M) : void 0, U = (e) => {
|
|
127
127
|
let t = y(e);
|
|
128
|
-
return V !== void 0 && t < V ||
|
|
129
|
-
},
|
|
130
|
-
let t = e.map(
|
|
128
|
+
return V !== void 0 && t < V || H !== void 0 && t > H || !!ie?.(e);
|
|
129
|
+
}, ye = (e) => {
|
|
130
|
+
let t = e.map(T);
|
|
131
131
|
return o === "single" ? t[0] ?? null : o === "range" ? t.length === 2 ? [t[0], t[1]] : null : t;
|
|
132
|
-
},
|
|
132
|
+
}, be = D(E(c)), [xe, W] = l(v, {
|
|
133
133
|
mode: o === "single" ? "single" : "multiple",
|
|
134
|
-
value:
|
|
135
|
-
defaultValue:
|
|
136
|
-
isDisabled: (e) =>
|
|
134
|
+
value: be,
|
|
135
|
+
defaultValue: E(u) ?? [],
|
|
136
|
+
isDisabled: (e) => U(T(e)),
|
|
137
137
|
max: o === "range" ? 2 : void 0,
|
|
138
|
-
onValueChange: (e) =>
|
|
139
|
-
}), [
|
|
138
|
+
onValueChange: (e) => O?.(ye(e))
|
|
139
|
+
}), [G, Se] = p(null), K = xe.value, q = o === "range" ? G === null ? K.length === 2 ? [K[0], K[1]] : null : [G, G] : null, Ce = K[0] ? T(K[0]) : void 0, [we, Te] = d(A, ne ?? Ce ?? (j && j > B ? j : B), re), J = x(we), Ee = !I && (!j || J > x(j)), De = !I && (!M || x(J, 1) <= M), Oe = (e) => {
|
|
140
140
|
let t = y(e);
|
|
141
|
-
|
|
141
|
+
k?.(e), o === "single" ? W({
|
|
142
142
|
type: "SELECT",
|
|
143
143
|
value: t
|
|
144
|
-
}) : o === "multiple" ?
|
|
144
|
+
}) : o === "multiple" ? W({
|
|
145
145
|
type: "TOGGLE",
|
|
146
146
|
value: t
|
|
147
|
-
}) :
|
|
147
|
+
}) : G === null || t < G ? Se(t) : (Se(null), W({
|
|
148
148
|
type: "SET",
|
|
149
|
-
value: [
|
|
150
|
-
})),
|
|
151
|
-
},
|
|
149
|
+
value: [G, t]
|
|
150
|
+
})), ee(e, J) || Te(x(e));
|
|
151
|
+
}, ke = f(() => {
|
|
152
152
|
try {
|
|
153
|
-
let e = new Intl.DateTimeFormat(z, {
|
|
153
|
+
let e = new Intl.DateTimeFormat(P ?? z, {
|
|
154
154
|
weekday: "long",
|
|
155
155
|
year: "numeric",
|
|
156
156
|
month: "long",
|
|
@@ -160,19 +160,19 @@ function M({ type: o = "single", value: c, defaultValue: u = null, onChange: A,
|
|
|
160
160
|
} catch {
|
|
161
161
|
return (e) => e.toDateString();
|
|
162
162
|
}
|
|
163
|
-
}, [z]),
|
|
164
|
-
for (;
|
|
165
|
-
let
|
|
166
|
-
for (let e = 0; e <
|
|
167
|
-
let
|
|
168
|
-
let t = e < 0 ?
|
|
169
|
-
return /* @__PURE__ */
|
|
163
|
+
}, [z, P]), Ae = (J.getDay() - N + 7) % 7, je = b(J.getFullYear(), J.getMonth() + 1, 0).getDate(), Y = [...Array.from({ length: Ae }, () => null), ...Array.from({ length: je }, (e, t) => _(J, t))];
|
|
164
|
+
for (; Y.length % 7;) Y.push(null);
|
|
165
|
+
let Me = [];
|
|
166
|
+
for (let e = 0; e < Y.length; e += 7) Me.push(Y.slice(e, e + 7));
|
|
167
|
+
let X = L.sizes[w[F]], Z = Math.min(X - L.space[1], 44), Q = L.colors["primary-color"], $ = _e.sans, Ne = (e) => {
|
|
168
|
+
let t = e < 0 ? Ee : De, i = e < 0 ? ae ?? R("monthCalendar.previousMonth") : oe ?? R("monthCalendar.nextMonth");
|
|
169
|
+
return /* @__PURE__ */ S(m, {
|
|
170
170
|
accessibilityRole: "button",
|
|
171
171
|
accessibilityLabel: i,
|
|
172
172
|
accessibilityState: { disabled: !t },
|
|
173
173
|
disabled: !t,
|
|
174
174
|
hitSlop: r(L, 32, 32),
|
|
175
|
-
onPress: () =>
|
|
175
|
+
onPress: () => Te(x(J, e)),
|
|
176
176
|
style: ({ pressed: e }) => ({
|
|
177
177
|
width: 32,
|
|
178
178
|
height: 32,
|
|
@@ -183,19 +183,19 @@ function M({ type: o = "single", value: c, defaultValue: u = null, onChange: A,
|
|
|
183
183
|
backgroundColor: e ? L.colors["surface-muted-color"] : "transparent"
|
|
184
184
|
}),
|
|
185
185
|
...n("calendar", e < 0 ? "prev" : "next"),
|
|
186
|
-
children: /* @__PURE__ */
|
|
186
|
+
children: /* @__PURE__ */ S(s, {
|
|
187
187
|
name: e < 0 ? "chevron-left" : "chevron-right",
|
|
188
188
|
size: 16,
|
|
189
189
|
color: L.colors["text-secondary-color"]
|
|
190
190
|
})
|
|
191
191
|
});
|
|
192
|
-
},
|
|
193
|
-
let t = y(e), r = I ||
|
|
192
|
+
}, Pe = (e) => {
|
|
193
|
+
let t = y(e), r = I || U(e), o = t === ve, s = q?.[0] === t, c = q?.[1] === t && G === null, l = !!q && t > q[0] && t < q[1], u = q ? s || c : K.includes(t), d = u || l, f = q?.[0] === q?.[1], p = [
|
|
194
194
|
o ? R("monthCalendar.today") : void 0,
|
|
195
195
|
s ? R("calendar.rangeStart") : void 0,
|
|
196
196
|
c ? R("calendar.rangeEnd") : void 0
|
|
197
|
-
].filter(Boolean), _ = [
|
|
198
|
-
return /* @__PURE__ */
|
|
197
|
+
].filter(Boolean), _ = [ke(e), ...p].join(", "), v = r ? L.colors["text-disabled-color"] : u ? L.colors["text-inverse-color"] : l ? L.colors["primary-color-text"] : o ? Q : L.colors["text-color"], b = L.colors["primary-color-subtle"];
|
|
198
|
+
return /* @__PURE__ */ C(m, {
|
|
199
199
|
accessibilityRole: "button",
|
|
200
200
|
accessibilityLabel: _,
|
|
201
201
|
accessibilityState: {
|
|
@@ -204,10 +204,10 @@ function M({ type: o = "single", value: c, defaultValue: u = null, onChange: A,
|
|
|
204
204
|
},
|
|
205
205
|
"aria-selected": d,
|
|
206
206
|
disabled: r,
|
|
207
|
-
onPress: () =>
|
|
207
|
+
onPress: () => Oe(e),
|
|
208
208
|
style: {
|
|
209
209
|
flex: 1,
|
|
210
|
-
height:
|
|
210
|
+
height: X,
|
|
211
211
|
alignItems: "center",
|
|
212
212
|
justifyContent: "center",
|
|
213
213
|
backgroundColor: l ? b : "transparent"
|
|
@@ -216,60 +216,60 @@ function M({ type: o = "single", value: c, defaultValue: u = null, onChange: A,
|
|
|
216
216
|
selected: d,
|
|
217
217
|
today: o,
|
|
218
218
|
disabled: r,
|
|
219
|
-
"range-start": s && !!
|
|
219
|
+
"range-start": s && !!q,
|
|
220
220
|
"range-end": c,
|
|
221
221
|
"range-middle": l
|
|
222
222
|
}),
|
|
223
|
-
children: [
|
|
223
|
+
children: [q && !f && (s || c) && /* @__PURE__ */ S(g, { style: {
|
|
224
224
|
position: "absolute",
|
|
225
225
|
top: 0,
|
|
226
226
|
bottom: 0,
|
|
227
227
|
left: s ? "50%" : 0,
|
|
228
228
|
right: c ? "50%" : 0,
|
|
229
229
|
backgroundColor: b
|
|
230
|
-
} }), /* @__PURE__ */
|
|
230
|
+
} }), /* @__PURE__ */ C(g, {
|
|
231
231
|
style: {
|
|
232
|
-
width:
|
|
233
|
-
height:
|
|
234
|
-
borderRadius:
|
|
232
|
+
width: Z,
|
|
233
|
+
height: Z,
|
|
234
|
+
borderRadius: Z / 2,
|
|
235
235
|
alignItems: "center",
|
|
236
236
|
justifyContent: "center",
|
|
237
|
-
backgroundColor: u && !r ?
|
|
237
|
+
backgroundColor: u && !r ? Q : "transparent",
|
|
238
238
|
borderWidth: o && !u ? 1 : 0,
|
|
239
|
-
borderColor:
|
|
239
|
+
borderColor: Q
|
|
240
240
|
},
|
|
241
|
-
children: [/* @__PURE__ */
|
|
241
|
+
children: [/* @__PURE__ */ S(h, {
|
|
242
242
|
allowFontScaling: !1,
|
|
243
|
-
style: [i(L, F === "small" ? "sm" : "md",
|
|
243
|
+
style: [i(L, F === "small" ? "sm" : "md", $), {
|
|
244
244
|
color: v,
|
|
245
245
|
fontWeight: a(L, u || o ? "semibold" : "regular")
|
|
246
246
|
}],
|
|
247
247
|
children: e.getDate()
|
|
248
|
-
}), (s || c) && !f && F !== "small" && /* @__PURE__ */
|
|
248
|
+
}), (s || c) && !f && F !== "small" && /* @__PURE__ */ S(h, {
|
|
249
249
|
allowFontScaling: !1,
|
|
250
250
|
style: {
|
|
251
251
|
position: "absolute",
|
|
252
252
|
bottom: -L.space["0-5"],
|
|
253
253
|
fontSize: L.fontSize.xs - 3,
|
|
254
254
|
color: L.colors["text-inverse-color"],
|
|
255
|
-
|
|
255
|
+
...$ ? { fontFamily: $ } : null
|
|
256
256
|
},
|
|
257
257
|
children: R(s ? "calendar.rangeStart" : "calendar.rangeEnd")
|
|
258
258
|
})]
|
|
259
259
|
})]
|
|
260
260
|
}, t);
|
|
261
261
|
};
|
|
262
|
-
return /* @__PURE__ */
|
|
262
|
+
return /* @__PURE__ */ C(g, {
|
|
263
263
|
role: "group",
|
|
264
|
-
accessibilityLabel:
|
|
264
|
+
accessibilityLabel: ce ?? R("monthCalendar.label"),
|
|
265
265
|
...n("calendar", "root", {
|
|
266
266
|
type: o,
|
|
267
267
|
disabled: I
|
|
268
268
|
}),
|
|
269
|
-
...
|
|
270
|
-
style: [{ backgroundColor: L.colors["surface-color"] },
|
|
269
|
+
...ge,
|
|
270
|
+
style: [{ backgroundColor: L.colors["surface-color"] }, se],
|
|
271
271
|
children: [
|
|
272
|
-
/* @__PURE__ */
|
|
272
|
+
/* @__PURE__ */ C(g, {
|
|
273
273
|
style: {
|
|
274
274
|
flexDirection: "row",
|
|
275
275
|
alignItems: "center",
|
|
@@ -278,21 +278,24 @@ function M({ type: o = "single", value: c, defaultValue: u = null, onChange: A,
|
|
|
278
278
|
paddingVertical: L.space[2]
|
|
279
279
|
},
|
|
280
280
|
children: [
|
|
281
|
-
|
|
282
|
-
/* @__PURE__ */
|
|
281
|
+
Ne(-1),
|
|
282
|
+
/* @__PURE__ */ S(h, {
|
|
283
283
|
accessibilityRole: "header",
|
|
284
284
|
accessibilityLiveRegion: "polite",
|
|
285
|
-
style: [i(L, "lg",
|
|
285
|
+
style: [i(L, "lg", $), { fontWeight: a(L, "semibold") }],
|
|
286
286
|
...n("calendar", "month-title"),
|
|
287
|
-
children:
|
|
288
|
-
year:
|
|
289
|
-
month:
|
|
287
|
+
children: P ? new Intl.DateTimeFormat(P, {
|
|
288
|
+
year: "numeric",
|
|
289
|
+
month: "long"
|
|
290
|
+
}).format(J) : R("calendar.monthTitle", {
|
|
291
|
+
year: J.getFullYear(),
|
|
292
|
+
month: J.getMonth() + 1
|
|
290
293
|
})
|
|
291
294
|
}),
|
|
292
|
-
|
|
295
|
+
Ne(1)
|
|
293
296
|
]
|
|
294
297
|
}),
|
|
295
|
-
/* @__PURE__ */
|
|
298
|
+
/* @__PURE__ */ S(g, {
|
|
296
299
|
importantForAccessibility: "no-hide-descendants",
|
|
297
300
|
accessibilityElementsHidden: !0,
|
|
298
301
|
style: {
|
|
@@ -301,9 +304,9 @@ function M({ type: o = "single", value: c, defaultValue: u = null, onChange: A,
|
|
|
301
304
|
},
|
|
302
305
|
...n("calendar", "weekdays"),
|
|
303
306
|
children: Array.from({ length: 7 }, (e, t) => {
|
|
304
|
-
let n =
|
|
305
|
-
return /* @__PURE__ */
|
|
306
|
-
style: [i(L, "xs",
|
|
307
|
+
let n = te[(N + t) % 7];
|
|
308
|
+
return /* @__PURE__ */ S(h, {
|
|
309
|
+
style: [i(L, "xs", $), {
|
|
307
310
|
flex: 1,
|
|
308
311
|
textAlign: "center",
|
|
309
312
|
color: L.colors["text-muted-color"]
|
|
@@ -312,21 +315,21 @@ function M({ type: o = "single", value: c, defaultValue: u = null, onChange: A,
|
|
|
312
315
|
}, n);
|
|
313
316
|
})
|
|
314
317
|
}),
|
|
315
|
-
|
|
318
|
+
Me.map((e, t) => /* @__PURE__ */ S(g, {
|
|
316
319
|
style: {
|
|
317
320
|
flexDirection: "row",
|
|
318
321
|
marginBottom: L.space["0-5"]
|
|
319
322
|
},
|
|
320
323
|
...n("calendar", "week"),
|
|
321
|
-
children: e.map((e, t) => e ?
|
|
324
|
+
children: e.map((e, t) => e ? Pe(e) : /* @__PURE__ */ S(g, { style: {
|
|
322
325
|
flex: 1,
|
|
323
|
-
height:
|
|
326
|
+
height: X
|
|
324
327
|
} }, `empty-${t}`))
|
|
325
328
|
}, t))
|
|
326
329
|
]
|
|
327
330
|
});
|
|
328
331
|
}
|
|
329
332
|
//#endregion
|
|
330
|
-
export {
|
|
333
|
+
export { O as Calendar };
|
|
331
334
|
|
|
332
335
|
//# sourceMappingURL=Calendar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","names":["WEEKDAYS","CELL_HEIGHT","parseKey","y","m","d","key","localDate","keysOf","value","dayKey","useStableKeys","joined","keys","useMemo","Calendar","props","PoppableCalendar","CalendarView","rest","t","useTheme","translate","useI18n","overlay","useOverlay","current","setCurrent","useControllable","defaultValue","onChange","ready","titleNode","title","titleText","Overlay","View","part","Text","textStyle","fonts","weight","Pressable","hitSlopFor","pressed","Icon","Button","onConfirm","confirmText","_poppable","_open","_defaultOpen","_onOpenChange","_title","_confirmText","_onConfirm","today","useState","now","todayKey","minKey","minDate","maxKey","maxDate","isDisabled","date","disabledDate","toValue","dates","type","controlledKeys","state","send","useMachine","createSelectionMachine","pendingStart","setPendingStart","selected","rangeKeys","firstSelected","shownMonth","setShownMonth","month","defaultMonth","onMonthChange","first","monthStart","canPrev","disabled","canNext","press","onSelect","sameMonth","fullDate","format","language","lead","firstDayOfWeek","daysInMonth","cells","addDays","i","weeks","cellHeight","size","dot","primary","sans","navButton","enabled","direction","label","previousMonthLabel","nextMonthLabel","renderDay","off","isToday","start","end","middle","filled","isSelected","singleDayRange","suffixes","textColor","band","accessibilityLabel","style","name","week","col","row"],"sources":["../../../../../native/src/components/Calendar/Calendar.tsx"],"sourcesContent":["import { useMemo, useState, type ReactNode } from \"react\";\nimport {\n Pressable,\n Text,\n View,\n type StyleProp,\n type ViewProps,\n type ViewStyle,\n} from \"react-native\";\nimport {\n addDays,\n createSelectionMachine,\n dayKey,\n localDate,\n monthStart,\n sameMonth,\n} from \"@minerva/core\";\nimport { useI18n, useTheme } from \"../../theme/MinervaProvider\";\nimport { Icon } from \"../../internal/Icon\";\nimport { Overlay, type OverlayCloseReason } from \"../../internal/Overlay\";\nimport { part } from \"../../internal/parts\";\nimport { hitSlopFor, textStyle, weight } from \"../../internal/styles\";\nimport { useControllable } from \"../../internal/useControllable\";\nimport { useMachine } from \"../../internal/useMachine\";\nimport { useOverlay } from \"../../internal/useOverlay\";\nimport { Button } from \"../Button\";\n\n/** Selection type of `Calendar` */\nexport type CalendarType = \"single\" | \"multiple\" | \"range\";\n\n/**\n * Value of `Calendar`: a day (`single`, `null`: none), days (`multiple`) or\n * a `[start, end]` range (`range`); every date is local midnight\n */\nexport type CalendarValue = Date | Date[] | [Date, Date] | null;\n\n/** Why a poppable calendar closed */\nexport type CalendarCloseReason = OverlayCloseReason;\n\nexport interface CalendarProps extends Omit<ViewProps, \"style\" | \"children\"> {\n /**\n * Selection type: one day, several days, or a range\n * @default \"single\"\n */\n type?: CalendarType;\n /**\n * Selected day(s) (controlled; pair with `onChange`): a `Date` (`single`),\n * `Date[]` (`multiple`) or `[start, end]` (`range`)\n */\n value?: CalendarValue;\n /** Initially selected day(s) (uncontrolled) @default null */\n defaultValue?: CalendarValue;\n /**\n * Called with the new selection (a range once both ends are picked)\n */\n onChange?: (value: CalendarValue) => void;\n /** Called with every pressed day */\n onSelect?: (date: Date) => void;\n /** Displayed month (controlled; any day of the month; pair with `onMonthChange`) */\n month?: Date;\n /**\n * Initially displayed month (uncontrolled)\n * @default the month of the first selected day, else of today\n */\n defaultMonth?: Date;\n /** Called with the first day of the month navigated to */\n onMonthChange?: (month: Date) => void;\n /** Earliest selectable day (earlier days are disabled) */\n minDate?: Date;\n /** Latest selectable day (later days are disabled) */\n maxDate?: Date;\n /** Extra disabled days */\n disabledDate?: (date: Date) => boolean;\n /**\n * First column of the week (0: Sunday ... 6: Saturday)\n * @default 0\n */\n firstDayOfWeek?: number;\n /**\n * Cell density: compact (\"small\"), default (\"medium\") or comfortable\n * (\"large\")\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n /**\n * Blocks navigation and selection\n * @default false\n */\n disabled?: boolean;\n /** Label of the previous-month button @default the \"monthCalendar.previousMonth\" message */\n previousMonthLabel?: string;\n /** Label of the next-month button @default the \"monthCalendar.nextMonth\" message */\n nextMonthLabel?: string;\n /**\n * Renders the calendar in a bottom sheet with a title and a confirm\n * button (`open` / `defaultOpen` / `onOpenChange`)\n * @default false\n */\n poppable?: boolean;\n /** Controlled open state of the poppable sheet */\n open?: boolean;\n /**\n * Initial open state of the poppable sheet while uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /** Called with the requested open state of the sheet and the close reason */\n onOpenChange?: (open: boolean, reason?: CalendarCloseReason) => void;\n /** Title of the poppable sheet @default the \"calendar.title\" message */\n title?: ReactNode;\n /** Text of the confirm button @default the \"calendar.confirm\" message */\n confirmText?: ReactNode;\n /** Called by the confirm button of the poppable sheet with the selection */\n onConfirm?: (value: CalendarValue) => void;\n /** Style of the calendar */\n style?: StyleProp<ViewStyle>;\n}\n\nconst WEEKDAYS = [\"sun\", \"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\"] as const;\nconst CELL_HEIGHT = {\n small: \"control-height-sm\",\n medium: \"control-height-md\",\n large: \"control-height-lg\",\n} as const;\n\nconst parseKey = (key: string) => {\n const [y, m, d] = key.split(\"-\").map(Number);\n return localDate(y, m - 1, d);\n};\n\n/** The selected day keys of a value */\nconst keysOf = (value: CalendarValue | undefined): string[] | undefined => {\n if (value === undefined) return undefined;\n if (value === null) return [];\n return (Array.isArray(value) ? value : [value]).map(dayKey);\n};\n\n/** The same array while its items are unchanged (controlled values) */\nfunction useStableKeys(keys: readonly string[] | undefined) {\n const joined = keys?.join(\"\\u0000\");\n return useMemo(\n () =>\n joined === undefined\n ? undefined\n : joined === \"\"\n ? []\n : joined.split(\"\\u0000\"),\n [joined],\n );\n}\n\n/**\n * A month calendar for picking a day, several days or a range: weekday\n * header, month navigation, min / max dates, today ring, selected fills\n * and range tint. Inline, or in a bottom sheet with a confirm button\n * (`poppable`). Single and multiple selections run on the selection\n * machine of @minerva/core.\n */\nexport function Calendar(props: CalendarProps) {\n if (!props.poppable) return <CalendarView {...props} />;\n return <PoppableCalendar {...props} />;\n}\n\nfunction PoppableCalendar({\n open,\n defaultOpen = false,\n onOpenChange,\n title,\n confirmText,\n onConfirm,\n onChange,\n value,\n defaultValue = null,\n type = \"single\",\n ...rest\n}: CalendarProps) {\n const { tokens: t, fonts } = useTheme();\n const { t: translate } = useI18n();\n const overlay = useOverlay({ open, defaultOpen, onOpenChange });\n // the sheet keeps the selection to confirm\n const [current, setCurrent] = useControllable<CalendarValue>(\n value,\n defaultValue,\n onChange,\n );\n if (overlay.state.phase === \"closed\") return null;\n const ready = Array.isArray(current) ? current.length > 0 : current !== null;\n const titleNode = title ?? translate(\"calendar.title\");\n const titleText =\n typeof titleNode === \"string\" || typeof titleNode === \"number\"\n ? String(titleNode)\n : undefined;\n const closeSize = 28;\n\n return (\n <Overlay\n component=\"calendar\"\n phase={overlay.state.phase}\n onAnimationEnd={overlay.onAnimationEnd}\n onRequestClose={overlay.close}\n placement=\"bottom\"\n panelProps={{ role: \"dialog\", accessibilityLabel: titleText }}\n >\n <View\n style={{\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"center\",\n paddingVertical: t.space[\"4\"],\n paddingHorizontal: t.space[\"12\"],\n }}\n {...part(\"calendar\", \"header\")}\n >\n {titleText !== undefined ? (\n <Text\n accessibilityRole=\"header\"\n style={[\n textStyle(t, \"lg\", fonts.sans),\n { fontWeight: weight(t, \"semibold\") },\n ]}\n {...part(\"calendar\", \"title\")}\n >\n {titleText}\n </Text>\n ) : (\n titleNode\n )}\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={translate(\"modal.close\")}\n hitSlop={hitSlopFor(t, closeSize, closeSize)}\n onPress={() => overlay.close(\"close-button\")}\n style={({ pressed }) => ({\n position: \"absolute\",\n right: t.space[\"4\"],\n width: closeSize,\n height: closeSize,\n borderRadius: closeSize / 2,\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: pressed\n ? t.colors[\"surface-muted-color\"]\n : \"transparent\",\n })}\n {...part(\"calendar\", \"close\")}\n >\n <Icon name=\"close\" size={14} color={t.colors[\"text-muted-color\"]} />\n </Pressable>\n </View>\n <CalendarView\n {...rest}\n type={type}\n value={current}\n onChange={setCurrent}\n style={[{ paddingHorizontal: t.space[\"2\"] }, rest.style]}\n />\n <View\n style={{ padding: t.space[\"4\"], paddingTop: t.space[\"2\"] }}\n {...part(\"calendar\", \"footer\")}\n >\n <Button\n fullWidth\n disabled={!ready}\n onPress={() => {\n onConfirm?.(current);\n overlay.close(\"confirm\");\n }}\n >\n {confirmText ?? translate(\"calendar.confirm\")}\n </Button>\n </View>\n </Overlay>\n );\n}\n\nfunction CalendarView({\n type = \"single\",\n value,\n defaultValue = null,\n onChange,\n onSelect,\n month,\n defaultMonth,\n onMonthChange,\n minDate,\n maxDate,\n disabledDate,\n firstDayOfWeek = 0,\n size = \"medium\",\n disabled = false,\n previousMonthLabel,\n nextMonthLabel,\n style,\n accessibilityLabel,\n // poppable-only props, unused inline\n poppable: _poppable,\n open: _open,\n defaultOpen: _defaultOpen,\n onOpenChange: _onOpenChange,\n title: _title,\n confirmText: _confirmText,\n onConfirm: _onConfirm,\n ...rest\n}: CalendarProps) {\n const { tokens: t, fonts } = useTheme();\n const { t: translate, language } = useI18n();\n const [today] = useState(() => {\n const now = new Date();\n return localDate(now.getFullYear(), now.getMonth(), now.getDate());\n });\n const todayKey = dayKey(today);\n const minKey = minDate ? dayKey(minDate) : undefined;\n const maxKey = maxDate ? dayKey(maxDate) : undefined;\n const isDisabled = (date: Date) => {\n const key = dayKey(date);\n return (\n (minKey !== undefined && key < minKey) ||\n (maxKey !== undefined && key > maxKey) ||\n !!disabledDate?.(date)\n );\n };\n\n const toValue = (keys: readonly string[]): CalendarValue => {\n const dates = keys.map(parseKey);\n if (type === \"single\") return dates[0] ?? null;\n if (type === \"range\") {\n return dates.length === 2 ? [dates[0], dates[1]] : null;\n }\n return dates;\n };\n const controlledKeys = useStableKeys(keysOf(value));\n const [state, send] = useMachine(createSelectionMachine<string>, {\n mode: type === \"single\" ? (\"single\" as const) : (\"multiple\" as const),\n value: controlledKeys,\n defaultValue: keysOf(defaultValue) ?? [],\n isDisabled: (key: string) => isDisabled(parseKey(key)),\n max: type === \"range\" ? 2 : undefined,\n onValueChange: (keys: string[]) => onChange?.(toValue(keys)),\n });\n // range: the first end picked, waiting for the second\n const [pendingStart, setPendingStart] = useState<string | null>(null);\n\n const selected = state.value;\n const rangeKeys: [string, string] | null =\n type === \"range\"\n ? pendingStart !== null\n ? [pendingStart, pendingStart]\n : selected.length === 2\n ? [selected[0], selected[1]]\n : null\n : null;\n\n const firstSelected = selected[0] ? parseKey(selected[0]) : undefined;\n const [shownMonth, setShownMonth] = useControllable<Date>(\n month,\n defaultMonth ??\n firstSelected ??\n (minDate && minDate > today ? minDate : today),\n onMonthChange,\n );\n const first = monthStart(shownMonth);\n const canPrev = !disabled && (!minDate || first > monthStart(minDate));\n const canNext = !disabled && (!maxDate || monthStart(first, 1) <= maxDate);\n\n const press = (date: Date) => {\n const key = dayKey(date);\n onSelect?.(date);\n if (type === \"single\") {\n send({ type: \"SELECT\", value: key });\n } else if (type === \"multiple\") {\n send({ type: \"TOGGLE\", value: key });\n } else if (pendingStart === null || key < pendingStart) {\n setPendingStart(key);\n } else {\n setPendingStart(null);\n send({ type: \"SET\", value: [pendingStart, key] });\n }\n if (!sameMonth(date, first)) setShownMonth(monthStart(date));\n };\n\n const fullDate = useMemo(() => {\n try {\n const format = new Intl.DateTimeFormat(language, {\n weekday: \"long\",\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n });\n return (date: Date) => format.format(date);\n } catch {\n return (date: Date) => date.toDateString();\n }\n }, [language]);\n\n const lead = (first.getDay() - firstDayOfWeek + 7) % 7;\n const daysInMonth = localDate(\n first.getFullYear(),\n first.getMonth() + 1,\n 0,\n ).getDate();\n const cells: (Date | null)[] = [\n ...Array.from({ length: lead }, () => null),\n ...Array.from({ length: daysInMonth }, (_, i) => addDays(first, i)),\n ];\n while (cells.length % 7) cells.push(null);\n const weeks: (Date | null)[][] = [];\n for (let i = 0; i < cells.length; i += 7) weeks.push(cells.slice(i, i + 7));\n\n const cellHeight = t.sizes[CELL_HEIGHT[size]];\n const dot = Math.min(cellHeight - t.space[\"1\"], 44);\n const primary = t.colors[\"primary-color\"];\n const sans = fonts.sans;\n const navSize = 32;\n\n const navButton = (direction: -1 | 1) => {\n const enabled = direction < 0 ? canPrev : canNext;\n const label =\n direction < 0\n ? (previousMonthLabel ?? translate(\"monthCalendar.previousMonth\"))\n : (nextMonthLabel ?? translate(\"monthCalendar.nextMonth\"));\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ disabled: !enabled }}\n disabled={!enabled}\n hitSlop={hitSlopFor(t, navSize, navSize)}\n onPress={() => setShownMonth(monthStart(first, direction))}\n style={({ pressed }) => ({\n width: navSize,\n height: navSize,\n borderRadius: navSize / 2,\n alignItems: \"center\",\n justifyContent: \"center\",\n opacity: enabled ? 1 : 0.35,\n backgroundColor: pressed\n ? t.colors[\"surface-muted-color\"]\n : \"transparent\",\n })}\n {...part(\"calendar\", direction < 0 ? \"prev\" : \"next\")}\n >\n <Icon\n name={direction < 0 ? \"chevron-left\" : \"chevron-right\"}\n size={16}\n color={t.colors[\"text-secondary-color\"]}\n />\n </Pressable>\n );\n };\n\n const renderDay = (date: Date) => {\n const key = dayKey(date);\n const off = disabled || isDisabled(date);\n const isToday = key === todayKey;\n const start = rangeKeys?.[0] === key;\n const end = rangeKeys?.[1] === key && pendingStart === null;\n const middle = !!rangeKeys && key > rangeKeys[0] && key < rangeKeys[1];\n const filled = rangeKeys ? start || end : selected.includes(key);\n const isSelected = filled || middle;\n const singleDayRange = rangeKeys?.[0] === rangeKeys?.[1];\n const suffixes = [\n isToday ? translate(\"monthCalendar.today\") : undefined,\n start ? translate(\"calendar.rangeStart\") : undefined,\n end ? translate(\"calendar.rangeEnd\") : undefined,\n ].filter(Boolean);\n const label = [fullDate(date), ...suffixes].join(\", \");\n const textColor = off\n ? t.colors[\"text-disabled-color\"]\n : filled\n ? t.colors[\"text-inverse-color\"]\n : middle\n ? t.colors[\"primary-color-text\"]\n : isToday\n ? primary\n : t.colors[\"text-color\"];\n const band = t.colors[\"primary-color-subtle\"];\n\n return (\n <Pressable\n key={key}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ selected: isSelected, disabled: off }}\n aria-selected={isSelected}\n disabled={off}\n onPress={() => press(date)}\n style={{\n flex: 1,\n height: cellHeight,\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: middle ? band : \"transparent\",\n }}\n {...part(\"calendar\", \"day\", {\n selected: isSelected,\n today: isToday,\n disabled: off,\n \"range-start\": start && !!rangeKeys,\n \"range-end\": end,\n \"range-middle\": middle,\n })}\n >\n {rangeKeys && !singleDayRange && (start || end) && (\n <View\n style={{\n position: \"absolute\",\n top: 0,\n bottom: 0,\n left: start ? \"50%\" : 0,\n right: end ? \"50%\" : 0,\n backgroundColor: band,\n }}\n />\n )}\n <View\n style={{\n width: dot,\n height: dot,\n borderRadius: dot / 2,\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: filled && !off ? primary : \"transparent\",\n borderWidth: isToday && !filled ? 1 : 0,\n borderColor: primary,\n }}\n >\n <Text\n allowFontScaling={false}\n style={[\n textStyle(t, size === \"small\" ? \"sm\" : \"md\", sans),\n {\n color: textColor,\n fontWeight: weight(\n t,\n filled || isToday ? \"semibold\" : \"regular\",\n ),\n },\n ]}\n >\n {date.getDate()}\n </Text>\n {(start || end) && !singleDayRange && size !== \"small\" && (\n <Text\n allowFontScaling={false}\n style={{\n position: \"absolute\",\n bottom: -t.space[\"0-5\"],\n fontSize: t.fontSize.xs - 3,\n color: t.colors[\"text-inverse-color\"],\n ...(sans ? { fontFamily: sans } : null),\n }}\n >\n {translate(start ? \"calendar.rangeStart\" : \"calendar.rangeEnd\")}\n </Text>\n )}\n </View>\n </Pressable>\n );\n };\n\n return (\n <View\n role=\"group\"\n accessibilityLabel={\n accessibilityLabel ?? translate(\"monthCalendar.label\")\n }\n {...part(\"calendar\", \"root\", { type, disabled })}\n {...rest}\n style={[{ backgroundColor: t.colors[\"surface-color\"] }, style]}\n >\n <View\n style={{\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n paddingHorizontal: t.space[\"2\"],\n paddingVertical: t.space[\"2\"],\n }}\n >\n {navButton(-1)}\n <Text\n accessibilityRole=\"header\"\n accessibilityLiveRegion=\"polite\"\n style={[\n textStyle(t, \"lg\", sans),\n { fontWeight: weight(t, \"semibold\") },\n ]}\n {...part(\"calendar\", \"month-title\")}\n >\n {translate(\"calendar.monthTitle\", {\n year: first.getFullYear(),\n month: first.getMonth() + 1,\n })}\n </Text>\n {navButton(1)}\n </View>\n <View\n importantForAccessibility=\"no-hide-descendants\"\n accessibilityElementsHidden\n style={{ flexDirection: \"row\", paddingVertical: t.space[\"1\"] }}\n {...part(\"calendar\", \"weekdays\")}\n >\n {Array.from({ length: 7 }, (_, i) => {\n const name = WEEKDAYS[(firstDayOfWeek + i) % 7];\n return (\n <Text\n key={name}\n style={[\n textStyle(t, \"xs\", sans),\n {\n flex: 1,\n textAlign: \"center\",\n color: t.colors[\"text-muted-color\"],\n },\n ]}\n >\n {translate(`monthCalendar.weekdays.${name}`)}\n </Text>\n );\n })}\n </View>\n {weeks.map((week, row) => (\n <View\n key={row}\n style={{ flexDirection: \"row\", marginBottom: t.space[\"0-5\"] }}\n {...part(\"calendar\", \"week\")}\n >\n {week.map((date, col) =>\n date ? (\n renderDay(date)\n ) : (\n <View\n key={`empty-${col}`}\n style={{ flex: 1, height: cellHeight }}\n />\n ),\n )}\n </View>\n ))}\n </View>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsHA,IAAMA,IAAW;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;AAAK,GAC3DC,IAAc;CAClB,OAAO;CACP,QAAQ;CACR,OAAO;AACT,GAEMC,KAAY,MAAgB;CAChC,IAAM,CAACC,GAAGC,GAAGC,KAAKC,EAAI,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CAC3C,OAAOC,EAAUJ,GAAGC,IAAI,GAAGC,CAAC;AAC9B,GAGMG,KAAU,MAA2D;CACzE,IAAIC,MAAU,KAAA,GAEd,OADIA,MAAU,OAAa,CAAC,KACpB,MAAM,QAAQA,CAAK,IAAIA,IAAQ,CAACA,CAAK,EAAA,CAAG,IAAIC,CAAM;AAC5D;AAGA,SAASC,EAAc,GAAqC;CAC1D,IAAMC,IAASC,GAAM,KAAK,IAAQ;CAClC,OAAOC,QAEHF,MAAW,KAAA,IACP,KAAA,IAC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localDate","keysOf","value","dayKey","useStableKeys","joined","keys","useMemo","Calendar","props","PoppableCalendar","CalendarView","rest","t","useTheme","translate","useI18n","overlay","useOverlay","current","setCurrent","useControllable","defaultValue","onChange","ready","titleNode","title","titleText","Overlay","View","part","Text","textStyle","fonts","weight","Pressable","hitSlopFor","pressed","Icon","Button","onConfirm","confirmText","_poppable","_open","_defaultOpen","_onOpenChange","_title","_confirmText","_onConfirm","today","useState","now","todayKey","minKey","minDate","maxKey","maxDate","isDisabled","date","disabledDate","toValue","dates","type","controlledKeys","state","send","useMachine","createSelectionMachine","pendingStart","setPendingStart","selected","rangeKeys","firstSelected","shownMonth","setShownMonth","month","defaultMonth","onMonthChange","first","monthStart","canPrev","disabled","canNext","press","onSelect","sameMonth","fullDate","format","locale","language","lead","firstDayOfWeek","daysInMonth","cells","addDays","i","weeks","cellHeight","size","dot","primary","sans","navButton","enabled","direction","label","previousMonthLabel","nextMonthLabel","renderDay","off","isToday","start","end","middle","filled","isSelected","singleDayRange","suffixes","textColor","band","accessibilityLabel","style","name","week","col","row"],"sources":["../../../../../native/src/components/Calendar/Calendar.tsx"],"sourcesContent":["import { useMemo, useState, type ReactNode } from \"react\";\nimport {\n Pressable,\n Text,\n View,\n type StyleProp,\n type ViewProps,\n type ViewStyle,\n} from \"react-native\";\nimport {\n addDays,\n createSelectionMachine,\n dayKey,\n localDate,\n monthStart,\n sameMonth,\n} from \"@minerva/core\";\nimport { useI18n, useTheme } from \"../../theme/MinervaProvider\";\nimport { Icon } from \"../../internal/Icon\";\nimport { Overlay, type OverlayCloseReason } from \"../../internal/Overlay\";\nimport { part } from \"../../internal/parts\";\nimport { hitSlopFor, textStyle, weight } from \"../../internal/styles\";\nimport { useControllable } from \"../../internal/useControllable\";\nimport { useMachine } from \"../../internal/useMachine\";\nimport { useOverlay } from \"../../internal/useOverlay\";\nimport { Button } from \"../Button\";\n\n/** Selection type of `Calendar` */\nexport type CalendarType = \"single\" | \"multiple\" | \"range\";\n\n/**\n * Value of `Calendar`: a day (`single`, `null`: none), days (`multiple`) or\n * a `[start, end]` range (`range`); every date is local midnight\n */\nexport type CalendarValue = Date | Date[] | [Date, Date] | null;\n\n/** Why a poppable calendar closed */\nexport type CalendarCloseReason = OverlayCloseReason;\n\nexport interface CalendarProps extends Omit<ViewProps, \"style\" | \"children\"> {\n /**\n * Selection type: one day, several days, or a range\n * @default \"single\"\n */\n type?: CalendarType;\n /**\n * Selected day(s) (controlled; pair with `onChange`): a `Date` (`single`),\n * `Date[]` (`multiple`) or `[start, end]` (`range`)\n */\n value?: CalendarValue;\n /** Initially selected day(s) (uncontrolled) @default null */\n defaultValue?: CalendarValue;\n /**\n * Called with the new selection (a range once both ends are picked)\n */\n onChange?: (value: CalendarValue) => void;\n /** Called with every pressed day */\n onSelect?: (date: Date) => void;\n /** Displayed month (controlled; any day of the month; pair with `onMonthChange`) */\n month?: Date;\n /**\n * Initially displayed month (uncontrolled)\n * @default the month of the first selected day, else of today\n */\n defaultMonth?: Date;\n /** Called with the first day of the month navigated to */\n onMonthChange?: (month: Date) => void;\n /** Earliest selectable day (earlier days are disabled) */\n minDate?: Date;\n /** Latest selectable day (later days are disabled) */\n maxDate?: Date;\n /** Locale of calendar month and accessible date names. */\n locale?: string;\n /** Extra disabled days */\n disabledDate?: (date: Date) => boolean;\n /**\n * First column of the week (0: Sunday ... 6: Saturday)\n * @default 0\n */\n firstDayOfWeek?: number;\n /**\n * Cell density: compact (\"small\"), default (\"medium\") or comfortable\n * (\"large\")\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n /**\n * Blocks navigation and selection\n * @default false\n */\n disabled?: boolean;\n /** Label of the previous-month button @default the \"monthCalendar.previousMonth\" message */\n previousMonthLabel?: string;\n /** Label of the next-month button @default the \"monthCalendar.nextMonth\" message */\n nextMonthLabel?: string;\n /**\n * Renders the calendar in a bottom sheet with a title and a confirm\n * button (`open` / `defaultOpen` / `onOpenChange`)\n * @default false\n */\n poppable?: boolean;\n /** Controlled open state of the poppable sheet */\n open?: boolean;\n /**\n * Initial open state of the poppable sheet while uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /** Called with the requested open state of the sheet and the close reason */\n onOpenChange?: (open: boolean, reason?: CalendarCloseReason) => void;\n /** Title of the poppable sheet @default the \"calendar.title\" message */\n title?: ReactNode;\n /** Text of the confirm button @default the \"calendar.confirm\" message */\n confirmText?: ReactNode;\n /** Called by the confirm button of the poppable sheet with the selection */\n onConfirm?: (value: CalendarValue) => void;\n /** Style of the calendar */\n style?: StyleProp<ViewStyle>;\n}\n\nconst WEEKDAYS = [\"sun\", \"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\"] as const;\nconst CELL_HEIGHT = {\n small: \"control-height-sm\",\n medium: \"control-height-md\",\n large: \"control-height-lg\",\n} as const;\n\nconst parseKey = (key: string) => {\n const [y, m, d] = key.split(\"-\").map(Number);\n return localDate(y, m - 1, d);\n};\n\n/** The selected day keys of a value */\nconst keysOf = (value: CalendarValue | undefined): string[] | undefined => {\n if (value === undefined) return undefined;\n if (value === null) return [];\n return (Array.isArray(value) ? value : [value]).map(dayKey);\n};\n\n/** The same array while its items are unchanged (controlled values) */\nfunction useStableKeys(keys: readonly string[] | undefined) {\n const joined = keys?.join(\"\\u0000\");\n return useMemo(\n () =>\n joined === undefined\n ? undefined\n : joined === \"\"\n ? []\n : joined.split(\"\\u0000\"),\n [joined],\n );\n}\n\n/**\n * A month calendar for picking a day, several days or a range: weekday\n * header, month navigation, min / max dates, today ring, selected fills\n * and range tint. Inline, or in a bottom sheet with a confirm button\n * (`poppable`). Single and multiple selections run on the selection\n * machine of @minerva/core.\n */\nexport function Calendar(props: CalendarProps) {\n if (!props.poppable) return <CalendarView {...props} />;\n return <PoppableCalendar {...props} />;\n}\n\nfunction PoppableCalendar({\n open,\n defaultOpen = false,\n onOpenChange,\n title,\n confirmText,\n onConfirm,\n onChange,\n value,\n defaultValue = null,\n type = \"single\",\n ...rest\n}: CalendarProps) {\n const { tokens: t, fonts } = useTheme();\n const { t: translate } = useI18n();\n const overlay = useOverlay({ open, defaultOpen, onOpenChange });\n // the sheet keeps the selection to confirm\n const [current, setCurrent] = useControllable<CalendarValue>(\n value,\n defaultValue,\n onChange,\n );\n if (overlay.state.phase === \"closed\") return null;\n const ready = Array.isArray(current) ? current.length > 0 : current !== null;\n const titleNode = title ?? translate(\"calendar.title\");\n const titleText =\n typeof titleNode === \"string\" || typeof titleNode === \"number\"\n ? String(titleNode)\n : undefined;\n const closeSize = 28;\n\n return (\n <Overlay\n component=\"calendar\"\n phase={overlay.state.phase}\n onAnimationEnd={overlay.onAnimationEnd}\n onRequestClose={overlay.close}\n placement=\"bottom\"\n panelProps={{ role: \"dialog\", accessibilityLabel: titleText }}\n >\n <View\n style={{\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"center\",\n paddingVertical: t.space[\"4\"],\n paddingHorizontal: t.space[\"12\"],\n }}\n {...part(\"calendar\", \"header\")}\n >\n {titleText !== undefined ? (\n <Text\n accessibilityRole=\"header\"\n style={[\n textStyle(t, \"lg\", fonts.sans),\n { fontWeight: weight(t, \"semibold\") },\n ]}\n {...part(\"calendar\", \"title\")}\n >\n {titleText}\n </Text>\n ) : (\n titleNode\n )}\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={translate(\"modal.close\")}\n hitSlop={hitSlopFor(t, closeSize, closeSize)}\n onPress={() => overlay.close(\"close-button\")}\n style={({ pressed }) => ({\n position: \"absolute\",\n right: t.space[\"4\"],\n width: closeSize,\n height: closeSize,\n borderRadius: closeSize / 2,\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: pressed\n ? t.colors[\"surface-muted-color\"]\n : \"transparent\",\n })}\n {...part(\"calendar\", \"close\")}\n >\n <Icon name=\"close\" size={14} color={t.colors[\"text-muted-color\"]} />\n </Pressable>\n </View>\n <CalendarView\n {...rest}\n type={type}\n value={current}\n onChange={setCurrent}\n style={[{ paddingHorizontal: t.space[\"2\"] }, rest.style]}\n />\n <View\n style={{ padding: t.space[\"4\"], paddingTop: t.space[\"2\"] }}\n {...part(\"calendar\", \"footer\")}\n >\n <Button\n fullWidth\n disabled={!ready}\n onPress={() => {\n onConfirm?.(current);\n overlay.close(\"confirm\");\n }}\n >\n {confirmText ?? translate(\"calendar.confirm\")}\n </Button>\n </View>\n </Overlay>\n );\n}\n\nfunction CalendarView({\n type = \"single\",\n value,\n defaultValue = null,\n onChange,\n onSelect,\n month,\n defaultMonth,\n onMonthChange,\n minDate,\n maxDate,\n disabledDate,\n firstDayOfWeek = 0,\n locale,\n size = \"medium\",\n disabled = false,\n previousMonthLabel,\n nextMonthLabel,\n style,\n accessibilityLabel,\n // poppable-only props, unused inline\n poppable: _poppable,\n open: _open,\n defaultOpen: _defaultOpen,\n onOpenChange: _onOpenChange,\n title: _title,\n confirmText: _confirmText,\n onConfirm: _onConfirm,\n ...rest\n}: CalendarProps) {\n const { tokens: t, fonts } = useTheme();\n const { t: translate, language } = useI18n();\n const [today] = useState(() => {\n const now = new Date();\n return localDate(now.getFullYear(), now.getMonth(), now.getDate());\n });\n const todayKey = dayKey(today);\n const minKey = minDate ? dayKey(minDate) : undefined;\n const maxKey = maxDate ? dayKey(maxDate) : undefined;\n const isDisabled = (date: Date) => {\n const key = dayKey(date);\n return (\n (minKey !== undefined && key < minKey) ||\n (maxKey !== undefined && key > maxKey) ||\n !!disabledDate?.(date)\n );\n };\n\n const toValue = (keys: readonly string[]): CalendarValue => {\n const dates = keys.map(parseKey);\n if (type === \"single\") return dates[0] ?? null;\n if (type === \"range\") {\n return dates.length === 2 ? [dates[0], dates[1]] : null;\n }\n return dates;\n };\n const controlledKeys = useStableKeys(keysOf(value));\n const [state, send] = useMachine(createSelectionMachine<string>, {\n mode: type === \"single\" ? (\"single\" as const) : (\"multiple\" as const),\n value: controlledKeys,\n defaultValue: keysOf(defaultValue) ?? [],\n isDisabled: (key: string) => isDisabled(parseKey(key)),\n max: type === \"range\" ? 2 : undefined,\n onValueChange: (keys: string[]) => onChange?.(toValue(keys)),\n });\n // range: the first end picked, waiting for the second\n const [pendingStart, setPendingStart] = useState<string | null>(null);\n\n const selected = state.value;\n const rangeKeys: [string, string] | null =\n type === \"range\"\n ? pendingStart !== null\n ? [pendingStart, pendingStart]\n : selected.length === 2\n ? [selected[0], selected[1]]\n : null\n : null;\n\n const firstSelected = selected[0] ? parseKey(selected[0]) : undefined;\n const [shownMonth, setShownMonth] = useControllable<Date>(\n month,\n defaultMonth ??\n firstSelected ??\n (minDate && minDate > today ? minDate : today),\n onMonthChange,\n );\n const first = monthStart(shownMonth);\n const canPrev = !disabled && (!minDate || first > monthStart(minDate));\n const canNext = !disabled && (!maxDate || monthStart(first, 1) <= maxDate);\n\n const press = (date: Date) => {\n const key = dayKey(date);\n onSelect?.(date);\n if (type === \"single\") {\n send({ type: \"SELECT\", value: key });\n } else if (type === \"multiple\") {\n send({ type: \"TOGGLE\", value: key });\n } else if (pendingStart === null || key < pendingStart) {\n setPendingStart(key);\n } else {\n setPendingStart(null);\n send({ type: \"SET\", value: [pendingStart, key] });\n }\n if (!sameMonth(date, first)) setShownMonth(monthStart(date));\n };\n\n const fullDate = useMemo(() => {\n try {\n const format = new Intl.DateTimeFormat(locale ?? language, {\n weekday: \"long\",\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n });\n return (date: Date) => format.format(date);\n } catch {\n return (date: Date) => date.toDateString();\n }\n }, [language, locale]);\n\n const lead = (first.getDay() - firstDayOfWeek + 7) % 7;\n const daysInMonth = localDate(\n first.getFullYear(),\n first.getMonth() + 1,\n 0,\n ).getDate();\n const cells: (Date | null)[] = [\n ...Array.from({ length: lead }, () => null),\n ...Array.from({ length: daysInMonth }, (_, i) => addDays(first, i)),\n ];\n while (cells.length % 7) cells.push(null);\n const weeks: (Date | null)[][] = [];\n for (let i = 0; i < cells.length; i += 7) weeks.push(cells.slice(i, i + 7));\n\n const cellHeight = t.sizes[CELL_HEIGHT[size]];\n const dot = Math.min(cellHeight - t.space[\"1\"], 44);\n const primary = t.colors[\"primary-color\"];\n const sans = fonts.sans;\n const navSize = 32;\n\n const navButton = (direction: -1 | 1) => {\n const enabled = direction < 0 ? canPrev : canNext;\n const label =\n direction < 0\n ? (previousMonthLabel ?? translate(\"monthCalendar.previousMonth\"))\n : (nextMonthLabel ?? translate(\"monthCalendar.nextMonth\"));\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ disabled: !enabled }}\n disabled={!enabled}\n hitSlop={hitSlopFor(t, navSize, navSize)}\n onPress={() => setShownMonth(monthStart(first, direction))}\n style={({ pressed }) => ({\n width: navSize,\n height: navSize,\n borderRadius: navSize / 2,\n alignItems: \"center\",\n justifyContent: \"center\",\n opacity: enabled ? 1 : 0.35,\n backgroundColor: pressed\n ? t.colors[\"surface-muted-color\"]\n : \"transparent\",\n })}\n {...part(\"calendar\", direction < 0 ? \"prev\" : \"next\")}\n >\n <Icon\n name={direction < 0 ? \"chevron-left\" : \"chevron-right\"}\n size={16}\n color={t.colors[\"text-secondary-color\"]}\n />\n </Pressable>\n );\n };\n\n const renderDay = (date: Date) => {\n const key = dayKey(date);\n const off = disabled || isDisabled(date);\n const isToday = key === todayKey;\n const start = rangeKeys?.[0] === key;\n const end = rangeKeys?.[1] === key && pendingStart === null;\n const middle = !!rangeKeys && key > rangeKeys[0] && key < rangeKeys[1];\n const filled = rangeKeys ? start || end : selected.includes(key);\n const isSelected = filled || middle;\n const singleDayRange = rangeKeys?.[0] === rangeKeys?.[1];\n const suffixes = [\n isToday ? translate(\"monthCalendar.today\") : undefined,\n start ? translate(\"calendar.rangeStart\") : undefined,\n end ? translate(\"calendar.rangeEnd\") : undefined,\n ].filter(Boolean);\n const label = [fullDate(date), ...suffixes].join(\", \");\n const textColor = off\n ? t.colors[\"text-disabled-color\"]\n : filled\n ? t.colors[\"text-inverse-color\"]\n : middle\n ? t.colors[\"primary-color-text\"]\n : isToday\n ? primary\n : t.colors[\"text-color\"];\n const band = t.colors[\"primary-color-subtle\"];\n\n return (\n <Pressable\n key={key}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ selected: isSelected, disabled: off }}\n aria-selected={isSelected}\n disabled={off}\n onPress={() => press(date)}\n style={{\n flex: 1,\n height: cellHeight,\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: middle ? band : \"transparent\",\n }}\n {...part(\"calendar\", \"day\", {\n selected: isSelected,\n today: isToday,\n disabled: off,\n \"range-start\": start && !!rangeKeys,\n \"range-end\": end,\n \"range-middle\": middle,\n })}\n >\n {rangeKeys && !singleDayRange && (start || end) && (\n <View\n style={{\n position: \"absolute\",\n top: 0,\n bottom: 0,\n left: start ? \"50%\" : 0,\n right: end ? \"50%\" : 0,\n backgroundColor: band,\n }}\n />\n )}\n <View\n style={{\n width: dot,\n height: dot,\n borderRadius: dot / 2,\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: filled && !off ? primary : \"transparent\",\n borderWidth: isToday && !filled ? 1 : 0,\n borderColor: primary,\n }}\n >\n <Text\n allowFontScaling={false}\n style={[\n textStyle(t, size === \"small\" ? \"sm\" : \"md\", sans),\n {\n color: textColor,\n fontWeight: weight(\n t,\n filled || isToday ? \"semibold\" : \"regular\",\n ),\n },\n ]}\n >\n {date.getDate()}\n </Text>\n {(start || end) && !singleDayRange && size !== \"small\" && (\n <Text\n allowFontScaling={false}\n style={{\n position: \"absolute\",\n bottom: -t.space[\"0-5\"],\n fontSize: t.fontSize.xs - 3,\n color: t.colors[\"text-inverse-color\"],\n ...(sans ? { fontFamily: sans } : null),\n }}\n >\n {translate(start ? \"calendar.rangeStart\" : \"calendar.rangeEnd\")}\n </Text>\n )}\n </View>\n </Pressable>\n );\n };\n\n return (\n <View\n role=\"group\"\n accessibilityLabel={\n accessibilityLabel ?? translate(\"monthCalendar.label\")\n }\n {...part(\"calendar\", \"root\", { type, disabled })}\n {...rest}\n style={[{ backgroundColor: t.colors[\"surface-color\"] }, style]}\n >\n <View\n style={{\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n paddingHorizontal: t.space[\"2\"],\n paddingVertical: t.space[\"2\"],\n }}\n >\n {navButton(-1)}\n <Text\n accessibilityRole=\"header\"\n accessibilityLiveRegion=\"polite\"\n style={[\n textStyle(t, \"lg\", sans),\n { fontWeight: weight(t, \"semibold\") },\n ]}\n {...part(\"calendar\", \"month-title\")}\n >\n {locale\n ? new Intl.DateTimeFormat(locale, {\n year: \"numeric\",\n month: \"long\",\n }).format(first)\n : translate(\"calendar.monthTitle\", {\n year: first.getFullYear(),\n month: first.getMonth() + 1,\n })}\n </Text>\n {navButton(1)}\n </View>\n <View\n importantForAccessibility=\"no-hide-descendants\"\n accessibilityElementsHidden\n style={{ flexDirection: \"row\", paddingVertical: t.space[\"1\"] }}\n {...part(\"calendar\", \"weekdays\")}\n >\n {Array.from({ length: 7 }, (_, i) => {\n const name = WEEKDAYS[(firstDayOfWeek + i) % 7];\n return (\n <Text\n key={name}\n style={[\n textStyle(t, \"xs\", sans),\n {\n flex: 1,\n textAlign: \"center\",\n color: t.colors[\"text-muted-color\"],\n },\n ]}\n >\n {translate(`monthCalendar.weekdays.${name}`)}\n </Text>\n );\n })}\n </View>\n {weeks.map((week, row) => (\n <View\n key={row}\n style={{ flexDirection: \"row\", marginBottom: t.space[\"0-5\"] }}\n {...part(\"calendar\", \"week\")}\n >\n {week.map((date, col) =>\n date ? (\n renderDay(date)\n ) : (\n <View\n key={`empty-${col}`}\n style={{ flex: 1, height: cellHeight }}\n />\n ),\n )}\n </View>\n ))}\n </View>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwHA,IAAMA,KAAW;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;AAAK,GAC3DC,IAAc;CAClB,OAAO;CACP,QAAQ;CACR,OAAO;AACT,GAEMC,KAAY,MAAgB;CAChC,IAAM,CAACC,GAAGC,GAAGC,KAAKC,EAAI,MAAM,GAAG,CAAC,CAAC,IAA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GAAM;KACvC,GAXCA,CAWD;IAEV,CAAC;GACG,CAAA;GACL1B,GAAM,KAAK,GAAM,MAChB,kBAACnE,GAAD;IAEE,OAAO;KAAE,eAAe;KAAO,cAAchB,EAAE,MAAM;IAAO;IAC5D,GAAIiB,EAAK,YAAY,MAAM;IAE1B,UAAA6F,EAAK,KAAK,GAAM,MACfjE,IACEkD,GAAUlD,CAAI,IAEd,kBAAC7B,GAAD,EAEE,OAAO;KAAE,MAAM;KAAG,QAAQoE;IAAW,EACtC,GAFM,SAAS2B,GAEf,CAEL;GACI,GAdCC,CAcD,CACP;EACG;;AAEV"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../theme/MinervaProvider.cjs"),t=require("../../internal/parts.cjs"),n=require("../../internal/styles.cjs"),r=require("../../internal/Icon.cjs"),i=require("../../internal/useMachine.cjs"),a=require("../../internal/FormControlContext.cjs"),o=require("../../internal/
|
|
1
|
+
const e=require("../../theme/MinervaProvider.cjs"),t=require("../../internal/parts.cjs"),n=require("../../internal/styles.cjs"),r=require("../../internal/Icon.cjs"),i=require("../../internal/useMachine.cjs"),a=require("../../internal/FormControlContext.cjs"),o=require("../../internal/formControl.cjs"),s=require("../../internal/toggleControl.cjs");let c=require("react"),l=require("react-native"),u=require("../../../core/index.cjs"),d=require("react/jsx-runtime");var f=(0,c.createContext)(null);function p(o){let{checked:p,defaultChecked:m=!1,onChange:h,indeterminate:g=!1,disabled:_=!1,label:v,children:y,color:b,size:x,shape:S,value:C,error:w=!1,labelPlacement:T=`end`,icon:E,style:D,labelStyle:O,accessibilityState:k,hitSlop:A,...j}=a.useFormControlProps(o),{tokens:M,fonts:N}=e.useTheme(),P=(0,c.useContext)(f),F=P!==null&&C!==void 0,I=F?P.value.includes(C):void 0,L=P?.size??x??`medium`,R=P?.color??b??`primary`,z=P?.shape??S??`square`,B=w||!!P?.error,V=_||!!P?.disabled||F&&!I&&P.full,[H,U]=i.useMachine(u.createCheckboxMachine,{checked:F?I:p,defaultChecked:m,indeterminate:g,disabled:V,onCheckedChange:e=>{F&&P.toggle(C),h?.(e,C)}}),W=n.colorRole(M,R),G=s.TOGGLE_BOX[L],K=H.checked||H.indeterminate,q=z===`circle`?G/2:z===`rounded`?M.radius.sm:Math.max(2,Math.round(M.radius.sm/2)),J=v??y,Y=n.textStyle(M,n.controlFontSize(M,L)).lineHeight??G;return(0,d.jsx)(l.Pressable,{accessibilityRole:`checkbox`,accessibilityState:{...k,checked:H.indeterminate?`mixed`:H.checked,disabled:V},"aria-checked":H.indeterminate?`mixed`:H.checked,"aria-disabled":V,disabled:V,onPress:()=>U({type:`TOGGLE`}),hitSlop:A??n.hitSlopFor(M,Math.max(G,Y)),...t.part(`checkbox`,`root`,{checked:H.checked,indeterminate:H.indeterminate,disabled:V,size:L,color:R,shape:z,invalid:B}),...j,style:[s.placementStyle(T),{gap:M.space[2],opacity:V?.5:1},D],children:({pressed:e})=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l.View,{style:{width:G,height:G,borderRadius:q,borderWidth:K?0:1.5,borderColor:B?M.colors[`danger-color`]:e?W.solid:M.colors[`border-strong-color`],backgroundColor:K?e?W.pressed:W.solid:e?W.subtle:M.colors[`surface-color`],alignItems:`center`,justifyContent:`center`},...t.part(`checkbox`,`control`,{checked:H.checked,indeterminate:H.indeterminate}),children:H.indeterminate?(0,d.jsx)(r.Icon,{name:`minus`,size:G*.9,color:W.onSolid}):H.checked?E??(0,d.jsx)(r.Icon,{name:`check`,size:G*.8,color:W.onSolid}):null}),(0,d.jsx)(s.ToggleLabel,{t:M,component:`checkbox`,size:L,disabled:V,fontFamily:N.sans,style:O,children:J})]})})}o.bindFormControl(p,{valuePropName:`checked`,emptyValue:!1,commitOnChange:!0,invalidPropName:`error`,requiredKey:`validation.checkMissing`}),exports.Checkbox=p,exports.CheckboxGroupContext=f;
|
|
2
2
|
//# sourceMappingURL=Checkbox.cjs.map
|