@onlynative/components 0.1.1-alpha.0 → 0.1.1-alpha.2
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/dist/appbar/index.d.ts +21 -2
- package/dist/appbar/index.js +207 -81
- package/dist/button/index.js +125 -33
- package/dist/card/index.js +88 -20
- package/dist/checkbox/index.js +88 -17
- package/dist/chip/index.js +122 -30
- package/dist/icon-button/index.js +107 -36
- package/dist/index.d.ts +1 -1
- package/dist/index.js +409 -270
- package/dist/list/index.js +71 -24
- package/dist/radio/index.js +43 -14
- package/dist/switch/index.js +90 -19
- package/dist/text-field/index.js +82 -26
- package/package.json +18 -7
- package/src/appbar/AppBar.tsx +0 -302
- package/src/appbar/index.ts +0 -2
- package/src/appbar/styles.ts +0 -92
- package/src/appbar/types.ts +0 -67
- package/src/button/Button.tsx +0 -133
- package/src/button/index.ts +0 -2
- package/src/button/styles.ts +0 -287
- package/src/button/types.ts +0 -42
- package/src/card/Card.tsx +0 -69
- package/src/card/index.ts +0 -2
- package/src/card/styles.ts +0 -150
- package/src/card/types.ts +0 -27
- package/src/checkbox/Checkbox.tsx +0 -113
- package/src/checkbox/index.ts +0 -2
- package/src/checkbox/styles.ts +0 -155
- package/src/checkbox/types.ts +0 -20
- package/src/chip/Chip.tsx +0 -188
- package/src/chip/index.ts +0 -2
- package/src/chip/styles.ts +0 -239
- package/src/chip/types.ts +0 -58
- package/src/icon-button/IconButton.tsx +0 -362
- package/src/icon-button/index.ts +0 -6
- package/src/icon-button/styles.ts +0 -259
- package/src/icon-button/types.ts +0 -55
- package/src/index.ts +0 -54
- package/src/keyboard-avoiding-wrapper/KeyboardAvoidingWrapper.tsx +0 -69
- package/src/keyboard-avoiding-wrapper/index.ts +0 -2
- package/src/keyboard-avoiding-wrapper/styles.ts +0 -10
- package/src/keyboard-avoiding-wrapper/types.ts +0 -37
- package/src/layout/Box.tsx +0 -99
- package/src/layout/Column.tsx +0 -16
- package/src/layout/Grid.tsx +0 -49
- package/src/layout/Layout.tsx +0 -81
- package/src/layout/Row.tsx +0 -22
- package/src/layout/index.ts +0 -13
- package/src/layout/resolveSpacing.ts +0 -11
- package/src/layout/types.ts +0 -82
- package/src/list/List.tsx +0 -17
- package/src/list/ListDivider.tsx +0 -20
- package/src/list/ListItem.tsx +0 -128
- package/src/list/index.ts +0 -9
- package/src/list/styles.ts +0 -132
- package/src/list/types.ts +0 -54
- package/src/radio/Radio.tsx +0 -103
- package/src/radio/index.ts +0 -2
- package/src/radio/styles.ts +0 -139
- package/src/radio/types.ts +0 -20
- package/src/switch/Switch.tsx +0 -121
- package/src/switch/index.ts +0 -2
- package/src/switch/styles.ts +0 -172
- package/src/switch/types.ts +0 -32
- package/src/text-field/TextField.tsx +0 -301
- package/src/text-field/index.ts +0 -2
- package/src/text-field/styles.ts +0 -239
- package/src/text-field/types.ts +0 -49
- package/src/typography/Typography.tsx +0 -79
- package/src/typography/index.ts +0 -3
- package/src/typography/types.ts +0 -17
package/dist/appbar/index.d.ts
CHANGED
|
@@ -6,6 +6,19 @@ import '@expo/vector-icons/MaterialCommunityIcons';
|
|
|
6
6
|
|
|
7
7
|
/** Size/layout variant of the AppBar. */
|
|
8
8
|
type AppBarVariant = 'small' | 'center-aligned' | 'medium' | 'large';
|
|
9
|
+
/**
|
|
10
|
+
* Color scheme that determines the default container and content colors.
|
|
11
|
+
*
|
|
12
|
+
* - `'surface'` — `surface` / `onSurface` (default, elevated uses `surfaceContainer`)
|
|
13
|
+
* - `'surfaceContainerLowest'` — `surfaceContainerLowest` / `onSurface`
|
|
14
|
+
* - `'surfaceContainerLow'` — `surfaceContainerLow` / `onSurface`
|
|
15
|
+
* - `'surfaceContainer'` — `surfaceContainer` / `onSurface`
|
|
16
|
+
* - `'surfaceContainerHigh'` — `surfaceContainerHigh` / `onSurface`
|
|
17
|
+
* - `'surfaceContainerHighest'` — `surfaceContainerHighest` / `onSurface`
|
|
18
|
+
* - `'primary'` — `primary` / `onPrimary`
|
|
19
|
+
* - `'primaryContainer'` — `primaryContainer` / `onPrimaryContainer`
|
|
20
|
+
*/
|
|
21
|
+
type AppBarColorScheme = 'surface' | 'surfaceContainerLowest' | 'surfaceContainerLow' | 'surfaceContainer' | 'surfaceContainerHigh' | 'surfaceContainerHighest' | 'primary' | 'primaryContainer';
|
|
9
22
|
/** A single action item rendered in the AppBar trailing slot. */
|
|
10
23
|
interface AppBarAction {
|
|
11
24
|
/** MaterialCommunityIcons icon name to render. */
|
|
@@ -28,6 +41,12 @@ interface AppBarProps {
|
|
|
28
41
|
* @default 'small'
|
|
29
42
|
*/
|
|
30
43
|
variant?: AppBarVariant;
|
|
44
|
+
/**
|
|
45
|
+
* Color scheme that determines the default container and content colors.
|
|
46
|
+
* `containerColor` and `contentColor` props override these defaults.
|
|
47
|
+
* @default 'surface'
|
|
48
|
+
*/
|
|
49
|
+
colorScheme?: AppBarColorScheme;
|
|
31
50
|
/**
|
|
32
51
|
* When `true`, renders a back button in the leading slot.
|
|
33
52
|
* @default false
|
|
@@ -66,6 +85,6 @@ interface AppBarProps {
|
|
|
66
85
|
style?: StyleProp<ViewStyle>;
|
|
67
86
|
}
|
|
68
87
|
|
|
69
|
-
declare function AppBar({ title, variant, canGoBack, onBackPress, insetTop, elevated, leading, trailing, actions, containerColor, contentColor, titleStyle, style, }: AppBarProps): react_jsx_runtime.JSX.Element;
|
|
88
|
+
declare function AppBar({ title, variant, colorScheme, canGoBack, onBackPress, insetTop, elevated, leading, trailing, actions, containerColor, contentColor, titleStyle, style, }: AppBarProps): react_jsx_runtime.JSX.Element;
|
|
70
89
|
|
|
71
|
-
export { AppBar, type AppBarAction, type AppBarProps, type AppBarVariant };
|
|
90
|
+
export { AppBar, type AppBarAction, type AppBarColorScheme, type AppBarProps, type AppBarVariant };
|
package/dist/appbar/index.js
CHANGED
|
@@ -26,24 +26,98 @@ module.exports = __toCommonJS(appbar_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/appbar/AppBar.tsx
|
|
28
28
|
var import_react3 = require("react");
|
|
29
|
-
var
|
|
29
|
+
var import_react_native7 = 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
|
|
|
33
33
|
// src/icon-button/IconButton.tsx
|
|
34
34
|
var import_react = require("react");
|
|
35
|
-
var
|
|
35
|
+
var import_react_native4 = require("react-native");
|
|
36
36
|
var import_core = require("@onlynative/core");
|
|
37
|
-
var import_utils2 = require("@onlynative/utils");
|
|
38
37
|
|
|
39
|
-
//
|
|
38
|
+
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
39
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
40
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
41
|
+
}) : x)(function(x) {
|
|
42
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
43
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// ../utils/dist/index.mjs
|
|
40
47
|
var import_react_native = require("react-native");
|
|
41
|
-
var
|
|
48
|
+
var import_react_native2 = require("react-native");
|
|
49
|
+
function parseHexColor(color) {
|
|
50
|
+
const normalized = color.replace("#", "");
|
|
51
|
+
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const r = Number.parseInt(normalized.slice(0, 2), 16);
|
|
55
|
+
const g = Number.parseInt(normalized.slice(2, 4), 16);
|
|
56
|
+
const b = Number.parseInt(normalized.slice(4, 6), 16);
|
|
57
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return { r, g, b };
|
|
61
|
+
}
|
|
62
|
+
function clampAlpha(alpha) {
|
|
63
|
+
return Math.max(0, Math.min(1, alpha));
|
|
64
|
+
}
|
|
65
|
+
function alphaColor(color, alpha) {
|
|
66
|
+
const channels = parseHexColor(color);
|
|
67
|
+
const boundedAlpha = clampAlpha(alpha);
|
|
68
|
+
if (!channels) {
|
|
69
|
+
return color;
|
|
70
|
+
}
|
|
71
|
+
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
72
|
+
}
|
|
73
|
+
function blendColor(base, overlay, overlayAlpha) {
|
|
74
|
+
const baseChannels = parseHexColor(base);
|
|
75
|
+
const overlayChannels = parseHexColor(overlay);
|
|
76
|
+
const boundedAlpha = clampAlpha(overlayAlpha);
|
|
77
|
+
if (!baseChannels || !overlayChannels) {
|
|
78
|
+
return alphaColor(overlay, boundedAlpha);
|
|
79
|
+
}
|
|
80
|
+
const r = Math.round(
|
|
81
|
+
(1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
|
|
82
|
+
);
|
|
83
|
+
const g = Math.round(
|
|
84
|
+
(1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
|
|
85
|
+
);
|
|
86
|
+
const b = Math.round(
|
|
87
|
+
(1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
|
|
88
|
+
);
|
|
89
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
90
|
+
}
|
|
91
|
+
var _MCIcons = null;
|
|
92
|
+
var _resolved = false;
|
|
93
|
+
function getMaterialCommunityIcons() {
|
|
94
|
+
if (!_resolved) {
|
|
95
|
+
_resolved = true;
|
|
96
|
+
try {
|
|
97
|
+
const mod = __require("@expo/vector-icons/MaterialCommunityIcons");
|
|
98
|
+
_MCIcons = mod.default || mod;
|
|
99
|
+
} catch {
|
|
100
|
+
_MCIcons = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!_MCIcons) {
|
|
104
|
+
throw new Error(
|
|
105
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return _MCIcons;
|
|
109
|
+
}
|
|
110
|
+
function selectRTL(ltr, rtl) {
|
|
111
|
+
return import_react_native2.I18nManager.isRTL ? rtl : ltr;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/icon-button/styles.ts
|
|
115
|
+
var import_react_native3 = require("react-native");
|
|
42
116
|
function createStyles(theme) {
|
|
43
|
-
const disabledContainerColor =
|
|
44
|
-
const disabledOutlineColor =
|
|
117
|
+
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
118
|
+
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
45
119
|
const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest;
|
|
46
|
-
return
|
|
120
|
+
return import_react_native3.StyleSheet.create({
|
|
47
121
|
container: {
|
|
48
122
|
borderRadius: theme.shape.cornerFull,
|
|
49
123
|
alignItems: "center",
|
|
@@ -109,160 +183,160 @@ function createStyles(theme) {
|
|
|
109
183
|
},
|
|
110
184
|
// Hover states (M3: 8% state layer)
|
|
111
185
|
hoveredFilled: {
|
|
112
|
-
backgroundColor:
|
|
186
|
+
backgroundColor: blendColor(
|
|
113
187
|
theme.colors.primary,
|
|
114
188
|
theme.colors.onPrimary,
|
|
115
189
|
theme.stateLayer.hoveredOpacity
|
|
116
190
|
)
|
|
117
191
|
},
|
|
118
192
|
hoveredFilledToggleUnselected: {
|
|
119
|
-
backgroundColor:
|
|
193
|
+
backgroundColor: blendColor(
|
|
120
194
|
toggleUnselectedContainerColor,
|
|
121
195
|
theme.colors.primary,
|
|
122
196
|
theme.stateLayer.hoveredOpacity
|
|
123
197
|
)
|
|
124
198
|
},
|
|
125
199
|
hoveredFilledToggleSelected: {
|
|
126
|
-
backgroundColor:
|
|
200
|
+
backgroundColor: blendColor(
|
|
127
201
|
theme.colors.primary,
|
|
128
202
|
theme.colors.onPrimary,
|
|
129
203
|
theme.stateLayer.hoveredOpacity
|
|
130
204
|
)
|
|
131
205
|
},
|
|
132
206
|
hoveredTonal: {
|
|
133
|
-
backgroundColor:
|
|
207
|
+
backgroundColor: blendColor(
|
|
134
208
|
theme.colors.secondaryContainer,
|
|
135
209
|
theme.colors.onSecondaryContainer,
|
|
136
210
|
theme.stateLayer.hoveredOpacity
|
|
137
211
|
)
|
|
138
212
|
},
|
|
139
213
|
hoveredTonalToggleUnselected: {
|
|
140
|
-
backgroundColor:
|
|
214
|
+
backgroundColor: blendColor(
|
|
141
215
|
toggleUnselectedContainerColor,
|
|
142
216
|
theme.colors.onSurfaceVariant,
|
|
143
217
|
theme.stateLayer.hoveredOpacity
|
|
144
218
|
)
|
|
145
219
|
},
|
|
146
220
|
hoveredTonalToggleSelected: {
|
|
147
|
-
backgroundColor:
|
|
221
|
+
backgroundColor: blendColor(
|
|
148
222
|
theme.colors.secondaryContainer,
|
|
149
223
|
theme.colors.onSecondaryContainer,
|
|
150
224
|
theme.stateLayer.hoveredOpacity
|
|
151
225
|
)
|
|
152
226
|
},
|
|
153
227
|
hoveredOutlined: {
|
|
154
|
-
backgroundColor:
|
|
228
|
+
backgroundColor: alphaColor(
|
|
155
229
|
theme.colors.onSurfaceVariant,
|
|
156
230
|
theme.stateLayer.hoveredOpacity
|
|
157
231
|
)
|
|
158
232
|
},
|
|
159
233
|
hoveredOutlinedToggleUnselected: {
|
|
160
|
-
backgroundColor:
|
|
234
|
+
backgroundColor: alphaColor(
|
|
161
235
|
theme.colors.onSurfaceVariant,
|
|
162
236
|
theme.stateLayer.hoveredOpacity
|
|
163
237
|
)
|
|
164
238
|
},
|
|
165
239
|
hoveredOutlinedToggleSelected: {
|
|
166
|
-
backgroundColor:
|
|
240
|
+
backgroundColor: blendColor(
|
|
167
241
|
theme.colors.inverseSurface,
|
|
168
242
|
theme.colors.inverseOnSurface,
|
|
169
243
|
theme.stateLayer.hoveredOpacity
|
|
170
244
|
)
|
|
171
245
|
},
|
|
172
246
|
hoveredStandard: {
|
|
173
|
-
backgroundColor:
|
|
247
|
+
backgroundColor: alphaColor(
|
|
174
248
|
theme.colors.onSurfaceVariant,
|
|
175
249
|
theme.stateLayer.hoveredOpacity
|
|
176
250
|
)
|
|
177
251
|
},
|
|
178
252
|
hoveredStandardToggleUnselected: {
|
|
179
|
-
backgroundColor:
|
|
253
|
+
backgroundColor: alphaColor(
|
|
180
254
|
theme.colors.onSurfaceVariant,
|
|
181
255
|
theme.stateLayer.hoveredOpacity
|
|
182
256
|
)
|
|
183
257
|
},
|
|
184
258
|
hoveredStandardToggleSelected: {
|
|
185
|
-
backgroundColor:
|
|
259
|
+
backgroundColor: alphaColor(
|
|
186
260
|
theme.colors.primary,
|
|
187
261
|
theme.stateLayer.hoveredOpacity
|
|
188
262
|
)
|
|
189
263
|
},
|
|
190
264
|
// Pressed states (M3: 12% state layer)
|
|
191
265
|
pressedFilled: {
|
|
192
|
-
backgroundColor:
|
|
266
|
+
backgroundColor: blendColor(
|
|
193
267
|
theme.colors.primary,
|
|
194
268
|
theme.colors.onPrimary,
|
|
195
269
|
theme.stateLayer.pressedOpacity
|
|
196
270
|
)
|
|
197
271
|
},
|
|
198
272
|
pressedFilledToggleUnselected: {
|
|
199
|
-
backgroundColor:
|
|
273
|
+
backgroundColor: blendColor(
|
|
200
274
|
toggleUnselectedContainerColor,
|
|
201
275
|
theme.colors.primary,
|
|
202
276
|
theme.stateLayer.pressedOpacity
|
|
203
277
|
)
|
|
204
278
|
},
|
|
205
279
|
pressedFilledToggleSelected: {
|
|
206
|
-
backgroundColor:
|
|
280
|
+
backgroundColor: blendColor(
|
|
207
281
|
theme.colors.primary,
|
|
208
282
|
theme.colors.onPrimary,
|
|
209
283
|
theme.stateLayer.pressedOpacity
|
|
210
284
|
)
|
|
211
285
|
},
|
|
212
286
|
pressedTonal: {
|
|
213
|
-
backgroundColor:
|
|
287
|
+
backgroundColor: blendColor(
|
|
214
288
|
theme.colors.secondaryContainer,
|
|
215
289
|
theme.colors.onSecondaryContainer,
|
|
216
290
|
theme.stateLayer.pressedOpacity
|
|
217
291
|
)
|
|
218
292
|
},
|
|
219
293
|
pressedTonalToggleUnselected: {
|
|
220
|
-
backgroundColor:
|
|
294
|
+
backgroundColor: blendColor(
|
|
221
295
|
toggleUnselectedContainerColor,
|
|
222
296
|
theme.colors.onSurfaceVariant,
|
|
223
297
|
theme.stateLayer.pressedOpacity
|
|
224
298
|
)
|
|
225
299
|
},
|
|
226
300
|
pressedTonalToggleSelected: {
|
|
227
|
-
backgroundColor:
|
|
301
|
+
backgroundColor: blendColor(
|
|
228
302
|
theme.colors.secondaryContainer,
|
|
229
303
|
theme.colors.onSecondaryContainer,
|
|
230
304
|
theme.stateLayer.pressedOpacity
|
|
231
305
|
)
|
|
232
306
|
},
|
|
233
307
|
pressedOutlined: {
|
|
234
|
-
backgroundColor:
|
|
308
|
+
backgroundColor: alphaColor(
|
|
235
309
|
theme.colors.onSurfaceVariant,
|
|
236
310
|
theme.stateLayer.pressedOpacity
|
|
237
311
|
)
|
|
238
312
|
},
|
|
239
313
|
pressedOutlinedToggleUnselected: {
|
|
240
|
-
backgroundColor:
|
|
314
|
+
backgroundColor: alphaColor(
|
|
241
315
|
theme.colors.onSurfaceVariant,
|
|
242
316
|
theme.stateLayer.pressedOpacity
|
|
243
317
|
)
|
|
244
318
|
},
|
|
245
319
|
pressedOutlinedToggleSelected: {
|
|
246
|
-
backgroundColor:
|
|
320
|
+
backgroundColor: blendColor(
|
|
247
321
|
theme.colors.inverseSurface,
|
|
248
322
|
theme.colors.inverseOnSurface,
|
|
249
323
|
theme.stateLayer.pressedOpacity
|
|
250
324
|
)
|
|
251
325
|
},
|
|
252
326
|
pressedStandard: {
|
|
253
|
-
backgroundColor:
|
|
327
|
+
backgroundColor: alphaColor(
|
|
254
328
|
theme.colors.onSurfaceVariant,
|
|
255
329
|
theme.stateLayer.pressedOpacity
|
|
256
330
|
)
|
|
257
331
|
},
|
|
258
332
|
pressedStandardToggleUnselected: {
|
|
259
|
-
backgroundColor:
|
|
333
|
+
backgroundColor: alphaColor(
|
|
260
334
|
theme.colors.onSurfaceVariant,
|
|
261
335
|
theme.stateLayer.pressedOpacity
|
|
262
336
|
)
|
|
263
337
|
},
|
|
264
338
|
pressedStandardToggleSelected: {
|
|
265
|
-
backgroundColor:
|
|
339
|
+
backgroundColor: alphaColor(
|
|
266
340
|
theme.colors.primary,
|
|
267
341
|
theme.stateLayer.pressedOpacity
|
|
268
342
|
)
|
|
@@ -295,7 +369,7 @@ function createStyles(theme) {
|
|
|
295
369
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
296
370
|
function getIconColor(variant, theme, disabled, isToggle, selected) {
|
|
297
371
|
if (disabled) {
|
|
298
|
-
return
|
|
372
|
+
return alphaColor(theme.colors.onSurface, 0.38);
|
|
299
373
|
}
|
|
300
374
|
if (isToggle) {
|
|
301
375
|
if (variant === "filled") {
|
|
@@ -445,7 +519,7 @@ function IconButton({
|
|
|
445
519
|
...props
|
|
446
520
|
}) {
|
|
447
521
|
var _a;
|
|
448
|
-
const MaterialCommunityIcons =
|
|
522
|
+
const MaterialCommunityIcons = getMaterialCommunityIcons();
|
|
449
523
|
const theme = (0, import_core.useTheme)();
|
|
450
524
|
const styles = (0, import_react.useMemo)(() => createStyles(theme), [theme]);
|
|
451
525
|
const isDisabled = Boolean(disabled);
|
|
@@ -465,14 +539,14 @@ function IconButton({
|
|
|
465
539
|
borderWidth: 0
|
|
466
540
|
},
|
|
467
541
|
hovered: {
|
|
468
|
-
backgroundColor:
|
|
542
|
+
backgroundColor: blendColor(
|
|
469
543
|
containerColor,
|
|
470
544
|
overlay,
|
|
471
545
|
theme.stateLayer.hoveredOpacity
|
|
472
546
|
)
|
|
473
547
|
},
|
|
474
548
|
pressed: {
|
|
475
|
-
backgroundColor:
|
|
549
|
+
backgroundColor: blendColor(
|
|
476
550
|
containerColor,
|
|
477
551
|
overlay,
|
|
478
552
|
theme.stateLayer.pressedOpacity
|
|
@@ -481,7 +555,7 @@ function IconButton({
|
|
|
481
555
|
};
|
|
482
556
|
}, [containerColor, resolvedIconColor, theme.stateLayer]);
|
|
483
557
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
484
|
-
|
|
558
|
+
import_react_native4.Pressable,
|
|
485
559
|
{
|
|
486
560
|
...props,
|
|
487
561
|
accessibilityRole: "button",
|
|
@@ -524,7 +598,7 @@ function IconButton({
|
|
|
524
598
|
|
|
525
599
|
// src/typography/Typography.tsx
|
|
526
600
|
var import_react2 = require("react");
|
|
527
|
-
var
|
|
601
|
+
var import_react_native5 = require("react-native");
|
|
528
602
|
var import_core2 = require("@onlynative/core");
|
|
529
603
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
530
604
|
var HEADING_VARIANTS = /* @__PURE__ */ new Set([
|
|
@@ -540,7 +614,7 @@ function Typography({
|
|
|
540
614
|
variant = "bodyMedium",
|
|
541
615
|
color,
|
|
542
616
|
style,
|
|
543
|
-
as: Component =
|
|
617
|
+
as: Component = import_react_native5.Text,
|
|
544
618
|
accessibilityRole,
|
|
545
619
|
...textProps
|
|
546
620
|
}) {
|
|
@@ -549,7 +623,7 @@ function Typography({
|
|
|
549
623
|
const resolvedRole = accessibilityRole != null ? accessibilityRole : HEADING_VARIANTS.has(variant) ? "header" : void 0;
|
|
550
624
|
const lineHeightFix = (0, import_react2.useMemo)(() => {
|
|
551
625
|
if (!style) return void 0;
|
|
552
|
-
const flat =
|
|
626
|
+
const flat = import_react_native5.StyleSheet.flatten(style);
|
|
553
627
|
if (!(flat == null ? void 0 : flat.fontSize) || flat.lineHeight) return void 0;
|
|
554
628
|
const ratio = typographyStyle.lineHeight / typographyStyle.fontSize;
|
|
555
629
|
return { lineHeight: Math.ceil(flat.fontSize * ratio) };
|
|
@@ -571,27 +645,77 @@ function Typography({
|
|
|
571
645
|
);
|
|
572
646
|
}
|
|
573
647
|
|
|
574
|
-
// src/appbar/AppBar.tsx
|
|
575
|
-
var import_utils3 = require("@onlynative/utils");
|
|
576
|
-
|
|
577
648
|
// src/appbar/styles.ts
|
|
578
|
-
var
|
|
649
|
+
var import_react_native6 = require("react-native");
|
|
579
650
|
var import_core3 = require("@onlynative/core");
|
|
580
|
-
function
|
|
651
|
+
function getColorSchemeColors(theme, colorScheme) {
|
|
652
|
+
switch (colorScheme) {
|
|
653
|
+
case "surfaceContainerLowest":
|
|
654
|
+
return {
|
|
655
|
+
containerColor: theme.colors.surfaceContainerLowest,
|
|
656
|
+
elevatedContainerColor: theme.colors.surfaceContainerLowest,
|
|
657
|
+
contentColor: theme.colors.onSurface
|
|
658
|
+
};
|
|
659
|
+
case "surfaceContainerLow":
|
|
660
|
+
return {
|
|
661
|
+
containerColor: theme.colors.surfaceContainerLow,
|
|
662
|
+
elevatedContainerColor: theme.colors.surfaceContainerLow,
|
|
663
|
+
contentColor: theme.colors.onSurface
|
|
664
|
+
};
|
|
665
|
+
case "surfaceContainer":
|
|
666
|
+
return {
|
|
667
|
+
containerColor: theme.colors.surfaceContainer,
|
|
668
|
+
elevatedContainerColor: theme.colors.surfaceContainer,
|
|
669
|
+
contentColor: theme.colors.onSurface
|
|
670
|
+
};
|
|
671
|
+
case "surfaceContainerHigh":
|
|
672
|
+
return {
|
|
673
|
+
containerColor: theme.colors.surfaceContainerHigh,
|
|
674
|
+
elevatedContainerColor: theme.colors.surfaceContainerHigh,
|
|
675
|
+
contentColor: theme.colors.onSurface
|
|
676
|
+
};
|
|
677
|
+
case "surfaceContainerHighest":
|
|
678
|
+
return {
|
|
679
|
+
containerColor: theme.colors.surfaceContainerHighest,
|
|
680
|
+
elevatedContainerColor: theme.colors.surfaceContainerHighest,
|
|
681
|
+
contentColor: theme.colors.onSurface
|
|
682
|
+
};
|
|
683
|
+
case "primary":
|
|
684
|
+
return {
|
|
685
|
+
containerColor: theme.colors.primary,
|
|
686
|
+
elevatedContainerColor: theme.colors.primary,
|
|
687
|
+
contentColor: theme.colors.onPrimary
|
|
688
|
+
};
|
|
689
|
+
case "primaryContainer":
|
|
690
|
+
return {
|
|
691
|
+
containerColor: theme.colors.primaryContainer,
|
|
692
|
+
elevatedContainerColor: theme.colors.primaryContainer,
|
|
693
|
+
contentColor: theme.colors.onPrimaryContainer
|
|
694
|
+
};
|
|
695
|
+
case "surface":
|
|
696
|
+
default:
|
|
697
|
+
return {
|
|
698
|
+
containerColor: theme.colors.surface,
|
|
699
|
+
elevatedContainerColor: theme.colors.surfaceContainer,
|
|
700
|
+
contentColor: theme.colors.onSurface
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function createStyles2(theme, schemeColors) {
|
|
581
705
|
var _a;
|
|
582
706
|
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core3.defaultTopAppBarTokens;
|
|
583
|
-
return
|
|
707
|
+
return import_react_native6.StyleSheet.create({
|
|
584
708
|
root: {
|
|
585
|
-
backgroundColor:
|
|
709
|
+
backgroundColor: schemeColors.containerColor
|
|
586
710
|
},
|
|
587
711
|
safeArea: {
|
|
588
|
-
backgroundColor:
|
|
712
|
+
backgroundColor: schemeColors.containerColor
|
|
589
713
|
},
|
|
590
714
|
elevatedRoot: {
|
|
591
|
-
backgroundColor:
|
|
715
|
+
backgroundColor: schemeColors.elevatedContainerColor
|
|
592
716
|
},
|
|
593
717
|
elevatedSafeArea: {
|
|
594
|
-
backgroundColor:
|
|
718
|
+
backgroundColor: schemeColors.elevatedContainerColor
|
|
595
719
|
},
|
|
596
720
|
smallContainer: {
|
|
597
721
|
height: topAppBar.smallContainerHeight,
|
|
@@ -669,10 +793,10 @@ function createStyles2(theme) {
|
|
|
669
793
|
// src/appbar/AppBar.tsx
|
|
670
794
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
671
795
|
function getBackIcon() {
|
|
672
|
-
if (
|
|
673
|
-
return
|
|
796
|
+
if (import_react_native7.Platform.OS === "ios") {
|
|
797
|
+
return selectRTL("chevron-left", "chevron-right");
|
|
674
798
|
}
|
|
675
|
-
return
|
|
799
|
+
return selectRTL("arrow-left", "arrow-right");
|
|
676
800
|
}
|
|
677
801
|
var titleVariantBySize = {
|
|
678
802
|
small: "titleLarge",
|
|
@@ -700,7 +824,7 @@ function withTopInset(enabled, content, style) {
|
|
|
700
824
|
if (enabled) {
|
|
701
825
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_safe_area_context.SafeAreaView, { edges: ["top"], style, children: content });
|
|
702
826
|
}
|
|
703
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
827
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style, children: content });
|
|
704
828
|
}
|
|
705
829
|
function measureWidth(event) {
|
|
706
830
|
return Math.round(event.nativeEvent.layout.width);
|
|
@@ -708,6 +832,7 @@ function measureWidth(event) {
|
|
|
708
832
|
function AppBar({
|
|
709
833
|
title,
|
|
710
834
|
variant = "small",
|
|
835
|
+
colorScheme = "surface",
|
|
711
836
|
canGoBack = false,
|
|
712
837
|
onBackPress,
|
|
713
838
|
insetTop = false,
|
|
@@ -723,12 +848,20 @@ function AppBar({
|
|
|
723
848
|
var _a;
|
|
724
849
|
const theme = (0, import_core4.useTheme)();
|
|
725
850
|
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core4.defaultTopAppBarTokens;
|
|
726
|
-
const
|
|
851
|
+
const schemeColors = (0, import_react3.useMemo)(
|
|
852
|
+
() => getColorSchemeColors(theme, colorScheme),
|
|
853
|
+
[theme, colorScheme]
|
|
854
|
+
);
|
|
855
|
+
const resolvedContentColor = contentColor != null ? contentColor : schemeColors.contentColor;
|
|
856
|
+
const styles = (0, import_react3.useMemo)(
|
|
857
|
+
() => createStyles2(theme, schemeColors),
|
|
858
|
+
[theme, schemeColors]
|
|
859
|
+
);
|
|
727
860
|
const [leadingWidth, setLeadingWidth] = (0, import_react3.useState)(0);
|
|
728
861
|
const [actionsWidth, setActionsWidth] = (0, import_react3.useState)(0);
|
|
729
862
|
const titleColorStyle = (0, import_react3.useMemo)(
|
|
730
|
-
() => ({ color:
|
|
731
|
-
[
|
|
863
|
+
() => ({ color: resolvedContentColor }),
|
|
864
|
+
[resolvedContentColor]
|
|
732
865
|
);
|
|
733
866
|
const size = resolveSize(variant);
|
|
734
867
|
const titleVariant = titleVariantBySize[size];
|
|
@@ -752,25 +885,18 @@ function AppBar({
|
|
|
752
885
|
if (!canGoBack) {
|
|
753
886
|
return null;
|
|
754
887
|
}
|
|
755
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: styles.iconFrame, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
756
889
|
IconButton,
|
|
757
890
|
{
|
|
758
891
|
icon: getBackIcon(),
|
|
759
892
|
size: "medium",
|
|
760
893
|
variant: "standard",
|
|
761
|
-
iconColor:
|
|
894
|
+
iconColor: resolvedContentColor,
|
|
762
895
|
accessibilityLabel: "Go back",
|
|
763
896
|
onPress: onBackPress
|
|
764
897
|
}
|
|
765
898
|
) });
|
|
766
|
-
}, [
|
|
767
|
-
canGoBack,
|
|
768
|
-
contentColor,
|
|
769
|
-
leading,
|
|
770
|
-
onBackPress,
|
|
771
|
-
styles.iconFrame,
|
|
772
|
-
theme.colors.onSurface
|
|
773
|
-
]);
|
|
899
|
+
}, [canGoBack, resolvedContentColor, leading, onBackPress, styles.iconFrame]);
|
|
774
900
|
const actionsContent = (0, import_react3.useMemo)(() => {
|
|
775
901
|
if (trailing) {
|
|
776
902
|
return trailing;
|
|
@@ -778,8 +904,8 @@ function AppBar({
|
|
|
778
904
|
if (!actions || actions.length === 0) {
|
|
779
905
|
return null;
|
|
780
906
|
}
|
|
781
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
782
|
-
|
|
907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: styles.actionsRow, children: actions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
908
|
+
import_react_native7.View,
|
|
783
909
|
{
|
|
784
910
|
style: styles.iconFrame,
|
|
785
911
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -788,7 +914,7 @@ function AppBar({
|
|
|
788
914
|
icon: action.icon,
|
|
789
915
|
size: "medium",
|
|
790
916
|
variant: "standard",
|
|
791
|
-
iconColor:
|
|
917
|
+
iconColor: resolvedContentColor,
|
|
792
918
|
accessibilityLabel: action.accessibilityLabel,
|
|
793
919
|
onPress: action.onPress,
|
|
794
920
|
disabled: action.disabled
|
|
@@ -797,7 +923,7 @@ function AppBar({
|
|
|
797
923
|
},
|
|
798
924
|
`${String(action.icon)}-${index}`
|
|
799
925
|
)) });
|
|
800
|
-
}, [actions,
|
|
926
|
+
}, [actions, resolvedContentColor, styles.actionsRow, styles.iconFrame, trailing]);
|
|
801
927
|
const onLeadingLayout = (0, import_react3.useCallback)((event) => {
|
|
802
928
|
const nextWidth = measureWidth(event);
|
|
803
929
|
setLeadingWidth((currentWidth) => {
|
|
@@ -816,9 +942,9 @@ function AppBar({
|
|
|
816
942
|
return nextWidth;
|
|
817
943
|
});
|
|
818
944
|
}, []);
|
|
819
|
-
const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
945
|
+
const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native7.View, { style: styles.topRow, children: [
|
|
820
946
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
821
|
-
|
|
947
|
+
import_react_native7.View,
|
|
822
948
|
{
|
|
823
949
|
collapsable: false,
|
|
824
950
|
onLayout: onLeadingLayout,
|
|
@@ -826,9 +952,9 @@ function AppBar({
|
|
|
826
952
|
children: leadingContent
|
|
827
953
|
}
|
|
828
954
|
),
|
|
829
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
955
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: styles.topRowSpacer }),
|
|
830
956
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
831
|
-
|
|
957
|
+
import_react_native7.View,
|
|
832
958
|
{
|
|
833
959
|
collapsable: false,
|
|
834
960
|
onLayout: onActionsLayout,
|
|
@@ -850,10 +976,10 @@ function AppBar({
|
|
|
850
976
|
containerOverride
|
|
851
977
|
];
|
|
852
978
|
if (isExpanded) {
|
|
853
|
-
const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
979
|
+
const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native7.View, { style: [styles.expandedContainer, getSizeStyle2(styles, size)], children: [
|
|
854
980
|
topRow,
|
|
855
981
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
856
|
-
|
|
982
|
+
import_react_native7.View,
|
|
857
983
|
{
|
|
858
984
|
style: [
|
|
859
985
|
styles.expandedTitleContainer,
|
|
@@ -877,11 +1003,11 @@ function AppBar({
|
|
|
877
1003
|
}
|
|
878
1004
|
)
|
|
879
1005
|
] });
|
|
880
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1006
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: rootStyle, children: withTopInset(insetTop, content2, safeAreaStyle) });
|
|
881
1007
|
}
|
|
882
|
-
const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1008
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native7.View, { style: styles.smallContainer, children: [
|
|
883
1009
|
topRow,
|
|
884
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1010
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: [styles.overlayTitleContainer, overlayTitleInsetStyle], children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
885
1011
|
Typography,
|
|
886
1012
|
{
|
|
887
1013
|
...APP_BAR_TITLE_TEXT_PROPS,
|
|
@@ -896,7 +1022,7 @@ function AppBar({
|
|
|
896
1022
|
}
|
|
897
1023
|
) })
|
|
898
1024
|
] });
|
|
899
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1025
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: rootStyle, children: withTopInset(insetTop, content, safeAreaStyle) });
|
|
900
1026
|
}
|
|
901
1027
|
// Annotate the CommonJS export names for ESM import in node:
|
|
902
1028
|
0 && (module.exports = {
|