@onlynative/components 0.1.0-alpha.3 → 0.1.1-alpha.0

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 (42) hide show
  1. package/dist/appbar/index.js +54 -122
  2. package/dist/button/index.js +31 -120
  3. package/dist/card/index.js +20 -89
  4. package/dist/checkbox/index.js +10 -75
  5. package/dist/chip/index.js +29 -118
  6. package/dist/icon-button/index.js +32 -97
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +461 -474
  9. package/dist/keyboard-avoiding-wrapper/index.d.ts +36 -0
  10. package/dist/keyboard-avoiding-wrapper/index.js +98 -0
  11. package/dist/list/index.js +5 -50
  12. package/dist/radio/index.js +8 -35
  13. package/dist/switch/index.js +12 -77
  14. package/dist/text-field/index.js +25 -78
  15. package/package.json +13 -3
  16. package/src/appbar/AppBar.tsx +1 -1
  17. package/src/button/Button.tsx +1 -1
  18. package/src/button/styles.ts +1 -2
  19. package/src/card/styles.ts +1 -2
  20. package/src/checkbox/Checkbox.tsx +1 -1
  21. package/src/checkbox/styles.ts +1 -1
  22. package/src/chip/Chip.tsx +1 -1
  23. package/src/chip/styles.ts +1 -2
  24. package/src/icon-button/IconButton.tsx +5 -2
  25. package/src/icon-button/styles.ts +1 -1
  26. package/src/index.ts +3 -0
  27. package/src/keyboard-avoiding-wrapper/KeyboardAvoidingWrapper.tsx +69 -0
  28. package/src/keyboard-avoiding-wrapper/index.ts +2 -0
  29. package/src/keyboard-avoiding-wrapper/styles.ts +10 -0
  30. package/src/keyboard-avoiding-wrapper/types.ts +37 -0
  31. package/src/list/styles.ts +1 -1
  32. package/src/radio/styles.ts +1 -1
  33. package/src/switch/Switch.tsx +1 -1
  34. package/src/switch/styles.ts +1 -1
  35. package/src/text-field/TextField.tsx +1 -1
  36. package/src/text-field/styles.ts +1 -2
  37. package/src/typography/Typography.tsx +2 -0
  38. package/src/test-utils/render-with-theme.tsx +0 -13
  39. package/src/utils/color.ts +0 -64
  40. package/src/utils/elevation.ts +0 -33
  41. package/src/utils/icon.ts +0 -30
  42. package/src/utils/rtl.ts +0 -19
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(appbar_exports);
26
26
 
27
27
  // src/appbar/AppBar.tsx
28
28
  var import_react3 = require("react");
29
- var import_react_native6 = require("react-native");
29
+ var import_react_native5 = require("react-native");
30
30
  var import_react_native_safe_area_context = require("react-native-safe-area-context");
31
31
  var import_core4 = require("@onlynative/core");
32
32
 
@@ -34,79 +34,14 @@ var import_core4 = require("@onlynative/core");
34
34
  var import_react = require("react");
35
35
  var import_react_native2 = require("react-native");
36
36
  var import_core = require("@onlynative/core");
37
-
38
- // src/utils/icon.ts
39
- var _MCIcons = null;
40
- var _resolved = false;
41
- function getMaterialCommunityIcons() {
42
- if (!_resolved) {
43
- _resolved = true;
44
- try {
45
- const mod = require("@expo/vector-icons/MaterialCommunityIcons");
46
- _MCIcons = mod.default || mod;
47
- } catch {
48
- _MCIcons = null;
49
- }
50
- }
51
- if (!_MCIcons) {
52
- throw new Error(
53
- "@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
54
- );
55
- }
56
- return _MCIcons;
57
- }
37
+ var import_utils2 = require("@onlynative/utils");
58
38
 
59
39
  // src/icon-button/styles.ts
60
40
  var import_react_native = require("react-native");
