@atlure/ui 0.12.3 → 0.12.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlure/ui",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
4
4
  "description": "Atlure React Native component library: NativeWind primitives built on @atlure/tokens, shipped as untranspiled TypeScript source",
5
5
  "license": "MIT",
6
6
  "author": "David Moreira",
@@ -37,9 +37,9 @@
37
37
  "class-variance-authority": "0.7.1",
38
38
  "clsx": "2.1.1",
39
39
  "tailwind-merge": "2.6.0",
40
- "@atlure/icons": "0.12.3",
41
- "@atlure/tokens": "0.12.3",
42
- "@atlure/types": "0.12.3"
40
+ "@atlure/icons": "0.12.4",
41
+ "@atlure/tokens": "0.12.4",
42
+ "@atlure/types": "0.12.4"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "nativewind": "^4.2.6",
@@ -4,8 +4,8 @@ import { Platform, TextInput, type TextInputProps, View } from "react-native";
4
4
  import { cn } from "../../lib/cn";
5
5
  import { touchTargetHitSlop } from "../../lib/touch-target";
6
6
  import {
7
- inputFieldWrapperClassName,
8
7
  inputIconSlotVariants,
8
+ inputTextClassName,
9
9
  inputVariants,
10
10
  type InputVariantProps,
11
11
  } from "../../variants/input-variants";
@@ -22,24 +22,10 @@ export interface InputProps extends Omit<TextInputProps, "editable" | "multiline
22
22
  ref?: Ref<ComponentRef<typeof TextInput>>;
23
23
  }
24
24
 
25
- const CONTROL_HEIGHT_PX: Record<NonNullable<InputVariantProps["size"]>, number> = {
26
- sm: 36,
27
- md: 40,
28
- lg: 48,
29
- };
30
-
31
- function singleLineVerticalFix(
32
- size: NonNullable<InputVariantProps["size"]>,
33
- ): { paddingTop: 0; paddingBottom: 0; lineHeight: number; includeFontPadding?: false } {
34
- const base = {
35
- paddingTop: 0 as const,
36
- paddingBottom: 0 as const,
37
- lineHeight: CONTROL_HEIGHT_PX[size],
38
- };
39
- return Platform.OS === "android"
40
- ? { ...base, includeFontPadding: false as const }
41
- : base;
42
- }
25
+ const TEXT_INPUT_RESET =
26
+ Platform.OS === "android"
27
+ ? { paddingTop: 0, paddingBottom: 0, includeFontPadding: false as const }
28
+ : { paddingTop: 0, paddingBottom: 0 };
43
29
 
44
30
  export function Input({
45
31
  size = "md",
@@ -59,22 +45,8 @@ export function Input({
59
45
  const isControlInvalid = isInvalid ?? field?.isInvalid ?? false;
60
46
  const isControlRequired = isRequired ?? field?.isRequired ?? false;
61
47
 
62
- const verticalFix = isMultiline ? null : singleLineVerticalFix(size);
63
-
64
- const control = (
65
- <TextInput
66
- accessibilityState={{ disabled: isControlDisabled }}
67
- accessibilityLabelledBy={field?.labelledBy}
68
- aria-labelledby={field?.labelledBy}
69
- aria-describedby={field?.describedBy}
70
- aria-disabled={isControlDisabled}
71
- aria-invalid={isControlInvalid}
72
- aria-required={isControlRequired}
73
- nativeID={nativeID ?? field?.nativeID}
74
- editable={!isControlDisabled}
75
- multiline={isMultiline}
76
- textAlignVertical={isMultiline ? "top" : "center"}
77
- hitSlop={touchTargetHitSlop(size)}
48
+ return (
49
+ <View
78
50
  className={cn(
79
51
  inputVariants({
80
52
  size,
@@ -86,21 +58,27 @@ export function Input({
86
58
  }),
87
59
  className,
88
60
  )}
89
- style={verticalFix ? [verticalFix, style] : style}
90
- {...textInputProps}
91
- />
92
- );
93
-
94
- if (!leadingIcon && !trailingIcon) {
95
- return control;
96
- }
97
-
98
- return (
99
- <View className={inputFieldWrapperClassName}>
61
+ >
100
62
  {leadingIcon ? (
101
63
  <View className={inputIconSlotVariants({ slot: "leading" })}>{leadingIcon}</View>
102
64
  ) : null}
103
- {control}
65
+ <TextInput
66
+ accessibilityState={{ disabled: isControlDisabled }}
67
+ accessibilityLabelledBy={field?.labelledBy}
68
+ aria-labelledby={field?.labelledBy}
69
+ aria-describedby={field?.describedBy}
70
+ aria-disabled={isControlDisabled}
71
+ aria-invalid={isControlInvalid}
72
+ aria-required={isControlRequired}
73
+ nativeID={nativeID ?? field?.nativeID}
74
+ editable={!isControlDisabled}
75
+ multiline={isMultiline}
76
+ textAlignVertical={isMultiline ? "top" : "center"}
77
+ hitSlop={touchTargetHitSlop(size)}
78
+ className={inputTextClassName}
79
+ style={[TEXT_INPUT_RESET, style]}
80
+ {...textInputProps}
81
+ />
104
82
  {trailingIcon ? (
105
83
  <View className={inputIconSlotVariants({ slot: "trailing" })}>{trailingIcon}</View>
106
84
  ) : null}
@@ -1,7 +1,7 @@
1
1
  import { cva, type VariantProps } from "class-variance-authority";
2
2
 
3
3
  export const inputVariants = cva(
4
- "w-full rounded-md border bg-input-background px-md text-base text-foreground placeholder:text-muted-foreground",
4
+ "w-full flex-row items-center rounded-md border bg-input-background px-md",
5
5
  {
6
6
  variants: {
7
7
  size: {
@@ -18,7 +18,7 @@ export const inputVariants = cva(
18
18
  false: "",
19
19
  },
20
20
  isMultiline: {
21
- true: "h-auto min-h-control-lg py-sm",
21
+ true: "h-auto min-h-control-lg py-sm items-start",
22
22
  false: "",
23
23
  },
24
24
  hasLeadingIcon: {
@@ -41,6 +41,9 @@ export const inputVariants = cva(
41
41
  },
42
42
  );
43
43
 
44
+ export const inputTextClassName =
45
+ "flex-1 text-base text-foreground placeholder:text-muted-foreground";
46
+
44
47
  export const inputIconSlotVariants = cva("absolute inset-y-0 justify-center", {
45
48
  variants: {
46
49
  slot: {