@forgedevstack/bear 1.1.3 → 1.1.4
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/ActionIcon/ActionIcon.cjs +1 -0
- package/dist/components/ActionIcon/ActionIcon.const.cjs +1 -0
- package/dist/components/ActionIcon/ActionIcon.const.d.ts +7 -0
- package/dist/components/ActionIcon/ActionIcon.const.js +68 -0
- package/dist/components/ActionIcon/ActionIcon.d.ts +4 -0
- package/dist/components/ActionIcon/ActionIcon.js +42 -0
- package/dist/components/ActionIcon/ActionIcon.types.d.ts +11 -0
- package/dist/components/ActionIcon/index.d.ts +2 -0
- package/dist/components/Affix/Affix.cjs +1 -0
- package/dist/components/Affix/Affix.const.cjs +1 -0
- package/dist/components/Affix/Affix.const.d.ts +6 -0
- package/dist/components/Affix/Affix.const.js +9 -0
- package/dist/components/Affix/Affix.d.ts +4 -0
- package/dist/components/Affix/Affix.js +69 -0
- package/dist/components/Affix/Affix.types.d.ts +10 -0
- package/dist/components/Affix/index.d.ts +2 -0
- package/dist/components/Anchor/Anchor.cjs +1 -0
- package/dist/components/Anchor/Anchor.const.cjs +1 -0
- package/dist/components/Anchor/Anchor.const.d.ts +9 -0
- package/dist/components/Anchor/Anchor.const.js +11 -0
- package/dist/components/Anchor/Anchor.d.ts +4 -0
- package/dist/components/Anchor/Anchor.js +91 -0
- package/dist/components/Anchor/Anchor.types.d.ts +16 -0
- package/dist/components/Anchor/index.d.ts +2 -0
- package/dist/components/Blockquote/Blockquote.cjs +1 -0
- package/dist/components/Blockquote/Blockquote.const.cjs +1 -0
- package/dist/components/Blockquote/Blockquote.const.d.ts +5 -0
- package/dist/components/Blockquote/Blockquote.const.js +19 -0
- package/dist/components/Blockquote/Blockquote.d.ts +4 -0
- package/dist/components/Blockquote/Blockquote.js +56 -0
- package/dist/components/Blockquote/Blockquote.types.d.ts +9 -0
- package/dist/components/Blockquote/index.d.ts +2 -0
- package/dist/components/CheckboxCard/CheckboxCard.cjs +1 -0
- package/dist/components/CheckboxCard/CheckboxCard.const.cjs +1 -0
- package/dist/components/CheckboxCard/CheckboxCard.const.d.ts +7 -0
- package/dist/components/CheckboxCard/CheckboxCard.const.js +22 -0
- package/dist/components/CheckboxCard/CheckboxCard.d.ts +5 -0
- package/dist/components/CheckboxCard/CheckboxCard.js +132 -0
- package/dist/components/CheckboxCard/CheckboxCard.types.d.ts +21 -0
- package/dist/components/CheckboxCard/index.d.ts +2 -0
- package/dist/components/ColorPicker/ColorPicker.cjs +1 -1
- package/dist/components/ColorPicker/ColorPicker.const.cjs +1 -0
- package/dist/components/ColorPicker/ColorPicker.const.d.ts +26 -0
- package/dist/components/ColorPicker/ColorPicker.const.js +38 -0
- package/dist/components/ColorPicker/ColorPicker.js +61 -78
- package/dist/components/ColorSwatch/ColorSwatch.cjs +1 -0
- package/dist/components/ColorSwatch/ColorSwatch.const.cjs +1 -0
- package/dist/components/ColorSwatch/ColorSwatch.const.d.ts +16 -0
- package/dist/components/ColorSwatch/ColorSwatch.const.js +19 -0
- package/dist/components/ColorSwatch/ColorSwatch.d.ts +5 -0
- package/dist/components/ColorSwatch/ColorSwatch.js +92 -0
- package/dist/components/ColorSwatch/ColorSwatch.types.d.ts +23 -0
- package/dist/components/ColorSwatch/ColorSwatch.utils.cjs +1 -0
- package/dist/components/ColorSwatch/ColorSwatch.utils.d.ts +6 -0
- package/dist/components/ColorSwatch/ColorSwatch.utils.js +14 -0
- package/dist/components/ColorSwatch/index.d.ts +2 -0
- package/dist/components/ContextMenu/ContextMenu.cjs +1 -0
- package/dist/components/ContextMenu/ContextMenu.const.cjs +1 -0
- package/dist/components/ContextMenu/ContextMenu.const.d.ts +9 -0
- package/dist/components/ContextMenu/ContextMenu.const.js +12 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +4 -0
- package/dist/components/ContextMenu/ContextMenu.js +64 -0
- package/dist/components/ContextMenu/ContextMenu.types.d.ts +23 -0
- package/dist/components/ContextMenu/index.d.ts +2 -0
- package/dist/components/DateRangePicker/DateRangePicker.cjs +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.const.cjs +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.const.d.ts +27 -0
- package/dist/components/DateRangePicker/DateRangePicker.const.js +74 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +4 -0
- package/dist/components/DateRangePicker/DateRangePicker.js +115 -0
- package/dist/components/DateRangePicker/DateRangePicker.types.d.ts +26 -0
- package/dist/components/DateRangePicker/DateRangePicker.utils.cjs +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.utils.d.ts +4 -0
- package/dist/components/DateRangePicker/DateRangePicker.utils.js +22 -0
- package/dist/components/DateRangePicker/index.d.ts +2 -0
- package/dist/components/Descriptions/Descriptions.cjs +1 -0
- package/dist/components/Descriptions/Descriptions.const.cjs +1 -0
- package/dist/components/Descriptions/Descriptions.const.d.ts +24 -0
- package/dist/components/Descriptions/Descriptions.const.js +27 -0
- package/dist/components/Descriptions/Descriptions.d.ts +4 -0
- package/dist/components/Descriptions/Descriptions.js +65 -0
- package/dist/components/Descriptions/Descriptions.types.d.ts +16 -0
- package/dist/components/Descriptions/index.d.ts +2 -0
- package/dist/components/Fieldset/Fieldset.cjs +1 -0
- package/dist/components/Fieldset/Fieldset.const.cjs +1 -0
- package/dist/components/Fieldset/Fieldset.const.d.ts +5 -0
- package/dist/components/Fieldset/Fieldset.const.js +16 -0
- package/dist/components/Fieldset/Fieldset.d.ts +4 -0
- package/dist/components/Fieldset/Fieldset.js +47 -0
- package/dist/components/Fieldset/Fieldset.types.d.ts +10 -0
- package/dist/components/Fieldset/index.d.ts +2 -0
- package/dist/components/ImageGallery/ImageGallery.cjs +1 -0
- package/dist/components/ImageGallery/ImageGallery.const.cjs +1 -0
- package/dist/components/ImageGallery/ImageGallery.const.d.ts +13 -0
- package/dist/components/ImageGallery/ImageGallery.const.js +16 -0
- package/dist/components/ImageGallery/ImageGallery.d.ts +4 -0
- package/dist/components/ImageGallery/ImageGallery.js +61 -0
- package/dist/components/ImageGallery/ImageGallery.types.d.ts +22 -0
- package/dist/components/ImageGallery/index.d.ts +2 -0
- package/dist/components/Indicator/Indicator.cjs +1 -0
- package/dist/components/Indicator/Indicator.const.cjs +1 -0
- package/dist/components/Indicator/Indicator.const.d.ts +15 -0
- package/dist/components/Indicator/Indicator.const.js +26 -0
- package/dist/components/Indicator/Indicator.d.ts +4 -0
- package/dist/components/Indicator/Indicator.js +56 -0
- package/dist/components/Indicator/Indicator.types.d.ts +16 -0
- package/dist/components/Indicator/index.d.ts +2 -0
- package/dist/components/InfiniteScroll/InfiniteScroll.cjs +1 -0
- package/dist/components/InfiniteScroll/InfiniteScroll.const.cjs +1 -0
- package/dist/components/InfiniteScroll/InfiniteScroll.const.d.ts +7 -0
- package/dist/components/InfiniteScroll/InfiniteScroll.const.js +10 -0
- package/dist/components/InfiniteScroll/InfiniteScroll.d.ts +4 -0
- package/dist/components/InfiniteScroll/InfiniteScroll.js +51 -0
- package/dist/components/InfiniteScroll/InfiniteScroll.types.d.ts +13 -0
- package/dist/components/InfiniteScroll/index.d.ts +2 -0
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +99 -66
- package/dist/components/Input/Input.types.d.ts +10 -0
- package/dist/components/Input/Input.utils.cjs +1 -0
- package/dist/components/Input/Input.utils.d.ts +2 -0
- package/dist/components/Input/Input.utils.js +15 -0
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/LoadingOverlay/LoadingOverlay.cjs +1 -0
- package/dist/components/LoadingOverlay/LoadingOverlay.const.cjs +1 -0
- package/dist/components/LoadingOverlay/LoadingOverlay.const.d.ts +6 -0
- package/dist/components/LoadingOverlay/LoadingOverlay.const.js +9 -0
- package/dist/components/LoadingOverlay/LoadingOverlay.d.ts +4 -0
- package/dist/components/LoadingOverlay/LoadingOverlay.js +42 -0
- package/dist/components/LoadingOverlay/LoadingOverlay.types.d.ts +11 -0
- package/dist/components/LoadingOverlay/index.d.ts +2 -0
- package/dist/components/NumberFormatter/NumberFormatter.cjs +1 -0
- package/dist/components/NumberFormatter/NumberFormatter.const.cjs +1 -0
- package/dist/components/NumberFormatter/NumberFormatter.const.d.ts +5 -0
- package/dist/components/NumberFormatter/NumberFormatter.const.js +8 -0
- package/dist/components/NumberFormatter/NumberFormatter.d.ts +4 -0
- package/dist/components/NumberFormatter/NumberFormatter.js +53 -0
- package/dist/components/NumberFormatter/NumberFormatter.types.d.ts +20 -0
- package/dist/components/NumberFormatter/NumberFormatter.utils.cjs +1 -0
- package/dist/components/NumberFormatter/NumberFormatter.utils.d.ts +2 -0
- package/dist/components/NumberFormatter/NumberFormatter.utils.js +19 -0
- package/dist/components/NumberFormatter/index.d.ts +2 -0
- package/dist/components/Popconfirm/Popconfirm.cjs +1 -0
- package/dist/components/Popconfirm/Popconfirm.const.cjs +1 -0
- package/dist/components/Popconfirm/Popconfirm.const.d.ts +13 -0
- package/dist/components/Popconfirm/Popconfirm.const.js +20 -0
- package/dist/components/Popconfirm/Popconfirm.d.ts +4 -0
- package/dist/components/Popconfirm/Popconfirm.js +65 -0
- package/dist/components/Popconfirm/Popconfirm.types.d.ts +16 -0
- package/dist/components/Popconfirm/index.d.ts +2 -0
- package/dist/components/RadioCard/RadioCard.cjs +1 -0
- package/dist/components/RadioCard/RadioCard.const.cjs +1 -0
- package/dist/components/RadioCard/RadioCard.const.d.ts +7 -0
- package/dist/components/RadioCard/RadioCard.const.js +22 -0
- package/dist/components/RadioCard/RadioCard.d.ts +5 -0
- package/dist/components/RadioCard/RadioCard.js +111 -0
- package/dist/components/RadioCard/RadioCard.types.d.ts +22 -0
- package/dist/components/RadioCard/index.d.ts +2 -0
- package/dist/components/Result/Result.cjs +1 -0
- package/dist/components/Result/Result.const.cjs +1 -0
- package/dist/components/Result/Result.const.d.ts +10 -0
- package/dist/components/Result/Result.const.js +20 -0
- package/dist/components/Result/Result.d.ts +4 -0
- package/dist/components/Result/Result.icons.cjs +1 -0
- package/dist/components/Result/Result.icons.d.ts +3 -0
- package/dist/components/Result/Result.icons.js +31 -0
- package/dist/components/Result/Result.js +35 -0
- package/dist/components/Result/Result.types.d.ts +10 -0
- package/dist/components/Result/index.d.ts +2 -0
- package/dist/components/RingProgress/RingProgress.cjs +1 -0
- package/dist/components/RingProgress/RingProgress.const.cjs +1 -0
- package/dist/components/RingProgress/RingProgress.const.d.ts +4 -0
- package/dist/components/RingProgress/RingProgress.const.js +7 -0
- package/dist/components/RingProgress/RingProgress.d.ts +4 -0
- package/dist/components/RingProgress/RingProgress.js +67 -0
- package/dist/components/RingProgress/RingProgress.types.d.ts +15 -0
- package/dist/components/RingProgress/index.d.ts +2 -0
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.const.cjs +1 -1
- package/dist/components/SignPad/SignPad.const.js +10 -11
- package/dist/components/SignPad/SignPad.d.ts +4 -6
- package/dist/components/SignPad/SignPad.js +108 -116
- package/dist/components/SignPad/SignPad.types.d.ts +2 -2
- package/dist/components/SplitButton/SplitButton.cjs +1 -0
- package/dist/components/SplitButton/SplitButton.const.cjs +1 -0
- package/dist/components/SplitButton/SplitButton.const.d.ts +25 -0
- package/dist/components/SplitButton/SplitButton.const.js +27 -0
- package/dist/components/SplitButton/SplitButton.d.ts +4 -0
- package/dist/components/SplitButton/SplitButton.js +73 -0
- package/dist/components/SplitButton/SplitButton.types.d.ts +21 -0
- package/dist/components/SplitButton/index.d.ts +2 -0
- package/dist/components/Spoiler/Spoiler.cjs +1 -0
- package/dist/components/Spoiler/Spoiler.const.cjs +1 -0
- package/dist/components/Spoiler/Spoiler.const.d.ts +6 -0
- package/dist/components/Spoiler/Spoiler.const.js +9 -0
- package/dist/components/Spoiler/Spoiler.d.ts +4 -0
- package/dist/components/Spoiler/Spoiler.js +59 -0
- package/dist/components/Spoiler/Spoiler.types.d.ts +10 -0
- package/dist/components/Spoiler/index.d.ts +2 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -1
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +63 -57
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -1
- package/dist/components/TimePicker/helpers/ClockFaceSvg.d.ts +0 -7
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +32 -31
- package/dist/components/TreeSelect/TreeSelect.cjs +1 -0
- package/dist/components/TreeSelect/TreeSelect.const.cjs +1 -0
- package/dist/components/TreeSelect/TreeSelect.const.d.ts +19 -0
- package/dist/components/TreeSelect/TreeSelect.const.js +22 -0
- package/dist/components/TreeSelect/TreeSelect.d.ts +4 -0
- package/dist/components/TreeSelect/TreeSelect.js +128 -0
- package/dist/components/TreeSelect/TreeSelect.types.d.ts +25 -0
- package/dist/components/TreeSelect/TreeSelect.utils.cjs +1 -0
- package/dist/components/TreeSelect/TreeSelect.utils.d.ts +5 -0
- package/dist/components/TreeSelect/TreeSelect.utils.js +25 -0
- package/dist/components/TreeSelect/index.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +44 -0
- package/dist/components/index.js +353 -306
- package/dist/index.cjs +1 -1
- package/dist/index.js +439 -392
- package/dist/postcss/bear-plugin.cjs +86 -0
- package/dist/styles/_alerts.css +14 -0
- package/dist/styles/_base.css +56 -0
- package/dist/styles/_buttons.css +108 -0
- package/dist/styles/_effects.css +90 -0
- package/dist/styles/_marquee.css +25 -0
- package/dist/styles/main.css +5 -0
- package/dist/styles.css +1 -1
- package/package.json +10 -3
|
@@ -1,94 +1,127 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { BearContext as
|
|
5
|
-
import { ClearIcon as
|
|
6
|
-
|
|
1
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ae, useContext as te, useState as se, useRef as be, useCallback as B, useEffect as le } from "react";
|
|
3
|
+
import { cn as f } from "../../utils/cn.js";
|
|
4
|
+
import { BearContext as ne } from "../../context/BearProvider.js";
|
|
5
|
+
import { ClearIcon as D } from "./components/ClearIcon/ClearIcon.js";
|
|
6
|
+
import { applyAutoFormat as ce } from "./Input.utils.js";
|
|
7
|
+
import { validateFieldValue as ie } from "../Form/Form.utils.js";
|
|
8
|
+
const ue = {
|
|
7
9
|
sm: "bear-h-8 bear-text-sm bear-px-3",
|
|
8
10
|
md: "bear-h-10 bear-text-base bear-px-4",
|
|
9
11
|
lg: "bear-h-12 bear-text-lg bear-px-5"
|
|
10
|
-
},
|
|
12
|
+
}, oe = ae(
|
|
11
13
|
({
|
|
12
|
-
label:
|
|
13
|
-
helperText:
|
|
14
|
-
error:
|
|
15
|
-
success:
|
|
16
|
-
size:
|
|
17
|
-
leftAddon:
|
|
18
|
-
rightAddon:
|
|
19
|
-
fullWidth:
|
|
20
|
-
clearable:
|
|
21
|
-
onClear:
|
|
22
|
-
showCharCount:
|
|
23
|
-
charCountMax:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
14
|
+
label: k,
|
|
15
|
+
helperText: F,
|
|
16
|
+
error: d,
|
|
17
|
+
success: N,
|
|
18
|
+
size: G = "md",
|
|
19
|
+
leftAddon: p,
|
|
20
|
+
rightAddon: b,
|
|
21
|
+
fullWidth: H = !1,
|
|
22
|
+
clearable: J = !1,
|
|
23
|
+
onClear: w,
|
|
24
|
+
showCharCount: v = !1,
|
|
25
|
+
charCountMax: K,
|
|
26
|
+
autoFormat: g,
|
|
27
|
+
validation: a,
|
|
28
|
+
validateOnBlur: Q,
|
|
29
|
+
validateOnChange: E = !1,
|
|
30
|
+
className: T,
|
|
31
|
+
disabled: x,
|
|
32
|
+
value: _,
|
|
33
|
+
defaultValue: y,
|
|
34
|
+
maxLength: j,
|
|
35
|
+
onChange: l,
|
|
36
|
+
onBlur: n,
|
|
37
|
+
...U
|
|
38
|
+
}, W) => {
|
|
39
|
+
var q;
|
|
40
|
+
const h = te(ne), e = (q = h == null ? void 0 : h.components) == null ? void 0 : q.Input, X = e == null ? void 0 : e.root, Y = e == null ? void 0 : e.input, Z = e == null ? void 0 : e.label, $ = e == null ? void 0 : e.helper, P = e == null ? void 0 : e.prefix, M = e == null ? void 0 : e.suffix, [S, R] = se(null), z = be(!1), C = a ? Q ?? !0 : !1, L = d || S, c = !!L, O = !!N && !c, i = K ?? j, m = typeof _ == "string" ? _.length : typeof y == "string" ? y.length : 0, A = i != null && m > i, I = J && !x && m > 0, V = L || N || F, u = B(async (r) => {
|
|
41
|
+
if (!a) return;
|
|
42
|
+
z.current = !0;
|
|
43
|
+
const o = await ie(r, a);
|
|
44
|
+
z.current = !1, R(o);
|
|
45
|
+
}, [a]);
|
|
46
|
+
le(() => {
|
|
47
|
+
d && R(null);
|
|
48
|
+
}, [d]);
|
|
49
|
+
const ee = B(
|
|
50
|
+
(r) => {
|
|
51
|
+
if (g) {
|
|
52
|
+
const o = ce(r.target.value, g);
|
|
53
|
+
o !== r.target.value && (r.target.value = o);
|
|
54
|
+
}
|
|
55
|
+
l == null || l(r), E && a && u(r.target.value);
|
|
56
|
+
},
|
|
57
|
+
[g, l, E, a, u]
|
|
58
|
+
), re = B(
|
|
59
|
+
(r) => {
|
|
60
|
+
n == null || n(r), C && a && u(r.target.value);
|
|
61
|
+
},
|
|
62
|
+
[n, C, a, u]
|
|
63
|
+
);
|
|
64
|
+
return /* @__PURE__ */ s("div", { className: f("Bear-Input bear-flex bear-flex-col bear-gap-1.5", H && "bear-w-full"), style: X, children: [
|
|
65
|
+
k && /* @__PURE__ */ t("label", { className: "Bear-Input__label bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-300", style: Z, children: k }),
|
|
66
|
+
/* @__PURE__ */ s("div", { className: "Bear-Input__wrapper bear-relative bear-flex bear-items-center", children: [
|
|
67
|
+
p && /* @__PURE__ */ t("div", { className: "Bear-Input__addon Bear-Input__addon--left bear-absolute bear-left-3 bear-text-gray-500 dark:bear-text-gray-400", style: P, children: p }),
|
|
68
|
+
/* @__PURE__ */ t(
|
|
38
69
|
"input",
|
|
39
70
|
{
|
|
40
|
-
ref:
|
|
41
|
-
disabled:
|
|
42
|
-
value:
|
|
43
|
-
defaultValue:
|
|
44
|
-
maxLength:
|
|
45
|
-
"aria-invalid":
|
|
46
|
-
|
|
71
|
+
ref: W,
|
|
72
|
+
disabled: x,
|
|
73
|
+
value: _,
|
|
74
|
+
defaultValue: y,
|
|
75
|
+
maxLength: j,
|
|
76
|
+
"aria-invalid": c || void 0,
|
|
77
|
+
onChange: ee,
|
|
78
|
+
onBlur: re,
|
|
79
|
+
className: f(
|
|
47
80
|
"Bear-Input__field",
|
|
48
81
|
"bear-w-full bear-rounded-lg bear-border bear-outline-none bear-transition-all bear-duration-200",
|
|
49
82
|
"bear-bg-white bear-text-gray-900 placeholder:bear-text-gray-400",
|
|
50
83
|
"bear-border-gray-300 focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-white",
|
|
51
84
|
"dark:bear-bg-gray-800 dark:bear-text-white dark:placeholder:bear-text-gray-500 dark:bear-border-gray-600 dark:focus:bear-ring-offset-gray-900",
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
85
|
+
c ? "Bear-Input__field--error bear-border-red-500 focus:bear-ring-red-500" : O ? "Bear-Input__field--success bear-border-green-500 focus:bear-ring-green-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",
|
|
86
|
+
x && "Bear-Input__field--disabled bear-opacity-50 bear-cursor-not-allowed",
|
|
87
|
+
p && "bear-pl-10",
|
|
88
|
+
(b || I) && "bear-pr-10",
|
|
89
|
+
ue[G],
|
|
90
|
+
T
|
|
58
91
|
),
|
|
59
|
-
style:
|
|
60
|
-
...
|
|
92
|
+
style: Y,
|
|
93
|
+
...U
|
|
61
94
|
}
|
|
62
95
|
),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
96
|
+
I && !b && /* @__PURE__ */ t("div", { className: "Bear-Input__addon Bear-Input__addon--right bear-absolute bear-right-3 bear-text-gray-500 dark:bear-text-gray-400", style: M, children: /* @__PURE__ */ t(D, { onClick: w }) }),
|
|
97
|
+
b && /* @__PURE__ */ s("div", { className: "Bear-Input__addon Bear-Input__addon--right bear-absolute bear-right-3 bear-flex bear-items-center bear-gap-1.5 bear-text-gray-500 dark:bear-text-gray-400", style: M, children: [
|
|
98
|
+
I && /* @__PURE__ */ t(D, { onClick: w }),
|
|
99
|
+
b
|
|
67
100
|
] })
|
|
68
101
|
] }),
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
|
|
102
|
+
/* @__PURE__ */ s("div", { className: "Bear-Input__footer bear-flex bear-items-center bear-justify-between bear-gap-2", children: [
|
|
103
|
+
V ? /* @__PURE__ */ t(
|
|
71
104
|
"p",
|
|
72
105
|
{
|
|
73
|
-
className:
|
|
106
|
+
className: f(
|
|
74
107
|
"Bear-Input__helper bear-text-sm bear-flex-1",
|
|
75
|
-
|
|
108
|
+
c ? "Bear-Input__helper--error bear-text-red-500" : O ? "Bear-Input__helper--success bear-text-green-500" : "bear-text-gray-500 dark:bear-text-gray-400"
|
|
76
109
|
),
|
|
77
|
-
style:
|
|
78
|
-
children:
|
|
110
|
+
style: $,
|
|
111
|
+
children: V
|
|
79
112
|
}
|
|
80
|
-
) :
|
|
81
|
-
|
|
113
|
+
) : v ? /* @__PURE__ */ t("span", {}) : null,
|
|
114
|
+
v && i != null && /* @__PURE__ */ s(
|
|
82
115
|
"span",
|
|
83
116
|
{
|
|
84
|
-
className:
|
|
117
|
+
className: f(
|
|
85
118
|
"Bear-Input__char-count bear-text-xs bear-tabular-nums bear-shrink-0",
|
|
86
|
-
|
|
119
|
+
A ? "bear-text-red-500" : "bear-text-gray-400 dark:bear-text-gray-500"
|
|
87
120
|
),
|
|
88
121
|
children: [
|
|
89
|
-
|
|
122
|
+
m,
|
|
90
123
|
"/",
|
|
91
|
-
|
|
124
|
+
i
|
|
92
125
|
]
|
|
93
126
|
}
|
|
94
127
|
)
|
|
@@ -96,7 +129,7 @@ const P = {
|
|
|
96
129
|
] });
|
|
97
130
|
}
|
|
98
131
|
);
|
|
99
|
-
|
|
132
|
+
oe.displayName = "Input";
|
|
100
133
|
export {
|
|
101
|
-
|
|
134
|
+
oe as Input
|
|
102
135
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { ValidationRule } from '../Form/Form.types';
|
|
3
|
+
export type AutoFormatType = 'capitalize' | 'uppercase' | 'lowercase' | 'titleCase' | 'sentenceCase' | 'none';
|
|
2
4
|
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
3
5
|
/** Input label */
|
|
4
6
|
label?: string;
|
|
@@ -24,4 +26,12 @@ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
24
26
|
showCharCount?: boolean;
|
|
25
27
|
/** Max chars for counter display (alternative to maxLength when you don't want native enforcement) */
|
|
26
28
|
charCountMax?: number;
|
|
29
|
+
/** Auto-format text on change using Anvil string utils */
|
|
30
|
+
autoFormat?: AutoFormatType;
|
|
31
|
+
/** Validation rules (reuses Form's ValidationRule) */
|
|
32
|
+
validation?: ValidationRule;
|
|
33
|
+
/** Run validation on blur (default true when validation is set) */
|
|
34
|
+
validateOnBlur?: boolean;
|
|
35
|
+
/** Run validation on change */
|
|
36
|
+
validateOnChange?: boolean;
|
|
27
37
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@forgedevstack/anvil"),n=e=>e.toUpperCase(),a=e=>e.toLowerCase(),r={capitalize:o.capitalize,uppercase:n,lowercase:a,titleCase:o.titleCase,sentenceCase:o.sentenceCase},c=(e,t)=>{if(!t||t==="none")return e;const s=r[t];return s?s(e):e};exports.applyAutoFormat=c;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { sentenceCase as s, titleCase as n, capitalize as r } from "@forgedevstack/anvil";
|
|
2
|
+
const p = (e) => e.toUpperCase(), c = (e) => e.toLowerCase(), a = {
|
|
3
|
+
capitalize: r,
|
|
4
|
+
uppercase: p,
|
|
5
|
+
lowercase: c,
|
|
6
|
+
titleCase: n,
|
|
7
|
+
sentenceCase: s
|
|
8
|
+
}, i = (e, t) => {
|
|
9
|
+
if (!t || t === "none") return e;
|
|
10
|
+
const o = a[t];
|
|
11
|
+
return o ? o(e) : e;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
i as applyAutoFormat
|
|
15
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Input } from './Input';
|
|
2
|
-
export type { InputProps } from './Input.types';
|
|
2
|
+
export type { InputProps, AutoFormatType } from './Input.types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),u=require("../../utils/cn.cjs");require("react");const y=require("../Typography/Typography.cjs"),A=require("../Spinner/Spinner.cjs"),e=require("./LoadingOverlay.const.cjs"),S={sm:"sm",md:"md",lg:"lg"},_=({visible:a,loader:t,overlayOpacity:n=e.DEFAULT_OVERLAY_OPACITY,overlayBlur:i=e.DEFAULT_OVERLAY_BLUR,zIndex:c=e.DEFAULT_Z_INDEX,loaderSize:o="md",label:s,children:d,className:l,testId:p,...L})=>r.jsxs("div",{className:u.cn(e.ROOT_CLASS,l),"data-testid":p,...L,children:[d,a&&r.jsxs("div",{className:e.OVERLAY_CLASS,style:{opacity:n,backdropFilter:`blur(${i}px)`,WebkitBackdropFilter:`blur(${i}px)`,zIndex:c},"aria-busy":!0,"aria-live":"polite",children:[t??r.jsx(A.Spinner,{size:S[o],className:"bear-text-pink-500 dark:bear-text-pink-400"}),s&&r.jsx(y.Typography,{variant:"body2",color:"secondary",className:e.LABEL_CLASS,children:s})]})]});exports.LoadingOverlay=_;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=.5,a=2,r=10,L="Bear-LoadingOverlay bear-relative",t="bear-absolute bear-inset-0 bear-flex bear-flex-col bear-items-center bear-justify-center bear-transition-opacity bear-duration-200 bear-bg-white/50 dark:bear-bg-zinc-900/50",A="Bear-LoadingOverlay__label bear-mt-2";exports.DEFAULT_OVERLAY_BLUR=a;exports.DEFAULT_OVERLAY_OPACITY=e;exports.DEFAULT_Z_INDEX=r;exports.LABEL_CLASS=A;exports.OVERLAY_CLASS=t;exports.ROOT_CLASS=L;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const DEFAULT_OVERLAY_OPACITY = 0.5;
|
|
2
|
+
export declare const DEFAULT_OVERLAY_BLUR = 2;
|
|
3
|
+
export declare const DEFAULT_Z_INDEX = 10;
|
|
4
|
+
export declare const ROOT_CLASS = "Bear-LoadingOverlay bear-relative";
|
|
5
|
+
export declare const OVERLAY_CLASS = "bear-absolute bear-inset-0 bear-flex bear-flex-col bear-items-center bear-justify-center bear-transition-opacity bear-duration-200 bear-bg-white/50 dark:bear-bg-zinc-900/50";
|
|
6
|
+
export declare const LABEL_CLASS = "Bear-LoadingOverlay__label bear-mt-2";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const e = 0.5, a = 2, r = 10, t = "Bear-LoadingOverlay bear-relative", b = "bear-absolute bear-inset-0 bear-flex bear-flex-col bear-items-center bear-justify-center bear-transition-opacity bear-duration-200 bear-bg-white/50 dark:bear-bg-zinc-900/50", n = "Bear-LoadingOverlay__label bear-mt-2";
|
|
2
|
+
export {
|
|
3
|
+
a as DEFAULT_OVERLAY_BLUR,
|
|
4
|
+
e as DEFAULT_OVERLAY_OPACITY,
|
|
5
|
+
r as DEFAULT_Z_INDEX,
|
|
6
|
+
n as LABEL_CLASS,
|
|
7
|
+
b as OVERLAY_CLASS,
|
|
8
|
+
t as ROOT_CLASS
|
|
9
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsxs as t, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { cn as L } from "../../utils/cn.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import { Typography as A } from "../Typography/Typography.js";
|
|
5
|
+
import { Spinner as _ } from "../Spinner/Spinner.js";
|
|
6
|
+
import { DEFAULT_Z_INDEX as E, DEFAULT_OVERLAY_BLUR as S, DEFAULT_OVERLAY_OPACITY as b, OVERLAY_CLASS as x, LABEL_CLASS as y, ROOT_CLASS as N } from "./LoadingOverlay.const.js";
|
|
7
|
+
const O = { sm: "sm", md: "md", lg: "lg" }, h = ({
|
|
8
|
+
visible: e,
|
|
9
|
+
loader: o,
|
|
10
|
+
overlayOpacity: m = b,
|
|
11
|
+
overlayBlur: r = S,
|
|
12
|
+
zIndex: s = E,
|
|
13
|
+
loaderSize: p = "md",
|
|
14
|
+
label: i,
|
|
15
|
+
children: d,
|
|
16
|
+
className: c,
|
|
17
|
+
testId: l,
|
|
18
|
+
...n
|
|
19
|
+
}) => /* @__PURE__ */ t("div", { className: L(N, c), "data-testid": l, ...n, children: [
|
|
20
|
+
d,
|
|
21
|
+
e && /* @__PURE__ */ t(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
className: x,
|
|
25
|
+
style: {
|
|
26
|
+
opacity: m,
|
|
27
|
+
backdropFilter: `blur(${r}px)`,
|
|
28
|
+
WebkitBackdropFilter: `blur(${r}px)`,
|
|
29
|
+
zIndex: s
|
|
30
|
+
},
|
|
31
|
+
"aria-busy": !0,
|
|
32
|
+
"aria-live": "polite",
|
|
33
|
+
children: [
|
|
34
|
+
o ?? /* @__PURE__ */ a(_, { size: O[p], className: "bear-text-pink-500 dark:bear-text-pink-400" }),
|
|
35
|
+
i && /* @__PURE__ */ a(A, { variant: "body2", color: "secondary", className: y, children: i })
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
] });
|
|
40
|
+
export {
|
|
41
|
+
h as LoadingOverlay
|
|
42
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes } from 'react';
|
|
2
|
+
export interface LoadingOverlayProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
loader?: ReactNode;
|
|
5
|
+
overlayOpacity?: number;
|
|
6
|
+
overlayBlur?: number;
|
|
7
|
+
zIndex?: number;
|
|
8
|
+
loaderSize?: 'sm' | 'md' | 'lg';
|
|
9
|
+
label?: string;
|
|
10
|
+
testId?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),r=require("react"),T=require("../../utils/cn.cjs"),u=require("./NumberFormatter.const.cjs"),_=require("./NumberFormatter.utils.cjs"),g=t=>{const{value:e,prefix:A="",suffix:F="",animated:c=!1,animationDuration:o=u.DEFAULT_ANIMATION_DURATION,className:N,testId:y,...D}=t,M=r.useMemo(()=>_.buildFormatter(t),[t.formatStyle,t.locale,t.currency,t.currencyDisplay,t.unit,t.unitDisplay,t.notation,t.minimumFractionDigits,t.maximumFractionDigits,t.signDisplay]),[R,n]=r.useState(e),a=r.useRef(e),i=r.useRef(0);r.useEffect(()=>{if(!c){n(e),a.current=e;return}const m=a.current,l=e-m;if(l===0)return;const f=Math.max(1,Math.round(o/u.ANIMATION_FRAME_RATE));let s=0;const d=()=>{s++;const q=s/f,I=1-Math.pow(1-q,3);n(m+l*I),s<f?i.current=requestAnimationFrame(d):(n(e),a.current=e)};return i.current=requestAnimationFrame(d),()=>cancelAnimationFrame(i.current)},[e,c,o]);const b=M.format(R);return S.jsxs("span",{className:T.cn(u.ROOT_CLASSES,N),"data-testid":y,...D,children:[A,b,F]})};exports.NumberFormatter=g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A="en-US",T="USD",E=400,e=16,t="Bear-NumberFormatter bear-inline bear-tabular-nums";exports.ANIMATION_FRAME_RATE=e;exports.DEFAULT_ANIMATION_DURATION=E;exports.DEFAULT_CURRENCY=T;exports.DEFAULT_LOCALE=A;exports.ROOT_CLASSES=t;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const DEFAULT_LOCALE = "en-US";
|
|
2
|
+
export declare const DEFAULT_CURRENCY = "USD";
|
|
3
|
+
export declare const DEFAULT_ANIMATION_DURATION = 400;
|
|
4
|
+
export declare const ANIMATION_FRAME_RATE = 16;
|
|
5
|
+
export declare const ROOT_CLASSES = "Bear-NumberFormatter bear-inline bear-tabular-nums";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsxs as E } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as O, useState as R, useRef as l, useEffect as S } from "react";
|
|
3
|
+
import { cn as _ } from "../../utils/cn.js";
|
|
4
|
+
import { DEFAULT_ANIMATION_DURATION as g, ROOT_CLASSES as h, ANIMATION_FRAME_RATE as V } from "./NumberFormatter.const.js";
|
|
5
|
+
import { buildFormatter as b } from "./NumberFormatter.utils.js";
|
|
6
|
+
const k = (t) => {
|
|
7
|
+
const {
|
|
8
|
+
value: e,
|
|
9
|
+
prefix: d = "",
|
|
10
|
+
suffix: A = "",
|
|
11
|
+
animated: m = !1,
|
|
12
|
+
animationDuration: s = g,
|
|
13
|
+
className: D,
|
|
14
|
+
testId: F,
|
|
15
|
+
...y
|
|
16
|
+
} = t, N = O(() => b(t), [
|
|
17
|
+
t.formatStyle,
|
|
18
|
+
t.locale,
|
|
19
|
+
t.currency,
|
|
20
|
+
t.currencyDisplay,
|
|
21
|
+
t.unit,
|
|
22
|
+
t.unitDisplay,
|
|
23
|
+
t.notation,
|
|
24
|
+
t.minimumFractionDigits,
|
|
25
|
+
t.maximumFractionDigits,
|
|
26
|
+
t.signDisplay
|
|
27
|
+
]), [I, r] = R(e), n = l(e), a = l(0);
|
|
28
|
+
S(() => {
|
|
29
|
+
if (!m) {
|
|
30
|
+
r(e), n.current = e;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const c = n.current, o = e - c;
|
|
34
|
+
if (o === 0) return;
|
|
35
|
+
const u = Math.max(1, Math.round(s / V));
|
|
36
|
+
let i = 0;
|
|
37
|
+
const f = () => {
|
|
38
|
+
i++;
|
|
39
|
+
const x = i / u, T = 1 - Math.pow(1 - x, 3);
|
|
40
|
+
r(c + o * T), i < u ? a.current = requestAnimationFrame(f) : (r(e), n.current = e);
|
|
41
|
+
};
|
|
42
|
+
return a.current = requestAnimationFrame(f), () => cancelAnimationFrame(a.current);
|
|
43
|
+
}, [e, m, s]);
|
|
44
|
+
const M = N.format(I);
|
|
45
|
+
return /* @__PURE__ */ E("span", { className: _(h, D), "data-testid": F, ...y, children: [
|
|
46
|
+
d,
|
|
47
|
+
M,
|
|
48
|
+
A
|
|
49
|
+
] });
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
k as NumberFormatter
|
|
53
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export type NumberFormatStyle = 'decimal' | 'currency' | 'percent' | 'compact' | 'unit';
|
|
3
|
+
export interface NumberFormatterProps extends HTMLAttributes<HTMLSpanElement> {
|
|
4
|
+
value: number;
|
|
5
|
+
formatStyle?: NumberFormatStyle;
|
|
6
|
+
locale?: string;
|
|
7
|
+
currency?: string;
|
|
8
|
+
currencyDisplay?: 'symbol' | 'code' | 'name' | 'narrowSymbol';
|
|
9
|
+
unit?: string;
|
|
10
|
+
unitDisplay?: 'short' | 'long' | 'narrow';
|
|
11
|
+
notation?: 'standard' | 'scientific' | 'engineering' | 'compact';
|
|
12
|
+
minimumFractionDigits?: number;
|
|
13
|
+
maximumFractionDigits?: number;
|
|
14
|
+
signDisplay?: 'auto' | 'never' | 'always' | 'exceptZero';
|
|
15
|
+
prefix?: string;
|
|
16
|
+
suffix?: string;
|
|
17
|
+
animated?: boolean;
|
|
18
|
+
animationDuration?: number;
|
|
19
|
+
testId?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./NumberFormatter.const.cjs"),p=m=>{const{formatStyle:t="decimal",locale:s=u.DEFAULT_LOCALE,currency:l=u.DEFAULT_CURRENCY,currencyDisplay:e,unit:n,unitDisplay:r,notation:c,minimumFractionDigits:o,maximumFractionDigits:a,signDisplay:y}=m,i={signDisplay:y};return t==="currency"?(i.style="currency",i.currency=l,e&&(i.currencyDisplay=e)):t==="percent"?i.style="percent":t==="compact"?i.notation="compact":t==="unit"&&n&&(i.style="unit",i.unit=n,r&&(i.unitDisplay=r)),c&&t!=="compact"&&(i.notation=c),o!==void 0&&(i.minimumFractionDigits=o),a!==void 0&&(i.maximumFractionDigits=a),new Intl.NumberFormat(s,i)};exports.buildFormatter=p;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DEFAULT_LOCALE as y, DEFAULT_CURRENCY as p } from "./NumberFormatter.const.js";
|
|
2
|
+
const D = (m) => {
|
|
3
|
+
const {
|
|
4
|
+
formatStyle: t = "decimal",
|
|
5
|
+
locale: s = y,
|
|
6
|
+
currency: u = p,
|
|
7
|
+
currencyDisplay: n,
|
|
8
|
+
unit: c,
|
|
9
|
+
unitDisplay: r,
|
|
10
|
+
notation: e,
|
|
11
|
+
minimumFractionDigits: o,
|
|
12
|
+
maximumFractionDigits: a,
|
|
13
|
+
signDisplay: l
|
|
14
|
+
} = m, i = { signDisplay: l };
|
|
15
|
+
return t === "currency" ? (i.style = "currency", i.currency = u, n && (i.currencyDisplay = n)) : t === "percent" ? i.style = "percent" : t === "compact" ? i.notation = "compact" : t === "unit" && c && (i.style = "unit", i.unit = c, r && (i.unitDisplay = r)), e && t !== "compact" && (i.notation = e), o !== void 0 && (i.minimumFractionDigits = o), a !== void 0 && (i.maximumFractionDigits = a), new Intl.NumberFormat(s, i);
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
D as buildFormatter
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),d=require("../../utils/cn.cjs"),S=require("../Typography/Typography.cjs"),n=require("./Popconfirm.const.cjs"),j=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:"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"})}),O=C=>{const{title:N,description:u,onConfirm:a,onCancel:o,confirmText:h=n.DEFAULT_CONFIRM_TEXT,cancelText:T=n.DEFAULT_CANCEL_TEXT,icon:p=j,placement:L="bottom",disabled:m=!1,children:_,variant:f="default",testId:b}=C,[s,E]=c.useState(!1),i=c.useRef(null),t=c.useCallback(()=>E(!1),[]);c.useEffect(()=>{const r=l=>{i.current&&!i.current.contains(l.target)&&t()};return s&&document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[s,t]),c.useEffect(()=>{const r=l=>{l.key==="Escape"&&t()};return s&&document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[s,t]);const v=()=>{m||E(!s)},A=()=>{a==null||a(),t()},x=()=>{o==null||o(),t()},y=f==="danger"?n.CONFIRM_BTN_DANGER_CLASSES:n.CONFIRM_BTN_DEFAULT_CLASSES;return e.jsxs("div",{ref:i,className:d.cn(n.ROOT_CLASS,"bear-relative bear-inline-block"),"data-testid":b,children:[e.jsx("div",{onClick:v,className:d.cn("bear-cursor-pointer",m&&"bear-opacity-50 bear-cursor-not-allowed bear-pointer-events-none"),children:_}),s&&e.jsxs("div",{className:d.cn(n.POPUP_CLASSES,n.PLACEMENT_OFFSETS[L]),children:[e.jsxs("div",{className:n.ICON_AREA_CLASSES,children:[e.jsx("div",{className:n.ICON_WRAPPER_CLASSES,children:p}),e.jsxs("div",{className:n.CONTENT_CLASSES,children:[e.jsx(S.Typography,{variant:"body2",className:"bear-text-gray-900 dark:bear-text-zinc-100",children:N}),u&&e.jsx(S.Typography,{variant:"caption",color:"secondary",className:"bear-mt-0.5",children:u})]})]}),e.jsxs("div",{className:n.BUTTONS_WRAPPER_CLASSES,children:[e.jsx("button",{type:"button",className:n.CANCEL_BTN_CLASSES,onClick:x,children:T}),e.jsx("button",{type:"button",className:y,onClick:A,children:h})]})]})]})};exports.Popconfirm=O;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="Bear-Popconfirm",r="bear-absolute bear-z-[9999] 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-p-4 bear-min-w-[220px] bear-max-w-[320px]",a={top:"bear-bottom-full bear-left-1/2 -bear-translate-x-1/2 bear-mb-2",bottom:"bear-top-full bear-left-1/2 -bear-translate-x-1/2 bear-mt-2",left:"bear-right-full bear-top-1/2 -bear-translate-y-1/2 bear-mr-2",right:"bear-left-full bear-top-1/2 -bear-translate-y-1/2 bear-ml-2"},b="bear-flex bear-items-center bear-gap-3 bear-mb-3",t="bear-flex-shrink-0 bear-w-8 bear-h-8 bear-flex bear-items-center bear-justify-center bear-rounded-full bear-bg-amber-100 dark:bear-bg-amber-900/30 bear-text-amber-600 dark:bear-text-amber-400",S="bear-flex-1 bear-min-w-0",o="bear-flex bear-justify-end bear-gap-2 bear-mt-4",n="bear-px-3 bear-py-1.5 bear-text-sm bear-font-medium bear-rounded-md bear-transition-colors bear-bg-pink-500 bear-text-white hover:bear-bg-pink-600 dark:hover:bear-bg-pink-600",E="bear-px-3 bear-py-1.5 bear-text-sm bear-font-medium bear-rounded-md bear-transition-colors bear-bg-red-500 bear-text-white hover:bear-bg-red-600 dark:hover:bear-bg-red-600",_="bear-px-3 bear-py-1.5 bear-text-sm bear-font-medium bear-rounded-md bear-transition-colors bear-bg-white dark:bear-bg-zinc-700 bear-text-gray-700 dark:bear-text-zinc-300 bear-border bear-border-gray-300 dark:bear-border-zinc-600 hover:bear-bg-gray-50 dark:hover:bear-bg-zinc-600",C="Confirm",A="Cancel";exports.BUTTONS_WRAPPER_CLASSES=o;exports.CANCEL_BTN_CLASSES=_;exports.CONFIRM_BTN_DANGER_CLASSES=E;exports.CONFIRM_BTN_DEFAULT_CLASSES=n;exports.CONTENT_CLASSES=S;exports.DEFAULT_CANCEL_TEXT=A;exports.DEFAULT_CONFIRM_TEXT=C;exports.ICON_AREA_CLASSES=b;exports.ICON_WRAPPER_CLASSES=t;exports.PLACEMENT_OFFSETS=a;exports.POPUP_CLASSES=r;exports.ROOT_CLASS=e;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PopconfirmPlacement } from './Popconfirm.types';
|
|
2
|
+
export declare const ROOT_CLASS = "Bear-Popconfirm";
|
|
3
|
+
export declare const POPUP_CLASSES = "bear-absolute bear-z-[9999] 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-p-4 bear-min-w-[220px] bear-max-w-[320px]";
|
|
4
|
+
export declare const PLACEMENT_OFFSETS: Record<PopconfirmPlacement, string>;
|
|
5
|
+
export declare const ICON_AREA_CLASSES = "bear-flex bear-items-center bear-gap-3 bear-mb-3";
|
|
6
|
+
export declare const ICON_WRAPPER_CLASSES = "bear-flex-shrink-0 bear-w-8 bear-h-8 bear-flex bear-items-center bear-justify-center bear-rounded-full bear-bg-amber-100 dark:bear-bg-amber-900/30 bear-text-amber-600 dark:bear-text-amber-400";
|
|
7
|
+
export declare const CONTENT_CLASSES = "bear-flex-1 bear-min-w-0";
|
|
8
|
+
export declare const BUTTONS_WRAPPER_CLASSES = "bear-flex bear-justify-end bear-gap-2 bear-mt-4";
|
|
9
|
+
export declare const CONFIRM_BTN_DEFAULT_CLASSES = "bear-px-3 bear-py-1.5 bear-text-sm bear-font-medium bear-rounded-md bear-transition-colors bear-bg-pink-500 bear-text-white hover:bear-bg-pink-600 dark:hover:bear-bg-pink-600";
|
|
10
|
+
export declare const CONFIRM_BTN_DANGER_CLASSES = "bear-px-3 bear-py-1.5 bear-text-sm bear-font-medium bear-rounded-md bear-transition-colors bear-bg-red-500 bear-text-white hover:bear-bg-red-600 dark:hover:bear-bg-red-600";
|
|
11
|
+
export declare const CANCEL_BTN_CLASSES = "bear-px-3 bear-py-1.5 bear-text-sm bear-font-medium bear-rounded-md bear-transition-colors bear-bg-white dark:bear-bg-zinc-700 bear-text-gray-700 dark:bear-text-zinc-300 bear-border bear-border-gray-300 dark:bear-border-zinc-600 hover:bear-bg-gray-50 dark:hover:bear-bg-zinc-600";
|
|
12
|
+
export declare const DEFAULT_CONFIRM_TEXT = "Confirm";
|
|
13
|
+
export declare const DEFAULT_CANCEL_TEXT = "Cancel";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const e = "Bear-Popconfirm", r = "bear-absolute bear-z-[9999] 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-p-4 bear-min-w-[220px] bear-max-w-[320px]", a = {
|
|
2
|
+
top: "bear-bottom-full bear-left-1/2 -bear-translate-x-1/2 bear-mb-2",
|
|
3
|
+
bottom: "bear-top-full bear-left-1/2 -bear-translate-x-1/2 bear-mt-2",
|
|
4
|
+
left: "bear-right-full bear-top-1/2 -bear-translate-y-1/2 bear-mr-2",
|
|
5
|
+
right: "bear-left-full bear-top-1/2 -bear-translate-y-1/2 bear-ml-2"
|
|
6
|
+
}, b = "bear-flex bear-items-center bear-gap-3 bear-mb-3", t = "bear-flex-shrink-0 bear-w-8 bear-h-8 bear-flex bear-items-center bear-justify-center bear-rounded-full bear-bg-amber-100 dark:bear-bg-amber-900/30 bear-text-amber-600 dark:bear-text-amber-400", o = "bear-flex-1 bear-min-w-0", n = "bear-flex bear-justify-end bear-gap-2 bear-mt-4", d = "bear-px-3 bear-py-1.5 bear-text-sm bear-font-medium bear-rounded-md bear-transition-colors bear-bg-pink-500 bear-text-white hover:bear-bg-pink-600 dark:hover:bear-bg-pink-600", i = "bear-px-3 bear-py-1.5 bear-text-sm bear-font-medium bear-rounded-md bear-transition-colors bear-bg-red-500 bear-text-white hover:bear-bg-red-600 dark:hover:bear-bg-red-600", s = "bear-px-3 bear-py-1.5 bear-text-sm bear-font-medium bear-rounded-md bear-transition-colors bear-bg-white dark:bear-bg-zinc-700 bear-text-gray-700 dark:bear-text-zinc-300 bear-border bear-border-gray-300 dark:bear-border-zinc-600 hover:bear-bg-gray-50 dark:hover:bear-bg-zinc-600", l = "Confirm", m = "Cancel";
|
|
7
|
+
export {
|
|
8
|
+
n as BUTTONS_WRAPPER_CLASSES,
|
|
9
|
+
s as CANCEL_BTN_CLASSES,
|
|
10
|
+
i as CONFIRM_BTN_DANGER_CLASSES,
|
|
11
|
+
d as CONFIRM_BTN_DEFAULT_CLASSES,
|
|
12
|
+
o as CONTENT_CLASSES,
|
|
13
|
+
m as DEFAULT_CANCEL_TEXT,
|
|
14
|
+
l as DEFAULT_CONFIRM_TEXT,
|
|
15
|
+
b as ICON_AREA_CLASSES,
|
|
16
|
+
t as ICON_WRAPPER_CLASSES,
|
|
17
|
+
a as PLACEMENT_OFFSETS,
|
|
18
|
+
r as POPUP_CLASSES,
|
|
19
|
+
e as ROOT_CLASS
|
|
20
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsxs as a, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useState as R, useRef as y, useCallback as F, useEffect as C } from "react";
|
|
3
|
+
import { cn as l } from "../../utils/cn.js";
|
|
4
|
+
import { Typography as S } from "../Typography/Typography.js";
|
|
5
|
+
import { DEFAULT_CONFIRM_TEXT as P, DEFAULT_CANCEL_TEXT as x, ICON_AREA_CLASSES as I, ICON_WRAPPER_CLASSES as g, CONTENT_CLASSES as w, BUTTONS_WRAPPER_CLASSES as B, CANCEL_BTN_CLASSES as U, CONFIRM_BTN_DANGER_CLASSES as D, CONFIRM_BTN_DEFAULT_CLASSES as M, PLACEMENT_OFFSETS as j, POPUP_CLASSES as W, ROOT_CLASS as z } from "./Popconfirm.const.js";
|
|
6
|
+
const X = /* @__PURE__ */ e("svg", { className: "bear-w-4 bear-h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("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" }) }), Q = (N) => {
|
|
7
|
+
const {
|
|
8
|
+
title: u,
|
|
9
|
+
description: d,
|
|
10
|
+
onConfirm: o,
|
|
11
|
+
onCancel: s,
|
|
12
|
+
confirmText: h = P,
|
|
13
|
+
cancelText: L = x,
|
|
14
|
+
icon: f = X,
|
|
15
|
+
placement: p = "bottom",
|
|
16
|
+
disabled: m = !1,
|
|
17
|
+
children: _,
|
|
18
|
+
variant: T = "default",
|
|
19
|
+
testId: v
|
|
20
|
+
} = N, [n, E] = R(!1), c = y(null), t = F(() => E(!1), []);
|
|
21
|
+
C(() => {
|
|
22
|
+
const r = (i) => {
|
|
23
|
+
c.current && !c.current.contains(i.target) && t();
|
|
24
|
+
};
|
|
25
|
+
return n && document.addEventListener("mousedown", r), () => document.removeEventListener("mousedown", r);
|
|
26
|
+
}, [n, t]), C(() => {
|
|
27
|
+
const r = (i) => {
|
|
28
|
+
i.key === "Escape" && t();
|
|
29
|
+
};
|
|
30
|
+
return n && document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
|
|
31
|
+
}, [n, t]);
|
|
32
|
+
const A = () => {
|
|
33
|
+
m || E(!n);
|
|
34
|
+
}, b = () => {
|
|
35
|
+
o == null || o(), t();
|
|
36
|
+
}, k = () => {
|
|
37
|
+
s == null || s(), t();
|
|
38
|
+
}, O = T === "danger" ? D : M;
|
|
39
|
+
return /* @__PURE__ */ a("div", { ref: c, className: l(z, "bear-relative bear-inline-block"), "data-testid": v, children: [
|
|
40
|
+
/* @__PURE__ */ e(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
onClick: A,
|
|
44
|
+
className: l("bear-cursor-pointer", m && "bear-opacity-50 bear-cursor-not-allowed bear-pointer-events-none"),
|
|
45
|
+
children: _
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
n && /* @__PURE__ */ a("div", { className: l(W, j[p]), children: [
|
|
49
|
+
/* @__PURE__ */ a("div", { className: I, children: [
|
|
50
|
+
/* @__PURE__ */ e("div", { className: g, children: f }),
|
|
51
|
+
/* @__PURE__ */ a("div", { className: w, children: [
|
|
52
|
+
/* @__PURE__ */ e(S, { variant: "body2", className: "bear-text-gray-900 dark:bear-text-zinc-100", children: u }),
|
|
53
|
+
d && /* @__PURE__ */ e(S, { variant: "caption", color: "secondary", className: "bear-mt-0.5", children: d })
|
|
54
|
+
] })
|
|
55
|
+
] }),
|
|
56
|
+
/* @__PURE__ */ a("div", { className: B, children: [
|
|
57
|
+
/* @__PURE__ */ e("button", { type: "button", className: U, onClick: k, children: L }),
|
|
58
|
+
/* @__PURE__ */ e("button", { type: "button", className: O, onClick: b, children: h })
|
|
59
|
+
] })
|
|
60
|
+
] })
|
|
61
|
+
] });
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
Q as Popconfirm
|
|
65
|
+
};
|