@onlynative/components 0.0.0-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.
- package/README.md +105 -0
- package/dist/appbar/index.d.ts +90 -0
- package/dist/appbar/index.js +1030 -0
- package/dist/avatar/index.d.ts +46 -0
- package/dist/avatar/index.js +250 -0
- package/dist/button/index.d.ts +41 -0
- package/dist/button/index.js +468 -0
- package/dist/card/index.d.ts +31 -0
- package/dist/card/index.js +263 -0
- package/dist/checkbox/index.d.ts +25 -0
- package/dist/checkbox/index.js +308 -0
- package/dist/chip/index.d.ts +62 -0
- package/dist/chip/index.js +467 -0
- package/dist/icon-button/index.d.ts +10 -0
- package/dist/icon-button/index.js +592 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +3681 -0
- package/dist/keyboard-avoiding-wrapper/index.d.ts +36 -0
- package/dist/keyboard-avoiding-wrapper/index.js +98 -0
- package/dist/layout/index.d.ts +98 -0
- package/dist/layout/index.js +282 -0
- package/dist/list/index.d.ts +60 -0
- package/dist/list/index.js +302 -0
- package/dist/radio/index.d.ts +25 -0
- package/dist/radio/index.js +252 -0
- package/dist/switch/index.d.ts +37 -0
- package/dist/switch/index.js +332 -0
- package/dist/text-field/index.d.ts +52 -0
- package/dist/text-field/index.js +510 -0
- package/dist/types-D3hlyvz-.d.ts +51 -0
- package/dist/typography/index.d.ts +28 -0
- package/dist/typography/index.js +78 -0
- package/llms.txt +458 -0
- package/package.json +202 -0
|
@@ -0,0 +1,1030 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/appbar/index.ts
|
|
21
|
+
var appbar_exports = {};
|
|
22
|
+
__export(appbar_exports, {
|
|
23
|
+
AppBar: () => AppBar
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(appbar_exports);
|
|
26
|
+
|
|
27
|
+
// src/appbar/AppBar.tsx
|
|
28
|
+
var import_react3 = require("react");
|
|
29
|
+
var import_react_native7 = require("react-native");
|
|
30
|
+
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
31
|
+
var import_core4 = require("@onlynative/core");
|
|
32
|
+
|
|
33
|
+
// src/icon-button/IconButton.tsx
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
var import_react_native4 = require("react-native");
|
|
36
|
+
var import_core = require("@onlynative/core");
|
|
37
|
+
|
|
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
|
|
47
|
+
var import_react_native = require("react-native");
|
|
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");
|
|
116
|
+
function createStyles(theme) {
|
|
117
|
+
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
118
|
+
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
119
|
+
const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest;
|
|
120
|
+
return import_react_native3.StyleSheet.create({
|
|
121
|
+
container: {
|
|
122
|
+
borderRadius: theme.shape.cornerFull,
|
|
123
|
+
alignItems: "center",
|
|
124
|
+
justifyContent: "center",
|
|
125
|
+
cursor: "pointer"
|
|
126
|
+
},
|
|
127
|
+
sizeSmall: {
|
|
128
|
+
width: 32,
|
|
129
|
+
height: 32
|
|
130
|
+
},
|
|
131
|
+
sizeMedium: {
|
|
132
|
+
width: 40,
|
|
133
|
+
height: 40
|
|
134
|
+
},
|
|
135
|
+
sizeLarge: {
|
|
136
|
+
width: 48,
|
|
137
|
+
height: 48
|
|
138
|
+
},
|
|
139
|
+
colorFilled: {
|
|
140
|
+
backgroundColor: theme.colors.primary,
|
|
141
|
+
borderColor: theme.colors.primary,
|
|
142
|
+
borderWidth: 0
|
|
143
|
+
},
|
|
144
|
+
colorFilledToggleUnselected: {
|
|
145
|
+
backgroundColor: toggleUnselectedContainerColor,
|
|
146
|
+
borderColor: toggleUnselectedContainerColor,
|
|
147
|
+
borderWidth: 0
|
|
148
|
+
},
|
|
149
|
+
colorFilledToggleSelected: {
|
|
150
|
+
backgroundColor: theme.colors.primary,
|
|
151
|
+
borderColor: theme.colors.primary,
|
|
152
|
+
borderWidth: 0
|
|
153
|
+
},
|
|
154
|
+
colorTonal: {
|
|
155
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
156
|
+
borderColor: theme.colors.secondaryContainer,
|
|
157
|
+
borderWidth: 0
|
|
158
|
+
},
|
|
159
|
+
colorTonalToggleUnselected: {
|
|
160
|
+
backgroundColor: toggleUnselectedContainerColor,
|
|
161
|
+
borderColor: toggleUnselectedContainerColor,
|
|
162
|
+
borderWidth: 0
|
|
163
|
+
},
|
|
164
|
+
colorTonalToggleSelected: {
|
|
165
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
166
|
+
borderColor: theme.colors.secondaryContainer,
|
|
167
|
+
borderWidth: 0
|
|
168
|
+
},
|
|
169
|
+
colorOutlined: {
|
|
170
|
+
borderColor: theme.colors.outline,
|
|
171
|
+
borderWidth: 1
|
|
172
|
+
},
|
|
173
|
+
colorOutlinedToggleSelected: {
|
|
174
|
+
backgroundColor: theme.colors.inverseSurface,
|
|
175
|
+
borderColor: theme.colors.inverseSurface,
|
|
176
|
+
borderWidth: 0
|
|
177
|
+
},
|
|
178
|
+
colorStandard: {
|
|
179
|
+
borderWidth: 0
|
|
180
|
+
},
|
|
181
|
+
colorStandardToggleSelected: {
|
|
182
|
+
borderWidth: 0
|
|
183
|
+
},
|
|
184
|
+
// Hover states (M3: 8% state layer)
|
|
185
|
+
hoveredFilled: {
|
|
186
|
+
backgroundColor: blendColor(
|
|
187
|
+
theme.colors.primary,
|
|
188
|
+
theme.colors.onPrimary,
|
|
189
|
+
theme.stateLayer.hoveredOpacity
|
|
190
|
+
)
|
|
191
|
+
},
|
|
192
|
+
hoveredFilledToggleUnselected: {
|
|
193
|
+
backgroundColor: blendColor(
|
|
194
|
+
toggleUnselectedContainerColor,
|
|
195
|
+
theme.colors.primary,
|
|
196
|
+
theme.stateLayer.hoveredOpacity
|
|
197
|
+
)
|
|
198
|
+
},
|
|
199
|
+
hoveredFilledToggleSelected: {
|
|
200
|
+
backgroundColor: blendColor(
|
|
201
|
+
theme.colors.primary,
|
|
202
|
+
theme.colors.onPrimary,
|
|
203
|
+
theme.stateLayer.hoveredOpacity
|
|
204
|
+
)
|
|
205
|
+
},
|
|
206
|
+
hoveredTonal: {
|
|
207
|
+
backgroundColor: blendColor(
|
|
208
|
+
theme.colors.secondaryContainer,
|
|
209
|
+
theme.colors.onSecondaryContainer,
|
|
210
|
+
theme.stateLayer.hoveredOpacity
|
|
211
|
+
)
|
|
212
|
+
},
|
|
213
|
+
hoveredTonalToggleUnselected: {
|
|
214
|
+
backgroundColor: blendColor(
|
|
215
|
+
toggleUnselectedContainerColor,
|
|
216
|
+
theme.colors.onSurfaceVariant,
|
|
217
|
+
theme.stateLayer.hoveredOpacity
|
|
218
|
+
)
|
|
219
|
+
},
|
|
220
|
+
hoveredTonalToggleSelected: {
|
|
221
|
+
backgroundColor: blendColor(
|
|
222
|
+
theme.colors.secondaryContainer,
|
|
223
|
+
theme.colors.onSecondaryContainer,
|
|
224
|
+
theme.stateLayer.hoveredOpacity
|
|
225
|
+
)
|
|
226
|
+
},
|
|
227
|
+
hoveredOutlined: {
|
|
228
|
+
backgroundColor: alphaColor(
|
|
229
|
+
theme.colors.onSurfaceVariant,
|
|
230
|
+
theme.stateLayer.hoveredOpacity
|
|
231
|
+
)
|
|
232
|
+
},
|
|
233
|
+
hoveredOutlinedToggleUnselected: {
|
|
234
|
+
backgroundColor: alphaColor(
|
|
235
|
+
theme.colors.onSurfaceVariant,
|
|
236
|
+
theme.stateLayer.hoveredOpacity
|
|
237
|
+
)
|
|
238
|
+
},
|
|
239
|
+
hoveredOutlinedToggleSelected: {
|
|
240
|
+
backgroundColor: blendColor(
|
|
241
|
+
theme.colors.inverseSurface,
|
|
242
|
+
theme.colors.inverseOnSurface,
|
|
243
|
+
theme.stateLayer.hoveredOpacity
|
|
244
|
+
)
|
|
245
|
+
},
|
|
246
|
+
hoveredStandard: {
|
|
247
|
+
backgroundColor: alphaColor(
|
|
248
|
+
theme.colors.onSurfaceVariant,
|
|
249
|
+
theme.stateLayer.hoveredOpacity
|
|
250
|
+
)
|
|
251
|
+
},
|
|
252
|
+
hoveredStandardToggleUnselected: {
|
|
253
|
+
backgroundColor: alphaColor(
|
|
254
|
+
theme.colors.onSurfaceVariant,
|
|
255
|
+
theme.stateLayer.hoveredOpacity
|
|
256
|
+
)
|
|
257
|
+
},
|
|
258
|
+
hoveredStandardToggleSelected: {
|
|
259
|
+
backgroundColor: alphaColor(
|
|
260
|
+
theme.colors.primary,
|
|
261
|
+
theme.stateLayer.hoveredOpacity
|
|
262
|
+
)
|
|
263
|
+
},
|
|
264
|
+
// Pressed states (M3: 12% state layer)
|
|
265
|
+
pressedFilled: {
|
|
266
|
+
backgroundColor: blendColor(
|
|
267
|
+
theme.colors.primary,
|
|
268
|
+
theme.colors.onPrimary,
|
|
269
|
+
theme.stateLayer.pressedOpacity
|
|
270
|
+
)
|
|
271
|
+
},
|
|
272
|
+
pressedFilledToggleUnselected: {
|
|
273
|
+
backgroundColor: blendColor(
|
|
274
|
+
toggleUnselectedContainerColor,
|
|
275
|
+
theme.colors.primary,
|
|
276
|
+
theme.stateLayer.pressedOpacity
|
|
277
|
+
)
|
|
278
|
+
},
|
|
279
|
+
pressedFilledToggleSelected: {
|
|
280
|
+
backgroundColor: blendColor(
|
|
281
|
+
theme.colors.primary,
|
|
282
|
+
theme.colors.onPrimary,
|
|
283
|
+
theme.stateLayer.pressedOpacity
|
|
284
|
+
)
|
|
285
|
+
},
|
|
286
|
+
pressedTonal: {
|
|
287
|
+
backgroundColor: blendColor(
|
|
288
|
+
theme.colors.secondaryContainer,
|
|
289
|
+
theme.colors.onSecondaryContainer,
|
|
290
|
+
theme.stateLayer.pressedOpacity
|
|
291
|
+
)
|
|
292
|
+
},
|
|
293
|
+
pressedTonalToggleUnselected: {
|
|
294
|
+
backgroundColor: blendColor(
|
|
295
|
+
toggleUnselectedContainerColor,
|
|
296
|
+
theme.colors.onSurfaceVariant,
|
|
297
|
+
theme.stateLayer.pressedOpacity
|
|
298
|
+
)
|
|
299
|
+
},
|
|
300
|
+
pressedTonalToggleSelected: {
|
|
301
|
+
backgroundColor: blendColor(
|
|
302
|
+
theme.colors.secondaryContainer,
|
|
303
|
+
theme.colors.onSecondaryContainer,
|
|
304
|
+
theme.stateLayer.pressedOpacity
|
|
305
|
+
)
|
|
306
|
+
},
|
|
307
|
+
pressedOutlined: {
|
|
308
|
+
backgroundColor: alphaColor(
|
|
309
|
+
theme.colors.onSurfaceVariant,
|
|
310
|
+
theme.stateLayer.pressedOpacity
|
|
311
|
+
)
|
|
312
|
+
},
|
|
313
|
+
pressedOutlinedToggleUnselected: {
|
|
314
|
+
backgroundColor: alphaColor(
|
|
315
|
+
theme.colors.onSurfaceVariant,
|
|
316
|
+
theme.stateLayer.pressedOpacity
|
|
317
|
+
)
|
|
318
|
+
},
|
|
319
|
+
pressedOutlinedToggleSelected: {
|
|
320
|
+
backgroundColor: blendColor(
|
|
321
|
+
theme.colors.inverseSurface,
|
|
322
|
+
theme.colors.inverseOnSurface,
|
|
323
|
+
theme.stateLayer.pressedOpacity
|
|
324
|
+
)
|
|
325
|
+
},
|
|
326
|
+
pressedStandard: {
|
|
327
|
+
backgroundColor: alphaColor(
|
|
328
|
+
theme.colors.onSurfaceVariant,
|
|
329
|
+
theme.stateLayer.pressedOpacity
|
|
330
|
+
)
|
|
331
|
+
},
|
|
332
|
+
pressedStandardToggleUnselected: {
|
|
333
|
+
backgroundColor: alphaColor(
|
|
334
|
+
theme.colors.onSurfaceVariant,
|
|
335
|
+
theme.stateLayer.pressedOpacity
|
|
336
|
+
)
|
|
337
|
+
},
|
|
338
|
+
pressedStandardToggleSelected: {
|
|
339
|
+
backgroundColor: alphaColor(
|
|
340
|
+
theme.colors.primary,
|
|
341
|
+
theme.stateLayer.pressedOpacity
|
|
342
|
+
)
|
|
343
|
+
},
|
|
344
|
+
// Disabled states
|
|
345
|
+
disabledFilled: {
|
|
346
|
+
backgroundColor: disabledContainerColor,
|
|
347
|
+
borderColor: disabledContainerColor,
|
|
348
|
+
cursor: "auto"
|
|
349
|
+
},
|
|
350
|
+
disabledTonal: {
|
|
351
|
+
backgroundColor: disabledContainerColor,
|
|
352
|
+
borderColor: disabledContainerColor,
|
|
353
|
+
cursor: "auto"
|
|
354
|
+
},
|
|
355
|
+
disabledOutlined: {
|
|
356
|
+
backgroundColor: "transparent",
|
|
357
|
+
borderColor: disabledOutlineColor,
|
|
358
|
+
cursor: "auto"
|
|
359
|
+
},
|
|
360
|
+
disabledStandard: {
|
|
361
|
+
backgroundColor: "transparent",
|
|
362
|
+
borderColor: "transparent",
|
|
363
|
+
cursor: "auto"
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/icon-button/IconButton.tsx
|
|
369
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
370
|
+
function getIconColor(variant, theme, disabled, isToggle, selected) {
|
|
371
|
+
if (disabled) {
|
|
372
|
+
return alphaColor(theme.colors.onSurface, 0.38);
|
|
373
|
+
}
|
|
374
|
+
if (isToggle) {
|
|
375
|
+
if (variant === "filled") {
|
|
376
|
+
return selected ? theme.colors.onPrimary : theme.colors.primary;
|
|
377
|
+
}
|
|
378
|
+
if (variant === "tonal") {
|
|
379
|
+
return selected ? theme.colors.onSecondaryContainer : theme.colors.onSurfaceVariant;
|
|
380
|
+
}
|
|
381
|
+
if (variant === "outlined") {
|
|
382
|
+
return selected ? theme.colors.inverseOnSurface : theme.colors.onSurfaceVariant;
|
|
383
|
+
}
|
|
384
|
+
return selected ? theme.colors.primary : theme.colors.onSurfaceVariant;
|
|
385
|
+
}
|
|
386
|
+
if (variant === "filled") {
|
|
387
|
+
return theme.colors.onPrimary;
|
|
388
|
+
}
|
|
389
|
+
if (variant === "tonal") {
|
|
390
|
+
return theme.colors.onSecondaryContainer;
|
|
391
|
+
}
|
|
392
|
+
return theme.colors.onSurfaceVariant;
|
|
393
|
+
}
|
|
394
|
+
function getColorStyle(styles, variant, isToggle, selected) {
|
|
395
|
+
if (isToggle) {
|
|
396
|
+
if (variant === "tonal") {
|
|
397
|
+
return selected ? styles.colorTonalToggleSelected : styles.colorTonalToggleUnselected;
|
|
398
|
+
}
|
|
399
|
+
if (variant === "outlined") {
|
|
400
|
+
return selected ? styles.colorOutlinedToggleSelected : styles.colorOutlined;
|
|
401
|
+
}
|
|
402
|
+
if (variant === "standard") {
|
|
403
|
+
return selected ? styles.colorStandardToggleSelected : styles.colorStandard;
|
|
404
|
+
}
|
|
405
|
+
return selected ? styles.colorFilledToggleSelected : styles.colorFilledToggleUnselected;
|
|
406
|
+
}
|
|
407
|
+
if (variant === "tonal") {
|
|
408
|
+
return styles.colorTonal;
|
|
409
|
+
}
|
|
410
|
+
if (variant === "outlined") {
|
|
411
|
+
return styles.colorOutlined;
|
|
412
|
+
}
|
|
413
|
+
if (variant === "standard") {
|
|
414
|
+
return styles.colorStandard;
|
|
415
|
+
}
|
|
416
|
+
return styles.colorFilled;
|
|
417
|
+
}
|
|
418
|
+
function getSizeStyle(styles, size) {
|
|
419
|
+
if (size === "small") {
|
|
420
|
+
return styles.sizeSmall;
|
|
421
|
+
}
|
|
422
|
+
if (size === "large") {
|
|
423
|
+
return styles.sizeLarge;
|
|
424
|
+
}
|
|
425
|
+
return styles.sizeMedium;
|
|
426
|
+
}
|
|
427
|
+
function getIconPixelSize(size) {
|
|
428
|
+
if (size === "small") {
|
|
429
|
+
return 18;
|
|
430
|
+
}
|
|
431
|
+
if (size === "large") {
|
|
432
|
+
return 28;
|
|
433
|
+
}
|
|
434
|
+
return 24;
|
|
435
|
+
}
|
|
436
|
+
function getDefaultHitSlop(size) {
|
|
437
|
+
if (size === "small") {
|
|
438
|
+
return 8;
|
|
439
|
+
}
|
|
440
|
+
if (size === "large") {
|
|
441
|
+
return 0;
|
|
442
|
+
}
|
|
443
|
+
return 4;
|
|
444
|
+
}
|
|
445
|
+
function getHoveredStyle(styles, variant, isToggle, selected) {
|
|
446
|
+
if (isToggle) {
|
|
447
|
+
if (variant === "tonal") {
|
|
448
|
+
return selected ? styles.hoveredTonalToggleSelected : styles.hoveredTonalToggleUnselected;
|
|
449
|
+
}
|
|
450
|
+
if (variant === "outlined") {
|
|
451
|
+
return selected ? styles.hoveredOutlinedToggleSelected : styles.hoveredOutlinedToggleUnselected;
|
|
452
|
+
}
|
|
453
|
+
if (variant === "standard") {
|
|
454
|
+
return selected ? styles.hoveredStandardToggleSelected : styles.hoveredStandardToggleUnselected;
|
|
455
|
+
}
|
|
456
|
+
return selected ? styles.hoveredFilledToggleSelected : styles.hoveredFilledToggleUnselected;
|
|
457
|
+
}
|
|
458
|
+
if (variant === "tonal") {
|
|
459
|
+
return styles.hoveredTonal;
|
|
460
|
+
}
|
|
461
|
+
if (variant === "outlined") {
|
|
462
|
+
return styles.hoveredOutlined;
|
|
463
|
+
}
|
|
464
|
+
if (variant === "standard") {
|
|
465
|
+
return styles.hoveredStandard;
|
|
466
|
+
}
|
|
467
|
+
return styles.hoveredFilled;
|
|
468
|
+
}
|
|
469
|
+
function getPressedStyle(styles, variant, isToggle, selected) {
|
|
470
|
+
if (isToggle) {
|
|
471
|
+
if (variant === "tonal") {
|
|
472
|
+
return selected ? styles.pressedTonalToggleSelected : styles.pressedTonalToggleUnselected;
|
|
473
|
+
}
|
|
474
|
+
if (variant === "outlined") {
|
|
475
|
+
return selected ? styles.pressedOutlinedToggleSelected : styles.pressedOutlinedToggleUnselected;
|
|
476
|
+
}
|
|
477
|
+
if (variant === "standard") {
|
|
478
|
+
return selected ? styles.pressedStandardToggleSelected : styles.pressedStandardToggleUnselected;
|
|
479
|
+
}
|
|
480
|
+
return selected ? styles.pressedFilledToggleSelected : styles.pressedFilledToggleUnselected;
|
|
481
|
+
}
|
|
482
|
+
if (variant === "tonal") {
|
|
483
|
+
return styles.pressedTonal;
|
|
484
|
+
}
|
|
485
|
+
if (variant === "outlined") {
|
|
486
|
+
return styles.pressedOutlined;
|
|
487
|
+
}
|
|
488
|
+
if (variant === "standard") {
|
|
489
|
+
return styles.pressedStandard;
|
|
490
|
+
}
|
|
491
|
+
return styles.pressedFilled;
|
|
492
|
+
}
|
|
493
|
+
function getDisabledStyle(styles, variant) {
|
|
494
|
+
if (variant === "tonal") {
|
|
495
|
+
return styles.disabledTonal;
|
|
496
|
+
}
|
|
497
|
+
if (variant === "outlined") {
|
|
498
|
+
return styles.disabledOutlined;
|
|
499
|
+
}
|
|
500
|
+
if (variant === "standard") {
|
|
501
|
+
return styles.disabledStandard;
|
|
502
|
+
}
|
|
503
|
+
return styles.disabledFilled;
|
|
504
|
+
}
|
|
505
|
+
function IconButton({
|
|
506
|
+
icon,
|
|
507
|
+
selectedIcon,
|
|
508
|
+
iconColor,
|
|
509
|
+
contentColor,
|
|
510
|
+
containerColor,
|
|
511
|
+
style,
|
|
512
|
+
onPress,
|
|
513
|
+
disabled = false,
|
|
514
|
+
variant = "filled",
|
|
515
|
+
selected,
|
|
516
|
+
size = "medium",
|
|
517
|
+
hitSlop,
|
|
518
|
+
accessibilityLabel,
|
|
519
|
+
...props
|
|
520
|
+
}) {
|
|
521
|
+
var _a;
|
|
522
|
+
const MaterialCommunityIcons = getMaterialCommunityIcons();
|
|
523
|
+
const theme = (0, import_core.useTheme)();
|
|
524
|
+
const styles = (0, import_react.useMemo)(() => createStyles(theme), [theme]);
|
|
525
|
+
const isDisabled = Boolean(disabled);
|
|
526
|
+
const isToggle = selected !== void 0;
|
|
527
|
+
const isSelected = Boolean(selected);
|
|
528
|
+
const resolvedIconColor = (_a = contentColor != null ? contentColor : iconColor) != null ? _a : getIconColor(variant, theme, isDisabled, isToggle, isSelected);
|
|
529
|
+
const displayIcon = isToggle && isSelected && selectedIcon ? selectedIcon : icon;
|
|
530
|
+
const iconPixelSize = getIconPixelSize(size);
|
|
531
|
+
const accessibilityState = isToggle ? { disabled: isDisabled, selected: isSelected } : { disabled: isDisabled };
|
|
532
|
+
const containerOverrides = (0, import_react.useMemo)(() => {
|
|
533
|
+
if (!containerColor) return null;
|
|
534
|
+
const overlay = resolvedIconColor;
|
|
535
|
+
return {
|
|
536
|
+
base: {
|
|
537
|
+
backgroundColor: containerColor,
|
|
538
|
+
borderColor: containerColor,
|
|
539
|
+
borderWidth: 0
|
|
540
|
+
},
|
|
541
|
+
hovered: {
|
|
542
|
+
backgroundColor: blendColor(
|
|
543
|
+
containerColor,
|
|
544
|
+
overlay,
|
|
545
|
+
theme.stateLayer.hoveredOpacity
|
|
546
|
+
)
|
|
547
|
+
},
|
|
548
|
+
pressed: {
|
|
549
|
+
backgroundColor: blendColor(
|
|
550
|
+
containerColor,
|
|
551
|
+
overlay,
|
|
552
|
+
theme.stateLayer.pressedOpacity
|
|
553
|
+
)
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
}, [containerColor, resolvedIconColor, theme.stateLayer]);
|
|
557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
558
|
+
import_react_native4.Pressable,
|
|
559
|
+
{
|
|
560
|
+
...props,
|
|
561
|
+
accessibilityRole: "button",
|
|
562
|
+
accessibilityLabel,
|
|
563
|
+
accessibilityState,
|
|
564
|
+
disabled: isDisabled,
|
|
565
|
+
hitSlop: hitSlop != null ? hitSlop : getDefaultHitSlop(size),
|
|
566
|
+
onPress,
|
|
567
|
+
style: ({
|
|
568
|
+
pressed,
|
|
569
|
+
hovered
|
|
570
|
+
}) => {
|
|
571
|
+
const base = [
|
|
572
|
+
styles.container,
|
|
573
|
+
getSizeStyle(styles, size),
|
|
574
|
+
getColorStyle(styles, variant, isToggle, isSelected),
|
|
575
|
+
containerOverrides == null ? void 0 : containerOverrides.base,
|
|
576
|
+
hovered && !pressed && !isDisabled ? containerOverrides ? containerOverrides.hovered : getHoveredStyle(styles, variant, isToggle, isSelected) : void 0,
|
|
577
|
+
pressed && !isDisabled ? containerOverrides ? containerOverrides.pressed : getPressedStyle(styles, variant, isToggle, isSelected) : void 0,
|
|
578
|
+
isDisabled ? getDisabledStyle(styles, variant) : void 0
|
|
579
|
+
];
|
|
580
|
+
if (typeof style === "function") {
|
|
581
|
+
base.push(style({ pressed }));
|
|
582
|
+
} else if (style) {
|
|
583
|
+
base.push(style);
|
|
584
|
+
}
|
|
585
|
+
return base;
|
|
586
|
+
},
|
|
587
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
588
|
+
MaterialCommunityIcons,
|
|
589
|
+
{
|
|
590
|
+
name: displayIcon,
|
|
591
|
+
size: iconPixelSize,
|
|
592
|
+
color: resolvedIconColor
|
|
593
|
+
}
|
|
594
|
+
)
|
|
595
|
+
}
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// src/typography/Typography.tsx
|
|
600
|
+
var import_react2 = require("react");
|
|
601
|
+
var import_react_native5 = require("react-native");
|
|
602
|
+
var import_core2 = require("@onlynative/core");
|
|
603
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
604
|
+
var HEADING_VARIANTS = /* @__PURE__ */ new Set([
|
|
605
|
+
"displayLarge",
|
|
606
|
+
"displayMedium",
|
|
607
|
+
"displaySmall",
|
|
608
|
+
"headlineLarge",
|
|
609
|
+
"headlineMedium",
|
|
610
|
+
"headlineSmall"
|
|
611
|
+
]);
|
|
612
|
+
function Typography({
|
|
613
|
+
children,
|
|
614
|
+
variant = "bodyMedium",
|
|
615
|
+
color,
|
|
616
|
+
style,
|
|
617
|
+
as: Component = import_react_native5.Text,
|
|
618
|
+
accessibilityRole,
|
|
619
|
+
...textProps
|
|
620
|
+
}) {
|
|
621
|
+
const theme = (0, import_core2.useTheme)();
|
|
622
|
+
const typographyStyle = theme.typography[variant];
|
|
623
|
+
const resolvedRole = accessibilityRole != null ? accessibilityRole : HEADING_VARIANTS.has(variant) ? "header" : void 0;
|
|
624
|
+
const lineHeightFix = (0, import_react2.useMemo)(() => {
|
|
625
|
+
if (!style) return void 0;
|
|
626
|
+
const flat = import_react_native5.StyleSheet.flatten(style);
|
|
627
|
+
if (!(flat == null ? void 0 : flat.fontSize) || flat.lineHeight) return void 0;
|
|
628
|
+
const ratio = typographyStyle.lineHeight / typographyStyle.fontSize;
|
|
629
|
+
return { lineHeight: Math.ceil(flat.fontSize * ratio) };
|
|
630
|
+
}, [style, typographyStyle.fontSize, typographyStyle.lineHeight]);
|
|
631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
632
|
+
Component,
|
|
633
|
+
{
|
|
634
|
+
...textProps,
|
|
635
|
+
accessibilityRole: resolvedRole,
|
|
636
|
+
style: [
|
|
637
|
+
{ color: theme.colors.onSurface },
|
|
638
|
+
typographyStyle,
|
|
639
|
+
style,
|
|
640
|
+
lineHeightFix,
|
|
641
|
+
color != null ? { color } : void 0
|
|
642
|
+
],
|
|
643
|
+
children
|
|
644
|
+
}
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// src/appbar/styles.ts
|
|
649
|
+
var import_react_native6 = require("react-native");
|
|
650
|
+
var import_core3 = require("@onlynative/core");
|
|
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) {
|
|
705
|
+
var _a;
|
|
706
|
+
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core3.defaultTopAppBarTokens;
|
|
707
|
+
return import_react_native6.StyleSheet.create({
|
|
708
|
+
root: {
|
|
709
|
+
backgroundColor: schemeColors.containerColor
|
|
710
|
+
},
|
|
711
|
+
safeArea: {
|
|
712
|
+
backgroundColor: schemeColors.containerColor
|
|
713
|
+
},
|
|
714
|
+
elevatedRoot: {
|
|
715
|
+
backgroundColor: schemeColors.elevatedContainerColor
|
|
716
|
+
},
|
|
717
|
+
elevatedSafeArea: {
|
|
718
|
+
backgroundColor: schemeColors.elevatedContainerColor
|
|
719
|
+
},
|
|
720
|
+
smallContainer: {
|
|
721
|
+
height: topAppBar.smallContainerHeight,
|
|
722
|
+
position: "relative"
|
|
723
|
+
},
|
|
724
|
+
mediumContainer: {
|
|
725
|
+
height: topAppBar.mediumContainerHeight
|
|
726
|
+
},
|
|
727
|
+
largeContainer: {
|
|
728
|
+
height: topAppBar.largeContainerHeight
|
|
729
|
+
},
|
|
730
|
+
expandedContainer: {
|
|
731
|
+
position: "relative"
|
|
732
|
+
},
|
|
733
|
+
topRow: {
|
|
734
|
+
height: topAppBar.topRowHeight,
|
|
735
|
+
paddingHorizontal: topAppBar.horizontalPadding,
|
|
736
|
+
flexDirection: "row",
|
|
737
|
+
alignItems: "center"
|
|
738
|
+
},
|
|
739
|
+
expandedTitleContainer: {
|
|
740
|
+
flex: 1,
|
|
741
|
+
justifyContent: "flex-end",
|
|
742
|
+
minWidth: 0,
|
|
743
|
+
paddingEnd: theme.spacing.md,
|
|
744
|
+
pointerEvents: "none"
|
|
745
|
+
},
|
|
746
|
+
topRowSpacer: {
|
|
747
|
+
flex: 1
|
|
748
|
+
},
|
|
749
|
+
sideSlot: {
|
|
750
|
+
flexDirection: "row",
|
|
751
|
+
alignItems: "center",
|
|
752
|
+
minHeight: topAppBar.sideSlotMinHeight
|
|
753
|
+
},
|
|
754
|
+
actionsRow: {
|
|
755
|
+
flexDirection: "row",
|
|
756
|
+
alignItems: "center"
|
|
757
|
+
},
|
|
758
|
+
iconFrame: {
|
|
759
|
+
width: topAppBar.iconFrameSize,
|
|
760
|
+
height: topAppBar.iconFrameSize,
|
|
761
|
+
alignItems: "center",
|
|
762
|
+
justifyContent: "center"
|
|
763
|
+
},
|
|
764
|
+
overlayTitleContainer: {
|
|
765
|
+
position: "absolute",
|
|
766
|
+
top: 0,
|
|
767
|
+
bottom: 0,
|
|
768
|
+
justifyContent: "center",
|
|
769
|
+
minWidth: 0,
|
|
770
|
+
pointerEvents: "none"
|
|
771
|
+
},
|
|
772
|
+
centeredTitle: {
|
|
773
|
+
textAlign: "center"
|
|
774
|
+
},
|
|
775
|
+
startAlignedTitle: {
|
|
776
|
+
textAlign: "auto"
|
|
777
|
+
},
|
|
778
|
+
mediumTitlePadding: {
|
|
779
|
+
paddingBottom: topAppBar.mediumTitleBottomPadding
|
|
780
|
+
},
|
|
781
|
+
largeTitlePadding: {
|
|
782
|
+
paddingBottom: topAppBar.largeTitleBottomPadding
|
|
783
|
+
},
|
|
784
|
+
title: {
|
|
785
|
+
flexShrink: 1,
|
|
786
|
+
maxWidth: "100%",
|
|
787
|
+
includeFontPadding: false,
|
|
788
|
+
textAlignVertical: "center"
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// src/appbar/AppBar.tsx
|
|
794
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
795
|
+
function getBackIcon() {
|
|
796
|
+
if (import_react_native7.Platform.OS === "ios") {
|
|
797
|
+
return selectRTL("chevron-left", "chevron-right");
|
|
798
|
+
}
|
|
799
|
+
return selectRTL("arrow-left", "arrow-right");
|
|
800
|
+
}
|
|
801
|
+
var titleVariantBySize = {
|
|
802
|
+
small: "titleLarge",
|
|
803
|
+
medium: "headlineSmall",
|
|
804
|
+
large: "headlineMedium"
|
|
805
|
+
};
|
|
806
|
+
var APP_BAR_TITLE_TEXT_PROPS = {
|
|
807
|
+
numberOfLines: 1,
|
|
808
|
+
ellipsizeMode: "tail",
|
|
809
|
+
accessibilityRole: "header"
|
|
810
|
+
};
|
|
811
|
+
function resolveSize(variant) {
|
|
812
|
+
if (variant === "medium" || variant === "large") {
|
|
813
|
+
return variant;
|
|
814
|
+
}
|
|
815
|
+
return "small";
|
|
816
|
+
}
|
|
817
|
+
function getSizeStyle2(styles, size) {
|
|
818
|
+
if (size === "large") {
|
|
819
|
+
return styles.largeContainer;
|
|
820
|
+
}
|
|
821
|
+
return styles.mediumContainer;
|
|
822
|
+
}
|
|
823
|
+
function withTopInset(enabled, content, style) {
|
|
824
|
+
if (enabled) {
|
|
825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_safe_area_context.SafeAreaView, { edges: ["top"], style, children: content });
|
|
826
|
+
}
|
|
827
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style, children: content });
|
|
828
|
+
}
|
|
829
|
+
function measureWidth(event) {
|
|
830
|
+
return Math.round(event.nativeEvent.layout.width);
|
|
831
|
+
}
|
|
832
|
+
function AppBar({
|
|
833
|
+
title,
|
|
834
|
+
variant = "small",
|
|
835
|
+
colorScheme = "surface",
|
|
836
|
+
canGoBack = false,
|
|
837
|
+
onBackPress,
|
|
838
|
+
insetTop = false,
|
|
839
|
+
elevated = false,
|
|
840
|
+
leading,
|
|
841
|
+
trailing,
|
|
842
|
+
actions,
|
|
843
|
+
containerColor,
|
|
844
|
+
contentColor,
|
|
845
|
+
titleStyle,
|
|
846
|
+
style
|
|
847
|
+
}) {
|
|
848
|
+
var _a;
|
|
849
|
+
const theme = (0, import_core4.useTheme)();
|
|
850
|
+
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core4.defaultTopAppBarTokens;
|
|
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
|
+
);
|
|
860
|
+
const [leadingWidth, setLeadingWidth] = (0, import_react3.useState)(0);
|
|
861
|
+
const [actionsWidth, setActionsWidth] = (0, import_react3.useState)(0);
|
|
862
|
+
const titleColorStyle = (0, import_react3.useMemo)(
|
|
863
|
+
() => ({ color: resolvedContentColor }),
|
|
864
|
+
[resolvedContentColor]
|
|
865
|
+
);
|
|
866
|
+
const size = resolveSize(variant);
|
|
867
|
+
const titleVariant = titleVariantBySize[size];
|
|
868
|
+
const isCenterAligned = variant === "center-aligned";
|
|
869
|
+
const isExpanded = size !== "small";
|
|
870
|
+
const titleStartInset = topAppBar.horizontalPadding + Math.max(topAppBar.titleStartInset, leadingWidth);
|
|
871
|
+
const compactTitleEndInset = topAppBar.horizontalPadding + actionsWidth;
|
|
872
|
+
const centeredSideInset = topAppBar.horizontalPadding + Math.max(leadingWidth, actionsWidth);
|
|
873
|
+
const expandedTitleInsetStyle = (0, import_react3.useMemo)(
|
|
874
|
+
() => ({ paddingStart: titleStartInset }),
|
|
875
|
+
[titleStartInset]
|
|
876
|
+
);
|
|
877
|
+
const overlayTitleInsetStyle = (0, import_react3.useMemo)(
|
|
878
|
+
() => isCenterAligned ? { start: centeredSideInset, end: centeredSideInset } : { start: titleStartInset, end: compactTitleEndInset },
|
|
879
|
+
[centeredSideInset, compactTitleEndInset, isCenterAligned, titleStartInset]
|
|
880
|
+
);
|
|
881
|
+
const leadingContent = (0, import_react3.useMemo)(() => {
|
|
882
|
+
if (leading) {
|
|
883
|
+
return leading;
|
|
884
|
+
}
|
|
885
|
+
if (!canGoBack) {
|
|
886
|
+
return null;
|
|
887
|
+
}
|
|
888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: styles.iconFrame, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
889
|
+
IconButton,
|
|
890
|
+
{
|
|
891
|
+
icon: getBackIcon(),
|
|
892
|
+
size: "medium",
|
|
893
|
+
variant: "standard",
|
|
894
|
+
iconColor: resolvedContentColor,
|
|
895
|
+
accessibilityLabel: "Go back",
|
|
896
|
+
onPress: onBackPress
|
|
897
|
+
}
|
|
898
|
+
) });
|
|
899
|
+
}, [canGoBack, resolvedContentColor, leading, onBackPress, styles.iconFrame]);
|
|
900
|
+
const actionsContent = (0, import_react3.useMemo)(() => {
|
|
901
|
+
if (trailing) {
|
|
902
|
+
return trailing;
|
|
903
|
+
}
|
|
904
|
+
if (!actions || actions.length === 0) {
|
|
905
|
+
return null;
|
|
906
|
+
}
|
|
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,
|
|
909
|
+
{
|
|
910
|
+
style: styles.iconFrame,
|
|
911
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
912
|
+
IconButton,
|
|
913
|
+
{
|
|
914
|
+
icon: action.icon,
|
|
915
|
+
size: "medium",
|
|
916
|
+
variant: "standard",
|
|
917
|
+
iconColor: resolvedContentColor,
|
|
918
|
+
accessibilityLabel: action.accessibilityLabel,
|
|
919
|
+
onPress: action.onPress,
|
|
920
|
+
disabled: action.disabled
|
|
921
|
+
}
|
|
922
|
+
)
|
|
923
|
+
},
|
|
924
|
+
`${String(action.icon)}-${index}`
|
|
925
|
+
)) });
|
|
926
|
+
}, [actions, resolvedContentColor, styles.actionsRow, styles.iconFrame, trailing]);
|
|
927
|
+
const onLeadingLayout = (0, import_react3.useCallback)((event) => {
|
|
928
|
+
const nextWidth = measureWidth(event);
|
|
929
|
+
setLeadingWidth((currentWidth) => {
|
|
930
|
+
if (currentWidth === nextWidth) {
|
|
931
|
+
return currentWidth;
|
|
932
|
+
}
|
|
933
|
+
return nextWidth;
|
|
934
|
+
});
|
|
935
|
+
}, []);
|
|
936
|
+
const onActionsLayout = (0, import_react3.useCallback)((event) => {
|
|
937
|
+
const nextWidth = measureWidth(event);
|
|
938
|
+
setActionsWidth((currentWidth) => {
|
|
939
|
+
if (currentWidth === nextWidth) {
|
|
940
|
+
return currentWidth;
|
|
941
|
+
}
|
|
942
|
+
return nextWidth;
|
|
943
|
+
});
|
|
944
|
+
}, []);
|
|
945
|
+
const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native7.View, { style: styles.topRow, children: [
|
|
946
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
947
|
+
import_react_native7.View,
|
|
948
|
+
{
|
|
949
|
+
collapsable: false,
|
|
950
|
+
onLayout: onLeadingLayout,
|
|
951
|
+
style: styles.sideSlot,
|
|
952
|
+
children: leadingContent
|
|
953
|
+
}
|
|
954
|
+
),
|
|
955
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: styles.topRowSpacer }),
|
|
956
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
957
|
+
import_react_native7.View,
|
|
958
|
+
{
|
|
959
|
+
collapsable: false,
|
|
960
|
+
onLayout: onActionsLayout,
|
|
961
|
+
style: styles.sideSlot,
|
|
962
|
+
children: actionsContent
|
|
963
|
+
}
|
|
964
|
+
)
|
|
965
|
+
] });
|
|
966
|
+
const containerOverride = containerColor ? { backgroundColor: containerColor } : void 0;
|
|
967
|
+
const rootStyle = [
|
|
968
|
+
styles.root,
|
|
969
|
+
elevated ? styles.elevatedRoot : void 0,
|
|
970
|
+
containerOverride,
|
|
971
|
+
style
|
|
972
|
+
];
|
|
973
|
+
const safeAreaStyle = [
|
|
974
|
+
styles.safeArea,
|
|
975
|
+
elevated ? styles.elevatedSafeArea : void 0,
|
|
976
|
+
containerOverride
|
|
977
|
+
];
|
|
978
|
+
if (isExpanded) {
|
|
979
|
+
const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native7.View, { style: [styles.expandedContainer, getSizeStyle2(styles, size)], children: [
|
|
980
|
+
topRow,
|
|
981
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
982
|
+
import_react_native7.View,
|
|
983
|
+
{
|
|
984
|
+
style: [
|
|
985
|
+
styles.expandedTitleContainer,
|
|
986
|
+
size === "large" ? styles.largeTitlePadding : styles.mediumTitlePadding,
|
|
987
|
+
expandedTitleInsetStyle
|
|
988
|
+
],
|
|
989
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
990
|
+
Typography,
|
|
991
|
+
{
|
|
992
|
+
...APP_BAR_TITLE_TEXT_PROPS,
|
|
993
|
+
variant: titleVariant,
|
|
994
|
+
style: [
|
|
995
|
+
styles.title,
|
|
996
|
+
titleColorStyle,
|
|
997
|
+
styles.startAlignedTitle,
|
|
998
|
+
titleStyle
|
|
999
|
+
],
|
|
1000
|
+
children: title
|
|
1001
|
+
}
|
|
1002
|
+
)
|
|
1003
|
+
}
|
|
1004
|
+
)
|
|
1005
|
+
] });
|
|
1006
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: rootStyle, children: withTopInset(insetTop, content2, safeAreaStyle) });
|
|
1007
|
+
}
|
|
1008
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native7.View, { style: styles.smallContainer, children: [
|
|
1009
|
+
topRow,
|
|
1010
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: [styles.overlayTitleContainer, overlayTitleInsetStyle], children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1011
|
+
Typography,
|
|
1012
|
+
{
|
|
1013
|
+
...APP_BAR_TITLE_TEXT_PROPS,
|
|
1014
|
+
variant: titleVariant,
|
|
1015
|
+
style: [
|
|
1016
|
+
styles.title,
|
|
1017
|
+
titleColorStyle,
|
|
1018
|
+
isCenterAligned ? styles.centeredTitle : styles.startAlignedTitle,
|
|
1019
|
+
titleStyle
|
|
1020
|
+
],
|
|
1021
|
+
children: title
|
|
1022
|
+
}
|
|
1023
|
+
) })
|
|
1024
|
+
] });
|
|
1025
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { style: rootStyle, children: withTopInset(insetTop, content, safeAreaStyle) });
|
|
1026
|
+
}
|
|
1027
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1028
|
+
0 && (module.exports = {
|
|
1029
|
+
AppBar
|
|
1030
|
+
});
|