@athbnb/ui 0.0.2 → 0.0.3

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.
@@ -0,0 +1,231 @@
1
+ import { c as e } from "react/compiler-runtime";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ import * as r from "react";
4
+ //#region src/ui/TimePicker.tsx
5
+ function i(r) {
6
+ let i = e(4), { className: a } = r, o, s;
7
+ i[0] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ t("circle", {
8
+ cx: "12",
9
+ cy: "12",
10
+ r: "10"
11
+ }), s = /* @__PURE__ */ t("path", { d: "M12 6v6l4 2" }), i[0] = o, i[1] = s) : (o = i[0], s = i[1]);
12
+ let c;
13
+ return i[2] === a ? c = i[3] : (c = /* @__PURE__ */ n("svg", {
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ viewBox: "0 0 24 24",
16
+ fill: "none",
17
+ stroke: "currentColor",
18
+ strokeWidth: "2",
19
+ strokeLinecap: "round",
20
+ strokeLinejoin: "round",
21
+ className: a,
22
+ "aria-hidden": !0,
23
+ children: [o, s]
24
+ }), i[2] = a, i[3] = c), c;
25
+ }
26
+ function a(r) {
27
+ let i = e(4), { className: a } = r, o, s;
28
+ i[0] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ t("circle", {
29
+ cx: "12",
30
+ cy: "12",
31
+ r: "4"
32
+ }), s = /* @__PURE__ */ t("path", { d: "M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41" }), i[0] = o, i[1] = s) : (o = i[0], s = i[1]);
33
+ let c;
34
+ return i[2] === a ? c = i[3] : (c = /* @__PURE__ */ n("svg", {
35
+ xmlns: "http://www.w3.org/2000/svg",
36
+ viewBox: "0 0 24 24",
37
+ fill: "none",
38
+ stroke: "currentColor",
39
+ strokeWidth: "2",
40
+ strokeLinecap: "round",
41
+ strokeLinejoin: "round",
42
+ className: a,
43
+ "aria-hidden": !0,
44
+ children: [o, s]
45
+ }), i[2] = a, i[3] = c), c;
46
+ }
47
+ function o(n) {
48
+ let r = e(3), { className: i } = n, a;
49
+ r[0] === Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ t("path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" }), r[0] = a) : a = r[0];
50
+ let o;
51
+ return r[1] === i ? o = r[2] : (o = /* @__PURE__ */ t("svg", {
52
+ xmlns: "http://www.w3.org/2000/svg",
53
+ viewBox: "0 0 24 24",
54
+ fill: "none",
55
+ stroke: "currentColor",
56
+ strokeWidth: "2",
57
+ strokeLinecap: "round",
58
+ strokeLinejoin: "round",
59
+ className: i,
60
+ "aria-hidden": !0,
61
+ children: a
62
+ }), r[1] = i, r[2] = o), o;
63
+ }
64
+ var s = Array.from({ length: 12 }, (e, t) => (t + 1).toString().padStart(2, "0")), c = Array.from({ length: 12 }, (e, t) => (t * 5).toString().padStart(2, "0"));
65
+ function l(e) {
66
+ if (!e || !/^\d{1,2}:\d{2}$/.test(e.trim())) return {
67
+ hour12: "12",
68
+ minute: "00",
69
+ period: "AM"
70
+ };
71
+ let [t, n] = e.trim().split(":"), r = Math.min(23, Math.max(0, parseInt(t, 10))), i = n.padStart(2, "0").slice(0, 2), a = r % 12;
72
+ a === 0 && (a = 12);
73
+ let o = r >= 12 ? "PM" : "AM";
74
+ return {
75
+ hour12: a.toString().padStart(2, "0"),
76
+ minute: i,
77
+ period: o
78
+ };
79
+ }
80
+ function ee(e, t, n) {
81
+ let r = parseInt(e, 10);
82
+ (Number.isNaN(r) || r < 1 || r > 12) && (r = 12);
83
+ let i = r;
84
+ n === "PM" && i !== 12 ? i += 12 : n === "AM" && i === 12 && (i = 0);
85
+ let a = t.padStart(2, "0").slice(0, 2);
86
+ return `${i.toString().padStart(2, "0")}:${a}`;
87
+ }
88
+ function te(e) {
89
+ if (!e || !/^\d{1,2}:\d{2}$/.test(e.trim())) return "—";
90
+ let { hour12: t, minute: n, period: r } = l(e);
91
+ return `${parseInt(t, 10).toString().padStart(2, "0")}:${n} ${r}`;
92
+ }
93
+ function u(u) {
94
+ let d = e(43), { value: f, onChange: p, placeholder: m, variant: h, horizontalPosition: g, className: _, id: v } = u, y = m === void 0 ? "Select time" : m, b = h === void 0 ? "day" : h, x = g === void 0 ? "left" : g, S = _ === void 0 ? "" : _, [C, w] = r.useState(!1), T;
95
+ d[0] === f ? T = d[1] : (T = l(f), d[0] = f, d[1] = T);
96
+ let E = T, [D, O] = r.useState(E.hour12), [k, A] = r.useState(E.minute), [j, M] = r.useState(E.period), N = r.useRef(null), P, F;
97
+ d[2] === f ? (P = d[3], F = d[4]) : (P = () => {
98
+ let e = l(f);
99
+ O(e.hour12), A(e.minute), M(e.period);
100
+ }, F = [f], d[2] = f, d[3] = P, d[4] = F), r.useEffect(P, F);
101
+ let I, L;
102
+ d[5] === Symbol.for("react.memo_cache_sentinel") ? (I = () => {
103
+ let e = (e) => {
104
+ let t = N.current, n = e.target;
105
+ t && n instanceof Node && !t.contains(n) && w(!1);
106
+ };
107
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
108
+ }, L = [], d[5] = I, d[6] = L) : (I = d[5], L = d[6]), r.useEffect(I, L);
109
+ let R;
110
+ d[7] !== p || d[8] !== D || d[9] !== k || d[10] !== j ? (R = () => {
111
+ let e = ee(D, k, j);
112
+ p?.(e), w(!1);
113
+ }, d[7] = p, d[8] = D, d[9] = k, d[10] = j, d[11] = R) : R = d[11];
114
+ let z = R, B;
115
+ d[12] === f ? B = d[13] : (B = f && /^\d{1,2}:\d{2}$/.test(f.trim()), d[12] = f, d[13] = B);
116
+ let V = !!B, H;
117
+ d[14] !== V || d[15] !== y || d[16] !== f ? (H = V ? te(f) : y, d[14] = V, d[15] = y, d[16] = f, d[17] = H) : H = d[17];
118
+ let U = H, W = `relative ${S}`, G;
119
+ d[18] === W ? G = d[19] : (G = W.trim(), d[18] = W, d[19] = G);
120
+ let K;
121
+ d[20] === Symbol.for("react.memo_cache_sentinel") ? (K = () => w(ne), d[20] = K) : K = d[20];
122
+ let q;
123
+ d[21] === Symbol.for("react.memo_cache_sentinel") ? (q = /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(i, { className: "h-3 w-3 sm:h-5 sm:w-5" }) }), d[21] = q) : q = d[21];
124
+ let J = `text-xs font-semibold sm:text-lg ${V ? "text-gray-600" : "text-gray-400"}`, Y;
125
+ d[22] !== J || d[23] !== U ? (Y = /* @__PURE__ */ t("div", {
126
+ className: "flex min-w-0 flex-1 items-center gap-1",
127
+ children: /* @__PURE__ */ t("span", {
128
+ className: J,
129
+ children: U
130
+ })
131
+ }), d[22] = J, d[23] = U, d[24] = Y) : Y = d[24];
132
+ let X;
133
+ d[25] === b ? X = d[26] : (X = /* @__PURE__ */ t("div", {
134
+ className: "shrink-0 text-gray-400",
135
+ children: b === "night" ? /* @__PURE__ */ t(o, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : /* @__PURE__ */ t(a, { className: "h-3 w-3 sm:h-5 sm:w-5" })
136
+ }), d[25] = b, d[26] = X);
137
+ let Z;
138
+ d[27] !== v || d[28] !== C || d[29] !== Y || d[30] !== X ? (Z = /* @__PURE__ */ n("button", {
139
+ id: v,
140
+ type: "button",
141
+ "aria-haspopup": "dialog",
142
+ "aria-expanded": C,
143
+ onClick: K,
144
+ className: "flex w-full min-w-0 items-center gap-1 rounded-lg border border-primary/50 bg-gray-50 px-1 py-2 transition-colors hover:bg-gray-100 focus:border-transparent focus:outline-none focus:ring-1 focus:ring-primary sm:px-3 sm:py-2",
145
+ children: [
146
+ q,
147
+ Y,
148
+ X
149
+ ]
150
+ }), d[27] = v, d[28] = C, d[29] = Y, d[30] = X, d[31] = Z) : Z = d[31];
151
+ let Q;
152
+ d[32] !== z || d[33] !== x || d[34] !== C || d[35] !== D || d[36] !== k || d[37] !== j ? (Q = C ? /* @__PURE__ */ n("div", {
153
+ role: "dialog",
154
+ "aria-label": "Choose time",
155
+ className: `absolute top-full z-20 mt-2 min-w-[200px] rounded-lg bg-white p-4 text-secondary shadow-primary ${x === "left" ? "left-0" : "right-0"}`,
156
+ children: [/* @__PURE__ */ n("div", {
157
+ className: "mb-4 flex gap-4",
158
+ children: [
159
+ /* @__PURE__ */ n("div", {
160
+ className: "min-w-0 flex-1",
161
+ children: [/* @__PURE__ */ t("div", {
162
+ className: "mb-2 text-center text-sm",
163
+ children: "Hour"
164
+ }), /* @__PURE__ */ t("div", {
165
+ className: "max-h-32 space-y-1 overflow-y-auto",
166
+ children: s.map((e) => /* @__PURE__ */ t("button", {
167
+ type: "button",
168
+ onClick: () => O(e),
169
+ className: `w-full rounded px-2 py-1 text-sm ${D === e ? "bg-primary text-white" : "hover:bg-primary/20"}`,
170
+ children: e
171
+ }, e))
172
+ })]
173
+ }),
174
+ /* @__PURE__ */ n("div", {
175
+ className: "min-w-0 flex-1",
176
+ children: [/* @__PURE__ */ t("div", {
177
+ className: "mb-2 text-center text-sm",
178
+ children: "Min"
179
+ }), /* @__PURE__ */ t("div", {
180
+ className: "max-h-32 space-y-1 overflow-y-auto",
181
+ children: c.map((e) => /* @__PURE__ */ t("button", {
182
+ type: "button",
183
+ onClick: () => A(e),
184
+ className: `w-full rounded px-2 py-1 text-sm ${k === e ? "bg-primary text-white" : "hover:bg-primary/20"}`,
185
+ children: e
186
+ }, e))
187
+ })]
188
+ }),
189
+ /* @__PURE__ */ n("div", {
190
+ className: "min-w-0 flex-1",
191
+ children: [/* @__PURE__ */ t("div", {
192
+ className: "mb-2 text-center text-sm",
193
+ children: "Period"
194
+ }), /* @__PURE__ */ t("div", {
195
+ className: "space-y-1",
196
+ children: ["AM", "PM"].map((e) => /* @__PURE__ */ t("button", {
197
+ type: "button",
198
+ onClick: () => M(e),
199
+ className: `w-full rounded px-2 py-1 text-sm ${j === e ? "bg-primary text-white" : "hover:bg-primary/20"}`,
200
+ children: e
201
+ }, e))
202
+ })]
203
+ })
204
+ ]
205
+ }), /* @__PURE__ */ n("div", {
206
+ className: "flex gap-2 border-t border-gray-600 pt-2",
207
+ children: [/* @__PURE__ */ t("button", {
208
+ type: "button",
209
+ onClick: () => w(!1),
210
+ className: "flex-1 cursor-pointer rounded px-3 py-2 text-sm transition-colors hover:bg-primary/20",
211
+ children: "CANCEL"
212
+ }), /* @__PURE__ */ t("button", {
213
+ type: "button",
214
+ onClick: z,
215
+ className: "flex-1 cursor-pointer rounded bg-primary px-3 py-2 text-sm text-white transition-colors",
216
+ children: "OK"
217
+ })]
218
+ })]
219
+ }) : null, d[32] = z, d[33] = x, d[34] = C, d[35] = D, d[36] = k, d[37] = j, d[38] = Q) : Q = d[38];
220
+ let $;
221
+ return d[39] !== G || d[40] !== Z || d[41] !== Q ? ($ = /* @__PURE__ */ n("div", {
222
+ className: G,
223
+ ref: N,
224
+ children: [Z, Q]
225
+ }), d[39] = G, d[40] = Z, d[41] = Q, d[42] = $) : $ = d[42], $;
226
+ }
227
+ function ne(e) {
228
+ return !e;
229
+ }
230
+ //#endregion
231
+ export { u as TimePicker };
@@ -0,0 +1,18 @@
1
+ /* empty css */
2
+ import { c as e } from "react/compiler-runtime";
3
+ import { jsx as t } from "react/jsx-runtime";
4
+ import { Bounce as n, Flip as r, Slide as i, ToastContainer as a, Zoom as o, toast as s } from "react-toastify";
5
+ //#region src/ui/Toast.tsx
6
+ var c = {
7
+ position: "top-right",
8
+ autoClose: 3e3
9
+ };
10
+ function l(n) {
11
+ let r = e(2), i;
12
+ return r[0] === n ? i = r[1] : (i = /* @__PURE__ */ t(a, {
13
+ ...c,
14
+ ...n
15
+ }), r[0] = n, r[1] = i), i;
16
+ }
17
+ //#endregion
18
+ export { n as Bounce, r as Flip, i as Slide, l as ToastContainer, o as Zoom, s as toast };
@@ -0,0 +1,30 @@
1
+ import { c as e } from "react/compiler-runtime";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { forwardRef as n } from "react";
4
+ import { Tooltip as r } from "react-tooltip";
5
+ //#region src/ui/Tooltip.tsx
6
+ var i = "!w-fit !text-xs text-black rounded-primary shadow-primary font-normal whitespace-break-spaces text-left", a = {
7
+ backgroundColor: "rgb(255, 255, 255)",
8
+ color: "#1b1b33",
9
+ borderRadius: "8px",
10
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)"
11
+ }, o = n(function(n, o) {
12
+ let s = e(13), c, l, u;
13
+ s[0] === n ? (c = s[1], l = s[2], u = s[3]) : ({className: c, style: u, ...l} = n, s[0] = n, s[1] = c, s[2] = l, s[3] = u);
14
+ let d;
15
+ s[4] === c ? d = s[5] : (d = [i, c].filter(Boolean), s[4] = c, s[5] = d);
16
+ let f = d.join(" "), p;
17
+ s[6] === u ? p = s[7] : (p = {
18
+ ...a,
19
+ ...u
20
+ }, s[6] = u, s[7] = p);
21
+ let m;
22
+ return s[8] !== o || s[9] !== l || s[10] !== f || s[11] !== p ? (m = /* @__PURE__ */ t(r, {
23
+ ref: o,
24
+ ...l,
25
+ className: f,
26
+ style: p
27
+ }), s[8] = o, s[9] = l, s[10] = f, s[11] = p, s[12] = m) : m = s[12], m;
28
+ });
29
+ //#endregion
30
+ export { o as Tooltip };
@@ -0,0 +1,81 @@
1
+ //#region src/utils/date-picker-utils.ts
2
+ var e = [
3
+ "January",
4
+ "February",
5
+ "March",
6
+ "April",
7
+ "May",
8
+ "June",
9
+ "July",
10
+ "August",
11
+ "September",
12
+ "October",
13
+ "November",
14
+ "December"
15
+ ], t = [
16
+ "Sun",
17
+ "Mon",
18
+ "Tue",
19
+ "Wed",
20
+ "Thu",
21
+ "Fri",
22
+ "Sat"
23
+ ];
24
+ function n(e) {
25
+ return new Date(e.getFullYear(), e.getMonth(), e.getDate());
26
+ }
27
+ function r(t) {
28
+ return !t || isNaN(t.getTime()) ? "" : `${t.getDate().toString().padStart(2, "0")} ${e[t.getMonth()].slice(0, 3)} ${t.getFullYear()}`;
29
+ }
30
+ function i(e) {
31
+ return `${e.getFullYear()}-${(e.getMonth() + 1).toString().padStart(2, "0")}-${e.getDate().toString().padStart(2, "0")}`;
32
+ }
33
+ function a(t) {
34
+ if (t == null || !String(t).trim()) return null;
35
+ let r = String(t).trim();
36
+ if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(r)) {
37
+ let [e, t, i] = r.split("/").map((e) => parseInt(e, 10)), a = new Date(i, t - 1, e);
38
+ return isNaN(a.getTime()) ? null : n(a);
39
+ }
40
+ let i = /^(\d{1,2})\s+([A-Za-z]{3})\s+(\d{4})$/.exec(r);
41
+ if (i) {
42
+ let t = parseInt(i[1], 10), r = i[2].toLowerCase(), a = parseInt(i[3], 10), o = e.findIndex((e) => e.slice(0, 3).toLowerCase() === r);
43
+ if (o >= 0) {
44
+ let e = new Date(a, o, t);
45
+ return isNaN(e.getTime()) ? null : n(e);
46
+ }
47
+ }
48
+ if (/^\d{4}-\d{2}-\d{2}/.test(r)) {
49
+ let [e, t, i] = r.slice(0, 10).split("-").map((e) => parseInt(e, 10)), a = new Date(e, t - 1, i);
50
+ return isNaN(a.getTime()) ? null : n(a);
51
+ }
52
+ let a = new Date(r);
53
+ return isNaN(a.getTime()) ? null : n(a);
54
+ }
55
+ function o(e) {
56
+ if (e == null) return null;
57
+ if (typeof e == "string" && /^\d{1,2}\/\d{1,2}\/\d{4}$/.test(e)) {
58
+ let [t, r, i] = e.split("/").map((e) => parseInt(e, 10));
59
+ return n(new Date(i, r - 1, t));
60
+ }
61
+ let t = typeof e == "string" ? new Date(e) : e;
62
+ return isNaN(t.getTime()) ? null : n(t);
63
+ }
64
+ function s(e, t) {
65
+ return !e || !t ? !1 : e.getDate() === t.getDate() && e.getMonth() === t.getMonth() && e.getFullYear() === t.getFullYear();
66
+ }
67
+ function c(e, t) {
68
+ return n(e).getTime() - n(t).getTime();
69
+ }
70
+ function l(e, t, r) {
71
+ let i = n(e).getTime(), a = n(t).getTime(), o = n(r).getTime();
72
+ return i >= Math.min(a, o) && i <= Math.max(a, o);
73
+ }
74
+ function u(e, t) {
75
+ return new Date(e, t + 1, 0).getDate();
76
+ }
77
+ function d(e, t) {
78
+ return new Date(e, t, 1).getDay();
79
+ }
80
+ //#endregion
81
+ export { e as MONTH_NAMES, t as WEEKDAYS, c as compareDay, r as formatDateDisplay, u as getDaysInMonth, d as getFirstWeekdayOfMonth, l as isDayBetweenInclusive, o as parseBoundaryDate, a as parseFlexibleDateInput, s as sameDay, n as startOfDay, i as toISODateString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athbnb/ui",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "scripts": {
@@ -22,6 +22,30 @@
22
22
  "types": "./dist/index.d.ts",
23
23
  "import": "./dist/index.js"
24
24
  },
25
+ "./ui/*": {
26
+ "types": "./dist/ui/*.d.ts",
27
+ "import": "./dist/ui/*.js"
28
+ },
29
+ "./utils/*": {
30
+ "types": "./dist/utils/*.d.ts",
31
+ "import": "./dist/utils/*.js"
32
+ },
33
+ "./button": {
34
+ "types": "./dist/ui/Button.d.ts",
35
+ "import": "./dist/ui/Button.js"
36
+ },
37
+ "./toast": {
38
+ "types": "./dist/ui/Toast.d.ts",
39
+ "import": "./dist/ui/Toast.js"
40
+ },
41
+ "./tooltip": {
42
+ "types": "./dist/ui/Tooltip.d.ts",
43
+ "import": "./dist/ui/Tooltip.js"
44
+ },
45
+ "./google-map": {
46
+ "types": "./dist/ui/GoogleMap.d.ts",
47
+ "import": "./dist/ui/GoogleMap.js"
48
+ },
25
49
  "./theme.css": "./dist/theme.css",
26
50
  "./toastify.css": "./dist/ui.css"
27
51
  },