@webority-technologies/mobile 0.0.15 → 0.0.21

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.
Files changed (202) hide show
  1. package/lib/commonjs/components/Accordion/Accordion.js +60 -19
  2. package/lib/commonjs/components/AppBar/AppBar.js +29 -20
  3. package/lib/commonjs/components/Avatar/Avatar.js +38 -8
  4. package/lib/commonjs/components/Badge/Badge.js +66 -4
  5. package/lib/commonjs/components/Banner/Banner.js +146 -66
  6. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +37 -15
  7. package/lib/commonjs/components/BottomSheet/BottomSheet.js +78 -53
  8. package/lib/commonjs/components/Button/Button.js +12 -5
  9. package/lib/commonjs/components/Card/Card.js +106 -16
  10. package/lib/commonjs/components/Carousel/Carousel.js +66 -12
  11. package/lib/commonjs/components/Checkbox/Checkbox.js +11 -7
  12. package/lib/commonjs/components/Chip/Chip.js +44 -12
  13. package/lib/commonjs/components/DatePicker/DatePicker.js +185 -76
  14. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +133 -59
  15. package/lib/commonjs/components/Dialog/Dialog.js +16 -10
  16. package/lib/commonjs/components/Drawer/Drawer.js +13 -10
  17. package/lib/commonjs/components/FieldBase/FieldBase.js +494 -0
  18. package/lib/commonjs/components/FieldBase/index.js +32 -0
  19. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +69 -44
  20. package/lib/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.js +8 -2
  21. package/lib/commonjs/components/FormField/FormField.js +3 -2
  22. package/lib/commonjs/components/ImageGallery/ImageGallery.js +132 -44
  23. package/lib/commonjs/components/Input/Input.js +144 -181
  24. package/lib/commonjs/components/ListItem/ListItem.js +90 -11
  25. package/lib/commonjs/components/Modal/Modal.js +55 -27
  26. package/lib/commonjs/components/NumberInput/NumberInput.js +60 -106
  27. package/lib/commonjs/components/OTPInput/OTPInput.js +65 -58
  28. package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +185 -0
  29. package/lib/commonjs/components/{AppIcon → PickerTrigger}/index.js +4 -4
  30. package/lib/commonjs/components/ProgressBar/ProgressBar.js +19 -11
  31. package/lib/commonjs/components/Radio/Radio.js +11 -6
  32. package/lib/commonjs/components/Rating/Rating.js +85 -19
  33. package/lib/commonjs/components/SearchBar/SearchBar.js +90 -107
  34. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +22 -11
  35. package/lib/commonjs/components/Select/Select.js +62 -91
  36. package/lib/commonjs/components/Skeleton/Skeleton.js +131 -174
  37. package/lib/commonjs/components/Skeleton/SkeletonClock.js +117 -0
  38. package/lib/commonjs/components/Skeleton/SkeletonContent.js +164 -81
  39. package/lib/commonjs/components/Skeleton/SkeletonProvider.js +72 -10
  40. package/lib/commonjs/components/Skeleton/index.js +17 -16
  41. package/lib/commonjs/components/Slider/Slider.js +44 -25
  42. package/lib/commonjs/components/Stepper/Stepper.js +199 -29
  43. package/lib/commonjs/components/Swipeable/Swipeable.js +36 -19
  44. package/lib/commonjs/components/Switch/Switch.js +9 -2
  45. package/lib/commonjs/components/Tabs/Tabs.js +84 -21
  46. package/lib/commonjs/components/TimePicker/TimePicker.js +123 -45
  47. package/lib/commonjs/components/Toast/Toast.js +27 -16
  48. package/lib/commonjs/components/Tooltip/Tooltip.js +56 -32
  49. package/lib/commonjs/components/index.js +37 -37
  50. package/lib/commonjs/theme/tokens.js +55 -7
  51. package/lib/module/components/Accordion/Accordion.js +61 -20
  52. package/lib/module/components/AppBar/AppBar.js +29 -20
  53. package/lib/module/components/Avatar/Avatar.js +39 -9
  54. package/lib/module/components/Badge/Badge.js +67 -5
  55. package/lib/module/components/Banner/Banner.js +147 -67
  56. package/lib/module/components/BottomNavigation/BottomNavigation.js +37 -15
  57. package/lib/module/components/BottomSheet/BottomSheet.js +80 -55
  58. package/lib/module/components/Button/Button.js +12 -5
  59. package/lib/module/components/Card/Card.js +107 -17
  60. package/lib/module/components/Carousel/Carousel.js +67 -13
  61. package/lib/module/components/Checkbox/Checkbox.js +11 -7
  62. package/lib/module/components/Chip/Chip.js +45 -13
  63. package/lib/module/components/DatePicker/DatePicker.js +185 -76
  64. package/lib/module/components/DateRangePicker/DateRangePicker.js +134 -60
  65. package/lib/module/components/Dialog/Dialog.js +16 -10
  66. package/lib/module/components/Drawer/Drawer.js +13 -10
  67. package/lib/module/components/FieldBase/FieldBase.js +485 -0
  68. package/lib/module/components/FieldBase/index.js +4 -0
  69. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +69 -44
  70. package/lib/module/components/ForceUpdateDialog/ForceUpdateDialog.js +8 -2
  71. package/lib/module/components/FormField/FormField.js +3 -2
  72. package/lib/module/components/ImageGallery/ImageGallery.js +128 -40
  73. package/lib/module/components/Input/Input.js +144 -179
  74. package/lib/module/components/ListItem/ListItem.js +91 -12
  75. package/lib/module/components/Modal/Modal.js +55 -27
  76. package/lib/module/components/NumberInput/NumberInput.js +60 -106
  77. package/lib/module/components/OTPInput/OTPInput.js +65 -58
  78. package/lib/module/components/PickerTrigger/PickerTrigger.js +181 -0
  79. package/lib/module/components/PickerTrigger/index.js +4 -0
  80. package/lib/module/components/ProgressBar/ProgressBar.js +19 -11
  81. package/lib/module/components/Radio/Radio.js +11 -6
  82. package/lib/module/components/Rating/Rating.js +86 -20
  83. package/lib/module/components/SearchBar/SearchBar.js +90 -107
  84. package/lib/module/components/SegmentedControl/SegmentedControl.js +22 -11
  85. package/lib/module/components/Select/Select.js +62 -91
  86. package/lib/module/components/Skeleton/Skeleton.js +135 -175
  87. package/lib/module/components/Skeleton/SkeletonClock.js +110 -0
  88. package/lib/module/components/Skeleton/SkeletonContent.js +167 -84
  89. package/lib/module/components/Skeleton/SkeletonProvider.js +71 -10
  90. package/lib/module/components/Skeleton/index.js +3 -2
  91. package/lib/module/components/Slider/Slider.js +44 -25
  92. package/lib/module/components/Stepper/Stepper.js +201 -31
  93. package/lib/module/components/Swipeable/Swipeable.js +36 -19
  94. package/lib/module/components/Switch/Switch.js +9 -2
  95. package/lib/module/components/Tabs/Tabs.js +84 -21
  96. package/lib/module/components/TimePicker/TimePicker.js +123 -45
  97. package/lib/module/components/Toast/Toast.js +27 -16
  98. package/lib/module/components/Tooltip/Tooltip.js +56 -32
  99. package/lib/module/components/index.js +2 -2
  100. package/lib/module/theme/tokens.js +55 -7
  101. package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +10 -5
  102. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +8 -0
  103. package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +12 -6
  104. package/lib/typescript/commonjs/components/Badge/Badge.d.ts +7 -6
  105. package/lib/typescript/commonjs/components/Banner/Banner.d.ts +17 -6
  106. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +7 -0
  107. package/lib/typescript/commonjs/components/Card/Card.d.ts +17 -6
  108. package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +7 -6
  109. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +9 -1
  110. package/lib/typescript/commonjs/components/Chip/Chip.d.ts +13 -6
  111. package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +38 -3
  112. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +36 -3
  113. package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +13 -1
  114. package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +172 -0
  115. package/lib/typescript/commonjs/components/FieldBase/index.d.ts +3 -0
  116. package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +8 -6
  117. package/lib/typescript/commonjs/components/FloatingActionButton/index.d.ts +1 -1
  118. package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +7 -0
  119. package/lib/typescript/commonjs/components/FormField/FormField.d.ts +7 -0
  120. package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +6 -4
  121. package/lib/typescript/commonjs/components/Input/Input.d.ts +7 -1
  122. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +13 -6
  123. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +3 -0
  124. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +57 -0
  125. package/lib/typescript/commonjs/components/PickerTrigger/index.d.ts +3 -0
  126. package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +2 -0
  127. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +3 -0
  128. package/lib/typescript/commonjs/components/Rating/Rating.d.ts +9 -6
  129. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -0
  130. package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +49 -20
  131. package/lib/typescript/commonjs/components/Skeleton/SkeletonClock.d.ts +60 -0
  132. package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +80 -19
  133. package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +39 -5
  134. package/lib/typescript/commonjs/components/Skeleton/index.d.ts +6 -4
  135. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +12 -1
  136. package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +18 -6
  137. package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +2 -0
  138. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +1 -0
  139. package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +26 -2
  140. package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +36 -3
  141. package/lib/typescript/commonjs/components/Toast/Toast.d.ts +8 -0
  142. package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +7 -1
  143. package/lib/typescript/commonjs/components/index.d.ts +5 -5
  144. package/lib/typescript/commonjs/index.d.ts +1 -1
  145. package/lib/typescript/commonjs/theme/index.d.ts +1 -1
  146. package/lib/typescript/commonjs/theme/types.d.ts +578 -12
  147. package/lib/typescript/module/components/Accordion/Accordion.d.ts +10 -5
  148. package/lib/typescript/module/components/AppBar/AppBar.d.ts +8 -0
  149. package/lib/typescript/module/components/Avatar/Avatar.d.ts +12 -6
  150. package/lib/typescript/module/components/Badge/Badge.d.ts +7 -6
  151. package/lib/typescript/module/components/Banner/Banner.d.ts +17 -6
  152. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +7 -0
  153. package/lib/typescript/module/components/Card/Card.d.ts +17 -6
  154. package/lib/typescript/module/components/Carousel/Carousel.d.ts +7 -6
  155. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +9 -1
  156. package/lib/typescript/module/components/Chip/Chip.d.ts +13 -6
  157. package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +38 -3
  158. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +36 -3
  159. package/lib/typescript/module/components/Dialog/Dialog.d.ts +13 -1
  160. package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +172 -0
  161. package/lib/typescript/module/components/FieldBase/index.d.ts +3 -0
  162. package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +8 -6
  163. package/lib/typescript/module/components/FloatingActionButton/index.d.ts +1 -1
  164. package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +7 -0
  165. package/lib/typescript/module/components/FormField/FormField.d.ts +7 -0
  166. package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +6 -4
  167. package/lib/typescript/module/components/Input/Input.d.ts +7 -1
  168. package/lib/typescript/module/components/ListItem/ListItem.d.ts +13 -6
  169. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +3 -0
  170. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +57 -0
  171. package/lib/typescript/module/components/PickerTrigger/index.d.ts +3 -0
  172. package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +2 -0
  173. package/lib/typescript/module/components/Radio/Radio.d.ts +3 -0
  174. package/lib/typescript/module/components/Rating/Rating.d.ts +9 -6
  175. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -0
  176. package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +49 -20
  177. package/lib/typescript/module/components/Skeleton/SkeletonClock.d.ts +60 -0
  178. package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +80 -19
  179. package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +39 -5
  180. package/lib/typescript/module/components/Skeleton/index.d.ts +6 -4
  181. package/lib/typescript/module/components/Slider/Slider.d.ts +12 -1
  182. package/lib/typescript/module/components/Stepper/Stepper.d.ts +18 -6
  183. package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +2 -0
  184. package/lib/typescript/module/components/Switch/Switch.d.ts +1 -0
  185. package/lib/typescript/module/components/Tabs/Tabs.d.ts +26 -2
  186. package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +36 -3
  187. package/lib/typescript/module/components/Toast/Toast.d.ts +8 -0
  188. package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +7 -1
  189. package/lib/typescript/module/components/index.d.ts +5 -5
  190. package/lib/typescript/module/index.d.ts +1 -1
  191. package/lib/typescript/module/theme/index.d.ts +1 -1
  192. package/lib/typescript/module/theme/types.d.ts +578 -12
  193. package/package.json +2 -6
  194. package/lib/commonjs/components/AppIcon/AppIcon.js +0 -120
  195. package/lib/commonjs/types/vector-icons.d.js +0 -2
  196. package/lib/module/components/AppIcon/AppIcon.js +0 -111
  197. package/lib/module/components/AppIcon/index.js +0 -4
  198. package/lib/module/types/vector-icons.d.js +0 -2
  199. package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +0 -20
  200. package/lib/typescript/commonjs/components/AppIcon/index.d.ts +0 -3
  201. package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +0 -20
  202. package/lib/typescript/module/components/AppIcon/index.d.ts +0 -3
