@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,27 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
required: "This field is required",
|
|
3
|
+
email: "Please enter a valid email address",
|
|
4
|
+
pattern: "Invalid format"
|
|
5
|
+
}, r = {
|
|
6
|
+
fields: {},
|
|
7
|
+
isSubmitting: !1,
|
|
8
|
+
isValid: !0,
|
|
9
|
+
isSubmitted: !1,
|
|
10
|
+
errors: {}
|
|
11
|
+
}, a = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i, l = {
|
|
12
|
+
vertical: "Bear-Form--vertical bear-flex bear-flex-col bear-gap-4",
|
|
13
|
+
horizontal: "Bear-Form--horizontal bear-flex bear-flex-col bear-gap-4",
|
|
14
|
+
inline: "Bear-Form--inline bear-flex bear-flex-wrap bear-items-end bear-gap-4"
|
|
15
|
+
}, i = {
|
|
16
|
+
vertical: "Bear-FormItem--vertical bear-flex bear-flex-col bear-gap-1.5",
|
|
17
|
+
horizontal: "Bear-FormItem--horizontal bear-flex bear-flex-row bear-items-start bear-gap-4",
|
|
18
|
+
inline: "Bear-FormItem--inline bear-flex bear-flex-col bear-gap-1"
|
|
19
|
+
}, t = "bear-w-32 bear-shrink-0";
|
|
20
|
+
export {
|
|
21
|
+
a as EMAIL_REGEX,
|
|
22
|
+
e as FORM_DEFAULT_TRANSLATIONS,
|
|
23
|
+
r as FORM_INITIAL_STATE,
|
|
24
|
+
i as FORM_ITEM_LAYOUT_CLASSES,
|
|
25
|
+
t as FORM_LABEL_WIDTH_HORIZONTAL,
|
|
26
|
+
l as FORM_LAYOUT_CLASSES
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),e=t.createContext(null),n=()=>{const o=t.useContext(e);if(!o)throw new Error("useFormContext must be used within a Form component");return o},r=()=>t.useContext(e);exports.FormContext=e;exports.useFormContext=n;exports.useFormContextSafe=r;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FormContextValue } from './Form.types';
|
|
2
|
+
/**
|
|
3
|
+
* Form context
|
|
4
|
+
*/
|
|
5
|
+
export declare const FormContext: import('react').Context<FormContextValue | null>;
|
|
6
|
+
/**
|
|
7
|
+
* Hook to access form context
|
|
8
|
+
*/
|
|
9
|
+
export declare const useFormContext: () => FormContextValue;
|
|
10
|
+
/**
|
|
11
|
+
* Hook to safely access form context (returns null if not in Form)
|
|
12
|
+
*/
|
|
13
|
+
export declare const useFormContextSafe: () => FormContextValue | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext as n, useContext as o } from "react";
|
|
2
|
+
const e = n(null), s = () => {
|
|
3
|
+
const t = o(e);
|
|
4
|
+
if (!t)
|
|
5
|
+
throw new Error("useFormContext must be used within a Form component");
|
|
6
|
+
return t;
|
|
7
|
+
}, m = () => o(e);
|
|
8
|
+
export {
|
|
9
|
+
e as FormContext,
|
|
10
|
+
s as useFormContext,
|
|
11
|
+
m as useFormContextSafe
|
|
12
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormProps, FormItemProps } from './Form.types';
|
|
3
|
+
/**
|
|
4
|
+
* Form - Form management component with validation
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <Form onSubmit={handleSubmit} initialValues={{ email: '' }}>
|
|
9
|
+
* <Form.Item name="email" label="Email" rules={{ required: true, email: true }}>
|
|
10
|
+
* <Input />
|
|
11
|
+
* </Form.Item>
|
|
12
|
+
* <Button type="submit">Submit</Button>
|
|
13
|
+
* </Form>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const Form: FC<FormProps> & {
|
|
17
|
+
Item: FC<FormItemProps>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { jsx as g, jsxs as B } from "react/jsx-runtime";
|
|
2
|
+
import { useState as M, useRef as V, useCallback as u, useMemo as q, isValidElement as z, cloneElement as k } from "react";
|
|
3
|
+
import { cn as E } from "../../utils/cn.js";
|
|
4
|
+
import { FormContext as D, useFormContext as H } from "./Form.context.js";
|
|
5
|
+
import { validateFieldValue as P } from "./Form.utils.js";
|
|
6
|
+
import { FORM_INITIAL_STATE as w, FORM_LAYOUT_CLASSES as U, FORM_LABEL_WIDTH_HORIZONTAL as Y, FORM_ITEM_LAYOUT_CLASSES as p } from "./Form.const.js";
|
|
7
|
+
const W = ({
|
|
8
|
+
children: I,
|
|
9
|
+
initialValues: n = {},
|
|
10
|
+
onSubmit: x,
|
|
11
|
+
onError: l,
|
|
12
|
+
layout: F = "vertical",
|
|
13
|
+
validateOnChange: m = !0,
|
|
14
|
+
validateOnBlur: h = !0,
|
|
15
|
+
className: N,
|
|
16
|
+
testId: S,
|
|
17
|
+
...v
|
|
18
|
+
}) => {
|
|
19
|
+
const [o, i] = M(() => ({
|
|
20
|
+
...w,
|
|
21
|
+
fields: Object.fromEntries(
|
|
22
|
+
Object.entries(n).map(([e, t]) => [
|
|
23
|
+
e,
|
|
24
|
+
{ value: t, error: void 0, touched: !1, validating: !1, dirty: !1 }
|
|
25
|
+
])
|
|
26
|
+
)
|
|
27
|
+
})), a = V({}), b = u((e, t) => {
|
|
28
|
+
i((r) => ({
|
|
29
|
+
...r,
|
|
30
|
+
fields: {
|
|
31
|
+
...r.fields,
|
|
32
|
+
[e]: {
|
|
33
|
+
...r.fields[e],
|
|
34
|
+
value: t,
|
|
35
|
+
dirty: !0
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
}, []), c = u((e) => {
|
|
40
|
+
var t;
|
|
41
|
+
return (t = o.fields[e]) == null ? void 0 : t.value;
|
|
42
|
+
}, [o.fields]), y = u((e, t) => {
|
|
43
|
+
i((r) => ({
|
|
44
|
+
...r,
|
|
45
|
+
fields: {
|
|
46
|
+
...r.fields,
|
|
47
|
+
[e]: {
|
|
48
|
+
...r.fields[e],
|
|
49
|
+
error: t
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
errors: { ...r.errors, [e]: t }
|
|
53
|
+
}));
|
|
54
|
+
}, []), A = u((e) => {
|
|
55
|
+
i((t) => {
|
|
56
|
+
const r = { ...t.errors };
|
|
57
|
+
return delete r[e], {
|
|
58
|
+
...t,
|
|
59
|
+
fields: {
|
|
60
|
+
...t.fields,
|
|
61
|
+
[e]: {
|
|
62
|
+
...t.fields[e],
|
|
63
|
+
error: void 0
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
errors: r
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}, []), _ = u(async (e) => {
|
|
70
|
+
var f;
|
|
71
|
+
const t = a.current[e];
|
|
72
|
+
if (!t) return !0;
|
|
73
|
+
i((d) => ({
|
|
74
|
+
...d,
|
|
75
|
+
fields: {
|
|
76
|
+
...d.fields,
|
|
77
|
+
[e]: {
|
|
78
|
+
...d.fields[e],
|
|
79
|
+
validating: !0
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
const r = (f = o.fields[e]) == null ? void 0 : f.value, s = await P(r, t);
|
|
84
|
+
return i((d) => ({
|
|
85
|
+
...d,
|
|
86
|
+
fields: {
|
|
87
|
+
...d.fields,
|
|
88
|
+
[e]: {
|
|
89
|
+
...d.fields[e],
|
|
90
|
+
error: s ?? void 0,
|
|
91
|
+
validating: !1
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
errors: s ? { ...d.errors, [e]: s } : (() => {
|
|
95
|
+
const T = { ...d.errors };
|
|
96
|
+
return delete T[e], T;
|
|
97
|
+
})()
|
|
98
|
+
})), !s;
|
|
99
|
+
}, [o.fields]), O = u(async () => {
|
|
100
|
+
const e = Object.keys(a.current);
|
|
101
|
+
return (await Promise.all(e.map(_))).every(Boolean);
|
|
102
|
+
}, [_]), L = u((e) => {
|
|
103
|
+
i({
|
|
104
|
+
...w,
|
|
105
|
+
fields: Object.fromEntries(
|
|
106
|
+
Object.entries(e ?? n).map(([r, s]) => [
|
|
107
|
+
r,
|
|
108
|
+
{ value: s, error: void 0, touched: !1, validating: !1, dirty: !1 }
|
|
109
|
+
])
|
|
110
|
+
)
|
|
111
|
+
});
|
|
112
|
+
}, [n]), R = u((e, t) => {
|
|
113
|
+
var r;
|
|
114
|
+
return t && (a.current[e] = t), o.fields[e] || i((s) => ({
|
|
115
|
+
...s,
|
|
116
|
+
fields: {
|
|
117
|
+
...s.fields,
|
|
118
|
+
[e]: {
|
|
119
|
+
value: n[e] ?? "",
|
|
120
|
+
error: void 0,
|
|
121
|
+
touched: !1,
|
|
122
|
+
validating: !1,
|
|
123
|
+
dirty: !1
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
})), {
|
|
127
|
+
name: e,
|
|
128
|
+
value: ((r = o.fields[e]) == null ? void 0 : r.value) ?? n[e] ?? "",
|
|
129
|
+
onChange: (s) => {
|
|
130
|
+
b(e, s), m && t && setTimeout(() => _(e), 0);
|
|
131
|
+
},
|
|
132
|
+
onBlur: () => {
|
|
133
|
+
i((s) => ({
|
|
134
|
+
...s,
|
|
135
|
+
fields: {
|
|
136
|
+
...s.fields,
|
|
137
|
+
[e]: {
|
|
138
|
+
...s.fields[e],
|
|
139
|
+
touched: !0
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
})), h && t && _(e);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}, [o.fields, n, b, _, m, h]), j = u(
|
|
146
|
+
(e) => async (t) => {
|
|
147
|
+
if (t.preventDefault(), i((f) => ({ ...f, isSubmitting: !0, isSubmitted: !0 })), !await O()) {
|
|
148
|
+
i((f) => ({ ...f, isSubmitting: !1 })), l == null || l(o.errors);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const s = Object.fromEntries(
|
|
152
|
+
Object.entries(o.fields).map(([f, d]) => [f, d.value])
|
|
153
|
+
);
|
|
154
|
+
try {
|
|
155
|
+
await e(s);
|
|
156
|
+
} finally {
|
|
157
|
+
i((f) => ({ ...f, isSubmitting: !1 }));
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
[O, o.fields, o.errors, l]
|
|
161
|
+
), C = q(
|
|
162
|
+
() => ({
|
|
163
|
+
state: o,
|
|
164
|
+
register: R,
|
|
165
|
+
setValue: b,
|
|
166
|
+
getValue: c,
|
|
167
|
+
setError: y,
|
|
168
|
+
clearError: A,
|
|
169
|
+
validateField: _,
|
|
170
|
+
validateForm: O,
|
|
171
|
+
reset: L,
|
|
172
|
+
handleSubmit: j,
|
|
173
|
+
layout: F
|
|
174
|
+
}),
|
|
175
|
+
[o, R, b, c, y, A, _, O, L, j, F]
|
|
176
|
+
);
|
|
177
|
+
return /* @__PURE__ */ g(D.Provider, { value: C, children: /* @__PURE__ */ g(
|
|
178
|
+
"form",
|
|
179
|
+
{
|
|
180
|
+
className: E("Bear-Form", U[F], N),
|
|
181
|
+
onSubmit: x ? j(x) : void 0,
|
|
182
|
+
"data-testid": S,
|
|
183
|
+
...v,
|
|
184
|
+
children: I
|
|
185
|
+
}
|
|
186
|
+
) });
|
|
187
|
+
}, Z = ({
|
|
188
|
+
name: I,
|
|
189
|
+
label: n,
|
|
190
|
+
required: x,
|
|
191
|
+
rules: l,
|
|
192
|
+
helperText: F,
|
|
193
|
+
children: m,
|
|
194
|
+
className: h
|
|
195
|
+
}) => {
|
|
196
|
+
const { register: N, state: S, layout: v } = H(), o = {
|
|
197
|
+
...l,
|
|
198
|
+
required: x ?? (l == null ? void 0 : l.required)
|
|
199
|
+
}, i = N(I, o), a = S.fields[I], b = (a == null ? void 0 : a.touched) && (a == null ? void 0 : a.error);
|
|
200
|
+
return /* @__PURE__ */ B("div", { className: E("Bear-FormItem", p[v], h), children: [
|
|
201
|
+
n && /* @__PURE__ */ B(
|
|
202
|
+
"label",
|
|
203
|
+
{
|
|
204
|
+
className: E(
|
|
205
|
+
"Bear-FormItem__label bear-text-sm bear-font-medium bear-text-zinc-300",
|
|
206
|
+
v === "horizontal" && Y
|
|
207
|
+
),
|
|
208
|
+
children: [
|
|
209
|
+
n,
|
|
210
|
+
(x || (l == null ? void 0 : l.required)) && /* @__PURE__ */ g("span", { className: "Bear-FormItem__required bear-text-red-500 bear-ml-0.5", children: "*" })
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
/* @__PURE__ */ B("div", { className: "Bear-FormItem__content bear-flex-1", children: [
|
|
215
|
+
/* @__PURE__ */ g("div", { className: "Bear-FormItem__control", children: typeof m == "function" ? m(i) : z(m) ? k(m, {
|
|
216
|
+
...i,
|
|
217
|
+
onChange: (c) => {
|
|
218
|
+
const y = c && typeof c == "object" && "target" in c && c.target && typeof c.target.value < "u" ? c.target.value : c;
|
|
219
|
+
i.onChange(y);
|
|
220
|
+
}
|
|
221
|
+
}) : m }),
|
|
222
|
+
b && /* @__PURE__ */ g("p", { className: "Bear-FormItem__error bear-mt-1 bear-text-xs bear-text-red-400", children: a.error }),
|
|
223
|
+
F && !b && /* @__PURE__ */ g("p", { className: "Bear-FormItem__helper bear-mt-1 bear-text-xs bear-text-zinc-500", children: F })
|
|
224
|
+
] })
|
|
225
|
+
] });
|
|
226
|
+
};
|
|
227
|
+
W.Item = Z;
|
|
228
|
+
export {
|
|
229
|
+
W as Form
|
|
230
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { ReactNode, FormHTMLAttributes } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Validation rule types
|
|
4
|
+
*/
|
|
5
|
+
export type ValidationRule = {
|
|
6
|
+
/** Required field validation */
|
|
7
|
+
required?: boolean | string;
|
|
8
|
+
/** Minimum length validation */
|
|
9
|
+
minLength?: {
|
|
10
|
+
value: number;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
/** Maximum length validation */
|
|
14
|
+
maxLength?: {
|
|
15
|
+
value: number;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
/** Minimum value validation (for numbers) */
|
|
19
|
+
min?: {
|
|
20
|
+
value: number;
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
/** Maximum value validation (for numbers) */
|
|
24
|
+
max?: {
|
|
25
|
+
value: number;
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
/** Pattern validation (regex) */
|
|
29
|
+
pattern?: {
|
|
30
|
+
value: RegExp;
|
|
31
|
+
message: string;
|
|
32
|
+
};
|
|
33
|
+
/** Custom validation function */
|
|
34
|
+
validate?: (value: unknown) => boolean | string | Promise<boolean | string>;
|
|
35
|
+
/** Email validation */
|
|
36
|
+
email?: boolean | string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Form field state
|
|
40
|
+
*/
|
|
41
|
+
export interface FormFieldState {
|
|
42
|
+
/** Current value */
|
|
43
|
+
value: unknown;
|
|
44
|
+
/** Error message if validation failed */
|
|
45
|
+
error?: string;
|
|
46
|
+
/** Whether field has been touched */
|
|
47
|
+
touched: boolean;
|
|
48
|
+
/** Whether field is currently being validated */
|
|
49
|
+
validating: boolean;
|
|
50
|
+
/** Whether field is dirty (value changed) */
|
|
51
|
+
dirty: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Form state
|
|
55
|
+
*/
|
|
56
|
+
export interface FormState {
|
|
57
|
+
/** Field states by name */
|
|
58
|
+
fields: Record<string, FormFieldState>;
|
|
59
|
+
/** Whether form is currently submitting */
|
|
60
|
+
isSubmitting: boolean;
|
|
61
|
+
/** Whether form is valid */
|
|
62
|
+
isValid: boolean;
|
|
63
|
+
/** Whether form has been submitted */
|
|
64
|
+
isSubmitted: boolean;
|
|
65
|
+
/** Form-level errors */
|
|
66
|
+
errors: Record<string, string>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Form context value
|
|
70
|
+
*/
|
|
71
|
+
export interface FormContextValue {
|
|
72
|
+
/** Current form state */
|
|
73
|
+
state: FormState;
|
|
74
|
+
/** Register a field */
|
|
75
|
+
register: (name: string, rules?: ValidationRule) => {
|
|
76
|
+
name: string;
|
|
77
|
+
value: unknown;
|
|
78
|
+
onChange: (value: unknown) => void;
|
|
79
|
+
onBlur: () => void;
|
|
80
|
+
};
|
|
81
|
+
/** Set field value */
|
|
82
|
+
setValue: (name: string, value: unknown) => void;
|
|
83
|
+
/** Get field value */
|
|
84
|
+
getValue: (name: string) => unknown;
|
|
85
|
+
/** Set field error */
|
|
86
|
+
setError: (name: string, error: string) => void;
|
|
87
|
+
/** Clear field error */
|
|
88
|
+
clearError: (name: string) => void;
|
|
89
|
+
/** Validate a field */
|
|
90
|
+
validateField: (name: string) => Promise<boolean>;
|
|
91
|
+
/** Validate all fields */
|
|
92
|
+
validateForm: () => Promise<boolean>;
|
|
93
|
+
/** Reset form */
|
|
94
|
+
reset: (values?: Record<string, unknown>) => void;
|
|
95
|
+
/** Handle form submission */
|
|
96
|
+
handleSubmit: (onSubmit: (data: Record<string, unknown>) => void | Promise<void>) => (e: React.FormEvent) => void;
|
|
97
|
+
/** Form layout */
|
|
98
|
+
layout: FormLayout;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Form layout options
|
|
102
|
+
*/
|
|
103
|
+
export type FormLayout = 'vertical' | 'horizontal' | 'inline';
|
|
104
|
+
/**
|
|
105
|
+
* Form component props
|
|
106
|
+
*/
|
|
107
|
+
export interface FormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, 'onSubmit' | 'onError'> {
|
|
108
|
+
/** Child elements */
|
|
109
|
+
children: ReactNode;
|
|
110
|
+
/** Initial form values */
|
|
111
|
+
initialValues?: Record<string, unknown>;
|
|
112
|
+
/** Form submission handler */
|
|
113
|
+
onSubmit?: (data: Record<string, unknown>) => void | Promise<void>;
|
|
114
|
+
/** Form validation error handler */
|
|
115
|
+
onError?: (errors: Record<string, string>) => void;
|
|
116
|
+
/** Form layout */
|
|
117
|
+
layout?: FormLayout;
|
|
118
|
+
/** Whether to validate on change */
|
|
119
|
+
validateOnChange?: boolean;
|
|
120
|
+
/** Whether to validate on blur */
|
|
121
|
+
validateOnBlur?: boolean;
|
|
122
|
+
/** Custom class name */
|
|
123
|
+
className?: string;
|
|
124
|
+
/** Test ID */
|
|
125
|
+
testId?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Field props from register
|
|
129
|
+
*/
|
|
130
|
+
export interface FormFieldProps {
|
|
131
|
+
name: string;
|
|
132
|
+
value: unknown;
|
|
133
|
+
onChange: (value: unknown) => void;
|
|
134
|
+
onBlur: () => void;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Form.Item props
|
|
138
|
+
*/
|
|
139
|
+
export interface FormItemProps {
|
|
140
|
+
/** Field name */
|
|
141
|
+
name: string;
|
|
142
|
+
/** Field label */
|
|
143
|
+
label?: string;
|
|
144
|
+
/** Required indicator */
|
|
145
|
+
required?: boolean;
|
|
146
|
+
/** Validation rules */
|
|
147
|
+
rules?: ValidationRule;
|
|
148
|
+
/** Helper text */
|
|
149
|
+
helperText?: string;
|
|
150
|
+
/** Children (form control or render prop) */
|
|
151
|
+
children: ReactNode | ((field: FormFieldProps) => ReactNode);
|
|
152
|
+
/** Custom class name */
|
|
153
|
+
className?: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Form translations
|
|
157
|
+
*/
|
|
158
|
+
export interface FormTranslations {
|
|
159
|
+
required: string;
|
|
160
|
+
email: string;
|
|
161
|
+
minLength: string;
|
|
162
|
+
maxLength: string;
|
|
163
|
+
min: string;
|
|
164
|
+
max: string;
|
|
165
|
+
pattern: string;
|
|
166
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./Form.const.cjs"),r=async(i,t)=>{const n=typeof i=="string"?i:String(i??""),e=typeof i=="number"?i:Number(i);if(t.required&&(i==null||n.trim()===""))return typeof t.required=="string"?t.required:m.FORM_DEFAULT_TRANSLATIONS.required;if(i==null||n==="")return null;if(t.email&&!m.EMAIL_REGEX.test(n))return typeof t.email=="string"?t.email:m.FORM_DEFAULT_TRANSLATIONS.email;if(t.minLength&&n.length<t.minLength.value)return t.minLength.message;if(t.maxLength&&n.length>t.maxLength.value)return t.maxLength.message;if(t.min&&!isNaN(e)&&e<t.min.value)return t.min.message;if(t.max&&!isNaN(e)&&e>t.max.value)return t.max.message;if(t.pattern&&!t.pattern.value.test(n))return t.pattern.message;if(t.validate){const a=await t.validate(i);if(typeof a=="string")return a;if(a===!1)return m.FORM_DEFAULT_TRANSLATIONS.pattern}return null};exports.validateFieldValue=r;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ValidationRule } from './Form.types';
|
|
2
|
+
/**
|
|
3
|
+
* Validate a single field value against rules
|
|
4
|
+
*/
|
|
5
|
+
export declare const validateFieldValue: (value: unknown, rules: ValidationRule) => Promise<string | null>;
|
|
6
|
+
/**
|
|
7
|
+
* Deep clone an object
|
|
8
|
+
*/
|
|
9
|
+
export declare const deepClone: <T>(obj: T) => T;
|
|
10
|
+
/**
|
|
11
|
+
* Get nested value from object by path
|
|
12
|
+
*/
|
|
13
|
+
export declare const getNestedValue: (obj: Record<string, unknown>, path: string) => unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Set nested value in object by path
|
|
16
|
+
*/
|
|
17
|
+
export declare const setNestedValue: (obj: Record<string, unknown>, path: string, value: unknown) => Record<string, unknown>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FORM_DEFAULT_TRANSLATIONS as m, EMAIL_REGEX as f } from "./Form.const.js";
|
|
2
|
+
const g = async (i, t) => {
|
|
3
|
+
const n = typeof i == "string" ? i : String(i ?? ""), e = typeof i == "number" ? i : Number(i);
|
|
4
|
+
if (t.required && (i == null || n.trim() === ""))
|
|
5
|
+
return typeof t.required == "string" ? t.required : m.required;
|
|
6
|
+
if (i == null || n === "")
|
|
7
|
+
return null;
|
|
8
|
+
if (t.email && !f.test(n))
|
|
9
|
+
return typeof t.email == "string" ? t.email : m.email;
|
|
10
|
+
if (t.minLength && n.length < t.minLength.value)
|
|
11
|
+
return t.minLength.message;
|
|
12
|
+
if (t.maxLength && n.length > t.maxLength.value)
|
|
13
|
+
return t.maxLength.message;
|
|
14
|
+
if (t.min && !isNaN(e) && e < t.min.value)
|
|
15
|
+
return t.min.message;
|
|
16
|
+
if (t.max && !isNaN(e) && e > t.max.value)
|
|
17
|
+
return t.max.message;
|
|
18
|
+
if (t.pattern && !t.pattern.value.test(n))
|
|
19
|
+
return t.pattern.message;
|
|
20
|
+
if (t.validate) {
|
|
21
|
+
const a = await t.validate(i);
|
|
22
|
+
if (typeof a == "string")
|
|
23
|
+
return a;
|
|
24
|
+
if (a === !1)
|
|
25
|
+
return m.pattern;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
g as validateFieldValue
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),q=require("react-dom"),c=require("../../utils/cn.cjs"),m=require("./NotificationCenter.const.cjs"),F=require("./NotificationCenter.utils.cjs"),W=({notification:r,onRead:d,onDismiss:g,onClick:b,translations:v})=>{const p=()=>{r.read||d==null||d(r.id),b==null||b(r)};return e.jsxs("div",{onClick:p,className:c.cn("Bear-NotificationCenter__item bear-flex bear-gap-3 bear-p-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700 last:bear-border-b-0 bear-cursor-pointer bear-transition-colors hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700/50",!r.read&&"bear-bg-gray-50 dark:bear-bg-zinc-800/50"),children:[e.jsx("div",{className:"Bear-NotificationCenter__item-icon bear-shrink-0",children:r.avatar?e.jsx("img",{src:r.avatar,alt:"",className:"bear-w-10 bear-h-10 bear-rounded-full bear-object-cover"}):r.icon?e.jsx("div",{className:c.cn("bear-w-10 bear-h-10 bear-rounded-full bear-flex bear-items-center bear-justify-center",m.NOTIFICATION_TYPE_COLORS[r.type]),children:r.icon}):e.jsxs("div",{className:c.cn("bear-w-10 bear-h-10 bear-rounded-full bear-flex bear-items-center bear-justify-center",m.NOTIFICATION_TYPE_COLORS[r.type]),children:[r.type==="success"&&e.jsx("svg",{className:"bear-w-5 bear-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),r.type==="error"&&e.jsx("svg",{className:"bear-w-5 bear-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),r.type==="warning"&&e.jsx("svg",{className:"bear-w-5 bear-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),r.type==="info"&&e.jsx("svg",{className:"bear-w-5 bear-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})]})}),e.jsxs("div",{className:"Bear-NotificationCenter__item-content bear-flex-1 bear-min-w-0",children:[e.jsxs("div",{className:"bear-flex bear-items-start bear-justify-between bear-gap-2",children:[e.jsx("p",{className:c.cn("Bear-NotificationCenter__item-title bear-text-sm bear-font-medium bear-truncate",r.read?"bear-text-gray-600 dark:bear-text-zinc-300":"bear-text-gray-900 dark:bear-text-white"),children:r.title}),!r.read&&e.jsx("span",{className:"Bear-NotificationCenter__item-badge bear-w-2 bear-h-2 bear-rounded-full bear-bg-pink-500 bear-shrink-0 bear-mt-1.5"})]}),r.description&&e.jsx("p",{className:"Bear-NotificationCenter__item-description bear-text-xs bear-text-gray-500 dark:bear-text-zinc-400 bear-mt-0.5 bear-line-clamp-2",children:r.description}),e.jsx("p",{className:"Bear-NotificationCenter__item-time bear-text-xs bear-text-gray-400 dark:bear-text-zinc-500 bear-mt-1",children:F.formatRelativeTime(r.timestamp,v)}),r.actions&&r.actions.length>0&&e.jsx("div",{className:"Bear-NotificationCenter__item-actions bear-flex bear-gap-2 bear-mt-2",children:r.actions.map((a,j)=>e.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),a.onClick()},className:c.cn("bear-px-2 bear-py-1 bear-text-xs bear-rounded bear-transition-colors",a.variant==="primary"&&"bear-bg-pink-500 bear-text-white hover:bear-bg-pink-600",a.variant==="secondary"&&"bear-bg-gray-200 dark:bear-bg-zinc-600 bear-text-gray-900 dark:bear-text-white hover:bear-bg-gray-300 dark:hover:bear-bg-zinc-500",a.variant==="danger"&&"bear-bg-red-500 bear-text-white hover:bear-bg-red-600",!a.variant&&"bear-bg-gray-100 dark:bear-bg-zinc-700 bear-text-gray-700 dark:bear-text-zinc-300 hover:bear-bg-gray-200 dark:hover:bear-bg-zinc-600"),children:a.label},j))})]}),g&&e.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),g(r.id)},className:"Bear-NotificationCenter__item-dismiss bear-p-1 bear-rounded bear-text-gray-500 dark:bear-text-zinc-500 hover:bear-text-gray-700 dark:hover:bear-text-zinc-300 hover:bear-bg-gray-200 dark:hover:bear-bg-zinc-700 bear-transition-colors bear-shrink-0",children:e.jsx("svg",{className:"bear-w-4 bear-h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},D=({notifications:r,onNotificationClick:d,onMarkAsRead:g,onMarkAllAsRead:b,onDismiss:v,onClearAll:p,maxVisible:a=m.NOTIFICATION_CENTER_MAX_VISIBLE,groupByCategory:j=!1,position:x="top-right",trigger:C,open:I,onOpenChange:T,className:O,testId:E,translations:_,icon:M})=>{const[A,R]=n.useState(!1),[w,S]=n.useState({top:0,left:0}),[f,P]=n.useState(!1),B=n.useRef(null),y=n.useRef(null),h=I??A,N=T??R,o=n.useMemo(()=>({...m.NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS,..._}),[_]),i=n.useMemo(()=>r.filter(t=>!t.read).length,[r]),z=n.useMemo(()=>f?r:r.slice(0,a),[r,a,f]);n.useEffect(()=>{if(h&&y.current){const t=y.current.getBoundingClientRect(),k=window.scrollY||document.documentElement.scrollTop,s=window.scrollX||document.documentElement.scrollLeft;let u=t.bottom+k+8,l=t.left+s;x.includes("left")?l=t.left+s:l=t.right+s-360,x.includes("bottom")&&(u=t.top+k-8),S({top:u,left:Math.max(8,l)})}},[h,x]),n.useEffect(()=>{const t=k=>{var u,l;const s=k.target;(u=B.current)!=null&&u.contains(s)||(l=s.closest)!=null&&l.call(s,"[data-bear-notification-center]")||N(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[N]);const L=n.useCallback(()=>{N(!h)},[h,N]);return e.jsxs("div",{ref:B,className:c.cn("Bear-NotificationCenter bear-relative bear-inline-block",O),"data-testid":E,children:[C?e.jsx("div",{onClick:L,children:C}):e.jsxs("button",{ref:y,type:"button",onClick:L,className:"Bear-NotificationCenter__trigger bear-relative bear-p-2 bear-rounded-lg bear-text-gray-500 dark:bear-text-zinc-400 hover:bear-text-gray-900 dark:hover:bear-text-white hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-800 bear-transition-colors",children:[M??e.jsx("svg",{className:"bear-w-6 bear-h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"})}),i>0&&e.jsx("span",{className:"Bear-NotificationCenter__badge bear-absolute bear-top-0 bear-right-0 bear-w-5 bear-h-5 bear-flex bear-items-center bear-justify-center bear-text-xs bear-font-medium bear-text-white bear-bg-pink-500 bear-rounded-full",children:i>99?"99+":i})]}),h&&typeof document<"u"&&q.createPortal(e.jsxs("div",{"data-bear-notification-center":!0,className:"Bear-NotificationCenter__dropdown bear-fixed bear-w-[360px] bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-lg bear-shadow-xl bear-overflow-hidden",style:{top:w.top,left:w.left,zIndex:m.NOTIFICATION_CENTER_Z_INDEX},children:[e.jsxs("div",{className:"Bear-NotificationCenter__header bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700",children:[e.jsxs("h3",{className:"Bear-NotificationCenter__title bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white",children:[o.title,i>0&&e.jsxs("span",{className:"bear-ml-2 bear-text-xs bear-font-normal bear-text-gray-500 dark:bear-text-zinc-400",children:["(",i," ",o.new.toLowerCase(),")"]})]}),e.jsxs("div",{className:"bear-flex bear-gap-2",children:[b&&i>0&&e.jsx("button",{type:"button",onClick:b,className:"Bear-NotificationCenter__mark-all bear-text-xs bear-text-pink-400 hover:bear-text-pink-300 bear-transition-colors",children:o.markAllRead}),p&&r.length>0&&e.jsx("button",{type:"button",onClick:p,className:"Bear-NotificationCenter__clear-all bear-text-xs bear-text-gray-500 dark:bear-text-zinc-400 hover:bear-text-gray-700 dark:hover:bear-text-zinc-300 bear-transition-colors",children:o.clearAll})]})]}),e.jsx("div",{className:"Bear-NotificationCenter__list bear-max-h-[400px] bear-overflow-y-auto",children:z.length===0?e.jsx("div",{className:"Bear-NotificationCenter__empty bear-py-8 bear-text-center bear-text-sm bear-text-gray-500 dark:bear-text-zinc-500",children:o.noNotifications}):z.map(t=>e.jsx(W,{notification:t,onRead:g,onDismiss:v,onClick:d,translations:o},t.id))}),!f&&r.length>a&&e.jsx("div",{className:"Bear-NotificationCenter__footer bear-border-t bear-border-gray-200 dark:bear-border-zinc-700",children:e.jsxs("button",{type:"button",onClick:()=>P(!0),className:"bear-w-full bear-py-2 bear-text-sm bear-text-pink-500 dark:bear-text-pink-400 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700/50 bear-transition-colors",children:[o.showMore," (",r.length-a," more)"]})})]}),document.body)]})};exports.NotificationCenter=D;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={title:"Notifications",noNotifications:"No notifications",markAllRead:"Mark all as read",clearAll:"Clear all",showMore:"Show more",justNow:"Just now",minutesAgo:"{count}m ago",hoursAgo:"{count}h ago",daysAgo:"{count}d ago",new:"New"},T=5,o=9999,I={info:"bear-text-blue-400 bear-bg-blue-500/20",success:"bear-text-green-400 bear-bg-green-500/20",warning:"bear-text-amber-400 bear-bg-amber-500/20",error:"bear-text-red-400 bear-bg-red-500/20"},N={MINUTE:60*1e3,HOUR:3600*1e3,DAY:1440*60*1e3};exports.NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS=e;exports.NOTIFICATION_CENTER_MAX_VISIBLE=T;exports.NOTIFICATION_CENTER_Z_INDEX=o;exports.NOTIFICATION_TYPE_COLORS=I;exports.TIME_THRESHOLDS=N;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NotificationCenterTranslations, NotificationType } from './NotificationCenter.types';
|
|
2
|
+
/**
|
|
3
|
+
* Default translations
|
|
4
|
+
*/
|
|
5
|
+
export declare const NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS: NotificationCenterTranslations;
|
|
6
|
+
/**
|
|
7
|
+
* Maximum visible notifications default
|
|
8
|
+
*/
|
|
9
|
+
export declare const NOTIFICATION_CENTER_MAX_VISIBLE = 5;
|
|
10
|
+
/**
|
|
11
|
+
* Dropdown z-index
|
|
12
|
+
*/
|
|
13
|
+
export declare const NOTIFICATION_CENTER_Z_INDEX = 9999;
|
|
14
|
+
/**
|
|
15
|
+
* Type icon colors
|
|
16
|
+
*/
|
|
17
|
+
export declare const NOTIFICATION_TYPE_COLORS: Record<NotificationType, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Time thresholds for relative time formatting (in ms)
|
|
20
|
+
*/
|
|
21
|
+
export declare const TIME_THRESHOLDS: {
|
|
22
|
+
readonly MINUTE: number;
|
|
23
|
+
readonly HOUR: number;
|
|
24
|
+
readonly DAY: number;
|
|
25
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
title: "Notifications",
|
|
3
|
+
noNotifications: "No notifications",
|
|
4
|
+
markAllRead: "Mark all as read",
|
|
5
|
+
clearAll: "Clear all",
|
|
6
|
+
showMore: "Show more",
|
|
7
|
+
justNow: "Just now",
|
|
8
|
+
minutesAgo: "{count}m ago",
|
|
9
|
+
hoursAgo: "{count}h ago",
|
|
10
|
+
daysAgo: "{count}d ago",
|
|
11
|
+
new: "New"
|
|
12
|
+
}, o = 5, t = 9999, a = {
|
|
13
|
+
info: "bear-text-blue-400 bear-bg-blue-500/20",
|
|
14
|
+
success: "bear-text-green-400 bear-bg-green-500/20",
|
|
15
|
+
warning: "bear-text-amber-400 bear-bg-amber-500/20",
|
|
16
|
+
error: "bear-text-red-400 bear-bg-red-500/20"
|
|
17
|
+
}, r = {
|
|
18
|
+
MINUTE: 60 * 1e3,
|
|
19
|
+
HOUR: 3600 * 1e3,
|
|
20
|
+
DAY: 1440 * 60 * 1e3
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
e as NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS,
|
|
24
|
+
o as NOTIFICATION_CENTER_MAX_VISIBLE,
|
|
25
|
+
t as NOTIFICATION_CENTER_Z_INDEX,
|
|
26
|
+
a as NOTIFICATION_TYPE_COLORS,
|
|
27
|
+
r as TIME_THRESHOLDS
|
|
28
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { NotificationCenterProps } from './NotificationCenter.types';
|
|
3
|
+
/**
|
|
4
|
+
* NotificationCenter - Notification management component
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <NotificationCenter
|
|
9
|
+
* notifications={notifications}
|
|
10
|
+
* onMarkAsRead={handleMarkAsRead}
|
|
11
|
+
* onDismiss={handleDismiss}
|
|
12
|
+
* />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const NotificationCenter: FC<NotificationCenterProps>;
|