@aurora-ds/components 0.4.0 → 0.5.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/dist/cjs/components/layout/text/Text.d.ts +1 -0
- package/dist/cjs/components/layout/text/Text.props.d.ts +3 -0
- package/dist/cjs/components/navigation/drawer-item/DrawerItem.props.d.ts +2 -13
- package/dist/cjs/index.js +36 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/ui/components/text/parseTextWithBold.utils.d.ts +7 -0
- package/dist/esm/components/layout/text/Text.d.ts +1 -0
- package/dist/esm/components/layout/text/Text.props.d.ts +3 -0
- package/dist/esm/components/navigation/drawer-item/DrawerItem.props.d.ts +2 -13
- package/dist/esm/index.js +37 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/ui/components/text/parseTextWithBold.utils.d.ts +7 -0
- package/dist/index.d.ts +4 -11
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Parses text content and converts **bold** syntax to <strong> elements
|
|
4
|
+
* @param children - The content to parse (string or ReactNode)
|
|
5
|
+
* @returns Parsed content with bold text wrapped in <strong> elements
|
|
6
|
+
*/
|
|
7
|
+
export declare const parseTextWithBold: (children: ReactNode) => ReactNode;
|
|
@@ -14,6 +14,7 @@ import { TextProps } from '@components/layout/text/Text.props.ts';
|
|
|
14
14
|
* - Theme-aware colors
|
|
15
15
|
* - Text truncation with `maxLines`
|
|
16
16
|
* - Underline support
|
|
17
|
+
* - Bold text with **double asterisks** syntax
|
|
17
18
|
*/
|
|
18
19
|
declare const Text: FC<TextProps>;
|
|
19
20
|
export default Text;
|
|
@@ -8,6 +8,8 @@ export type TextProps = PropsWithChildren<{
|
|
|
8
8
|
color?: keyof Theme['colors'];
|
|
9
9
|
/** Font size from theme (overrides variant fontSize if provided) */
|
|
10
10
|
fontSize?: keyof Theme['fontSize'];
|
|
11
|
+
/** Font family override (CSS value) */
|
|
12
|
+
fontFamily?: string;
|
|
11
13
|
/** Maximum number of lines before truncation with ellipsis */
|
|
12
14
|
maxLines?: number;
|
|
13
15
|
/** Add underline text decoration */
|
|
@@ -17,6 +19,7 @@ export type TextStyleParams = {
|
|
|
17
19
|
variant?: TextVariants;
|
|
18
20
|
color?: keyof Theme['colors'];
|
|
19
21
|
fontSize?: keyof Theme['fontSize'];
|
|
22
|
+
fontFamily?: string;
|
|
20
23
|
maxLines?: number;
|
|
21
24
|
underline?: boolean;
|
|
22
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ChipProps } from '@/components';
|
|
3
3
|
export type DrawerItemProps = {
|
|
4
4
|
/** DrawerItem text label */
|
|
5
5
|
label: string;
|
|
@@ -14,19 +14,8 @@ export type DrawerItemProps = {
|
|
|
14
14
|
/** Disabled state */
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
/** Optional chip to display */
|
|
17
|
-
chip?:
|
|
18
|
-
};
|
|
19
|
-
type DrawerItemChip = {
|
|
20
|
-
/** Chip text label */
|
|
21
|
-
label?: string;
|
|
22
|
-
/** Chip icon */
|
|
23
|
-
icon?: ReactNode;
|
|
24
|
-
/** Chip color */
|
|
25
|
-
color?: ChipColor;
|
|
26
|
-
/** Chip variant */
|
|
27
|
-
variant?: ChipVariant;
|
|
17
|
+
chip?: Omit<ChipProps, 'size' | 'disabled'>;
|
|
28
18
|
};
|
|
29
19
|
export type DrawerItemStyleParams = {
|
|
30
20
|
selected?: boolean;
|
|
31
21
|
};
|
|
32
|
-
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import require$$0, { useContext, createContext,
|
|
1
|
+
import require$$0, { useContext, createContext, createElement, Fragment, useMemo, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = {exports: {}};
|
|
4
4
|
|
|
@@ -1641,13 +1641,14 @@ const getTruncateTextStyles = (maxLines) => (maxLines === 1
|
|
|
1641
1641
|
const TEXT_STYLES = pr((theme) => {
|
|
1642
1642
|
const variantStyles = getTextVariantStyles(theme);
|
|
1643
1643
|
return {
|
|
1644
|
-
root: ({ variant = 'span', color, fontSize, maxLines, underline }) => ({
|
|
1644
|
+
root: ({ variant = 'span', color, fontSize, fontFamily, maxLines, underline }) => ({
|
|
1645
1645
|
margin: 0,
|
|
1646
1646
|
fontSize: fontSize ? theme.fontSize[fontSize] : variantStyles[variant].fontSize,
|
|
1647
1647
|
fontWeight: variantStyles[variant].fontWeight,
|
|
1648
1648
|
lineHeight: variantStyles[variant].lineHeight,
|
|
1649
1649
|
color: color ? theme.colors[color] : 'inherit',
|
|
1650
1650
|
cursor: 'inherit',
|
|
1651
|
+
...(fontFamily && { fontFamily }),
|
|
1651
1652
|
...(underline && {
|
|
1652
1653
|
textDecoration: 'underline',
|
|
1653
1654
|
textUnderlineOffset: '3px',
|
|
@@ -1657,6 +1658,35 @@ const TEXT_STYLES = pr((theme) => {
|
|
|
1657
1658
|
};
|
|
1658
1659
|
});
|
|
1659
1660
|
|
|
1661
|
+
/**
|
|
1662
|
+
* Parses text content and converts **bold** syntax to <strong> elements
|
|
1663
|
+
* @param children - The content to parse (string or ReactNode)
|
|
1664
|
+
* @returns Parsed content with bold text wrapped in <strong> elements
|
|
1665
|
+
*/
|
|
1666
|
+
const parseTextWithBold = (children) => {
|
|
1667
|
+
if (typeof children !== 'string' || !children.includes('**')) {
|
|
1668
|
+
return children;
|
|
1669
|
+
}
|
|
1670
|
+
const boldPattern = /\*\*(.+?)\*\*/g;
|
|
1671
|
+
const parts = [];
|
|
1672
|
+
let lastIndex = 0;
|
|
1673
|
+
let match;
|
|
1674
|
+
while ((match = boldPattern.exec(children)) !== null) {
|
|
1675
|
+
if (match.index > lastIndex) {
|
|
1676
|
+
parts.push(children.slice(lastIndex, match.index));
|
|
1677
|
+
}
|
|
1678
|
+
parts.push(createElement('strong', { key: match.index }, match[1]));
|
|
1679
|
+
lastIndex = match.index + match[0].length;
|
|
1680
|
+
}
|
|
1681
|
+
if (parts.length === 0) {
|
|
1682
|
+
return children;
|
|
1683
|
+
}
|
|
1684
|
+
if (lastIndex < children.length) {
|
|
1685
|
+
parts.push(children.slice(lastIndex));
|
|
1686
|
+
}
|
|
1687
|
+
return createElement(Fragment, null, ...parts);
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1660
1690
|
/**
|
|
1661
1691
|
* Text component - Renders semantic HTML elements based on variant
|
|
1662
1692
|
*
|
|
@@ -1671,12 +1701,14 @@ const TEXT_STYLES = pr((theme) => {
|
|
|
1671
1701
|
* - Theme-aware colors
|
|
1672
1702
|
* - Text truncation with `maxLines`
|
|
1673
1703
|
* - Underline support
|
|
1704
|
+
* - Bold text with **double asterisks** syntax
|
|
1674
1705
|
*/
|
|
1675
|
-
const Text = ({ children, variant = 'span', color, fontSize, maxLines, underline, }) => {
|
|
1706
|
+
const Text = ({ children, variant = 'span', color, fontSize, fontFamily, maxLines, underline, }) => {
|
|
1676
1707
|
const theme = rr();
|
|
1677
1708
|
const variantStyles = useMemo(() => getTextVariantStyles(theme), [theme]);
|
|
1678
1709
|
const tag = variantStyles[variant].tag;
|
|
1679
|
-
|
|
1710
|
+
const parsedChildren = useMemo(() => parseTextWithBold(children), [children]);
|
|
1711
|
+
return createElement(tag, { className: TEXT_STYLES.root({ variant, color, fontSize, fontFamily, maxLines, underline }) }, parsedChildren);
|
|
1680
1712
|
};
|
|
1681
1713
|
Text.displayName = 'Text';
|
|
1682
1714
|
|
|
@@ -2058,7 +2090,7 @@ const DRAWER_ITEM_STYLES = pr((theme) => ({
|
|
|
2058
2090
|
* Similar to a text button with selected state support.
|
|
2059
2091
|
*/
|
|
2060
2092
|
const DrawerItem = ({ label, startIcon, endIcon, selected = false, onClick, disabled, chip }) => {
|
|
2061
|
-
return (jsxRuntimeExports.jsxs("button", { onClick: onClick, disabled: disabled, type: 'button', className: DRAWER_ITEM_STYLES.root({ selected }), children: [jsxRuntimeExports.jsxs(Stack, { children: [startIcon && (jsxRuntimeExports.jsx(Icon, { children: startIcon })), jsxRuntimeExports.jsx(Text, { variant: 'label', maxLines: 1, children: label }), endIcon && (jsxRuntimeExports.jsx(Icon, { children: endIcon }))] }), chip && !selected && (jsxRuntimeExports.jsx(Chip, {
|
|
2093
|
+
return (jsxRuntimeExports.jsxs("button", { onClick: onClick, disabled: disabled, type: 'button', className: DRAWER_ITEM_STYLES.root({ selected }), children: [jsxRuntimeExports.jsxs(Stack, { children: [startIcon && (jsxRuntimeExports.jsx(Icon, { children: startIcon })), jsxRuntimeExports.jsx(Text, { variant: 'label', maxLines: 1, children: label }), endIcon && (jsxRuntimeExports.jsx(Icon, { children: endIcon }))] }), chip && !selected && (jsxRuntimeExports.jsx(Chip, { ...chip, size: '2xs', color: chip.color ?? 'info', disabled: disabled }))] }));
|
|
2062
2094
|
};
|
|
2063
2095
|
DrawerItem.displayName = 'DrawerItem';
|
|
2064
2096
|
|