@@ -0,0 +1,485 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * FieldBase — the unified field-box primitive.
5
+ *
6
+ * Every input-like control in the library (Input, Select, SearchBar,
7
+ * NumberInput, OTPInput cell, PickerTrigger) composes FieldBase so the
8
+ * height / radius / padding / border / fill / focus + disabled + error
9
+ * states stay identical across the library. Differences (pill SearchBar,
10
+ * OTP underline, NumberInput steppers) become explicit overrides via
11
+ * props or via theme tokens — never accidental drift.
12
+ *
13
+ * Responsibilities:
14
+ * - Resolve size / variant dimensions from `theme.components.field`.
15
+ * - Animate the border + background between idle / focused / error.
16
+ * - Render leading + trailing slots either side of `children`.
17
+ * - Become Pressable when `onPress` is set (Select, PickerTrigger).
18
+ * - Apply disabled fill + cursor semantics.
19
+ *
20
+ * Non-responsibilities (the parent owns these):
21
+ * - The actual TextInput / Text / nested editor.
22
+ * - Floating / static labels rendered above the field.
23
+ * - Helper / error / counter text rendered below the field.
24
+ * - Shake-on-error or any cross-field animation.
25
+ */
26
+
27
+ import React, { useEffect, useMemo, useRef } from 'react';
28
+ import { Animated, Easing, Pressable, StyleSheet, View } from 'react-native';
29
+ import { useTheme, createAnimatedValue, fontFor } from "../../theme/index.js";
30
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
31
+ const SIDES = ['top', 'right', 'bottom', 'left'];
32
+
33
+ /** Map a single colour string to all four sides (shorthand expansion). */
34
+ const expandColorSides = value => {
35
+ if (typeof value === 'string') {
36
+ return {
37
+ top: value,
38
+ right: value,
39
+ bottom: value,
40
+ left: value
41
+ };
42
+ }
43
+ // Object form: any side the consumer omitted falls through to 'transparent'.
44
+ // Rationale: if a consumer says `{ bottom: '#000' }`, they want only the
45
+ // bottom drawn — the other sides should be invisible, not inherit some
46
+ // unrelated colour.
47
+ return {
48
+ top: value.top ?? 'transparent',
49
+ right: value.right ?? 'transparent',
50
+ bottom: value.bottom ?? 'transparent',
51
+ left: value.left ?? 'transparent'
52
+ };
53
+ };
54
+
55
+ /** Map a single width number to all four sides (shorthand expansion). */
56
+ const expandWidthSides = value => {
57
+ if (typeof value === 'number') {
58
+ return {
59
+ top: value,
60
+ right: value,
61
+ bottom: value,
62
+ left: value
63
+ };
64
+ }
65
+ return {
66
+ top: value.top ?? 0,
67
+ right: value.right ?? 0,
68
+ bottom: value.bottom ?? 0,
69
+ left: value.left ?? 0
70
+ };
71
+ };
72
+
73
+ /** Are all four sides of a per-side record equal? Used to collapse to shorthand. */
74
+ const allSidesEqual = sides => sides.top === sides.right && sides.right === sides.bottom && sides.bottom === sides.left;
75
+
76
+ /**
77
+ * Pick the most "representative" side colour from a 4-side record. Used by
78
+ * consumers (Input's selectionColor, focus rings, etc.) that need a single
79
+ * colour to mirror the visible focus indicator. Priority: bottom → top →
80
+ * left → right, skipping `'transparent'`. The bottom-first order means
81
+ * underline variants pick their underline colour automatically.
82
+ */
83
+ export const pickRepresentativeBorderColor = sides => {
84
+ for (const side of ['bottom', 'top', 'left', 'right']) {
85
+ const c = sides[side];
86
+ if (c && c !== 'transparent') return c;
87
+ }
88
+ return sides.bottom;
89
+ };
90
+
91
+ /**
92
+ * Resolved text styling for the editable / displayed content inside a field.
93
+ * Single source of truth so every field component (Input, NumberInput,
94
+ * Select, SearchBar, PickerTrigger) renders identical colour + weight +
95
+ * fontFamily for value text — and reads the placeholder colour from the
96
+ * same place. OTPInput intentionally overrides this with its own semibold
97
+ * display weight.
98
+ */
99
+
100
+ /**
101
+ * Resolve the canonical text style chunk for a field's value. Reads from
102
+ * `theme.components.field.{textColor,disabledTextColor,placeholderColor,fontWeight}`
103
+ * with library-default fallbacks; brand fonts wired via `typography.fontFamily`
104
+ * apply via the shared `fontFor` helper.
105
+ */
106
+ export const resolveFieldTextStyle = (theme, options = {}) => {
107
+ const {
108
+ disabled = false
109
+ } = options;
110
+ const tokens = theme.components.field;
111
+ const color = disabled ? tokens?.disabledTextColor ?? theme.colors.text.disabled : tokens?.textColor ?? theme.colors.text.primary;
112
+ const placeholderColor = tokens?.placeholderColor ?? theme.colors.text.tertiary;
113
+
114
+ // If a consumer sets `field.fontWeight` directly (raw RN weight string),
115
+ // honour it verbatim — they've opted out of the brand-font path. Otherwise
116
+ // resolve weight through `fontFor` so `typography.fontFamily.<weight>`
117
+ // takes precedence when a custom face is registered.
118
+ const weightStyle = tokens?.fontWeight ? {
119
+ fontWeight: tokens.fontWeight
120
+ } : fontFor(theme, 'medium');
121
+ return {
122
+ color,
123
+ placeholderColor,
124
+ weightStyle
125
+ };
126
+ };
127
+
128
+ /**
129
+ * Public re-export of the resolved size tokens — components that need to
130
+ * compute their own padding adjustments (e.g. multiline Input, icon-slot
131
+ * sizing) read from this rather than re-hardcoding the size table.
132
+ */
133
+ export const resolveFieldSize = (theme, size) => {
134
+ const sizeFromTheme = theme.components.field?.[size];
135
+ return {
136
+ paddingHorizontal: sizeFromTheme?.paddingHorizontal ?? DEFAULT_SIZES[size].paddingHorizontal,
137
+ paddingVertical: sizeFromTheme?.paddingVertical ?? DEFAULT_SIZES[size].paddingVertical,
138
+ minHeight: sizeFromTheme?.minHeight ?? DEFAULT_SIZES[size].minHeight,
139
+ fontSize: sizeFromTheme?.fontSize ?? DEFAULT_SIZES[size].fontSize,
140
+ borderRadius: sizeFromTheme?.borderRadius ?? DEFAULT_SIZES[size].borderRadius,
141
+ iconSize: sizeFromTheme?.iconSize ?? DEFAULT_SIZES[size].iconSize
142
+ };
143
+ };
144
+
145
+ // Library defaults for when consumers haven't supplied per-size tokens. The
146
+ // numbers here MUST stay in sync with the `fieldSizes` table in tokens.ts —
147
+ // these are the same values, duplicated so resolveFieldSize works even when
148
+ // the consumer passes a custom theme without `components.field` set.
149
+ const DEFAULT_SIZES = {
150
+ sm: {
151
+ paddingHorizontal: 12,
152
+ paddingVertical: 8,
153
+ minHeight: 38,
154
+ fontSize: 13,
155
+ borderRadius: 10,
156
+ iconSize: 16
157
+ },
158
+ md: {
159
+ paddingHorizontal: 14,
160
+ paddingVertical: 11,
161
+ minHeight: 46,
162
+ fontSize: 15,
163
+ borderRadius: 12,
164
+ iconSize: 18
165
+ },
166
+ lg: {
167
+ paddingHorizontal: 16,
168
+ paddingVertical: 14,
169
+ minHeight: 54,
170
+ fontSize: 16,
171
+ borderRadius: 14,
172
+ iconSize: 20
173
+ }
174
+ };
175
+
176
+ /**
177
+ * Strict, fully-resolved colour set used internally. Mirrors `FieldVariantTokens`
178
+ * but every border colour / width is expanded to a 4-side record by the time
179
+ * the box renders, so the animation pipeline can treat per-side and shorthand
180
+ * the same way. `borderFocusedRepresentative` is a single colour pulled from
181
+ * the focused sides — exposed for consumers (Input's selectionColor) that
182
+ * need to mirror the visible focus indicator without re-resolving per side.
183
+ */
184
+
185
+ /**
186
+ * Resolve the full set of state-aware fill + border colours for a given
187
+ * variant. Order: explicit override → theme token → library default. Border
188
+ * colour + width are normalized to per-side records here; callers that need
189
+ * a single colour read `borderFocusedRepresentative`.
190
+ */
191
+ export const resolveVariantColors = (theme, variant, override) => {
192
+ const tokenSet = theme.components.field?.[variant];
193
+
194
+ // Variant-specific defaults for resting fill + border treatment. `outlined`
195
+ // draws all four sides; `filled` draws nothing (fill-only); `underline`
196
+ // draws only the bottom edge — Material-style single-line inputs.
197
+ let idleEmpty;
198
+ let borderIdleDefault;
199
+ let borderWidthDefault;
200
+ if (variant === 'outlined') {
201
+ idleEmpty = theme.colors.background.primary;
202
+ borderIdleDefault = theme.colors.border.primary;
203
+ borderWidthDefault = theme.colors.border.width;
204
+ } else if (variant === 'underline') {
205
+ idleEmpty = 'transparent';
206
+ borderIdleDefault = {
207
+ bottom: theme.colors.border.primary
208
+ };
209
+ borderWidthDefault = {
210
+ bottom: theme.colors.border.width
211
+ };
212
+ } else {
213
+ idleEmpty = theme.colors.background.secondary;
214
+ borderIdleDefault = 'transparent';
215
+ borderWidthDefault = 0;
216
+ }
217
+
218
+ // For focused/error/disabled we expand using the same per-side shape as
219
+ // idle. If `borderIdle` ended up bottom-only (underline), an unset
220
+ // `borderFocused` defaults to `{ bottom: colors.border.focus }` so the
221
+ // focus indicator stays on the same edge. Same logic for error.
222
+ const wrapToIdleShape = colour => typeof borderIdleDefault === 'string' ? colour : {
223
+ bottom: colour
224
+ };
225
+ const borderIdle = expandColorSides(override?.borderIdle ?? tokenSet?.borderIdle ?? borderIdleDefault);
226
+ const borderFocused = expandColorSides(override?.borderFocused ?? tokenSet?.borderFocused ?? wrapToIdleShape(theme.colors.border.focus));
227
+ const borderError = expandColorSides(override?.borderError ?? tokenSet?.borderError ?? wrapToIdleShape(theme.colors.border.error));
228
+ const borderDisabled = expandColorSides(override?.borderDisabled ?? tokenSet?.borderDisabled ?? borderIdleDefault);
229
+ const borderWidth = expandWidthSides(override?.borderWidth ?? tokenSet?.borderWidth ?? borderWidthDefault);
230
+ return {
231
+ backgroundIdleEmpty: override?.backgroundIdleEmpty ?? tokenSet?.backgroundIdleEmpty ?? idleEmpty,
232
+ backgroundIdleFilled: override?.backgroundIdleFilled ?? tokenSet?.backgroundIdleFilled ?? override?.backgroundIdleEmpty ?? tokenSet?.backgroundIdleEmpty ?? idleEmpty,
233
+ backgroundFocused: override?.backgroundFocused ?? tokenSet?.backgroundFocused ?? undefined,
234
+ backgroundError: override?.backgroundError ?? tokenSet?.backgroundError ?? undefined,
235
+ backgroundDisabled: override?.backgroundDisabled ?? tokenSet?.backgroundDisabled ?? theme.colors.surface.disabled,
236
+ borderIdle,
237
+ borderFocused,
238
+ borderError,
239
+ borderDisabled,
240
+ borderWidth,
241
+ borderFocusedRepresentative: pickRepresentativeBorderColor(borderFocused)
242
+ };
243
+ };
244
+ export const FieldBase = props => {
245
+ const {
246
+ size = 'md',
247
+ variant: variantProp,
248
+ focused = false,
249
+ disabled = false,
250
+ error = false,
251
+ filled = false,
252
+ leading,
253
+ trailing,
254
+ children,
255
+ onPress,
256
+ minHeight: minHeightProp,
257
+ maxHeight,
258
+ width,
259
+ height,
260
+ paddingHorizontal: paddingHorizontalProp,
261
+ paddingVertical: paddingVerticalProp,
262
+ borderRadius: borderRadiusProp,
263
+ borderTopLeftRadius: borderTopLeftRadiusProp,
264
+ borderTopRightRadius: borderTopRightRadiusProp,
265
+ borderBottomLeftRadius: borderBottomLeftRadiusProp,
266
+ borderBottomRightRadius: borderBottomRightRadiusProp,
267
+ borderWidth: borderWidthProp,
268
+ borderTopWidth: borderTopWidthProp,
269
+ borderRightWidth: borderRightWidthProp,
270
+ borderBottomWidth: borderBottomWidthProp,
271
+ borderLeftWidth: borderLeftWidthProp,
272
+ gap: gapProp,
273
+ fillOverrides,
274
+ style,
275
+ testID,
276
+ accessibilityRole,
277
+ accessibilityLabel,
278
+ accessibilityState,
279
+ accessibilityHint
280
+ } = props;
281
+ const theme = useTheme();
282
+ const styles = useMemo(() => buildStyles(), []);
283
+ const variant = variantProp ?? theme.components.field?.defaultVariant ?? 'outlined';
284
+ const sizeTokens = resolveFieldSize(theme, size);
285
+ const colors = useMemo(() => resolveVariantColors(theme, variant, fillOverrides), [theme, variant, fillOverrides]);
286
+ const focusAnim = useRef(createAnimatedValue(focused ? 1 : 0)).current;
287
+ const errorAnim = useRef(createAnimatedValue(error ? 1 : 0)).current;
288
+ useEffect(() => {
289
+ Animated.timing(focusAnim, {
290
+ toValue: focused ? 1 : 0,
291
+ duration: theme.motion.duration.fast,
292
+ easing: Easing.bezier(...theme.motion.easing.standard),
293
+ useNativeDriver: false
294
+ }).start();
295
+ }, [focused, focusAnim, theme.motion.duration.fast, theme.motion.easing.standard]);
296
+ useEffect(() => {
297
+ Animated.timing(errorAnim, {
298
+ toValue: error ? 1 : 0,
299
+ duration: theme.motion.duration.fast,
300
+ easing: Easing.bezier(...theme.motion.easing.standard),
301
+ useNativeDriver: false
302
+ }).start();
303
+ }, [error, errorAnim, theme.motion.duration.fast, theme.motion.easing.standard]);
304
+
305
+ // Resting border + fill (pre-animation). Error wins over focus when both
306
+ // happen at once; we drive a single interpolation between blurred ↔ active.
307
+ const idleFill = filled ? colors.backgroundIdleFilled : colors.backgroundIdleEmpty;
308
+ const focusedFill = colors.backgroundFocused ?? idleFill;
309
+ const errorFill = colors.backgroundError ?? idleFill;
310
+ const animatedBackgroundColor = disabled ? colors.backgroundDisabled : error ? errorAnim.interpolate({
311
+ inputRange: [0, 1],
312
+ outputRange: [idleFill, errorFill]
313
+ }) : focusAnim.interpolate({
314
+ inputRange: [0, 1],
315
+ outputRange: [idleFill, focusedFill]
316
+ });
317
+
318
+ // Per-side border colour. For each side we resolve the "from" (idle) and
319
+ // "to" (focused or error, depending on state) colour, then drive a single
320
+ // animated interpolation. When all four sides share the same from+to pair
321
+ // we collapse to one `borderColor` key — the common case stays cheap.
322
+ const activeColors = error ? colors.borderError : colors.borderFocused;
323
+ const activeAnim = error ? errorAnim : focusAnim;
324
+ const sideFrom = disabled ? colors.borderDisabled : colors.borderIdle;
325
+ const sideTo = disabled ? colors.borderDisabled : activeColors;
326
+
327
+ // Per-side widths: longhand prop wins over shorthand prop wins over
328
+ // resolved variant token. Each side independently.
329
+ const propWidth = {
330
+ top: borderTopWidthProp,
331
+ right: borderRightWidthProp,
332
+ bottom: borderBottomWidthProp,
333
+ left: borderLeftWidthProp
334
+ };
335
+ const resolvedWidths = {
336
+ top: propWidth.top ?? borderWidthProp ?? colors.borderWidth.top,
337
+ right: propWidth.right ?? borderWidthProp ?? colors.borderWidth.right,
338
+ bottom: propWidth.bottom ?? borderWidthProp ?? colors.borderWidth.bottom,
339
+ left: propWidth.left ?? borderWidthProp ?? colors.borderWidth.left
340
+ };
341
+ const boxStyle = {
342
+ minHeight: height ?? minHeightProp ?? sizeTokens.minHeight,
343
+ maxHeight,
344
+ paddingHorizontal: paddingHorizontalProp ?? sizeTokens.paddingHorizontal,
345
+ paddingVertical: paddingVerticalProp ?? sizeTokens.paddingVertical,
346
+ backgroundColor: animatedBackgroundColor,
347
+ columnGap: gapProp ?? theme.spacing.sm
348
+ };
349
+
350
+ // Radius: per-corner prop wins over shorthand prop wins over size token.
351
+ // Collapse to single `borderRadius` when all four corners match.
352
+ const radiusShorthand = borderRadiusProp ?? sizeTokens.borderRadius;
353
+ const corners = {
354
+ tl: borderTopLeftRadiusProp ?? radiusShorthand,
355
+ tr: borderTopRightRadiusProp ?? radiusShorthand,
356
+ bl: borderBottomLeftRadiusProp ?? radiusShorthand,
357
+ br: borderBottomRightRadiusProp ?? radiusShorthand
358
+ };
359
+ if (corners.tl === corners.tr && corners.tr === corners.bl && corners.bl === corners.br) {
360
+ boxStyle.borderRadius = corners.tl;
361
+ } else {
362
+ boxStyle.borderTopLeftRadius = corners.tl;
363
+ boxStyle.borderTopRightRadius = corners.tr;
364
+ boxStyle.borderBottomLeftRadius = corners.bl;
365
+ boxStyle.borderBottomRightRadius = corners.br;
366
+ }
367
+
368
+ // Width: collapse to single `borderWidth` when all four sides match.
369
+ if (resolvedWidths.top === resolvedWidths.right && resolvedWidths.right === resolvedWidths.bottom && resolvedWidths.bottom === resolvedWidths.left) {
370
+ boxStyle.borderWidth = resolvedWidths.top;
371
+ } else {
372
+ boxStyle.borderTopWidth = resolvedWidths.top;
373
+ boxStyle.borderRightWidth = resolvedWidths.right;
374
+ boxStyle.borderBottomWidth = resolvedWidths.bottom;
375
+ boxStyle.borderLeftWidth = resolvedWidths.left;
376
+ }
377
+
378
+ // Colour: collapse to single `borderColor` only when both endpoints are
379
+ // identical across all sides. Otherwise emit four `borderXColor`
380
+ // interpolations. Disabled state is static (no animation needed).
381
+ const fromAllEqual = allSidesEqual(sideFrom);
382
+ const toAllEqual = allSidesEqual(sideTo);
383
+ if (disabled) {
384
+ if (fromAllEqual) {
385
+ boxStyle.borderColor = sideFrom.top;
386
+ } else {
387
+ boxStyle.borderTopColor = sideFrom.top;
388
+ boxStyle.borderRightColor = sideFrom.right;
389
+ boxStyle.borderBottomColor = sideFrom.bottom;
390
+ boxStyle.borderLeftColor = sideFrom.left;
391
+ }
392
+ } else if (fromAllEqual && toAllEqual && sideFrom.top === sideFrom.right && sideTo.top === sideTo.right) {
393
+ // Common case: shorthand on both ends → single interpolation.
394
+ boxStyle.borderColor = activeAnim.interpolate({
395
+ inputRange: [0, 1],
396
+ outputRange: [sideFrom.top, sideTo.top]
397
+ });
398
+ } else {
399
+ boxStyle.borderTopColor = activeAnim.interpolate({
400
+ inputRange: [0, 1],
401
+ outputRange: [sideFrom.top, sideTo.top]
402
+ });
403
+ boxStyle.borderRightColor = activeAnim.interpolate({
404
+ inputRange: [0, 1],
405
+ outputRange: [sideFrom.right, sideTo.right]
406
+ });
407
+ boxStyle.borderBottomColor = activeAnim.interpolate({
408
+ inputRange: [0, 1],
409
+ outputRange: [sideFrom.bottom, sideTo.bottom]
410
+ });
411
+ boxStyle.borderLeftColor = activeAnim.interpolate({
412
+ inputRange: [0, 1],
413
+ outputRange: [sideFrom.left, sideTo.left]
414
+ });
415
+ }
416
+ if (width !== undefined) boxStyle.width = width;
417
+ if (height !== undefined) boxStyle.height = height;
418
+ const a11yState = {
419
+ disabled,
420
+ ...accessibilityState
421
+ };
422
+ const innerContent = /*#__PURE__*/_jsxs(_Fragment, {
423
+ children: [leading != null ? /*#__PURE__*/_jsx(View, {
424
+ style: styles.slot,
425
+ children: leading
426
+ }) : null, /*#__PURE__*/_jsx(View, {
427
+ style: styles.content,
428
+ children: children
429
+ }), trailing != null ? /*#__PURE__*/_jsx(View, {
430
+ style: styles.slot,
431
+ children: trailing
432
+ }) : null]
433
+ });
434
+ if (onPress) {
435
+ return /*#__PURE__*/_jsx(Pressable, {
436
+ onPress: onPress,
437
+ disabled: disabled,
438
+ android_ripple: {
439
+ color: theme.colors.surface.pressed,
440
+ borderless: false
441
+ },
442
+ accessibilityRole: accessibilityRole ?? 'button',
443
+ accessibilityLabel: accessibilityLabel,
444
+ accessibilityHint: accessibilityHint,
445
+ accessibilityState: a11yState,
446
+ testID: testID,
447
+ children: ({
448
+ pressed
449
+ }) => /*#__PURE__*/_jsx(Animated.View, {
450
+ style: [styles.box, boxStyle, pressed && !disabled ? {
451
+ backgroundColor: theme.colors.surface.pressed
452
+ } : null, style],
453
+ children: innerContent
454
+ })
455
+ });
456
+ }
457
+ return /*#__PURE__*/_jsx(Animated.View, {
458
+ style: [styles.box, boxStyle, style],
459
+ accessibilityRole: accessibilityRole,
460
+ accessibilityLabel: accessibilityLabel,
461
+ accessibilityHint: accessibilityHint,
462
+ accessibilityState: a11yState,
463
+ testID: testID,
464
+ children: innerContent
465
+ });
466
+ };
467
+ FieldBase.displayName = 'FieldBase';
468
+ const buildStyles = () => StyleSheet.create({
469
+ box: {
470
+ flexDirection: 'row',
471
+ alignItems: 'center',
472
+ overflow: 'visible'
473
+ },
474
+ slot: {
475
+ alignItems: 'center',
476
+ justifyContent: 'center'
477
+ },
478
+ content: {
479
+ flex: 1,
480
+ flexDirection: 'row',
481
+ alignItems: 'center'
482
+ }
483
+ });
484
+ export default FieldBase;
485
+ //# sourceMappingURL=FieldBase.js.map
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { FieldBase, resolveFieldSize, resolveFieldTextStyle, default } from "./FieldBase.js";
4
+ //# sourceMappingURL=index.js.map