@bioturing/components 0.33.1 → 0.35.2
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/component.d.ts +12 -0
- package/dist/components/base-menu/component.d.ts.map +1 -0
- package/dist/components/base-menu/component.js +69 -0
- package/dist/components/base-menu/component.js.map +1 -0
- package/dist/components/base-menu/index.d.ts +18 -0
- package/dist/components/base-menu/index.d.ts.map +1 -0
- package/dist/components/base-menu/index.js +11 -0
- package/dist/components/base-menu/index.js.map +1 -0
- package/dist/components/base-menu/item.css +1 -0
- package/dist/components/base-menu/item.d.ts +47 -0
- package/dist/components/base-menu/item.d.ts.map +1 -0
- package/dist/components/base-menu/item.js +73 -0
- package/dist/components/base-menu/item.js.map +1 -0
- package/dist/components/base-menu/style.css +1 -0
- package/dist/components/breadcrumb/component.d.ts +3 -2
- package/dist/components/breadcrumb/component.d.ts.map +1 -1
- package/dist/components/breadcrumb/component.js +138 -38
- package/dist/components/breadcrumb/component.js.map +1 -1
- package/dist/components/breadcrumb/index.d.ts +1 -0
- package/dist/components/breadcrumb/index.d.ts.map +1 -1
- package/dist/components/breadcrumb/item.d.ts +3 -0
- package/dist/components/breadcrumb/item.d.ts.map +1 -0
- package/dist/components/breadcrumb/item.js +19 -0
- package/dist/components/breadcrumb/item.js.map +1 -0
- package/dist/components/breadcrumb/style.css +1 -1
- package/dist/components/breadcrumb/types.d.ts +9 -2
- package/dist/components/breadcrumb/types.d.ts.map +1 -1
- package/dist/components/code-block/component.d.ts +1 -1
- package/dist/components/code-block/component.d.ts.map +1 -1
- package/dist/components/code-block/component.js +80 -71
- package/dist/components/code-block/component.js.map +1 -1
- package/dist/components/code-block/types.d.ts +17 -0
- package/dist/components/code-block/types.d.ts.map +1 -1
- package/dist/components/combobox/component.d.ts +3 -26
- package/dist/components/combobox/component.d.ts.map +1 -1
- package/dist/components/combobox/component.js +326 -216
- package/dist/components/combobox/component.js.map +1 -1
- package/dist/components/combobox/style.css +1 -1
- package/dist/components/command-palette/component.js +6 -6
- package/dist/components/command-palette/component.js.map +1 -1
- package/dist/components/dropdown-menu/component.d.ts.map +1 -1
- package/dist/components/dropdown-menu/component.js +90 -87
- package/dist/components/dropdown-menu/component.js.map +1 -1
- package/dist/components/dropdown-menu/divider.d.ts.map +1 -1
- package/dist/components/dropdown-menu/divider.js +17 -10
- package/dist/components/dropdown-menu/divider.js.map +1 -1
- package/dist/components/dropdown-menu/item.d.ts +19 -9
- package/dist/components/dropdown-menu/item.d.ts.map +1 -1
- package/dist/components/dropdown-menu/item.js +71 -130
- package/dist/components/dropdown-menu/item.js.map +1 -1
- package/dist/components/dropdown-menu/style.css +1 -1
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts.map +1 -1
- package/dist/components/dropdown-menu/useDropdownMenu.js +60 -63
- package/dist/components/dropdown-menu/useDropdownMenu.js.map +1 -1
- package/dist/components/field/component.d.ts +5 -1
- package/dist/components/field/component.d.ts.map +1 -1
- package/dist/components/field/component.js +29 -20
- package/dist/components/field/component.js.map +1 -1
- package/dist/components/popup-panel/component.d.ts.map +1 -1
- package/dist/components/popup-panel/component.js +101 -101
- package/dist/components/popup-panel/component.js.map +1 -1
- package/dist/components/scroll-area/component.d.ts +1 -1
- package/dist/components/scroll-area/component.d.ts.map +1 -1
- package/dist/components/scroll-area/component.js +74 -58
- package/dist/components/scroll-area/component.js.map +1 -1
- package/dist/components/select-trigger/component.d.ts +71 -9
- package/dist/components/select-trigger/component.d.ts.map +1 -1
- package/dist/components/select-trigger/component.js +180 -139
- package/dist/components/select-trigger/component.js.map +1 -1
- package/dist/components/select-trigger/index.d.ts +1 -2
- package/dist/components/select-trigger/index.d.ts.map +1 -1
- package/dist/components/select-trigger/style.css +1 -1
- package/dist/components/table/component.d.ts.map +1 -1
- package/dist/components/table/component.js +53 -52
- package/dist/components/table/component.js.map +1 -1
- package/dist/components/theme-provider/style.css +1 -1
- package/dist/components/truncate/component.d.ts.map +1 -1
- package/dist/components/truncate/component.js +84 -80
- package/dist/components/truncate/component.js.map +1 -1
- package/dist/components/truncate/helpers.d.ts +9 -0
- package/dist/components/truncate/helpers.d.ts.map +1 -1
- package/dist/components/truncate/helpers.js +70 -40
- package/dist/components/truncate/helpers.js.map +1 -1
- package/dist/components/truncate/index.d.ts +1 -0
- package/dist/components/truncate/index.d.ts.map +1 -1
- package/dist/components/truncate/useOverflowDetection.d.ts +19 -0
- package/dist/components/truncate/useOverflowDetection.d.ts.map +1 -0
- package/dist/components/truncate/useOverflowDetection.js +54 -0
- package/dist/components/truncate/useOverflowDetection.js.map +1 -0
- package/dist/components/utils/WithRenderProp.d.ts.map +1 -1
- package/dist/components/utils/WithRenderProp.js +10 -10
- package/dist/components/utils/WithRenderProp.js.map +1 -1
- package/dist/components/vertical-collapsible-panel/component.d.ts +14 -0
- package/dist/components/vertical-collapsible-panel/component.d.ts.map +1 -1
- package/dist/components/vertical-collapsible-panel/component.js +82 -75
- package/dist/components/vertical-collapsible-panel/component.js.map +1 -1
- package/dist/components/vertical-collapsible-panel/style.css +1 -1
- package/dist/index.js +230 -224
- package/dist/index.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +5 -6
- package/dist/components/dropdown-menu/item.css +0 -1
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { DropdownMenuItemType } from './types';
|
|
3
3
|
export interface DropdownMenuItemProps {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* The menu item data
|
|
6
|
+
*/
|
|
5
7
|
item: DropdownMenuItemType & {
|
|
6
8
|
type: "item";
|
|
7
9
|
};
|
|
8
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Custom render function for the item
|
|
12
|
+
*/
|
|
9
13
|
itemRender?: (item: DropdownMenuItemType, props: React.HTMLAttributes<HTMLElement>) => React.ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* Custom render function for the item label
|
|
16
|
+
*/
|
|
10
17
|
itemLabelRender?: (item: DropdownMenuItemType & {
|
|
11
18
|
type: "item";
|
|
12
19
|
}, props: React.HTMLAttributes<HTMLElement>) => React.ReactElement;
|
|
13
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Additional props to pass to the item
|
|
22
|
+
*/
|
|
14
23
|
itemProps?: React.HTMLAttributes<HTMLElement>;
|
|
15
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Class names from parent DropdownMenu
|
|
26
|
+
*/
|
|
16
27
|
classNames?: {
|
|
17
28
|
item?: string;
|
|
18
29
|
itemIcon?: string;
|
|
19
30
|
itemText?: string;
|
|
20
31
|
itemSuffix?: string;
|
|
21
32
|
};
|
|
22
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Function to be called after the menu item is selected
|
|
35
|
+
*/
|
|
36
|
+
afterSelect?: (item: DropdownMenuItemType & {
|
|
23
37
|
type: "item";
|
|
24
38
|
}) => void;
|
|
25
39
|
/**
|
|
26
40
|
* Whether the menu item is in a combobox
|
|
27
41
|
*/
|
|
28
42
|
inCombobox?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Whether the menu item is in a menu
|
|
31
|
-
*/
|
|
32
|
-
renderAsNativeElement?: boolean;
|
|
33
43
|
/**
|
|
34
44
|
* Whether the menu item is selected (for combobox)
|
|
35
45
|
* @default false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/item.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/item.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,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;I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
|
-
import { Command as
|
|
5
|
-
import { Menu as
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import { WithRenderProp as I } from "../utils/WithRenderProp.js";
|
|
12
|
-
const J = ({
|
|
2
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback as b, useMemo as x } from "react";
|
|
4
|
+
import { Command as O } from "../cmdk/index.js";
|
|
5
|
+
import { Menu as y } from "@base-ui-components/react/menu";
|
|
6
|
+
import { BaseMenuItem as S } from "../base-menu/item.js";
|
|
7
|
+
import { reactNodeToString as w } from "../utils/reactToString.js";
|
|
8
|
+
import { useCls as C } from "../utils/antdUtils.js";
|
|
9
|
+
import { clsx as p } from "../utils/cn.js";
|
|
10
|
+
const D = ({
|
|
13
11
|
item: o,
|
|
14
|
-
inCombobox:
|
|
15
|
-
selected:
|
|
16
|
-
itemRender:
|
|
17
|
-
itemLabelRender:
|
|
18
|
-
itemProps:
|
|
12
|
+
inCombobox: e = !1,
|
|
13
|
+
selected: u = !1,
|
|
14
|
+
itemRender: d,
|
|
15
|
+
itemLabelRender: f,
|
|
16
|
+
itemProps: t = {},
|
|
19
17
|
classNames: n,
|
|
20
|
-
|
|
21
|
-
showCheckbox:
|
|
22
|
-
indeterminate:
|
|
23
|
-
|
|
24
|
-
getItemKeywords: t
|
|
18
|
+
afterSelect: a,
|
|
19
|
+
showCheckbox: v,
|
|
20
|
+
indeterminate: k,
|
|
21
|
+
getItemKeywords: l
|
|
25
22
|
}) => {
|
|
26
|
-
const
|
|
27
|
-
() =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
const c = C(), M = b(
|
|
24
|
+
(r) => {
|
|
25
|
+
o.onSelect && o.onSelect(o), o.onClick && typeof r == "object" && o.onClick(r), a && a(o);
|
|
26
|
+
},
|
|
27
|
+
[a, o]
|
|
28
|
+
), g = x(
|
|
29
|
+
() => l ? l(o) : [String(o.key), w(o.label)],
|
|
30
|
+
[l, o]
|
|
31
|
+
);
|
|
32
|
+
return d ? d(o, {
|
|
33
|
+
className: p(
|
|
34
|
+
c("dropdown-menu-item", e && "dropdown-menu-item-combobox"),
|
|
32
35
|
n?.item,
|
|
33
36
|
o.className
|
|
34
37
|
),
|
|
35
|
-
disabled: o.disabled,
|
|
36
38
|
"data-danger": o.danger,
|
|
37
|
-
"data-actual-selected":
|
|
39
|
+
"data-actual-selected": u,
|
|
40
|
+
"data-value": typeof o.label == "string" ? o.label : String(o.key),
|
|
38
41
|
ref: o.ref,
|
|
39
42
|
onClick: o.onClick,
|
|
40
43
|
onMouseEnter: o.onMouseEnter,
|
|
41
44
|
onMouseLeave: o.onMouseLeave,
|
|
42
45
|
onMouseOver: o.onMouseOver,
|
|
43
46
|
onMouseOut: o.onMouseOut,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
n?.itemIcon
|
|
61
|
-
),
|
|
62
|
-
children: o.icon
|
|
63
|
-
}
|
|
64
|
-
),
|
|
65
|
-
/* @__PURE__ */ r(
|
|
66
|
-
I,
|
|
67
|
-
{
|
|
68
|
-
render: p ? (a) => p(o, a) : void 0,
|
|
69
|
-
as: "span",
|
|
70
|
-
className: e(
|
|
71
|
-
d("dropdown-menu-item-text"),
|
|
72
|
-
n?.itemText
|
|
73
|
-
),
|
|
74
|
-
children: o.label
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
] }) : /* @__PURE__ */ x(h, { children: [
|
|
78
|
-
l && /* @__PURE__ */ r(
|
|
79
|
-
g,
|
|
80
|
-
{
|
|
81
|
-
checked: s,
|
|
82
|
-
tabIndex: -1,
|
|
83
|
-
indeterminate: i
|
|
84
|
-
}
|
|
85
|
-
),
|
|
86
|
-
o.icon && /* @__PURE__ */ r(
|
|
87
|
-
"span",
|
|
88
|
-
{
|
|
89
|
-
className: e(
|
|
90
|
-
d("dropdown-menu-item-icon"),
|
|
91
|
-
n?.itemIcon
|
|
47
|
+
...t
|
|
48
|
+
}) : /* @__PURE__ */ s(
|
|
49
|
+
S,
|
|
50
|
+
{
|
|
51
|
+
disabled: o.disabled,
|
|
52
|
+
danger: o.danger,
|
|
53
|
+
selected: u,
|
|
54
|
+
showCheckbox: v,
|
|
55
|
+
indeterminate: k,
|
|
56
|
+
icon: o.icon,
|
|
57
|
+
suffix: e ? void 0 : o.suffix,
|
|
58
|
+
classNames: {
|
|
59
|
+
root: p(
|
|
60
|
+
c(
|
|
61
|
+
"dropdown-menu-item",
|
|
62
|
+
e && "dropdown-menu-item-combobox"
|
|
92
63
|
),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
o.
|
|
105
|
-
|
|
64
|
+
n?.item,
|
|
65
|
+
o.className
|
|
66
|
+
),
|
|
67
|
+
icon: n?.itemIcon,
|
|
68
|
+
text: n?.itemText,
|
|
69
|
+
suffix: n?.itemSuffix
|
|
70
|
+
},
|
|
71
|
+
labelRender: f ? (r) => f(o, r) : void 0,
|
|
72
|
+
ref: o.ref,
|
|
73
|
+
onMouseEnter: o.onMouseEnter,
|
|
74
|
+
onMouseLeave: o.onMouseLeave,
|
|
75
|
+
onMouseOver: o.onMouseOver,
|
|
76
|
+
onMouseOut: o.onMouseOut,
|
|
77
|
+
"data-value": typeof o.label == "string" ? o.label : String(o.key),
|
|
78
|
+
"data-actual-selected": u,
|
|
79
|
+
render: e ? /* @__PURE__ */ s(
|
|
80
|
+
O.Item,
|
|
106
81
|
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
),
|
|
111
|
-
children: o.suffix
|
|
82
|
+
value: String(o.key),
|
|
83
|
+
keywords: g || void 0,
|
|
84
|
+
onSelect: M
|
|
112
85
|
}
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
}), [
|
|
116
|
-
n?.item,
|
|
117
|
-
n?.itemIcon,
|
|
118
|
-
n?.itemText,
|
|
119
|
-
n?.itemSuffix,
|
|
120
|
-
d,
|
|
121
|
-
u,
|
|
122
|
-
i,
|
|
123
|
-
o,
|
|
124
|
-
c,
|
|
125
|
-
s,
|
|
126
|
-
l,
|
|
127
|
-
p
|
|
128
|
-
]), O = M(
|
|
129
|
-
() => t ? t(o) : [String(o.key), P(o.label)],
|
|
130
|
-
[t, o]
|
|
131
|
-
);
|
|
132
|
-
if (c)
|
|
133
|
-
return c(o, {
|
|
134
|
-
...f,
|
|
135
|
-
...S
|
|
136
|
-
});
|
|
137
|
-
const { render: k, ...T } = f;
|
|
138
|
-
return w ? k ? k(f) : /* @__PURE__ */ r("div", { onClick: v, ...T }) : /* @__PURE__ */ r(
|
|
139
|
-
y,
|
|
140
|
-
{
|
|
141
|
-
value: String(o.key),
|
|
142
|
-
keywords: O || void 0,
|
|
143
|
-
onSelect: () => {
|
|
144
|
-
v(o);
|
|
145
|
-
},
|
|
146
|
-
...f
|
|
86
|
+
) : /* @__PURE__ */ s(y.Item, { onClick: M }),
|
|
87
|
+
children: o.label
|
|
147
88
|
}
|
|
148
89
|
);
|
|
149
90
|
};
|
|
150
91
|
export {
|
|
151
|
-
|
|
92
|
+
D as DropdownMenuItem
|
|
152
93
|
};
|
|
153
94
|
//# 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, useMemo } from \"react\";\nimport { clsx, reactNodeToString, useCls
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../src/components/dropdown-menu/item.tsx"],"sourcesContent":["\"use client\";\nimport React, { Ref, useCallback, useMemo } from \"react\";\nimport { clsx, reactNodeToString, useCls } 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 if (item.onSelect) item.onSelect(item);\n if (item.onClick && typeof e === \"object\") item.onClick(e);\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: item.onClick,\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","keywords","useMemo","reactNodeToString","clsx","jsx","BaseMenuItem","props","Command","Menu"],"mappings":";;;;;;;;;AAqEO,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;AAC1D,MAAIf,EAAK,YAAUA,EAAK,SAASA,CAAI,GACjCA,EAAK,WAAW,OAAOe,KAAM,YAAUf,EAAK,QAAQe,CAAC,GACrDR,OAAyBP,CAAI;AAAA,IACnC;AAAA,IACA,CAACO,GAAaP,CAAI;AAAA,EAAA,GAGdgB,IAAWC;AAAA,IACf,MACEP,IACIA,EAAgBV,CAAI,IACpB,CAAC,OAAOA,EAAK,GAAG,GAAGkB,EAAkBlB,EAAK,KAAK,CAAC;AAAA,IACtD,CAACU,GAAiBV,CAAI;AAAA,EAAA;AAIxB,SAAIG,IACKA,EAAWH,GAAM;AAAA,IACtB,WAAWmB;AAAA,MACTR,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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er components{.ds-dropdown-menu-search{margin-bottom:.25rem}.ds-dropdown-menu-header{font-size:.75rem;font-weight:500;line-height:1rem;text-transform:uppercase;color:var(--ds-color-text-tertiary);padding:.75rem .75rem .25rem}.ds-dropdown-menu-header:first-child{padding-top:.5rem}.ds-dropdown-menu-empty{padding:.375rem .75rem;color:var(--ds-color-text-tertiary)}.ds-dropdown-menu-match-trigger-width{width:min(var(--anchor-width),var(--available-width))}.ds-dropdown-menu-container{display:flex;flex-direction:column;flex-shrink:1;min-height:0}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDropdownMenu.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAOlE,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF;;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,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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;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC;IAC/B;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;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,eAAe,GAAI,kJAW7B,oBAAoB;;2BAGZ,oBAAoB,KAAK,MAAM,KAAK,MAAM;yBAqEzC,iBAAiB,SAAS,MAAM;CA2D3C,CAAC"}
|
|
@@ -1,127 +1,124 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t, jsxs as D } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback as m, useMemo as S } from "react";
|
|
3
3
|
import { DropdownMenuItem as k } from "./item.js";
|
|
4
|
-
import { DropdownMenuDivider as
|
|
5
|
-
import { Menu as
|
|
4
|
+
import { DropdownMenuDivider as I } from "./divider.js";
|
|
5
|
+
import { Menu as b } from "@base-ui-components/react";
|
|
6
6
|
import { Command as L } from "../cmdk/index.js";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
7
|
+
import './style.css';/* empty css */
|
|
8
|
+
import { useCls as j } from "../utils/antdUtils.js";
|
|
9
|
+
import { reactNodeToString as T } from "../utils/reactToString.js";
|
|
9
10
|
import { clsx as d } from "../utils/cn.js";
|
|
10
|
-
const
|
|
11
|
-
items:
|
|
12
|
-
inCombobox:
|
|
11
|
+
const U = ({
|
|
12
|
+
items: f,
|
|
13
|
+
inCombobox: u = !1,
|
|
13
14
|
classNames: o = {},
|
|
14
|
-
selectedItemKeys:
|
|
15
|
+
selectedItemKeys: s,
|
|
15
16
|
keepOpenOnSelect: h,
|
|
16
|
-
showCheckbox:
|
|
17
|
-
getItemKeywords:
|
|
18
|
-
onOpenChange:
|
|
19
|
-
itemRender:
|
|
20
|
-
itemLabelRender:
|
|
17
|
+
showCheckbox: a = !1,
|
|
18
|
+
getItemKeywords: g = (p) => [String(p.key), T(p.label)],
|
|
19
|
+
onOpenChange: G,
|
|
20
|
+
itemRender: y,
|
|
21
|
+
itemLabelRender: M
|
|
21
22
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
(e, r,
|
|
23
|
+
const p = j(), l = m(
|
|
24
|
+
(e, r, i) => e.type === "item" ? /* @__PURE__ */ t(
|
|
24
25
|
k,
|
|
25
26
|
{
|
|
26
27
|
item: e,
|
|
27
|
-
inCombobox:
|
|
28
|
-
selected:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
itemRender: M,
|
|
37
|
-
showCheckbox: G,
|
|
38
|
-
getItemKeywords: b,
|
|
39
|
-
itemLabelRender: c,
|
|
28
|
+
inCombobox: u,
|
|
29
|
+
selected: s?.includes(e.key),
|
|
30
|
+
afterSelect: () => {
|
|
31
|
+
h || G?.(!1);
|
|
32
|
+
},
|
|
33
|
+
itemRender: y,
|
|
34
|
+
showCheckbox: a,
|
|
35
|
+
getItemKeywords: g,
|
|
36
|
+
itemLabelRender: M,
|
|
40
37
|
classNames: {
|
|
41
38
|
item: o.item,
|
|
42
39
|
itemIcon: o.itemIcon,
|
|
43
40
|
itemSuffix: o.itemSuffix
|
|
44
41
|
}
|
|
45
42
|
},
|
|
46
|
-
r + "-" +
|
|
47
|
-
) : e.type === "divider" ? /* @__PURE__ */
|
|
48
|
-
|
|
43
|
+
r + "-" + i
|
|
44
|
+
) : e.type === "divider" ? /* @__PURE__ */ t(
|
|
45
|
+
I,
|
|
49
46
|
{
|
|
50
|
-
inCombobox:
|
|
47
|
+
inCombobox: u,
|
|
51
48
|
className: o?.divider
|
|
52
49
|
},
|
|
53
|
-
r + "-" +
|
|
50
|
+
r + "-" + i
|
|
54
51
|
) : null,
|
|
55
52
|
[
|
|
56
53
|
o,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
y,
|
|
55
|
+
G,
|
|
56
|
+
u,
|
|
60
57
|
h,
|
|
58
|
+
s,
|
|
61
59
|
a,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
c
|
|
60
|
+
g,
|
|
61
|
+
M
|
|
65
62
|
]
|
|
66
63
|
), v = m(
|
|
67
|
-
(e, r) => /* @__PURE__ */
|
|
68
|
-
|
|
64
|
+
(e, r) => /* @__PURE__ */ D(
|
|
65
|
+
b.Group,
|
|
69
66
|
{
|
|
70
|
-
className: d(
|
|
67
|
+
className: d(p("dropdown-menu-group"), o?.group),
|
|
71
68
|
children: [
|
|
72
|
-
e.label && /* @__PURE__ */
|
|
73
|
-
|
|
69
|
+
e.label && /* @__PURE__ */ t(
|
|
70
|
+
b.GroupLabel,
|
|
74
71
|
{
|
|
75
72
|
className: d(
|
|
76
|
-
|
|
73
|
+
p("dropdown-menu-header"),
|
|
77
74
|
o?.groupLabel
|
|
78
75
|
),
|
|
79
|
-
children: /* @__PURE__ */
|
|
76
|
+
children: /* @__PURE__ */ t("span", { children: e.label })
|
|
80
77
|
}
|
|
81
78
|
),
|
|
82
|
-
e.items.map((
|
|
79
|
+
e.items.map((i, n) => l(i, r, n))
|
|
83
80
|
]
|
|
84
81
|
},
|
|
85
82
|
"group" + r
|
|
86
83
|
),
|
|
87
|
-
[
|
|
84
|
+
[p, o, l]
|
|
88
85
|
), w = m(
|
|
89
|
-
(e, r) => e.label ? /* @__PURE__ */
|
|
86
|
+
(e, r) => e.label ? /* @__PURE__ */ t(
|
|
90
87
|
L.Group,
|
|
91
88
|
{
|
|
92
|
-
className: d(
|
|
93
|
-
heading: /* @__PURE__ */
|
|
94
|
-
|
|
89
|
+
className: d(p("dropdown-menu-group"), o?.group),
|
|
90
|
+
heading: /* @__PURE__ */ t(
|
|
91
|
+
"div",
|
|
95
92
|
{
|
|
96
93
|
className: d(
|
|
97
|
-
|
|
94
|
+
p("dropdown-menu-header"),
|
|
98
95
|
o?.groupLabel
|
|
99
96
|
),
|
|
100
|
-
children: /* @__PURE__ */
|
|
97
|
+
children: /* @__PURE__ */ t("span", { children: e.label })
|
|
101
98
|
}
|
|
102
99
|
),
|
|
103
|
-
children: e.items.map((
|
|
100
|
+
children: e.items.map((i, n) => l(i, r, n))
|
|
104
101
|
},
|
|
105
102
|
"group" + r
|
|
106
|
-
) : e.items.map((
|
|
107
|
-
[
|
|
103
|
+
) : e.items.map((i, n) => l(i, r, n)),
|
|
104
|
+
[p, o, l]
|
|
108
105
|
);
|
|
109
106
|
return {
|
|
110
107
|
itemGroups: S(
|
|
111
|
-
() =>
|
|
108
|
+
() => f.reduce((e, r) => (e.length === 0 && r.type !== "header" && e.push({
|
|
112
109
|
label: null,
|
|
113
110
|
items: []
|
|
114
111
|
}), r.type === "header" ? e.push({
|
|
115
112
|
label: r.title,
|
|
116
113
|
items: []
|
|
117
114
|
}) : (r.type === "item" || r.type === "divider") && e.length > 0 && e[e.length - 1].items.push(r), e), []),
|
|
118
|
-
[
|
|
115
|
+
[f]
|
|
119
116
|
),
|
|
120
|
-
renderMenuItem:
|
|
121
|
-
renderGroup:
|
|
117
|
+
renderMenuItem: l,
|
|
118
|
+
renderGroup: u ? w : v
|
|
122
119
|
};
|
|
123
120
|
};
|
|
124
121
|
export {
|
|
125
|
-
|
|
122
|
+
U as useDropdownMenu
|
|
126
123
|
};
|
|
127
124
|
//# sourceMappingURL=useDropdownMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDropdownMenu.js","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { DropdownMenuItemType, DropdownMenuGroup } from \"./types\";\nimport { DropdownMenuItem } from \"./item\";\nimport { DropdownMenuDivider } from \"./divider\";\nimport { reactNodeToString, clsx, useCls } from \"../utils\";\nimport { Menu } from \"@base-ui-components/react\";\nimport { Command } from \"../cmdk\";\n\nexport interface UseDropdownMenuProps {\n /**\n * Callback function to handle the open state change of the dropdown menu.\n */\n onOpenChange?: (open: boolean) => void;\n items: DropdownMenuItemType[];\n inCombobox?: boolean;\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemSuffix?: string;\n group?: string;\n groupLabel?: string;\n divider?: string;\n };\n /**\n * Custom render function for menu items\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Custom render function for menu item labels\n */\n itemLabelRender?: (\n item: DropdownMenuItemType & { type: \"item\" },\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Whether to keep the dropdown open when an item is selected\n * @default false\n */\n keepOpenOnSelect?: boolean;\n /**\n * Control the highlighted state of the menu item\n */\n highlightedItemKey?: React.Key;\n /**\n * Control the selected state of the menu item\n */\n selectedItemKeys?: React.Key[];\n /**\n * Whether to show checkbox\n * @default false\n */\n showCheckbox?: 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 useDropdownMenu = ({\n items,\n inCombobox = false,\n classNames = {},\n selectedItemKeys,\n keepOpenOnSelect,\n showCheckbox = false,\n getItemKeywords = (item) => [String(item.key), reactNodeToString(item.label)],\n onOpenChange,\n itemRender,\n itemLabelRender,\n}: UseDropdownMenuProps) => {\n const cls = useCls();\n const renderMenuItem = useCallback(\n (item: DropdownMenuItemType, i: number, j: number) => {\n if (item.type === \"item\") {\n return (\n <DropdownMenuItem\n key={i + \"-\" + j}\n item={item}\n inCombobox={inCombobox}\n selected={selectedItemKeys?.includes(item.key)}\n
|
|
1
|
+
{"version":3,"file":"useDropdownMenu.js","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { DropdownMenuItemType, DropdownMenuGroup } from \"./types\";\nimport { DropdownMenuItem } from \"./item\";\nimport { DropdownMenuDivider } from \"./divider\";\nimport { reactNodeToString, clsx, useCls } from \"../utils\";\nimport { Menu } from \"@base-ui-components/react\";\nimport { Command } from \"../cmdk\";\n\nimport \"./style.css\";\n\nexport interface UseDropdownMenuProps {\n /**\n * Callback function to handle the open state change of the dropdown menu.\n */\n onOpenChange?: (open: boolean) => void;\n items: DropdownMenuItemType[];\n inCombobox?: boolean;\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemSuffix?: string;\n group?: string;\n groupLabel?: string;\n divider?: string;\n };\n /**\n * Custom render function for menu items\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Custom render function for menu item labels\n */\n itemLabelRender?: (\n item: DropdownMenuItemType & { type: \"item\" },\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Whether to keep the dropdown open when an item is selected\n * @default false\n */\n keepOpenOnSelect?: boolean;\n /**\n * Control the highlighted state of the menu item\n */\n highlightedItemKey?: React.Key;\n /**\n * Control the selected state of the menu item\n */\n selectedItemKeys?: React.Key[];\n /**\n * Whether to show checkbox\n * @default false\n */\n showCheckbox?: 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 useDropdownMenu = ({\n items,\n inCombobox = false,\n classNames = {},\n selectedItemKeys,\n keepOpenOnSelect,\n showCheckbox = false,\n getItemKeywords = (item) => [String(item.key), reactNodeToString(item.label)],\n onOpenChange,\n itemRender,\n itemLabelRender,\n}: UseDropdownMenuProps) => {\n const cls = useCls();\n const renderMenuItem = useCallback(\n (item: DropdownMenuItemType, i: number, j: number) => {\n if (item.type === \"item\") {\n return (\n <DropdownMenuItem\n key={i + \"-\" + j}\n item={item}\n inCombobox={inCombobox}\n selected={selectedItemKeys?.includes(item.key)}\n afterSelect={() => {\n if (!keepOpenOnSelect) onOpenChange?.(false);\n }}\n itemRender={itemRender}\n showCheckbox={showCheckbox}\n getItemKeywords={getItemKeywords}\n itemLabelRender={itemLabelRender}\n classNames={{\n item: classNames.item,\n itemIcon: classNames.itemIcon,\n itemSuffix: classNames.itemSuffix,\n }}\n />\n );\n } else if (item.type === \"divider\") {\n return (\n <DropdownMenuDivider\n key={i + \"-\" + j}\n inCombobox={inCombobox}\n className={classNames?.divider}\n />\n );\n }\n return null;\n },\n [\n classNames,\n itemRender,\n onOpenChange,\n inCombobox,\n keepOpenOnSelect,\n selectedItemKeys,\n showCheckbox,\n getItemKeywords,\n itemLabelRender,\n ]\n );\n\n const renderGroup = useCallback(\n (group: DropdownMenuGroup, index: number) => (\n <Menu.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n >\n {group.label && (\n <Menu.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n )}\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Menu.Group>\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderGroupCombobox = useCallback(\n (group: DropdownMenuGroup, index: number) =>\n group.label ? (\n <Command.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n heading={\n <div\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </div>\n }\n >\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Command.Group>\n ) : (\n group.items.map((item, j) => renderMenuItem(item, index, j))\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const itemGroups = useMemo(\n () =>\n items.reduce<DropdownMenuGroup[]>((acc, current) => {\n // If no groups exist yet and current item is not a header, create default group\n if (acc.length === 0 && current.type !== \"header\") {\n acc.push({\n label: null,\n items: [],\n });\n }\n\n // If it's a header, create a new group\n if (current.type === \"header\") {\n acc.push({\n label: current.title,\n items: [],\n });\n }\n // If it's an item and we have at least one group, add it to the last group's items\n else if (\n (current.type === \"item\" || current.type === \"divider\") &&\n acc.length > 0\n ) {\n acc[acc.length - 1].items.push(current);\n }\n // Skip dividers\n return acc;\n }, []),\n [items]\n );\n return {\n itemGroups,\n renderMenuItem,\n renderGroup: inCombobox ? renderGroupCombobox : renderGroup,\n };\n};\n"],"names":["useDropdownMenu","items","inCombobox","classNames","selectedItemKeys","keepOpenOnSelect","showCheckbox","getItemKeywords","item","reactNodeToString","onOpenChange","itemRender","itemLabelRender","cls","useCls","renderMenuItem","useCallback","i","j","jsx","DropdownMenuItem","DropdownMenuDivider","renderGroup","group","index","jsxs","Menu","clsx","renderGroupCombobox","Command","useMemo","acc","current"],"mappings":";;;;;;;;;;AAgEO,MAAMA,IAAkB,CAAC;AAAA,EAC9B,OAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,YAAAC,IAAa,CAAA;AAAA,EACb,kBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,iBAAAC,IAAkB,CAACC,MAAS,CAAC,OAAOA,EAAK,GAAG,GAAGC,EAAkBD,EAAK,KAAK,CAAC;AAAA,EAC5E,cAAAE;AAAA,EACA,YAAAC;AAAA,EACA,iBAAAC;AACF,MAA4B;AAC1B,QAAMC,IAAMC,EAAA,GACNC,IAAiBC;AAAA,IACrB,CAACR,G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E;AAAA,MACP,CAAC9B,CAAK;AAAA,IAAA;AAAA,IAIN,gBAAAc;AAAA,IACA,aAAab,IAAa0B,IAAsBN;AAAA,EAAA;AAEpD;"}
|
|
@@ -21,6 +21,10 @@ interface BaseFieldProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
21
21
|
* @default true
|
|
22
22
|
*/
|
|
23
23
|
colon?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Props for the label element
|
|
26
|
+
*/
|
|
27
|
+
labelProps?: React.HTMLAttributes<HTMLLabelElement>;
|
|
24
28
|
}
|
|
25
29
|
type InputFieldProps = BaseFieldProps & {
|
|
26
30
|
type?: "input";
|
|
@@ -34,7 +38,7 @@ export type FieldProps<T extends FieldType = "input"> = T extends "input" ? Inpu
|
|
|
34
38
|
/**
|
|
35
39
|
* Generic Field component that forwards ref to Input or Select
|
|
36
40
|
*/
|
|
37
|
-
declare const FieldInner: <T extends FieldType>({ label, className, size, colon, type, ...rest }: FieldProps<T>, ref: ForwardedRef<RefType<T>>) => import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
declare const FieldInner: <T extends FieldType>({ label, className, size, colon, type, labelProps, ...rest }: FieldProps<T>, ref: ForwardedRef<RefType<T>>) => import("react/jsx-runtime").JSX.Element;
|
|
38
42
|
export declare const Field: <T extends FieldType>(props: FieldProps<T> & {
|
|
39
43
|
ref?: ForwardedRef<RefType<T>>;
|
|
40
44
|
}) => ReturnType<typeof FieldInner<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/field/component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAqB,MAAM,O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