braid-design-system 33.2.2 → 33.3.0
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/CHANGELOG.md +63 -0
- package/dist/index.cjs +13 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +13 -0
- package/dist/lib/components/Accordion/Accordion.cjs +6 -4
- package/dist/lib/components/Accordion/Accordion.mjs +6 -4
- package/dist/lib/components/Accordion/AccordionItem.cjs +55 -55
- package/dist/lib/components/Accordion/AccordionItem.mjs +55 -55
- package/dist/lib/components/Badge/Badge.cjs +5 -3
- package/dist/lib/components/Badge/Badge.mjs +5 -3
- package/dist/lib/components/Badge/defaultBadgeProps.cjs +28 -0
- package/dist/lib/components/Badge/defaultBadgeProps.mjs +29 -0
- package/dist/lib/components/Button/Button.cjs +1 -0
- package/dist/lib/components/Button/Button.mjs +1 -0
- package/dist/lib/components/Columns/Columns.cjs +1 -0
- package/dist/lib/components/Columns/Columns.mjs +1 -0
- package/dist/lib/components/MenuItem/MenuItem.cjs +1 -1
- package/dist/lib/components/MenuItem/MenuItem.mjs +1 -1
- package/dist/lib/components/MenuItem/MenuItemLink.cjs +1 -1
- package/dist/lib/components/MenuItem/MenuItemLink.mjs +1 -1
- package/dist/lib/components/MenuItem/useMenuItem.cjs +39 -42
- package/dist/lib/components/MenuItem/useMenuItem.css.cjs +5 -0
- package/dist/lib/components/MenuItem/useMenuItem.css.mjs +6 -1
- package/dist/lib/components/MenuItem/useMenuItem.mjs +41 -44
- package/dist/lib/components/MenuItemCheckbox/MenuItemCheckbox.cjs +36 -43
- package/dist/lib/components/MenuItemCheckbox/MenuItemCheckbox.mjs +37 -44
- package/dist/lib/components/MenuRenderer/MenuRenderer.cjs +39 -24
- package/dist/lib/components/MenuRenderer/MenuRenderer.css.cjs +4 -3
- package/dist/lib/components/MenuRenderer/MenuRenderer.css.mjs +5 -4
- package/dist/lib/components/MenuRenderer/MenuRenderer.mjs +40 -25
- package/dist/lib/components/OverflowMenu/OverflowMenu.cjs +4 -1
- package/dist/lib/components/OverflowMenu/OverflowMenu.mjs +4 -1
- package/dist/lib/components/Table/Table.cjs +28 -0
- package/dist/lib/components/Table/Table.css.cjs +95 -0
- package/dist/lib/components/Table/Table.css.mjs +96 -0
- package/dist/lib/components/Table/Table.mjs +29 -0
- package/dist/lib/components/Table/TableBody.cjs +24 -0
- package/dist/lib/components/Table/TableBody.mjs +23 -0
- package/dist/lib/components/Table/TableCell.cjs +118 -0
- package/dist/lib/components/Table/TableCell.mjs +117 -0
- package/dist/lib/components/Table/TableContext.cjs +12 -0
- package/dist/lib/components/Table/TableContext.mjs +13 -0
- package/dist/lib/components/Table/TableFooter.cjs +28 -0
- package/dist/lib/components/Table/TableFooter.mjs +27 -0
- package/dist/lib/components/Table/TableHeader.cjs +28 -0
- package/dist/lib/components/Table/TableHeader.mjs +27 -0
- package/dist/lib/components/Table/TableRow.cjs +36 -0
- package/dist/lib/components/Table/TableRow.mjs +35 -0
- package/dist/lib/components/Text/Text.cjs +5 -2
- package/dist/lib/components/Text/Text.mjs +5 -2
- package/dist/lib/components/Tiles/Tiles.cjs +6 -5
- package/dist/lib/components/Tiles/Tiles.css.cjs +3 -3
- package/dist/lib/components/Tiles/Tiles.css.mjs +4 -4
- package/dist/lib/components/Tiles/Tiles.mjs +6 -5
- package/dist/lib/components/private/ScrollContainer/ScrollContainer.cjs +2 -2
- package/dist/lib/components/private/ScrollContainer/ScrollContainer.mjs +2 -2
- package/dist/lib/components/private/defaultTextProps.cjs +11 -6
- package/dist/lib/components/private/defaultTextProps.mjs +11 -6
- package/dist/lib/hooks/useIsomorphicLayoutEffect.cjs +3 -1
- package/dist/lib/hooks/useIsomorphicLayoutEffect.mjs +3 -1
- package/dist/lib/playroom/snippets/MenuRenderer.cjs +51 -0
- package/dist/lib/playroom/snippets/MenuRenderer.mjs +52 -0
- package/dist/lib/playroom/snippets/OverflowMenu.cjs +3 -0
- package/dist/lib/playroom/snippets/OverflowMenu.mjs +3 -0
- package/dist/lib/playroom/snippets/Table.cjs +179 -0
- package/dist/lib/playroom/snippets/Table.mjs +180 -0
- package/dist/lib/playroom/snippets.cjs +4 -0
- package/dist/lib/playroom/snippets.mjs +52 -48
- package/dist/playroom/components.cjs +13 -0
- package/dist/playroom/components.d.mts +1 -1
- package/dist/playroom/components.d.ts +1 -1
- package/dist/playroom/components.mjs +13 -0
- package/dist/wireframe.chunk.d.ts +57 -7
- package/package.json +1 -1
|
@@ -48,6 +48,7 @@ const Columns = ({
|
|
|
48
48
|
{
|
|
49
49
|
component,
|
|
50
50
|
...collapsibleAlignmentProps,
|
|
51
|
+
height: "full",
|
|
51
52
|
className: lib_css_negativeMargin_negativeMargin_cjs.negativeMargin("left", {
|
|
52
53
|
mobile: collapseMobile ? "none" : mobileSpace,
|
|
53
54
|
tablet: collapseTablet ? "none" : tabletSpace,
|
|
@@ -17,7 +17,7 @@ const MenuItem = ({
|
|
|
17
17
|
data,
|
|
18
18
|
id
|
|
19
19
|
});
|
|
20
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lib_components_Box_Box_cjs.Box, { ...menuItemProps, component: "button", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(MenuItemChildren, { tone, icon, badge, children }) });
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(lib_components_Box_Box_cjs.Box, { ...menuItemProps, component: "button", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(MenuItemChildren, { tone, leftSlot: icon, badge, children }) });
|
|
21
21
|
};
|
|
22
22
|
MenuItem.__isMenuItem__ = true;
|
|
23
23
|
exports.MenuItem = MenuItem;
|
|
@@ -16,7 +16,7 @@ const MenuItem = ({
|
|
|
16
16
|
data,
|
|
17
17
|
id
|
|
18
18
|
});
|
|
19
|
-
return /* @__PURE__ */ jsx(Box, { ...menuItemProps, component: "button", type: "button", children: /* @__PURE__ */ jsx(MenuItemChildren, { tone, icon, badge, children }) });
|
|
19
|
+
return /* @__PURE__ */ jsx(Box, { ...menuItemProps, component: "button", type: "button", children: /* @__PURE__ */ jsx(MenuItemChildren, { tone, leftSlot: icon, badge, children }) });
|
|
20
20
|
};
|
|
21
21
|
MenuItem.__isMenuItem__ = true;
|
|
22
22
|
export {
|
|
@@ -30,7 +30,7 @@ const MenuItemLink = ({
|
|
|
30
30
|
href,
|
|
31
31
|
target,
|
|
32
32
|
rel,
|
|
33
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(MenuItemChildren, { tone, icon, badge, children })
|
|
33
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MenuItemChildren, { tone, leftSlot: icon, badge, children })
|
|
34
34
|
}
|
|
35
35
|
);
|
|
36
36
|
};
|
|
@@ -4,7 +4,6 @@ const assert = require("assert");
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const lib_components_Box_Box_cjs = require("../Box/Box.cjs");
|
|
6
6
|
const lib_components_Text_Text_cjs = require("../Text/Text.cjs");
|
|
7
|
-
const lib_css_typography_css_cjs = require("../../css/typography.css.cjs");
|
|
8
7
|
const lib_components_private_normalizeKey_cjs = require("../private/normalizeKey.cjs");
|
|
9
8
|
const lib_components_MenuRenderer_MenuRendererItemContext_cjs = require("../MenuRenderer/MenuRendererItemContext.cjs");
|
|
10
9
|
const lib_components_MenuRenderer_MenuRenderer_actions_cjs = require("../MenuRenderer/MenuRenderer.actions.cjs");
|
|
@@ -16,6 +15,7 @@ const lib_components_MenuRenderer_MenuRendererContext_cjs = require("../MenuRend
|
|
|
16
15
|
const lib_components_BraidProvider_BraidThemeContext_cjs = require("../BraidProvider/BraidThemeContext.cjs");
|
|
17
16
|
const lib_components_private_iconSlotSpace_cjs = require("../private/iconSlotSpace.cjs");
|
|
18
17
|
const lib_components_private_badgeSlotSpace_cjs = require("../private/badgeSlotSpace.cjs");
|
|
18
|
+
const lib_components_private_touchable_virtualTouchable_css_cjs = require("../private/touchable/virtualTouchable.css.cjs");
|
|
19
19
|
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
20
20
|
const assert__default = /* @__PURE__ */ _interopDefaultCompat(assert);
|
|
21
21
|
const {
|
|
@@ -28,7 +28,6 @@ const {
|
|
|
28
28
|
MENU_ITEM_CLICK,
|
|
29
29
|
MENU_ITEM_HOVER
|
|
30
30
|
} = lib_components_MenuRenderer_MenuRenderer_actions_cjs.actionTypes;
|
|
31
|
-
const menuItemChildrenSize = "standard";
|
|
32
31
|
function useMenuItem({
|
|
33
32
|
displayName = "MenuItem",
|
|
34
33
|
formElement = false,
|
|
@@ -38,14 +37,16 @@ function useMenuItem({
|
|
|
38
37
|
id,
|
|
39
38
|
...restProps
|
|
40
39
|
}) {
|
|
40
|
+
const menuRendererContext = React.useContext(lib_components_MenuRenderer_MenuRendererContext_cjs.MenuRendererContext);
|
|
41
41
|
const menuRendererItemContext = React.useContext(lib_components_MenuRenderer_MenuRendererItemContext_cjs.MenuRendererItemContext);
|
|
42
42
|
assert__default.default(
|
|
43
|
-
menuRendererItemContext !== null,
|
|
43
|
+
menuRendererContext !== null && menuRendererItemContext !== null,
|
|
44
44
|
`${displayName} must be rendered as an immediate child of a menu. See the documentation for correct usage: https://seek-oss.github.io/braid-design-system/components/MenuItem`
|
|
45
45
|
);
|
|
46
46
|
if (menuRendererItemContext === null) {
|
|
47
47
|
throw new Error(`${displayName} element rendered outside menu context`);
|
|
48
48
|
}
|
|
49
|
+
const { size } = menuRendererContext;
|
|
49
50
|
const { isHighlighted, index, dispatch, focusTrigger } = menuRendererItemContext;
|
|
50
51
|
const menuItemRef = React.useRef(null);
|
|
51
52
|
React.useEffect(() => {
|
|
@@ -107,11 +108,14 @@ function useMenuItem({
|
|
|
107
108
|
background: isHighlighted ? hoverBackground : void 0,
|
|
108
109
|
className: [
|
|
109
110
|
lib_components_MenuItem_useMenuItem_css_cjs.menuItem,
|
|
110
|
-
|
|
111
|
+
size === "small" ? lib_components_private_touchable_virtualTouchable_css_cjs.virtualTouchable : void 0,
|
|
111
112
|
lib_css_atoms_atoms_cjs.atoms({
|
|
112
|
-
display: "
|
|
113
|
+
display: "flex",
|
|
114
|
+
alignItems: "center",
|
|
113
115
|
width: "full",
|
|
114
116
|
paddingX: "small",
|
|
117
|
+
paddingY: size === "standard" ? void 0 : "xsmall",
|
|
118
|
+
height: size === "standard" ? "touchable" : void 0,
|
|
115
119
|
cursor: "pointer",
|
|
116
120
|
textAlign: "left",
|
|
117
121
|
outline: "none"
|
|
@@ -122,16 +126,15 @@ function useMenuItem({
|
|
|
122
126
|
};
|
|
123
127
|
}
|
|
124
128
|
function MenuItemChildren({
|
|
125
|
-
|
|
129
|
+
leftSlot,
|
|
126
130
|
tone,
|
|
127
131
|
children,
|
|
128
132
|
badge,
|
|
129
|
-
|
|
133
|
+
isCheckbox = false
|
|
130
134
|
}) {
|
|
131
135
|
const menuRendererContext = React.useContext(lib_components_MenuRenderer_MenuRendererContext_cjs.MenuRendererContext);
|
|
132
|
-
const
|
|
133
|
-
const iconSpace = legacy ? "small" : lib_components_private_iconSlotSpace_cjs.iconSlotSpace;
|
|
134
|
-
const badgeSpace = legacy ? "small" : lib_components_private_badgeSlotSpace_cjs.badgeSlotSpace;
|
|
136
|
+
const badgeSpace = lib_components_BraidProvider_BraidThemeContext_cjs.useBraidTheme().legacy ? "small" : lib_components_private_badgeSlotSpace_cjs.badgeSlotSpace;
|
|
137
|
+
const iconSpace = lib_components_BraidProvider_BraidThemeContext_cjs.useBraidTheme().legacy ? "small" : lib_components_private_iconSlotSpace_cjs.iconSlotSpace;
|
|
135
138
|
assert__default.default(
|
|
136
139
|
menuRendererContext !== null,
|
|
137
140
|
`MenuItem must be rendered as an immediate child of a menu. See the documentation for correct usage: https://seek-oss.github.io/braid-design-system/components/MenuItem`
|
|
@@ -141,53 +144,47 @@ function MenuItemChildren({
|
|
|
141
144
|
!badge || badge.type.__isBadge__,
|
|
142
145
|
`MenuItem badge prop can only be an instance of Badge. e.g. <MenuItem badge={<Badge>New</Badge>}>`
|
|
143
146
|
);
|
|
144
|
-
|
|
145
|
-
if (!formElement) {
|
|
146
|
-
if (icon) {
|
|
147
|
-
leftSlot = /* @__PURE__ */ jsxRuntime.jsx(
|
|
148
|
-
lib_components_Text_Text_cjs.Text,
|
|
149
|
-
{
|
|
150
|
-
size: menuItemChildrenSize,
|
|
151
|
-
baseline: false,
|
|
152
|
-
tone: tone === "critical" ? tone : void 0,
|
|
153
|
-
children: icon
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
} else if (menuRendererContext.reserveIconSpace) {
|
|
157
|
-
leftSlot = /* @__PURE__ */ jsxRuntime.jsx(lib_components_Box_Box_cjs.Box, { component: "span", display: "block", className: lib_hooks_useIcon_index_cjs.iconSize() });
|
|
158
|
-
}
|
|
159
|
-
}
|
|
147
|
+
const { size, reserveIconSpace } = menuRendererContext;
|
|
160
148
|
return /* @__PURE__ */ jsxRuntime.jsxs(lib_components_Box_Box_cjs.Box, { component: "span", display: "flex", alignItems: "center", minWidth: 0, children: [
|
|
161
|
-
leftSlot ? /* @__PURE__ */ jsxRuntime.
|
|
149
|
+
leftSlot || reserveIconSpace ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
162
150
|
lib_components_Box_Box_cjs.Box,
|
|
163
151
|
{
|
|
164
152
|
component: "span",
|
|
153
|
+
position: "relative",
|
|
154
|
+
display: "flex",
|
|
155
|
+
alignItems: "center",
|
|
165
156
|
paddingRight: iconSpace,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
159
|
+
lib_components_Box_Box_cjs.Box,
|
|
160
|
+
{
|
|
161
|
+
component: "span",
|
|
162
|
+
display: "block",
|
|
163
|
+
className: [lib_hooks_useIcon_index_cjs.iconSize({ size }), lib_components_MenuItem_useMenuItem_css_cjs.menuItemLeftSlot],
|
|
164
|
+
children: " "
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
leftSlot ? /* @__PURE__ */ jsxRuntime.jsx(lib_components_Box_Box_cjs.Box, { component: "span", position: "absolute", children: isCheckbox ? leftSlot : /* @__PURE__ */ jsxRuntime.jsx(
|
|
168
|
+
lib_components_Text_Text_cjs.Text,
|
|
169
|
+
{
|
|
170
|
+
size,
|
|
171
|
+
tone: tone && tone === "critical" ? tone : void 0,
|
|
172
|
+
children: leftSlot
|
|
173
|
+
}
|
|
174
|
+
) }) : null
|
|
175
|
+
]
|
|
169
176
|
}
|
|
170
177
|
) : null,
|
|
171
178
|
/* @__PURE__ */ jsxRuntime.jsx(lib_components_Box_Box_cjs.Box, { component: "span", minWidth: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
172
179
|
lib_components_Text_Text_cjs.Text,
|
|
173
180
|
{
|
|
174
|
-
size
|
|
175
|
-
baseline: false,
|
|
181
|
+
size,
|
|
176
182
|
tone: tone === "critical" ? tone : void 0,
|
|
177
183
|
maxLines: 1,
|
|
178
184
|
children
|
|
179
185
|
}
|
|
180
186
|
) }),
|
|
181
|
-
badge ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
182
|
-
lib_components_Box_Box_cjs.Box,
|
|
183
|
-
{
|
|
184
|
-
component: "span",
|
|
185
|
-
paddingLeft: badgeSpace,
|
|
186
|
-
flexShrink: 0,
|
|
187
|
-
minWidth: 0,
|
|
188
|
-
children: badge
|
|
189
|
-
}
|
|
190
|
-
) : null
|
|
187
|
+
badge ? /* @__PURE__ */ jsxRuntime.jsx(lib_components_Box_Box_cjs.Box, { component: "span", paddingLeft: badgeSpace, children: /* @__PURE__ */ jsxRuntime.jsx(lib_components_Text_Text_cjs.Text, { size, children: badge }) }) : null
|
|
191
188
|
] });
|
|
192
189
|
}
|
|
193
190
|
exports.useMenuItem = useMenuItem;
|
|
@@ -9,5 +9,10 @@ const menuItem = css.style({
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}, "menuItem");
|
|
12
|
+
const menuItemLeftSlot = css.style({
|
|
13
|
+
height: "0px"
|
|
14
|
+
// Prevents the slot from affecting the height of the MenuItem
|
|
15
|
+
}, "menuItemLeftSlot");
|
|
12
16
|
fileScope.endFileScope();
|
|
13
17
|
exports.menuItem = menuItem;
|
|
18
|
+
exports.menuItemLeftSlot = menuItemLeftSlot;
|
|
@@ -8,7 +8,12 @@ const menuItem = style({
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}, "menuItem");
|
|
11
|
+
const menuItemLeftSlot = style({
|
|
12
|
+
height: "0px"
|
|
13
|
+
// Prevents the slot from affecting the height of the MenuItem
|
|
14
|
+
}, "menuItemLeftSlot");
|
|
11
15
|
endFileScope();
|
|
12
16
|
export {
|
|
13
|
-
menuItem
|
|
17
|
+
menuItem,
|
|
18
|
+
menuItemLeftSlot
|
|
14
19
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import assert from "assert";
|
|
3
3
|
import { useContext, useRef, useEffect } from "react";
|
|
4
4
|
import { Box } from "../Box/Box.mjs";
|
|
5
5
|
import { Text } from "../Text/Text.mjs";
|
|
6
|
-
import { touchableText } from "../../css/typography.css.mjs";
|
|
7
6
|
import { normalizeKey } from "../private/normalizeKey.mjs";
|
|
8
7
|
import { MenuRendererItemContext } from "../MenuRenderer/MenuRendererItemContext.mjs";
|
|
9
8
|
import { actionTypes } from "../MenuRenderer/MenuRenderer.actions.mjs";
|
|
10
9
|
import { buildDataAttributes } from "../private/buildDataAttributes.mjs";
|
|
11
10
|
import { atoms } from "../../css/atoms/atoms.mjs";
|
|
12
11
|
import { iconSize } from "../../hooks/useIcon/index.mjs";
|
|
13
|
-
import { menuItem } from "./useMenuItem.css.mjs";
|
|
12
|
+
import { menuItem, menuItemLeftSlot } from "./useMenuItem.css.mjs";
|
|
14
13
|
import { MenuRendererContext } from "../MenuRenderer/MenuRendererContext.mjs";
|
|
15
14
|
import { useBraidTheme } from "../BraidProvider/BraidThemeContext.mjs";
|
|
16
15
|
import { iconSlotSpace } from "../private/iconSlotSpace.mjs";
|
|
17
16
|
import { badgeSlotSpace } from "../private/badgeSlotSpace.mjs";
|
|
17
|
+
import { virtualTouchable } from "../private/touchable/virtualTouchable.css.mjs";
|
|
18
18
|
const {
|
|
19
19
|
MENU_ITEM_UP,
|
|
20
20
|
MENU_ITEM_DOWN,
|
|
@@ -25,7 +25,6 @@ const {
|
|
|
25
25
|
MENU_ITEM_CLICK,
|
|
26
26
|
MENU_ITEM_HOVER
|
|
27
27
|
} = actionTypes;
|
|
28
|
-
const menuItemChildrenSize = "standard";
|
|
29
28
|
function useMenuItem({
|
|
30
29
|
displayName = "MenuItem",
|
|
31
30
|
formElement = false,
|
|
@@ -35,14 +34,16 @@ function useMenuItem({
|
|
|
35
34
|
id,
|
|
36
35
|
...restProps
|
|
37
36
|
}) {
|
|
37
|
+
const menuRendererContext = useContext(MenuRendererContext);
|
|
38
38
|
const menuRendererItemContext = useContext(MenuRendererItemContext);
|
|
39
39
|
assert(
|
|
40
|
-
menuRendererItemContext !== null,
|
|
40
|
+
menuRendererContext !== null && menuRendererItemContext !== null,
|
|
41
41
|
`${displayName} must be rendered as an immediate child of a menu. See the documentation for correct usage: https://seek-oss.github.io/braid-design-system/components/MenuItem`
|
|
42
42
|
);
|
|
43
43
|
if (menuRendererItemContext === null) {
|
|
44
44
|
throw new Error(`${displayName} element rendered outside menu context`);
|
|
45
45
|
}
|
|
46
|
+
const { size } = menuRendererContext;
|
|
46
47
|
const { isHighlighted, index, dispatch, focusTrigger } = menuRendererItemContext;
|
|
47
48
|
const menuItemRef = useRef(null);
|
|
48
49
|
useEffect(() => {
|
|
@@ -104,11 +105,14 @@ function useMenuItem({
|
|
|
104
105
|
background: isHighlighted ? hoverBackground : void 0,
|
|
105
106
|
className: [
|
|
106
107
|
menuItem,
|
|
107
|
-
|
|
108
|
+
size === "small" ? virtualTouchable : void 0,
|
|
108
109
|
atoms({
|
|
109
|
-
display: "
|
|
110
|
+
display: "flex",
|
|
111
|
+
alignItems: "center",
|
|
110
112
|
width: "full",
|
|
111
113
|
paddingX: "small",
|
|
114
|
+
paddingY: size === "standard" ? void 0 : "xsmall",
|
|
115
|
+
height: size === "standard" ? "touchable" : void 0,
|
|
112
116
|
cursor: "pointer",
|
|
113
117
|
textAlign: "left",
|
|
114
118
|
outline: "none"
|
|
@@ -119,16 +123,15 @@ function useMenuItem({
|
|
|
119
123
|
};
|
|
120
124
|
}
|
|
121
125
|
function MenuItemChildren({
|
|
122
|
-
|
|
126
|
+
leftSlot,
|
|
123
127
|
tone,
|
|
124
128
|
children,
|
|
125
129
|
badge,
|
|
126
|
-
|
|
130
|
+
isCheckbox = false
|
|
127
131
|
}) {
|
|
128
132
|
const menuRendererContext = useContext(MenuRendererContext);
|
|
129
|
-
const
|
|
130
|
-
const iconSpace = legacy ? "small" : iconSlotSpace;
|
|
131
|
-
const badgeSpace = legacy ? "small" : badgeSlotSpace;
|
|
133
|
+
const badgeSpace = useBraidTheme().legacy ? "small" : badgeSlotSpace;
|
|
134
|
+
const iconSpace = useBraidTheme().legacy ? "small" : iconSlotSpace;
|
|
132
135
|
assert(
|
|
133
136
|
menuRendererContext !== null,
|
|
134
137
|
`MenuItem must be rendered as an immediate child of a menu. See the documentation for correct usage: https://seek-oss.github.io/braid-design-system/components/MenuItem`
|
|
@@ -138,53 +141,47 @@ function MenuItemChildren({
|
|
|
138
141
|
!badge || badge.type.__isBadge__,
|
|
139
142
|
`MenuItem badge prop can only be an instance of Badge. e.g. <MenuItem badge={<Badge>New</Badge>}>`
|
|
140
143
|
);
|
|
141
|
-
|
|
142
|
-
if (!formElement) {
|
|
143
|
-
if (icon) {
|
|
144
|
-
leftSlot = /* @__PURE__ */ jsx(
|
|
145
|
-
Text,
|
|
146
|
-
{
|
|
147
|
-
size: menuItemChildrenSize,
|
|
148
|
-
baseline: false,
|
|
149
|
-
tone: tone === "critical" ? tone : void 0,
|
|
150
|
-
children: icon
|
|
151
|
-
}
|
|
152
|
-
);
|
|
153
|
-
} else if (menuRendererContext.reserveIconSpace) {
|
|
154
|
-
leftSlot = /* @__PURE__ */ jsx(Box, { component: "span", display: "block", className: iconSize() });
|
|
155
|
-
}
|
|
156
|
-
}
|
|
144
|
+
const { size, reserveIconSpace } = menuRendererContext;
|
|
157
145
|
return /* @__PURE__ */ jsxs(Box, { component: "span", display: "flex", alignItems: "center", minWidth: 0, children: [
|
|
158
|
-
leftSlot ? /* @__PURE__ */
|
|
146
|
+
leftSlot || reserveIconSpace ? /* @__PURE__ */ jsxs(
|
|
159
147
|
Box,
|
|
160
148
|
{
|
|
161
149
|
component: "span",
|
|
150
|
+
position: "relative",
|
|
151
|
+
display: "flex",
|
|
152
|
+
alignItems: "center",
|
|
162
153
|
paddingRight: iconSpace,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ jsx(
|
|
156
|
+
Box,
|
|
157
|
+
{
|
|
158
|
+
component: "span",
|
|
159
|
+
display: "block",
|
|
160
|
+
className: [iconSize({ size }), menuItemLeftSlot],
|
|
161
|
+
children: " "
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
leftSlot ? /* @__PURE__ */ jsx(Box, { component: "span", position: "absolute", children: isCheckbox ? leftSlot : /* @__PURE__ */ jsx(
|
|
165
|
+
Text,
|
|
166
|
+
{
|
|
167
|
+
size,
|
|
168
|
+
tone: tone && tone === "critical" ? tone : void 0,
|
|
169
|
+
children: leftSlot
|
|
170
|
+
}
|
|
171
|
+
) }) : null
|
|
172
|
+
]
|
|
166
173
|
}
|
|
167
174
|
) : null,
|
|
168
175
|
/* @__PURE__ */ jsx(Box, { component: "span", minWidth: 0, children: /* @__PURE__ */ jsx(
|
|
169
176
|
Text,
|
|
170
177
|
{
|
|
171
|
-
size
|
|
172
|
-
baseline: false,
|
|
178
|
+
size,
|
|
173
179
|
tone: tone === "critical" ? tone : void 0,
|
|
174
180
|
maxLines: 1,
|
|
175
181
|
children
|
|
176
182
|
}
|
|
177
183
|
) }),
|
|
178
|
-
badge ? /* @__PURE__ */ jsx(
|
|
179
|
-
Box,
|
|
180
|
-
{
|
|
181
|
-
component: "span",
|
|
182
|
-
paddingLeft: badgeSpace,
|
|
183
|
-
flexShrink: 0,
|
|
184
|
-
minWidth: 0,
|
|
185
|
-
children: badge
|
|
186
|
-
}
|
|
187
|
-
) : null
|
|
184
|
+
badge ? /* @__PURE__ */ jsx(Box, { component: "span", paddingLeft: badgeSpace, children: /* @__PURE__ */ jsx(Text, { size, children: badge }) }) : null
|
|
188
185
|
] });
|
|
189
186
|
}
|
|
190
187
|
export {
|
|
@@ -3,8 +3,6 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
3
3
|
const lib_components_Box_Box_cjs = require("../Box/Box.cjs");
|
|
4
4
|
const lib_components_icons_IconTick_IconTick_cjs = require("../icons/IconTick/IconTick.cjs");
|
|
5
5
|
const lib_components_MenuItem_useMenuItem_cjs = require("../MenuItem/useMenuItem.cjs");
|
|
6
|
-
const lib_components_private_iconSlotSpace_cjs = require("../private/iconSlotSpace.cjs");
|
|
7
|
-
const lib_components_BraidProvider_BraidThemeContext_cjs = require("../BraidProvider/BraidThemeContext.cjs");
|
|
8
6
|
const lib_components_MenuItemCheckbox_MenuItemCheckbox_css_cjs = require("./MenuItemCheckbox.css.cjs");
|
|
9
7
|
const MenuItemCheckbox = ({
|
|
10
8
|
children,
|
|
@@ -20,9 +18,7 @@ const MenuItemCheckbox = ({
|
|
|
20
18
|
data,
|
|
21
19
|
id
|
|
22
20
|
});
|
|
23
|
-
|
|
24
|
-
const iconSpace = legacy ? "xsmall" : lib_components_private_iconSlotSpace_cjs.iconSlotSpace;
|
|
25
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
26
22
|
lib_components_Box_Box_cjs.Box,
|
|
27
23
|
{
|
|
28
24
|
...menuItemProps,
|
|
@@ -32,44 +28,41 @@ const MenuItemCheckbox = ({
|
|
|
32
28
|
type: "button",
|
|
33
29
|
display: "flex",
|
|
34
30
|
alignItems: "center",
|
|
35
|
-
children:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
)
|
|
72
|
-
]
|
|
31
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
+
MenuItemChildren,
|
|
33
|
+
{
|
|
34
|
+
tone: void 0,
|
|
35
|
+
leftSlot: /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
|
+
lib_components_Box_Box_cjs.Box,
|
|
37
|
+
{
|
|
38
|
+
component: "span",
|
|
39
|
+
display: "block",
|
|
40
|
+
borderRadius: "standard",
|
|
41
|
+
boxShadow: "borderField",
|
|
42
|
+
position: "relative",
|
|
43
|
+
background: { lightMode: "surface" },
|
|
44
|
+
flexShrink: 0,
|
|
45
|
+
className: lib_components_MenuItemCheckbox_MenuItemCheckbox_css_cjs.checkboxSize,
|
|
46
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
|
+
lib_components_Box_Box_cjs.Box,
|
|
48
|
+
{
|
|
49
|
+
component: "span",
|
|
50
|
+
position: "absolute",
|
|
51
|
+
inset: 0,
|
|
52
|
+
background: "formAccent",
|
|
53
|
+
borderRadius: "standard",
|
|
54
|
+
transition: "fast",
|
|
55
|
+
opacity: checked ? void 0 : 0,
|
|
56
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lib_components_icons_IconTick_IconTick_cjs.IconTick, { size: "fill" })
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
badge,
|
|
62
|
+
isCheckbox: true,
|
|
63
|
+
children
|
|
64
|
+
}
|
|
65
|
+
)
|
|
73
66
|
}
|
|
74
67
|
);
|
|
75
68
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from "../Box/Box.mjs";
|
|
3
3
|
import { IconTick } from "../icons/IconTick/IconTick.mjs";
|
|
4
4
|
import { useMenuItem } from "../MenuItem/useMenuItem.mjs";
|
|
5
|
-
import { iconSlotSpace } from "../private/iconSlotSpace.mjs";
|
|
6
|
-
import { useBraidTheme } from "../BraidProvider/BraidThemeContext.mjs";
|
|
7
5
|
import { checkboxSize } from "./MenuItemCheckbox.css.mjs";
|
|
8
6
|
const MenuItemCheckbox = ({
|
|
9
7
|
children,
|
|
@@ -19,9 +17,7 @@ const MenuItemCheckbox = ({
|
|
|
19
17
|
data,
|
|
20
18
|
id
|
|
21
19
|
});
|
|
22
|
-
|
|
23
|
-
const iconSpace = legacy ? "xsmall" : iconSlotSpace;
|
|
24
|
-
return /* @__PURE__ */ jsxs(
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
25
21
|
Box,
|
|
26
22
|
{
|
|
27
23
|
...menuItemProps,
|
|
@@ -31,44 +27,41 @@ const MenuItemCheckbox = ({
|
|
|
31
27
|
type: "button",
|
|
32
28
|
display: "flex",
|
|
33
29
|
alignItems: "center",
|
|
34
|
-
children:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
]
|
|
30
|
+
children: /* @__PURE__ */ jsx(
|
|
31
|
+
MenuItemChildren,
|
|
32
|
+
{
|
|
33
|
+
tone: void 0,
|
|
34
|
+
leftSlot: /* @__PURE__ */ jsx(
|
|
35
|
+
Box,
|
|
36
|
+
{
|
|
37
|
+
component: "span",
|
|
38
|
+
display: "block",
|
|
39
|
+
borderRadius: "standard",
|
|
40
|
+
boxShadow: "borderField",
|
|
41
|
+
position: "relative",
|
|
42
|
+
background: { lightMode: "surface" },
|
|
43
|
+
flexShrink: 0,
|
|
44
|
+
className: checkboxSize,
|
|
45
|
+
children: /* @__PURE__ */ jsx(
|
|
46
|
+
Box,
|
|
47
|
+
{
|
|
48
|
+
component: "span",
|
|
49
|
+
position: "absolute",
|
|
50
|
+
inset: 0,
|
|
51
|
+
background: "formAccent",
|
|
52
|
+
borderRadius: "standard",
|
|
53
|
+
transition: "fast",
|
|
54
|
+
opacity: checked ? void 0 : 0,
|
|
55
|
+
children: /* @__PURE__ */ jsx(IconTick, { size: "fill" })
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
badge,
|
|
61
|
+
isCheckbox: true,
|
|
62
|
+
children
|
|
63
|
+
}
|
|
64
|
+
)
|
|
72
65
|
}
|
|
73
66
|
);
|
|
74
67
|
};
|