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.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();
@@ -3294,7 +3320,7 @@ var desaturateColor = (hexColor, amount) => {
3294
3320
 
3295
3321
  // src/components/Chip.tsx
3296
3322
  var import_jsx_runtime12 = require("react/jsx-runtime");
3297
- var ChipComponent = (0, import_react14.forwardRef)(function Chip({ text, color, backgroundColor, borderRadius, isSmall, isCircle, ...props }, ref) {
3323
+ var ChipComponent = (0, import_react14.forwardRef)(function Chip({ text, color, backgroundColor, borderRadius, isCircle, ...props }, ref) {
3298
3324
  const theme2 = useTheme();
3299
3325
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3300
3326
  Div_default,
@@ -3302,8 +3328,8 @@ var ChipComponent = (0, import_react14.forwardRef)(function Chip({ text, color,
3302
3328
  width: "fit-content",
3303
3329
  backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
3304
3330
  borderRadius: isCircle ? 999 : borderRadius ?? theme2.styles.borderRadius / 1.3,
3305
- paddingBlock: theme2.styles.gap / (isSmall ? 2 : 1),
3306
- paddingInline: theme2.styles.space / (isSmall ? 1.5 : 1),
3331
+ paddingBlock: theme2.styles.gap / 2,
3332
+ paddingInline: theme2.styles.space / 1.5,
3307
3333
  ...props,
3308
3334
  ref,
3309
3335
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Text_default, { color: color ?? theme2.colors.textPrimary, children: text })
@@ -4879,7 +4905,7 @@ var getFormErrorObject = (formValues) => {
4879
4905
  // src/components/Label.tsx
4880
4906
  var import_react15 = require("react");
4881
4907
  var import_jsx_runtime13 = require("react/jsx-runtime");
4882
- function Label({ text, required, isError, color }) {
4908
+ function Label({ text, required, isError, color, htmlFor }) {
4883
4909
  const theme2 = useTheme();
4884
4910
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
4885
4911
  Text_default,
@@ -4888,6 +4914,8 @@ function Label({ text, required, isError, color }) {
4888
4914
  height: 16,
4889
4915
  fontSize: 14,
4890
4916
  color: isError ? theme2.colors.error : color ?? theme2.colors.textSecondary,
4917
+ htmlFor,
4918
+ "aria-required": required,
4891
4919
  children: [
4892
4920
  text,
4893
4921
  required && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Text_default, { as: "span", fontSize: 16, color: theme2.colors.error, children: [
@@ -4909,6 +4937,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
4909
4937
  errorText,
4910
4938
  infoText,
4911
4939
  required,
4940
+ name,
4912
4941
  disabled,
4913
4942
  options,
4914
4943
  value: controlledValue,
@@ -4925,6 +4954,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
4925
4954
  onChange,
4926
4955
  onChangeSearch,
4927
4956
  renderOption,
4957
+ id,
4928
4958
  ...props
4929
4959
  }, ref) {
4930
4960
  const theme2 = useTheme();
@@ -5068,9 +5098,11 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
5068
5098
  errorText,
5069
5099
  infoText,
5070
5100
  required,
5101
+ name,
5071
5102
  disabled,
5072
5103
  readOnly: !withSearch,
5073
5104
  value: displayValue,
5105
+ id,
5074
5106
  cursor: !withSearch ? "pointer" : void 0,
5075
5107
  placeholder: withSearch ? selectedOption ? selectedOption.label : readyPlaceholder : readyPlaceholder,
5076
5108
  leftIcon,
@@ -5172,7 +5204,8 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
5172
5204
  color: theme2.colors.textSecondary,
5173
5205
  transform: `rotate(${isOpen ? 180 : 0}deg)`,
5174
5206
  transition: theme2.styles.transition,
5175
- pointerEvents: "none"
5207
+ pointerEvents: "none",
5208
+ "aria-hidden": true
5176
5209
  }
5177
5210
  )
5178
5211
  ]
@@ -5504,9 +5537,11 @@ var InputFieldComponent = (0, import_react18.forwardRef)(function InputField({
5504
5537
  holderRef,
5505
5538
  required,
5506
5539
  placeholder,
5540
+ id,
5507
5541
  ...props
5508
5542
  }, ref) {
5509
5543
  const theme2 = useTheme();
5544
+ const internalId = (0, import_react18.useId)();
5510
5545
  const [_, debouncedValue, setDebouncedValue] = useDebounceState(
5511
5546
  props.value?.toString() ?? "",
5512
5547
  debounceDelay
@@ -5539,8 +5574,9 @@ var InputFieldComponent = (0, import_react18.forwardRef)(function InputField({
5539
5574
  if (!withDebounce) return;
5540
5575
  onChangeValue?.(debouncedValue);
5541
5576
  }, [withDebounce, onChangeValue, debouncedValue]);
5577
+ const readyId = id ?? internalId;
5542
5578
  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 }),
5579
+ label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
5544
5580
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Div_default, { position: "relative", width: "100%", ref: holderRef, children: [
5545
5581
  leftIcon && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
5546
5582
  Icon_default,
@@ -5562,6 +5598,7 @@ var InputFieldComponent = (0, import_react18.forwardRef)(function InputField({
5562
5598
  withRightIcon: rightIcon !== void 0,
5563
5599
  required,
5564
5600
  placeholder: placeholder ?? label,
5601
+ id: readyId,
5565
5602
  onChange: onChangeElement,
5566
5603
  ...styledComponentStylesWithoutExcluded,
5567
5604
  ...dataProps,
@@ -5616,9 +5653,11 @@ InputFieldComponent.multiline = (0, import_react18.forwardRef)(function Multilin
5616
5653
  onChangeValue,
5617
5654
  onClickRightIcon,
5618
5655
  required,
5656
+ id,
5619
5657
  ...props
5620
5658
  }, ref) {
5621
5659
  const theme2 = useTheme();
5660
+ const internalId = (0, import_react18.useId)();
5622
5661
  const styledComponentStyles = useStyledComponentStyles(props, theme2);
5623
5662
  const dataProps = useComponentPropsWithPrefix(props, "data");
5624
5663
  const ariaProps = useComponentPropsWithPrefix(props, "aria");
@@ -5630,8 +5669,9 @@ InputFieldComponent.multiline = (0, import_react18.forwardRef)(function Multilin
5630
5669
  },
5631
5670
  [onChange, onChangeValue]
5632
5671
  );
5672
+ const readyId = id ?? internalId;
5633
5673
  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 }),
5674
+ label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label_default, { text: label, required, isError: !!errorText, htmlFor: readyId }),
5635
5675
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Div_default, { position: "relative", width: "100%", children: [
5636
5676
  leftIcon && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
5637
5677
  Icon_default,
@@ -5653,6 +5693,7 @@ InputFieldComponent.multiline = (0, import_react18.forwardRef)(function Multilin
5653
5693
  required,
5654
5694
  placeholder: placeholder ?? label,
5655
5695
  onChange: onChangeElement,
5696
+ id: readyId,
5656
5697
  ...styledComponentStyles,
5657
5698
  ...dataProps,
5658
5699
  ...ariaProps,
@@ -5729,8 +5770,9 @@ InputFieldComponent.password = (0, import_react18.forwardRef)(function Password(
5729
5770
  InputFieldComponent.search = (0, import_react18.forwardRef)(function Search({ ...props }, ref) {
5730
5771
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(InputFieldComponent, { leftIcon: "magnifyingGlass", placeholder: "Search...", ref, ...props });
5731
5772
  });
5732
- InputFieldComponent.phoneNumber = (0, import_react18.forwardRef)(function PhoneNumber({ label, value, onChangeValue, labelColor, ...props }, ref) {
5773
+ InputFieldComponent.phoneNumber = (0, import_react18.forwardRef)(function PhoneNumber({ label, value, onChangeValue, labelColor, id, ...props }, ref) {
5733
5774
  const theme2 = useTheme();
5775
+ const internalId = (0, import_react18.useId)();
5734
5776
  const [dropdownValue, setDropdownValue] = (0, import_react18.useState)();
5735
5777
  const [inputFieldValue, setInputFieldValue] = (0, import_react18.useState)(value?.toString() ?? "");
5736
5778
  const renderOption = (0, import_react18.useCallback)(
@@ -5778,8 +5820,18 @@ InputFieldComponent.phoneNumber = (0, import_react18.forwardRef)(function PhoneN
5778
5820
  setDropdownValue(country.phoneNumberExtension);
5779
5821
  setInputFieldValue(newValue.slice(country?.phoneNumberExtension.length + 1));
5780
5822
  }, [value]);
5823
+ const readyId = id ?? internalId;
5781
5824
  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 }),
5825
+ label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
5826
+ Label_default,
5827
+ {
5828
+ text: label,
5829
+ color: labelColor,
5830
+ required: props.required,
5831
+ isError: !!props.errorText,
5832
+ htmlFor: readyId
5833
+ }
5834
+ ),
5783
5835
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Div_default.row, { children: [
5784
5836
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
5785
5837
  Dropdown_default,
@@ -5805,6 +5857,7 @@ InputFieldComponent.phoneNumber = (0, import_react18.forwardRef)(function PhoneN
5805
5857
  value: inputFieldValue,
5806
5858
  onChangeValue: onChangeValueElement,
5807
5859
  ref,
5860
+ id: readyId,
5808
5861
  ...props
5809
5862
  }
5810
5863
  )
@@ -6223,9 +6276,11 @@ var ToggleInputComponent = (0, import_react19.forwardRef)(function ToggleInput({
6223
6276
  checked: controlledChecked,
6224
6277
  color,
6225
6278
  required,
6279
+ id,
6226
6280
  ...props
6227
6281
  }, ref) {
6228
6282
  const theme2 = useTheme();
6283
+ const internalId = (0, import_react19.useId)();
6229
6284
  const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
6230
6285
  const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
6231
6286
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -6246,8 +6301,9 @@ var ToggleInputComponent = (0, import_react19.forwardRef)(function ToggleInput({
6246
6301
  if (controlledChecked === void 0) setInternalChecked(newIsChecked);
6247
6302
  onChange?.(newIsChecked, value);
6248
6303
  }, [checked, controlledChecked, onChange, value]);
6304
+ const readyId = id ?? internalId;
6249
6305
  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 }),
6306
+ label && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
6251
6307
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Div_default.row, { alignItems: "center", gap: theme2.styles.gap, children: [
6252
6308
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Div_default.row, { position: "relative", alignItems: "center", children: [
6253
6309
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -6257,6 +6313,7 @@ var ToggleInputComponent = (0, import_react19.forwardRef)(function ToggleInput({
6257
6313
  type: props.type ?? "checkbox",
6258
6314
  checked,
6259
6315
  onChange: onChangeElement,
6316
+ id: readyId,
6260
6317
  ...styledComponentStyles,
6261
6318
  ...dataProps,
6262
6319
  ...ariaProps,
@@ -6330,9 +6387,11 @@ var ToggleInput_default = {
6330
6387
  onChange,
6331
6388
  checked: controlledChecked,
6332
6389
  required,
6390
+ id,
6333
6391
  ...props
6334
6392
  }, ref) {
6335
6393
  const theme2 = useTheme();
6394
+ const internalId = (0, import_react19.useId)();
6336
6395
  const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
6337
6396
  const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
6338
6397
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -6347,8 +6406,9 @@ var ToggleInput_default = {
6347
6406
  if (controlledChecked === void 0) setInternalChecked.setState(newIsChecked);
6348
6407
  onChange?.(newIsChecked, value);
6349
6408
  }, [disabled, checked, onChange, controlledChecked, value]);
6409
+ const readyId = id ?? internalId;
6350
6410
  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 }),
6411
+ label && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label_default, { text: label, color: labelColor, required, isError: !!errorText, htmlFor: readyId }),
6352
6412
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
6353
6413
  Div_default.row,
6354
6414
  {
@@ -6368,6 +6428,10 @@ var ToggleInput_default = {
6368
6428
  disabled: disabled ?? false,
6369
6429
  isMouseDown,
6370
6430
  onClick: onClickElement,
6431
+ id: readyId,
6432
+ role: "switch",
6433
+ "aria-checked": checked,
6434
+ "aria-disabled": disabled ?? false,
6371
6435
  ...styledComponentStyles,
6372
6436
  ...dataProps,
6373
6437
  ...ariaProps,