react-better-html 1.1.278 → 1.1.280
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/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +38 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +136 -113
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -176,6 +176,8 @@ type TextAs = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "label" |
|
|
|
176
176
|
type TextProps<As extends TextAs = "p"> = {
|
|
177
177
|
/** @default "p" */
|
|
178
178
|
as?: As;
|
|
179
|
+
/** @default false */
|
|
180
|
+
isTabAccessed?: boolean;
|
|
179
181
|
htmlContentTranslate?: React.ComponentProps<"div">["translate"];
|
|
180
182
|
} & OmitProps<React.ComponentProps<As>, "style"> & ComponentStyle & ComponentHoverStyle;
|
|
181
183
|
type TextComponentType = {
|
|
@@ -256,7 +258,7 @@ declare const Div: typeof DivComponent & {
|
|
|
256
258
|
box: typeof DivComponent.box;
|
|
257
259
|
};
|
|
258
260
|
|
|
259
|
-
type
|
|
261
|
+
type InternalChipProps<Value = unknown> = {
|
|
260
262
|
text: string | React.ReactNode;
|
|
261
263
|
beforeText?: React.ReactNode;
|
|
262
264
|
afterText?: React.ReactNode;
|
|
@@ -271,7 +273,9 @@ type ChipProps<Value = unknown> = {
|
|
|
271
273
|
value?: Value;
|
|
272
274
|
onClick?: (event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void;
|
|
273
275
|
onClickWithValue?: (value: Value) => void;
|
|
276
|
+
fromSubcomponent?: boolean;
|
|
274
277
|
} & Pick<DivProps, "border" | "borderColor" | "borderWidth" | "borderStyle" | keyof ComponentPaddingProps | "transition" | "height"> & Pick<TextProps, "fontFamily" | "fontSize" | "fontWeight" | "fontStyle">;
|
|
278
|
+
type ChipProps<Value = unknown> = OmitProps<InternalChipProps<Value>, "fromSubcomponent">;
|
|
275
279
|
type ChipComponentType = {
|
|
276
280
|
<Value>(props: ComponentPropWithRef<HTMLDivElement, ChipProps<Value>>): React.ReactElement;
|
|
277
281
|
colored: <Value>(props: ComponentPropWithRef<HTMLDivElement, OmitProps<ChipProps<Value>, "color" | "backgroundColor"> & {
|
|
@@ -504,6 +508,9 @@ type BetterHtmlConfig = {
|
|
|
504
508
|
/** @default 80 */
|
|
505
509
|
sidebarWidth?: number;
|
|
506
510
|
};
|
|
511
|
+
chip?: {
|
|
512
|
+
style?: ComponentStyleConfig<ChipProps, "default" | "colored">;
|
|
513
|
+
};
|
|
507
514
|
};
|
|
508
515
|
};
|
|
509
516
|
|
|
@@ -811,6 +818,9 @@ type PageHolderComponentType = {
|
|
|
811
818
|
pageBackgroundColor?: React.CSSProperties["backgroundColor"];
|
|
812
819
|
pageBackgroundImage?: React.CSSProperties["backgroundImage"];
|
|
813
820
|
contentMaxWidth?: React.CSSProperties["maxWidth"];
|
|
821
|
+
border?: React.CSSProperties["border"];
|
|
822
|
+
borderRadius?: React.CSSProperties["borderRadius"];
|
|
823
|
+
boxShadow?: React.CSSProperties["boxShadow"];
|
|
814
824
|
/** @default true */
|
|
815
825
|
contentInsideBox?: boolean;
|
|
816
826
|
behindComponent?: React.ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -176,6 +176,8 @@ type TextAs = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "label" |
|
|
|
176
176
|
type TextProps<As extends TextAs = "p"> = {
|
|
177
177
|
/** @default "p" */
|
|
178
178
|
as?: As;
|
|
179
|
+
/** @default false */
|
|
180
|
+
isTabAccessed?: boolean;
|
|
179
181
|
htmlContentTranslate?: React.ComponentProps<"div">["translate"];
|
|
180
182
|
} & OmitProps<React.ComponentProps<As>, "style"> & ComponentStyle & ComponentHoverStyle;
|
|
181
183
|
type TextComponentType = {
|
|
@@ -256,7 +258,7 @@ declare const Div: typeof DivComponent & {
|
|
|
256
258
|
box: typeof DivComponent.box;
|
|
257
259
|
};
|
|
258
260
|
|
|
259
|
-
type
|
|
261
|
+
type InternalChipProps<Value = unknown> = {
|
|
260
262
|
text: string | React.ReactNode;
|
|
261
263
|
beforeText?: React.ReactNode;
|
|
262
264
|
afterText?: React.ReactNode;
|
|
@@ -271,7 +273,9 @@ type ChipProps<Value = unknown> = {
|
|
|
271
273
|
value?: Value;
|
|
272
274
|
onClick?: (event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void;
|
|
273
275
|
onClickWithValue?: (value: Value) => void;
|
|
276
|
+
fromSubcomponent?: boolean;
|
|
274
277
|
} & Pick<DivProps, "border" | "borderColor" | "borderWidth" | "borderStyle" | keyof ComponentPaddingProps | "transition" | "height"> & Pick<TextProps, "fontFamily" | "fontSize" | "fontWeight" | "fontStyle">;
|
|
278
|
+
type ChipProps<Value = unknown> = OmitProps<InternalChipProps<Value>, "fromSubcomponent">;
|
|
275
279
|
type ChipComponentType = {
|
|
276
280
|
<Value>(props: ComponentPropWithRef<HTMLDivElement, ChipProps<Value>>): React.ReactElement;
|
|
277
281
|
colored: <Value>(props: ComponentPropWithRef<HTMLDivElement, OmitProps<ChipProps<Value>, "color" | "backgroundColor"> & {
|
|
@@ -504,6 +508,9 @@ type BetterHtmlConfig = {
|
|
|
504
508
|
/** @default 80 */
|
|
505
509
|
sidebarWidth?: number;
|
|
506
510
|
};
|
|
511
|
+
chip?: {
|
|
512
|
+
style?: ComponentStyleConfig<ChipProps, "default" | "colored">;
|
|
513
|
+
};
|
|
507
514
|
};
|
|
508
515
|
};
|
|
509
516
|
|
|
@@ -811,6 +818,9 @@ type PageHolderComponentType = {
|
|
|
811
818
|
pageBackgroundColor?: React.CSSProperties["backgroundColor"];
|
|
812
819
|
pageBackgroundImage?: React.CSSProperties["backgroundImage"];
|
|
813
820
|
contentMaxWidth?: React.CSSProperties["maxWidth"];
|
|
821
|
+
border?: React.CSSProperties["border"];
|
|
822
|
+
borderRadius?: React.CSSProperties["borderRadius"];
|
|
823
|
+
boxShadow?: React.CSSProperties["boxShadow"];
|
|
814
824
|
/** @default true */
|
|
815
825
|
contentInsideBox?: boolean;
|
|
816
826
|
behindComponent?: React.ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -1392,17 +1392,30 @@ var TextStyledComponent = import_styled_components.default.p.withConfig({
|
|
|
1392
1392
|
${(props) => props.hoverStyle}
|
|
1393
1393
|
}
|
|
1394
1394
|
`;
|
|
1395
|
-
var TextComponent = (0, import_react2.forwardRef)(function Text({ as: asValue, htmlContentTranslate, children, ...props }, ref) {
|
|
1395
|
+
var TextComponent = (0, import_react2.forwardRef)(function Text({ as: asValue, isTabAccessed, htmlContentTranslate, onKeyDown, children, ...props }, ref) {
|
|
1396
1396
|
const theme2 = (0, import_react_better_core2.useTheme)();
|
|
1397
1397
|
const { style, hoverStyle, restProps } = useComponentPropsGrouper(props);
|
|
1398
1398
|
const dataProps = useComponentPropsWithPrefix(restProps, "data");
|
|
1399
1399
|
const ariaProps = useComponentPropsWithPrefix(restProps, "aria");
|
|
1400
|
+
const onKeyDownElement = (0, import_react2.useCallback)(
|
|
1401
|
+
(event) => {
|
|
1402
|
+
onKeyDown?.(event);
|
|
1403
|
+
if (!isTabAccessed) return;
|
|
1404
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1405
|
+
event.preventDefault();
|
|
1406
|
+
event.currentTarget.click();
|
|
1407
|
+
}
|
|
1408
|
+
},
|
|
1409
|
+
[onKeyDown, isTabAccessed]
|
|
1410
|
+
);
|
|
1400
1411
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1401
1412
|
TextStyledComponent,
|
|
1402
1413
|
{
|
|
1403
1414
|
as: asValue,
|
|
1415
|
+
tabIndex: isTabAccessed && !isMobileDevice ? 0 : void 0,
|
|
1404
1416
|
theme: theme2,
|
|
1405
1417
|
translate: htmlContentTranslate,
|
|
1418
|
+
onKeyDown: onKeyDownElement,
|
|
1406
1419
|
style,
|
|
1407
1420
|
hoverStyle,
|
|
1408
1421
|
isP: asValue === "p",
|
|
@@ -3671,19 +3684,24 @@ var import_react17 = require("react");
|
|
|
3671
3684
|
var import_react_better_core15 = require("react-better-core");
|
|
3672
3685
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3673
3686
|
var borderRadiusOffset = 1.3;
|
|
3674
|
-
var ChipComponent = (0, import_react17.forwardRef)(function Chip({
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
+
var ChipComponent = (0, import_react17.forwardRef)(function Chip({ fromSubcomponent, ...chipProps }, ref) {
|
|
3688
|
+
const betterHtmlContextInternal = useBetterHtmlContextInternal();
|
|
3689
|
+
const {
|
|
3690
|
+
text,
|
|
3691
|
+
beforeText,
|
|
3692
|
+
afterText,
|
|
3693
|
+
color,
|
|
3694
|
+
backgroundColor,
|
|
3695
|
+
borderRadius,
|
|
3696
|
+
isCircle,
|
|
3697
|
+
value,
|
|
3698
|
+
onClick,
|
|
3699
|
+
onClickWithValue,
|
|
3700
|
+
...props
|
|
3701
|
+
} = useComponentsPropsMerger(
|
|
3702
|
+
!fromSubcomponent ? betterHtmlContextInternal.components.chip?.style?.default : {},
|
|
3703
|
+
chipProps
|
|
3704
|
+
);
|
|
3687
3705
|
const theme2 = (0, import_react_better_core15.useTheme)();
|
|
3688
3706
|
const onClickElement = (0, import_react17.useCallback)(
|
|
3689
3707
|
(event) => {
|
|
@@ -3713,7 +3731,12 @@ var ChipComponent = (0, import_react17.forwardRef)(function Chip({
|
|
|
3713
3731
|
}
|
|
3714
3732
|
);
|
|
3715
3733
|
});
|
|
3716
|
-
ChipComponent.colored = (0, import_react17.forwardRef)(function Colored({ color, withWhiteBackground, ...
|
|
3734
|
+
ChipComponent.colored = (0, import_react17.forwardRef)(function Colored({ color, withWhiteBackground, ...chipProps }, ref) {
|
|
3735
|
+
const betterHtmlContextInternal = useBetterHtmlContextInternal();
|
|
3736
|
+
const { ...props } = useComponentsPropsMerger(
|
|
3737
|
+
betterHtmlContextInternal.components.chip?.style?.colored,
|
|
3738
|
+
chipProps
|
|
3739
|
+
);
|
|
3717
3740
|
const theme2 = (0, import_react_better_core15.useTheme)();
|
|
3718
3741
|
const { colorTheme } = (0, import_react_better_core15.useBetterCoreContext)();
|
|
3719
3742
|
const readyColor = color ?? theme2.colors.textSecondary;
|