react-better-html 1.1.89 → 1.1.91

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.mjs CHANGED
@@ -1941,6 +1941,7 @@ function useForm(options) {
1941
1941
  return {
1942
1942
  required: requiredFields?.includes(field),
1943
1943
  value: values[field]?.toString() ?? "",
1944
+ name: field.toString(),
1944
1945
  onChangeValue: (newValue) => {
1945
1946
  const readyValue = type === "number" ? newValue ? Number(newValue) : void 0 : newValue;
1946
1947
  setFieldValue(field, readyValue);
@@ -1964,6 +1965,7 @@ function useForm(options) {
1964
1965
  return {
1965
1966
  required: requiredFields?.includes(field),
1966
1967
  value: values[field]?.toString() ?? "",
1968
+ name: field.toString(),
1967
1969
  onChangeValue: (newValue) => {
1968
1970
  setFieldValue(field, newValue);
1969
1971
  },
@@ -1977,6 +1979,7 @@ function useForm(options) {
1977
1979
  return {
1978
1980
  required: requiredFields?.includes(field),
1979
1981
  value: values[field],
1982
+ name: field.toString(),
1980
1983
  onChange: (value) => {
1981
1984
  setFieldValue(field, value);
1982
1985
  },
@@ -1990,6 +1993,7 @@ function useForm(options) {
1990
1993
  return {
1991
1994
  required: requiredFields?.includes(field),
1992
1995
  checked: values[field],
1996
+ name: field.toString(),
1993
1997
  onChange: (checked) => {
1994
1998
  setFieldValue(field, checked);
1995
1999
  },
@@ -2018,6 +2022,7 @@ function useForm(options) {
2018
2022
  return {
2019
2023
  required: requiredFields?.includes(field),
2020
2024
  checked: values[field],
2025
+ name: field.toString(),
2021
2026
  onChange: (checked) => {
2022
2027
  setFieldValue(field, checked);
2023
2028
  },
@@ -2153,7 +2158,17 @@ var DivStyledComponent = styled.div.withConfig({
2153
2158
  ${(props) => props.hoverStyle}
2154
2159
  }
2155
2160
  `;
2156
- var DivComponent = forwardRef(function Div({ value, as, isTabAccessed, onClickWithValue, role, onClick, onKeyDown, children, ...props }, ref) {
2161
+ var DivComponent = forwardRef(function Div({
2162
+ as = "div",
2163
+ value,
2164
+ isTabAccessed,
2165
+ onClickWithValue,
2166
+ role,
2167
+ onClick,
2168
+ onKeyDown,
2169
+ children,
2170
+ ...props
2171
+ }, ref) {
2157
2172
  const theme2 = useTheme();
2158
2173
  const styledComponentStyles = useStyledComponentStyles(props, theme2);
2159
2174
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -2247,7 +2262,7 @@ var Div_default = Div2;
2247
2262
  import { forwardRef as forwardRef2, memo as memo3 } from "react";
2248
2263
  import styled2 from "styled-components";
2249
2264
  import { jsx as jsx3 } from "react/jsx-runtime";
2250
- var TextStyledComponent = styled2.div.withConfig({
2265
+ var TextStyledComponent = styled2.p.withConfig({
2251
2266
  shouldForwardProp: (prop) => !["normalStyle", "hoverStyle"].includes(prop)
2252
2267
  })`
2253
2268
  ${(props) => props.normalStyle}
@@ -2256,13 +2271,24 @@ var TextStyledComponent = styled2.div.withConfig({
2256
2271
  ${(props) => props.hoverStyle}
2257
2272
  }
2258
2273
  `;
2259
- var TextComponent = forwardRef2(function Text({ as = "p", children, ...props }, ref) {
2274
+ var TextComponent = forwardRef2(function Text({ children, ...props }, ref) {
2260
2275
  const theme2 = useTheme();
2261
2276
  const styledComponentStyles = useStyledComponentStyles(props, theme2);
2262
2277
  const dataProps = useComponentPropsWithPrefix(props, "data");
2263
2278
  const ariaProps = useComponentPropsWithPrefix(props, "aria");
2264
2279
  const restProps = useComponentPropsWithoutStyle(props);
2265
- return /* @__PURE__ */ jsx3(TextStyledComponent, { as, ...styledComponentStyles, ...dataProps, ...ariaProps, ...restProps, ref, children });
2280
+ return /* @__PURE__ */ jsx3(
2281
+ TextStyledComponent,
2282
+ {
2283
+ as: props.as,
2284
+ ...styledComponentStyles,
2285
+ ...dataProps,
2286
+ ...ariaProps,
2287
+ ...restProps,
2288
+ ref,
2289
+ children
2290
+ }
2291
+ );
2266
2292
  });
2267
2293
  TextComponent.unknown = forwardRef2(function Unknown(props, ref) {
2268
2294
  const theme2 = useTheme();
@@ -2438,8 +2464,22 @@ var Image = forwardRef4(function Image2({ name, src, ...props }, ref) {
2438
2464
  }
2439
2465
  );
2440
2466
  });
2441
- Image.profileImage = forwardRef4(function ProfileImage({ size = 40, ...props }, ref) {
2442
- return /* @__PURE__ */ jsx6(Image, { width: size, height: size, borderRadius: "50%", objectFit: "cover", ref, ...props });
2467
+ Image.profileImage = forwardRef4(function ProfileImage({ size = 40, letters, backgroundColor, ...props }, ref) {
2468
+ const theme2 = useTheme();
2469
+ return letters ? /* @__PURE__ */ jsx6(
2470
+ Div_default.row,
2471
+ {
2472
+ width: size,
2473
+ height: size,
2474
+ backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
2475
+ borderRadius: 999,
2476
+ alignItems: "center",
2477
+ justifyContent: "center",
2478
+ ref,
2479
+ ...props,
2480
+ children: /* @__PURE__ */ jsx6(Text_default, { fontWeight: 700, children: letters.toUpperCase().slice(0, 2) })
2481
+ }
2482
+ ) : /* @__PURE__ */ jsx6(Image, { width: size, height: size, borderRadius: 999, objectFit: "cover", ref, ...props });
2443
2483
  });
2444
2484
  var MemoizedImage = memo6(Image);
2445
2485
  MemoizedImage.profileImage = Image.profileImage;
@@ -3251,7 +3291,7 @@ Chip2.colored = ChipComponent.colored;
3251
3291
  var Chip_default = Chip2;
3252
3292
 
3253
3293
  // src/components/InputField.tsx
3254
- import { forwardRef as forwardRef8, memo as memo16, useCallback as useCallback8, useState as useState6, useEffect as useEffect7, useMemo as useMemo5, useRef as useRef4 } from "react";
3294
+ import { forwardRef as forwardRef8, memo as memo16, useCallback as useCallback8, useState as useState6, useEffect as useEffect7, useMemo as useMemo5, useRef as useRef4, useId } from "react";
3255
3295
  import styled8 from "styled-components";
3256
3296
 
3257
3297
  // src/constants/countries.ts
@@ -4800,7 +4840,7 @@ var getFormErrorObject = (formValues) => {
4800
4840
  // src/components/Label.tsx
4801
4841
  import { memo as memo13 } from "react";
4802
4842
  import { jsxs as jsxs7 } from "react/jsx-runtime";
4803
- function Label({ text, required, isError, color }) {
4843
+ function Label({ text, required, isError, color, htmlFor }) {
4804
4844
  const theme2 = useTheme();
4805
4845
  return /* @__PURE__ */ jsxs7(
4806
4846
  Text_default,
@@ -4809,6 +4849,8 @@ function Label({ text, required, isError, color }) {
4809
4849
  height: 16,
4810
4850
  fontSize: 14,
4811
4851
  color: isError ? theme2.colors.error : color ?? theme2.colors.textSecondary,
4852
+ htmlFor,
4853
+ "aria-required": required,
4812
4854
  children: [
4813
4855
  text,
4814
4856
  required && /* @__PURE__ */ jsxs7(Text_default, { as: "span", fontSize: 16, color: theme2.colors.error, children: [
@@ -4830,6 +4872,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
4830
4872
  errorText,
4831
4873
  infoText,
4832
4874
  required,
4875
+ name,
4833
4876
  disabled,
4834
4877
  options,
4835
4878
  value: controlledValue,
@@ -4846,6 +4889,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
4846
4889
  onChange,
4847
4890
  onChangeSearch,
4848
4891
  renderOption,
4892
+ id,
4849
4893
  ...props
4850
4894
  }, ref) {
4851
4895
  const theme2 = useTheme();
@@ -4989,9 +5033,11 @@ var DropdownComponent = forwardRef7(function Dropdown({
4989
5033
  errorText,
4990
5034
  infoText,
4991
5035
  required,
5036
+ name,
4992
5037
  disabled,
4993
5038
  readOnly: !withSearch,
4994
5039
  value: displayValue,
5040
+ id,
4995
5041
  cursor: !withSearch ? "pointer" : void 0,
4996
5042
  placeholder: withSearch ? selectedOption ? selectedOption.label : readyPlaceholder : readyPlaceholder,
4997
5043
  leftIcon,
@@ -5093,7 +5139,8 @@ var DropdownComponent = forwardRef7(function Dropdown({
5093
5139
  color: theme2.colors.textSecondary,
5094
5140
  transform: `rotate(${isOpen ? 180 : 0}deg)`,
5095
5141
  transition: theme2.styles.transition,
5096
- pointerEvents: "none"
5142
+ pointerEvents: "none",
5143
+ "aria-hidden": true
5097
5144
  }
5098
5145
  )
5099
5146
  ]
@@ -5425,9 +5472,11 @@ var InputFieldComponent = forwardRef8(function InputField({
5425
5472
  holderRef,
5426
5473
  required,
5427
5474
  placeholder,
5475
+ id,
5428
5476
  ...props
5429
5477
  }, ref) {
5430
5478
  const theme2 = useTheme();
5479
+ const internalId = useId();
5431
5480
  const [_, debouncedValue, setDebouncedValue] = useDebounceState(
5432
5481
  props.value?.toString() ?? "",
5433
5482
  debounceDelay
@@ -5460,8 +5509,9 @@ var InputFieldComponent = forwardRef8(function InputField({
5460
5509
  if (!withDebounce) return;
5461
5510
  onChangeValue?.(debouncedValue);
5462
5511
  }, [withDebounce, onChangeValue, debouncedValue]);
5512
+ const readyId = id ?? internalId;
5463
5513
  return /* @__PURE__ */ jsxs10(Div_default.column, { width: "100%", gap: theme2.styles.gap, ...styledComponentStylesWithExcluded, children: [
5464
- label && /* @__PURE__ */ jsx15(Label_default, { text: label, color: labelColor, required, isError: !!errorText }),
5514
+ label && /* @__PURE__ */ jsx15(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
5465
5515
  /* @__PURE__ */ jsxs10(Div_default, { position: "relative", width: "100%", ref: holderRef, children: [
5466
5516
  leftIcon && /* @__PURE__ */ jsx15(
5467
5517
  Icon_default,
@@ -5483,6 +5533,7 @@ var InputFieldComponent = forwardRef8(function InputField({
5483
5533
  withRightIcon: rightIcon !== void 0,
5484
5534
  required,
5485
5535
  placeholder: placeholder ?? label,
5536
+ id: readyId,
5486
5537
  onChange: onChangeElement,
5487
5538
  ...styledComponentStylesWithoutExcluded,
5488
5539
  ...dataProps,
@@ -5537,9 +5588,11 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
5537
5588
  onChangeValue,
5538
5589
  onClickRightIcon,
5539
5590
  required,
5591
+ id,
5540
5592
  ...props
5541
5593
  }, ref) {
5542
5594
  const theme2 = useTheme();
5595
+ const internalId = useId();
5543
5596
  const styledComponentStyles = useStyledComponentStyles(props, theme2);
5544
5597
  const dataProps = useComponentPropsWithPrefix(props, "data");
5545
5598
  const ariaProps = useComponentPropsWithPrefix(props, "aria");
@@ -5551,8 +5604,9 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
5551
5604
  },
5552
5605
  [onChange, onChangeValue]
5553
5606
  );
5607
+ const readyId = id ?? internalId;
5554
5608
  return /* @__PURE__ */ jsxs10(Div_default.column, { gap: theme2.styles.gap, children: [
5555
- label && /* @__PURE__ */ jsx15(Label_default, { text: label, required, isError: !!errorText }),
5609
+ label && /* @__PURE__ */ jsx15(Label_default, { text: label, required, isError: !!errorText, htmlFor: readyId }),
5556
5610
  /* @__PURE__ */ jsxs10(Div_default, { position: "relative", width: "100%", children: [
5557
5611
  leftIcon && /* @__PURE__ */ jsx15(
5558
5612
  Icon_default,
@@ -5574,6 +5628,7 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
5574
5628
  required,
5575
5629
  placeholder: placeholder ?? label,
5576
5630
  onChange: onChangeElement,
5631
+ id: readyId,
5577
5632
  ...styledComponentStyles,
5578
5633
  ...dataProps,
5579
5634
  ...ariaProps,
@@ -5650,8 +5705,9 @@ InputFieldComponent.password = forwardRef8(function Password({ ...props }, ref)
5650
5705
  InputFieldComponent.search = forwardRef8(function Search({ ...props }, ref) {
5651
5706
  return /* @__PURE__ */ jsx15(InputFieldComponent, { leftIcon: "magnifyingGlass", placeholder: "Search...", ref, ...props });
5652
5707
  });
5653
- InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, value, onChangeValue, labelColor, ...props }, ref) {
5708
+ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, value, onChangeValue, labelColor, id, ...props }, ref) {
5654
5709
  const theme2 = useTheme();
5710
+ const internalId = useId();
5655
5711
  const [dropdownValue, setDropdownValue] = useState6();
5656
5712
  const [inputFieldValue, setInputFieldValue] = useState6(value?.toString() ?? "");
5657
5713
  const renderOption = useCallback8(
@@ -5699,8 +5755,18 @@ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, valu
5699
5755
  setDropdownValue(country.phoneNumberExtension);
5700
5756
  setInputFieldValue(newValue.slice(country?.phoneNumberExtension.length + 1));
5701
5757
  }, [value]);
5758
+ const readyId = id ?? internalId;
5702
5759
  return /* @__PURE__ */ jsxs10(Div_default.column, { width: "100%", gap: theme2.styles.gap, children: [
5703
- label && /* @__PURE__ */ jsx15(Label_default, { text: label, color: labelColor, required: props.required, isError: !!props.errorText }),
5760
+ label && /* @__PURE__ */ jsx15(
5761
+ Label_default,
5762
+ {
5763
+ text: label,
5764
+ color: labelColor,
5765
+ required: props.required,
5766
+ isError: !!props.errorText,
5767
+ htmlFor: readyId
5768
+ }
5769
+ ),
5704
5770
  /* @__PURE__ */ jsxs10(Div_default.row, { children: [
5705
5771
  /* @__PURE__ */ jsx15(
5706
5772
  Dropdown_default,
@@ -5726,6 +5792,7 @@ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, valu
5726
5792
  value: inputFieldValue,
5727
5793
  onChangeValue: onChangeValueElement,
5728
5794
  ref,
5795
+ id: readyId,
5729
5796
  ...props
5730
5797
  }
5731
5798
  )
@@ -6038,7 +6105,7 @@ InputField2.time = InputFieldComponent.time;
6038
6105
  var InputField_default = InputField2;
6039
6106
 
6040
6107
  // src/components/ToggleInput.tsx
6041
- import { forwardRef as forwardRef9, useCallback as useCallback9, useState as useState7 } from "react";
6108
+ import { forwardRef as forwardRef9, useCallback as useCallback9, useId as useId2, useState as useState7 } from "react";
6042
6109
  import styled9 from "styled-components";
6043
6110
  import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
6044
6111
  var componentSize = 26;
@@ -6144,9 +6211,11 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
6144
6211
  checked: controlledChecked,
6145
6212
  color,
6146
6213
  required,
6214
+ id,
6147
6215
  ...props
6148
6216
  }, ref) {
6149
6217
  const theme2 = useTheme();
6218
+ const internalId = useId2();
6150
6219
  const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
6151
6220
  const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
6152
6221
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -6167,8 +6236,9 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
6167
6236
  if (controlledChecked === void 0) setInternalChecked(newIsChecked);
6168
6237
  onChange?.(newIsChecked, value);
6169
6238
  }, [checked, controlledChecked, onChange, value]);
6239
+ const readyId = id ?? internalId;
6170
6240
  return /* @__PURE__ */ jsxs11(Div_default.column, { width: "100%", gap: theme2.styles.gap, ...styledComponentStylesWithExcluded, children: [
6171
- label && /* @__PURE__ */ jsx16(Label_default, { text: label, color: labelColor, required, isError: !!errorText }),
6241
+ label && /* @__PURE__ */ jsx16(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
6172
6242
  /* @__PURE__ */ jsxs11(Div_default.row, { alignItems: "center", gap: theme2.styles.gap, children: [
6173
6243
  /* @__PURE__ */ jsxs11(Div_default.row, { position: "relative", alignItems: "center", children: [
6174
6244
  /* @__PURE__ */ jsx16(
@@ -6178,6 +6248,7 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
6178
6248
  type: props.type ?? "checkbox",
6179
6249
  checked,
6180
6250
  onChange: onChangeElement,
6251
+ id: readyId,
6181
6252
  ...styledComponentStyles,
6182
6253
  ...dataProps,
6183
6254
  ...ariaProps,
@@ -6251,9 +6322,11 @@ var ToggleInput_default = {
6251
6322
  onChange,
6252
6323
  checked: controlledChecked,
6253
6324
  required,
6325
+ id,
6254
6326
  ...props
6255
6327
  }, ref) {
6256
6328
  const theme2 = useTheme();
6329
+ const internalId = useId2();
6257
6330
  const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
6258
6331
  const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
6259
6332
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -6268,8 +6341,9 @@ var ToggleInput_default = {
6268
6341
  if (controlledChecked === void 0) setInternalChecked.setState(newIsChecked);
6269
6342
  onChange?.(newIsChecked, value);
6270
6343
  }, [disabled, checked, onChange, controlledChecked, value]);
6344
+ const readyId = id ?? internalId;
6271
6345
  return /* @__PURE__ */ jsxs11(Div_default.column, { width: "fit-content", gap: theme2.styles.gap, ...styledComponentStylesWithExcluded, children: [
6272
- label && /* @__PURE__ */ jsx16(Label_default, { text: label, color: labelColor, required, isError: !!errorText }),
6346
+ label && /* @__PURE__ */ jsx16(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
6273
6347
  /* @__PURE__ */ jsx16(
6274
6348
  Div_default.row,
6275
6349
  {
@@ -6289,6 +6363,10 @@ var ToggleInput_default = {
6289
6363
  disabled: disabled ?? false,
6290
6364
  isMouseDown,
6291
6365
  onClick: onClickElement,
6366
+ id: readyId,
6367
+ role: "switch",
6368
+ "aria-checked": checked,
6369
+ "aria-disabled": disabled ?? false,
6292
6370
  ...styledComponentStyles,
6293
6371
  ...dataProps,
6294
6372
  ...ariaProps,