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