@bioturing/components 0.35.2 → 0.35.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/base-menu/item.css +1 -1
- package/dist/components/dropdown-menu/item.d.ts.map +1 -1
- package/dist/components/dropdown-menu/item.js +32 -22
- package/dist/components/dropdown-menu/item.js.map +1 -1
- package/dist/components/utils/client.d.ts +1 -0
- package/dist/components/utils/client.d.ts.map +1 -1
- package/dist/components/utils/createSyntheticClickEvent.d.ts +13 -0
- package/dist/components/utils/createSyntheticClickEvent.d.ts.map +1 -0
- package/dist/components/utils/createSyntheticClickEvent.js +62 -0
- package/dist/components/utils/createSyntheticClickEvent.js.map +1 -0
- package/dist/index.js +273 -271
- package/dist/index.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-menu-item-base{padding:.375rem .75rem;border-radius:var(--ds-border-radius-sm);transition:all .3s var(--ds-motion-ease-out);cursor:pointer;display:flex;align-items:center;color:var(--ds-color-text);border:none;background:none;width:100%;text-align:left}.ds-menu-item-base:focus{outline:none}.ds-menu-item-base:hover,.ds-menu-item-base[data-active=true],.ds-menu-item-base[data-highlighted]{background:var(--ds-control-item-bg-hover)}.ds-menu-item-base:active,.ds-menu-item-base:focus,.ds-menu-item-base[data-selected=true],.ds-menu-item-base[data-focus=true]{background:var(--ds-control-item-bg-active)}.ds-menu-item-base[data-disabled=true]{pointer-events:none;color:var(--ds-color-text-disabled)}.ds-menu-item-base[data-danger=true]{color:var(--ds-color-error)}.ds-menu-item-base[data-danger=true]:hover{background:var(--ds-color-error-bg)}.ds-menu-item-base[data-danger=true]:active,.ds-menu-item-base[data-danger=true]:focus,.ds-menu-item-base[data-danger=true][data-focus=true]{background:var(--ds-color-error-bg-hover)}.ds-menu-item-icon{display:flex;align-items:center;justify-content:center;margin-right:.5rem;font-size:1rem;color:var(--ds-color-icon);flex-shrink:0}.ds-menu-item-base[data-danger=true] .ds-menu-item-icon{color:var(--ds-color-error)}.ds-menu-item-text{flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ds-menu-item-suffix{margin-left:.75rem;font-size:.75rem;line-height:1.25rem;color:var(--ds-color-text-tertiary);display:flex;flex-grow:0;flex-shrink:0;align-items:flex-end}.ds-menu-item-base .ds-checkbox-wrapper{margin-right:.5rem}.ds-menu-item-base:not(.ds-menu-item-show-checkbox) [data-actual-selected=true]:scope{background:var(--ds-control-item-bg-active)}
|
|
1
|
+
@layer components{.ds-menu-item-base{padding:.375rem .75rem;border-radius:var(--ds-border-radius-sm);transition:all .3s var(--ds-motion-ease-out);cursor:pointer;display:flex;align-items:center;color:var(--ds-color-text);border:none;background:none;width:100%;text-align:left}.ds-menu-item-base:focus{outline:none}.ds-menu-item-base:hover,.ds-menu-item-base[data-active=true],.ds-menu-item-base[data-highlighted]{background:var(--ds-control-item-bg-hover)}.ds-menu-item-base:active,.ds-menu-item-base:focus,.ds-menu-item-base[data-selected=true],.ds-menu-item-base[data-focus=true]{background:var(--ds-control-item-bg-active)}.ds-menu-item-base[data-disabled=true]{pointer-events:none;color:var(--ds-color-text-disabled)}.ds-menu-item-base[data-danger=true]{color:var(--ds-color-error)}.ds-menu-item-base[data-danger=true]:hover{background:var(--ds-color-error-bg)}.ds-menu-item-base[data-danger=true]:active,.ds-menu-item-base[data-danger=true]:focus,.ds-menu-item-base[data-danger=true][data-focus=true]{background:var(--ds-color-error-bg-hover)}.ds-menu-item-icon{display:flex;align-items:center;justify-content:center;margin-right:.5rem;font-size:1rem;color:var(--ds-color-icon);flex-shrink:0}.ds-menu-item-base[data-danger=true] .ds-menu-item-icon{color:var(--ds-color-error)}.ds-menu-item-text{flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ds-menu-item-suffix{margin-left:.75rem;font-size:.75rem;line-height:1.25rem;color:var(--ds-color-text-tertiary);display:flex;flex-grow:0;flex-shrink:0;align-items:flex-end}.ds-menu-item-base .ds-checkbox-wrapper{margin-right:.5rem}.ds-menu-item-base:not(.ds-menu-item-show-checkbox) [data-actual-selected=true]:scope{background:var(--ds-control-item-bg-active)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/item.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/item.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAOzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAKpD,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,IAAI,EAAE,oBAAoB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C;;OAEG;IACH,UAAU,CAAC,EAAE,CACX,IAAI,EAAE,oBAAoB,EAC1B,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,KACrC,KAAK,CAAC,YAAY,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,CAChB,IAAI,EAAE,oBAAoB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAC7C,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,KACrC,KAAK,CAAC,YAAY,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IAC9C;;OAEG;IACH,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACtE;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,EAAE,CAAC;CAC/E;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAqH5D,CAAC"}
|
|
@@ -1,28 +1,38 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import { Command as
|
|
5
|
-
import { Menu as
|
|
2
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback as i, useMemo as x } from "react";
|
|
4
|
+
import { Command as y } from "../cmdk/index.js";
|
|
5
|
+
import { Menu as O } from "@base-ui-components/react/menu";
|
|
6
6
|
import { BaseMenuItem as S } from "../base-menu/item.js";
|
|
7
|
+
import C from "../utils/createSyntheticClickEvent.js";
|
|
7
8
|
import { reactNodeToString as w } from "../utils/reactToString.js";
|
|
8
|
-
import { useCls as
|
|
9
|
-
import { clsx as
|
|
10
|
-
const
|
|
9
|
+
import { useCls as E } from "../utils/antdUtils.js";
|
|
10
|
+
import { clsx as M } from "../utils/cn.js";
|
|
11
|
+
const z = ({
|
|
11
12
|
item: o,
|
|
12
13
|
inCombobox: e = !1,
|
|
13
14
|
selected: u = !1,
|
|
14
15
|
itemRender: d,
|
|
15
16
|
itemLabelRender: f,
|
|
16
|
-
itemProps:
|
|
17
|
+
itemProps: p = {},
|
|
17
18
|
classNames: n,
|
|
18
19
|
afterSelect: a,
|
|
19
20
|
showCheckbox: v,
|
|
20
21
|
indeterminate: k,
|
|
21
22
|
getItemKeywords: l
|
|
22
23
|
}) => {
|
|
23
|
-
const
|
|
24
|
+
const t = E(), s = i(
|
|
24
25
|
(r) => {
|
|
25
|
-
|
|
26
|
+
if (o.onSelect)
|
|
27
|
+
o.onSelect(o);
|
|
28
|
+
else if (o.onClick)
|
|
29
|
+
if (typeof r == "object")
|
|
30
|
+
o.onClick(r);
|
|
31
|
+
else {
|
|
32
|
+
const b = C(null);
|
|
33
|
+
o.onClick(b);
|
|
34
|
+
}
|
|
35
|
+
a && a(o);
|
|
26
36
|
},
|
|
27
37
|
[a, o]
|
|
28
38
|
), g = x(
|
|
@@ -30,8 +40,8 @@ const D = ({
|
|
|
30
40
|
[l, o]
|
|
31
41
|
);
|
|
32
42
|
return d ? d(o, {
|
|
33
|
-
className:
|
|
34
|
-
|
|
43
|
+
className: M(
|
|
44
|
+
t("dropdown-menu-item", e && "dropdown-menu-item-combobox"),
|
|
35
45
|
n?.item,
|
|
36
46
|
o.className
|
|
37
47
|
),
|
|
@@ -39,13 +49,13 @@ const D = ({
|
|
|
39
49
|
"data-actual-selected": u,
|
|
40
50
|
"data-value": typeof o.label == "string" ? o.label : String(o.key),
|
|
41
51
|
ref: o.ref,
|
|
42
|
-
onClick:
|
|
52
|
+
onClick: s,
|
|
43
53
|
onMouseEnter: o.onMouseEnter,
|
|
44
54
|
onMouseLeave: o.onMouseLeave,
|
|
45
55
|
onMouseOver: o.onMouseOver,
|
|
46
56
|
onMouseOut: o.onMouseOut,
|
|
47
|
-
...
|
|
48
|
-
}) : /* @__PURE__ */
|
|
57
|
+
...p
|
|
58
|
+
}) : /* @__PURE__ */ c(
|
|
49
59
|
S,
|
|
50
60
|
{
|
|
51
61
|
disabled: o.disabled,
|
|
@@ -56,8 +66,8 @@ const D = ({
|
|
|
56
66
|
icon: o.icon,
|
|
57
67
|
suffix: e ? void 0 : o.suffix,
|
|
58
68
|
classNames: {
|
|
59
|
-
root:
|
|
60
|
-
|
|
69
|
+
root: M(
|
|
70
|
+
t(
|
|
61
71
|
"dropdown-menu-item",
|
|
62
72
|
e && "dropdown-menu-item-combobox"
|
|
63
73
|
),
|
|
@@ -76,19 +86,19 @@ const D = ({
|
|
|
76
86
|
onMouseOut: o.onMouseOut,
|
|
77
87
|
"data-value": typeof o.label == "string" ? o.label : String(o.key),
|
|
78
88
|
"data-actual-selected": u,
|
|
79
|
-
render: e ? /* @__PURE__ */
|
|
80
|
-
|
|
89
|
+
render: e ? /* @__PURE__ */ c(
|
|
90
|
+
y.Item,
|
|
81
91
|
{
|
|
82
92
|
value: String(o.key),
|
|
83
93
|
keywords: g || void 0,
|
|
84
|
-
onSelect:
|
|
94
|
+
onSelect: s
|
|
85
95
|
}
|
|
86
|
-
) : /* @__PURE__ */
|
|
96
|
+
) : /* @__PURE__ */ c(O.Item, { onClick: s }),
|
|
87
97
|
children: o.label
|
|
88
98
|
}
|
|
89
99
|
);
|
|
90
100
|
};
|
|
91
101
|
export {
|
|
92
|
-
|
|
102
|
+
z as DropdownMenuItem
|
|
93
103
|
};
|
|
94
104
|
//# sourceMappingURL=item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sources":["../../../src/components/dropdown-menu/item.tsx"],"sourcesContent":["\"use client\";\nimport React, { Ref, useCallback, useMemo } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../src/components/dropdown-menu/item.tsx"],"sourcesContent":["\"use client\";\nimport React, { Ref, useCallback, useMemo } from \"react\";\nimport {\n clsx,\n createSyntheticClickEvent,\n reactNodeToString,\n useCls,\n} from \"../utils\";\nimport type { DropdownMenuItemType } from \"./types\";\nimport { Command } from \"../cmdk\";\nimport { Menu } from \"@base-ui-components/react/menu\";\nimport { BaseMenuItem } from \"../base-menu\";\n\nexport interface DropdownMenuItemProps {\n /**\n * The menu item data\n */\n item: DropdownMenuItemType & { type: \"item\" };\n /**\n * Custom render function for the item\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Custom render function for the item label\n */\n itemLabelRender?: (\n item: DropdownMenuItemType & { type: \"item\" },\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Additional props to pass to the item\n */\n itemProps?: React.HTMLAttributes<HTMLElement>;\n /**\n * Class names from parent DropdownMenu\n */\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemText?: string;\n itemSuffix?: string;\n };\n /**\n * Function to be called after the menu item is selected\n */\n afterSelect?: (item: DropdownMenuItemType & { type: \"item\" }) => void;\n /**\n * Whether the menu item is in a combobox\n */\n inCombobox?: boolean;\n /**\n * Whether the menu item is selected (for combobox)\n * @default false\n */\n selected?: boolean;\n /**\n * Whether to show checkbox (only for decoration purpose)\n */\n showCheckbox?: boolean;\n /**\n * Whether the menu item checkbox is indeterminate (for combobox)\n * @default false\n */\n indeterminate?: boolean;\n /**\n * Function to extract keywords from the item for search filtering\n * @default (item) => [String(item.key), reactNodeToString(item.label)]\n */\n getItemKeywords?: (item: DropdownMenuItemType & { type: \"item\" }) => string[];\n}\n\nexport const DropdownMenuItem: React.FC<DropdownMenuItemProps> = ({\n item,\n inCombobox = false,\n selected = false,\n itemRender,\n itemLabelRender,\n itemProps = {},\n classNames,\n afterSelect,\n showCheckbox,\n indeterminate,\n getItemKeywords,\n}) => {\n const cls = useCls();\n\n const handler = useCallback(\n (e?: React.MouseEvent<HTMLElement, MouseEvent> | string) => {\n // onSelect has priority over onClick\n if (item.onSelect) {\n item.onSelect(item);\n } else if (item.onClick) {\n if (typeof e === \"object\") {\n item.onClick(e);\n } else {\n const event = createSyntheticClickEvent(null);\n item.onClick(event);\n }\n }\n if (afterSelect) afterSelect(item);\n },\n [afterSelect, item]\n );\n\n const keywords = useMemo(\n () =>\n getItemKeywords\n ? getItemKeywords(item)\n : [String(item.key), reactNodeToString(item.label)],\n [getItemKeywords, item]\n );\n\n // If custom render function is provided, use it\n if (itemRender) {\n return itemRender(item, {\n className: clsx(\n cls(\"dropdown-menu-item\", inCombobox && \"dropdown-menu-item-combobox\"),\n classNames?.item,\n item.className\n ),\n \"data-danger\": item.danger,\n \"data-actual-selected\": selected,\n \"data-value\":\n typeof item.label === \"string\" ? item.label : String(item.key),\n ref: item.ref as Ref<HTMLDivElement>,\n onClick: handler,\n onMouseEnter: item.onMouseEnter,\n onMouseLeave: item.onMouseLeave,\n onMouseOver: item.onMouseOver,\n onMouseOut: item.onMouseOut,\n ...itemProps,\n } as React.HTMLAttributes<HTMLElement>);\n }\n\n return (\n <BaseMenuItem\n // BaseMenuItem props\n disabled={item.disabled}\n danger={item.danger}\n selected={selected}\n showCheckbox={showCheckbox}\n indeterminate={indeterminate}\n icon={item.icon}\n suffix={!inCombobox ? item.suffix : undefined}\n classNames={{\n root: clsx(\n cls(\n \"dropdown-menu-item\",\n inCombobox && \"dropdown-menu-item-combobox\"\n ),\n classNames?.item,\n item.className\n ),\n icon: classNames?.itemIcon,\n text: classNames?.itemText,\n suffix: classNames?.itemSuffix,\n }}\n labelRender={\n itemLabelRender\n ? (props: React.HTMLAttributes<HTMLElement>) =>\n itemLabelRender(item, props)\n : undefined\n }\n ref={item.ref as Ref<HTMLDivElement>}\n onMouseEnter={item.onMouseEnter}\n onMouseLeave={item.onMouseLeave}\n onMouseOver={item.onMouseOver}\n onMouseOut={item.onMouseOut}\n data-value={\n typeof item.label === \"string\" ? item.label : String(item.key)\n }\n data-actual-selected={selected}\n // Render prop to use Base UI components\n render={\n inCombobox ? (\n <Command.Item\n value={String(item.key)}\n keywords={keywords || undefined}\n onSelect={handler}\n />\n ) : (\n <Menu.Item onClick={handler} />\n )\n }\n >\n {item.label}\n </BaseMenuItem>\n );\n};\n"],"names":["DropdownMenuItem","item","inCombobox","selected","itemRender","itemLabelRender","itemProps","classNames","afterSelect","showCheckbox","indeterminate","getItemKeywords","cls","useCls","handler","useCallback","e","event","createSyntheticClickEvent","keywords","useMemo","reactNodeToString","clsx","jsx","BaseMenuItem","props","Command","Menu"],"mappings":";;;;;;;;;;AA0EO,MAAMA,IAAoD,CAAC;AAAA,EAChE,MAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,UAAAC,IAAW;AAAA,EACX,YAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,WAAAC,IAAY,CAAA;AAAA,EACZ,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC;AACF,MAAM;AACJ,QAAMC,IAAMC,EAAA,GAENC,IAAUC;AAAA,IACd,CAACC,MAA2D;AAE1D,UAAIf,EAAK;AACP,QAAAA,EAAK,SAASA,CAAI;AAAA,eACTA,EAAK;AACd,YAAI,OAAOe,KAAM;AACf,UAAAf,EAAK,QAAQe,CAAC;AAAA,aACT;AACL,gBAAMC,IAAQC,EAA0B,IAAI;AAC5C,UAAAjB,EAAK,QAAQgB,CAAK;AAAA,QACpB;AAEF,MAAIT,OAAyBP,CAAI;AAAA,IACnC;AAAA,IACA,CAACO,GAAaP,CAAI;AAAA,EAAA,GAGdkB,IAAWC;AAAA,IACf,MACET,IACIA,EAAgBV,CAAI,IACpB,CAAC,OAAOA,EAAK,GAAG,GAAGoB,EAAkBpB,EAAK,KAAK,CAAC;AAAA,IACtD,CAACU,GAAiBV,CAAI;AAAA,EAAA;AAIxB,SAAIG,IACKA,EAAWH,GAAM;AAAA,IACtB,WAAWqB;AAAA,MACTV,EAAI,sBAAsBV,KAAc,6BAA6B;AAAA,MACrEK,GAAY;AAAA,MACZN,EAAK;AAAA,IAAA;AAAA,IAEP,eAAeA,EAAK;AAAA,IACpB,wBAAwBE;AAAA,IACxB,cACE,OAAOF,EAAK,SAAU,WAAWA,EAAK,QAAQ,OAAOA,EAAK,GAAG;AAAA,IAC/D,KAAKA,EAAK;AAAA,IACV,SAASa;AAAA,IACT,cAAcb,EAAK;AAAA,IACnB,cAAcA,EAAK;AAAA,IACnB,aAAaA,EAAK;AAAA,IAClB,YAAYA,EAAK;AAAA,IACjB,GAAGK;AAAA,EAAA,CACiC,IAItC,gBAAAiB;AAAA,IAACC;AAAA,IAAA;AAAA,MAEC,UAAUvB,EAAK;AAAA,MACf,QAAQA,EAAK;AAAA,MACb,UAAAE;AAAA,MACA,cAAAM;AAAA,MACA,eAAAC;AAAA,MACA,MAAMT,EAAK;AAAA,MACX,QAASC,IAA2B,SAAdD,EAAK;AAAA,MAC3B,YAAY;AAAA,QACV,MAAMqB;AAAA,UACJV;AAAA,YACE;AAAA,YACAV,KAAc;AAAA,UAAA;AAAA,UAEhBK,GAAY;AAAA,UACZN,EAAK;AAAA,QAAA;AAAA,QAEP,MAAMM,GAAY;AAAA,QAClB,MAAMA,GAAY;AAAA,QAClB,QAAQA,GAAY;AAAA,MAAA;AAAA,MAEtB,aACEF,IACI,CAACoB,MACCpB,EAAgBJ,GAAMwB,CAAK,IAC7B;AAAA,MAEN,KAAKxB,EAAK;AAAA,MACV,cAAcA,EAAK;AAAA,MACnB,cAAcA,EAAK;AAAA,MACnB,aAAaA,EAAK;AAAA,MAClB,YAAYA,EAAK;AAAA,MACjB,cACE,OAAOA,EAAK,SAAU,WAAWA,EAAK,QAAQ,OAAOA,EAAK,GAAG;AAAA,MAE/D,wBAAsBE;AAAA,MAEtB,QACED,IACE,gBAAAqB;AAAA,QAACG,EAAQ;AAAA,QAAR;AAAA,UACC,OAAO,OAAOzB,EAAK,GAAG;AAAA,UACtB,UAAUkB,KAAY;AAAA,UACtB,UAAUL;AAAA,QAAA;AAAA,MAAA,IAGZ,gBAAAS,EAACI,EAAK,MAAL,EAAU,SAASb,EAAA,CAAS;AAAA,MAIhC,UAAAb,EAAK;AAAA,IAAA;AAAA,EAAA;AAGZ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/components/utils/client.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/components/utils/client.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a synthetic React MouseEvent for programmatic event simulation
|
|
4
|
+
*
|
|
5
|
+
* References:
|
|
6
|
+
* - React SyntheticEvent: https://react.dev/reference/react-dom/components/common#react-event-object
|
|
7
|
+
* - MouseEvent Web API: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
|
|
8
|
+
* - React TypeScript types: @types/react package
|
|
9
|
+
* - Dispatch events in tests: https://react.dev/reference/react/act#dispatching-events-in-tests
|
|
10
|
+
*/
|
|
11
|
+
declare function createSyntheticClickEvent(target: HTMLElement | null): React.MouseEvent<HTMLElement, MouseEvent>;
|
|
12
|
+
export default createSyntheticClickEvent;
|
|
13
|
+
//# sourceMappingURL=createSyntheticClickEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSyntheticClickEvent.d.ts","sourceRoot":"","sources":["../../../src/components/utils/createSyntheticClickEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;GAQG;AACH,iBAAS,yBAAyB,CAChC,MAAM,EAAE,WAAW,GAAG,IAAI,GACzB,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,CAmE3C;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function i(t) {
|
|
2
|
+
const e = new MouseEvent("click", {
|
|
3
|
+
bubbles: !0,
|
|
4
|
+
cancelable: !0,
|
|
5
|
+
view: window,
|
|
6
|
+
detail: 1
|
|
7
|
+
});
|
|
8
|
+
return {
|
|
9
|
+
nativeEvent: e,
|
|
10
|
+
currentTarget: t,
|
|
11
|
+
target: t,
|
|
12
|
+
bubbles: !0,
|
|
13
|
+
cancelable: !0,
|
|
14
|
+
defaultPrevented: !1,
|
|
15
|
+
eventPhase: e.eventPhase,
|
|
16
|
+
isTrusted: !0,
|
|
17
|
+
timeStamp: e.timeStamp,
|
|
18
|
+
type: "click",
|
|
19
|
+
// UIEvent properties
|
|
20
|
+
detail: 1,
|
|
21
|
+
view: window,
|
|
22
|
+
// Type cast to avoid AbstractView mismatch
|
|
23
|
+
// Event methods
|
|
24
|
+
preventDefault: function() {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
},
|
|
27
|
+
isDefaultPrevented: function() {
|
|
28
|
+
return e.defaultPrevented;
|
|
29
|
+
},
|
|
30
|
+
stopPropagation: function() {
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
},
|
|
33
|
+
isPropagationStopped: function() {
|
|
34
|
+
return !1;
|
|
35
|
+
},
|
|
36
|
+
persist: function() {
|
|
37
|
+
},
|
|
38
|
+
// MouseEvent specific properties
|
|
39
|
+
altKey: !1,
|
|
40
|
+
button: 0,
|
|
41
|
+
buttons: 0,
|
|
42
|
+
clientX: 0,
|
|
43
|
+
clientY: 0,
|
|
44
|
+
ctrlKey: !1,
|
|
45
|
+
metaKey: !1,
|
|
46
|
+
movementX: 0,
|
|
47
|
+
movementY: 0,
|
|
48
|
+
pageX: 0,
|
|
49
|
+
pageY: 0,
|
|
50
|
+
relatedTarget: null,
|
|
51
|
+
screenX: 0,
|
|
52
|
+
screenY: 0,
|
|
53
|
+
shiftKey: !1,
|
|
54
|
+
getModifierState: function(a) {
|
|
55
|
+
return !1;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
i as default
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=createSyntheticClickEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSyntheticClickEvent.js","sources":["../../../src/components/utils/createSyntheticClickEvent.ts"],"sourcesContent":["import React from \"react\";\n\n/**\n * Creates a synthetic React MouseEvent for programmatic event simulation\n *\n * References:\n * - React SyntheticEvent: https://react.dev/reference/react-dom/components/common#react-event-object\n * - MouseEvent Web API: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent\n * - React TypeScript types: @types/react package\n * - Dispatch events in tests: https://react.dev/reference/react/act#dispatching-events-in-tests\n */\nfunction createSyntheticClickEvent(\n target: HTMLElement | null\n): React.MouseEvent<HTMLElement, MouseEvent> {\n // Create native MouseEvent - standard Web API\n const nativeEvent = new MouseEvent(\"click\", {\n bubbles: true,\n cancelable: true,\n view: window,\n detail: 1,\n });\n\n // React's synthetic event wraps the native event\n // Using 'unknown' first to bypass strict type checking, as recommended by TypeScript\n const syntheticEvent = {\n nativeEvent,\n currentTarget: target,\n target: target,\n bubbles: true,\n cancelable: true,\n defaultPrevented: false,\n eventPhase: nativeEvent.eventPhase,\n isTrusted: true,\n timeStamp: nativeEvent.timeStamp,\n type: \"click\",\n\n // UIEvent properties\n detail: 1,\n view: window as any, // Type cast to avoid AbstractView mismatch\n\n // Event methods\n preventDefault: function () {\n nativeEvent.preventDefault();\n },\n isDefaultPrevented: function () {\n return nativeEvent.defaultPrevented;\n },\n stopPropagation: function () {\n nativeEvent.stopPropagation();\n },\n isPropagationStopped: function () {\n return false;\n },\n persist: function () {\n // React 17+ doesn't pool events, so this is a no-op\n },\n\n // MouseEvent specific properties\n altKey: false,\n button: 0,\n buttons: 0,\n clientX: 0,\n clientY: 0,\n ctrlKey: false,\n metaKey: false,\n movementX: 0,\n movementY: 0,\n pageX: 0,\n pageY: 0,\n relatedTarget: null as EventTarget | null,\n screenX: 0,\n screenY: 0,\n shiftKey: false,\n\n getModifierState: function (key: string): boolean {\n return false;\n },\n } as unknown as React.MouseEvent<HTMLElement, MouseEvent>;\n\n return syntheticEvent;\n}\n\nexport default createSyntheticClickEvent;\n"],"names":["createSyntheticClickEvent","target","nativeEvent","key"],"mappings":"AAWA,SAASA,EACPC,GAC2C;AAE3C,QAAMC,IAAc,IAAI,WAAW,SAAS;AAAA,IAC1C,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,QAAQ;AAAA,EAAA,CACT;AA2DD,SAvDuB;AAAA,IACrB,aAAAA;AAAA,IACA,eAAeD;AAAA,IACf,QAAAA;AAAA,IACA,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,YAAYC,EAAY;AAAA,IACxB,WAAW;AAAA,IACX,WAAWA,EAAY;AAAA,IACvB,MAAM;AAAA;AAAA,IAGN,QAAQ;AAAA,IACR,MAAM;AAAA;AAAA;AAAA,IAGN,gBAAgB,WAAY;AAC1B,MAAAA,EAAY,eAAA;AAAA,IACd;AAAA,IACA,oBAAoB,WAAY;AAC9B,aAAOA,EAAY;AAAA,IACrB;AAAA,IACA,iBAAiB,WAAY;AAC3B,MAAAA,EAAY,gBAAA;AAAA,IACd;AAAA,IACA,sBAAsB,WAAY;AAChC,aAAO;AAAA,IACT;AAAA,IACA,SAAS,WAAY;AAAA,IAErB;AAAA;AAAA,IAGA,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS;AAAA,IACT,WAAW;AAAA,IACX,WAAW;AAAA,IACX,OAAO;AAAA,IACP,OAAO;AAAA,IACP,eAAe;AAAA,IACf,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU;AAAA,IAEV,kBAAkB,SAAUC,GAAsB;AAChD,aAAO;AAAA,IACT;AAAA,EAAA;AAIJ;"}
|