@retray-dev/ui-kit 6.1.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPONENTS.md +447 -13
- package/EXAMPLES.md +248 -0
- package/README.md +11 -10
- package/dist/Accordion.d.mts +28 -0
- package/dist/Accordion.d.ts +28 -0
- package/dist/Accordion.js +340 -0
- package/dist/Accordion.mjs +6 -0
- package/dist/AlertBanner.d.mts +16 -0
- package/dist/AlertBanner.d.ts +16 -0
- package/dist/AlertBanner.js +247 -0
- package/dist/AlertBanner.mjs +5 -0
- package/dist/Avatar.d.mts +20 -0
- package/dist/Avatar.d.ts +20 -0
- package/dist/Avatar.js +234 -0
- package/dist/Avatar.mjs +3 -0
- package/dist/Badge.d.mts +26 -0
- package/dist/Badge.d.ts +26 -0
- package/dist/Badge.js +247 -0
- package/dist/Badge.mjs +4 -0
- package/dist/Button.d.mts +25 -0
- package/dist/Button.d.ts +25 -0
- package/dist/Button.js +414 -0
- package/dist/Button.mjs +8 -0
- package/dist/ButtonGroup.d.mts +26 -0
- package/dist/ButtonGroup.d.ts +26 -0
- package/dist/ButtonGroup.js +52 -0
- package/dist/ButtonGroup.mjs +2 -0
- package/dist/Card.d.mts +39 -0
- package/dist/Card.d.ts +39 -0
- package/dist/Card.js +329 -0
- package/dist/Card.mjs +7 -0
- package/dist/CategoryStrip.d.mts +26 -0
- package/dist/CategoryStrip.d.ts +26 -0
- package/dist/CategoryStrip.js +396 -0
- package/dist/CategoryStrip.mjs +9 -0
- package/dist/Checkbox.d.mts +14 -0
- package/dist/Checkbox.d.ts +14 -0
- package/dist/Checkbox.js +304 -0
- package/dist/Checkbox.mjs +7 -0
- package/dist/Chip.d.mts +31 -0
- package/dist/Chip.d.ts +31 -0
- package/dist/Chip.js +370 -0
- package/dist/Chip.mjs +8 -0
- package/dist/ConfirmDialog.d.mts +15 -0
- package/dist/ConfirmDialog.d.ts +15 -0
- package/dist/ConfirmDialog.js +530 -0
- package/dist/ConfirmDialog.mjs +9 -0
- package/dist/CurrencyDisplay.d.mts +24 -0
- package/dist/CurrencyDisplay.d.ts +24 -0
- package/dist/CurrencyDisplay.js +189 -0
- package/dist/CurrencyDisplay.mjs +3 -0
- package/dist/CurrencyInput.d.mts +26 -0
- package/dist/CurrencyInput.d.ts +26 -0
- package/dist/CurrencyInput.js +404 -0
- package/dist/CurrencyInput.mjs +7 -0
- package/dist/DetailRow.d.mts +32 -0
- package/dist/DetailRow.d.ts +32 -0
- package/dist/DetailRow.js +275 -0
- package/dist/DetailRow.mjs +4 -0
- package/dist/EmptyState.d.mts +27 -0
- package/dist/EmptyState.d.ts +27 -0
- package/dist/EmptyState.js +503 -0
- package/dist/EmptyState.mjs +9 -0
- package/dist/Form.d.mts +52 -0
- package/dist/Form.d.ts +52 -0
- package/dist/Form.js +204 -0
- package/dist/Form.mjs +3 -0
- package/dist/IconButton.d.mts +22 -0
- package/dist/IconButton.d.ts +22 -0
- package/dist/IconButton.js +383 -0
- package/dist/IconButton.mjs +7 -0
- package/dist/Input.d.mts +23 -0
- package/dist/Input.d.ts +23 -0
- package/dist/Input.js +351 -0
- package/dist/Input.mjs +6 -0
- package/dist/LabelValue.d.mts +16 -0
- package/dist/LabelValue.d.ts +16 -0
- package/dist/LabelValue.js +225 -0
- package/dist/LabelValue.mjs +4 -0
- package/dist/ListGroup.d.mts +34 -0
- package/dist/ListGroup.d.ts +34 -0
- package/dist/ListGroup.js +217 -0
- package/dist/ListGroup.mjs +4 -0
- package/dist/ListItem.d.mts +64 -0
- package/dist/ListItem.d.ts +64 -0
- package/dist/ListItem.js +430 -0
- package/dist/ListItem.mjs +8 -0
- package/dist/MediaCard.d.mts +39 -0
- package/dist/MediaCard.d.ts +39 -0
- package/dist/MediaCard.js +427 -0
- package/dist/MediaCard.mjs +8 -0
- package/dist/MenuGroup.d.mts +34 -0
- package/dist/MenuGroup.d.ts +34 -0
- package/dist/MenuGroup.js +217 -0
- package/dist/MenuGroup.mjs +4 -0
- package/dist/MenuItem.d.mts +48 -0
- package/dist/MenuItem.d.ts +48 -0
- package/dist/MenuItem.js +403 -0
- package/dist/MenuItem.mjs +8 -0
- package/dist/MonthPicker.d.mts +20 -0
- package/dist/MonthPicker.d.ts +20 -0
- package/dist/MonthPicker.js +234 -0
- package/dist/MonthPicker.mjs +4 -0
- package/dist/Pressable.d.mts +34 -0
- package/dist/Pressable.d.ts +34 -0
- package/dist/Pressable.js +132 -0
- package/dist/Pressable.mjs +4 -0
- package/dist/Progress.d.mts +14 -0
- package/dist/Progress.d.ts +14 -0
- package/dist/Progress.js +191 -0
- package/dist/Progress.mjs +4 -0
- package/dist/RadioGroup.d.mts +19 -0
- package/dist/RadioGroup.d.ts +19 -0
- package/dist/RadioGroup.js +341 -0
- package/dist/RadioGroup.mjs +7 -0
- package/dist/Select.d.mts +22 -0
- package/dist/Select.d.ts +22 -0
- package/dist/Select.js +441 -0
- package/dist/Select.mjs +6 -0
- package/dist/Separator.d.mts +10 -0
- package/dist/Separator.d.ts +10 -0
- package/dist/Separator.js +156 -0
- package/dist/Separator.mjs +2 -0
- package/dist/Sheet.d.mts +81 -0
- package/dist/Sheet.d.ts +81 -0
- package/dist/Sheet.js +340 -0
- package/dist/Sheet.mjs +4 -0
- package/dist/Skeleton.d.mts +17 -0
- package/dist/Skeleton.d.ts +17 -0
- package/dist/Skeleton.js +205 -0
- package/dist/Skeleton.mjs +4 -0
- package/dist/Slider.d.mts +20 -0
- package/dist/Slider.d.ts +20 -0
- package/dist/Slider.js +232 -0
- package/dist/Slider.mjs +4 -0
- package/dist/Spinner.d.mts +12 -0
- package/dist/Spinner.d.ts +12 -0
- package/dist/Spinner.js +172 -0
- package/dist/Spinner.mjs +3 -0
- package/dist/Switch.d.mts +13 -0
- package/dist/Switch.d.ts +13 -0
- package/dist/Switch.js +261 -0
- package/dist/Switch.mjs +5 -0
- package/dist/Tabs.d.mts +27 -0
- package/dist/Tabs.d.ts +27 -0
- package/dist/Tabs.js +389 -0
- package/dist/Tabs.mjs +6 -0
- package/dist/Text.d.mts +12 -0
- package/dist/Text.d.ts +12 -0
- package/dist/Text.js +311 -0
- package/dist/Text.mjs +4 -0
- package/dist/Textarea.d.mts +16 -0
- package/dist/Textarea.d.ts +16 -0
- package/dist/Textarea.js +333 -0
- package/dist/Textarea.mjs +6 -0
- package/dist/Toast.d.mts +47 -0
- package/dist/Toast.d.ts +47 -0
- package/dist/Toast.js +185 -0
- package/dist/Toast.mjs +3 -0
- package/dist/Toggle.d.mts +33 -0
- package/dist/Toggle.d.ts +33 -0
- package/dist/Toggle.js +397 -0
- package/dist/Toggle.mjs +8 -0
- package/dist/VirtualList.d.mts +19 -0
- package/dist/VirtualList.d.ts +19 -0
- package/dist/VirtualList.js +38 -0
- package/dist/VirtualList.mjs +1 -0
- package/dist/chunk-2CE3TQVY.mjs +11 -0
- package/dist/chunk-2UYENBLV.mjs +49 -0
- package/dist/chunk-3BBOZ3OQ.mjs +41 -0
- package/dist/chunk-5IKW3VNC.mjs +43 -0
- package/dist/chunk-63357L2X.mjs +51 -0
- package/dist/chunk-6LQYY7HC.mjs +127 -0
- package/dist/chunk-6Q64UFIA.mjs +71 -0
- package/dist/chunk-76PFOSM2.mjs +41 -0
- package/dist/chunk-7H2OR44A.mjs +14 -0
- package/dist/chunk-A4MDAP7G.mjs +42 -0
- package/dist/chunk-AU2VDY4P.mjs +190 -0
- package/dist/chunk-BRKYVJVV.mjs +60 -0
- package/dist/chunk-CRYBX2CM.mjs +146 -0
- package/dist/chunk-DITNP6PL.mjs +106 -0
- package/dist/chunk-FTLJOUOQ.mjs +97 -0
- package/dist/chunk-GCWOGZYL.mjs +104 -0
- package/dist/chunk-GNGLDL6Z.mjs +60 -0
- package/dist/chunk-GPOUINK5.mjs +148 -0
- package/dist/chunk-HSPSMN6U.mjs +115 -0
- package/dist/chunk-IRRY3CRZ.mjs +82 -0
- package/dist/chunk-JB67UOB5.mjs +92 -0
- package/dist/chunk-JBLL7U3U.mjs +64 -0
- package/dist/chunk-KWCPOM6W.mjs +136 -0
- package/dist/chunk-KZJRQOIU.mjs +64 -0
- package/dist/chunk-L7E7TVEZ.mjs +145 -0
- package/dist/chunk-LG4DO3DK.mjs +174 -0
- package/dist/chunk-LWG526VX.mjs +139 -0
- package/dist/chunk-MN7OG7IY.mjs +96 -0
- package/dist/chunk-MX6HRKMI.mjs +29 -0
- package/dist/chunk-NC5ZTR2Y.mjs +32 -0
- package/dist/chunk-NQGVLMWG.mjs +90 -0
- package/dist/chunk-QCNARS3X.mjs +46 -0
- package/dist/chunk-QXGYKWI7.mjs +134 -0
- package/dist/chunk-QY3X2UYR.mjs +191 -0
- package/dist/chunk-RKLHUDZS.mjs +92 -0
- package/dist/chunk-RMMK64W5.mjs +54 -0
- package/dist/chunk-RR2VQLKE.mjs +190 -0
- package/dist/chunk-RTC3CFXF.mjs +29 -0
- package/dist/chunk-SBZYEV4S.mjs +61 -0
- package/dist/chunk-SOA2Z4RB.mjs +82 -0
- package/dist/chunk-SOYNZDVY.mjs +151 -0
- package/dist/chunk-T7XZ7H7Y.mjs +57 -0
- package/dist/chunk-TAJ2PQ2O.mjs +163 -0
- package/dist/chunk-U4N7WF4Z.mjs +108 -0
- package/dist/chunk-URDE3EUU.mjs +132 -0
- package/dist/chunk-URLL5JBR.mjs +245 -0
- package/dist/chunk-XDMN67KV.mjs +59 -0
- package/dist/chunk-Y6MXOREN.mjs +120 -0
- package/dist/chunk-YZJAFS4P.mjs +131 -0
- package/dist/index.d.mts +94 -852
- package/dist/index.d.ts +94 -852
- package/dist/index.js +1387 -942
- package/dist/index.mjs +50 -3844
- package/package.json +23 -14
- package/src/assets/fonts/Sohne-Bold.otf +0 -0
- package/src/assets/fonts/Sohne-BoldItalic.otf +0 -0
- package/src/assets/fonts/Sohne-ExtraBold.otf +0 -0
- package/src/assets/fonts/Sohne-ExtraBoldItalic.otf +0 -0
- package/src/assets/fonts/Sohne-ExtraLight.otf +0 -0
- package/src/assets/fonts/Sohne-ExtraLightItalic.otf +0 -0
- package/src/assets/fonts/Sohne-Italic.otf +0 -0
- package/src/assets/fonts/Sohne-Light.otf +0 -0
- package/src/assets/fonts/Sohne-LightItalic.otf +0 -0
- package/src/assets/fonts/Sohne-Medium.otf +0 -0
- package/src/assets/fonts/Sohne-MediumItalic.otf +0 -0
- package/src/assets/fonts/Sohne-Regular.otf +0 -0
- package/src/assets/fonts/Sohne-SemiBold.otf +0 -0
- package/src/assets/fonts/Sohne-SemiBoldItalic.otf +0 -0
- package/src/assets/fonts/SohneMono-Bold.otf +0 -0
- package/src/assets/fonts/SohneMono-BoldItalic.otf +0 -0
- package/src/assets/fonts/SohneMono-ExtraBold.otf +0 -0
- package/src/assets/fonts/SohneMono-ExtraBoldItalic.otf +0 -0
- package/src/assets/fonts/SohneMono-ExtraLight.otf +0 -0
- package/src/assets/fonts/SohneMono-ExtraLightItalic.otf +0 -0
- package/src/assets/fonts/SohneMono-Italic.otf +0 -0
- package/src/assets/fonts/SohneMono-Light.otf +0 -0
- package/src/assets/fonts/SohneMono-LightItalic.otf +0 -0
- package/src/assets/fonts/SohneMono-Medium.otf +0 -0
- package/src/assets/fonts/SohneMono-MediumItalic.otf +0 -0
- package/src/assets/fonts/SohneMono-Regular.otf +0 -0
- package/src/assets/fonts/SohneMono-SemiBold.otf +0 -0
- package/src/assets/fonts/SohneMono-SemiBoldItalic.otf +0 -0
- package/src/components/Accordion/Accordion.tsx +13 -15
- package/src/components/AlertBanner/AlertBanner.tsx +33 -12
- package/src/components/Avatar/Avatar.tsx +4 -2
- package/src/components/Badge/Badge.tsx +4 -2
- package/src/components/Button/Button.tsx +30 -29
- package/src/components/ButtonGroup/ButtonGroup.tsx +13 -10
- package/src/components/Card/Card.tsx +36 -65
- package/src/components/CategoryStrip/CategoryStrip.tsx +68 -58
- package/src/components/Checkbox/Checkbox.tsx +41 -55
- package/src/components/Chip/Chip.tsx +49 -84
- package/src/components/ConfirmDialog/ConfirmDialog.tsx +2 -2
- package/src/components/CurrencyDisplay/CurrencyDisplay.tsx +4 -2
- package/src/components/CurrencyInput/CurrencyInput.tsx +2 -2
- package/src/components/DetailRow/DetailRow.tsx +9 -7
- package/src/components/EmptyState/EmptyState.tsx +2 -2
- package/src/components/Form/Form.tsx +149 -0
- package/src/components/Form/index.ts +1 -0
- package/src/components/IconButton/IconButton.tsx +24 -20
- package/src/components/Input/Input.tsx +63 -50
- package/src/components/LabelValue/LabelValue.tsx +6 -4
- package/src/components/ListGroup/ListGroup.tsx +145 -0
- package/src/components/ListGroup/index.ts +1 -0
- package/src/components/ListItem/ListItem.tsx +30 -43
- package/src/components/MediaCard/MediaCard.tsx +31 -29
- package/src/components/MenuGroup/MenuGroup.tsx +145 -0
- package/src/components/MenuGroup/index.ts +1 -0
- package/src/components/MenuItem/MenuItem.tsx +29 -40
- package/src/components/MonthPicker/MonthPicker.tsx +14 -4
- package/src/components/Pressable/Pressable.tsx +27 -46
- package/src/components/Progress/Progress.tsx +21 -12
- package/src/components/RadioGroup/RadioGroup.tsx +55 -32
- package/src/components/Select/Select.tsx +23 -21
- package/src/components/Separator/Separator.tsx +1 -3
- package/src/components/Sheet/Sheet.tsx +85 -18
- package/src/components/Skeleton/Skeleton.tsx +25 -14
- package/src/components/Slider/Slider.tsx +13 -3
- package/src/components/Spinner/Spinner.tsx +1 -1
- package/src/components/Switch/Switch.tsx +70 -52
- package/src/components/Tabs/Tabs.tsx +59 -47
- package/src/components/Text/Text.tsx +3 -1
- package/src/components/Textarea/Textarea.tsx +44 -23
- package/src/components/Toast/Toast.tsx +6 -6
- package/src/components/Toggle/Toggle.tsx +86 -68
- package/src/components/VirtualList/VirtualList.tsx +60 -0
- package/src/components/VirtualList/index.ts +1 -0
- package/src/fonts.ts +38 -20
- package/src/index.ts +5 -1
- package/src/theme/colors.ts +53 -39
- package/src/theme/types.ts +3 -0
- package/src/tokens.ts +49 -39
- package/src/utils/animations.ts +58 -0
- package/src/utils/icons.ts +47 -20
- package/src/utils/useColorTransition.ts +40 -0
- package/src/utils/usePressScale.ts +75 -0
- package/src/assets/fonts/Poppins-Black.ttf +0 -0
- package/src/assets/fonts/Poppins-BlackItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-Bold.ttf +0 -0
- package/src/assets/fonts/Poppins-BoldItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-ExtraBold.ttf +0 -0
- package/src/assets/fonts/Poppins-ExtraBoldItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-ExtraLight.ttf +0 -0
- package/src/assets/fonts/Poppins-ExtraLightItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-Italic.ttf +0 -0
- package/src/assets/fonts/Poppins-Light.ttf +0 -0
- package/src/assets/fonts/Poppins-LightItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-Medium.ttf +0 -0
- package/src/assets/fonts/Poppins-MediumItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-Regular.ttf +0 -0
- package/src/assets/fonts/Poppins-SemiBold.ttf +0 -0
- package/src/assets/fonts/Poppins-SemiBoldItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-Thin.ttf +0 -0
- package/src/assets/fonts/Poppins-ThinItalic.ttf +0 -0
package/dist/Form.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React2 = require('react');
|
|
4
|
+
var reactNative = require('react-native');
|
|
5
|
+
var reactNativeSizeMatters = require('react-native-size-matters');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
10
|
+
|
|
11
|
+
// src/components/Form/Form.tsx
|
|
12
|
+
|
|
13
|
+
// src/theme/colorUtils.ts
|
|
14
|
+
function hexToRgb(hex) {
|
|
15
|
+
const clean = hex.replace("#", "");
|
|
16
|
+
const full = clean.length === 3 ? clean.split("").map((c) => c + c).join("") : clean;
|
|
17
|
+
if (full.length !== 6) return null;
|
|
18
|
+
return {
|
|
19
|
+
r: parseInt(full.slice(0, 2), 16),
|
|
20
|
+
g: parseInt(full.slice(2, 4), 16),
|
|
21
|
+
b: parseInt(full.slice(4, 6), 16)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function componentToHex(c) {
|
|
25
|
+
return Math.round(Math.max(0, Math.min(255, c))).toString(16).padStart(2, "0");
|
|
26
|
+
}
|
|
27
|
+
function rgbToHex(r, g, b) {
|
|
28
|
+
return `#${componentToHex(r)}${componentToHex(g)}${componentToHex(b)}`;
|
|
29
|
+
}
|
|
30
|
+
function withAlphaOnWhite(hex, alpha) {
|
|
31
|
+
const rgb = hexToRgb(hex);
|
|
32
|
+
if (!rgb) return hex;
|
|
33
|
+
const r = rgb.r * alpha + 255 * (1 - alpha);
|
|
34
|
+
const g = rgb.g * alpha + 255 * (1 - alpha);
|
|
35
|
+
const b = rgb.b * alpha + 255 * (1 - alpha);
|
|
36
|
+
return rgbToHex(r, g, b);
|
|
37
|
+
}
|
|
38
|
+
function withAlphaOnDark(hex, alpha, bgHex = "#0f0f0f") {
|
|
39
|
+
const rgb = hexToRgb(hex);
|
|
40
|
+
const bg = hexToRgb(bgHex);
|
|
41
|
+
if (!rgb || !bg) return hex;
|
|
42
|
+
const r = rgb.r * alpha + bg.r * (1 - alpha);
|
|
43
|
+
const g = rgb.g * alpha + bg.g * (1 - alpha);
|
|
44
|
+
const b = rgb.b * alpha + bg.b * (1 - alpha);
|
|
45
|
+
return rgbToHex(r, g, b);
|
|
46
|
+
}
|
|
47
|
+
function mixWithBackground(fgHex, bgHex, opacity) {
|
|
48
|
+
const fg = hexToRgb(fgHex);
|
|
49
|
+
const bg = hexToRgb(bgHex);
|
|
50
|
+
if (!fg || !bg) return fgHex;
|
|
51
|
+
const r = fg.r * opacity + bg.r * (1 - opacity);
|
|
52
|
+
const g = fg.g * opacity + bg.g * (1 - opacity);
|
|
53
|
+
const b = fg.b * opacity + bg.b * (1 - opacity);
|
|
54
|
+
return rgbToHex(r, g, b);
|
|
55
|
+
}
|
|
56
|
+
function lighten(hex, amount) {
|
|
57
|
+
return withAlphaOnWhite(hex, 1 - amount);
|
|
58
|
+
}
|
|
59
|
+
function darken(hex, amount) {
|
|
60
|
+
const rgb = hexToRgb(hex);
|
|
61
|
+
if (!rgb) return hex;
|
|
62
|
+
return rgbToHex(rgb.r * (1 - amount), rgb.g * (1 - amount), rgb.b * (1 - amount));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/theme/colors.ts
|
|
66
|
+
var defaultLight = {
|
|
67
|
+
background: "#ffffff",
|
|
68
|
+
foreground: "#1a1a1a",
|
|
69
|
+
card: "#ffffff",
|
|
70
|
+
primary: "#1a1a1a",
|
|
71
|
+
primaryForeground: "#ffffff",
|
|
72
|
+
// AUDIT FIX: brand accent — was undefined; falls back to primary when omitted
|
|
73
|
+
accent: "#d4561d",
|
|
74
|
+
accentForeground: "#ffffff",
|
|
75
|
+
border: "#dddddd",
|
|
76
|
+
// AUDIT FIX: was #e53935 (4.22:1 on white — fails AA); #c72828 = 5.59:1 ✓
|
|
77
|
+
destructive: "#c72828",
|
|
78
|
+
destructiveForeground: "#ffffff",
|
|
79
|
+
success: "#1a7a45",
|
|
80
|
+
successForeground: "#ffffff",
|
|
81
|
+
// AUDIT FIX: was #e67e00 (2.86:1 — severe fail); #9a5200 = 5.86:1 ✓ AAA-near
|
|
82
|
+
warning: "#9a5200",
|
|
83
|
+
warningForeground: "#ffffff"
|
|
84
|
+
};
|
|
85
|
+
function deriveColors(t, scheme) {
|
|
86
|
+
const dark = scheme === "dark";
|
|
87
|
+
const bg = t.background;
|
|
88
|
+
const foregroundSubtle = mixWithBackground(t.foreground, bg, 0.7);
|
|
89
|
+
const foregroundMuted = mixWithBackground(t.foreground, bg, 0.62);
|
|
90
|
+
const surface = dark ? lighten(bg, -0.06) : darken(bg, 0.04);
|
|
91
|
+
const surfaceStrong = dark ? lighten(bg, -0.12) : darken(bg, 0.08);
|
|
92
|
+
const destructiveTint = dark ? withAlphaOnDark(t.destructive, 0.15, bg) : withAlphaOnWhite(t.destructive, 0.08);
|
|
93
|
+
const destructiveBorder = dark ? withAlphaOnDark(t.destructive, 0.45, bg) : withAlphaOnWhite(t.destructive, 0.3);
|
|
94
|
+
const successTint = dark ? withAlphaOnDark(t.success, 0.15, bg) : withAlphaOnWhite(t.success, 0.08);
|
|
95
|
+
const successBorder = dark ? withAlphaOnDark(t.success, 0.45, bg) : withAlphaOnWhite(t.success, 0.3);
|
|
96
|
+
const warningTint = dark ? withAlphaOnDark(t.warning, 0.15, bg) : withAlphaOnWhite(t.warning, 0.08);
|
|
97
|
+
const warningBorder = dark ? withAlphaOnDark(t.warning, 0.45, bg) : withAlphaOnWhite(t.warning, 0.3);
|
|
98
|
+
return {
|
|
99
|
+
...t,
|
|
100
|
+
foregroundSubtle,
|
|
101
|
+
foregroundMuted,
|
|
102
|
+
surface,
|
|
103
|
+
surfaceStrong,
|
|
104
|
+
destructiveTint,
|
|
105
|
+
destructiveBorder,
|
|
106
|
+
successTint,
|
|
107
|
+
successBorder,
|
|
108
|
+
warningTint,
|
|
109
|
+
warningBorder,
|
|
110
|
+
overlay: t.overlay ?? "rgba(0,0,0,0.45)",
|
|
111
|
+
accentResolved: t.accent ?? t.primary,
|
|
112
|
+
accentForegroundResolved: t.accentForeground ?? t.primaryForeground,
|
|
113
|
+
ring: t.accent ?? t.primary,
|
|
114
|
+
input: t.border,
|
|
115
|
+
separator: dark ? lighten(t.border, 0.22) : darken(t.border, 0.16)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/theme/ThemeProvider.tsx
|
|
120
|
+
var ThemeContext = React2.createContext({
|
|
121
|
+
colors: deriveColors(defaultLight, "light"),
|
|
122
|
+
colorScheme: "light"
|
|
123
|
+
});
|
|
124
|
+
function useTheme() {
|
|
125
|
+
const context = React2.useContext(ThemeContext);
|
|
126
|
+
if (!context) {
|
|
127
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
128
|
+
}
|
|
129
|
+
return context;
|
|
130
|
+
}
|
|
131
|
+
var isWeb = reactNative.Platform.OS === "web";
|
|
132
|
+
var s = isWeb ? (n) => n : reactNativeSizeMatters.scale;
|
|
133
|
+
var vs = isWeb ? (n) => n : reactNativeSizeMatters.verticalScale;
|
|
134
|
+
|
|
135
|
+
// src/components/Form/Form.tsx
|
|
136
|
+
function Form({ children, style }) {
|
|
137
|
+
return /* @__PURE__ */ React2__default.default.createElement(reactNative.View, { style: [styles.form, style] }, children);
|
|
138
|
+
}
|
|
139
|
+
function FormField({
|
|
140
|
+
children,
|
|
141
|
+
label,
|
|
142
|
+
error,
|
|
143
|
+
required,
|
|
144
|
+
style,
|
|
145
|
+
labelStyle,
|
|
146
|
+
errorStyle
|
|
147
|
+
}) {
|
|
148
|
+
const { colors } = useTheme();
|
|
149
|
+
return /* @__PURE__ */ React2__default.default.createElement(reactNative.View, { style: [styles.field, style] }, label ? /* @__PURE__ */ React2__default.default.createElement(reactNative.Text, { style: [styles.label, { color: colors.foreground }, labelStyle], allowFontScaling: true }, label, required ? /* @__PURE__ */ React2__default.default.createElement(reactNative.Text, { style: { color: colors.destructive } }, " *") : null) : null, children, error ? /* @__PURE__ */ React2__default.default.createElement(reactNative.Text, { style: [styles.error, { color: colors.destructive }, errorStyle], allowFontScaling: true }, error) : null);
|
|
150
|
+
}
|
|
151
|
+
function FormSection({ children, title, description, style }) {
|
|
152
|
+
const { colors } = useTheme();
|
|
153
|
+
return /* @__PURE__ */ React2__default.default.createElement(reactNative.View, { style: [styles.section, style] }, title ? /* @__PURE__ */ React2__default.default.createElement(reactNative.View, { style: styles.sectionHeader }, /* @__PURE__ */ React2__default.default.createElement(reactNative.Text, { style: [styles.sectionTitle, { color: colors.foreground }], allowFontScaling: true }, title), description ? /* @__PURE__ */ React2__default.default.createElement(reactNative.Text, { style: [styles.sectionDescription, { color: colors.foregroundMuted }], allowFontScaling: true }, description) : null) : null, children);
|
|
154
|
+
}
|
|
155
|
+
function FormFooter({ children, style }) {
|
|
156
|
+
return /* @__PURE__ */ React2__default.default.createElement(reactNative.View, { style: [styles.footer, style] }, children);
|
|
157
|
+
}
|
|
158
|
+
Form.Field = FormField;
|
|
159
|
+
Form.Section = FormSection;
|
|
160
|
+
Form.Footer = FormFooter;
|
|
161
|
+
var styles = reactNative.StyleSheet.create({
|
|
162
|
+
form: {
|
|
163
|
+
gap: vs(16)
|
|
164
|
+
},
|
|
165
|
+
field: {
|
|
166
|
+
gap: vs(6)
|
|
167
|
+
},
|
|
168
|
+
label: {
|
|
169
|
+
fontFamily: "Sohne-Medium",
|
|
170
|
+
fontSize: 14,
|
|
171
|
+
lineHeight: 20
|
|
172
|
+
},
|
|
173
|
+
error: {
|
|
174
|
+
fontFamily: "Sohne-Regular",
|
|
175
|
+
fontSize: 12,
|
|
176
|
+
lineHeight: 16
|
|
177
|
+
},
|
|
178
|
+
section: {
|
|
179
|
+
gap: vs(16)
|
|
180
|
+
},
|
|
181
|
+
sectionHeader: {
|
|
182
|
+
gap: vs(4)
|
|
183
|
+
},
|
|
184
|
+
sectionTitle: {
|
|
185
|
+
fontFamily: "Sohne-SemiBold",
|
|
186
|
+
fontSize: 16,
|
|
187
|
+
lineHeight: 24
|
|
188
|
+
},
|
|
189
|
+
sectionDescription: {
|
|
190
|
+
fontFamily: "Sohne-Regular",
|
|
191
|
+
fontSize: 14,
|
|
192
|
+
lineHeight: 20
|
|
193
|
+
},
|
|
194
|
+
footer: {
|
|
195
|
+
flexDirection: "row",
|
|
196
|
+
gap: s(12),
|
|
197
|
+
paddingTop: vs(8)
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
exports.Form = Form;
|
|
202
|
+
exports.FormField = FormField;
|
|
203
|
+
exports.FormFooter = FormFooter;
|
|
204
|
+
exports.FormSection = FormSection;
|
package/dist/Form.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacityProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type IconButtonVariant = 'primary' | 'secondary' | 'outline' | 'text' | 'destructive';
|
|
5
|
+
type IconButtonSize = 'sm' | 'md' | 'lg';
|
|
6
|
+
interface IconButtonProps extends TouchableOpacityProps {
|
|
7
|
+
iconName?: string;
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
iconColor?: string;
|
|
10
|
+
variant?: IconButtonVariant;
|
|
11
|
+
size?: IconButtonSize;
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Badge overlay. `true` shows a dot. A number shows a count (capped at 99).
|
|
15
|
+
* The dot/count appears top-right of the button.
|
|
16
|
+
*/
|
|
17
|
+
badge?: boolean | number;
|
|
18
|
+
}
|
|
19
|
+
declare function IconButtonBase({ iconName, icon, iconColor, variant, size, loading, badge, disabled, style, onPress, accessibilityLabel, accessibilityHint, ...props }: IconButtonProps): React.JSX.Element;
|
|
20
|
+
declare const IconButton: React.MemoExoticComponent<typeof IconButtonBase>;
|
|
21
|
+
|
|
22
|
+
export { IconButton, type IconButtonProps, type IconButtonSize, type IconButtonVariant };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacityProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type IconButtonVariant = 'primary' | 'secondary' | 'outline' | 'text' | 'destructive';
|
|
5
|
+
type IconButtonSize = 'sm' | 'md' | 'lg';
|
|
6
|
+
interface IconButtonProps extends TouchableOpacityProps {
|
|
7
|
+
iconName?: string;
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
iconColor?: string;
|
|
10
|
+
variant?: IconButtonVariant;
|
|
11
|
+
size?: IconButtonSize;
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Badge overlay. `true` shows a dot. A number shows a count (capped at 99).
|
|
15
|
+
* The dot/count appears top-right of the button.
|
|
16
|
+
*/
|
|
17
|
+
badge?: boolean | number;
|
|
18
|
+
}
|
|
19
|
+
declare function IconButtonBase({ iconName, icon, iconColor, variant, size, loading, badge, disabled, style, onPress, accessibilityLabel, accessibilityHint, ...props }: IconButtonProps): React.JSX.Element;
|
|
20
|
+
declare const IconButton: React.MemoExoticComponent<typeof IconButtonBase>;
|
|
21
|
+
|
|
22
|
+
export { IconButton, type IconButtonProps, type IconButtonSize, type IconButtonVariant };
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React3 = require('react');
|
|
4
|
+
var reactNative = require('react-native');
|
|
5
|
+
var Animated = require('react-native-reanimated');
|
|
6
|
+
var reactNativeSizeMatters = require('react-native-size-matters');
|
|
7
|
+
var AntDesign = require('@expo/vector-icons/AntDesign');
|
|
8
|
+
var Entypo = require('@expo/vector-icons/Entypo');
|
|
9
|
+
var Feather = require('@expo/vector-icons/Feather');
|
|
10
|
+
var FontAwesome5 = require('@expo/vector-icons/FontAwesome5');
|
|
11
|
+
var MaterialIcons = require('@expo/vector-icons/MaterialIcons');
|
|
12
|
+
var Ionicons = require('@expo/vector-icons/Ionicons');
|
|
13
|
+
|
|
14
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
|
|
16
|
+
var React3__default = /*#__PURE__*/_interopDefault(React3);
|
|
17
|
+
var Animated__default = /*#__PURE__*/_interopDefault(Animated);
|
|
18
|
+
var AntDesign__default = /*#__PURE__*/_interopDefault(AntDesign);
|
|
19
|
+
var Entypo__default = /*#__PURE__*/_interopDefault(Entypo);
|
|
20
|
+
var Feather__default = /*#__PURE__*/_interopDefault(Feather);
|
|
21
|
+
var FontAwesome5__default = /*#__PURE__*/_interopDefault(FontAwesome5);
|
|
22
|
+
var MaterialIcons__default = /*#__PURE__*/_interopDefault(MaterialIcons);
|
|
23
|
+
var Ionicons__default = /*#__PURE__*/_interopDefault(Ionicons);
|
|
24
|
+
|
|
25
|
+
// src/components/IconButton/IconButton.tsx
|
|
26
|
+
var _haptics = null;
|
|
27
|
+
async function getHaptics() {
|
|
28
|
+
if (reactNative.Platform.OS === "web") return null;
|
|
29
|
+
if (!_haptics) {
|
|
30
|
+
_haptics = await import('expo-haptics');
|
|
31
|
+
}
|
|
32
|
+
return _haptics;
|
|
33
|
+
}
|
|
34
|
+
function impactLight() {
|
|
35
|
+
if (reactNative.Platform.OS === "web") return;
|
|
36
|
+
getHaptics().then((h) => h?.impactAsync(h.ImpactFeedbackStyle.Light));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/theme/colorUtils.ts
|
|
40
|
+
function hexToRgb(hex) {
|
|
41
|
+
const clean = hex.replace("#", "");
|
|
42
|
+
const full = clean.length === 3 ? clean.split("").map((c) => c + c).join("") : clean;
|
|
43
|
+
if (full.length !== 6) return null;
|
|
44
|
+
return {
|
|
45
|
+
r: parseInt(full.slice(0, 2), 16),
|
|
46
|
+
g: parseInt(full.slice(2, 4), 16),
|
|
47
|
+
b: parseInt(full.slice(4, 6), 16)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function componentToHex(c) {
|
|
51
|
+
return Math.round(Math.max(0, Math.min(255, c))).toString(16).padStart(2, "0");
|
|
52
|
+
}
|
|
53
|
+
function rgbToHex(r, g, b) {
|
|
54
|
+
return `#${componentToHex(r)}${componentToHex(g)}${componentToHex(b)}`;
|
|
55
|
+
}
|
|
56
|
+
function withAlphaOnWhite(hex, alpha) {
|
|
57
|
+
const rgb = hexToRgb(hex);
|
|
58
|
+
if (!rgb) return hex;
|
|
59
|
+
const r = rgb.r * alpha + 255 * (1 - alpha);
|
|
60
|
+
const g = rgb.g * alpha + 255 * (1 - alpha);
|
|
61
|
+
const b = rgb.b * alpha + 255 * (1 - alpha);
|
|
62
|
+
return rgbToHex(r, g, b);
|
|
63
|
+
}
|
|
64
|
+
function withAlphaOnDark(hex, alpha, bgHex = "#0f0f0f") {
|
|
65
|
+
const rgb = hexToRgb(hex);
|
|
66
|
+
const bg = hexToRgb(bgHex);
|
|
67
|
+
if (!rgb || !bg) return hex;
|
|
68
|
+
const r = rgb.r * alpha + bg.r * (1 - alpha);
|
|
69
|
+
const g = rgb.g * alpha + bg.g * (1 - alpha);
|
|
70
|
+
const b = rgb.b * alpha + bg.b * (1 - alpha);
|
|
71
|
+
return rgbToHex(r, g, b);
|
|
72
|
+
}
|
|
73
|
+
function mixWithBackground(fgHex, bgHex, opacity) {
|
|
74
|
+
const fg = hexToRgb(fgHex);
|
|
75
|
+
const bg = hexToRgb(bgHex);
|
|
76
|
+
if (!fg || !bg) return fgHex;
|
|
77
|
+
const r = fg.r * opacity + bg.r * (1 - opacity);
|
|
78
|
+
const g = fg.g * opacity + bg.g * (1 - opacity);
|
|
79
|
+
const b = fg.b * opacity + bg.b * (1 - opacity);
|
|
80
|
+
return rgbToHex(r, g, b);
|
|
81
|
+
}
|
|
82
|
+
function lighten(hex, amount) {
|
|
83
|
+
return withAlphaOnWhite(hex, 1 - amount);
|
|
84
|
+
}
|
|
85
|
+
function darken(hex, amount) {
|
|
86
|
+
const rgb = hexToRgb(hex);
|
|
87
|
+
if (!rgb) return hex;
|
|
88
|
+
return rgbToHex(rgb.r * (1 - amount), rgb.g * (1 - amount), rgb.b * (1 - amount));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/theme/colors.ts
|
|
92
|
+
var defaultLight = {
|
|
93
|
+
background: "#ffffff",
|
|
94
|
+
foreground: "#1a1a1a",
|
|
95
|
+
card: "#ffffff",
|
|
96
|
+
primary: "#1a1a1a",
|
|
97
|
+
primaryForeground: "#ffffff",
|
|
98
|
+
// AUDIT FIX: brand accent — was undefined; falls back to primary when omitted
|
|
99
|
+
accent: "#d4561d",
|
|
100
|
+
accentForeground: "#ffffff",
|
|
101
|
+
border: "#dddddd",
|
|
102
|
+
// AUDIT FIX: was #e53935 (4.22:1 on white — fails AA); #c72828 = 5.59:1 ✓
|
|
103
|
+
destructive: "#c72828",
|
|
104
|
+
destructiveForeground: "#ffffff",
|
|
105
|
+
success: "#1a7a45",
|
|
106
|
+
successForeground: "#ffffff",
|
|
107
|
+
// AUDIT FIX: was #e67e00 (2.86:1 — severe fail); #9a5200 = 5.86:1 ✓ AAA-near
|
|
108
|
+
warning: "#9a5200",
|
|
109
|
+
warningForeground: "#ffffff"
|
|
110
|
+
};
|
|
111
|
+
function deriveColors(t, scheme) {
|
|
112
|
+
const dark = scheme === "dark";
|
|
113
|
+
const bg = t.background;
|
|
114
|
+
const foregroundSubtle = mixWithBackground(t.foreground, bg, 0.7);
|
|
115
|
+
const foregroundMuted = mixWithBackground(t.foreground, bg, 0.62);
|
|
116
|
+
const surface = dark ? lighten(bg, -0.06) : darken(bg, 0.04);
|
|
117
|
+
const surfaceStrong = dark ? lighten(bg, -0.12) : darken(bg, 0.08);
|
|
118
|
+
const destructiveTint = dark ? withAlphaOnDark(t.destructive, 0.15, bg) : withAlphaOnWhite(t.destructive, 0.08);
|
|
119
|
+
const destructiveBorder = dark ? withAlphaOnDark(t.destructive, 0.45, bg) : withAlphaOnWhite(t.destructive, 0.3);
|
|
120
|
+
const successTint = dark ? withAlphaOnDark(t.success, 0.15, bg) : withAlphaOnWhite(t.success, 0.08);
|
|
121
|
+
const successBorder = dark ? withAlphaOnDark(t.success, 0.45, bg) : withAlphaOnWhite(t.success, 0.3);
|
|
122
|
+
const warningTint = dark ? withAlphaOnDark(t.warning, 0.15, bg) : withAlphaOnWhite(t.warning, 0.08);
|
|
123
|
+
const warningBorder = dark ? withAlphaOnDark(t.warning, 0.45, bg) : withAlphaOnWhite(t.warning, 0.3);
|
|
124
|
+
return {
|
|
125
|
+
...t,
|
|
126
|
+
foregroundSubtle,
|
|
127
|
+
foregroundMuted,
|
|
128
|
+
surface,
|
|
129
|
+
surfaceStrong,
|
|
130
|
+
destructiveTint,
|
|
131
|
+
destructiveBorder,
|
|
132
|
+
successTint,
|
|
133
|
+
successBorder,
|
|
134
|
+
warningTint,
|
|
135
|
+
warningBorder,
|
|
136
|
+
overlay: t.overlay ?? "rgba(0,0,0,0.45)",
|
|
137
|
+
accentResolved: t.accent ?? t.primary,
|
|
138
|
+
accentForegroundResolved: t.accentForeground ?? t.primaryForeground,
|
|
139
|
+
ring: t.accent ?? t.primary,
|
|
140
|
+
input: t.border,
|
|
141
|
+
separator: dark ? lighten(t.border, 0.22) : darken(t.border, 0.16)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/theme/ThemeProvider.tsx
|
|
146
|
+
var ThemeContext = React3.createContext({
|
|
147
|
+
colors: deriveColors(defaultLight, "light"),
|
|
148
|
+
colorScheme: "light"
|
|
149
|
+
});
|
|
150
|
+
function useTheme() {
|
|
151
|
+
const context = React3.useContext(ThemeContext);
|
|
152
|
+
if (!context) {
|
|
153
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
154
|
+
}
|
|
155
|
+
return context;
|
|
156
|
+
}
|
|
157
|
+
var isWeb = reactNative.Platform.OS === "web";
|
|
158
|
+
var s = isWeb ? (n) => n : reactNativeSizeMatters.scale;
|
|
159
|
+
var ms = isWeb ? (n, _factor) => n : reactNativeSizeMatters.moderateScale;
|
|
160
|
+
var glyphMapOf = (mod) => mod.glyphMap ?? {};
|
|
161
|
+
var ALL_FAMILIES = [
|
|
162
|
+
{ name: "Ionicons", component: Ionicons__default.default, getGlyphMap: () => glyphMapOf(Ionicons__default.default) },
|
|
163
|
+
{ name: "MaterialIcons", component: MaterialIcons__default.default, getGlyphMap: () => glyphMapOf(MaterialIcons__default.default) },
|
|
164
|
+
{ name: "FontAwesome5", component: FontAwesome5__default.default, getGlyphMap: () => glyphMapOf(FontAwesome5__default.default) },
|
|
165
|
+
{ name: "Entypo", component: Entypo__default.default, getGlyphMap: () => glyphMapOf(Entypo__default.default) },
|
|
166
|
+
{ name: "AntDesign", component: AntDesign__default.default, getGlyphMap: () => glyphMapOf(AntDesign__default.default) },
|
|
167
|
+
{ name: "Feather", component: Feather__default.default, getGlyphMap: () => glyphMapOf(Feather__default.default) }
|
|
168
|
+
];
|
|
169
|
+
var activeFamilies = ALL_FAMILIES;
|
|
170
|
+
var resolvedCache = null;
|
|
171
|
+
function buildCache() {
|
|
172
|
+
const cache = /* @__PURE__ */ new Map();
|
|
173
|
+
for (const family of activeFamilies) {
|
|
174
|
+
const glyphMap = family.getGlyphMap();
|
|
175
|
+
for (const iconName of Object.keys(glyphMap)) {
|
|
176
|
+
cache.set(iconName, family);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return cache;
|
|
180
|
+
}
|
|
181
|
+
function resolveFamily(name) {
|
|
182
|
+
if (!resolvedCache) {
|
|
183
|
+
resolvedCache = buildCache();
|
|
184
|
+
}
|
|
185
|
+
return resolvedCache.get(name) ?? null;
|
|
186
|
+
}
|
|
187
|
+
function Icon({ name, size, color, family }) {
|
|
188
|
+
let resolved = null;
|
|
189
|
+
if (family) {
|
|
190
|
+
resolved = ALL_FAMILIES.find((f) => f.name === family) ?? null;
|
|
191
|
+
} else {
|
|
192
|
+
resolved = resolveFamily(name);
|
|
193
|
+
}
|
|
194
|
+
if (!resolved) return null;
|
|
195
|
+
const Component = resolved.component;
|
|
196
|
+
return React3__default.default.createElement(Component, { name, size, color });
|
|
197
|
+
}
|
|
198
|
+
function renderIcon(name, size, color) {
|
|
199
|
+
return React3__default.default.createElement(Icon, { name, size, color });
|
|
200
|
+
}
|
|
201
|
+
var SPRINGS = {
|
|
202
|
+
/** Tight, premium press feel — Buttons, Toggle, Tabs triggers. */
|
|
203
|
+
pressIn: { stiffness: 600, damping: 35, mass: 0.8 },
|
|
204
|
+
pressOut: { stiffness: 280, damping: 22, mass: 0.8 }};
|
|
205
|
+
({
|
|
206
|
+
/** Material-style ease-out — natural deceleration for state changes. */
|
|
207
|
+
standard: Animated.Easing.bezier(0.2, 0, 0, 1),
|
|
208
|
+
/** Strong ease-out for expanding surfaces (Accordion open). */
|
|
209
|
+
expand: Animated.Easing.bezier(0.23, 1, 0.32, 1),
|
|
210
|
+
/** Quick ease-in for collapsing. */
|
|
211
|
+
collapse: Animated.Easing.in(Animated.Easing.ease)
|
|
212
|
+
});
|
|
213
|
+
var PRESS_SCALE = {
|
|
214
|
+
button: 0.95};
|
|
215
|
+
function useHover() {
|
|
216
|
+
const [hovered, setHovered] = React3.useState(false);
|
|
217
|
+
const onMouseEnter = React3.useCallback(() => setHovered(true), []);
|
|
218
|
+
const onMouseLeave = React3.useCallback(() => setHovered(false), []);
|
|
219
|
+
if (reactNative.Platform.OS !== "web") {
|
|
220
|
+
return { hovered: false, hoverHandlers: {} };
|
|
221
|
+
}
|
|
222
|
+
return { hovered, hoverHandlers: { onMouseEnter, onMouseLeave } };
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/utils/usePressScale.ts
|
|
226
|
+
function usePressScale({
|
|
227
|
+
pressScale = PRESS_SCALE.button,
|
|
228
|
+
hoverScale = 1.02,
|
|
229
|
+
pressInSpring = SPRINGS.pressIn,
|
|
230
|
+
pressOutSpring = SPRINGS.pressOut,
|
|
231
|
+
disabled = false
|
|
232
|
+
} = {}) {
|
|
233
|
+
const scale2 = Animated.useSharedValue(1);
|
|
234
|
+
const { hovered, hoverHandlers } = useHover();
|
|
235
|
+
const onPressIn = React3.useCallback(() => {
|
|
236
|
+
if (disabled) return;
|
|
237
|
+
scale2.value = Animated.withSpring(pressScale, pressInSpring);
|
|
238
|
+
}, [disabled, pressScale, pressInSpring, scale2]);
|
|
239
|
+
const onPressOut = React3.useCallback(() => {
|
|
240
|
+
if (disabled) return;
|
|
241
|
+
scale2.value = Animated.withSpring(1, pressOutSpring);
|
|
242
|
+
}, [disabled, pressOutSpring, scale2]);
|
|
243
|
+
const hoverActive = reactNative.Platform.OS === "web" && hovered && hoverScale !== 1 && !disabled;
|
|
244
|
+
const animatedStyle = Animated.useAnimatedStyle(() => ({
|
|
245
|
+
transform: [
|
|
246
|
+
{ scale: scale2.value * (hoverActive ? hoverScale : 1) }
|
|
247
|
+
]
|
|
248
|
+
}));
|
|
249
|
+
return {
|
|
250
|
+
animatedStyle,
|
|
251
|
+
onPressIn,
|
|
252
|
+
onPressOut,
|
|
253
|
+
hoverHandlers
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// src/components/IconButton/IconButton.tsx
|
|
258
|
+
var sizeMap = {
|
|
259
|
+
sm: { container: s(32), icon: 16 },
|
|
260
|
+
md: { container: s(44), icon: 20 },
|
|
261
|
+
lg: { container: s(52), icon: 24 }
|
|
262
|
+
};
|
|
263
|
+
function IconButtonBase({
|
|
264
|
+
iconName,
|
|
265
|
+
icon,
|
|
266
|
+
iconColor,
|
|
267
|
+
variant = "primary",
|
|
268
|
+
size = "md",
|
|
269
|
+
loading = false,
|
|
270
|
+
badge,
|
|
271
|
+
disabled,
|
|
272
|
+
style,
|
|
273
|
+
onPress,
|
|
274
|
+
accessibilityLabel,
|
|
275
|
+
accessibilityHint,
|
|
276
|
+
...props
|
|
277
|
+
}) {
|
|
278
|
+
const { colors } = useTheme();
|
|
279
|
+
const isDisabled = disabled || loading;
|
|
280
|
+
const { animatedStyle, onPressIn, onPressOut, hoverHandlers } = usePressScale({
|
|
281
|
+
pressScale: PRESS_SCALE.button,
|
|
282
|
+
disabled: isDisabled
|
|
283
|
+
});
|
|
284
|
+
const handlePress = (e) => {
|
|
285
|
+
impactLight();
|
|
286
|
+
onPress?.(e);
|
|
287
|
+
};
|
|
288
|
+
const containerVariantStyle = {
|
|
289
|
+
primary: { backgroundColor: colors.primary },
|
|
290
|
+
secondary: { backgroundColor: colors.surface },
|
|
291
|
+
outline: { backgroundColor: "transparent", borderWidth: 1.5, borderColor: colors.border },
|
|
292
|
+
text: { backgroundColor: "transparent" },
|
|
293
|
+
destructive: { backgroundColor: colors.destructive }
|
|
294
|
+
}[variant];
|
|
295
|
+
const defaultIconColor = {
|
|
296
|
+
primary: colors.primaryForeground,
|
|
297
|
+
secondary: colors.foreground,
|
|
298
|
+
outline: colors.foreground,
|
|
299
|
+
text: colors.foreground,
|
|
300
|
+
destructive: colors.destructiveForeground
|
|
301
|
+
}[variant];
|
|
302
|
+
const spinnerColor = variant === "destructive" ? colors.destructiveForeground : variant === "primary" ? colors.primaryForeground : colors.foreground;
|
|
303
|
+
const { container: containerSize, icon: iconSize } = sizeMap[size];
|
|
304
|
+
const resolvedIcon = iconName ? renderIcon(iconName, iconSize, iconColor ?? defaultIconColor) : icon;
|
|
305
|
+
const showBadge = badge !== void 0 && badge !== false && badge !== 0;
|
|
306
|
+
const badgeCount = typeof badge === "number" ? Math.min(badge, 99) : null;
|
|
307
|
+
const showCount = typeof badge === "number" && badge > 0;
|
|
308
|
+
return /* @__PURE__ */ React3__default.default.createElement(
|
|
309
|
+
Animated__default.default.View,
|
|
310
|
+
{
|
|
311
|
+
style: [styles.wrapper, animatedStyle],
|
|
312
|
+
...hoverHandlers
|
|
313
|
+
},
|
|
314
|
+
/* @__PURE__ */ React3__default.default.createElement(
|
|
315
|
+
reactNative.TouchableOpacity,
|
|
316
|
+
{
|
|
317
|
+
style: [
|
|
318
|
+
styles.base,
|
|
319
|
+
containerVariantStyle,
|
|
320
|
+
{ width: containerSize, height: containerSize },
|
|
321
|
+
isDisabled && styles.disabled,
|
|
322
|
+
style
|
|
323
|
+
],
|
|
324
|
+
disabled: isDisabled,
|
|
325
|
+
activeOpacity: 1,
|
|
326
|
+
touchSoundDisabled: true,
|
|
327
|
+
onPress: handlePress,
|
|
328
|
+
onPressIn,
|
|
329
|
+
onPressOut,
|
|
330
|
+
accessibilityRole: "button",
|
|
331
|
+
accessibilityLabel: accessibilityLabel ?? iconName ?? "icon button",
|
|
332
|
+
accessibilityHint,
|
|
333
|
+
accessibilityState: { disabled: isDisabled, busy: loading },
|
|
334
|
+
...props
|
|
335
|
+
},
|
|
336
|
+
loading ? /* @__PURE__ */ React3__default.default.createElement(reactNative.ActivityIndicator, { size: "small", color: spinnerColor }) : resolvedIcon
|
|
337
|
+
),
|
|
338
|
+
showBadge && /* @__PURE__ */ React3__default.default.createElement(reactNative.View, { style: [
|
|
339
|
+
styles.badge,
|
|
340
|
+
{ backgroundColor: colors.primary },
|
|
341
|
+
showCount ? styles.badgeCount : styles.badgeDot
|
|
342
|
+
] }, showCount && /* @__PURE__ */ React3__default.default.createElement(reactNative.Text, { style: [styles.badgeText, { color: colors.primaryForeground }] }, badgeCount))
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
var IconButton = React3__default.default.memo(IconButtonBase);
|
|
346
|
+
var styles = reactNative.StyleSheet.create({
|
|
347
|
+
wrapper: {
|
|
348
|
+
alignSelf: "flex-start"
|
|
349
|
+
},
|
|
350
|
+
base: {
|
|
351
|
+
borderRadius: 9999,
|
|
352
|
+
alignItems: "center",
|
|
353
|
+
justifyContent: "center"
|
|
354
|
+
},
|
|
355
|
+
disabled: {
|
|
356
|
+
opacity: 0.45
|
|
357
|
+
},
|
|
358
|
+
badge: {
|
|
359
|
+
position: "absolute",
|
|
360
|
+
top: -2,
|
|
361
|
+
right: -2,
|
|
362
|
+
alignItems: "center",
|
|
363
|
+
justifyContent: "center"
|
|
364
|
+
},
|
|
365
|
+
badgeDot: {
|
|
366
|
+
width: 8,
|
|
367
|
+
height: 8,
|
|
368
|
+
borderRadius: 9999
|
|
369
|
+
},
|
|
370
|
+
badgeCount: {
|
|
371
|
+
minWidth: 16,
|
|
372
|
+
height: 16,
|
|
373
|
+
borderRadius: 9999,
|
|
374
|
+
paddingHorizontal: 3
|
|
375
|
+
},
|
|
376
|
+
badgeText: {
|
|
377
|
+
fontFamily: "Sohne-Bold",
|
|
378
|
+
fontSize: ms(9),
|
|
379
|
+
lineHeight: 14
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
exports.IconButton = IconButton;
|
package/dist/Input.d.mts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextInputProps, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
interface InputProps extends TextInputProps {
|
|
5
|
+
label?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
hint?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
prefix?: React.ReactNode;
|
|
10
|
+
suffix?: React.ReactNode;
|
|
11
|
+
prefixStyle?: TextStyle;
|
|
12
|
+
suffixStyle?: TextStyle;
|
|
13
|
+
prefixIcon?: string;
|
|
14
|
+
suffixIcon?: string;
|
|
15
|
+
prefixIconColor?: string;
|
|
16
|
+
suffixIconColor?: string;
|
|
17
|
+
type?: 'text' | 'password';
|
|
18
|
+
containerStyle?: ViewStyle;
|
|
19
|
+
inputWrapperStyle?: ViewStyle;
|
|
20
|
+
}
|
|
21
|
+
declare function Input({ label, error, hint, disabled, prefix, suffix, prefixStyle, suffixStyle, prefixIcon, suffixIcon, prefixIconColor, suffixIconColor, type, containerStyle, inputWrapperStyle, style, onFocus, onBlur, secureTextEntry, editable, accessibilityLabel, ...props }: InputProps): React.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { Input, type InputProps };
|
package/dist/Input.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextInputProps, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
interface InputProps extends TextInputProps {
|
|
5
|
+
label?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
hint?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
prefix?: React.ReactNode;
|
|
10
|
+
suffix?: React.ReactNode;
|
|
11
|
+
prefixStyle?: TextStyle;
|
|
12
|
+
suffixStyle?: TextStyle;
|
|
13
|
+
prefixIcon?: string;
|
|
14
|
+
suffixIcon?: string;
|
|
15
|
+
prefixIconColor?: string;
|
|
16
|
+
suffixIconColor?: string;
|
|
17
|
+
type?: 'text' | 'password';
|
|
18
|
+
containerStyle?: ViewStyle;
|
|
19
|
+
inputWrapperStyle?: ViewStyle;
|
|
20
|
+
}
|
|
21
|
+
declare function Input({ label, error, hint, disabled, prefix, suffix, prefixStyle, suffixStyle, prefixIcon, suffixIcon, prefixIconColor, suffixIconColor, type, containerStyle, inputWrapperStyle, style, onFocus, onBlur, secureTextEntry, editable, accessibilityLabel, ...props }: InputProps): React.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { Input, type InputProps };
|