react-better-html 1.1.88 → 1.1.90

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();
@@ -3215,7 +3241,7 @@ var desaturateColor = (hexColor, amount) => {
3215
3241
 
3216
3242
  // src/components/Chip.tsx
3217
3243
  import { jsx as jsx12 } from "react/jsx-runtime";
3218
- var ChipComponent = forwardRef6(function Chip({ text, color, backgroundColor, borderRadius, isSmall, isCircle, ...props }, ref) {
3244
+ var ChipComponent = forwardRef6(function Chip({ text, color, backgroundColor, borderRadius, isCircle, ...props }, ref) {
3219
3245
  const theme2 = useTheme();
3220
3246
  return /* @__PURE__ */ jsx12(
3221
3247
  Div_default,
@@ -3223,8 +3249,8 @@ var ChipComponent = forwardRef6(function Chip({ text, color, backgroundColor, bo
3223
3249
  width: "fit-content",
3224
3250
  backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
3225
3251
  borderRadius: isCircle ? 999 : borderRadius ?? theme2.styles.borderRadius / 1.3,
3226
- paddingBlock: theme2.styles.gap / (isSmall ? 2 : 1),
3227
- paddingInline: theme2.styles.space / (isSmall ? 1.5 : 1),
3252
+ paddingBlock: theme2.styles.gap / 2,
3253
+ paddingInline: theme2.styles.space / 1.5,
3228
3254
  ...props,
3229
3255
  ref,
3230
3256
  children: /* @__PURE__ */ jsx12(Text_default, { color: color ?? theme2.colors.textPrimary, children: text })
@@ -3251,7 +3277,7 @@ Chip2.colored = ChipComponent.colored;
3251
3277
  var Chip_default = Chip2;
3252
3278
 
3253
3279
  // 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";
3280
+ 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
3281
  import styled8 from "styled-components";
3256
3282
 
3257
3283
  // src/constants/countries.ts
@@ -4800,7 +4826,7 @@ var getFormErrorObject = (formValues) => {
4800
4826
  // src/components/Label.tsx
4801
4827
  import { memo as memo13 } from "react";
4802
4828
  import { jsxs as jsxs7 } from "react/jsx-runtime";
4803
- function Label({ text, required, isError, color }) {
4829
+ function Label({ text, required, isError, color, htmlFor }) {
4804
4830
  const theme2 = useTheme();
4805
4831
  return /* @__PURE__ */ jsxs7(
4806
4832
  Text_default,
@@ -4809,6 +4835,8 @@ function Label({ text, required, isError, color }) {
4809
4835
  height: 16,
4810
4836
  fontSize: 14,
4811
4837
  color: isError ? theme2.colors.error : color ?? theme2.colors.textSecondary,
4838
+ htmlFor,
4839
+ "aria-required": required,
4812
4840
  children: [
4813
4841
  text,
4814
4842
  required && /* @__PURE__ */ jsxs7(Text_default, { as: "span", fontSize: 16, color: theme2.colors.error, children: [
@@ -4830,6 +4858,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
4830
4858
  errorText,
4831
4859
  infoText,
4832
4860
  required,
4861
+ name,
4833
4862
  disabled,
4834
4863
  options,
4835
4864
  value: controlledValue,
@@ -4846,6 +4875,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
4846
4875
  onChange,
4847
4876
  onChangeSearch,
4848
4877
  renderOption,
4878
+ id,
4849
4879
  ...props
4850
4880
  }, ref) {
4851
4881
  const theme2 = useTheme();
@@ -4989,9 +5019,11 @@ var DropdownComponent = forwardRef7(function Dropdown({
4989
5019
  errorText,
4990
5020
  infoText,
4991
5021
  required,
5022
+ name,
4992
5023
  disabled,
4993
5024
  readOnly: !withSearch,
4994
5025
  value: displayValue,
5026
+ id,
4995
5027
  cursor: !withSearch ? "pointer" : void 0,
4996
5028
  placeholder: withSearch ? selectedOption ? selectedOption.label : readyPlaceholder : readyPlaceholder,
4997
5029
  leftIcon,
@@ -5093,7 +5125,8 @@ var DropdownComponent = forwardRef7(function Dropdown({
5093
5125
  color: theme2.colors.textSecondary,
5094
5126
  transform: `rotate(${isOpen ? 180 : 0}deg)`,
5095
5127
  transition: theme2.styles.transition,
5096
- pointerEvents: "none"
5128
+ pointerEvents: "none",
5129
+ "aria-hidden": true
5097
5130
  }
5098
5131
  )
5099
5132
  ]
@@ -5425,9 +5458,11 @@ var InputFieldComponent = forwardRef8(function InputField({
5425
5458
  holderRef,
5426
5459
  required,
5427
5460
  placeholder,
5461
+ id,
5428
5462
  ...props
5429
5463
  }, ref) {
5430
5464
  const theme2 = useTheme();
5465
+ const internalId = useId();
5431
5466
  const [_, debouncedValue, setDebouncedValue] = useDebounceState(
5432
5467
  props.value?.toString() ?? "",
5433
5468
  debounceDelay
@@ -5460,8 +5495,9 @@ var InputFieldComponent = forwardRef8(function InputField({
5460
5495
  if (!withDebounce) return;
5461
5496
  onChangeValue?.(debouncedValue);
5462
5497
  }, [withDebounce, onChangeValue, debouncedValue]);
5498
+ const readyId = id ?? internalId;
5463
5499
  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 }),
5500
+ label && /* @__PURE__ */ jsx15(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
5465
5501
  /* @__PURE__ */ jsxs10(Div_default, { position: "relative", width: "100%", ref: holderRef, children: [
5466
5502
  leftIcon && /* @__PURE__ */ jsx15(
5467
5503
  Icon_default,
@@ -5483,6 +5519,7 @@ var InputFieldComponent = forwardRef8(function InputField({
5483
5519
  withRightIcon: rightIcon !== void 0,
5484
5520
  required,
5485
5521
  placeholder: placeholder ?? label,
5522
+ id: readyId,
5486
5523
  onChange: onChangeElement,
5487
5524
  ...styledComponentStylesWithoutExcluded,
5488
5525
  ...dataProps,
@@ -5537,9 +5574,11 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
5537
5574
  onChangeValue,
5538
5575
  onClickRightIcon,
5539
5576
  required,
5577
+ id,
5540
5578
  ...props
5541
5579
  }, ref) {
5542
5580
  const theme2 = useTheme();
5581
+ const internalId = useId();
5543
5582
  const styledComponentStyles = useStyledComponentStyles(props, theme2);
5544
5583
  const dataProps = useComponentPropsWithPrefix(props, "data");
5545
5584
  const ariaProps = useComponentPropsWithPrefix(props, "aria");
@@ -5551,8 +5590,9 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
5551
5590
  },
5552
5591
  [onChange, onChangeValue]
5553
5592
  );
5593
+ const readyId = id ?? internalId;
5554
5594
  return /* @__PURE__ */ jsxs10(Div_default.column, { gap: theme2.styles.gap, children: [
5555
- label && /* @__PURE__ */ jsx15(Label_default, { text: label, required, isError: !!errorText }),
5595
+ label && /* @__PURE__ */ jsx15(Label_default, { text: label, required, isError: !!errorText, htmlFor: readyId }),
5556
5596
  /* @__PURE__ */ jsxs10(Div_default, { position: "relative", width: "100%", children: [
5557
5597
  leftIcon && /* @__PURE__ */ jsx15(
5558
5598
  Icon_default,
@@ -5574,6 +5614,7 @@ InputFieldComponent.multiline = forwardRef8(function Multiline({
5574
5614
  required,
5575
5615
  placeholder: placeholder ?? label,
5576
5616
  onChange: onChangeElement,
5617
+ id: readyId,
5577
5618
  ...styledComponentStyles,
5578
5619
  ...dataProps,
5579
5620
  ...ariaProps,
@@ -5650,8 +5691,9 @@ InputFieldComponent.password = forwardRef8(function Password({ ...props }, ref)
5650
5691
  InputFieldComponent.search = forwardRef8(function Search({ ...props }, ref) {
5651
5692
  return /* @__PURE__ */ jsx15(InputFieldComponent, { leftIcon: "magnifyingGlass", placeholder: "Search...", ref, ...props });
5652
5693
  });
5653
- InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, value, onChangeValue, labelColor, ...props }, ref) {
5694
+ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, value, onChangeValue, labelColor, id, ...props }, ref) {
5654
5695
  const theme2 = useTheme();
5696
+ const internalId = useId();
5655
5697
  const [dropdownValue, setDropdownValue] = useState6();
5656
5698
  const [inputFieldValue, setInputFieldValue] = useState6(value?.toString() ?? "");
5657
5699
  const renderOption = useCallback8(
@@ -5699,8 +5741,18 @@ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, valu
5699
5741
  setDropdownValue(country.phoneNumberExtension);
5700
5742
  setInputFieldValue(newValue.slice(country?.phoneNumberExtension.length + 1));
5701
5743
  }, [value]);
5744
+ const readyId = id ?? internalId;
5702
5745
  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 }),
5746
+ label && /* @__PURE__ */ jsx15(
5747
+ Label_default,
5748
+ {
5749
+ text: label,
5750
+ color: labelColor,
5751
+ required: props.required,
5752
+ isError: !!props.errorText,
5753
+ htmlFor: readyId
5754
+ }
5755
+ ),
5704
5756
  /* @__PURE__ */ jsxs10(Div_default.row, { children: [
5705
5757
  /* @__PURE__ */ jsx15(
5706
5758
  Dropdown_default,
@@ -5726,6 +5778,7 @@ InputFieldComponent.phoneNumber = forwardRef8(function PhoneNumber({ label, valu
5726
5778
  value: inputFieldValue,
5727
5779
  onChangeValue: onChangeValueElement,
5728
5780
  ref,
5781
+ id: readyId,
5729
5782
  ...props
5730
5783
  }
5731
5784
  )
@@ -6038,7 +6091,7 @@ InputField2.time = InputFieldComponent.time;
6038
6091
  var InputField_default = InputField2;
6039
6092
 
6040
6093
  // src/components/ToggleInput.tsx
6041
- import { forwardRef as forwardRef9, useCallback as useCallback9, useState as useState7 } from "react";
6094
+ import { forwardRef as forwardRef9, useCallback as useCallback9, useId as useId2, useState as useState7 } from "react";
6042
6095
  import styled9 from "styled-components";
6043
6096
  import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
6044
6097
  var componentSize = 26;
@@ -6144,9 +6197,11 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
6144
6197
  checked: controlledChecked,
6145
6198
  color,
6146
6199
  required,
6200
+ id,
6147
6201
  ...props
6148
6202
  }, ref) {
6149
6203
  const theme2 = useTheme();
6204
+ const internalId = useId2();
6150
6205
  const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
6151
6206
  const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
6152
6207
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -6167,8 +6222,9 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
6167
6222
  if (controlledChecked === void 0) setInternalChecked(newIsChecked);
6168
6223
  onChange?.(newIsChecked, value);
6169
6224
  }, [checked, controlledChecked, onChange, value]);
6225
+ const readyId = id ?? internalId;
6170
6226
  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 }),
6227
+ label && /* @__PURE__ */ jsx16(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
6172
6228
  /* @__PURE__ */ jsxs11(Div_default.row, { alignItems: "center", gap: theme2.styles.gap, children: [
6173
6229
  /* @__PURE__ */ jsxs11(Div_default.row, { position: "relative", alignItems: "center", children: [
6174
6230
  /* @__PURE__ */ jsx16(
@@ -6178,6 +6234,7 @@ var ToggleInputComponent = forwardRef9(function ToggleInput({
6178
6234
  type: props.type ?? "checkbox",
6179
6235
  checked,
6180
6236
  onChange: onChangeElement,
6237
+ id: readyId,
6181
6238
  ...styledComponentStyles,
6182
6239
  ...dataProps,
6183
6240
  ...ariaProps,
@@ -6251,9 +6308,11 @@ var ToggleInput_default = {
6251
6308
  onChange,
6252
6309
  checked: controlledChecked,
6253
6310
  required,
6311
+ id,
6254
6312
  ...props
6255
6313
  }, ref) {
6256
6314
  const theme2 = useTheme();
6315
+ const internalId = useId2();
6257
6316
  const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
6258
6317
  const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
6259
6318
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -6268,8 +6327,9 @@ var ToggleInput_default = {
6268
6327
  if (controlledChecked === void 0) setInternalChecked.setState(newIsChecked);
6269
6328
  onChange?.(newIsChecked, value);
6270
6329
  }, [disabled, checked, onChange, controlledChecked, value]);
6330
+ const readyId = id ?? internalId;
6271
6331
  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 }),
6332
+ label && /* @__PURE__ */ jsx16(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
6273
6333
  /* @__PURE__ */ jsx16(
6274
6334
  Div_default.row,
6275
6335
  {
@@ -6289,6 +6349,10 @@ var ToggleInput_default = {
6289
6349
  disabled: disabled ?? false,
6290
6350
  isMouseDown,
6291
6351
  onClick: onClickElement,
6352
+ id: readyId,
6353
+ role: "switch",
6354
+ "aria-checked": checked,
6355
+ "aria-disabled": disabled ?? false,
6292
6356
  ...styledComponentStyles,
6293
6357
  ...dataProps,
6294
6358
  ...ariaProps,