react-better-html 1.1.156 → 1.1.158

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
@@ -1565,10 +1565,24 @@ import styled from "styled-components";
1565
1565
  import { jsx } from "react/jsx-runtime";
1566
1566
  import { createElement } from "react";
1567
1567
  var IconElement = styled.svg.withConfig({
1568
- shouldForwardProp: (prop) => !["normalStyle", "hoverStyle"].includes(prop)
1568
+ shouldForwardProp: (prop) => !["theme", "normalStyle", "hoverStyle", "hoverColor"].includes(prop)
1569
1569
  })`
1570
1570
  ${(props) => props.normalStyle}
1571
1571
 
1572
+ path {
1573
+ ${(props) => props.hoverColor ? `transition: ${props.theme.styles.transition};` : ""}
1574
+ }
1575
+
1576
+ &:hover {
1577
+ path.react-better-html-icon-path-with-fill {
1578
+ fill: ${(props) => props.hoverColor};
1579
+ }
1580
+
1581
+ path.react-better-html-icon-path-with-stroke {
1582
+ stroke: ${(props) => props.hoverColor};
1583
+ }
1584
+ }
1585
+
1572
1586
  &:hover {
1573
1587
  ${(props) => props.hoverStyle}
1574
1588
  }
@@ -1581,6 +1595,7 @@ var Icon = forwardRef(function Icon2({ name, size = 16, ...props }, ref) {
1581
1595
  const ariaProps = useComponentPropsWithPrefix(props, "aria");
1582
1596
  const restProps = useComponentPropsWithoutStyle(props);
1583
1597
  const svgColor = props.color ?? theme2.colors.textPrimary;
1598
+ const svgHoverColorColor = props.colorHover;
1584
1599
  useEffect(() => {
1585
1600
  if (!icons2[name.toString()])
1586
1601
  console.warn(
@@ -1595,6 +1610,8 @@ var Icon = forwardRef(function Icon2({ name, size = 16, ...props }, ref) {
1595
1610
  viewBox: `0 0 ${icons2[name.toString()]?.width ?? 0} ${icons2[name.toString()]?.height ?? 0}`,
1596
1611
  fill: "none",
1597
1612
  xmlns: "http://www.w3.org/2000/svg",
1613
+ theme: theme2,
1614
+ hoverColor: svgHoverColorColor,
1598
1615
  ...styledComponentStyles,
1599
1616
  ...dataProps,
1600
1617
  ...ariaProps,
@@ -1604,6 +1621,7 @@ var Icon = forwardRef(function Icon2({ name, size = 16, ...props }, ref) {
1604
1621
  "path",
1605
1622
  {
1606
1623
  ...path,
1624
+ className: path.type === "fill" ? "react-better-html-icon-path-with-fill" : "react-better-html-icon-path-with-stroke",
1607
1625
  fill: path.type === "fill" ? svgColor : void 0,
1608
1626
  stroke: path.type === "stroke" ? svgColor : void 0,
1609
1627
  key: path.d
@@ -2619,12 +2637,17 @@ function useStyledComponentStyles(props, theme2, excludeProps) {
2619
2637
  haveHover = true;
2620
2638
  const normalKey = key.slice(0, -5);
2621
2639
  hoverStyle[normalKey] = props[key];
2640
+ if (normalKey === "transition") hoverStyle.WebkitTransition = hoverStyle.transition;
2622
2641
  } else {
2623
2642
  if (!cssProps[key.toLowerCase()]) continue;
2624
2643
  normalStyle[key] = props[key];
2644
+ if (key === "transition") normalStyle.WebkitTransition = normalStyle.transition;
2625
2645
  }
2626
2646
  }
2627
- if (haveHover) normalStyle.transition = theme2?.styles.transition ?? "";
2647
+ if (haveHover) {
2648
+ normalStyle.transition = theme2?.styles.transition ?? "";
2649
+ normalStyle.WebkitTransition = normalStyle.transition;
2650
+ }
2628
2651
  return {
2629
2652
  normalStyle,
2630
2653
  hoverStyle
@@ -3830,7 +3853,7 @@ Chip2.colored = ChipComponent.colored;
3830
3853
  var Chip_default = Chip2;
3831
3854
 
3832
3855
  // src/components/InputField.tsx
3833
- import { forwardRef as forwardRef11, memo as memo18, useCallback as useCallback9, useState as useState7, useEffect as useEffect8, useMemo as useMemo6, useRef as useRef5, useId } from "react";
3856
+ import { forwardRef as forwardRef11, memo as memo18, useCallback as useCallback9, useState as useState7, useEffect as useEffect8, useMemo as useMemo6, useRef as useRef5, useId as useId2 } from "react";
3834
3857
  import styled10 from "styled-components";
3835
3858
 
3836
3859
  // src/constants/countries.ts
@@ -4289,13 +4312,15 @@ var countries = [
4289
4312
  name: "Finland",
4290
4313
  code: "FI",
4291
4314
  timeZone: "Europe/Helsinki",
4292
- phoneNumberExtension: "358"
4315
+ phoneNumberExtension: "358",
4316
+ phoneNumberFormat: "XX XXX XX XX"
4293
4317
  },
4294
4318
  {
4295
4319
  name: "France",
4296
4320
  code: "FR",
4297
4321
  timeZone: "Europe/Paris",
4298
- phoneNumberExtension: "33"
4322
+ phoneNumberExtension: "33",
4323
+ phoneNumberFormat: "X XX XX XX XX"
4299
4324
  },
4300
4325
  {
4301
4326
  name: "French Guiana",
@@ -4338,7 +4363,7 @@ var countries = [
4338
4363
  code: "DE",
4339
4364
  timeZone: "Europe/Berlin",
4340
4365
  phoneNumberExtension: "49",
4341
- phoneNumberFormat: "XXXX XXXXXX"
4366
+ phoneNumberFormat: "XXXX XXXXXXX"
4342
4367
  },
4343
4368
  {
4344
4369
  name: "Ghana",
@@ -5375,6 +5400,16 @@ var formatPhoneNumber = (phoneNumber) => {
5375
5400
  var getFormErrorObject = (formValues) => {
5376
5401
  return {};
5377
5402
  };
5403
+ var eventPreventDefault = (event) => {
5404
+ event.preventDefault();
5405
+ };
5406
+ var eventStopPropagation = (event) => {
5407
+ event.stopPropagation();
5408
+ };
5409
+ var eventPreventStop = (event) => {
5410
+ event.preventDefault();
5411
+ event.stopPropagation();
5412
+ };
5378
5413
 
5379
5414
  // src/components/Label.tsx
5380
5415
  import { memo as memo15 } from "react";
@@ -5745,7 +5780,7 @@ Dropdown2.countries = DropdownComponent.countries;
5745
5780
  var Dropdown_default = Dropdown2;
5746
5781
 
5747
5782
  // src/components/Calendar.tsx
5748
- import { useCallback as useCallback8, useMemo as useMemo5, useState as useState6, memo as memo17, useEffect as useEffect7 } from "react";
5783
+ import { useCallback as useCallback8, useMemo as useMemo5, useState as useState6, memo as memo17, useEffect as useEffect7, useId } from "react";
5749
5784
  import styled9 from "styled-components";
5750
5785
  import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
5751
5786
  var getMonthName = (month, short = false) => {
@@ -5777,8 +5812,18 @@ var getWeekDayName = (day, short = false) => {
5777
5812
  };
5778
5813
  var weekDaysIndex = [1, 2, 3, 4, 5, 6, 0];
5779
5814
  var yearsRange = Array.from({ length: 100 + 1 + 50 }, (_, index) => index + (/* @__PURE__ */ new Date()).getFullYear() - 100);
5815
+ var SelectWrapperComponent = styled9.div.withConfig({
5816
+ shouldForwardProp: (prop) => !["theme"].includes(prop)
5817
+ })`
5818
+ &:has(select:focus) {
5819
+ outline: auto;
5820
+ outline-color: -webkit-focus-ring-color;
5821
+ outline-style: auto;
5822
+ outline-offset: 2px;
5823
+ }
5824
+ `;
5780
5825
  var SelectComponent = styled9.select.withConfig({
5781
- shouldForwardProp: (prop) => !["normalStyle", "hoverStyle"].includes(prop)
5826
+ shouldForwardProp: (prop) => !["theme"].includes(prop)
5782
5827
  })`