61
-
62
- // src/utils/color.ts
63
- function parseHexColor(color) {
64
- const normalized = color.replace("#", "");
65
- if (normalized.length !== 6 && normalized.length !== 8) {
66
- return null;
67
- }
68
- const r = Number.parseInt(normalized.slice(0, 2), 16);
69
- const g = Number.parseInt(normalized.slice(2, 4), 16);
70
- const b = Number.parseInt(normalized.slice(4, 6), 16);
71
- if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
72
- return null;
73
- }
74
- return { r, g, b };
75
- }
76
- function clampAlpha(alpha) {
77
- return Math.max(0, Math.min(1, alpha));
78
- }
79
- function alphaColor(color, alpha) {
80
- const channels = parseHexColor(color);
81
- const boundedAlpha = clampAlpha(alpha);
82
- if (!channels) {
83
- return color;
84
- }
85
- return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
86
- }
87
- function blendColor(base, overlay, overlayAlpha) {
88
- const baseChannels = parseHexColor(base);
89
- const overlayChannels = parseHexColor(overlay);
90
- const boundedAlpha = clampAlpha(overlayAlpha);
91
- if (!baseChannels || !overlayChannels) {
92
- return alphaColor(overlay, boundedAlpha);
93
- }
94
- const r = Math.round(
95
- (1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
96
- );
97
- const g = Math.round(
98
- (1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
99
- );
100
- const b = Math.round(
101
- (1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
102
- );
103
- return `rgb(${r}, ${g}, ${b})`;
104
- }
105
-
106
- // src/icon-button/styles.ts
41
+ var import_utils = require("@onlynative/utils");
107
42
  function createStyles(theme) {
108
- const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
109
- const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
43
+ const disabledContainerColor = (0, import_utils.alphaColor)(theme.colors.onSurface, 0.12);
44
+ const disabledOutlineColor = (0, import_utils.alphaColor)(theme.colors.onSurface, 0.12);
110
45
  const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest;
111
46
  return import_react_native.StyleSheet.create({
112
47
  container: {
@@ -174,160 +109,160 @@ function createStyles(theme) {
174
109
  },
175
110
  // Hover states (M3: 8% state layer)
176
111
  hoveredFilled: {
177
- backgroundColor: blendColor(
112
+ backgroundColor: (0, import_utils.blendColor)(
178
113
  theme.colors.primary,
179
114
  theme.colors.onPrimary,
180
115
  theme.stateLayer.hoveredOpacity
181
116
  )
182
117
  },
183
118
  hoveredFilledToggleUnselected: {
184
- backgroundColor: blendColor(
119
+ backgroundColor: (0, import_utils.blendColor)(
185
120
  toggleUnselectedContainerColor,
186
121
  theme.colors.primary,
187
122
  theme.stateLayer.hoveredOpacity
188
123
  )
189
124
  },
190
125
  hoveredFilledToggleSelected: {
191
- backgroundColor: blendColor(
126
+ backgroundColor: (0, import_utils.blendColor)(
192
127
  theme.colors.primary,
193
128
  theme.colors.onPrimary,
194
129
  theme.stateLayer.hoveredOpacity
195
130
  )
196
131
  },
197
132
  hoveredTonal: {
198
- backgroundColor: blendColor(
133
+ backgroundColor: (0, import_utils.blendColor)(
199
134
  theme.colors.secondaryContainer,
200
135
  theme.colors.onSecondaryContainer,
201
136
  theme.stateLayer.hoveredOpacity
202
137
  )
203
138
  },
204
139
  hoveredTonalToggleUnselected: {
205
- backgroundColor: blendColor(
140
+ backgroundColor: (0, import_utils.blendColor)(
206
141
  toggleUnselectedContainerColor,
207
142
  theme.colors.onSurfaceVariant,
208
143
  theme.stateLayer.hoveredOpacity
209
144
  )
210
145
  },
211
146
  hoveredTonalToggleSelected: {
212
- backgroundColor: blendColor(
147
+ backgroundColor: (0, import_utils.blendColor)(
213
148
  theme.colors.secondaryContainer,
214
149
  theme.colors.onSecondaryContainer,
215
150
  theme.stateLayer.hoveredOpacity
216
151
  )
217
152
  },
218
153
  hoveredOutlined: {
219
- backgroundColor: alphaColor(
154
+ backgroundColor: (0, import_utils.alphaColor)(
220
155
  theme.colors.onSurfaceVariant,
221
156
  theme.stateLayer.hoveredOpacity
222
157
  )
223
158
  },
224
159
  hoveredOutlinedToggleUnselected: {
225
- backgroundColor: alphaColor(
160
+ backgroundColor: (0, import_utils.alphaColor)(
226
161
  theme.colors.onSurfaceVariant,
227
162
  theme.stateLayer.hoveredOpacity
228
163
  )
229
164
  },
230
165
  hoveredOutlinedToggleSelected: {
231
- backgroundColor: blendColor(
166
+ backgroundColor: (0, import_utils.blendColor)(
232
167
  theme.colors.inverseSurface,
233
168
  theme.colors.inverseOnSurface,
234
169
  theme.stateLayer.hoveredOpacity
235
170
  )
236
171
  },
237
172
  hoveredStandard: {
238
- backgroundColor: alphaColor(
173
+ backgroundColor: (0, import_utils.alphaColor)(
239
174
  theme.colors.onSurfaceVariant,
240
175
  theme.stateLayer.hoveredOpacity
241
176
  )
242
177
  },
243
178
  hoveredStandardToggleUnselected: {
244
- backgroundColor: alphaColor(
179
+ backgroundColor: (0, import_utils.alphaColor)(
245
180
  theme.colors.onSurfaceVariant,
246
181
  theme.stateLayer.hoveredOpacity
247
182
  )
248
183
  },
249
184
  hoveredStandardToggleSelected: {
250
- backgroundColor: alphaColor(
185
+ backgroundColor: (0, import_utils.alphaColor)(
251
186
  theme.colors.primary,
252
187
  theme.stateLayer.hoveredOpacity
253
188
  )
254
189
  },
255
190
  // Pressed states (M3: 12% state layer)
256
191
  pressedFilled: {
257
- backgroundColor: blendColor(
192
+ backgroundColor: (0, import_utils.blendColor)(
258
193
  theme.colors.primary,
259
194
  theme.colors.onPrimary,
260
195
  theme.stateLayer.pressedOpacity
261
196
  )
262
197
  },
263
198
  pressedFilledToggleUnselected: {
264
- backgroundColor: blendColor(
199
+ backgroundColor: (0, import_utils.blendColor)(
265
200
  toggleUnselectedContainerColor,
266
201
  theme.colors.primary,
267
202
  theme.stateLayer.pressedOpacity
268
203
  )
269
204
  },
270
205
  pressedFilledToggleSelected: {
271
- backgroundColor: blendColor(
206
+ backgroundColor: (0, import_utils.blendColor)(
272
207
  theme.colors.primary,
273
208
  theme.colors.onPrimary,
274
209
  theme.stateLayer.pressedOpacity
275
210
  )
276
211
  },
277
212
  pressedTonal: {
278
- backgroundColor: blendColor(
213
+ backgroundColor: (0, import_utils.blendColor)(
279
214
  theme.colors.secondaryContainer,
280
215
  theme.colors.onSecondaryContainer,
281
216
  theme.stateLayer.pressedOpacity
282
217
  )
283
218
  },
284
219
  pressedTonalToggleUnselected: {
285
- backgroundColor: blendColor(
220
+ backgroundColor: (0, import_utils.blendColor)(
286
221
  toggleUnselectedContainerColor,
287
222
  theme.colors.onSurfaceVariant,
288
223
  theme.stateLayer.pressedOpacity
289
224
  )
290
225
  },
291
226
  pressedTonalToggleSelected: {
292
- backgroundColor: blendColor(
227
+ backgroundColor: (0, import_utils.blendColor)(
293
228
  theme.colors.secondaryContainer,
294
229
  theme.colors.onSecondaryContainer,
295
230
  theme.stateLayer.pressedOpacity
296
231
  )
297
232
  },
298
233
  pressedOutlined: {
299
- backgroundColor: alphaColor(
234
+ backgroundColor: (0, import_utils.alphaColor)(
300
235
  theme.colors.onSurfaceVariant,
301
236
  theme.stateLayer.pressedOpacity
302
237
  )
303
238
  },
304
239
  pressedOutlinedToggleUnselected: {
305
- backgroundColor: alphaColor(
240
+ backgroundColor: (0, import_utils.alphaColor)(
306
241
  theme.colors.onSurfaceVariant,
307
242
  theme.stateLayer.pressedOpacity
308
243
  )
309
244
  },
310
245
  pressedOutlinedToggleSelected: {
311
- backgroundColor: blendColor(
246
+ backgroundColor: (0, import_utils.blendColor)(
312
247
  theme.colors.inverseSurface,
313
248
  theme.colors.inverseOnSurface,
314
249
  theme.stateLayer.pressedOpacity
315
250
  )
316
251
  },
317
252
  pressedStandard: {
318
- backgroundColor: alphaColor(
253
+ backgroundColor: (0, import_utils.alphaColor)(
319
254
  theme.colors.onSurfaceVariant,
320
255
  theme.stateLayer.pressedOpacity
321
256
  )
322
257
  },
323
258
  pressedStandardToggleUnselected: {
324
- backgroundColor: alphaColor(
259
+ backgroundColor: (0, import_utils.alphaColor)(
325
260
  theme.colors.onSurfaceVariant,
326
261
  theme.stateLayer.pressedOpacity
327
262
  )
328
263
  },
329
264
  pressedStandardToggleSelected: {
330
- backgroundColor: alphaColor(
265
+ backgroundColor: (0, import_utils.alphaColor)(
331
266
  theme.colors.primary,
332
267
  theme.stateLayer.pressedOpacity
333
268
  )
@@ -360,7 +295,7 @@ function createStyles(theme) {
360
295
  var import_jsx_runtime = require("react/jsx-runtime");
361
296
  function getIconColor(variant, theme, disabled, isToggle, selected) {
362
297
  if (disabled) {
363
- return alphaColor(theme.colors.onSurface, 0.38);
298
+ return (0, import_utils2.alphaColor)(theme.colors.onSurface, 0.38);
364
299
  }
365
300
  if (isToggle) {
366
301
  if (variant === "filled") {
@@ -510,7 +445,7 @@ function IconButton({
510
445
  ...props
511
446
  }) {
512
447
  var _a;
513
- const MaterialCommunityIcons = getMaterialCommunityIcons();
448
+ const MaterialCommunityIcons = (0, import_utils2.getMaterialCommunityIcons)();
514
449
  const theme = (0, import_core.useTheme)();
515
450
  const styles = (0, import_react.useMemo)(() => createStyles(theme), [theme]);
516
451
  const isDisabled = Boolean(disabled);
@@ -530,14 +465,14 @@ function IconButton({
530
465
  borderWidth: 0
531
466
  },
532
467
  hovered: {
533
- backgroundColor: blendColor(
468
+ backgroundColor: (0, import_utils2.blendColor)(
534
469
  containerColor,
535
470
  overlay,
536
471
  theme.stateLayer.hoveredOpacity
537
472
  )
538
473
  },
539
474
  pressed: {
540
- backgroundColor: blendColor(
475
+ backgroundColor: (0, import_utils2.blendColor)(
541
476
  containerColor,
542
477
  overlay,
543
478
  theme.stateLayer.pressedOpacity
@@ -636,19 +571,16 @@ function Typography({
636
571
  );
637
572
  }
638
573
 
639
- // src/utils/rtl.ts
640
- var import_react_native4 = require("react-native");
641
- function selectRTL(ltr, rtl) {
642
- return import_react_native4.I18nManager.isRTL ? rtl : ltr;
643
- }
574
+ // src/appbar/AppBar.tsx
575
+ var import_utils3 = require("@onlynative/utils");
644
576
 
645
577
  // src/appbar/styles.ts
646
- var import_react_native5 = require("react-native");
578
+ var import_react_native4 = require("react-native");
647
579
  var import_core3 = require("@onlynative/core");
648
580
  function createStyles2(theme) {
649
581
  var _a;
650
582
  const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core3.defaultTopAppBarTokens;
651
- return import_react_native5.StyleSheet.create({
583
+ return import_react_native4.StyleSheet.create({
652
584
  root: {
653
585
  backgroundColor: theme.colors.surface
654
586
  },
@@ -737,10 +669,10 @@ function createStyles2(theme) {
737
669
  // src/appbar/AppBar.tsx
738
670
  var import_jsx_runtime3 = require("react/jsx-runtime");
739
671
  function getBackIcon() {
740
- if (import_react_native6.Platform.OS === "ios") {
741
- return selectRTL("chevron-left", "chevron-right");
672
+ if (import_react_native5.Platform.OS === "ios") {
673
+ return (0, import_utils3.selectRTL)("chevron-left", "chevron-right");
742
674
  }
743
- return selectRTL("arrow-left", "arrow-right");
675
+ return (0, import_utils3.selectRTL)("arrow-left", "arrow-right");
744
676
  }
745
677
  var titleVariantBySize = {
746
678
  small: "titleLarge",
@@ -768,7 +700,7 @@ function withTopInset(enabled, content, style) {
768
700
  if (enabled) {
769
701
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_safe_area_context.SafeAreaView, { edges: ["top"], style, children: content });
770
702
  }
771
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style, children: content });
703
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style, children: content });
772
704
  }
773
705
  function measureWidth(event) {
774
706
  return Math.round(event.nativeEvent.layout.width);
@@ -820,7 +752,7 @@ function AppBar({
820
752
  if (!canGoBack) {
821
753
  return null;
822
754
  }
823
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: styles.iconFrame, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
755
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: styles.iconFrame, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
824
756
  IconButton,
825
757
  {
826
758
  icon: getBackIcon(),
@@ -846,8 +778,8 @@ function AppBar({
846
778
  if (!actions || actions.length === 0) {
847
779
  return null;
848
780
  }
849
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: styles.actionsRow, children: actions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
850
- import_react_native6.View,
781
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: styles.actionsRow, children: actions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
782
+ import_react_native5.View,
851
783
  {
852
784
  style: styles.iconFrame,
853
785
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -884,9 +816,9 @@ function AppBar({
884
816
  return nextWidth;
885
817
  });
886
818
  }, []);
887
- const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native6.View, { style: styles.topRow, children: [
819
+ const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native5.View, { style: styles.topRow, children: [
888
820
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
889
- import_react_native6.View,
821
+ import_react_native5.View,
890
822
  {
891
823
  collapsable: false,
892
824
  onLayout: onLeadingLayout,
@@ -894,9 +826,9 @@ function AppBar({
894
826
  children: leadingContent
895
827
  }
896
828
  ),
897
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: styles.topRowSpacer }),
829
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: styles.topRowSpacer }),
898
830
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
899
- import_react_native6.View,
831
+ import_react_native5.View,
900
832
  {
901
833
  collapsable: false,
902
834
  onLayout: onActionsLayout,
@@ -918,10 +850,10 @@ function AppBar({
918
850
  containerOverride
919
851
  ];
920
852
  if (isExpanded) {
921
- const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native6.View, { style: [styles.expandedContainer, getSizeStyle2(styles, size)], children: [
853
+ const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native5.View, { style: [styles.expandedContainer, getSizeStyle2(styles, size)], children: [
922
854
  topRow,
923
855
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
924
- import_react_native6.View,
856
+ import_react_native5.View,
925
857
  {
926
858
  style: [
927
859
  styles.expandedTitleContainer,
@@ -945,11 +877,11 @@ function AppBar({
945
877
  }
946
878
  )
947
879
  ] });
948
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: rootStyle, children: withTopInset(insetTop, content2, safeAreaStyle) });
880
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: rootStyle, children: withTopInset(insetTop, content2, safeAreaStyle) });
949
881
  }
950
- const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native6.View, { style: styles.smallContainer, children: [
882
+ const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native5.View, { style: styles.smallContainer, children: [
951
883
  topRow,
952
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: [styles.overlayTitleContainer, overlayTitleInsetStyle], children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
884
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: [styles.overlayTitleContainer, overlayTitleInsetStyle], children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
953
885
  Typography,
954
886
  {
955
887
  ...APP_BAR_TITLE_TEXT_PROPS,
@@ -964,7 +896,7 @@ function AppBar({
964
896
  }
965
897
  ) })
966
898
  ] });
967
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: rootStyle, children: withTopInset(insetTop, content, safeAreaStyle) });
899
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: rootStyle, children: withTopInset(insetTop, content, safeAreaStyle) });
968
900
  }
969
901
  // Annotate the CommonJS export names for ESM import in node:
970
902
  0 && (module.exports = {