react-better-html 1.1.153 → 1.1.155

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
@@ -44,8 +44,9 @@ type DivProps<Value = unknown> = {
44
44
  as?: WebTarget;
45
45
  /** @default false */
46
46
  isTabAccessed?: boolean;
47
+ htmlContentTranslate?: React.ComponentProps<"div">["translate"];
47
48
  onClickWithValue?: (value: Value) => void;
48
- } & OmitProps<React.ComponentProps<"div">, "style" | "defaultValue"> & ComponentStyle & ComponentHoverStyle;
49
+ } & OmitProps<React.ComponentProps<"div">, "style" | "defaultValue" | "translate"> & ComponentStyle & ComponentHoverStyle;
49
50
  type DivComponentType = {
50
51
  <Value>(props: ComponentPropWithRef<HTMLDivElement, DivProps<Value>>): React.ReactElement;
51
52
  row: <Value>(props: ComponentPropWithRef<HTMLDivElement, OmitProps<DivProps<Value>, "display" | "flexDirection"> & {
@@ -386,6 +387,10 @@ type InputFieldProps = {
386
387
  infoText?: string;
387
388
  leftIcon?: IconName | AnyOtherString;
388
389
  rightIcon?: IconName | AnyOtherString;
390
+ prefix?: React.ReactNode;
391
+ prefixBackgroundColor?: string;
392
+ suffix?: React.ReactNode;
393
+ suffixBackgroundColor?: string;
389
394
  insideInputFieldComponent?: React.ReactNode;
390
395
  /** @default false */
391
396
  withDebounce?: boolean;
@@ -394,7 +399,7 @@ type InputFieldProps = {
394
399
  onChangeValue?: (value: string) => void;
395
400
  onClickRightIcon?: () => void;
396
401
  holderRef?: React.ForwardedRef<HTMLDivElement>;
397
- } & OmitProps<React.ComponentProps<"input">, "style" | "ref"> & ComponentStyle & ComponentHoverStyle;
402
+ } & OmitProps<React.ComponentProps<"input">, "style" | "ref" | "prefix"> & ComponentStyle & ComponentHoverStyle;
398
403
  type TextareaFieldProps = OmitProps<InputFieldProps, "type"> & OmitProps<React.ComponentProps<"textarea">, "style" | "ref">;
399
404
  type InputFieldComponentType = {
400
405
  (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>): React.ReactElement;
@@ -402,7 +407,7 @@ type InputFieldComponentType = {
402
407
  email: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
403
408
  password: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
404
409
  search: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
405
- phoneNumber: (props: ComponentPropWithRef<HTMLInputElement, OmitProps<InputFieldProps, "type">>) => React.ReactElement;
410
+ phoneNumber: (props: ComponentPropWithRef<HTMLInputElement, OmitProps<InputFieldProps, "type" | "prefix">>) => React.ReactElement;
406
411
  date: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps & {
407
412
  minDate?: Date;
408
413
  maxDate?: Date;
package/dist/index.d.ts CHANGED
@@ -44,8 +44,9 @@ type DivProps<Value = unknown> = {
44
44
  as?: WebTarget;
45
45
  /** @default false */
46
46
  isTabAccessed?: boolean;
47
+ htmlContentTranslate?: React.ComponentProps<"div">["translate"];
47
48
  onClickWithValue?: (value: Value) => void;
48
- } & OmitProps<React.ComponentProps<"div">, "style" | "defaultValue"> & ComponentStyle & ComponentHoverStyle;
49
+ } & OmitProps<React.ComponentProps<"div">, "style" | "defaultValue" | "translate"> & ComponentStyle & ComponentHoverStyle;
49
50
  type DivComponentType = {
50
51
  <Value>(props: ComponentPropWithRef<HTMLDivElement, DivProps<Value>>): React.ReactElement;
51
52
  row: <Value>(props: ComponentPropWithRef<HTMLDivElement, OmitProps<DivProps<Value>, "display" | "flexDirection"> & {
@@ -386,6 +387,10 @@ type InputFieldProps = {
386
387
  infoText?: string;
387
388
  leftIcon?: IconName | AnyOtherString;
388
389
  rightIcon?: IconName | AnyOtherString;
390
+ prefix?: React.ReactNode;
391
+ prefixBackgroundColor?: string;
392
+ suffix?: React.ReactNode;
393
+ suffixBackgroundColor?: string;
389
394
  insideInputFieldComponent?: React.ReactNode;
390
395
  /** @default false */
391
396
  withDebounce?: boolean;
@@ -394,7 +399,7 @@ type InputFieldProps = {
394
399
  onChangeValue?: (value: string) => void;
395
400
  onClickRightIcon?: () => void;
396
401
  holderRef?: React.ForwardedRef<HTMLDivElement>;
397
- } & OmitProps<React.ComponentProps<"input">, "style" | "ref"> & ComponentStyle & ComponentHoverStyle;
402
+ } & OmitProps<React.ComponentProps<"input">, "style" | "ref" | "prefix"> & ComponentStyle & ComponentHoverStyle;
398
403
  type TextareaFieldProps = OmitProps<InputFieldProps, "type"> & OmitProps<React.ComponentProps<"textarea">, "style" | "ref">;
399
404
  type InputFieldComponentType = {
400
405
  (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>): React.ReactElement;
@@ -402,7 +407,7 @@ type InputFieldComponentType = {
402
407
  email: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
403
408
  password: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
404
409
  search: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
405
- phoneNumber: (props: ComponentPropWithRef<HTMLInputElement, OmitProps<InputFieldProps, "type">>) => React.ReactElement;
410
+ phoneNumber: (props: ComponentPropWithRef<HTMLInputElement, OmitProps<InputFieldProps, "type" | "prefix">>) => React.ReactElement;
406
411
  date: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps & {
407
412
  minDate?: Date;
408
413
  maxDate?: Date;
package/dist/index.js CHANGED
@@ -3170,6 +3170,7 @@ var DivComponent = (0, import_react11.forwardRef)(function Div({
3170
3170
  as = "div",
3171
3171
  value,
3172
3172
  isTabAccessed,
3173
+ htmlContentTranslate,
3173
3174
  onClickWithValue,
3174
3175
  role,
3175
3176
  onClick,
@@ -3205,6 +3206,7 @@ var DivComponent = (0, import_react11.forwardRef)(function Div({
3205
3206
  {
3206
3207
  as,
3207
3208
  tabIndex: isTabAccessed && !isMobileDevice ? 0 : void 0,
3209
+ translate: htmlContentTranslate,
3208
3210
  role: role ?? (onClick ? "button" : void 0),
3209
3211
  onClick: onClickElement,
3210
3212
  onKeyDown: onKeyDownElement,
@@ -6030,7 +6032,9 @@ var colorPickerSpacing = 4;
6030
6032
  var colorPickerColorWidth = 12 + 27 + colorPickerSpacing;
6031
6033
  var colorPickerValueWidth = 12 + 74 + colorPickerSpacing;
6032
6034
  var InputElement = import_styled_components11.default.input.withConfig({
6033
- shouldForwardProp: (prop) => !["theme", "withLeftIcon", "withRightIcon", "normalStyle", "hoverStyle"].includes(prop)
6035
+ shouldForwardProp: (prop) => !["theme", "withLeftIcon", "withRightIcon", "withPrefix", "withSuffix", "normalStyle", "hoverStyle"].includes(
6036
+ prop
6037
+ )
6034
6038
  })`
6035
6039
  position: relative;
6036
6040
  width: 100%;
@@ -6041,10 +6045,14 @@ var InputElement = import_styled_components11.default.input.withConfig({
6041
6045
  background: ${(props) => props.theme.colors.backgroundContent};
6042
6046
  border: 1px solid ${(props) => props.theme.colors.border};
6043
6047
  border-radius: ${(props) => props.theme.styles.borderRadius}px;
6048
+ border-top-left-radius: ${(props) => props.withPrefix ? 0 : void 0};
6049
+ border-bottom-left-radius: ${(props) => props.withPrefix ? 0 : void 0};
6050
+ border-top-right-radius: ${(props) => props.withSuffix ? 0 : void 0};
6051
+ border-bottom-right-radius: ${(props) => props.withSuffix ? 0 : void 0};
6044
6052
  outline: none;
6045
- padding: ${(props) => `${(props.theme.styles.space + props.theme.styles.gap) / 2}px ${props.theme.styles.space + props.theme.styles.gap}px`};
6046
- padding-left: ${(props) => props.withLeftIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : void 0};
6047
- padding-right: ${(props) => props.withRightIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : void 0};
6053
+ padding: ${(props) => `${(props.theme.styles.space + props.theme.styles.gap) / 2}px ${props.theme.styles.space}px`};
6054
+ padding-left: ${(props) => props.withLeftIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : props.withPrefix ? `${props.theme.styles.space}px` : void 0};
6055
+ padding-right: ${(props) => props.withRightIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : props.withSuffix ? `${props.theme.styles.space}px` : void 0};
6048
6056
  transition: ${(props) => props.theme.styles.transition};
6049
6057
 
6050
6058
  &::placeholder {
@@ -6151,7 +6159,7 @@ var TextareaElement = import_styled_components11.default.textarea.withConfig({
6151
6159
  border: 1px solid ${(props) => props.theme.colors.border};
6152
6160
  border-radius: ${(props) => props.theme.styles.borderRadius}px;
6153
6161
  outline: none;
6154
- padding: ${(props) => `${(props.theme.styles.gap + props.theme.styles.space) / 2}px ${props.theme.styles.space + props.theme.styles.gap}px`};
6162
+ padding: ${(props) => `${(props.theme.styles.gap + props.theme.styles.space) / 2}px ${props.theme.styles.space}px`};
6155
6163
  padding-left: ${(props) => props.withLeftIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : void 0};
6156
6164
  padding-right: ${(props) => props.withRightIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : void 0};
6157
6165
  resize: vertical;
@@ -6180,6 +6188,10 @@ var InputFieldComponent = (0, import_react20.forwardRef)(function InputField({
6180
6188
  infoText,
6181
6189
  leftIcon,
6182
6190
  rightIcon,
6191
+ prefix,
6192
+ prefixBackgroundColor,
6193
+ suffix,
6194
+ suffixBackgroundColor,
6183
6195
  insideInputFieldComponent,
6184
6196
  withDebounce,
6185
6197
  debounceDelay = 0.5,
@@ -6194,6 +6206,7 @@ var InputFieldComponent = (0, import_react20.forwardRef)(function InputField({
6194
6206
  }, ref) {
6195
6207
  const theme2 = useTheme();
6196
6208
  const internalId = (0, import_react20.useId)();
6209
+ const { colorTheme } = useBetterHtmlContextInternal();
6197
6210
  const [_, debouncedValue, setDebouncedValue] = useDebounceState(
6198
6211
  props.value?.toString() ?? "",
6199
6212
  debounceDelay
@@ -6229,58 +6242,90 @@ var InputFieldComponent = (0, import_react20.forwardRef)(function InputField({
6229
6242
  const readyId = id ?? internalId;
6230
6243
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.gap / 2, ...styledComponentStylesWithExcluded, children: [
6231
6244
  label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
6232
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Div_default, { position: "relative", width: "100%", ref: holderRef, children: [
6233
- leftIcon && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6234
- Icon_default,
6235
- {
6236
- name: leftIcon,
6237
- position: "absolute",
6238
- top: (props.type === "date" || props.type === "time" || props.type === "datetime-local" ? 48 : 46) / 2,
6239
- left: theme2.styles.space + 1,
6240
- transform: "translateY(-50%)",
6241
- pointerEvents: "none",
6242
- zIndex: leftIconZIndex
6243
- }
6244
- ),
6245
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6246
- InputElement,
6245
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Div_default.row, { alignItems: "stretch", width: "100%", children: [
6246
+ prefix && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6247
+ Div_default.row,
6247
6248
  {
6248
- theme: theme2,
6249
- withLeftIcon: leftIcon !== void 0,
6250
- withRightIcon: rightIcon !== void 0,
6251
- required,
6252
- placeholder: placeholder ?? label,
6253
- id: readyId,
6254
- onChange: onChangeElement,
6255
- ...styledComponentStylesWithoutExcluded,
6256
- ...dataProps,
6257
- ...ariaProps,
6258
- ...restProps,
6259
- ref
6249
+ alignItems: "center",
6250
+ justifyContent: "center",
6251
+ border: `1px solid ${theme2.colors.border}`,
6252
+ borderRight: "none",
6253
+ backgroundColor: prefixBackgroundColor ?? (colorTheme === "light" ? darkenColor(theme2.colors.backgroundContent, 0.03) : lightenColor(theme2.colors.backgroundContent, 0.1)),
6254
+ borderTopLeftRadius: theme2.styles.borderRadius,
6255
+ borderBottomLeftRadius: theme2.styles.borderRadius,
6256
+ paddingInline: theme2.styles.space,
6257
+ children: prefix
6260
6258
  }
6261
6259
  ),
6262
- rightIcon ? onClickRightIcon ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6263
- Button_default.icon,
6264
- {
6265
- icon: rightIcon,
6266
- position: "absolute",
6267
- top: 46 / 2,
6268
- right: theme2.styles.space + 1 - theme2.styles.space / 2,
6269
- transform: "translateY(-50%)",
6270
- onClick: onClickRightIcon
6271
- }
6272
- ) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6273
- Icon_default,
6260
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Div_default, { position: "relative", width: "100%", height: "fit-content", ref: holderRef, children: [
6261
+ leftIcon && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6262
+ Icon_default,
6263
+ {
6264
+ name: leftIcon,
6265
+ position: "absolute",
6266
+ top: (props.type === "date" || props.type === "time" || props.type === "datetime-local" ? 48 : 46) / 2,
6267
+ left: theme2.styles.space + 1,
6268
+ transform: "translateY(-50%)",
6269
+ pointerEvents: "none",
6270
+ zIndex: leftIconZIndex
6271
+ }
6272
+ ),
6273
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6274
+ InputElement,
6275
+ {
6276
+ theme: theme2,
6277
+ withLeftIcon: leftIcon !== void 0,
6278
+ withRightIcon: rightIcon !== void 0,
6279
+ withPrefix: prefix !== void 0,
6280
+ withSuffix: suffix !== void 0,
6281
+ required,
6282
+ placeholder: placeholder ?? label,
6283
+ id: readyId,
6284
+ onChange: onChangeElement,
6285
+ ...styledComponentStylesWithoutExcluded,
6286
+ ...dataProps,
6287
+ ...ariaProps,
6288
+ ...restProps,
6289
+ ref
6290
+ }
6291
+ ),
6292
+ rightIcon ? onClickRightIcon ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6293
+ Button_default.icon,
6294
+ {
6295
+ icon: rightIcon,
6296
+ position: "absolute",
6297
+ top: 46 / 2,
6298
+ right: theme2.styles.space + 1 - theme2.styles.space / 2,
6299
+ transform: "translateY(-50%)",
6300
+ onClick: onClickRightIcon
6301
+ }
6302
+ ) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6303
+ Icon_default,
6304
+ {
6305
+ name: rightIcon,
6306
+ position: "absolute",
6307
+ top: 46 / 2,
6308
+ right: theme2.styles.space + 1,
6309
+ transform: "translateY(-50%)",
6310
+ pointerEvents: "none"
6311
+ }
6312
+ ) : void 0,
6313
+ insideInputFieldComponent
6314
+ ] }),
6315
+ suffix && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6316
+ Div_default.row,
6274
6317
  {
6275
- name: rightIcon,
6276
- position: "absolute",
6277
- top: 46 / 2,
6278
- right: theme2.styles.space + 1,
6279
- transform: "translateY(-50%)",
6280
- pointerEvents: "none"
6318
+ alignItems: "center",
6319
+ justifyContent: "center",
6320
+ border: `1px solid ${theme2.colors.border}`,
6321
+ borderLeft: "none",
6322
+ backgroundColor: suffixBackgroundColor ?? (colorTheme === "light" ? darkenColor(theme2.colors.backgroundContent, 0.03) : lightenColor(theme2.colors.backgroundContent, 0.1)),
6323
+ borderTopRightRadius: theme2.styles.borderRadius,
6324
+ borderBottomRightRadius: theme2.styles.borderRadius,
6325
+ paddingInline: theme2.styles.space,
6326
+ children: suffix
6281
6327
  }
6282
- ) : void 0,
6283
- insideInputFieldComponent
6328
+ )
6284
6329
  ] }),
6285
6330
  (errorText || infoText) && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
6286
6331
  Text_default,