@vertigis/react-ui 15.2.3 → 15.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/Chip/Chip.d.ts +7 -0
- package/Chip/Chip.js +20 -0
- package/Chip/index.d.ts +2 -2
- package/Chip/index.js +2 -2
- package/package.json +1 -1
package/Chip/Chip.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ChipProps as MuiChipProps } from "@mui/material/Chip";
|
|
2
|
+
export * from "@mui/material/Chip";
|
|
3
|
+
export interface ChipProps extends MuiChipProps {
|
|
4
|
+
deleteLabel?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const Chip: import("react").ForwardRefExoticComponent<Omit<ChipProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export default Chip;
|
package/Chip/Chip.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import MuiChip from "@mui/material/Chip";
|
|
3
|
+
import { forwardRef, useEffect, useMemo, useState } from "react";
|
|
4
|
+
import IconButton from "../IconButton/index.js";
|
|
5
|
+
import Typography from "../Typography/index.js";
|
|
6
|
+
import Clear from "../icons/Clear.js";
|
|
7
|
+
export * from "@mui/material/Chip";
|
|
8
|
+
const Chip = forwardRef(({ deleteIcon, label, deleteLabel = "", onClick, onDelete, ...props }, ref) => {
|
|
9
|
+
// Replace the close button as it is not WCAG compliant by default.
|
|
10
|
+
const deleteChipButton = useMemo(() => (_jsx(IconButton, { size: "small", "aria-label": deleteLabel, title: deleteLabel, children: deleteIcon ? deleteIcon : _jsx(Clear, { fontSize: "small" }) })), [deleteLabel, deleteIcon]);
|
|
11
|
+
const [title, setTitle] = useState();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setTitle(typeof label === "string" ? label : undefined);
|
|
14
|
+
}, [label]);
|
|
15
|
+
return (_jsx(MuiChip, { ref: ref, "aria-label": onClick ? title : undefined, deleteIcon: onDelete ? deleteChipButton : undefined, label: _jsx(Typography, { children: label }), title: title, onClick: onClick, onDelete: onDelete,
|
|
16
|
+
// The chip should only have the button role and be focusable if
|
|
17
|
+
// it is clickable.
|
|
18
|
+
role: onClick ? "button" : undefined, tabIndex: onClick ? 0 : -1, ...props }));
|
|
19
|
+
});
|
|
20
|
+
export default Chip;
|
package/Chip/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "
|
|
2
|
-
export * from "
|
|
1
|
+
export { default } from "./Chip.js";
|
|
2
|
+
export * from "./Chip.js";
|
package/Chip/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "
|
|
2
|
-
export * from "
|
|
1
|
+
export { default } from "./Chip.js";
|
|
2
|
+
export * from "./Chip.js";
|