@lets-events/react 11.0.2 → 11.0.3

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @lets-events/react@11.0.2 build
2
+ > @lets-events/react@11.0.3 build
3
3
  > tsup src/index.tsx --format esm,cjs --dts --external react
4
4
 
5
5
  CLI Building entry: src/index.tsx
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist\index.mjs 275.12 KB
12
- ESM ⚡️ Build success in 224ms
13
- CJS dist\index.js 283.47 KB
14
- CJS ⚡️ Build success in 225ms
11
+ CJS dist\index.js 283.68 KB
12
+ CJS ⚡️ Build success in 226ms
13
+ ESM dist\index.mjs 275.33 KB
14
+ ESM ⚡️ Build success in 226ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 3530ms
17
- DTS dist\index.d.mts 338.30 KB
18
- DTS dist\index.d.ts 338.30 KB
16
+ DTS ⚡️ Build success in 3664ms
17
+ DTS dist\index.d.mts 338.36 KB
18
+ DTS dist\index.d.ts 338.36 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lets-events/react
2
2
 
3
+ ## 11.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - fix textfield ref
8
+
3
9
  ## 11.0.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1926,7 +1926,7 @@ type AvatarProps = ComponentProps<typeof AvatarStyled> & {
1926
1926
  };
1927
1927
  declare function Avatar({ asChild, ...props }: AvatarProps): react_jsx_runtime.JSX.Element;
1928
1928
 
