@forgedevstack/bear 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.const.cjs +1 -1
- package/dist/components/Calendar/Calendar.const.d.ts +1 -0
- package/dist/components/Calendar/Calendar.const.js +6 -5
- package/dist/components/Calendar/Calendar.helpers.cjs +1 -1
- package/dist/components/Calendar/Calendar.helpers.js +4 -4
- package/dist/components/Calendar/Calendar.js +128 -128
- package/dist/components/Cascader/Cascader.cjs +1 -0
- package/dist/components/Cascader/Cascader.const.cjs +1 -0
- package/dist/components/Cascader/Cascader.const.d.ts +33 -0
- package/dist/components/Cascader/Cascader.const.js +21 -0
- package/dist/components/Cascader/Cascader.d.ts +17 -0
- package/dist/components/Cascader/Cascader.js +227 -0
- package/dist/components/Cascader/Cascader.types.d.ts +94 -0
- package/dist/components/Cascader/index.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPalette.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.const.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.const.d.ts +25 -0
- package/dist/components/CommandPalette/CommandPalette.const.js +13 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +18 -0
- package/dist/components/CommandPalette/CommandPalette.js +190 -0
- package/dist/components/CommandPalette/CommandPalette.types.d.ts +90 -0
- package/dist/components/CommandPalette/CommandPalette.utils.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.utils.d.ts +17 -0
- package/dist/components/CommandPalette/CommandPalette.utils.js +63 -0
- package/dist/components/CommandPalette/index.d.ts +2 -0
- package/dist/components/CreditInput/CreditInput.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.const.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.const.d.ts +37 -0
- package/dist/components/CreditInput/CreditInput.const.js +66 -0
- package/dist/components/CreditInput/CreditInput.d.ts +15 -0
- package/dist/components/CreditInput/CreditInput.js +214 -0
- package/dist/components/CreditInput/CreditInput.types.d.ts +93 -0
- package/dist/components/CreditInput/CreditInput.utils.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.utils.d.ts +48 -0
- package/dist/components/CreditInput/CreditInput.utils.js +79 -0
- package/dist/components/CreditInput/index.d.ts +2 -0
- package/dist/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.js +108 -84
- package/dist/components/DatePicker/DatePicker.types.d.ts +2 -1
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +75 -44
- package/dist/components/Form/Form.cjs +1 -0
- package/dist/components/Form/Form.const.cjs +1 -0
- package/dist/components/Form/Form.const.d.ts +33 -0
- package/dist/components/Form/Form.const.js +27 -0
- package/dist/components/Form/Form.context.cjs +1 -0
- package/dist/components/Form/Form.context.d.ts +13 -0
- package/dist/components/Form/Form.context.js +12 -0
- package/dist/components/Form/Form.d.ts +18 -0
- package/dist/components/Form/Form.js +230 -0
- package/dist/components/Form/Form.types.d.ts +166 -0
- package/dist/components/Form/Form.utils.cjs +1 -0
- package/dist/components/Form/Form.utils.d.ts +17 -0
- package/dist/components/Form/Form.utils.js +31 -0
- package/dist/components/Form/index.d.ts +3 -0
- package/dist/components/NotificationCenter/NotificationCenter.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.d.ts +25 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.js +28 -0
- package/dist/components/NotificationCenter/NotificationCenter.d.ts +15 -0
- package/dist/components/NotificationCenter/NotificationCenter.js +223 -0
- package/dist/components/NotificationCenter/NotificationCenter.types.d.ts +117 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.d.ts +11 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.js +19 -0
- package/dist/components/NotificationCenter/index.d.ts +2 -0
- package/dist/components/PhoneInput/PhoneInput.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.const.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.const.d.ts +33 -0
- package/dist/components/PhoneInput/PhoneInput.const.js +82 -0
- package/dist/components/PhoneInput/PhoneInput.d.ts +16 -0
- package/dist/components/PhoneInput/PhoneInput.js +194 -0
- package/dist/components/PhoneInput/PhoneInput.types.d.ts +108 -0
- package/dist/components/PhoneInput/PhoneInput.utils.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.utils.d.ts +25 -0
- package/dist/components/PhoneInput/PhoneInput.utils.js +39 -0
- package/dist/components/PhoneInput/index.d.ts +2 -0
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.js +56 -56
- package/dist/components/TimePicker/TimePicker.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.d.ts +22 -1
- package/dist/components/TimePicker/TimePicker.constants.js +36 -19
- package/dist/components/TimePicker/TimePicker.js +97 -131
- package/dist/components/TimePicker/TimePicker.types.d.ts +47 -6
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.cjs +1 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.d.ts +3 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.js +81 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/index.d.ts +1 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.d.ts +3 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +84 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/index.d.ts +1 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.d.ts +18 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +67 -0
- package/dist/components/TimePicker/helpers/index.d.ts +2 -0
- package/dist/components/TimePicker/index.d.ts +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +12 -2
- package/dist/components/index.js +139 -126
- package/dist/index.cjs +1 -1
- package/dist/index.js +247 -234
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.cjs +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +0 -3
- package/dist/components/DateTimePicker/DateTimePicker.js +0 -178
- package/dist/components/DateTimePicker/DateTimePicker.types.d.ts +0 -26
- package/dist/components/DateTimePicker/DateTimePicker.utils.cjs +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.utils.d.ts +0 -2
- package/dist/components/DateTimePicker/DateTimePicker.utils.js +0 -16
- package/dist/components/DateTimePicker/index.d.ts +0 -2
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CardType, CreditCardValue } from './CreditInput.types';
|
|
2
|
+
/**
|
|
3
|
+
* Detect card type from card number
|
|
4
|
+
*/
|
|
5
|
+
export declare const detectCardType: (number: string) => CardType;
|
|
6
|
+
/**
|
|
7
|
+
* Format card number with spaces
|
|
8
|
+
*/
|
|
9
|
+
export declare const formatCardNumber: (number: string, cardType: CardType) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Format expiry date as MM/YY
|
|
12
|
+
*/
|
|
13
|
+
export declare const formatExpiry: (value: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Parse expiry date to month and year
|
|
16
|
+
*/
|
|
17
|
+
export declare const parseExpiry: (value: string) => {
|
|
18
|
+
month: string;
|
|
19
|
+
year: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Validate card number using Luhn algorithm
|
|
23
|
+
*/
|
|
24
|
+
export declare const validateLuhn: (number: string) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Validate card number length
|
|
27
|
+
*/
|
|
28
|
+
export declare const validateCardLength: (number: string, cardType: CardType) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Validate CVV length
|
|
31
|
+
*/
|
|
32
|
+
export declare const validateCvvLength: (cvv: string, cardType: CardType) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Validate expiry date
|
|
35
|
+
*/
|
|
36
|
+
export declare const validateExpiry: (month: string, year: string) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Create credit card value object
|
|
39
|
+
*/
|
|
40
|
+
export declare const createCreditCardValue: (number: string, expiry: string, cvv: string, name?: string) => CreditCardValue;
|
|
41
|
+
/**
|
|
42
|
+
* Get max CVV length for card type
|
|
43
|
+
*/
|
|
44
|
+
export declare const getMaxCvvLength: (cardType: CardType) => number;
|
|
45
|
+
/**
|
|
46
|
+
* Get max card number length for card type
|
|
47
|
+
*/
|
|
48
|
+
export declare const getMaxCardLength: (cardType: CardType) => number;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { CARD_PATTERNS as f, CARD_NUMBER_LENGTHS as i, CARD_FORMATS as u, CVV_LENGTHS as c } from "./CreditInput.const.js";
|
|
2
|
+
const h = (e) => {
|
|
3
|
+
const t = e.replace(/\D/g, ""), n = ["amex", "diners", "discover", "jcb", "unionpay", "mastercard", "visa"];
|
|
4
|
+
for (const r of n)
|
|
5
|
+
if (f[r].test(t))
|
|
6
|
+
return r;
|
|
7
|
+
return "unknown";
|
|
8
|
+
}, m = (e, t) => {
|
|
9
|
+
const n = e.replace(/\D/g, ""), r = u[t] || u.unknown;
|
|
10
|
+
let s = "", o = 0;
|
|
11
|
+
for (const a of r) {
|
|
12
|
+
if (o >= n.length) break;
|
|
13
|
+
s && (s += " "), s += n.slice(o, o + a), o += a;
|
|
14
|
+
}
|
|
15
|
+
return s;
|
|
16
|
+
}, L = (e) => {
|
|
17
|
+
const t = e.replace(/\D/g, "");
|
|
18
|
+
if (t.length === 0) return "";
|
|
19
|
+
if (t.length === 1)
|
|
20
|
+
return parseInt(t) > 1 ? `0${t}/` : t;
|
|
21
|
+
if (t.length === 2)
|
|
22
|
+
return parseInt(t) > 12 ? `0${t[0]}/${t[1]}` : `${t}/`;
|
|
23
|
+
const n = t.slice(0, 2), r = t.slice(2, 4);
|
|
24
|
+
return `${n}/${r}`;
|
|
25
|
+
}, v = (e) => {
|
|
26
|
+
const t = e.split("/");
|
|
27
|
+
return {
|
|
28
|
+
month: t[0] || "",
|
|
29
|
+
year: t[1] || ""
|
|
30
|
+
};
|
|
31
|
+
}, y = (e) => {
|
|
32
|
+
const t = e.replace(/\D/g, "");
|
|
33
|
+
if (t.length === 0) return !1;
|
|
34
|
+
let n = 0, r = !1;
|
|
35
|
+
for (let s = t.length - 1; s >= 0; s--) {
|
|
36
|
+
let o = parseInt(t[s], 10);
|
|
37
|
+
r && (o *= 2, o > 9 && (o -= 9)), n += o, r = !r;
|
|
38
|
+
}
|
|
39
|
+
return n % 10 === 0;
|
|
40
|
+
}, x = (e, t) => {
|
|
41
|
+
const n = e.replace(/\D/g, "");
|
|
42
|
+
return (i[t] || i.unknown).includes(n.length);
|
|
43
|
+
}, C = (e, t) => {
|
|
44
|
+
const n = e.replace(/\D/g, ""), r = c[t] || c.unknown;
|
|
45
|
+
return n.length === r;
|
|
46
|
+
}, N = (e, t) => {
|
|
47
|
+
const n = parseInt(e, 10), r = parseInt(t, 10);
|
|
48
|
+
if (isNaN(n) || isNaN(r) || n < 1 || n > 12) return !1;
|
|
49
|
+
const s = /* @__PURE__ */ new Date(), o = s.getFullYear() % 100, a = s.getMonth() + 1;
|
|
50
|
+
return !(r < o || r === o && n < a);
|
|
51
|
+
}, w = (e, t, n, r) => {
|
|
52
|
+
const s = e.replace(/\D/g, ""), o = h(s), { month: a, year: l } = v(t), g = y(s) && x(s, o), d = N(a, l), p = C(n, o);
|
|
53
|
+
return {
|
|
54
|
+
number: m(s, o),
|
|
55
|
+
rawNumber: s,
|
|
56
|
+
expiryMonth: a,
|
|
57
|
+
expiryYear: l,
|
|
58
|
+
cvv: n.replace(/\D/g, ""),
|
|
59
|
+
name: r,
|
|
60
|
+
cardType: o,
|
|
61
|
+
isValid: g && d && p
|
|
62
|
+
};
|
|
63
|
+
}, E = (e) => c[e] || c.unknown, M = (e) => {
|
|
64
|
+
const t = i[e] || i.unknown;
|
|
65
|
+
return Math.max(...t);
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
w as createCreditCardValue,
|
|
69
|
+
h as detectCardType,
|
|
70
|
+
m as formatCardNumber,
|
|
71
|
+
L as formatExpiry,
|
|
72
|
+
M as getMaxCardLength,
|
|
73
|
+
E as getMaxCvvLength,
|
|
74
|
+
v as parseExpiry,
|
|
75
|
+
x as validateCardLength,
|
|
76
|
+
C as validateCvvLength,
|
|
77
|
+
N as validateExpiry,
|
|
78
|
+
y as validateLuhn
|
|
79
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),a=require("react"),J=require("react-dom"),K=require("../Calendar/Calendar.cjs"),D=require("../../utils/cn.cjs"),Q=require("../../hooks/useBearStyles.cjs"),U=require("./DatePicker.utils.cjs"),X=({value:c,onChange:t,minDate:y,maxDate:j,disabled:b=!1,placeholder:z="Select date",label:p,error:o,helperText:m,format:B="MM/DD/YYYY",clearable:P=!0,className:_,style:h,bis:v,showWeekNumbers:S=!1,disabledDates:N=[],highlightedDates:g=[],slots:q,weekdayLabels:R,firstDayOfWeek:V=0,size:H="md",variant:M="default",icon:O})=>{const[i,n]=a.useState(!1),[E,L]=a.useState(c??new Date),[x,Y]=a.useState({top:0,left:0}),k=a.useRef(null),d=a.useRef(null),w=Q.useBearStyles(v,h);a.useEffect(()=>{if(i&&d.current){const e=d.current.getBoundingClientRect(),l=8,s=360,G=window.innerHeight-e.bottom<s&&e.top>s;Y({top:G?e.top-s-l:e.bottom+l,left:e.left})}},[i]),a.useEffect(()=>{const e=l=>{var u,f;const s=l.target;(u=k.current)!=null&&u.contains(s)||(f=s.closest)!=null&&f.call(s,"[data-bear-datepicker-calendar]")||n(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const T=a.useCallback(e=>{t==null||t(e),n(!1)},[t]),A=a.useCallback(()=>{t==null||t(null),n(!1)},[t]),I=a.useCallback(e=>{L(e)},[]),W={sm:"bear-py-1.5 bear-px-3 bear-text-sm",md:"bear-py-2 bear-px-4",lg:"bear-py-2.5 bear-px-5 bear-text-lg"},F={default:"bear-bg-white dark:bear-bg-zinc-800 bear-border-zinc-300 dark:bear-border-zinc-600",filled:"bear-bg-zinc-100 dark:bear-bg-zinc-700 bear-border-transparent",outline:"bear-bg-transparent bear-border-zinc-400 dark:bear-border-zinc-500"};return r.jsxs("div",{ref:k,className:D.cn("Bear-DatePicker bear-relative",_),style:Object.keys(w).length?w:void 0,children:[p&&r.jsx("label",{className:"Bear-DatePicker__label bear-block bear-text-sm bear-font-medium bear-text-zinc-700 dark:bear-text-zinc-300 bear-mb-1.5",children:p}),r.jsxs("button",{ref:d,type:"button",onClick:()=>!b&&n(!i),disabled:b,className:D.cn("Bear-DatePicker__trigger bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-text-left bear-transition-colors",W[H],F[M],o?"bear-border-red-500":"focus:bear-border-pink-500",b&&"bear-opacity-50 bear-cursor-not-allowed",c?"bear-text-zinc-900 dark:bear-text-white":"bear-text-zinc-500"),children:[r.jsx("span",{className:"Bear-DatePicker__value",children:c?U.formatDate(c,B):z}),r.jsx("span",{className:"Bear-DatePicker__icon",children:O??r.jsx("svg",{className:"bear-w-5 bear-h-5 bear-text-zinc-400 bear-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})})]}),o&&r.jsx("p",{className:"Bear-DatePicker__error bear-mt-1 bear-text-xs bear-text-red-400",children:o}),m&&!o&&r.jsx("p",{className:"Bear-DatePicker__helper bear-mt-1 bear-text-xs bear-text-zinc-500",children:m}),i&&typeof document<"u"&&J.createPortal(r.jsx("div",{"data-bear-datepicker-calendar":!0,className:"Bear-DatePicker__dropdown bear-fixed bear-z-[9999]",style:{top:x.top,left:x.left},children:r.jsx(K.Calendar,{viewDate:E,onViewChange:I,value:c??null,onSelect:T,minDate:y,maxDate:j,disabledDates:N,highlightedDates:g,slots:q,weekdayLabels:R,firstDayOfWeek:V,showWeekNumbers:S,clearable:P,onClear:A,showTodayButton:!0,onToday:()=>{t==null||t(new Date),n(!1)}})}),document.body)]})};exports.DatePicker=X;
|
|
@@ -1,103 +1,127 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import { jsxs as z, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as p, useRef as y, useEffect as h, useCallback as f } from "react";
|
|
3
|
+
import { createPortal as X } from "react-dom";
|
|
4
|
+
import { Calendar as Z } from "../Calendar/Calendar.js";
|
|
5
|
+
import { cn as B } from "../../utils/cn.js";
|
|
6
|
+
import { useBearStyles as $ } from "../../hooks/useBearStyles.js";
|
|
7
|
+
import { formatDate as C } from "./DatePicker.utils.js";
|
|
8
|
+
const ce = ({
|
|
9
|
+
value: o,
|
|
10
|
+
onChange: t,
|
|
11
|
+
minDate: _,
|
|
12
|
+
maxDate: v,
|
|
13
|
+
disabled: l = !1,
|
|
14
|
+
placeholder: P = "Select date",
|
|
15
|
+
label: u,
|
|
16
|
+
error: n,
|
|
17
|
+
helperText: k,
|
|
18
|
+
format: N = "MM/DD/YYYY",
|
|
19
|
+
clearable: g = !0,
|
|
20
|
+
className: S,
|
|
21
|
+
style: V,
|
|
22
|
+
bis: j,
|
|
23
|
+
showWeekNumbers: H = !1,
|
|
24
|
+
disabledDates: L = [],
|
|
25
|
+
highlightedDates: M = [],
|
|
26
|
+
slots: O,
|
|
27
|
+
weekdayLabels: R,
|
|
28
|
+
firstDayOfWeek: Y = 0,
|
|
29
|
+
size: E = "md",
|
|
30
|
+
variant: A = "default",
|
|
31
|
+
icon: I
|
|
30
32
|
}) => {
|
|
31
|
-
const [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const [c, s] = p(!1), [T, W] = p(o ?? /* @__PURE__ */ new Date()), [w, q] = p({ top: 0, left: 0 }), x = y(null), b = y(null), D = $(j, V);
|
|
34
|
+
h(() => {
|
|
35
|
+
if (c && b.current) {
|
|
36
|
+
const e = b.current.getBoundingClientRect(), i = 8, a = 360, U = window.innerHeight - e.bottom < a && e.top > a;
|
|
37
|
+
q({
|
|
38
|
+
top: U ? e.top - a - i : e.bottom + i,
|
|
39
|
+
left: e.left
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, [c]), h(() => {
|
|
43
|
+
const e = (i) => {
|
|
44
|
+
var d, m;
|
|
45
|
+
const a = i.target;
|
|
46
|
+
(d = x.current) != null && d.contains(a) || (m = a.closest) != null && m.call(a, "[data-bear-datepicker-calendar]") || s(!1);
|
|
35
47
|
};
|
|
36
|
-
return document.addEventListener("mousedown",
|
|
48
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
37
49
|
}, []);
|
|
38
|
-
const
|
|
39
|
-
(
|
|
40
|
-
|
|
50
|
+
const F = f(
|
|
51
|
+
(e) => {
|
|
52
|
+
t == null || t(e), s(!1);
|
|
41
53
|
},
|
|
42
|
-
[
|
|
43
|
-
),
|
|
44
|
-
|
|
45
|
-
}, [
|
|
46
|
-
|
|
47
|
-
}, []),
|
|
48
|
-
default: "bear-bg-zinc-800 bear-border-zinc-600",
|
|
49
|
-
filled: "bear-bg-zinc-700 bear-border-transparent",
|
|
50
|
-
outline: "bear-bg-transparent bear-border-zinc-500"
|
|
54
|
+
[t]
|
|
55
|
+
), G = f(() => {
|
|
56
|
+
t == null || t(null), s(!1);
|
|
57
|
+
}, [t]), J = f((e) => {
|
|
58
|
+
W(e);
|
|
59
|
+
}, []), K = { sm: "bear-py-1.5 bear-px-3 bear-text-sm", md: "bear-py-2 bear-px-4", lg: "bear-py-2.5 bear-px-5 bear-text-lg" }, Q = {
|
|
60
|
+
default: "bear-bg-white dark:bear-bg-zinc-800 bear-border-zinc-300 dark:bear-border-zinc-600",
|
|
61
|
+
filled: "bear-bg-zinc-100 dark:bear-bg-zinc-700 bear-border-transparent",
|
|
62
|
+
outline: "bear-bg-transparent bear-border-zinc-400 dark:bear-border-zinc-500"
|
|
51
63
|
};
|
|
52
|
-
return /* @__PURE__ */
|
|
53
|
-
|
|
54
|
-
/* @__PURE__ */
|
|
64
|
+
return /* @__PURE__ */ z("div", { ref: x, className: B("Bear-DatePicker bear-relative", S), style: Object.keys(D).length ? D : void 0, children: [
|
|
65
|
+
u && /* @__PURE__ */ r("label", { className: "Bear-DatePicker__label bear-block bear-text-sm bear-font-medium bear-text-zinc-700 dark:bear-text-zinc-300 bear-mb-1.5", children: u }),
|
|
66
|
+
/* @__PURE__ */ z(
|
|
55
67
|
"button",
|
|
56
68
|
{
|
|
69
|
+
ref: b,
|
|
57
70
|
type: "button",
|
|
58
|
-
onClick: () => !
|
|
59
|
-
disabled:
|
|
60
|
-
className:
|
|
61
|
-
"bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-text-left bear-transition-colors",
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
onClick: () => !l && s(!c),
|
|
72
|
+
disabled: l,
|
|
73
|
+
className: B(
|
|
74
|
+
"Bear-DatePicker__trigger bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-text-left bear-transition-colors",
|
|
75
|
+
K[E],
|
|
76
|
+
Q[A],
|
|
77
|
+
n ? "bear-border-red-500" : "focus:bear-border-pink-500",
|
|
78
|
+
l && "bear-opacity-50 bear-cursor-not-allowed",
|
|
79
|
+
o ? "bear-text-zinc-900 dark:bear-text-white" : "bear-text-zinc-500"
|
|
67
80
|
),
|
|
68
81
|
children: [
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
/* @__PURE__ */
|
|
82
|
+
/* @__PURE__ */ r("span", { className: "Bear-DatePicker__value", children: o ? C(o, N) : P }),
|
|
83
|
+
/* @__PURE__ */ r("span", { className: "Bear-DatePicker__icon", children: I ?? /* @__PURE__ */ r("svg", { className: "bear-w-5 bear-h-5 bear-text-zinc-400 bear-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) })
|
|
71
84
|
]
|
|
72
85
|
}
|
|
73
86
|
),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
n && /* @__PURE__ */ r("p", { className: "Bear-DatePicker__error bear-mt-1 bear-text-xs bear-text-red-400", children: n }),
|
|
88
|
+
k && !n && /* @__PURE__ */ r("p", { className: "Bear-DatePicker__helper bear-mt-1 bear-text-xs bear-text-zinc-500", children: k }),
|
|
89
|
+
c && typeof document < "u" && X(
|
|
90
|
+
/* @__PURE__ */ r(
|
|
91
|
+
"div",
|
|
92
|
+
{
|
|
93
|
+
"data-bear-datepicker-calendar": !0,
|
|
94
|
+
className: "Bear-DatePicker__dropdown bear-fixed bear-z-[9999]",
|
|
95
|
+
style: { top: w.top, left: w.left },
|
|
96
|
+
children: /* @__PURE__ */ r(
|
|
97
|
+
Z,
|
|
98
|
+
{
|
|
99
|
+
viewDate: T,
|
|
100
|
+
onViewChange: J,
|
|
101
|
+
value: o ?? null,
|
|
102
|
+
onSelect: F,
|
|
103
|
+
minDate: _,
|
|
104
|
+
maxDate: v,
|
|
105
|
+
disabledDates: L,
|
|
106
|
+
highlightedDates: M,
|
|
107
|
+
slots: O,
|
|
108
|
+
weekdayLabels: R,
|
|
109
|
+
firstDayOfWeek: Y,
|
|
110
|
+
showWeekNumbers: H,
|
|
111
|
+
clearable: g,
|
|
112
|
+
onClear: G,
|
|
113
|
+
showTodayButton: !0,
|
|
114
|
+
onToday: () => {
|
|
115
|
+
t == null || t(/* @__PURE__ */ new Date()), s(!1);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
)
|
|
96
119
|
}
|
|
97
|
-
|
|
120
|
+
),
|
|
121
|
+
document.body
|
|
98
122
|
)
|
|
99
123
|
] });
|
|
100
124
|
};
|
|
101
125
|
export {
|
|
102
|
-
|
|
126
|
+
ce as DatePicker
|
|
103
127
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),a=require("react"),N=require("react-dom"),y=require("../../utils/cn.cjs"),k=require("../Icon/index.cjs"),c=300,q={left:{sm:"bear-w-64",md:"bear-w-80",lg:"bear-w-96",xl:"bear-w-[32rem]"},right:{sm:"bear-w-64",md:"bear-w-80",lg:"bear-w-96",xl:"bear-w-[32rem]"},top:{sm:"bear-h-32",md:"bear-h-48",lg:"bear-h-64",xl:"bear-h-96"},bottom:{sm:"bear-h-32",md:"bear-h-48",lg:"bear-h-64",xl:"bear-h-96"}},C={left:"bear-left-0 bear-top-0 bear-h-full",right:"bear-right-0 bear-top-0 bear-h-full",top:"bear-top-0 bear-left-0 bear-w-full",bottom:"bear-bottom-0 bear-left-0 bear-w-full"},D={left:"bear-translate-x-0",right:"bear-translate-x-0",top:"bear-translate-y-0",bottom:"bear-translate-y-0"},E={left:"-bear-translate-x-full",right:"bear-translate-x-full",top:"-bear-translate-y-full",bottom:"bear-translate-y-full"},S=({isOpen:l,onClose:o,title:s,children:x,side:e="right",size:g="md",showCloseButton:d=!0,closeOnBackdrop:w=!0,closeOnEscape:u=!0,className:p})=>{const[t,m]=a.useState(l),[f,n]=a.useState(!1),[v,h]=a.useState(!1);a.useEffect(()=>{if(l){m(!0),n(!1);const b=requestAnimationFrame(()=>h(!0));return()=>cancelAnimationFrame(b)}if(t){h(!1),n(!0);const b=setTimeout(()=>{m(!1),n(!1)},c);return()=>clearTimeout(b)}},[l,t]);const i=a.useCallback(b=>{u&&b.key==="Escape"&&o()},[u,o]);if(a.useEffect(()=>(t&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}),[t,i]),!t)return null;const j=r.jsxs("div",{className:"bear-fixed bear-inset-0 bear-z-50",children:[r.jsx("div",{className:y.cn("bear-absolute bear-inset-0 bear-bg-black/60 bear-backdrop-blur-sm bear-transition-opacity",f?"bear-opacity-0":"bear-opacity-100"),style:{transitionDuration:`${c}ms`},onClick:w?o:void 0,"aria-hidden":"true"}),r.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":s?"drawer-title":void 0,className:y.cn("bear-absolute bear-bg-gray-900 bear-shadow-2xl","bear-border-gray-700 bear-overflow-hidden","bear-transform bear-transition-transform",e==="left"&&"bear-border-r",e==="right"&&"bear-border-l",e==="top"&&"bear-border-b",e==="bottom"&&"bear-border-t",C[e],q[e][g],v&&!f?D[e]:E[e],p),style:{transitionDuration:`${c}ms`},children:[(s||d)&&r.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-gray-700",children:[s&&r.jsx("h2",{id:"drawer-title",className:"bear-text-lg bear-font-semibold bear-text-white",children:s}),d&&r.jsx("button",{onClick:o,className:"bear-p-1 bear-rounded-lg bear-text-gray-400 hover:bear-text-white hover:bear-bg-gray-700 bear-transition-colors","aria-label":"Close drawer",children:r.jsx(k.XIcon,{className:"bear-w-5 bear-h-5"})})]}),r.jsx("div",{className:"bear-flex-1 bear-overflow-y-auto bear-p-4 bear-text-gray-300",children:x})]})]});return N.createPortal(j,document.body)};exports.Drawer=S;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { XIcon as
|
|
6
|
-
const
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as m, useEffect as g, useCallback as A } from "react";
|
|
3
|
+
import { createPortal as E } from "react-dom";
|
|
4
|
+
import { cn as p } from "../../utils/cn.js";
|
|
5
|
+
import { XIcon as I } from "../Icon/index.js";
|
|
6
|
+
const d = 300, D = {
|
|
7
7
|
left: {
|
|
8
8
|
sm: "bear-w-64",
|
|
9
9
|
md: "bear-w-80",
|
|
@@ -28,86 +28,117 @@ const x = {
|
|
|
28
28
|
lg: "bear-h-64",
|
|
29
29
|
xl: "bear-h-96"
|
|
30
30
|
}
|
|
31
|
-
},
|
|
31
|
+
}, M = {
|
|
32
32
|
left: "bear-left-0 bear-top-0 bear-h-full",
|
|
33
33
|
right: "bear-right-0 bear-top-0 bear-h-full",
|
|
34
34
|
top: "bear-top-0 bear-left-0 bear-w-full",
|
|
35
35
|
bottom: "bear-bottom-0 bear-left-0 bear-w-full"
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
}, j = {
|
|
37
|
+
left: "bear-translate-x-0",
|
|
38
|
+
right: "bear-translate-x-0",
|
|
39
|
+
top: "bear-translate-y-0",
|
|
40
|
+
bottom: "bear-translate-y-0"
|
|
41
|
+
}, T = {
|
|
42
|
+
left: "-bear-translate-x-full",
|
|
43
|
+
right: "bear-translate-x-full",
|
|
44
|
+
top: "-bear-translate-y-full",
|
|
45
|
+
bottom: "bear-translate-y-full"
|
|
46
|
+
}, _ = ({
|
|
47
|
+
isOpen: l,
|
|
48
|
+
onClose: b,
|
|
49
|
+
title: o,
|
|
50
|
+
children: w,
|
|
41
51
|
side: e = "right",
|
|
42
|
-
size:
|
|
43
|
-
showCloseButton:
|
|
44
|
-
closeOnBackdrop:
|
|
45
|
-
closeOnEscape:
|
|
46
|
-
className:
|
|
52
|
+
size: x = "md",
|
|
53
|
+
showCloseButton: c = !0,
|
|
54
|
+
closeOnBackdrop: v = !0,
|
|
55
|
+
closeOnEscape: f = !0,
|
|
56
|
+
className: N
|
|
47
57
|
}) => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
const [r, u] = m(l), [h, s] = m(!1), [k, y] = m(!1);
|
|
59
|
+
g(() => {
|
|
60
|
+
if (l) {
|
|
61
|
+
u(!0), s(!1);
|
|
62
|
+
const a = requestAnimationFrame(() => y(!0));
|
|
63
|
+
return () => cancelAnimationFrame(a);
|
|
64
|
+
}
|
|
65
|
+
if (r) {
|
|
66
|
+
y(!1), s(!0);
|
|
67
|
+
const a = setTimeout(() => {
|
|
68
|
+
u(!1), s(!1);
|
|
69
|
+
}, d);
|
|
70
|
+
return () => clearTimeout(a);
|
|
71
|
+
}
|
|
72
|
+
}, [l, r]);
|
|
73
|
+
const n = A(
|
|
74
|
+
(a) => {
|
|
75
|
+
f && a.key === "Escape" && b();
|
|
51
76
|
},
|
|
52
|
-
[
|
|
77
|
+
[f, b]
|
|
53
78
|
);
|
|
54
|
-
if (
|
|
55
|
-
document.removeEventListener("keydown",
|
|
56
|
-
}), [
|
|
57
|
-
const
|
|
58
|
-
/* @__PURE__ */
|
|
79
|
+
if (g(() => (r && (document.addEventListener("keydown", n), document.body.style.overflow = "hidden"), () => {
|
|
80
|
+
document.removeEventListener("keydown", n), document.body.style.overflow = "";
|
|
81
|
+
}), [r, n]), !r) return null;
|
|
82
|
+
const C = /* @__PURE__ */ i("div", { className: "bear-fixed bear-inset-0 bear-z-50", children: [
|
|
83
|
+
/* @__PURE__ */ t(
|
|
59
84
|
"div",
|
|
60
85
|
{
|
|
61
|
-
className:
|
|
62
|
-
|
|
86
|
+
className: p(
|
|
87
|
+
"bear-absolute bear-inset-0 bear-bg-black/60 bear-backdrop-blur-sm bear-transition-opacity",
|
|
88
|
+
h ? "bear-opacity-0" : "bear-opacity-100"
|
|
89
|
+
),
|
|
90
|
+
style: { transitionDuration: `${d}ms` },
|
|
91
|
+
onClick: v ? b : void 0,
|
|
63
92
|
"aria-hidden": "true"
|
|
64
93
|
}
|
|
65
94
|
),
|
|
66
|
-
/* @__PURE__ */
|
|
95
|
+
/* @__PURE__ */ i(
|
|
67
96
|
"div",
|
|
68
97
|
{
|
|
69
98
|
role: "dialog",
|
|
70
99
|
"aria-modal": "true",
|
|
71
|
-
"aria-labelledby":
|
|
72
|
-
className:
|
|
100
|
+
"aria-labelledby": o ? "drawer-title" : void 0,
|
|
101
|
+
className: p(
|
|
73
102
|
"bear-absolute bear-bg-gray-900 bear-shadow-2xl",
|
|
74
103
|
"bear-border-gray-700 bear-overflow-hidden",
|
|
75
|
-
"bear-transform bear-transition-transform
|
|
104
|
+
"bear-transform bear-transition-transform",
|
|
76
105
|
e === "left" && "bear-border-r",
|
|
77
106
|
e === "right" && "bear-border-l",
|
|
78
107
|
e === "top" && "bear-border-b",
|
|
79
108
|
e === "bottom" && "bear-border-t",
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
109
|
+
M[e],
|
|
110
|
+
D[e][x],
|
|
111
|
+
k && !h ? j[e] : T[e],
|
|
112
|
+
N
|
|
83
113
|
),
|
|
114
|
+
style: { transitionDuration: `${d}ms` },
|
|
84
115
|
children: [
|
|
85
|
-
(
|
|
86
|
-
|
|
116
|
+
(o || c) && /* @__PURE__ */ i("div", { className: "bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-gray-700", children: [
|
|
117
|
+
o && /* @__PURE__ */ t(
|
|
87
118
|
"h2",
|
|
88
119
|
{
|
|
89
120
|
id: "drawer-title",
|
|
90
121
|
className: "bear-text-lg bear-font-semibold bear-text-white",
|
|
91
|
-
children:
|
|
122
|
+
children: o
|
|
92
123
|
}
|
|
93
124
|
),
|
|
94
|
-
|
|
125
|
+
c && /* @__PURE__ */ t(
|
|
95
126
|
"button",
|
|
96
127
|
{
|
|
97
|
-
onClick:
|
|
128
|
+
onClick: b,
|
|
98
129
|
className: "bear-p-1 bear-rounded-lg bear-text-gray-400 hover:bear-text-white hover:bear-bg-gray-700 bear-transition-colors",
|
|
99
130
|
"aria-label": "Close drawer",
|
|
100
|
-
children: /* @__PURE__ */
|
|
131
|
+
children: /* @__PURE__ */ t(I, { className: "bear-w-5 bear-h-5" })
|
|
101
132
|
}
|
|
102
133
|
)
|
|
103
134
|
] }),
|
|
104
|
-
/* @__PURE__ */
|
|
135
|
+
/* @__PURE__ */ t("div", { className: "bear-flex-1 bear-overflow-y-auto bear-p-4 bear-text-gray-300", children: w })
|
|
105
136
|
]
|
|
106
137
|
}
|
|
107
138
|
)
|
|
108
139
|
] });
|
|
109
|
-
return
|
|
140
|
+
return E(C, document.body);
|
|
110
141
|
};
|
|
111
142
|
export {
|
|
112
|
-
|
|
143
|
+
_ as Drawer
|
|
113
144
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),l=require("react"),T=require("../../utils/cn.cjs"),B=require("./Form.context.cjs"),M=require("./Form.utils.cjs"),j=require("./Form.const.cjs"),q=({children:I,initialValues:u={},onSubmit:g,onError:a,layout:x="vertical",validateOnChange:b=!0,validateOnBlur:y=!0,className:v,testId:S,...C})=>{const[o,i]=l.useState(()=>({...j.FORM_INITIAL_STATE,fields:Object.fromEntries(Object.entries(u).map(([e,t])=>[e,{value:t,error:void 0,touched:!1,validating:!1,dirty:!1}]))})),c=l.useRef({}),_=l.useCallback((e,t)=>{i(s=>({...s,fields:{...s.fields,[e]:{...s.fields[e],value:t,dirty:!0}}}))},[]),n=l.useCallback(e=>{var t;return(t=o.fields[e])==null?void 0:t.value},[o.fields]),O=l.useCallback((e,t)=>{i(s=>({...s,fields:{...s.fields,[e]:{...s.fields[e],error:t}},errors:{...s.errors,[e]:t}}))},[]),E=l.useCallback(e=>{i(t=>{const s={...t.errors};return delete s[e],{...t,fields:{...t.fields,[e]:{...t.fields[e],error:void 0}},errors:s}})},[]),F=l.useCallback(async e=>{var f;const t=c.current[e];if(!t)return!0;i(d=>({...d,fields:{...d.fields,[e]:{...d.fields[e],validating:!0}}}));const s=(f=o.fields[e])==null?void 0:f.value,r=await M.validateFieldValue(s,t);return i(d=>({...d,fields:{...d.fields,[e]:{...d.fields[e],error:r??void 0,validating:!1}},errors:r?{...d.errors,[e]:r}:(()=>{const A={...d.errors};return delete A[e],A})()})),!r},[o.fields]),h=l.useCallback(async()=>{const e=Object.keys(c.current);return(await Promise.all(e.map(F))).every(Boolean)},[F]),R=l.useCallback(e=>{const t=e??u;i({...j.FORM_INITIAL_STATE,fields:Object.fromEntries(Object.entries(t).map(([s,r])=>[s,{value:r,error:void 0,touched:!1,validating:!1,dirty:!1}]))})},[u]),k=l.useCallback((e,t)=>{var s;return t&&(c.current[e]=t),o.fields[e]||i(r=>({...r,fields:{...r.fields,[e]:{value:u[e]??"",error:void 0,touched:!1,validating:!1,dirty:!1}}})),{name:e,value:((s=o.fields[e])==null?void 0:s.value)??u[e]??"",onChange:r=>{_(e,r),b&&t&&setTimeout(()=>F(e),0)},onBlur:()=>{i(r=>({...r,fields:{...r.fields,[e]:{...r.fields[e],touched:!0}}})),y&&t&&F(e)}}},[o.fields,u,_,F,b,y]),N=l.useCallback(e=>async t=>{if(t.preventDefault(),i(f=>({...f,isSubmitting:!0,isSubmitted:!0})),!await h()){i(f=>({...f,isSubmitting:!1})),a==null||a(o.errors);return}const r=Object.fromEntries(Object.entries(o.fields).map(([f,d])=>[f,d.value]));try{await e(r)}finally{i(f=>({...f,isSubmitting:!1}))}},[h,o.fields,o.errors,a]),L=l.useMemo(()=>({state:o,register:k,setValue:_,getValue:n,setError:O,clearError:E,validateField:F,validateForm:h,reset:R,handleSubmit:N,layout:x}),[o,k,_,n,O,E,F,h,R,N,x]);return m.jsx(B.FormContext.Provider,{value:L,children:m.jsx("form",{className:T.cn("Bear-Form",j.FORM_LAYOUT_CLASSES[x],v),onSubmit:g?N(g):void 0,"data-testid":S,...C,children:I})})},w=({name:I,label:u,required:g,rules:a,helperText:x,children:b,className:y})=>{const{register:v,state:S,layout:C}=B.useFormContext(),o={...a,required:g??(a==null?void 0:a.required)},i=v(I,o),c=S.fields[I],_=(c==null?void 0:c.touched)&&(c==null?void 0:c.error);return m.jsxs("div",{className:T.cn("Bear-FormItem",j.FORM_ITEM_LAYOUT_CLASSES[C],y),children:[u&&m.jsxs("label",{className:T.cn("Bear-FormItem__label bear-text-sm bear-font-medium bear-text-zinc-300",C==="horizontal"&&j.FORM_LABEL_WIDTH_HORIZONTAL),children:[u,(g||(a==null?void 0:a.required))&&m.jsx("span",{className:"Bear-FormItem__required bear-text-red-500 bear-ml-0.5",children:"*"})]}),m.jsxs("div",{className:"Bear-FormItem__content bear-flex-1",children:[m.jsx("div",{className:"Bear-FormItem__control",children:typeof b=="function"?b(i):l.isValidElement(b)?l.cloneElement(b,{...i,onChange:n=>{const O=n&&typeof n=="object"&&"target"in n&&n.target&&typeof n.target.value<"u"?n.target.value:n;i.onChange(O)}}):b}),_&&m.jsx("p",{className:"Bear-FormItem__error bear-mt-1 bear-text-xs bear-text-red-400",children:c.error}),x&&!_&&m.jsx("p",{className:"Bear-FormItem__helper bear-mt-1 bear-text-xs bear-text-zinc-500",children:x})]})]})};q.Item=w;exports.Form=q;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={required:"This field is required",email:"Please enter a valid email address",pattern:"Invalid format"},r={fields:{},isSubmitting:!1,isValid:!0,isSubmitted:!1,errors:{}},a=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,l={vertical:"Bear-Form--vertical bear-flex bear-flex-col bear-gap-4",horizontal:"Bear-Form--horizontal bear-flex bear-flex-col bear-gap-4",inline:"Bear-Form--inline bear-flex bear-flex-wrap bear-items-end bear-gap-4"},i={vertical:"Bear-FormItem--vertical bear-flex bear-flex-col bear-gap-1.5",horizontal:"Bear-FormItem--horizontal bear-flex bear-flex-row bear-items-start bear-gap-4",inline:"Bear-FormItem--inline bear-flex bear-flex-col bear-gap-1"},t="bear-w-32 bear-shrink-0";exports.EMAIL_REGEX=a;exports.FORM_DEFAULT_TRANSLATIONS=e;exports.FORM_INITIAL_STATE=r;exports.FORM_ITEM_LAYOUT_CLASSES=i;exports.FORM_LABEL_WIDTH_HORIZONTAL=t;exports.FORM_LAYOUT_CLASSES=l;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FormTranslations, FormState } from './Form.types';
|
|
2
|
+
/**
|
|
3
|
+
* Default form translations
|
|
4
|
+
*/
|
|
5
|
+
export declare const FORM_DEFAULT_TRANSLATIONS: FormTranslations;
|
|
6
|
+
/**
|
|
7
|
+
* Initial form state
|
|
8
|
+
*/
|
|
9
|
+
export declare const FORM_INITIAL_STATE: FormState;
|
|
10
|
+
/**
|
|
11
|
+
* Email validation regex
|
|
12
|
+
*/
|
|
13
|
+
export declare const EMAIL_REGEX: RegExp;
|
|
14
|
+
/**
|
|
15
|
+
* Layout classes
|
|
16
|
+
*/
|
|
17
|
+
export declare const FORM_LAYOUT_CLASSES: {
|
|
18
|
+
readonly vertical: "Bear-Form--vertical bear-flex bear-flex-col bear-gap-4";
|
|
19
|
+
readonly horizontal: "Bear-Form--horizontal bear-flex bear-flex-col bear-gap-4";
|
|
20
|
+
readonly inline: "Bear-Form--inline bear-flex bear-flex-wrap bear-items-end bear-gap-4";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Form item layout classes
|
|
24
|
+
*/
|
|
25
|
+
export declare const FORM_ITEM_LAYOUT_CLASSES: {
|
|
26
|
+
readonly vertical: "Bear-FormItem--vertical bear-flex bear-flex-col bear-gap-1.5";
|
|
27
|
+
readonly horizontal: "Bear-FormItem--horizontal bear-flex bear-flex-row bear-items-start bear-gap-4";
|
|
28
|
+
readonly inline: "Bear-FormItem--inline bear-flex bear-flex-col bear-gap-1";
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Label width for horizontal layout
|
|
32
|
+
*/
|
|
33
|
+
export declare const FORM_LABEL_WIDTH_HORIZONTAL = "bear-w-32 bear-shrink-0";
|