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.js CHANGED
@@ -2020,6 +2020,7 @@ function useForm(options) {
2020
2020
  return {
2021
2021
  required: requiredFields?.includes(field),
2022
2022
  value: values[field]?.toString() ?? "",
2023
+ name: field.toString(),
2023
2024
  onChangeValue: (newValue) => {
2024
2025
  const readyValue = type === "number" ? newValue ? Number(newValue) : void 0 : newValue;
2025
2026
  setFieldValue(field, readyValue);
@@ -2043,6 +2044,7 @@ function useForm(options) {
2043
2044
  return {
2044
2045
  required: requiredFields?.includes(field),
2045
2046
  value: values[field]?.toString() ?? "",
2047
+ name: field.toString(),
2046
2048
  onChangeValue: (newValue) => {
2047
2049
  setFieldValue(field, newValue);
2048
2050
  },
@@ -2056,6 +2058,7 @@ function useForm(options) {
2056
2058
  return {
2057
2059
  required: requiredFields?.includes(field),
2058
2060
  value: values[field],
2061
+ name: field.toString(),
2059
2062
  onChange: (value) => {
2060
2063
  setFieldValue(field, value);
2061
2064
  },
@@ -2069,6 +2072,7 @@ function useForm(options) {
2069
2072
  return {
2070
2073
  required: requiredFields?.includes(field),
2071
2074
  checked: values[field],
2075
+ name: field.toString(),
2072
2076
  onChange: (checked) => {
2073
2077
  setFieldValue(field, checked);
2074
2078
  },
@@ -2097,6 +2101,7 @@ function useForm(options) {
2097
2101
  return {
2098
2102
  required: requiredFields?.includes(field),
2099
2103
  checked: values[field],
2104
+ name: field.toString(),
2100
2105
  onChange: (checked) => {
2101
2106
  setFieldValue(field, checked);
2102
2107
  },
@@ -2232,7 +2237,17 @@ var DivStyledComponent = import_styled_components2.default.div.withConfig({
2232
2237
  ${(props) => props.hoverStyle}
2233
2238
  }
2234
2239
  `;
2235
- var DivComponent = (0, import_react3.forwardRef)(function Div({ value, as, isTabAccessed, onClickWithValue, role, onClick, onKeyDown, children, ...props }, ref) {
2240
+ var DivComponent = (0, import_react3.forwardRef)(function Div({
2241
+ as = "div",
2242
+ value,
2243
+ isTabAccessed,
2244
+ onClickWithValue,
2245
+ role,
2246
+ onClick,
2247
+ onKeyDown,
2248
+ children,
2249
+ ...props
2250
+ }, ref) {
2236
2251
  const theme2 = useTheme();
2237
2252
  const styledComponentStyles = useStyledComponentStyles(props, theme2);
2238
2253
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -2326,7 +2341,7 @@ var Div_default = Div2;
2326
2341
  var import_react4 = require("react");
2327
2342
  var import_styled_components3 = __toESM(require("styled-components"));
2328
2343
  var import_jsx_runtime3 = require("react/jsx-runtime");
2329
- var TextStyledComponent = import_styled_components3.default.div.withConfig({
2344
+ var TextStyledComponent = import_styled_components3.default.p.withConfig({
2330
2345
  shouldForwardProp: (prop) => !["normalStyle", "hoverStyle"].includes(prop)
2331
2346
  })`
2332
2347
  ${(props) => props.normalStyle}
@@ -2335,13 +2350,24 @@ var TextStyledComponent = import_styled_components3.default.div.withConfig({
2335
2350
  ${(props) => props.hoverStyle}
2336
2351
  }
2337
2352
  `;
2338
- var TextComponent = (0, import_react4.forwardRef)(function Text({ as = "p", children, ...props }, ref) {
2353
+ var TextComponent = (0, import_react4.forwardRef)(function Text({ children, ...props }, ref) {
2339
2354
  const theme2 = useTheme();
2340
2355
  const styledComponentStyles = useStyledComponentStyles(props, theme2);
2341
2356
  const dataProps = useComponentPropsWithPrefix(props, "data");
2342
2357
  const ariaProps = useComponentPropsWithPrefix(props, "aria");
2343
2358
  const restProps = useComponentPropsWithoutStyle(props);
2344
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TextStyledComponent, { as, ...styledComponentStyles, ...dataProps, ...ariaProps, ...restProps, ref, children });
2359
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2360
+ TextStyledComponent,
2361
+ {
2362
+ as: props.as,
2363
+ ...styledComponentStyles,
2364
+ ...dataProps,
2365
+ ...ariaProps,
2366
+ ...restProps,
2367
+ ref,
2368
+ children
2369
+ }
2370
+ );
2345
2371
  });
2346
2372
  TextComponent.unknown = (0, import_react4.forwardRef)(function Unknown(props, ref) {
2347
2373
  const theme2 = useTheme();
@@ -2517,8 +2543,22 @@ var Image = (0, import_react8.forwardRef)(function Image2({ name, src, ...props
2517
2543
  }
2518
2544
  );
2519
2545
  });
2520
- Image.profileImage = (0, import_react8.forwardRef)(function ProfileImage({ size = 40, ...props }, ref) {
2521
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Image, { width: size, height: size, borderRadius: "50%", objectFit: "cover", ref, ...props });
2546
+ Image.profileImage = (0, import_react8.forwardRef)(function ProfileImage({ size = 40, letters, backgroundColor, ...props }, ref) {
2547
+ const theme2 = useTheme();
2548
+ return letters ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2549
+ Div_default.row,
2550
+ {
2551
+ width: size,
2552
+ height: size,
2553
+ backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
2554
+ borderRadius: 999,
2555
+ alignItems: "center",
2556
+ justifyContent: "center",
2557
+ ref,
2558
+ ...props,
2559
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text_default, { fontWeight: 700, children: letters.toUpperCase().slice(0, 2) })
2560
+ }
2561
+ ) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Image, { width: size, height: size, borderRadius: 999, objectFit: "cover", ref, ...props });
2522
2562
  });
2523
2563
  var MemoizedImage = (0, import_react8.memo)(Image);
2524
2564
  MemoizedImage.profileImage = Image.profileImage;
@@ -4879,7 +4919,7 @@ var getFormErrorObject = (formValues) => {
4879
4919
  // src/components/Label.tsx
4880
4920
  var import_react15 = require("react");
4881
4921
  var import_jsx_runtime13 = require("react/jsx-runtime");
4882
- function Label({ text, required, isError, color }) {
4922
+ function Label({ text, required, isError, color, htmlFor }) {
4883
4923
  const theme2 = useTheme();
4884
4924
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
4885
4925
  Text_default,
@@ -4888,6 +4928,8 @@ function Label({ text, required, isError, color }) {
4888
4928
  height: 16,
4889
4929
  fontSize: 14,
4890
4930
  color: isError ? theme2.colors.error : color ?? theme2.colors.textSecondary,
4931
+ htmlFor,
4932
+ "aria-required": required,
4891
4933
  children: [
4892
4934
  text,
4893
4935
  required && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Text_default, { as: "span", fontSize: 16, color: theme2.colors.error, children: [
@@ -4909,6 +4951,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
4909
4951
  errorText,
4910
4952
  infoText,
4911
4953
  required,
4954
+ name,
4912
4955
  disabled,
4913
4956
  options,
4914
4957
  value: controlledValue,
@@ -4925,6 +4968,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
4925
4968
  onChange,
4926
4969
  onChangeSearch,
4927
4970
  renderOption,
4971
+ id,
4928
4972
  ...props
4929
4973
  }, ref) {
4930
4974
  const theme2 = useTheme();
@@ -5068,9 +5112,11 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
5068
5112
  errorText,
5069
5113
  infoText,
5070
5114
  required,
5115
+ name,
5071
5116
  disabled,
5072
5117
  readOnly: !withSearch,
5073
5118
  value: displayValue,
5119
+ id,
5074
5120
  cursor: !withSearch ? "pointer" : void 0,
5075
5121
  placeholder: withSearch ? selectedOption ? selectedOption.label : readyPlaceholder : readyPlaceholder,
5076
5122
  leftIcon,
@@ -5172,7 +5218,8 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
5172
5218
  color: theme2.colors.textSecondary,
5173
5219
  transform: `rotate(${isOpen ? 180 : 0}deg)`,
5174
5220
  transition: theme2.styles.transition,
5175
- pointerEvents: "none"
5221
+ pointerEvents: "none",
5222
+ "aria-hidden": true
5176
5223
  }
5177
5224
  )
5178
5225
  ]
@@ -5504,9 +5551,11 @@ var InputFieldComponent = (0, import_react18.forwardRef)(function InputField({
5504
5551
  holderRef,
5505
5552
  required,
5506
5553
  placeholder,
5554
+ id,
5507
5555
  ...props
5508
5556
  }, ref) {
5509
5557
  const theme2 = useTheme();
5558
+ const internalId = (0, import_react18.useId)();
5510
5559
  const [_, debouncedValue, setDebouncedValue] = useDebounceState(
5511
5560
  props.value?.toString() ?? "",
5512
5561
  debounceDelay
@@ -5539,8 +5588,9 @@ var InputFieldComponent = (0, import_react18.forwardRef)(function InputField({
5539
5588
  if (!withDebounce) return;
5540
5589
  onChangeValue?.(debouncedValue);
5541
5590
  }, [withDebounce, onChangeValue, debouncedValue]);
5591
+ const readyId = id ?? internalId;
5542
5592
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.gap, ...styledComponentStylesWithExcluded, children: [
5543
- label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label_default, { text: label, color: labelColor, required, isError: !!errorText }),
5593
+ label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
5544
5594
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Div_default, { position: "relative", width: "100%", ref: holderRef, children: [
5545
5595
  leftIcon && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
5546
5596
  Icon_default,
@@ -5562,6 +5612,7 @@ var InputFieldComponent = (0, import_react18.forwardRef)(function InputField({
5562
5612
  withRightIcon: rightIcon !== void 0,
5563
5613
  required,
5564
5614
  placeholder: placeholder ?? label,
5615
+ id: readyId,
5565
5616
  onChange: onChangeElement,
5566
5617
  ...styledComponentStylesWithoutExcluded,
5567
5618
  ...dataProps,
@@ -5616,9 +5667,11 @@ InputFieldComponent.multiline = (0, import_react18.forwardRef)(function Multilin
5616
5667
  onChangeValue,
5617
5668
  onClickRightIcon,
5618
5669
  required,
5670
+ id,
5619
5671
  ...props
5620
5672
  }, ref) {
5621
5673
  const theme2 = useTheme();
5674
+ const internalId = (0, import_react18.useId)();
5622
5675
  const styledComponentStyles = useStyledComponentStyles(props, theme2);
5623
5676
  const dataProps = useComponentPropsWithPrefix(props, "data");
5624
5677
  const ariaProps = useComponentPropsWithPrefix(props, "aria");
@@ -5630,8 +5683,9 @@ InputFieldComponent.multiline = (0, import_react18.forwardRef)(function Multilin
5630
5683
  },
5631
5684
  [onChange, onChangeValue]
5632
5685
  );
5686
+ const readyId = id ?? internalId;
5633
5687
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Div_default.column, { gap: theme2.styles.gap, children: [
5634
- label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label_default, { text: label, required, isError: !!errorText }),
5688
+ label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label_default, { text: label, required, isError: !!errorText, htmlFor: readyId }),
5635
5689
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Div_default, { position: "relative", width: "100%", children: [
5636
5690
  leftIcon && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
5637
5691
  Icon_default,
@@ -5653,6 +5707,7 @@ InputFieldComponent.multiline = (0, import_react18.forwardRef)(function Multilin
5653
5707
  required,
5654
5708
  placeholder: placeholder ?? label,
5655
5709
  onChange: onChangeElement,
5710
+ id: readyId,
5656
5711
  ...styledComponentStyles,
5657
5712
  ...dataProps,
5658
5713
  ...ariaProps,
@@ -5729,8 +5784,9 @@ InputFieldComponent.password = (0, import_react18.forwardRef)(function Password(
5729
5784
  InputFieldComponent.search = (0, import_react18.forwardRef)(function Search({ ...props }, ref) {
5730
5785
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(InputFieldComponent, { leftIcon: "magnifyingGlass", placeholder: "Search...", ref, ...props });
5731
5786
  });
5732
- InputFieldComponent.phoneNumber = (0, import_react18.forwardRef)(function PhoneNumber({ label, value, onChangeValue, labelColor, ...props }, ref) {
5787
+ InputFieldComponent.phoneNumber = (0, import_react18.forwardRef)(function PhoneNumber({ label, value, onChangeValue, labelColor, id, ...props }, ref) {
5733
5788
  const theme2 = useTheme();
5789
+ const internalId = (0, import_react18.useId)();
5734
5790
  const [dropdownValue, setDropdownValue] = (0, import_react18.useState)();
5735
5791
  const [inputFieldValue, setInputFieldValue] = (0, import_react18.useState)(value?.toString() ?? "");
5736
5792
  const renderOption = (0, import_react18.useCallback)(
@@ -5778,8 +5834,18 @@ InputFieldComponent.phoneNumber = (0, import_react18.forwardRef)(function PhoneN
5778
5834
  setDropdownValue(country.phoneNumberExtension);
5779
5835
  setInputFieldValue(newValue.slice(country?.phoneNumberExtension.length + 1));
5780
5836
  }, [value]);
5837
+ const readyId = id ?? internalId;
5781
5838
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.gap, children: [
5782
- label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label_default, { text: label, color: labelColor, required: props.required, isError: !!props.errorText }),
5839
+ label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
5840
+ Label_default,
5841
+ {
5842
+ text: label,
5843
+ color: labelColor,
5844
+ required: props.required,
5845
+ isError: !!props.errorText,
5846
+ htmlFor: readyId
5847
+ }
5848
+ ),
5783
5849
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Div_default.row, { children: [
5784
5850
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
5785
5851
  Dropdown_default,
@@ -5805,6 +5871,7 @@ InputFieldComponent.phoneNumber = (0, import_react18.forwardRef)(function PhoneN
5805
5871
  value: inputFieldValue,
5806
5872
  onChangeValue: onChangeValueElement,
5807
5873
  ref,
5874
+ id: readyId,
5808
5875
  ...props
5809
5876
  }
5810
5877
  )
@@ -6223,9 +6290,11 @@ var ToggleInputComponent = (0, import_react19.forwardRef)(function ToggleInput({
6223
6290
  checked: controlledChecked,
6224
6291
  color,
6225
6292
  required,
6293
+ id,
6226
6294
  ...props
6227
6295
  }, ref) {
6228
6296
  const theme2 = useTheme();
6297
+ const internalId = (0, import_react19.useId)();
6229
6298
  const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
6230
6299
  const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
6231
6300
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -6246,8 +6315,9 @@ var ToggleInputComponent = (0, import_react19.forwardRef)(function ToggleInput({
6246
6315
  if (controlledChecked === void 0) setInternalChecked(newIsChecked);
6247
6316
  onChange?.(newIsChecked, value);
6248
6317
  }, [checked, controlledChecked, onChange, value]);
6318
+ const readyId = id ?? internalId;
6249
6319
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.gap, ...styledComponentStylesWithExcluded, children: [
6250
- label && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label_default, { text: label, color: labelColor, required, isError: !!errorText }),
6320
+ label && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
6251
6321
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Div_default.row, { alignItems: "center", gap: theme2.styles.gap, children: [
6252
6322
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Div_default.row, { position: "relative", alignItems: "center", children: [
6253
6323
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -6257,6 +6327,7 @@ var ToggleInputComponent = (0, import_react19.forwardRef)(function ToggleInput({
6257
6327
  type: props.type ?? "checkbox",
6258
6328
  checked,
6259
6329
  onChange: onChangeElement,
6330
+ id: readyId,
6260
6331
  ...styledComponentStyles,
6261
6332
  ...dataProps,
6262
6333
  ...ariaProps,
@@ -6330,9 +6401,11 @@ var ToggleInput_default = {
6330
6401
  onChange,
6331
6402
  checked: controlledChecked,
6332
6403
  required,
6404
+ id,
6333
6405
  ...props
6334
6406
  }, ref) {
6335
6407
  const theme2 = useTheme();
6408
+ const internalId = (0, import_react19.useId)();
6336
6409
  const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
6337
6410
  const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
6338
6411
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -6347,8 +6420,9 @@ var ToggleInput_default = {
6347
6420
  if (controlledChecked === void 0) setInternalChecked.setState(newIsChecked);
6348
6421
  onChange?.(newIsChecked, value);
6349
6422
  }, [disabled, checked, onChange, controlledChecked, value]);
6423
+ const readyId = id ?? internalId;
6350
6424
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Div_default.column, { width: "fit-content", gap: theme2.styles.gap, ...styledComponentStylesWithExcluded, children: [
6351
- label && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label_default, { text: label, color: labelColor, required, isError: !!errorText }),
6425
+ label && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
6352
6426
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
6353
6427
  Div_default.row,
6354
6428
  {
@@ -6368,6 +6442,10 @@ var ToggleInput_default = {
6368
6442
  disabled: disabled ?? false,
6369
6443
  isMouseDown,
6370
6444
  onClick: onClickElement,
6445
+ id: readyId,
6446
+ role: "switch",
6447
+ "aria-checked": checked,
6448
+ "aria-disabled": disabled ?? false,
6371
6449
  ...styledComponentStyles,
6372
6450
  ...dataProps,
6373
6451
  ...ariaProps,