@onlynative/components 0.1.0-alpha.2 → 0.1.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/dist/appbar/index.js +75 -123
- package/dist/button/index.js +33 -111
- package/dist/card/index.js +20 -89
- package/dist/checkbox/index.js +11 -65
- package/dist/chip/index.js +33 -110
- package/dist/icon-button/index.js +33 -87
- package/dist/index.d.ts +1 -0
- package/dist/index.js +535 -517
- package/dist/keyboard-avoiding-wrapper/index.d.ts +36 -0
- package/dist/keyboard-avoiding-wrapper/index.js +98 -0
- package/dist/list/index.js +5 -50
- package/dist/radio/index.js +8 -35
- package/dist/switch/index.js +13 -67
- package/dist/text-field/index.js +27 -69
- package/dist/typography/index.js +9 -0
- package/package.json +13 -3
- package/src/appbar/AppBar.tsx +1 -1
- package/src/button/Button.tsx +4 -1
- package/src/button/styles.ts +1 -2
- package/src/card/styles.ts +1 -2
- package/src/checkbox/Checkbox.tsx +5 -1
- package/src/checkbox/styles.ts +1 -1
- package/src/chip/Chip.tsx +7 -1
- package/src/chip/styles.ts +1 -2
- package/src/icon-button/IconButton.tsx +6 -2
- package/src/icon-button/styles.ts +1 -1
- package/src/index.ts +3 -0
- package/src/keyboard-avoiding-wrapper/KeyboardAvoidingWrapper.tsx +69 -0
- package/src/keyboard-avoiding-wrapper/index.ts +2 -0
- package/src/keyboard-avoiding-wrapper/styles.ts +10 -0
- package/src/keyboard-avoiding-wrapper/types.ts +37 -0
- package/src/list/styles.ts +1 -1
- package/src/radio/styles.ts +1 -1
- package/src/switch/Switch.tsx +4 -1
- package/src/switch/styles.ts +1 -1
- package/src/text-field/TextField.tsx +4 -1
- package/src/text-field/styles.ts +1 -2
- package/src/typography/Typography.tsx +15 -1
- package/src/test-utils/render-with-theme.tsx +0 -13
- package/src/utils/color.ts +0 -64
- package/src/utils/elevation.ts +0 -33
- package/src/utils/rtl.ts +0 -19
package/dist/appbar/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/appbar/index.ts
|
|
@@ -35,68 +25,23 @@ __export(appbar_exports, {
|
|
|
35
25
|
module.exports = __toCommonJS(appbar_exports);
|
|
36
26
|
|
|
37
27
|
// src/appbar/AppBar.tsx
|
|
38
|
-
var
|
|
39
|
-
var
|
|
28
|
+
var import_react3 = require("react");
|
|
29
|
+
var import_react_native5 = require("react-native");
|
|
40
30
|
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
41
31
|
var import_core4 = require("@onlynative/core");
|
|
42
32
|
|
|
43
33
|
// src/icon-button/IconButton.tsx
|
|
44
|
-
var import_MaterialCommunityIcons = __toESM(require("@expo/vector-icons/MaterialCommunityIcons"));
|
|
45
34
|
var import_react = require("react");
|
|
46
35
|
var import_react_native2 = require("react-native");
|
|
47
36
|
var import_core = require("@onlynative/core");
|
|
37
|
+
var import_utils2 = require("@onlynative/utils");
|
|
48
38
|
|
|
49
39
|
// src/icon-button/styles.ts
|
|
50
40
|
var import_react_native = require("react-native");
|
|
51
|
-
|
|
52
|
-
// src/utils/color.ts
|
|
53
|
-
function parseHexColor(color) {
|
|
54
|
-
const normalized = color.replace("#", "");
|
|
55
|
-
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
const r = Number.parseInt(normalized.slice(0, 2), 16);
|
|
59
|
-
const g = Number.parseInt(normalized.slice(2, 4), 16);
|
|
60
|
-
const b = Number.parseInt(normalized.slice(4, 6), 16);
|
|
61
|
-
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return { r, g, b };
|
|
65
|
-
}
|
|
66
|
-
function clampAlpha(alpha) {
|
|
67
|
-
return Math.max(0, Math.min(1, alpha));
|
|
68
|
-
}
|
|
69
|
-
function alphaColor(color, alpha) {
|
|
70
|
-
const channels = parseHexColor(color);
|
|
71
|
-
const boundedAlpha = clampAlpha(alpha);
|
|
72
|
-
if (!channels) {
|
|
73
|
-
return color;
|
|
74
|
-
}
|
|
75
|
-
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
76
|
-
}
|
|
77
|
-
function blendColor(base, overlay, overlayAlpha) {
|
|
78
|
-
const baseChannels = parseHexColor(base);
|
|
79
|
-
const overlayChannels = parseHexColor(overlay);
|
|
80
|
-
const boundedAlpha = clampAlpha(overlayAlpha);
|
|
81
|
-
if (!baseChannels || !overlayChannels) {
|
|
82
|
-
return alphaColor(overlay, boundedAlpha);
|
|
83
|
-
}
|
|
84
|
-
const r = Math.round(
|
|
85
|
-
(1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
|
|
86
|
-
);
|
|
87
|
-
const g = Math.round(
|
|
88
|
-
(1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
|
|
89
|
-
);
|
|
90
|
-
const b = Math.round(
|
|
91
|
-
(1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
|
|
92
|
-
);
|
|
93
|
-
return `rgb(${r}, ${g}, ${b})`;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// src/icon-button/styles.ts
|
|
41
|
+
var import_utils = require("@onlynative/utils");
|
|
97
42
|
function createStyles(theme) {
|
|
98
|
-
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
99
|
-
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
43
|
+
const disabledContainerColor = (0, import_utils.alphaColor)(theme.colors.onSurface, 0.12);
|
|
44
|
+
const disabledOutlineColor = (0, import_utils.alphaColor)(theme.colors.onSurface, 0.12);
|
|
100
45
|
const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest;
|
|
101
46
|
return import_react_native.StyleSheet.create({
|
|
102
47
|
container: {
|
|
@@ -164,160 +109,160 @@ function createStyles(theme) {
|
|
|
164
109
|
},
|
|
165
110
|
// Hover states (M3: 8% state layer)
|
|
166
111
|
hoveredFilled: {
|
|
167
|
-
backgroundColor: blendColor(
|
|
112
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
168
113
|
theme.colors.primary,
|
|
169
114
|
theme.colors.onPrimary,
|
|
170
115
|
theme.stateLayer.hoveredOpacity
|
|
171
116
|
)
|
|
172
117
|
},
|
|
173
118
|
hoveredFilledToggleUnselected: {
|
|
174
|
-
backgroundColor: blendColor(
|
|
119
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
175
120
|
toggleUnselectedContainerColor,
|
|
176
121
|
theme.colors.primary,
|
|
177
122
|
theme.stateLayer.hoveredOpacity
|
|
178
123
|
)
|
|
179
124
|
},
|
|
180
125
|
hoveredFilledToggleSelected: {
|
|
181
|
-
backgroundColor: blendColor(
|
|
126
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
182
127
|
theme.colors.primary,
|
|
183
128
|
theme.colors.onPrimary,
|
|
184
129
|
theme.stateLayer.hoveredOpacity
|
|
185
130
|
)
|
|
186
131
|
},
|
|
187
132
|
hoveredTonal: {
|
|
188
|
-
backgroundColor: blendColor(
|
|
133
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
189
134
|
theme.colors.secondaryContainer,
|
|
190
135
|
theme.colors.onSecondaryContainer,
|
|
191
136
|
theme.stateLayer.hoveredOpacity
|
|
192
137
|
)
|
|
193
138
|
},
|
|
194
139
|
hoveredTonalToggleUnselected: {
|
|
195
|
-
backgroundColor: blendColor(
|
|
140
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
196
141
|
toggleUnselectedContainerColor,
|
|
197
142
|
theme.colors.onSurfaceVariant,
|
|
198
143
|
theme.stateLayer.hoveredOpacity
|
|
199
144
|
)
|
|
200
145
|
},
|
|
201
146
|
hoveredTonalToggleSelected: {
|
|
202
|
-
backgroundColor: blendColor(
|
|
147
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
203
148
|
theme.colors.secondaryContainer,
|
|
204
149
|
theme.colors.onSecondaryContainer,
|
|
205
150
|
theme.stateLayer.hoveredOpacity
|
|
206
151
|
)
|
|
207
152
|
},
|
|
208
153
|
hoveredOutlined: {
|
|
209
|
-
backgroundColor: alphaColor(
|
|
154
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
210
155
|
theme.colors.onSurfaceVariant,
|
|
211
156
|
theme.stateLayer.hoveredOpacity
|
|
212
157
|
)
|
|
213
158
|
},
|
|
214
159
|
hoveredOutlinedToggleUnselected: {
|
|
215
|
-
backgroundColor: alphaColor(
|
|
160
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
216
161
|
theme.colors.onSurfaceVariant,
|
|
217
162
|
theme.stateLayer.hoveredOpacity
|
|
218
163
|
)
|
|
219
164
|
},
|
|
220
165
|
hoveredOutlinedToggleSelected: {
|
|
221
|
-
backgroundColor: blendColor(
|
|
166
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
222
167
|
theme.colors.inverseSurface,
|
|
223
168
|
theme.colors.inverseOnSurface,
|
|
224
169
|
theme.stateLayer.hoveredOpacity
|
|
225
170
|
)
|
|
226
171
|
},
|
|
227
172
|
hoveredStandard: {
|
|
228
|
-
backgroundColor: alphaColor(
|
|
173
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
229
174
|
theme.colors.onSurfaceVariant,
|
|
230
175
|
theme.stateLayer.hoveredOpacity
|
|
231
176
|
)
|
|
232
177
|
},
|
|
233
178
|
hoveredStandardToggleUnselected: {
|
|
234
|
-
backgroundColor: alphaColor(
|
|
179
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
235
180
|
theme.colors.onSurfaceVariant,
|
|
236
181
|
theme.stateLayer.hoveredOpacity
|
|
237
182
|
)
|
|
238
183
|
},
|
|
239
184
|
hoveredStandardToggleSelected: {
|
|
240
|
-
backgroundColor: alphaColor(
|
|
185
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
241
186
|
theme.colors.primary,
|
|
242
187
|
theme.stateLayer.hoveredOpacity
|
|
243
188
|
)
|
|
244
189
|
},
|
|
245
190
|
// Pressed states (M3: 12% state layer)
|
|
246
191
|
pressedFilled: {
|
|
247
|
-
backgroundColor: blendColor(
|
|
192
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
248
193
|
theme.colors.primary,
|
|
249
194
|
theme.colors.onPrimary,
|
|
250
195
|
theme.stateLayer.pressedOpacity
|
|
251
196
|
)
|
|
252
197
|
},
|
|
253
198
|
pressedFilledToggleUnselected: {
|
|
254
|
-
backgroundColor: blendColor(
|
|
199
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
255
200
|
toggleUnselectedContainerColor,
|
|
256
201
|
theme.colors.primary,
|
|
257
202
|
theme.stateLayer.pressedOpacity
|
|
258
203
|
)
|
|
259
204
|
},
|
|
260
205
|
pressedFilledToggleSelected: {
|
|
261
|
-
backgroundColor: blendColor(
|
|
206
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
262
207
|
theme.colors.primary,
|
|
263
208
|
theme.colors.onPrimary,
|
|
264
209
|
theme.stateLayer.pressedOpacity
|
|
265
210
|
)
|
|
266
211
|
},
|
|
267
212
|
pressedTonal: {
|
|
268
|
-
backgroundColor: blendColor(
|
|
213
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
269
214
|
theme.colors.secondaryContainer,
|
|
270
215
|
theme.colors.onSecondaryContainer,
|
|
271
216
|
theme.stateLayer.pressedOpacity
|
|
272
217
|
)
|
|
273
218
|
},
|
|
274
219
|
pressedTonalToggleUnselected: {
|
|
275
|
-
backgroundColor: blendColor(
|
|
220
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
276
221
|
toggleUnselectedContainerColor,
|
|
277
222
|
theme.colors.onSurfaceVariant,
|
|
278
223
|
theme.stateLayer.pressedOpacity
|
|
279
224
|
)
|
|
280
225
|
},
|
|
281
226
|
pressedTonalToggleSelected: {
|
|
282
|
-
backgroundColor: blendColor(
|
|
227
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
283
228
|
theme.colors.secondaryContainer,
|
|
284
229
|
theme.colors.onSecondaryContainer,
|
|
285
230
|
theme.stateLayer.pressedOpacity
|
|
286
231
|
)
|
|
287
232
|
},
|
|
288
233
|
pressedOutlined: {
|
|
289
|
-
backgroundColor: alphaColor(
|
|
234
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
290
235
|
theme.colors.onSurfaceVariant,
|
|
291
236
|
theme.stateLayer.pressedOpacity
|
|
292
237
|
)
|
|
293
238
|
},
|
|
294
239
|
pressedOutlinedToggleUnselected: {
|
|
295
|
-
backgroundColor: alphaColor(
|
|
240
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
296
241
|
theme.colors.onSurfaceVariant,
|
|
297
242
|
theme.stateLayer.pressedOpacity
|
|
298
243
|
)
|
|
299
244
|
},
|
|
300
245
|
pressedOutlinedToggleSelected: {
|
|
301
|
-
backgroundColor: blendColor(
|
|
246
|
+
backgroundColor: (0, import_utils.blendColor)(
|
|
302
247
|
theme.colors.inverseSurface,
|
|
303
248
|
theme.colors.inverseOnSurface,
|
|
304
249
|
theme.stateLayer.pressedOpacity
|
|
305
250
|
)
|
|
306
251
|
},
|
|
307
252
|
pressedStandard: {
|
|
308
|
-
backgroundColor: alphaColor(
|
|
253
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
309
254
|
theme.colors.onSurfaceVariant,
|
|
310
255
|
theme.stateLayer.pressedOpacity
|
|
311
256
|
)
|
|
312
257
|
},
|
|
313
258
|
pressedStandardToggleUnselected: {
|
|
314
|
-
backgroundColor: alphaColor(
|
|
259
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
315
260
|
theme.colors.onSurfaceVariant,
|
|
316
261
|
theme.stateLayer.pressedOpacity
|
|
317
262
|
)
|
|
318
263
|
},
|
|
319
264
|
pressedStandardToggleSelected: {
|
|
320
|
-
backgroundColor: alphaColor(
|
|
265
|
+
backgroundColor: (0, import_utils.alphaColor)(
|
|
321
266
|
theme.colors.primary,
|
|
322
267
|
theme.stateLayer.pressedOpacity
|
|
323
268
|
)
|
|
@@ -350,7 +295,7 @@ function createStyles(theme) {
|
|
|
350
295
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
351
296
|
function getIconColor(variant, theme, disabled, isToggle, selected) {
|
|
352
297
|
if (disabled) {
|
|
353
|
-
return alphaColor(theme.colors.onSurface, 0.38);
|
|
298
|
+
return (0, import_utils2.alphaColor)(theme.colors.onSurface, 0.38);
|
|
354
299
|
}
|
|
355
300
|
if (isToggle) {
|
|
356
301
|
if (variant === "filled") {
|
|
@@ -500,6 +445,7 @@ function IconButton({
|
|
|
500
445
|
...props
|
|
501
446
|
}) {
|
|
502
447
|
var _a;
|
|
448
|
+
const MaterialCommunityIcons = (0, import_utils2.getMaterialCommunityIcons)();
|
|
503
449
|
const theme = (0, import_core.useTheme)();
|
|
504
450
|
const styles = (0, import_react.useMemo)(() => createStyles(theme), [theme]);
|
|
505
451
|
const isDisabled = Boolean(disabled);
|
|
@@ -519,14 +465,14 @@ function IconButton({
|
|
|
519
465
|
borderWidth: 0
|
|
520
466
|
},
|
|
521
467
|
hovered: {
|
|
522
|
-
backgroundColor: blendColor(
|
|
468
|
+
backgroundColor: (0, import_utils2.blendColor)(
|
|
523
469
|
containerColor,
|
|
524
470
|
overlay,
|
|
525
471
|
theme.stateLayer.hoveredOpacity
|
|
526
472
|
)
|
|
527
473
|
},
|
|
528
474
|
pressed: {
|
|
529
|
-
backgroundColor: blendColor(
|
|
475
|
+
backgroundColor: (0, import_utils2.blendColor)(
|
|
530
476
|
containerColor,
|
|
531
477
|
overlay,
|
|
532
478
|
theme.stateLayer.pressedOpacity
|
|
@@ -565,7 +511,7 @@ function IconButton({
|
|
|
565
511
|
return base;
|
|
566
512
|
},
|
|
567
513
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
568
|
-
|
|
514
|
+
MaterialCommunityIcons,
|
|
569
515
|
{
|
|
570
516
|
name: displayIcon,
|
|
571
517
|
size: iconPixelSize,
|
|
@@ -577,6 +523,7 @@ function IconButton({
|
|
|
577
523
|
}
|
|
578
524
|
|
|
579
525
|
// src/typography/Typography.tsx
|
|
526
|
+
var import_react2 = require("react");
|
|
580
527
|
var import_react_native3 = require("react-native");
|
|
581
528
|
var import_core2 = require("@onlynative/core");
|
|
582
529
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -600,6 +547,13 @@ function Typography({
|
|
|
600
547
|
const theme = (0, import_core2.useTheme)();
|
|
601
548
|
const typographyStyle = theme.typography[variant];
|
|
602
549
|
const resolvedRole = accessibilityRole != null ? accessibilityRole : HEADING_VARIANTS.has(variant) ? "header" : void 0;
|
|
550
|
+
const lineHeightFix = (0, import_react2.useMemo)(() => {
|
|
551
|
+
if (!style) return void 0;
|
|
552
|
+
const flat = import_react_native3.StyleSheet.flatten(style);
|
|
553
|
+
if (!(flat == null ? void 0 : flat.fontSize) || flat.lineHeight) return void 0;
|
|
554
|
+
const ratio = typographyStyle.lineHeight / typographyStyle.fontSize;
|
|
555
|
+
return { lineHeight: Math.ceil(flat.fontSize * ratio) };
|
|
556
|
+
}, [style, typographyStyle.fontSize, typographyStyle.lineHeight]);
|
|
603
557
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
604
558
|
Component,
|
|
605
559
|
{
|
|
@@ -609,6 +563,7 @@ function Typography({
|
|
|
609
563
|
{ color: theme.colors.onSurface },
|
|
610
564
|
typographyStyle,
|
|
611
565
|
style,
|
|
566
|
+
lineHeightFix,
|
|
612
567
|
color != null ? { color } : void 0
|
|
613
568
|
],
|
|
614
569
|
children
|
|
@@ -616,19 +571,16 @@ function Typography({
|
|
|
616
571
|
);
|
|
617
572
|
}
|
|
618
573
|
|
|
619
|
-
// src/
|
|
620
|
-
var
|
|
621
|
-
function selectRTL(ltr, rtl) {
|
|
622
|
-
return import_react_native4.I18nManager.isRTL ? rtl : ltr;
|
|
623
|
-
}
|
|
574
|
+
// src/appbar/AppBar.tsx
|
|
575
|
+
var import_utils3 = require("@onlynative/utils");
|
|
624
576
|
|
|
625
577
|
// src/appbar/styles.ts
|
|
626
|
-
var
|
|
578
|
+
var import_react_native4 = require("react-native");
|
|
627
579
|
var import_core3 = require("@onlynative/core");
|
|
628
580
|
function createStyles2(theme) {
|
|
629
581
|
var _a;
|
|
630
582
|
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core3.defaultTopAppBarTokens;
|
|
631
|
-
return
|
|
583
|
+
return import_react_native4.StyleSheet.create({
|
|
632
584
|
root: {
|
|
633
585
|
backgroundColor: theme.colors.surface
|
|
634
586
|
},
|
|
@@ -717,10 +669,10 @@ function createStyles2(theme) {
|
|
|
717
669
|
// src/appbar/AppBar.tsx
|
|
718
670
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
719
671
|
function getBackIcon() {
|
|
720
|
-
if (
|
|
721
|
-
return selectRTL("chevron-left", "chevron-right");
|
|
672
|
+
if (import_react_native5.Platform.OS === "ios") {
|
|
673
|
+
return (0, import_utils3.selectRTL)("chevron-left", "chevron-right");
|
|
722
674
|
}
|
|
723
|
-
return selectRTL("arrow-left", "arrow-right");
|
|
675
|
+
return (0, import_utils3.selectRTL)("arrow-left", "arrow-right");
|
|
724
676
|
}
|
|
725
677
|
var titleVariantBySize = {
|
|
726
678
|
small: "titleLarge",
|
|
@@ -748,7 +700,7 @@ function withTopInset(enabled, content, style) {
|
|
|
748
700
|
if (enabled) {
|
|
749
701
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_safe_area_context.SafeAreaView, { edges: ["top"], style, children: content });
|
|
750
702
|
}
|
|
751
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style, children: content });
|
|
752
704
|
}
|
|
753
705
|
function measureWidth(event) {
|
|
754
706
|
return Math.round(event.nativeEvent.layout.width);
|
|
@@ -771,10 +723,10 @@ function AppBar({
|
|
|
771
723
|
var _a;
|
|
772
724
|
const theme = (0, import_core4.useTheme)();
|
|
773
725
|
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core4.defaultTopAppBarTokens;
|
|
774
|
-
const styles = (0,
|
|
775
|
-
const [leadingWidth, setLeadingWidth] = (0,
|
|
776
|
-
const [actionsWidth, setActionsWidth] = (0,
|
|
777
|
-
const titleColorStyle = (0,
|
|
726
|
+
const styles = (0, import_react3.useMemo)(() => createStyles2(theme), [theme]);
|
|
727
|
+
const [leadingWidth, setLeadingWidth] = (0, import_react3.useState)(0);
|
|
728
|
+
const [actionsWidth, setActionsWidth] = (0, import_react3.useState)(0);
|
|
729
|
+
const titleColorStyle = (0, import_react3.useMemo)(
|
|
778
730
|
() => ({ color: contentColor != null ? contentColor : theme.colors.onSurface }),
|
|
779
731
|
[contentColor, theme.colors.onSurface]
|
|
780
732
|
);
|
|
@@ -785,22 +737,22 @@ function AppBar({
|
|
|
785
737
|
const titleStartInset = topAppBar.horizontalPadding + Math.max(topAppBar.titleStartInset, leadingWidth);
|
|
786
738
|
const compactTitleEndInset = topAppBar.horizontalPadding + actionsWidth;
|
|
787
739
|
const centeredSideInset = topAppBar.horizontalPadding + Math.max(leadingWidth, actionsWidth);
|
|
788
|
-
const expandedTitleInsetStyle = (0,
|
|
740
|
+
const expandedTitleInsetStyle = (0, import_react3.useMemo)(
|
|
789
741
|
() => ({ paddingStart: titleStartInset }),
|
|
790
742
|
[titleStartInset]
|
|
791
743
|
);
|
|
792
|
-
const overlayTitleInsetStyle = (0,
|
|
744
|
+
const overlayTitleInsetStyle = (0, import_react3.useMemo)(
|
|
793
745
|
() => isCenterAligned ? { start: centeredSideInset, end: centeredSideInset } : { start: titleStartInset, end: compactTitleEndInset },
|
|
794
746
|
[centeredSideInset, compactTitleEndInset, isCenterAligned, titleStartInset]
|
|
795
747
|
);
|
|
796
|
-
const leadingContent = (0,
|
|
748
|
+
const leadingContent = (0, import_react3.useMemo)(() => {
|
|
797
749
|
if (leading) {
|
|
798
750
|
return leading;
|
|
799
751
|
}
|
|
800
752
|
if (!canGoBack) {
|
|
801
753
|
return null;
|
|
802
754
|
}
|
|
803
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: styles.iconFrame, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
804
756
|
IconButton,
|
|
805
757
|
{
|
|
806
758
|
icon: getBackIcon(),
|
|
@@ -819,15 +771,15 @@ function AppBar({
|
|
|
819
771
|
styles.iconFrame,
|
|
820
772
|
theme.colors.onSurface
|
|
821
773
|
]);
|
|
822
|
-
const actionsContent = (0,
|
|
774
|
+
const actionsContent = (0, import_react3.useMemo)(() => {
|
|
823
775
|
if (trailing) {
|
|
824
776
|
return trailing;
|
|
825
777
|
}
|
|
826
778
|
if (!actions || actions.length === 0) {
|
|
827
779
|
return null;
|
|
828
780
|
}
|
|
829
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
830
|
-
|
|
781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: styles.actionsRow, children: actions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
782
|
+
import_react_native5.View,
|
|
831
783
|
{
|
|
832
784
|
style: styles.iconFrame,
|
|
833
785
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -846,7 +798,7 @@ function AppBar({
|
|
|
846
798
|
`${String(action.icon)}-${index}`
|
|
847
799
|
)) });
|
|
848
800
|
}, [actions, contentColor, styles.actionsRow, styles.iconFrame, trailing]);
|
|
849
|
-
const onLeadingLayout = (0,
|
|
801
|
+
const onLeadingLayout = (0, import_react3.useCallback)((event) => {
|
|
850
802
|
const nextWidth = measureWidth(event);
|
|
851
803
|
setLeadingWidth((currentWidth) => {
|
|
852
804
|
if (currentWidth === nextWidth) {
|
|
@@ -855,7 +807,7 @@ function AppBar({
|
|
|
855
807
|
return nextWidth;
|
|
856
808
|
});
|
|
857
809
|
}, []);
|
|
858
|
-
const onActionsLayout = (0,
|
|
810
|
+
const onActionsLayout = (0, import_react3.useCallback)((event) => {
|
|
859
811
|
const nextWidth = measureWidth(event);
|
|
860
812
|
setActionsWidth((currentWidth) => {
|
|
861
813
|
if (currentWidth === nextWidth) {
|
|
@@ -864,9 +816,9 @@ function AppBar({
|
|
|
864
816
|
return nextWidth;
|
|
865
817
|
});
|
|
866
818
|
}, []);
|
|
867
|
-
const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
819
|
+
const topRow = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native5.View, { style: styles.topRow, children: [
|
|
868
820
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
869
|
-
|
|
821
|
+
import_react_native5.View,
|
|
870
822
|
{
|
|
871
823
|
collapsable: false,
|
|
872
824
|
onLayout: onLeadingLayout,
|
|
@@ -874,9 +826,9 @@ function AppBar({
|
|
|
874
826
|
children: leadingContent
|
|
875
827
|
}
|
|
876
828
|
),
|
|
877
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
829
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: styles.topRowSpacer }),
|
|
878
830
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
879
|
-
|
|
831
|
+
import_react_native5.View,
|
|
880
832
|
{
|
|
881
833
|
collapsable: false,
|
|
882
834
|
onLayout: onActionsLayout,
|
|
@@ -898,10 +850,10 @@ function AppBar({
|
|
|
898
850
|
containerOverride
|
|
899
851
|
];
|
|
900
852
|
if (isExpanded) {
|
|
901
|
-
const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
853
|
+
const content2 = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native5.View, { style: [styles.expandedContainer, getSizeStyle2(styles, size)], children: [
|
|
902
854
|
topRow,
|
|
903
855
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
904
|
-
|
|
856
|
+
import_react_native5.View,
|
|
905
857
|
{
|
|
906
858
|
style: [
|
|
907
859
|
styles.expandedTitleContainer,
|
|
@@ -925,11 +877,11 @@ function AppBar({
|
|
|
925
877
|
}
|
|
926
878
|
)
|
|
927
879
|
] });
|
|
928
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: rootStyle, children: withTopInset(insetTop, content2, safeAreaStyle) });
|
|
929
881
|
}
|
|
930
|
-
const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
882
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native5.View, { style: styles.smallContainer, children: [
|
|
931
883
|
topRow,
|
|
932
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
884
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: [styles.overlayTitleContainer, overlayTitleInsetStyle], children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
933
885
|
Typography,
|
|
934
886
|
{
|
|
935
887
|
...APP_BAR_TITLE_TEXT_PROPS,
|
|
@@ -944,7 +896,7 @@ function AppBar({
|
|
|
944
896
|
}
|
|
945
897
|
) })
|
|
946
898
|
] });
|
|
947
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.View, { style: rootStyle, children: withTopInset(insetTop, content, safeAreaStyle) });
|
|
948
900
|
}
|
|
949
901
|
// Annotate the CommonJS export names for ESM import in node:
|
|
950
902
|
0 && (module.exports = {
|