5783
5828
  position: absolute;
5784
5829
  top: 50%;
@@ -5788,6 +5833,7 @@ var SelectComponent = styled9.select.withConfig({
5788
5833
  `;
5789
5834
  function Calendar({ value, minDate, maxDate, onChange }) {
5790
5835
  const theme2 = useTheme();
5836
+ const internalYearSelectId = useId();
5791
5837
  const [currentDate, setCurrentDate] = useState6(value ? new Date(value) : void 0);
5792
5838
  const [currentMonth, setCurrentMonth] = useState6(currentDate?.getMonth() ?? (/* @__PURE__ */ new Date()).getMonth());
5793
5839
  const [currentYear, setCurrentYear] = useState6(currentDate?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear());
@@ -5855,11 +5901,20 @@ function Calendar({ value, minDate, maxDate, onChange }) {
5855
5901
  /* @__PURE__ */ jsx16(Button_default.icon, { icon: "chevronLeft", onClick: onClickPreviousMonthButton }),
5856
5902
  /* @__PURE__ */ jsxs11(Div_default.row, { alignItems: "center", gap: 4, children: [
5857
5903
  /* @__PURE__ */ jsx16(Text_default, { fontWeight: 700, children: getMonthName(currentMonth) }),
5858
- /* @__PURE__ */ jsxs11(Div_default.row, { position: "relative", alignItems: "center", gap: 2, children: [
5904
+ /* @__PURE__ */ jsx16(SelectWrapperComponent, { children: /* @__PURE__ */ jsxs11(Div_default.row, { position: "relative", alignItems: "center", gap: 2, children: [
5859
5905
  /* @__PURE__ */ jsx16(Text_default, { fontWeight: 700, children: currentYear }),
5860
5906
  /* @__PURE__ */ jsx16(Icon_default, { name: "chevronDown", size: 12 }),
5861
- /* @__PURE__ */ jsx16(SelectComponent, { theme: theme2, value: currentYear, onChange: onChangeYearSelect, children: yearsRange.map((year) => /* @__PURE__ */ jsx16("option", { value: year, children: year }, year)) })
5862
- ] })
5907
+ /* @__PURE__ */ jsx16(
5908
+ SelectComponent,
5909
+ {
5910
+ theme: theme2,
5911
+ value: currentYear,
5912
+ onChange: onChangeYearSelect,
5913
+ id: internalYearSelectId,
5914
+ children: yearsRange.map((year) => /* @__PURE__ */ jsx16("option", { value: year, children: year }, year))
5915
+ }
5916
+ )
5917
+ ] }) })
5863
5918
  ] }),
5864
5919
  /* @__PURE__ */ jsx16(Button_default.icon, { icon: "chevronRight", onClick: onClickNextMonthButton })
5865
5920
  ] }),
@@ -5983,6 +6038,10 @@ var InputElement = styled10.input.withConfig({
5983
6038
  cursor: not-allowed;
5984
6039
  }
5985
6040
 
6041
+ &:read-only {
6042
+ caret-color: transparent;
6043
+ }
6044
+
5986
6045
  &::-webkit-outer-spin-button,
5987
6046
  &::-webkit-inner-spin-button {
5988
6047
  -webkit-appearance: none;
@@ -6120,7 +6179,7 @@ var InputFieldComponent = forwardRef11(function InputField({
6120
6179
  ...props
6121
6180
  }, ref) {
6122
6181
  const theme2 = useTheme();
6123
- const internalId = useId();
6182
+ const internalId = useId2();
6124
6183
  const { colorTheme } = useBetterHtmlContextInternal();
6125
6184
  const [_, debouncedValue, setDebouncedValue] = useDebounceState(
6126
6185
  props.value?.toString() ?? "",
@@ -6269,7 +6328,7 @@ InputFieldComponent.multiline = forwardRef11(function Multiline({
6269
6328
  ...props
6270
6329
  }, ref) {
6271
6330
  const theme2 = useTheme();
6272
- const internalId = useId();
6331
+ const internalId = useId2();
6273
6332
  const styledComponentStyles = useStyledComponentStyles(props, theme2);
6274
6333
  const dataProps = useComponentPropsWithPrefix(props, "data");
6275
6334
  const ariaProps = useComponentPropsWithPrefix(props, "aria");
@@ -6424,7 +6483,7 @@ InputFieldComponent.search = forwardRef11(function Search({ value, onChangeValue
6424
6483
  });
6425
6484
  InputFieldComponent.phoneNumber = forwardRef11(function PhoneNumber({ label, value, onChangeValue, labelColor, id, ...props }, ref) {
6426
6485
  const theme2 = useTheme();
6427
- const internalId = useId();
6486
+ const internalId = useId2();
6428
6487
  const [dropdownValue, setDropdownValue] = useState7();
6429
6488
  const [inputFieldValue, setInputFieldValue] = useState7(value?.toString() ?? "");
6430
6489
  const renderOption = useCallback9(
@@ -6639,6 +6698,7 @@ InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate
6639
6698
  width: buttonWidth,
6640
6699
  height: `calc(100% - ${16 + theme2.styles.gap / 2}px)`,
6641
6700
  overflowY: "auto",
6701
+ tabIndex: -1,
6642
6702
  children: hours.map((hour) => {
6643
6703
  const isSelected = hour.toString() === valueHour;
6644
6704
  return /* @__PURE__ */ jsx17(
@@ -6672,6 +6732,7 @@ InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate
6672
6732
  width: buttonWidth,
6673
6733
  height: `calc(100% - ${16 + theme2.styles.gap / 2}px)`,
6674
6734
  overflowY: "auto",
6735
+ tabIndex: -1,
6675
6736
  children: minutes.map((minute) => {
6676
6737
  const isSelected = minute.toString() === valueMinute;
6677
6738
  return /* @__PURE__ */ jsx17(
@@ -6760,46 +6821,66 @@ InputFieldComponent.time = forwardRef11(function Time({ ...props }, ref) {
6760
6821
  userSelect: "none",
6761
6822
  ...insideInputFieldComponentProps,
6762
6823
  children: /* @__PURE__ */ jsxs12(Div_default.row, { height: "100%", children: [
6763
- /* @__PURE__ */ jsx17(Div_default, { className: "react-better-html-no-scrollbar", width: buttonWidth, height: "100%", overflowY: "auto", children: hours.map((hour) => {
6764
- const isSelected = hour.toString() === valueHour;
6765
- return /* @__PURE__ */ jsx17(
6766
- Div_default.row,
6767
- {
6768
- alignItems: "center",
6769
- justifyContent: "center",
6770
- color: isSelected ? theme2.colors.base : theme2.colors.textPrimary,
6771
- backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
6772
- filterHover: "brightness(0.9)",
6773
- cursor: "pointer",
6774
- padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
6775
- value: hour,
6776
- onClickWithValue: onClickHour,
6777
- ref: isSelected ? selectedHourRef : void 0,
6778
- children: /* @__PURE__ */ jsx17(Text_default, { textAlign: "center", children: hour.toString().padStart(2, "0") })
6779
- },
6780
- hour
6781
- );
6782
- }) }),
6783
- /* @__PURE__ */ jsx17(Div_default, { className: "react-better-html-no-scrollbar", width: buttonWidth, height: "100%", overflowY: "auto", children: minutes.map((minute) => {
6784
- const isSelected = minute.toString() === valueMinute;
6785
- return /* @__PURE__ */ jsx17(
6786
- Div_default.row,
6787
- {
6788
- alignItems: "center",
6789
- justifyContent: "center",
6790
- color: isSelected ? theme2.colors.base : theme2.colors.textPrimary,
6791
- backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
6792
- filterHover: "brightness(0.9)",
6793
- cursor: "pointer",
6794
- padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
6795
- value: minute,
6796
- onClickWithValue: onClickMinute,
6797
- ref: isSelected ? selectedMinuteRef : void 0,
6798
- children: /* @__PURE__ */ jsx17(Text_default, { textAlign: "center", children: minute.toString().padStart(2, "0") })
6799
- },
6800
- minute
6801
- );
6802
- }) })
6824
+ /* @__PURE__ */ jsx17(
6825
+ Div_default,
6826
+ {
6827
+ className: "react-better-html-no-scrollbar",
6828
+ width: buttonWidth,
6829
+ height: "100%",
6830
+ overflowY: "auto",
6831
+ tabIndex: -1,
6832
+ children: hours.map((hour) => {
6833
+ const isSelected = hour.toString() === valueHour;
6834
+ return /* @__PURE__ */ jsx17(
6835
+ Div_default.row,
6836
+ {
6837
+ alignItems: "center",
6838
+ justifyContent: "center",
6839
+ color: isSelected ? theme2.colors.base : theme2.colors.textPrimary,
6840
+ backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
6841
+ filterHover: "brightness(0.9)",
6842
+ cursor: "pointer",
6843
+ padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
6844
+ value: hour,
6845
+ onClickWithValue: onClickHour,
6846
+ ref: isSelected ? selectedHourRef : void 0,
6847
+ children: /* @__PURE__ */ jsx17(Text_default, { textAlign: "center", children: hour.toString().padStart(2, "0") })
6848
+ },
6849
+ hour
6850
+ );
6851
+ })
6852
+ }
6853
+ ),
6854
+ /* @__PURE__ */ jsx17(
6855
+ Div_default,
6856
+ {
6857
+ className: "react-better-html-no-scrollbar",
6858
+ width: buttonWidth,
6859
+ height: "100%",
6860
+ overflowY: "auto",
6861
+ tabIndex: -1,
6862
+ children: minutes.map((minute) => {
6863
+ const isSelected = minute.toString() === valueMinute;
6864
+ return /* @__PURE__ */ jsx17(
6865
+ Div_default.row,
6866
+ {
6867
+ alignItems: "center",
6868
+ justifyContent: "center",
6869
+ color: isSelected ? theme2.colors.base : theme2.colors.textPrimary,
6870
+ backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
6871
+ filterHover: "brightness(0.9)",
6872
+ cursor: "pointer",
6873
+ padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
6874
+ value: minute,
6875
+ onClickWithValue: onClickMinute,
6876
+ ref: isSelected ? selectedMinuteRef : void 0,
6877
+ children: /* @__PURE__ */ jsx17(Text_default, { textAlign: "center", children: minute.toString().padStart(2, "0") })
6878
+ },
6879
+ minute
6880
+ );
6881
+ })
6882
+ }
6883
+ )
6803
6884
  ] })
6804
6885
  }
6805
6886
  ) : void 0,
@@ -6862,7 +6943,7 @@ InputField2.color = InputFieldComponent.color;
6862
6943
  var InputField_default = InputField2;
6863
6944
 
6864
6945
  // src/components/ToggleInput.tsx
6865
- import { forwardRef as forwardRef12, useCallback as useCallback10, useId as useId2, useState as useState8 } from "react";
6946
+ import { forwardRef as forwardRef12, useCallback as useCallback10, useId as useId3, useState as useState8 } from "react";
6866
6947
  import styled11 from "styled-components";
6867
6948
  import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
6868
6949
  var componentSize = 26;
@@ -6973,7 +7054,7 @@ var ToggleInputComponent = forwardRef12(function ToggleInput({
6973
7054
  ...props
6974
7055
  }, ref) {
6975
7056
  const theme2 = useTheme();
6976
- const internalId = useId2();
7057
+ const internalId = useId3();
6977
7058
  const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
6978
7059
  const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
6979
7060
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -7090,7 +7171,7 @@ var ToggleInput_default = {
7090
7171
  ...props
7091
7172
  }, ref) {
7092
7173
  const theme2 = useTheme();
7093
- const internalId = useId2();
7174
+ const internalId = useId3();
7094
7175
  const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
7095
7176
  const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
7096
7177
  const dataProps = useComponentPropsWithPrefix(props, "data");
@@ -8992,6 +9073,9 @@ export {
8992
9073
  darkenColor,
8993
9074
  defaultAlertsPluginOptions,
8994
9075
  desaturateColor,
9076
+ eventPreventDefault,
9077
+ eventPreventStop,
9078
+ eventStopPropagation,
8995
9079
  formatPhoneNumber,
8996
9080
  generateRandomString,
8997
9081
  getBrowser,