1929
- declare const TextFieldStyled: _stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<TextField$1.RootProps & react.RefAttributes<HTMLInputElement>>, {
1929
+ declare const TextFieldStyled: _stitches_react_types_styled_component.StyledComponent<react__default.ForwardRefExoticComponent<TextField$1.RootProps & react__default.RefAttributes<HTMLInputElement>>, {
1930
1930
  color?: "default" | "error" | undefined;
1931
1931
  typography?: "tooltip" | "displayLarge" | "displayMedium" | "displaySmall" | "headline1" | "headline2" | "headline3" | "headline4" | "headline5" | "headline6" | "headline7" | "headline8" | "bodyXL" | "bodyL" | "bodyM" | "bodyS" | "bodyXS" | "bodyXXS" | "badgeLarge" | "badgeMedium" | "badgeSmall" | "badgeExtraSmall" | "popoversRegular" | "captionLarge" | "captionMedium" | "captionSmall" | "buttonLarge" | "buttonMedium" | "buttonSmall" | "buttonExtraSmall" | "labelLarge" | "labelMedium" | "labelSmall" | "labelExtraSmall" | undefined;
1932
1932
  fontWeight?: "bold" | "medium" | "regular" | "semibold" | undefined;
@@ -2302,7 +2302,7 @@ declare const TextFieldStyled: _stitches_react_types_styled_component.StyledComp
2302
2302
  transition: "transitions";
2303
2303
  zIndex: "zIndices";
2304
2304
  }, {}>>;
2305
- declare const TextFieldSlotStyled: _stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<TextField$1.SlotProps & react.RefAttributes<HTMLDivElement>>, {
2305
+ declare const TextFieldSlotStyled: _stitches_react_types_styled_component.StyledComponent<react__default.ForwardRefExoticComponent<TextField$1.SlotProps & react__default.RefAttributes<HTMLDivElement>>, {
2306
2306
  typography?: "tooltip" | "displayLarge" | "displayMedium" | "displaySmall" | "headline1" | "headline2" | "headline3" | "headline4" | "headline5" | "headline6" | "headline7" | "headline8" | "bodyXL" | "bodyL" | "bodyM" | "bodyS" | "bodyXS" | "bodyXXS" | "badgeLarge" | "badgeMedium" | "badgeSmall" | "badgeExtraSmall" | "popoversRegular" | "captionLarge" | "captionMedium" | "captionSmall" | "buttonLarge" | "buttonMedium" | "buttonSmall" | "buttonExtraSmall" | "labelLarge" | "labelMedium" | "labelSmall" | "labelExtraSmall" | undefined;
2307
2307
  fontWeight?: "bold" | "medium" | "regular" | "semibold" | undefined;
2308
2308
  textAlign?: "left" | "right" | "center" | undefined;
@@ -2679,27 +2679,27 @@ declare const TextFieldSlotStyled: _stitches_react_types_styled_component.Styled
2679
2679
  type TextFieldProps = ComponentProps<typeof TextFieldStyled> & {
2680
2680
  addon?: ReactNode;
2681
2681
  placeholder?: string;
2682
- children?: React.ReactNode;
2682
+ children?: react__default.ReactNode;
2683
2683
  isValid?: boolean;
2684
2684
  name?: string;
2685
2685
  typography?: string;
2686
- fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold';
2687
- textAlign?: 'left' | 'right' | 'center';
2686
+ fontWeight?: "regular" | "medium" | "semibold" | "bold";
2687
+ textAlign?: "left" | "right" | "center";
2688
2688
  mask?: MaskOptions;
2689
2689
  };
2690
- type TextFieldSlotProps = Omit<ComponentProps<typeof TextFieldStyled>, 'color'> & {
2690
+ type TextFieldSlotProps = Omit<ComponentProps<typeof TextFieldStyled>, "color"> & {
2691
2691
  placeholder?: string;
2692
- children?: React.ReactNode;
2693
- position?: 'flex-start' | 'flex-end';
2692
+ children?: react__default.ReactNode;
2693
+ position?: "flex-start" | "flex-end";
2694
2694
  onClick?: () => void;
2695
- color?: 'error' | 'success' | undefined;
2695
+ color?: "error" | "success" | undefined;
2696
2696
  typography?: string;
2697
- fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold';
2698
- textAlign?: 'left' | 'right' | 'center';
2697
+ fontWeight?: "regular" | "medium" | "semibold" | "bold";
2698
+ textAlign?: "left" | "right" | "center";
2699
2699
  };
2700
2700
  declare const maskFormat: typeof format;
2701
2701
  declare const maskUnformat: typeof unformat;
2702
- declare function TextField({ children, isValid, name, color, typography, fontWeight, addon, textAlign, mask, ...props }: TextFieldProps): react_jsx_runtime.JSX.Element;
2702
+ declare const TextField: ({ children, isValid, name, color, typography, fontWeight, addon, textAlign, mask, ref, ...props }: TextFieldProps) => react_jsx_runtime.JSX.Element;
2703
2703
  declare function TextFieldSlot({ children, position, onClick, typography, fontWeight, textAlign, ...props }: TextFieldSlotProps): react_jsx_runtime.JSX.Element;
2704
2704
 
2705
2705
  declare const RadioGroupStyled: _stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<RadioGroup$1.RootProps & react.RefAttributes<HTMLDivElement>>, {
package/dist/index.d.ts CHANGED
@@ -1926,7 +1926,7 @@ type AvatarProps = ComponentProps<typeof AvatarStyled> & {
1926
1926
  };
1927
1927
  declare function Avatar({ asChild, ...props }: AvatarProps): react_jsx_runtime.JSX.Element;
1928
1928
 
1929
- declare const TextFieldStyled: _stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<TextField$1.RootProps & react.RefAttributes<HTMLInputElement>>, {
1929
+ declare const TextFieldStyled: _stitches_react_types_styled_component.StyledComponent<react__default.ForwardRefExoticComponent<TextField$1.RootProps & react__default.RefAttributes<HTMLInputElement>>, {
1930
1930
  color?: "default" | "error" | undefined;
1931
1931
  typography?: "tooltip" | "displayLarge" | "displayMedium" | "displaySmall" | "headline1" | "headline2" | "headline3" | "headline4" | "headline5" | "headline6" | "headline7" | "headline8" | "bodyXL" | "bodyL" | "bodyM" | "bodyS" | "bodyXS" | "bodyXXS" | "badgeLarge" | "badgeMedium" | "badgeSmall" | "badgeExtraSmall" | "popoversRegular" | "captionLarge" | "captionMedium" | "captionSmall" | "buttonLarge" | "buttonMedium" | "buttonSmall" | "buttonExtraSmall" | "labelLarge" | "labelMedium" | "labelSmall" | "labelExtraSmall" | undefined;
1932
1932
  fontWeight?: "bold" | "medium" | "regular" | "semibold" | undefined;
@@ -2302,7 +2302,7 @@ declare const TextFieldStyled: _stitches_react_types_styled_component.StyledComp
2302
2302
  transition: "transitions";
2303
2303
  zIndex: "zIndices";
2304
2304
  }, {}>>;
2305
- declare const TextFieldSlotStyled: _stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<TextField$1.SlotProps & react.RefAttributes<HTMLDivElement>>, {
2305
+ declare const TextFieldSlotStyled: _stitches_react_types_styled_component.StyledComponent<react__default.ForwardRefExoticComponent<TextField$1.SlotProps & react__default.RefAttributes<HTMLDivElement>>, {
2306
2306
  typography?: "tooltip" | "displayLarge" | "displayMedium" | "displaySmall" | "headline1" | "headline2" | "headline3" | "headline4" | "headline5" | "headline6" | "headline7" | "headline8" | "bodyXL" | "bodyL" | "bodyM" | "bodyS" | "bodyXS" | "bodyXXS" | "badgeLarge" | "badgeMedium" | "badgeSmall" | "badgeExtraSmall" | "popoversRegular" | "captionLarge" | "captionMedium" | "captionSmall" | "buttonLarge" | "buttonMedium" | "buttonSmall" | "buttonExtraSmall" | "labelLarge" | "labelMedium" | "labelSmall" | "labelExtraSmall" | undefined;
2307
2307
  fontWeight?: "bold" | "medium" | "regular" | "semibold" | undefined;
2308
2308
  textAlign?: "left" | "right" | "center" | undefined;
@@ -2679,27 +2679,27 @@ declare const TextFieldSlotStyled: _stitches_react_types_styled_component.Styled
2679
2679
  type TextFieldProps = ComponentProps<typeof TextFieldStyled> & {
2680
2680
  addon?: ReactNode;
2681
2681
  placeholder?: string;
2682
- children?: React.ReactNode;
2682
+ children?: react__default.ReactNode;
2683
2683
  isValid?: boolean;
2684
2684
  name?: string;
2685
2685
  typography?: string;
2686
- fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold';
2687
- textAlign?: 'left' | 'right' | 'center';
2686
+ fontWeight?: "regular" | "medium" | "semibold" | "bold";
2687
+ textAlign?: "left" | "right" | "center";
2688
2688
  mask?: MaskOptions;
2689
2689
  };
2690
- type TextFieldSlotProps = Omit<ComponentProps<typeof TextFieldStyled>, 'color'> & {
2690
+ type TextFieldSlotProps = Omit<ComponentProps<typeof TextFieldStyled>, "color"> & {
2691
2691
  placeholder?: string;
2692
- children?: React.ReactNode;
2693
- position?: 'flex-start' | 'flex-end';
2692
+ children?: react__default.ReactNode;
2693
+ position?: "flex-start" | "flex-end";
2694
2694
  onClick?: () => void;
2695
- color?: 'error' | 'success' | undefined;
2695
+ color?: "error" | "success" | undefined;
2696
2696
  typography?: string;
2697
- fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold';
2698
- textAlign?: 'left' | 'right' | 'center';
2697
+ fontWeight?: "regular" | "medium" | "semibold" | "bold";
2698
+ textAlign?: "left" | "right" | "center";
2699
2699
  };
2700
2700
  declare const maskFormat: typeof format;
2701
2701
  declare const maskUnformat: typeof unformat;
2702
- declare function TextField({ children, isValid, name, color, typography, fontWeight, addon, textAlign, mask, ...props }: TextFieldProps): react_jsx_runtime.JSX.Element;
2702
+ declare const TextField: ({ children, isValid, name, color, typography, fontWeight, addon, textAlign, mask, ref, ...props }: TextFieldProps) => react_jsx_runtime.JSX.Element;
2703
2703
  declare function TextFieldSlot({ children, position, onClick, typography, fontWeight, textAlign, ...props }: TextFieldSlotProps): react_jsx_runtime.JSX.Element;
2704
2704
 
2705
2705
  declare const RadioGroupStyled: _stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<RadioGroup$1.RootProps & react.RefAttributes<HTMLDivElement>>, {
package/dist/index.js CHANGED
@@ -2746,7 +2746,7 @@ var InputAddon = styled(TextStyle, {
2746
2746
  });
2747
2747
  var maskFormat = import_mask.format;
2748
2748
  var maskUnformat = import_mask.unformat;
2749
- function TextField(_a) {
2749
+ var TextField = (_a) => {
2750
2750
  var _b = _a, {
2751
2751
  children,
2752
2752
  isValid: isValid2,
@@ -2756,7 +2756,8 @@ function TextField(_a) {
2756
2756
  fontWeight,
2757
2757
  addon,
2758
2758
  textAlign = "left",
2759
- mask
2759
+ mask,
2760
+ ref
2760
2761
  } = _b, props = __objRest(_b, [
2761
2762
  "children",
2762
2763
  "isValid",
@@ -2766,7 +2767,8 @@ function TextField(_a) {
2766
2767
  "fontWeight",
2767
2768
  "addon",
2768
2769
  "textAlign",
2769
- "mask"
2770
+ "mask",
2771
+ "ref"
2770
2772
  ]);
2771
2773
  const maskRef = mask ? (0, import_mask.useMask)(mask) : void 0;
2772
2774
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Flex2, { gap: "0", css: { width: "100%" }, children: [
@@ -2780,7 +2782,14 @@ function TextField(_a) {
2780
2782
  typography,
2781
2783
  fontWeight,
2782
2784
  textAlign,
2783
- ref: maskRef
2785
+ ref: (r) => {
2786
+ if (!r) return;
2787
+ if (maskRef) maskRef.current = r;
2788
+ if (ref) {
2789
+ if (typeof ref === "function") ref(r);
2790
+ else ref.current = r;
2791
+ }
2792
+ }
2784
2793
  }, props), {
2785
2794
  style: addon ? { borderTopLeftRadius: "0px", borderBottomLeftRadius: "0px" } : void 0,
2786
2795
  children: [
@@ -2801,7 +2810,7 @@ function TextField(_a) {
2801
2810
  })
2802
2811
  )
2803
2812
  ] });
2804
- }
2813
+ };
2805
2814
  function TextFieldSlot(_a) {
2806
2815
  var _b = _a, {
2807
2816
  children,
package/dist/index.mjs CHANGED
@@ -2660,7 +2660,7 @@ var InputAddon = styled(TextStyle, {
2660
2660
  });
2661
2661
  var maskFormat = format;
2662
2662
  var maskUnformat = unformat;
2663
- function TextField(_a) {
2663
+ var TextField = (_a) => {
2664
2664
  var _b = _a, {
2665
2665
  children,
2666
2666
  isValid: isValid2,
@@ -2670,7 +2670,8 @@ function TextField(_a) {
2670
2670
  fontWeight,
2671
2671
  addon,
2672
2672
  textAlign = "left",
2673
- mask
2673
+ mask,
2674
+ ref
2674
2675
  } = _b, props = __objRest(_b, [
2675
2676
  "children",
2676
2677
  "isValid",
@@ -2680,7 +2681,8 @@ function TextField(_a) {
2680
2681
  "fontWeight",
2681
2682
  "addon",
2682
2683
  "textAlign",
2683
- "mask"
2684
+ "mask",
2685
+ "ref"
2684
2686
  ]);
2685
2687
  const maskRef = mask ? useMask(mask) : void 0;
2686
2688
  return /* @__PURE__ */ jsxs(Flex2, { gap: "0", css: { width: "100%" }, children: [
@@ -2694,7 +2696,14 @@ function TextField(_a) {
2694
2696
  typography,
2695
2697
  fontWeight,
2696
2698
  textAlign,
2697
- ref: maskRef
2699
+ ref: (r) => {
2700
+ if (!r) return;
2701
+ if (maskRef) maskRef.current = r;
2702
+ if (ref) {
2703
+ if (typeof ref === "function") ref(r);
2704
+ else ref.current = r;
2705
+ }
2706
+ }
2698
2707
  }, props), {
2699
2708
  style: addon ? { borderTopLeftRadius: "0px", borderBottomLeftRadius: "0px" } : void 0,
2700
2709
  children: [
@@ -2715,7 +2724,7 @@ function TextField(_a) {
2715
2724
  })
2716
2725
  )
2717
2726
  ] });
2718
- }
2727
+ };
2719
2728
  function TextFieldSlot(_a) {
2720
2729
  var _b = _a, {
2721
2730
  children,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lets-events/react",
3
- "version": "11.0.2",
3
+ "version": "11.0.3",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,89 +1,89 @@
1
- import { ComponentProps, ReactNode } from 'react'
2
- import { styled } from '../styles'
3
- import { TextField as TextFieldRadix } from '@radix-ui/themes'
4
- import Icon from './Icon'
5
- import { typographyValues } from '../types/typographyValues'
6
- import { TextStyle } from './Text'
7
- import { Flex } from './Flex'
8
- import { format, MaskOptions, useMask, unformat } from '@react-input/mask'
1
+ import React, { ComponentProps, ReactNode } from "react";
2
+ import { styled } from "../styles";
3
+ import { TextField as TextFieldRadix } from "@radix-ui/themes";
4
+ import Icon from "./Icon";
5
+ import { typographyValues } from "../types/typographyValues";
6
+ import { TextStyle } from "./Text";
7
+ import { Flex } from "./Flex";
8
+ import { format, MaskOptions, useMask, unformat } from "@react-input/mask";
9
9
 
10
10
  export const TextFieldStyled = styled(TextFieldRadix.Root, {
11
- height: '$40',
12
- fontFamily: '$default',
13
- borderRadius: '$sm',
14
- boxSizing: 'border-box',
15
- color: '$dark500',
16
- border: '1px solid $dark300',
17
- position: 'relative',
18
- display: 'flex',
19
- width: '100%',
20
- alignItems: 'center',
21
- padding: '0 $14',
22
- gap: '$14',
11
+ height: "$40",
12
+ fontFamily: "$default",
13
+ borderRadius: "$sm",
14
+ boxSizing: "border-box",
15
+ color: "$dark500",
16
+ border: "1px solid $dark300",
17
+ position: "relative",
18
+ display: "flex",
19
+ width: "100%",
20
+ alignItems: "center",
21
+ padding: "0 $14",
22
+ gap: "$14",
23
23
  input: {
24
24
  order: 1,
25
- outline: 'none',
26
- border: 'none',
25
+ outline: "none",
26
+ border: "none",
27
27
  margin: 0,
28
- width: '100%',
29
- font: 'inherit',
30
- textAlign: 'left',
28
+ width: "100%",
29
+ font: "inherit",
30
+ textAlign: "left",
31
31
  },
32
32
 
33
- '&:has(input:focus)': {
34
- border: '2px solid $brand300',
33
+ "&:has(input:focus)": {
34
+ border: "2px solid $brand300",
35
35
  },
36
- '&:has(input:disabled)': {
37
- backgroundColor: '$dark100',
38
- color: '$dark400',
39
- border: '1px solid $dark200',
40
- cursor: 'not-allowed',
36
+ "&:has(input:disabled)": {
37
+ backgroundColor: "$dark100",
38
+ color: "$dark400",
39
+ border: "1px solid $dark200",
40
+ cursor: "not-allowed",
41
41
  },
42
42
 
43
43
  variants: {
44
44
  color: {
45
45
  default: {
46
- color: '$dark400',
47
- border: '1px solid $dark200',
48
- '&:has(input:focus)': {
49
- border: '2px solid $brand300',
46
+ color: "$dark400",
47
+ border: "1px solid $dark200",
48
+ "&:has(input:focus)": {
49
+ border: "2px solid $brand300",
50
50
  },
51
- '&:has(input:disabled)': {
52
- backgroundColor: '$dark100',
53
- color: '$dark400',
54
- border: '1px solid $dark200',
55
- cursor: 'not-allowed',
51
+ "&:has(input:disabled)": {
52
+ backgroundColor: "$dark100",
53
+ color: "$dark400",
54
+ border: "1px solid $dark200",
55
+ cursor: "not-allowed",
56
56
  },
57
57
  },
58
58
  error: {
59
- border: '1px solid $error400',
60
- color: '$error400',
61
- 'input::placeholder': {
62
- color: '$error400',
59
+ border: "1px solid $error400",
60
+ color: "$error400",
61
+ "input::placeholder": {
62
+ color: "$error400",
63
63
  },
64
- '&:has(input:focus)': {
65
- border: '2px solid $error400',
64
+ "&:has(input:focus)": {
65
+ border: "2px solid $error400",
66
66
  },
67
- '&:has(input:disabled)': {
68
- backgroundColor: '$error50',
69
- color: '$error300',
70
- border: '1px solid $error100',
71
- cursor: 'not-allowed',
67
+ "&:has(input:disabled)": {
68
+ backgroundColor: "$error50",
69
+ color: "$error300",
70
+ border: "1px solid $error100",
71
+ cursor: "not-allowed",
72
72
  },
73
73
  },
74
74
  },
75
75
 
76
76
  typography: typographyValues,
77
77
  fontWeight: {
78
- regular: { fontWeight: '$regular' },
79
- medium: { fontWeight: '$medium' },
80
- semibold: { fontWeight: '$semibold' },
81
- bold: { fontWeight: '$bold' },
78
+ regular: { fontWeight: "$regular" },
79
+ medium: { fontWeight: "$medium" },
80
+ semibold: { fontWeight: "$semibold" },
81
+ bold: { fontWeight: "$bold" },
82
82
  },
83
83
  textAlign: {
84
- left: { textAlign: 'left' },
85
- center: { textAlign: 'center' },
86
- right: { textAlign: 'right' },
84
+ left: { textAlign: "left" },
85
+ center: { textAlign: "center" },
86
+ right: { textAlign: "right" },
87
87
  },
88
88
  isValid: {
89
89
  true: {},
@@ -95,114 +95,114 @@ export const TextFieldStyled = styled(TextFieldRadix.Root, {
95
95
  {
96
96
  isValid: false,
97
97
  css: {
98
- border: '1px solid $error400',
99
- color: '$error400',
100
- backgroundColor: '$error50',
98
+ border: "1px solid $error400",
99
+ color: "$error400",
100
+ backgroundColor: "$error50",
101
101
  input: {
102
- '&::placeholder': {
103
- color: '$error400',
102
+ "&::placeholder": {
103
+ color: "$error400",
104
104
  },
105
- backgroundColor: '$error50',
105
+ backgroundColor: "$error50",
106
106
  },
107
- '&:has(input:focus)': {
108
- border: '2px solid $error400',
107
+ "&:has(input:focus)": {
108
+ border: "2px solid $error400",
109
109
  },
110
- '&:has(input:disabled)': {
110
+ "&:has(input:disabled)": {
111
111
  input: {
112
- backgroundColor: '$error50',
112
+ backgroundColor: "$error50",
113
113
  },
114
- backgroundColor: '$error50',
115
- color: '$error300',
116
- border: '1px solid $error100',
117
- cursor: 'not-allowed',
114
+ backgroundColor: "$error50",
115
+ color: "$error300",
116
+ border: "1px solid $error100",
117
+ cursor: "not-allowed",
118
118
  },
119
119
  },
120
120
  },
121
121
  {
122
122
  isValid: true,
123
123
  css: {
124
- '&:has(input:focus)': {
125
- border: '2px solid $success500',
124
+ "&:has(input:focus)": {
125
+ border: "2px solid $success500",
126
126
  },
127
- '&:has(input:disabled)': {
128
- backgroundColor: '$dark100',
129
- color: '$dark400',
130
- border: '1px solid $dark200',
131
- cursor: 'not-allowed',
127
+ "&:has(input:disabled)": {
128
+ backgroundColor: "$dark100",
129
+ color: "$dark400",
130
+ border: "1px solid $dark200",
131
+ cursor: "not-allowed",
132
132
  },
133
133
  },
134
134
  },
135
135
  ],
136
- })
136
+ });
137
137
 
138
138
  export const TextFieldSlotStyled = styled(TextFieldRadix.Slot, {
139
- display: 'flex',
140
- alignItems: 'center',
141
- justifyContent: 'center',
139
+ display: "flex",
140
+ alignItems: "center",
141
+ justifyContent: "center",
142
142
  padding: 4,
143
143
 
144
144
  variants: {
145
145
  typography: typographyValues,
146
146
  fontWeight: {
147
- regular: { fontWeight: '$regular' },
148
- medium: { fontWeight: '$medium' },
149
- semibold: { fontWeight: '$semibold' },
150
- bold: { fontWeight: '$bold' },
147
+ regular: { fontWeight: "$regular" },
148
+ medium: { fontWeight: "$medium" },
149
+ semibold: { fontWeight: "$semibold" },
150
+ bold: { fontWeight: "$bold" },
151
151
  },
152
152
  textAlign: {
153
- left: { textAlign: 'left' },
154
- right: { textAlign: 'right' },
155
- center: { textAlign: 'center' },
153
+ left: { textAlign: "left" },
154
+ right: { textAlign: "right" },
155
+ center: { textAlign: "center" },
156
156
  },
157
157
  },
158
- })
158
+ });
159
159
 
160
160
  export type TextFieldProps = ComponentProps<typeof TextFieldStyled> & {
161
- addon?: ReactNode
162
- placeholder?: string
163
- children?: React.ReactNode
164
- isValid?: boolean
165
- name?: string
166
- typography?: string
167
- fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
168
- textAlign?: 'left' | 'right' | 'center'
169
- mask?: MaskOptions
170
- }
161
+ addon?: ReactNode;
162
+ placeholder?: string;
163
+ children?: React.ReactNode;
164
+ isValid?: boolean;
165
+ name?: string;
166
+ typography?: string;
167
+ fontWeight?: "regular" | "medium" | "semibold" | "bold";
168
+ textAlign?: "left" | "right" | "center";
169
+ mask?: MaskOptions;
170
+ };
171
171
 
172
172
  export type TextFieldSlotProps = Omit<
173
173
  ComponentProps<typeof TextFieldStyled>,
174
- 'color'
174
+ "color"
175
175
  > & {
176
- placeholder?: string
177
- children?: React.ReactNode
178
- position?: 'flex-start' | 'flex-end'
179
- onClick?: () => void
180
- color?: 'error' | 'success' | undefined
181
- typography?: string
182
- fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
183
- textAlign?: 'left' | 'right' | 'center'
184
- }
176
+ placeholder?: string;
177
+ children?: React.ReactNode;
178
+ position?: "flex-start" | "flex-end";
179
+ onClick?: () => void;
180
+ color?: "error" | "success" | undefined;
181
+ typography?: string;
182
+ fontWeight?: "regular" | "medium" | "semibold" | "bold";
183
+ textAlign?: "left" | "right" | "center";
184
+ };
185
185
 
186
186
  const InputAddon = styled(TextStyle, {
187
- boxSizing: 'border-box',
188
- border: '1px solid $dark300',
189
- height: '$40',
190
- padding: '0 $12',
191
- margin: '0 auto',
187
+ boxSizing: "border-box",
188
+ border: "1px solid $dark300",
189
+ height: "$40",
190
+ padding: "0 $12",
191
+ margin: "0 auto",
192
192
 
193
- color: '$dark600',
194
- whiteSpace: 'nowrap',
195
- borderRadius: '$sm 0px 0px $sm',
196
- borderRightWidth: '0px',
197
- display: 'flex',
198
- flexWrap: 'nowrap',
199
- alignItems: 'center',
193
+ color: "$dark600",
194
+ whiteSpace: "nowrap",
195
+ borderRadius: "$sm 0px 0px $sm",
196
+ borderRightWidth: "0px",
197
+ display: "flex",
198
+ flexWrap: "nowrap",
199
+ alignItems: "center",
200
200
  lineHeight: 1,
201
- })
202
- export const maskFormat = format
203
- export const maskUnformat = unformat
201
+ });
202
+ export const maskFormat = format;
203
+ export const maskUnformat = unformat;
204
204
 
205
- export function TextField({
205
+ export const TextField = ({
206
206
  children,
207
207
  isValid,
208
208
  name,
@@ -210,14 +210,15 @@ export function TextField({
210
210
  typography,
211
211
  fontWeight,
212
212
  addon,
213
- textAlign = 'left',
213
+ textAlign = "left",
214
214
  mask,
215
+ ref,
215
216
  ...props
216
- }: TextFieldProps) {
217
- const maskRef = mask ? useMask(mask) : undefined
217
+ }: TextFieldProps) => {
218
+ const maskRef = mask ? useMask(mask) : undefined;
218
219
 
219
220
  return (
220
- <Flex gap={'0'} css={{ width: '100%' }}>
221
+ <Flex gap={"0"} css={{ width: "100%" }}>
221
222
  {!!addon && <InputAddon typography="labelSmall">{addon}</InputAddon>}
222
223
 
223
224
  <TextFieldStyled
@@ -227,11 +228,18 @@ export function TextField({
227
228
  typography={typography}
228
229
  fontWeight={fontWeight}
229
230
  textAlign={textAlign}
230
- ref={maskRef}
231
+ ref={(r) => {
232
+ if (!r) return;
233
+ if (maskRef) maskRef.current = r;
234
+ if (ref) {
235
+ if (typeof ref === "function") ref(r);
236
+ else ref.current = r;
237
+ }
238
+ }}
231
239
  {...props}
232
240
  style={
233
241
  addon
234
- ? { borderTopLeftRadius: '0px', borderBottomLeftRadius: '0px' }
242
+ ? { borderTopLeftRadius: "0px", borderBottomLeftRadius: "0px" }
235
243
  : undefined
236
244
  }
237
245
  >
@@ -240,7 +248,7 @@ export function TextField({
240
248
  <TextFieldSlot
241
249
  position="flex-end"
242
250
  name={name}
243
- color={color as TextFieldSlotProps['color']}
251
+ color={color as TextFieldSlotProps["color"]}
244
252
  typography={typography}
245
253
  fontWeight={fontWeight}
246
254
  textAlign={textAlign}
@@ -250,16 +258,16 @@ export function TextField({
250
258
  )}
251
259
  </TextFieldStyled>
252
260
  </Flex>
253
- )
254
- }
261
+ );
262
+ };
255
263
 
256
264
  export function TextFieldSlot({
257
265
  children,
258
- position = 'flex-start',
266
+ position = "flex-start",
259
267
  onClick,
260
- typography = 'bodyXS',
261
- fontWeight = 'regular',
262
- textAlign = 'right',
268
+ typography = "bodyXS",
269
+ fontWeight = "regular",
270
+ textAlign = "right",
263
271
  ...props
264
272
  }: TextFieldSlotProps) {
265
273
  const sharedStyles = {
@@ -268,17 +276,17 @@ export function TextFieldSlot({
268
276
  textAlign,
269
277
  ...props,
270
278
  color: undefined,
271
- }
279
+ };
272
280
 
273
281
  return onClick ? (
274
282
  <TextFieldSlotStyled
275
283
  {...sharedStyles}
276
284
  style={{
277
- float: position === 'flex-start' ? 'left' : 'right',
278
- order: position === 'flex-start' ? 0 : 2,
285
+ float: position === "flex-start" ? "left" : "right",
286
+ order: position === "flex-start" ? 0 : 2,
279
287
  textAlign,
280
288
  zIndex: 2,
281
- cursor: 'pointer',
289
+ cursor: "pointer",
282
290
  }}
283
291
  onClick={() => onClick()}
284
292
  >
@@ -288,12 +296,12 @@ export function TextFieldSlot({
288
296
  <TextFieldSlotStyled
289
297
  {...sharedStyles}
290
298
  style={{
291
- float: position === 'flex-start' ? 'left' : 'right',
292
- order: position === 'flex-start' ? 0 : 2,
299
+ float: position === "flex-start" ? "left" : "right",
300
+ order: position === "flex-start" ? 0 : 2,
293
301
  textAlign,
294
302
  }}
295
303
  >
296
304
  {children}
297
305
  </TextFieldSlotStyled>
298
- )
306
+ );
299
307
  }