react-better-html 1.1.279 → 1.1.281

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 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 ChipProps<Value = unknown> = {
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
 
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 ChipProps<Value = unknown> = {
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
 
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
- text,
3676
- beforeText,
3677
- afterText,
3678
- color,
3679
- backgroundColor,
3680
- borderRadius,
3681
- isCircle,
3682
- value,
3683
- onClick,
3684
- onClickWithValue,
3685
- ...props
3686
- }, ref) {
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, ...props }, ref) {
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;
@@ -4241,7 +4264,7 @@ DropdownComponent.countries = (0, import_react19.forwardRef)(function Countries(
4241
4264
  }
4242
4265
  );
4243
4266
  });
4244
- DropdownComponent.language = (0, import_react19.forwardRef)(function Countries2({ isSmall, ...dropdownProps }, ref) {
4267
+ DropdownComponent.language = (0, import_react19.forwardRef)(function Language2({ isSmall, ...dropdownProps }, ref) {
4245
4268
  const betterHtmlContextInternal = useBetterHtmlContextInternal();
4246
4269
  const { inputFieldClassName, ...props } = useComponentsPropsMerger(
4247
4270
  betterHtmlContextInternal.components.dropdown?.style?.language,
@@ -4268,7 +4291,7 @@ DropdownComponent.language = (0, import_react19.forwardRef)(function Countries2(
4268
4291
  searchValues: [data.code]
4269
4292
  })
4270
4293
  ),
4271
- []
4294
+ [betterHtmlContextInternal.languages, isSmall]
4272
4295
  );
4273
4296
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
4274
4297
  DropdownComponent,