@forgedevstack/bear 1.3.3 → 1.3.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/README.md +145 -292
- package/dist/components/AlertDialog/AlertDialog.cjs +1 -1
- package/dist/components/AlertDialog/AlertDialog.js +67 -84
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/BottomSheet/BottomSheet.js +72 -64
- package/dist/components/ChipGroup/ChipGroup.cjs +1 -1
- package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -1
- package/dist/components/ChipGroup/ChipGroup.const.d.ts +2 -0
- package/dist/components/ChipGroup/ChipGroup.const.js +6 -4
- package/dist/components/ChipGroup/ChipGroup.js +52 -48
- package/dist/components/CommandPalette/CommandItem.cjs +1 -0
- package/dist/components/CommandPalette/CommandItem.d.ts +6 -0
- package/dist/components/CommandPalette/CommandItem.js +39 -0
- package/dist/components/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/CommandPalette/CommandPalette.js +129 -144
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +72 -66
- package/dist/components/EmptyState/EmptyState.cjs +1 -1
- package/dist/components/EmptyState/EmptyState.const.cjs +1 -1
- package/dist/components/EmptyState/EmptyState.const.d.ts +5 -0
- package/dist/components/EmptyState/EmptyState.const.js +30 -15
- package/dist/components/EmptyState/EmptyState.js +35 -35
- package/dist/components/EmptyState/EmptyState.types.d.ts +2 -2
- package/dist/components/HoverCard/HoverCard.cjs +4 -3
- package/dist/components/HoverCard/HoverCard.const.cjs +1 -0
- package/dist/components/HoverCard/HoverCard.const.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.const.js +10 -0
- package/dist/components/HoverCard/HoverCard.js +62 -56
- package/dist/components/HoverCard/HoverCard.types.d.ts +7 -0
- package/dist/components/Menu/Menu.cjs +1 -1
- package/dist/components/Menu/Menu.const.cjs +1 -0
- package/dist/components/Menu/Menu.const.d.ts +2 -0
- package/dist/components/Menu/Menu.const.js +12 -0
- package/dist/components/Menu/Menu.d.ts +3 -9
- package/dist/components/Menu/Menu.js +57 -89
- package/dist/components/Menu/Menu.types.d.ts +8 -1
- package/dist/components/Menu/MenuDivider.cjs +1 -0
- package/dist/components/Menu/MenuDivider.d.ts +6 -0
- package/dist/components/Menu/MenuDivider.js +7 -0
- package/dist/components/Menu/MenuItem.cjs +1 -0
- package/dist/components/Menu/MenuItem.d.ts +6 -0
- package/dist/components/Menu/MenuItem.js +46 -0
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.const.cjs +1 -1
- package/dist/components/Modal/Modal.const.d.ts +1 -0
- package/dist/components/Modal/Modal.const.js +20 -12
- package/dist/components/Modal/Modal.js +62 -59
- package/dist/components/Modal/Modal.types.d.ts +7 -0
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.const.cjs +1 -0
- package/dist/components/Popover/Popover.const.d.ts +15 -1
- package/dist/components/Popover/Popover.const.js +29 -0
- package/dist/components/Popover/Popover.js +77 -73
- package/dist/components/Popover/Popover.types.d.ts +7 -0
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.const.cjs +1 -1
- package/dist/components/Select/Select.const.d.ts +1 -0
- package/dist/components/Select/Select.const.js +7 -6
- package/dist/components/Select/Select.js +101 -96
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.const.cjs +1 -1
- package/dist/components/Toast/Toast.const.d.ts +2 -0
- package/dist/components/Toast/Toast.const.js +11 -8
- package/dist/components/Toast/Toast.context.cjs +1 -0
- package/dist/components/Toast/Toast.context.d.ts +3 -0
- package/dist/components/Toast/Toast.context.js +11 -0
- package/dist/components/Toast/Toast.d.ts +4 -3
- package/dist/components/Toast/Toast.icons.cjs +1 -0
- package/dist/components/Toast/Toast.icons.d.ts +4 -0
- package/dist/components/Toast/Toast.icons.js +29 -0
- package/dist/components/Toast/Toast.js +32 -160
- package/dist/components/Toast/ToastContainer.cjs +1 -0
- package/dist/components/Toast/ToastContainer.d.ts +3 -0
- package/dist/components/Toast/ToastContainer.js +39 -0
- package/dist/components/Toast/ToastItem.cjs +1 -0
- package/dist/components/Toast/ToastItem.d.ts +5 -0
- package/dist/components/Toast/ToastItem.js +86 -0
- package/dist/components/ToggleGroup/ToggleGroup.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.const.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.const.d.ts +15 -0
- package/dist/components/ToggleGroup/ToggleGroup.const.js +33 -0
- package/dist/components/ToggleGroup/ToggleGroup.context.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.context.d.ts +2 -0
- package/dist/components/ToggleGroup/ToggleGroup.context.js +5 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +2 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +86 -0
- package/dist/components/ToggleGroup/ToggleGroup.types.d.ts +48 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.d.ts +2 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.js +50 -0
- package/dist/components/ToggleGroup/hooks/useToggleGroupContext.cjs +1 -0
- package/dist/components/ToggleGroup/hooks/useToggleGroupContext.d.ts +1 -0
- package/dist/components/ToggleGroup/hooks/useToggleGroupContext.js +6 -0
- package/dist/components/ToggleGroup/index.d.ts +4 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.const.cjs +1 -0
- package/dist/components/Tooltip/Tooltip.const.d.ts +8 -0
- package/dist/components/Tooltip/Tooltip.const.js +18 -0
- package/dist/components/Tooltip/Tooltip.js +59 -61
- package/dist/components/Tooltip/Tooltip.types.d.ts +7 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +428 -418
- package/dist/constants/numbers.const.cjs +1 -1
- package/dist/constants/numbers.const.d.ts +3 -0
- package/dist/constants/numbers.const.js +37 -34
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +6 -4
- package/dist/hooks/useFocusTrap/index.d.ts +2 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.cjs +1 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.d.ts +3 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.js +41 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.types.d.ts +8 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.utils.cjs +1 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.utils.d.ts +1 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.utils.js +23 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +575 -563
- package/dist/styles.css +52 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),T=require("../Box/Box.cjs"),I=require("../Flex/Flex.cjs"),_=require("../Typography/Typography.cjs"),r=require("../../utils/cn.cjs");require("react");const M=require("../../utils/generateBearId.utils.cjs"),g=require("../../utils/useBearId.cjs"),e=require("./EmptyState.const.cjs"),h=d=>{const{icon:l,title:S,description:c,action:n,secondaryAction:i,className:p,size:m=e.EMPTY_STATE_DEFAULT_SIZE,variant:u=e.EMPTY_STATE_DEFAULT_VARIANT,preset:a=e.EMPTY_STATE_DEFAULT_PRESET,id:y,testId:A}=d,P=g.useBearId(e.COMPONENT_NAME_EMPTY_STATE),B=M.resolveBearId(y,P),s=e.EMPTY_STATE_SIZE_CLASSES[m],N=e.EMPTY_STATE_PRESET_ICON[a],x=l??t.jsx(N,{className:"bear-w-full bear-h-full"}),o=e.EMPTY_STATE_PRESET_DEFAULTS[a]??e.EMPTY_STATE_PRESET_DEFAULTS.empty,E=c!==void 0?c:o.description;return t.jsxs(T.Box,{id:B,"data-testid":A,className:r.cn("Bear-EmptyState",u==="card"&&"Bear-EmptyState--card",`Bear-EmptyState--${a}`,s.padding,p),children:[t.jsx(T.Box,{className:r.cn("Bear-EmptyState__icon",s.icon),children:x}),t.jsx(_.Typography,{className:r.cn("Bear-EmptyState__title",s.title),children:S??o.title}),E&&t.jsx(_.Typography,{className:r.cn("Bear-EmptyState__description",s.desc),children:E}),(n||i)&&t.jsxs(I.Flex,{className:"Bear-EmptyState__actions",align:"center",gap:3,children:[n,i]})]})};exports.EmptyState=h;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../constants/generals.const.cjs"),r=require("./helpers/EmptyStateErrorSvg.cjs"),e=require("./helpers/EmptyStateInboxSvg.cjs"),E=require("./helpers/EmptyStateSearchSvg.cjs"),T=t.SIZE_MD,o=t.VARIANT_DEFAULT,a=t.EMPTY_STATE_PRESET_EMPTY,S="EmptyState",i={[t.EMPTY_STATE_PRESET_EMPTY]:e.EmptyStateInboxSvg,[t.EMPTY_STATE_PRESET_INBOX]:e.EmptyStateInboxSvg,[t.EMPTY_STATE_PRESET_SEARCH]:E.EmptyStateSearchSvg,[t.EMPTY_STATE_PRESET_ERROR]:r.EmptyStateErrorSvg,"no-data":e.EmptyStateInboxSvg,404:E.EmptyStateSearchSvg,offline:r.EmptyStateErrorSvg,"filter-empty":E.EmptyStateSearchSvg},n={empty:{title:"No items yet",description:"Get started by creating your first item."},inbox:{title:"Your inbox is empty",description:"All caught up! Check back later for new messages."},search:{title:"No results found",description:"Try adjusting your search or filter keywords."},error:{title:"Something went wrong",description:"We encountered an error loading this content."},"no-data":{title:"No data available",description:"There is no data to display right now."},404:{title:"Page not found",description:"The requested page or resource could not be located."},offline:{title:"Connection lost",description:"Please check your internet connection and try again."},"filter-empty":{title:"No matching filters",description:"No records match the selected filter criteria."}},_={sm:{icon:"bear-w-12 bear-h-12",title:"bear-text-lg",desc:"bear-text-sm",padding:"bear-py-6 bear-px-4"},md:{icon:"bear-w-16 bear-h-16",title:"bear-text-xl",desc:"bear-text-base",padding:"bear-py-10 bear-px-6"},lg:{icon:"bear-w-20 bear-h-20",title:"bear-text-2xl",desc:"bear-text-lg",padding:"bear-py-14 bear-px-8"}};exports.COMPONENT_NAME_EMPTY_STATE=S;exports.EMPTY_STATE_DEFAULT_PRESET=a;exports.EMPTY_STATE_DEFAULT_SIZE=T;exports.EMPTY_STATE_DEFAULT_VARIANT=o;exports.EMPTY_STATE_PRESET_DEFAULTS=n;exports.EMPTY_STATE_PRESET_ICON=i;exports.EMPTY_STATE_SIZE_CLASSES=_;
|
|
@@ -3,9 +3,14 @@ import { EmptyStatePreset } from './EmptyState.types';
|
|
|
3
3
|
export declare const EMPTY_STATE_DEFAULT_SIZE: "md";
|
|
4
4
|
export declare const EMPTY_STATE_DEFAULT_VARIANT: "default";
|
|
5
5
|
export declare const EMPTY_STATE_DEFAULT_PRESET: EmptyStatePreset;
|
|
6
|
+
export declare const COMPONENT_NAME_EMPTY_STATE = "EmptyState";
|
|
6
7
|
export declare const EMPTY_STATE_PRESET_ICON: Record<EmptyStatePreset, ComponentType<{
|
|
7
8
|
className?: string;
|
|
8
9
|
}>>;
|
|
10
|
+
export declare const EMPTY_STATE_PRESET_DEFAULTS: Record<EmptyStatePreset, {
|
|
11
|
+
title: string;
|
|
12
|
+
description: string;
|
|
13
|
+
}>;
|
|
9
14
|
export declare const EMPTY_STATE_SIZE_CLASSES: {
|
|
10
15
|
readonly sm: {
|
|
11
16
|
readonly icon: "bear-w-12 bear-h-12";
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import { SIZE_MD as
|
|
2
|
-
import { EmptyStateErrorSvg as
|
|
3
|
-
import { EmptyStateInboxSvg as
|
|
4
|
-
import { EmptyStateSearchSvg as
|
|
5
|
-
const
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
|
|
1
|
+
import { SIZE_MD as i, VARIANT_DEFAULT as a, EMPTY_STATE_PRESET_EMPTY as o, EMPTY_STATE_PRESET_ERROR as n, EMPTY_STATE_PRESET_SEARCH as E, EMPTY_STATE_PRESET_INBOX as T } from "../../constants/generals.const.js";
|
|
2
|
+
import { EmptyStateErrorSvg as r } from "./helpers/EmptyStateErrorSvg.js";
|
|
3
|
+
import { EmptyStateInboxSvg as e } from "./helpers/EmptyStateInboxSvg.js";
|
|
4
|
+
import { EmptyStateSearchSvg as t } from "./helpers/EmptyStateSearchSvg.js";
|
|
5
|
+
const S = i, _ = a, p = o, b = "EmptyState", m = {
|
|
6
|
+
[o]: e,
|
|
7
|
+
[T]: e,
|
|
8
|
+
[E]: t,
|
|
9
|
+
[n]: r,
|
|
10
|
+
"no-data": e,
|
|
11
|
+
404: t,
|
|
12
|
+
offline: r,
|
|
13
|
+
"filter-empty": t
|
|
14
|
+
}, A = {
|
|
15
|
+
empty: { title: "No items yet", description: "Get started by creating your first item." },
|
|
16
|
+
inbox: { title: "Your inbox is empty", description: "All caught up! Check back later for new messages." },
|
|
17
|
+
search: { title: "No results found", description: "Try adjusting your search or filter keywords." },
|
|
18
|
+
error: { title: "Something went wrong", description: "We encountered an error loading this content." },
|
|
19
|
+
"no-data": { title: "No data available", description: "There is no data to display right now." },
|
|
20
|
+
404: { title: "Page not found", description: "The requested page or resource could not be located." },
|
|
21
|
+
offline: { title: "Connection lost", description: "Please check your internet connection and try again." },
|
|
22
|
+
"filter-empty": { title: "No matching filters", description: "No records match the selected filter criteria." }
|
|
23
|
+
}, P = {
|
|
11
24
|
sm: {
|
|
12
25
|
icon: "bear-w-12 bear-h-12",
|
|
13
26
|
title: "bear-text-lg",
|
|
@@ -28,9 +41,11 @@ const m = t, i = e, x = T, c = {
|
|
|
28
41
|
}
|
|
29
42
|
};
|
|
30
43
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
b as COMPONENT_NAME_EMPTY_STATE,
|
|
45
|
+
p as EMPTY_STATE_DEFAULT_PRESET,
|
|
46
|
+
S as EMPTY_STATE_DEFAULT_SIZE,
|
|
47
|
+
_ as EMPTY_STATE_DEFAULT_VARIANT,
|
|
48
|
+
A as EMPTY_STATE_PRESET_DEFAULTS,
|
|
49
|
+
m as EMPTY_STATE_PRESET_ICON,
|
|
50
|
+
P as EMPTY_STATE_SIZE_CLASSES
|
|
36
51
|
};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Box as
|
|
3
|
-
import { Flex as
|
|
4
|
-
import { Typography as
|
|
5
|
-
import { cn as
|
|
1
|
+
import { jsxs as m, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { Box as n } from "../Box/Box.js";
|
|
3
|
+
import { Flex as h } from "../Flex/Flex.js";
|
|
4
|
+
import { Typography as T } from "../Typography/Typography.js";
|
|
5
|
+
import { cn as r } from "../../utils/cn.js";
|
|
6
6
|
import "react";
|
|
7
|
-
import { resolveBearId as
|
|
8
|
-
import { useBearId as
|
|
9
|
-
import { EMPTY_STATE_DEFAULT_SIZE as
|
|
10
|
-
const
|
|
7
|
+
import { resolveBearId as Y } from "../../utils/generateBearId.utils.js";
|
|
8
|
+
import { useBearId as g } from "../../utils/useBearId.js";
|
|
9
|
+
import { EMPTY_STATE_DEFAULT_SIZE as u, EMPTY_STATE_DEFAULT_VARIANT as x, EMPTY_STATE_DEFAULT_PRESET as D, COMPONENT_NAME_EMPTY_STATE as F, EMPTY_STATE_PRESET_DEFAULTS as d, EMPTY_STATE_SIZE_CLASSES as L, EMPTY_STATE_PRESET_ICON as v } from "./EmptyState.const.js";
|
|
10
|
+
const V = (_) => {
|
|
11
11
|
const {
|
|
12
12
|
icon: p,
|
|
13
|
-
title:
|
|
14
|
-
description:
|
|
15
|
-
action:
|
|
16
|
-
secondaryAction:
|
|
17
|
-
className:
|
|
18
|
-
size:
|
|
19
|
-
variant:
|
|
20
|
-
preset:
|
|
21
|
-
id:
|
|
22
|
-
testId:
|
|
23
|
-
} =
|
|
24
|
-
return /* @__PURE__ */
|
|
25
|
-
|
|
13
|
+
title: l,
|
|
14
|
+
description: o,
|
|
15
|
+
action: s,
|
|
16
|
+
secondaryAction: i,
|
|
17
|
+
className: S,
|
|
18
|
+
size: A = u,
|
|
19
|
+
variant: N = x,
|
|
20
|
+
preset: a = D,
|
|
21
|
+
id: y,
|
|
22
|
+
testId: P
|
|
23
|
+
} = _, f = g(F), B = Y(y, f), t = L[A], I = v[a], M = p ?? /* @__PURE__ */ e(I, { className: "bear-w-full bear-h-full" }), c = d[a] ?? d.empty, E = o !== void 0 ? o : c.description;
|
|
24
|
+
return /* @__PURE__ */ m(
|
|
25
|
+
n,
|
|
26
26
|
{
|
|
27
|
-
id:
|
|
28
|
-
"data-testid":
|
|
29
|
-
className:
|
|
27
|
+
id: B,
|
|
28
|
+
"data-testid": P,
|
|
29
|
+
className: r(
|
|
30
30
|
"Bear-EmptyState",
|
|
31
|
-
|
|
32
|
-
`Bear-EmptyState--${
|
|
31
|
+
N === "card" && "Bear-EmptyState--card",
|
|
32
|
+
`Bear-EmptyState--${a}`,
|
|
33
33
|
t.padding,
|
|
34
|
-
|
|
34
|
+
S
|
|
35
35
|
),
|
|
36
36
|
children: [
|
|
37
|
-
/* @__PURE__ */ e(
|
|
38
|
-
/* @__PURE__ */ e(
|
|
39
|
-
|
|
40
|
-
(
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
/* @__PURE__ */ e(n, { className: r("Bear-EmptyState__icon", t.icon), children: M }),
|
|
38
|
+
/* @__PURE__ */ e(T, { className: r("Bear-EmptyState__title", t.title), children: l ?? c.title }),
|
|
39
|
+
E && /* @__PURE__ */ e(T, { className: r("Bear-EmptyState__description", t.desc), children: E }),
|
|
40
|
+
(s || i) && /* @__PURE__ */ m(h, { className: "Bear-EmptyState__actions", align: "center", gap: 3, children: [
|
|
41
|
+
s,
|
|
42
|
+
i
|
|
43
43
|
] })
|
|
44
44
|
]
|
|
45
45
|
}
|
|
46
46
|
);
|
|
47
47
|
};
|
|
48
48
|
export {
|
|
49
|
-
|
|
49
|
+
V as EmptyState
|
|
50
50
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export type EmptyStatePreset = 'empty' | 'search' | 'inbox' | 'error';
|
|
2
|
+
export type EmptyStatePreset = 'empty' | 'search' | 'inbox' | 'error' | 'no-data' | '404' | 'offline' | 'filter-empty';
|
|
3
3
|
export interface EmptyStateProps {
|
|
4
4
|
testId?: string;
|
|
5
5
|
id?: string;
|
|
6
6
|
icon?: ReactNode;
|
|
7
|
-
title
|
|
7
|
+
title?: string;
|
|
8
8
|
description?: string;
|
|
9
9
|
action?: ReactNode;
|
|
10
10
|
secondaryAction?: ReactNode;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),s=require("react"),U=require("../Portal/Portal.cjs"),y=require("../../hooks/useFixedAnchorPosition/useFixedAnchorPosition.utils.cjs"),e=require("../../constants/numbers.const.cjs"),w=require("./HoverCard.const.cjs");function C(t,c,o){const a=e.EIGHT;let r=e.ZERO,n=e.ZERO;const T=e.TWO_HUNDRED_EIGHTY_EIGHT/e.TWO;return c==="bottom"?(r=t.bottom+a,n=t.left+t.width/e.TWO-T,o==="start"&&(n=t.left),o==="end"&&(n=t.right-e.TWO_HUNDRED_EIGHTY_EIGHT)):c==="top"?(r=t.top-e.TWO_HUNDRED-a,n=t.left+t.width/e.TWO-T,o==="start"&&(n=t.left),o==="end"&&(n=t.right-e.TWO_HUNDRED_EIGHTY_EIGHT)):c==="right"?(n=t.right+a,r=t.top+t.height/e.TWO-e.TWO_HUNDRED/e.TWO,o==="start"&&(r=t.top),o==="end"&&(r=t.bottom-e.TWO_HUNDRED)):(n=t.left-e.TWO_HUNDRED_EIGHTY_EIGHT-a,r=t.top+t.height/e.TWO-e.TWO_HUNDRED/e.TWO,o==="start"&&(r=t.top),o==="end"&&(r=t.bottom-e.TWO_HUNDRED)),n=Math.max(e.EIGHT,Math.min(n,window.innerWidth-e.TWO_HUNDRED_EIGHTY_EIGHT-e.EIGHT)),r=Math.max(e.EIGHT,Math.min(r,window.innerHeight-e.TWO_HUNDRED-e.EIGHT)),{position:"fixed",zIndex:e.ELEVEN_THOUSAND,top:r,left:n,width:e.TWO_HUNDRED_EIGHTY_EIGHT}}const W=s.forwardRef(({children:t,cardContent:c,side:o="bottom",align:a="center",openDelay:r=200,closeDelay:n=300,arrow:T=!0,className:p="",...m},I)=>{const[u,H]=s.useState(!1),[N,G]=s.useState({}),l=s.useRef(),f=s.useRef(),d=s.useRef(null),b=s.useRef(null);s.useEffect(()=>{if(!u||!d.current)return;const i=()=>{const _=d.current.getBoundingClientRect();G(C(_,o,a))};return i(),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[u,o,a]),s.useEffect(()=>{if(!u)return;const i=_=>{var D,v;const h=_.target;(D=d.current)!=null&&D.contains(h)||(v=b.current)!=null&&v.contains(h)||H(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[u]);const R=()=>{f.current&&clearTimeout(f.current),l.current=setTimeout(()=>H(!0),r)},O=()=>{l.current&&clearTimeout(l.current),f.current=setTimeout(()=>H(!1),n)};s.useEffect(()=>()=>{l.current&&clearTimeout(l.current),f.current&&clearTimeout(f.current)},[]);const{openEffect:g}=y.resolveOverlayEffects(m,"scale"),M=w.HOVER_CARD_EFFECT_CLASS_MAP[g]??w.HOVER_CARD_EFFECT_CLASS_MAP.scale;return E.jsxs("div",{ref:I,className:`bear-hover-card bear-relative bear-inline-block ${p}`.trim(),onMouseEnter:R,onMouseLeave:O,...m,children:[E.jsx("div",{ref:d,className:"bear-inline-block",children:t}),u&&E.jsx(U.Portal,{children:E.jsx("div",{ref:b,style:N,className:`
|
|
2
2
|
bear-bg-white dark:bear-bg-gray-800 bear-rounded-lg bear-shadow-xl
|
|
3
3
|
bear-border bear-border-gray-200 dark:bear-border-gray-700 bear-p-4
|
|
4
4
|
bear-transition-all bear-duration-200
|
|
5
|
-
${
|
|
6
|
-
|
|
5
|
+
${u?"bear-opacity-100 bear-scale-100":"bear-opacity-0 bear-scale-95"}
|
|
6
|
+
${M}
|
|
7
|
+
`.trim(),onMouseEnter:R,onMouseLeave:O,children:c})})]})});W.displayName="HoverCard";exports.HoverCard=W;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={scale:"animate-scale-in",fade:"animate-fade-in","slide-down":"animate-grow-up",fold:"animate-alert-dialog-in",none:""};exports.HOVER_CARD_EFFECT_CLASS_MAP=e;
|
|
@@ -1,86 +1,92 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { Portal as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsxs as A, jsx as v } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as P, useState as _, useRef as h, useEffect as T } from "react";
|
|
3
|
+
import { Portal as z } from "../Portal/Portal.js";
|
|
4
|
+
import { resolveOverlayEffects as G } from "../../hooks/useFixedAnchorPosition/useFixedAnchorPosition.utils.js";
|
|
5
|
+
import { TWO as a, TWO_HUNDRED_EIGHTY_EIGHT as u, TWO_HUNDRED as f, ZERO as x, ELEVEN_THOUSAND as U, EIGHT as m } from "../../constants/numbers.const.js";
|
|
6
|
+
import { HOVER_CARD_EFFECT_CLASS_MAP as N } from "./HoverCard.const.js";
|
|
7
|
+
function $(e, l, o) {
|
|
8
|
+
const i = m;
|
|
9
|
+
let t = x, r = x;
|
|
10
|
+
const p = u / a;
|
|
11
|
+
return l === "bottom" ? (t = e.bottom + i, r = e.left + e.width / a - p, o === "start" && (r = e.left), o === "end" && (r = e.right - u)) : l === "top" ? (t = e.top - f - i, r = e.left + e.width / a - p, o === "start" && (r = e.left), o === "end" && (r = e.right - u)) : l === "right" ? (r = e.right + i, t = e.top + e.height / a - f / a, o === "start" && (t = e.top), o === "end" && (t = e.bottom - f)) : (r = e.left - u - i, t = e.top + e.height / a - f / a, o === "start" && (t = e.top), o === "end" && (t = e.bottom - f)), r = Math.max(m, Math.min(r, window.innerWidth - u - m)), t = Math.max(m, Math.min(t, window.innerHeight - f - m)), {
|
|
9
12
|
position: "fixed",
|
|
10
|
-
zIndex:
|
|
13
|
+
zIndex: U,
|
|
11
14
|
top: t,
|
|
12
15
|
left: r,
|
|
13
|
-
width:
|
|
16
|
+
width: u
|
|
14
17
|
};
|
|
15
18
|
}
|
|
16
|
-
const
|
|
19
|
+
const j = P(({
|
|
17
20
|
children: e,
|
|
18
|
-
cardContent:
|
|
19
|
-
side:
|
|
20
|
-
align:
|
|
21
|
+
cardContent: l,
|
|
22
|
+
side: o = "bottom",
|
|
23
|
+
align: i = "center",
|
|
21
24
|
openDelay: t = 200,
|
|
22
25
|
closeDelay: r = 300,
|
|
23
|
-
arrow:
|
|
24
|
-
className:
|
|
25
|
-
...
|
|
26
|
-
},
|
|
27
|
-
const [
|
|
28
|
-
|
|
29
|
-
if (!
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
26
|
+
arrow: p = !0,
|
|
27
|
+
className: C = "",
|
|
28
|
+
...R
|
|
29
|
+
}, D) => {
|
|
30
|
+
const [s, E] = _(!1), [S, I] = _({}), d = h(), c = h(), b = h(null), g = h(null);
|
|
31
|
+
T(() => {
|
|
32
|
+
if (!s || !b.current) return;
|
|
33
|
+
const n = () => {
|
|
34
|
+
const w = b.current.getBoundingClientRect();
|
|
35
|
+
I($(w, o, i));
|
|
33
36
|
};
|
|
34
|
-
return
|
|
35
|
-
window.removeEventListener("resize",
|
|
37
|
+
return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
38
|
+
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
36
39
|
};
|
|
37
|
-
}, [
|
|
38
|
-
if (!
|
|
39
|
-
const
|
|
40
|
-
var
|
|
41
|
-
const
|
|
42
|
-
(
|
|
40
|
+
}, [s, o, i]), T(() => {
|
|
41
|
+
if (!s) return;
|
|
42
|
+
const n = (w) => {
|
|
43
|
+
var H, O;
|
|
44
|
+
const y = w.target;
|
|
45
|
+
(H = b.current) != null && H.contains(y) || (O = g.current) != null && O.contains(y) || E(!1);
|
|
43
46
|
};
|
|
44
|
-
return document.addEventListener("mousedown",
|
|
45
|
-
}, [
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
d.current && clearTimeout(d.current),
|
|
47
|
+
return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
|
|
48
|
+
}, [s]);
|
|
49
|
+
const L = () => {
|
|
50
|
+
c.current && clearTimeout(c.current), d.current = setTimeout(() => E(!0), t);
|
|
51
|
+
}, M = () => {
|
|
52
|
+
d.current && clearTimeout(d.current), c.current = setTimeout(() => E(!1), r);
|
|
50
53
|
};
|
|
51
|
-
|
|
52
|
-
d.current && clearTimeout(d.current),
|
|
53
|
-
}, [])
|
|
54
|
+
T(() => () => {
|
|
55
|
+
d.current && clearTimeout(d.current), c.current && clearTimeout(c.current);
|
|
56
|
+
}, []);
|
|
57
|
+
const { openEffect: W } = G(R, "scale"), k = N[W] ?? N.scale;
|
|
58
|
+
return /* @__PURE__ */ A(
|
|
54
59
|
"div",
|
|
55
60
|
{
|
|
56
|
-
ref:
|
|
57
|
-
className: `bear-hover-card bear-relative bear-inline-block ${
|
|
58
|
-
onMouseEnter:
|
|
59
|
-
onMouseLeave:
|
|
60
|
-
...
|
|
61
|
+
ref: D,
|
|
62
|
+
className: `bear-hover-card bear-relative bear-inline-block ${C}`.trim(),
|
|
63
|
+
onMouseEnter: L,
|
|
64
|
+
onMouseLeave: M,
|
|
65
|
+
...R,
|
|
61
66
|
children: [
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
|
|
67
|
+
/* @__PURE__ */ v("div", { ref: b, className: "bear-inline-block", children: e }),
|
|
68
|
+
s && /* @__PURE__ */ v(z, { children: /* @__PURE__ */ v(
|
|
64
69
|
"div",
|
|
65
70
|
{
|
|
66
71
|
ref: g,
|
|
67
|
-
style:
|
|
72
|
+
style: S,
|
|
68
73
|
className: `
|
|
69
74
|
bear-bg-white dark:bear-bg-gray-800 bear-rounded-lg bear-shadow-xl
|
|
70
75
|
bear-border bear-border-gray-200 dark:bear-border-gray-700 bear-p-4
|
|
71
76
|
bear-transition-all bear-duration-200
|
|
72
|
-
${
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
${s ? "bear-opacity-100 bear-scale-100" : "bear-opacity-0 bear-scale-95"}
|
|
78
|
+
${k}
|
|
79
|
+
`.trim(),
|
|
80
|
+
onMouseEnter: L,
|
|
81
|
+
onMouseLeave: M,
|
|
82
|
+
children: l
|
|
77
83
|
}
|
|
78
84
|
) })
|
|
79
85
|
]
|
|
80
86
|
}
|
|
81
87
|
);
|
|
82
88
|
});
|
|
83
|
-
|
|
89
|
+
j.displayName = "HoverCard";
|
|
84
90
|
export {
|
|
85
|
-
|
|
91
|
+
j as HoverCard
|
|
86
92
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { OverlayMotionEffect, OverlayEffectConfig } from '../../hooks/useFixedAnchorPosition';
|
|
2
3
|
export interface HoverCardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'content'> {
|
|
3
4
|
testId?: string;
|
|
4
5
|
id?: string;
|
|
@@ -9,6 +10,12 @@ export interface HoverCardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'co
|
|
|
9
10
|
openDelay?: number;
|
|
10
11
|
closeDelay?: number;
|
|
11
12
|
arrow?: boolean;
|
|
13
|
+
/** Transition effect when opening */
|
|
14
|
+
openEffect?: OverlayMotionEffect;
|
|
15
|
+
/** Transition effect when closing */
|
|
16
|
+
closeEffect?: OverlayMotionEffect;
|
|
17
|
+
/** Config for open and close transition effects */
|
|
18
|
+
effect?: OverlayEffectConfig;
|
|
12
19
|
}
|
|
13
20
|
export interface HoverCardContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
21
|
children?: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),u=require("react"),p=require("../../utils/cn.cjs"),S=require("../../hooks/useFixedAnchorPosition/useFixedAnchorPosition.utils.cjs"),q=require("../Portal/Portal.cjs"),b=require("./Menu.const.cjs"),P=({open:c=!1,anchorEl:n,onClose:s,children:k,position:l="bottom-start",minWidth:d=180,maxHeight:f=300,className:E,testId:m,...v})=>{const i=u.useRef(null),[g,L]=u.useState({top:0,left:0});u.useLayoutEffect(()=>{if(!c||!n)return;const r=()=>{const t=n.getBoundingClientRect(),e=i.current,w=e?e.offsetHeight:Math.min(f,200);let o=0,a=0;switch(l){case"bottom-start":o=t.bottom+4,a=t.left;break;case"bottom-end":o=t.bottom+4,a=t.right-((e==null?void 0:e.offsetWidth)??d);break;case"top-start":o=t.top-w-4,a=t.left;break;case"top-end":o=t.top-w-4,a=t.right-((e==null?void 0:e.offsetWidth)??d);break;case"right-start":o=t.top,a=t.right+4;break;case"left-start":o=t.top,a=t.left-((e==null?void 0:e.offsetWidth)??d)-4;break}L({top:o,left:a})};return r(),window.addEventListener("resize",r),window.addEventListener("scroll",r,!0),()=>{window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0)}},[c,n,l,d,f]),u.useEffect(()=>{if(!c)return;const r=e=>{i.current&&!i.current.contains(e.target)&&n&&!n.contains(e.target)&&(s==null||s())},t=e=>{e.key==="Escape"&&(s==null||s())};return document.addEventListener("mousedown",r),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",t)}},[c,n,s]);const{openEffect:M}=S.resolveOverlayEffects(v,"fade"),_=b.MENU_EFFECT_CLASS_MAP[M]??b.MENU_EFFECT_CLASS_MAP.fade;return c?y.jsx(q.Portal,{children:y.jsx("div",{ref:i,role:"menu",className:p.cn("bear-fixed bear-bg-white dark:bear-bg-gray-800","bear-border bear-border-gray-200 dark:bear-border-gray-700","bear-rounded-lg bear-shadow-lg bear-py-1","bear-overflow-y-auto",_,E),style:{top:g.top,left:g.left,minWidth:d,maxHeight:f,zIndex:b.MENU_Z_INDEX},"data-testid":m,...v,children:k})}):null};exports.Menu=P;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/numbers.const.cjs"),n=e.TWELVE_THOUSAND,a={scale:"animate-scale-in",fade:"animate-fade-in","slide-down":"animate-grow-up",fold:"animate-alert-dialog-in",none:""};exports.MENU_EFFECT_CLASS_MAP=a;exports.MENU_Z_INDEX=n;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TWELVE_THOUSAND as a } from "../../constants/numbers.const.js";
|
|
2
|
+
const n = a, i = {
|
|
3
|
+
scale: "animate-scale-in",
|
|
4
|
+
fade: "animate-fade-in",
|
|
5
|
+
"slide-down": "animate-grow-up",
|
|
6
|
+
fold: "animate-alert-dialog-in",
|
|
7
|
+
none: ""
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
i as MENU_EFFECT_CLASS_MAP,
|
|
11
|
+
n as MENU_Z_INDEX
|
|
12
|
+
};
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { MenuProps
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export declare const MenuItem: FC<MenuItemProps>;
|
|
7
|
-
/**
|
|
8
|
-
* MenuDivider component for separating menu sections
|
|
9
|
-
*/
|
|
10
|
-
export declare const MenuDivider: FC<MenuDividerProps>;
|
|
2
|
+
import { MenuProps } from './Menu.types';
|
|
3
|
+
export { MenuItem } from './MenuItem';
|
|
4
|
+
export { MenuDivider } from './MenuDivider';
|
|
11
5
|
/**
|
|
12
6
|
* Menu component for dropdown menus
|
|
13
7
|
*
|