@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
package/dist/index.js
ADDED
|
@@ -0,0 +1,3681 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
AppBar: () => AppBar,
|
|
34
|
+
Avatar: () => Avatar,
|
|
35
|
+
Box: () => Box,
|
|
36
|
+
Button: () => Button,
|
|
37
|
+
Card: () => Card,
|
|
38
|
+
Checkbox: () => Checkbox,
|
|
39
|
+
Chip: () => Chip,
|
|
40
|
+
Column: () => Column,
|
|
41
|
+
Grid: () => Grid,
|
|
42
|
+
IconButton: () => IconButton,
|
|
43
|
+
KeyboardAvoidingWrapper: () => KeyboardAvoidingWrapper,
|
|
44
|
+
Layout: () => Layout,
|
|
45
|
+
List: () => List,
|
|
46
|
+
ListDivider: () => ListDivider,
|
|
47
|
+
ListItem: () => ListItem,
|
|
48
|
+
Radio: () => Radio,
|
|
49
|
+
Row: () => Row,
|
|
50
|
+
Switch: () => Switch,
|
|
51
|
+
TextField: () => TextField,
|
|
52
|
+
Typography: () => Typography
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(index_exports);
|
|
55
|
+
|
|
56
|
+
// src/typography/Typography.tsx
|
|
57
|
+
var import_react = require("react");
|
|
58
|
+
var import_react_native = require("react-native");
|
|
59
|
+
var import_core = require("@onlynative/core");
|
|
60
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
61
|
+
var HEADING_VARIANTS = /* @__PURE__ */ new Set([
|
|
62
|
+
"displayLarge",
|
|
63
|
+
"displayMedium",
|
|
64
|
+
"displaySmall",
|
|
65
|
+
"headlineLarge",
|
|
66
|
+
"headlineMedium",
|
|
67
|
+
"headlineSmall"
|
|
68
|
+
]);
|
|
69
|
+
function Typography({
|
|
70
|
+
children,
|
|
71
|
+
variant = "bodyMedium",
|
|
72
|
+
color,
|
|
73
|
+
style,
|
|
74
|
+
as: Component = import_react_native.Text,
|
|
75
|
+
accessibilityRole,
|
|
76
|
+
...textProps
|
|
77
|
+
}) {
|
|
78
|
+
const theme = (0, import_core.useTheme)();
|
|
79
|
+
const typographyStyle = theme.typography[variant];
|
|
80
|
+
const resolvedRole = accessibilityRole != null ? accessibilityRole : HEADING_VARIANTS.has(variant) ? "header" : void 0;
|
|
81
|
+
const lineHeightFix = (0, import_react.useMemo)(() => {
|
|
82
|
+
if (!style) return void 0;
|
|
83
|
+
const flat = import_react_native.StyleSheet.flatten(style);
|
|
84
|
+
if (!(flat == null ? void 0 : flat.fontSize) || flat.lineHeight) return void 0;
|
|
85
|
+
const ratio = typographyStyle.lineHeight / typographyStyle.fontSize;
|
|
86
|
+
return { lineHeight: Math.ceil(flat.fontSize * ratio) };
|
|
87
|
+
}, [style, typographyStyle.fontSize, typographyStyle.lineHeight]);
|
|
88
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
+
Component,
|
|
90
|
+
{
|
|
91
|
+
...textProps,
|
|
92
|
+
accessibilityRole: resolvedRole,
|
|
93
|
+
style: [
|
|
94
|
+
{ color: theme.colors.onSurface },
|
|
95
|
+
typographyStyle,
|
|
96
|
+
style,
|
|
97
|
+
lineHeightFix,
|
|
98
|
+
color != null ? { color } : void 0
|
|
99
|
+
],
|
|
100
|
+
children
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/layout/Layout.tsx
|
|
106
|
+
var import_react2 = require("react");
|
|
107
|
+
var import_react_native2 = require("react-native");
|
|
108
|
+
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
109
|
+
var import_core2 = require("@onlynative/core");
|
|
110
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
111
|
+
var defaultEdges = ["bottom"];
|
|
112
|
+
function resolveEdges(immersive, edges) {
|
|
113
|
+
if (edges) {
|
|
114
|
+
return edges;
|
|
115
|
+
}
|
|
116
|
+
if (immersive) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
return defaultEdges;
|
|
120
|
+
}
|
|
121
|
+
var styles = import_react_native2.StyleSheet.create({
|
|
122
|
+
root: {
|
|
123
|
+
flex: 1
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
function removeBackgroundColor(style) {
|
|
127
|
+
if (!style) {
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
const flattenedStyle = import_react_native2.StyleSheet.flatten(style);
|
|
131
|
+
if (!flattenedStyle || flattenedStyle.backgroundColor === void 0) {
|
|
132
|
+
return style;
|
|
133
|
+
}
|
|
134
|
+
const styleWithoutBackground = { ...flattenedStyle };
|
|
135
|
+
delete styleWithoutBackground.backgroundColor;
|
|
136
|
+
return styleWithoutBackground;
|
|
137
|
+
}
|
|
138
|
+
function Layout({ immersive, edges, children, style }) {
|
|
139
|
+
const theme = (0, import_core2.useTheme)();
|
|
140
|
+
const themeBackgroundStyle = (0, import_react2.useMemo)(
|
|
141
|
+
() => ({ backgroundColor: theme.colors.background }),
|
|
142
|
+
[theme.colors.background]
|
|
143
|
+
);
|
|
144
|
+
const styleWithoutBackground = (0, import_react2.useMemo)(
|
|
145
|
+
() => removeBackgroundColor(style),
|
|
146
|
+
[style]
|
|
147
|
+
);
|
|
148
|
+
const safeAreaEdges = (0, import_react2.useMemo)(
|
|
149
|
+
() => resolveEdges(immersive, edges),
|
|
150
|
+
[immersive, edges]
|
|
151
|
+
);
|
|
152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
153
|
+
import_react_native_safe_area_context.SafeAreaView,
|
|
154
|
+
{
|
|
155
|
+
style: [styles.root, themeBackgroundStyle, styleWithoutBackground],
|
|
156
|
+
edges: safeAreaEdges,
|
|
157
|
+
children
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// src/layout/Box.tsx
|
|
163
|
+
var import_react3 = require("react");
|
|
164
|
+
var import_react_native3 = require("react-native");
|
|
165
|
+
var import_core3 = require("@onlynative/core");
|
|
166
|
+
|
|
167
|
+
// src/layout/resolveSpacing.ts
|
|
168
|
+
function resolveSpacing(spacing, value) {
|
|
169
|
+
if (value === void 0) return void 0;
|
|
170
|
+
if (typeof value === "number") return value;
|
|
171
|
+
return spacing[value];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/layout/Box.tsx
|
|
175
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
176
|
+
function Box({
|
|
177
|
+
p,
|
|
178
|
+
px,
|
|
179
|
+
py,
|
|
180
|
+
pt,
|
|
181
|
+
pb,
|
|
182
|
+
ps,
|
|
183
|
+
pe,
|
|
184
|
+
m,
|
|
185
|
+
mx,
|
|
186
|
+
my,
|
|
187
|
+
mt,
|
|
188
|
+
mb,
|
|
189
|
+
ms,
|
|
190
|
+
me,
|
|
191
|
+
gap,
|
|
192
|
+
rowGap,
|
|
193
|
+
columnGap,
|
|
194
|
+
flex,
|
|
195
|
+
align,
|
|
196
|
+
justify,
|
|
197
|
+
bg,
|
|
198
|
+
style,
|
|
199
|
+
...viewProps
|
|
200
|
+
}) {
|
|
201
|
+
const { spacing } = (0, import_core3.useTheme)();
|
|
202
|
+
const layoutStyle = (0, import_react3.useMemo)(() => {
|
|
203
|
+
const s = (v) => resolveSpacing(spacing, v);
|
|
204
|
+
return {
|
|
205
|
+
...p !== void 0 && { padding: s(p) },
|
|
206
|
+
...px !== void 0 && {
|
|
207
|
+
paddingStart: s(px),
|
|
208
|
+
paddingEnd: s(px)
|
|
209
|
+
},
|
|
210
|
+
...py !== void 0 && {
|
|
211
|
+
paddingTop: s(py),
|
|
212
|
+
paddingBottom: s(py)
|
|
213
|
+
},
|
|
214
|
+
...pt !== void 0 && { paddingTop: s(pt) },
|
|
215
|
+
...pb !== void 0 && { paddingBottom: s(pb) },
|
|
216
|
+
...ps !== void 0 && { paddingStart: s(ps) },
|
|
217
|
+
...pe !== void 0 && { paddingEnd: s(pe) },
|
|
218
|
+
...m !== void 0 && { margin: s(m) },
|
|
219
|
+
...mx !== void 0 && {
|
|
220
|
+
marginStart: s(mx),
|
|
221
|
+
marginEnd: s(mx)
|
|
222
|
+
},
|
|
223
|
+
...my !== void 0 && {
|
|
224
|
+
marginTop: s(my),
|
|
225
|
+
marginBottom: s(my)
|
|
226
|
+
},
|
|
227
|
+
...mt !== void 0 && { marginTop: s(mt) },
|
|
228
|
+
...mb !== void 0 && { marginBottom: s(mb) },
|
|
229
|
+
...ms !== void 0 && { marginStart: s(ms) },
|
|
230
|
+
...me !== void 0 && { marginEnd: s(me) },
|
|
231
|
+
...gap !== void 0 && { gap: s(gap) },
|
|
232
|
+
...rowGap !== void 0 && { rowGap: s(rowGap) },
|
|
233
|
+
...columnGap !== void 0 && { columnGap: s(columnGap) },
|
|
234
|
+
...flex !== void 0 && { flex },
|
|
235
|
+
...align !== void 0 && { alignItems: align },
|
|
236
|
+
...justify !== void 0 && { justifyContent: justify },
|
|
237
|
+
...bg !== void 0 && { backgroundColor: bg }
|
|
238
|
+
};
|
|
239
|
+
}, [
|
|
240
|
+
spacing,
|
|
241
|
+
p,
|
|
242
|
+
px,
|
|
243
|
+
py,
|
|
244
|
+
pt,
|
|
245
|
+
pb,
|
|
246
|
+
ps,
|
|
247
|
+
pe,
|
|
248
|
+
m,
|
|
249
|
+
mx,
|
|
250
|
+
my,
|
|
251
|
+
mt,
|
|
252
|
+
mb,
|
|
253
|
+
ms,
|
|
254
|
+
me,
|
|
255
|
+
gap,
|
|
256
|
+
rowGap,
|
|
257
|
+
columnGap,
|
|
258
|
+
flex,
|
|
259
|
+
align,
|
|
260
|
+
justify,
|
|
261
|
+
bg
|
|
262
|
+
]);
|
|
263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { ...viewProps, style: [layoutStyle, style] });
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// src/layout/Column.tsx
|
|
267
|
+
var import_react4 = require("react");
|
|
268
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
269
|
+
function Column({ inverted = false, style, ...boxProps }) {
|
|
270
|
+
const directionStyle = (0, import_react4.useMemo)(
|
|
271
|
+
() => ({
|
|
272
|
+
flexDirection: inverted ? "column-reverse" : "column"
|
|
273
|
+
}),
|
|
274
|
+
[inverted]
|
|
275
|
+
);
|
|
276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { ...boxProps, style: [directionStyle, style] });
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// src/layout/Grid.tsx
|
|
280
|
+
var import_react6 = __toESM(require("react"));
|
|
281
|
+
var import_react_native4 = require("react-native");
|
|
282
|
+
var import_core4 = require("@onlynative/core");
|
|
283
|
+
|
|
284
|
+
// src/layout/Row.tsx
|
|
285
|
+
var import_react5 = require("react");
|
|
286
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
287
|
+
function Row({
|
|
288
|
+
wrap = false,
|
|
289
|
+
inverted = false,
|
|
290
|
+
style,
|
|
291
|
+
...boxProps
|
|
292
|
+
}) {
|
|
293
|
+
const directionStyle = (0, import_react5.useMemo)(
|
|
294
|
+
() => ({
|
|
295
|
+
flexDirection: inverted ? "row-reverse" : "row",
|
|
296
|
+
...wrap && { flexWrap: "wrap" }
|
|
297
|
+
}),
|
|
298
|
+
[wrap, inverted]
|
|
299
|
+
);
|
|
300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { ...boxProps, style: [directionStyle, style] });
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/layout/Grid.tsx
|
|
304
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
305
|
+
function Grid({
|
|
306
|
+
columns,
|
|
307
|
+
gap,
|
|
308
|
+
columnGap,
|
|
309
|
+
rowGap,
|
|
310
|
+
children,
|
|
311
|
+
style,
|
|
312
|
+
...rowProps
|
|
313
|
+
}) {
|
|
314
|
+
const { spacing } = (0, import_core4.useTheme)();
|
|
315
|
+
const resolvedColumnGap = resolveSpacing(spacing, columnGap != null ? columnGap : gap);
|
|
316
|
+
const resolvedRowGap = resolveSpacing(spacing, rowGap != null ? rowGap : gap);
|
|
317
|
+
const halfGap = resolvedColumnGap ? resolvedColumnGap / 2 : 0;
|
|
318
|
+
const cellStyle = (0, import_react6.useMemo)(
|
|
319
|
+
() => ({
|
|
320
|
+
flexBasis: `${100 / columns}%`,
|
|
321
|
+
flexShrink: 1,
|
|
322
|
+
paddingStart: halfGap,
|
|
323
|
+
paddingEnd: halfGap
|
|
324
|
+
}),
|
|
325
|
+
[columns, halfGap]
|
|
326
|
+
);
|
|
327
|
+
const rowStyle = (0, import_react6.useMemo)(
|
|
328
|
+
() => ({
|
|
329
|
+
marginStart: -halfGap,
|
|
330
|
+
marginEnd: -halfGap
|
|
331
|
+
}),
|
|
332
|
+
[halfGap]
|
|
333
|
+
);
|
|
334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Row, { wrap: true, rowGap: resolvedRowGap, ...rowProps, style: [rowStyle, style], children: import_react6.default.Children.map(
|
|
335
|
+
children,
|
|
336
|
+
(child) => child != null ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native4.View, { style: cellStyle, children: child }) : null
|
|
337
|
+
) });
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/button/Button.tsx
|
|
341
|
+
var import_react7 = require("react");
|
|
342
|
+
var import_react_native8 = require("react-native");
|
|
343
|
+
var import_react_native9 = require("react-native");
|
|
344
|
+
var import_react_native10 = require("react-native");
|
|
345
|
+
var import_core5 = require("@onlynative/core");
|
|
346
|
+
|
|
347
|
+
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
348
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
349
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
350
|
+
}) : x)(function(x) {
|
|
351
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
352
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// ../utils/dist/index.mjs
|
|
356
|
+
var import_react_native5 = require("react-native");
|
|
357
|
+
var import_react_native6 = require("react-native");
|
|
358
|
+
function parseHexColor(color) {
|
|
359
|
+
const normalized = color.replace("#", "");
|
|
360
|
+
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
const r = Number.parseInt(normalized.slice(0, 2), 16);
|
|
364
|
+
const g = Number.parseInt(normalized.slice(2, 4), 16);
|
|
365
|
+
const b = Number.parseInt(normalized.slice(4, 6), 16);
|
|
366
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
return { r, g, b };
|
|
370
|
+
}
|
|
371
|
+
function clampAlpha(alpha) {
|
|
372
|
+
return Math.max(0, Math.min(1, alpha));
|
|
373
|
+
}
|
|
374
|
+
function alphaColor(color, alpha) {
|
|
375
|
+
const channels = parseHexColor(color);
|
|
376
|
+
const boundedAlpha = clampAlpha(alpha);
|
|
377
|
+
if (!channels) {
|
|
378
|
+
return color;
|
|
379
|
+
}
|
|
380
|
+
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
381
|
+
}
|
|
382
|
+
function blendColor(base, overlay, overlayAlpha) {
|
|
383
|
+
const baseChannels = parseHexColor(base);
|
|
384
|
+
const overlayChannels = parseHexColor(overlay);
|
|
385
|
+
const boundedAlpha = clampAlpha(overlayAlpha);
|
|
386
|
+
if (!baseChannels || !overlayChannels) {
|
|
387
|
+
return alphaColor(overlay, boundedAlpha);
|
|
388
|
+
}
|
|
389
|
+
const r = Math.round(
|
|
390
|
+
(1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
|
|
391
|
+
);
|
|
392
|
+
const g = Math.round(
|
|
393
|
+
(1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
|
|
394
|
+
);
|
|
395
|
+
const b = Math.round(
|
|
396
|
+
(1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
|
|
397
|
+
);
|
|
398
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
399
|
+
}
|
|
400
|
+
function elevationStyle(level) {
|
|
401
|
+
if (import_react_native5.Platform.OS === "web") {
|
|
402
|
+
const { shadowOffset, shadowOpacity, shadowRadius } = level;
|
|
403
|
+
if (shadowOpacity === 0) {
|
|
404
|
+
return { boxShadow: "none" };
|
|
405
|
+
}
|
|
406
|
+
return {
|
|
407
|
+
boxShadow: `${shadowOffset.width}px ${shadowOffset.height}px ${shadowRadius}px rgba(0, 0, 0, ${shadowOpacity})`
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
shadowColor: level.shadowColor,
|
|
412
|
+
shadowOffset: {
|
|
413
|
+
width: level.shadowOffset.width,
|
|
414
|
+
height: level.shadowOffset.height
|
|
415
|
+
},
|
|
416
|
+
shadowOpacity: level.shadowOpacity,
|
|
417
|
+
shadowRadius: level.shadowRadius,
|
|
418
|
+
elevation: level.elevation
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
var _MCIcons = null;
|
|
422
|
+
var _resolved = false;
|
|
423
|
+
function getMaterialCommunityIcons() {
|
|
424
|
+
if (!_resolved) {
|
|
425
|
+
_resolved = true;
|
|
426
|
+
try {
|
|
427
|
+
const mod = __require("@expo/vector-icons/MaterialCommunityIcons");
|
|
428
|
+
_MCIcons = mod.default || mod;
|
|
429
|
+
} catch {
|
|
430
|
+
_MCIcons = null;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (!_MCIcons) {
|
|
434
|
+
throw new Error(
|
|
435
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
return _MCIcons;
|
|
439
|
+
}
|
|
440
|
+
function transformOrigin(vertical = "top") {
|
|
441
|
+
return import_react_native6.I18nManager.isRTL ? `right ${vertical}` : `left ${vertical}`;
|
|
442
|
+
}
|
|
443
|
+
function selectRTL(ltr, rtl) {
|
|
444
|
+
return import_react_native6.I18nManager.isRTL ? rtl : ltr;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// src/button/styles.ts
|
|
448
|
+
var import_react_native7 = require("react-native");
|
|
449
|
+
function getVariantColors(theme, variant) {
|
|
450
|
+
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
451
|
+
const disabledLabelColor = alphaColor(theme.colors.onSurface, 0.38);
|
|
452
|
+
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
453
|
+
if (variant === "outlined") {
|
|
454
|
+
return {
|
|
455
|
+
backgroundColor: "transparent",
|
|
456
|
+
textColor: theme.colors.primary,
|
|
457
|
+
borderColor: theme.colors.outline,
|
|
458
|
+
borderWidth: 1,
|
|
459
|
+
hoveredBackgroundColor: alphaColor(
|
|
460
|
+
theme.colors.primary,
|
|
461
|
+
theme.stateLayer.hoveredOpacity
|
|
462
|
+
),
|
|
463
|
+
pressedBackgroundColor: alphaColor(
|
|
464
|
+
theme.colors.primary,
|
|
465
|
+
theme.stateLayer.pressedOpacity
|
|
466
|
+
),
|
|
467
|
+
disabledBackgroundColor: "transparent",
|
|
468
|
+
disabledTextColor: disabledLabelColor,
|
|
469
|
+
disabledBorderColor: disabledOutlineColor
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
if (variant === "text") {
|
|
473
|
+
return {
|
|
474
|
+
backgroundColor: "transparent",
|
|
475
|
+
textColor: theme.colors.primary,
|
|
476
|
+
borderColor: "transparent",
|
|
477
|
+
borderWidth: 0,
|
|
478
|
+
hoveredBackgroundColor: alphaColor(
|
|
479
|
+
theme.colors.primary,
|
|
480
|
+
theme.stateLayer.hoveredOpacity
|
|
481
|
+
),
|
|
482
|
+
pressedBackgroundColor: alphaColor(
|
|
483
|
+
theme.colors.primary,
|
|
484
|
+
theme.stateLayer.pressedOpacity
|
|
485
|
+
),
|
|
486
|
+
disabledBackgroundColor: "transparent",
|
|
487
|
+
disabledTextColor: disabledLabelColor,
|
|
488
|
+
disabledBorderColor: "transparent"
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
if (variant === "elevated") {
|
|
492
|
+
return {
|
|
493
|
+
backgroundColor: theme.colors.surfaceContainerLow,
|
|
494
|
+
textColor: theme.colors.primary,
|
|
495
|
+
borderColor: theme.colors.surfaceContainerLow,
|
|
496
|
+
borderWidth: 0,
|
|
497
|
+
hoveredBackgroundColor: blendColor(
|
|
498
|
+
theme.colors.surfaceContainerLow,
|
|
499
|
+
theme.colors.primary,
|
|
500
|
+
theme.stateLayer.hoveredOpacity
|
|
501
|
+
),
|
|
502
|
+
pressedBackgroundColor: blendColor(
|
|
503
|
+
theme.colors.surfaceContainerLow,
|
|
504
|
+
theme.colors.primary,
|
|
505
|
+
theme.stateLayer.pressedOpacity
|
|
506
|
+
),
|
|
507
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
508
|
+
disabledTextColor: disabledLabelColor,
|
|
509
|
+
disabledBorderColor: disabledContainerColor
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
if (variant === "tonal") {
|
|
513
|
+
return {
|
|
514
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
515
|
+
textColor: theme.colors.onSecondaryContainer,
|
|
516
|
+
borderColor: theme.colors.secondaryContainer,
|
|
517
|
+
borderWidth: 0,
|
|
518
|
+
hoveredBackgroundColor: blendColor(
|
|
519
|
+
theme.colors.secondaryContainer,
|
|
520
|
+
theme.colors.onSecondaryContainer,
|
|
521
|
+
theme.stateLayer.hoveredOpacity
|
|
522
|
+
),
|
|
523
|
+
pressedBackgroundColor: blendColor(
|
|
524
|
+
theme.colors.secondaryContainer,
|
|
525
|
+
theme.colors.onSecondaryContainer,
|
|
526
|
+
theme.stateLayer.pressedOpacity
|
|
527
|
+
),
|
|
528
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
529
|
+
disabledTextColor: disabledLabelColor,
|
|
530
|
+
disabledBorderColor: disabledContainerColor
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
return {
|
|
534
|
+
backgroundColor: theme.colors.primary,
|
|
535
|
+
textColor: theme.colors.onPrimary,
|
|
536
|
+
borderColor: theme.colors.primary,
|
|
537
|
+
borderWidth: 0,
|
|
538
|
+
hoveredBackgroundColor: blendColor(
|
|
539
|
+
theme.colors.primary,
|
|
540
|
+
theme.colors.onPrimary,
|
|
541
|
+
theme.stateLayer.hoveredOpacity
|
|
542
|
+
),
|
|
543
|
+
pressedBackgroundColor: blendColor(
|
|
544
|
+
theme.colors.primary,
|
|
545
|
+
theme.colors.onPrimary,
|
|
546
|
+
theme.stateLayer.pressedOpacity
|
|
547
|
+
),
|
|
548
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
549
|
+
disabledTextColor: disabledLabelColor,
|
|
550
|
+
disabledBorderColor: disabledContainerColor
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function getHorizontalPadding(theme, variant, hasLeadingIcon, hasTrailingIcon) {
|
|
554
|
+
if (variant === "text") {
|
|
555
|
+
return {
|
|
556
|
+
paddingStart: hasLeadingIcon ? 12 : hasTrailingIcon ? theme.spacing.md : 12,
|
|
557
|
+
paddingEnd: hasTrailingIcon ? 12 : hasLeadingIcon ? theme.spacing.md : 12
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
return {
|
|
561
|
+
paddingStart: hasLeadingIcon ? theme.spacing.md : theme.spacing.lg,
|
|
562
|
+
paddingEnd: hasTrailingIcon ? theme.spacing.md : theme.spacing.lg
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
function applyColorOverrides(theme, colors, containerColor, contentColor) {
|
|
566
|
+
if (!containerColor && !contentColor) return colors;
|
|
567
|
+
const result = { ...colors };
|
|
568
|
+
if (contentColor) {
|
|
569
|
+
result.textColor = contentColor;
|
|
570
|
+
}
|
|
571
|
+
if (containerColor) {
|
|
572
|
+
const overlay = contentColor != null ? contentColor : colors.textColor;
|
|
573
|
+
result.backgroundColor = containerColor;
|
|
574
|
+
result.borderColor = containerColor;
|
|
575
|
+
result.hoveredBackgroundColor = blendColor(
|
|
576
|
+
containerColor,
|
|
577
|
+
overlay,
|
|
578
|
+
theme.stateLayer.hoveredOpacity
|
|
579
|
+
);
|
|
580
|
+
result.pressedBackgroundColor = blendColor(
|
|
581
|
+
containerColor,
|
|
582
|
+
overlay,
|
|
583
|
+
theme.stateLayer.pressedOpacity
|
|
584
|
+
);
|
|
585
|
+
} else if (contentColor) {
|
|
586
|
+
if (colors.backgroundColor === "transparent") {
|
|
587
|
+
result.hoveredBackgroundColor = alphaColor(
|
|
588
|
+
contentColor,
|
|
589
|
+
theme.stateLayer.hoveredOpacity
|
|
590
|
+
);
|
|
591
|
+
result.pressedBackgroundColor = alphaColor(
|
|
592
|
+
contentColor,
|
|
593
|
+
theme.stateLayer.pressedOpacity
|
|
594
|
+
);
|
|
595
|
+
} else {
|
|
596
|
+
result.hoveredBackgroundColor = blendColor(
|
|
597
|
+
colors.backgroundColor,
|
|
598
|
+
contentColor,
|
|
599
|
+
theme.stateLayer.hoveredOpacity
|
|
600
|
+
);
|
|
601
|
+
result.pressedBackgroundColor = blendColor(
|
|
602
|
+
colors.backgroundColor,
|
|
603
|
+
contentColor,
|
|
604
|
+
theme.stateLayer.pressedOpacity
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return result;
|
|
609
|
+
}
|
|
610
|
+
function createStyles(theme, variant, hasLeadingIcon, hasTrailingIcon, containerColor, contentColor) {
|
|
611
|
+
const baseColors = getVariantColors(theme, variant);
|
|
612
|
+
const colors = applyColorOverrides(
|
|
613
|
+
theme,
|
|
614
|
+
baseColors,
|
|
615
|
+
containerColor,
|
|
616
|
+
contentColor
|
|
617
|
+
);
|
|
618
|
+
const labelStyle = theme.typography.labelLarge;
|
|
619
|
+
const padding = getHorizontalPadding(
|
|
620
|
+
theme,
|
|
621
|
+
variant,
|
|
622
|
+
hasLeadingIcon,
|
|
623
|
+
hasTrailingIcon
|
|
624
|
+
);
|
|
625
|
+
const elevationLevel0 = elevationStyle(theme.elevation.level0);
|
|
626
|
+
const elevationLevel1 = elevationStyle(theme.elevation.level1);
|
|
627
|
+
const elevationLevel2 = elevationStyle(theme.elevation.level2);
|
|
628
|
+
const baseElevation = variant === "elevated" ? elevationLevel1 : elevationLevel0;
|
|
629
|
+
return import_react_native7.StyleSheet.create({
|
|
630
|
+
container: {
|
|
631
|
+
alignSelf: "flex-start",
|
|
632
|
+
alignItems: "center",
|
|
633
|
+
flexDirection: "row",
|
|
634
|
+
justifyContent: "center",
|
|
635
|
+
minWidth: 58,
|
|
636
|
+
minHeight: 40,
|
|
637
|
+
paddingStart: padding.paddingStart,
|
|
638
|
+
paddingEnd: padding.paddingEnd,
|
|
639
|
+
paddingVertical: 10,
|
|
640
|
+
borderRadius: theme.shape.cornerFull,
|
|
641
|
+
backgroundColor: colors.backgroundColor,
|
|
642
|
+
borderColor: colors.borderColor,
|
|
643
|
+
borderWidth: colors.borderWidth,
|
|
644
|
+
cursor: "pointer",
|
|
645
|
+
...baseElevation
|
|
646
|
+
},
|
|
647
|
+
hoveredContainer: {
|
|
648
|
+
backgroundColor: colors.hoveredBackgroundColor,
|
|
649
|
+
...variant === "elevated" ? elevationLevel2 : void 0
|
|
650
|
+
},
|
|
651
|
+
pressedContainer: {
|
|
652
|
+
backgroundColor: colors.pressedBackgroundColor
|
|
653
|
+
},
|
|
654
|
+
disabledContainer: {
|
|
655
|
+
backgroundColor: colors.disabledBackgroundColor,
|
|
656
|
+
borderColor: colors.disabledBorderColor,
|
|
657
|
+
cursor: "auto",
|
|
658
|
+
...elevationLevel0
|
|
659
|
+
},
|
|
660
|
+
label: {
|
|
661
|
+
fontFamily: labelStyle.fontFamily,
|
|
662
|
+
fontSize: labelStyle.fontSize,
|
|
663
|
+
lineHeight: labelStyle.lineHeight,
|
|
664
|
+
fontWeight: labelStyle.fontWeight,
|
|
665
|
+
letterSpacing: labelStyle.letterSpacing,
|
|
666
|
+
color: colors.textColor
|
|
667
|
+
},
|
|
668
|
+
leadingIcon: {
|
|
669
|
+
marginEnd: theme.spacing.sm
|
|
670
|
+
},
|
|
671
|
+
trailingIcon: {
|
|
672
|
+
marginStart: theme.spacing.sm
|
|
673
|
+
},
|
|
674
|
+
disabledLabel: {
|
|
675
|
+
color: colors.disabledTextColor
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// src/button/Button.tsx
|
|
681
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
682
|
+
function resolveStyle(containerStyle, hoveredContainerStyle, pressedContainerStyle, disabledContainerStyle, disabled, style) {
|
|
683
|
+
if (typeof style === "function") {
|
|
684
|
+
return (state) => [
|
|
685
|
+
containerStyle,
|
|
686
|
+
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
687
|
+
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
688
|
+
disabled ? disabledContainerStyle : void 0,
|
|
689
|
+
style(state)
|
|
690
|
+
];
|
|
691
|
+
}
|
|
692
|
+
return (state) => [
|
|
693
|
+
containerStyle,
|
|
694
|
+
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
695
|
+
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
696
|
+
disabled ? disabledContainerStyle : void 0,
|
|
697
|
+
style
|
|
698
|
+
];
|
|
699
|
+
}
|
|
700
|
+
function Button({
|
|
701
|
+
children,
|
|
702
|
+
style,
|
|
703
|
+
variant = "filled",
|
|
704
|
+
leadingIcon,
|
|
705
|
+
trailingIcon,
|
|
706
|
+
iconSize = 18,
|
|
707
|
+
containerColor,
|
|
708
|
+
contentColor,
|
|
709
|
+
labelStyle: labelStyleOverride,
|
|
710
|
+
disabled = false,
|
|
711
|
+
...props
|
|
712
|
+
}) {
|
|
713
|
+
const isDisabled = Boolean(disabled);
|
|
714
|
+
const hasLeading = Boolean(leadingIcon);
|
|
715
|
+
const hasTrailing = Boolean(trailingIcon);
|
|
716
|
+
const theme = (0, import_core5.useTheme)();
|
|
717
|
+
const styles3 = (0, import_react7.useMemo)(
|
|
718
|
+
() => createStyles(
|
|
719
|
+
theme,
|
|
720
|
+
variant,
|
|
721
|
+
hasLeading,
|
|
722
|
+
hasTrailing,
|
|
723
|
+
containerColor,
|
|
724
|
+
contentColor
|
|
725
|
+
),
|
|
726
|
+
[theme, variant, hasLeading, hasTrailing, containerColor, contentColor]
|
|
727
|
+
);
|
|
728
|
+
const MaterialCommunityIcons = leadingIcon || trailingIcon ? getMaterialCommunityIcons() : null;
|
|
729
|
+
const resolvedIconColor = (0, import_react7.useMemo)(() => {
|
|
730
|
+
const base = import_react_native9.StyleSheet.flatten([
|
|
731
|
+
styles3.label,
|
|
732
|
+
isDisabled ? styles3.disabledLabel : void 0
|
|
733
|
+
]);
|
|
734
|
+
return typeof (base == null ? void 0 : base.color) === "string" ? base.color : void 0;
|
|
735
|
+
}, [styles3.label, styles3.disabledLabel, isDisabled]);
|
|
736
|
+
const computedLabelStyle = (0, import_react7.useMemo)(
|
|
737
|
+
() => [
|
|
738
|
+
styles3.label,
|
|
739
|
+
isDisabled ? styles3.disabledLabel : void 0,
|
|
740
|
+
labelStyleOverride
|
|
741
|
+
],
|
|
742
|
+
[isDisabled, styles3.disabledLabel, styles3.label, labelStyleOverride]
|
|
743
|
+
);
|
|
744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
745
|
+
import_react_native8.Pressable,
|
|
746
|
+
{
|
|
747
|
+
...props,
|
|
748
|
+
accessibilityRole: "button",
|
|
749
|
+
accessibilityState: { disabled: isDisabled },
|
|
750
|
+
hitSlop: import_react_native8.Platform.OS === "web" ? void 0 : 4,
|
|
751
|
+
disabled: isDisabled,
|
|
752
|
+
style: resolveStyle(
|
|
753
|
+
styles3.container,
|
|
754
|
+
styles3.hoveredContainer,
|
|
755
|
+
styles3.pressedContainer,
|
|
756
|
+
styles3.disabledContainer,
|
|
757
|
+
isDisabled,
|
|
758
|
+
style
|
|
759
|
+
),
|
|
760
|
+
children: [
|
|
761
|
+
leadingIcon ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
762
|
+
MaterialCommunityIcons,
|
|
763
|
+
{
|
|
764
|
+
name: leadingIcon,
|
|
765
|
+
size: iconSize,
|
|
766
|
+
color: resolvedIconColor,
|
|
767
|
+
style: styles3.leadingIcon
|
|
768
|
+
}
|
|
769
|
+
) : null,
|
|
770
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { style: computedLabelStyle, children }),
|
|
771
|
+
trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
772
|
+
MaterialCommunityIcons,
|
|
773
|
+
{
|
|
774
|
+
name: trailingIcon,
|
|
775
|
+
size: iconSize,
|
|
776
|
+
color: resolvedIconColor,
|
|
777
|
+
style: styles3.trailingIcon
|
|
778
|
+
}
|
|
779
|
+
) : null
|
|
780
|
+
]
|
|
781
|
+
}
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// src/icon-button/IconButton.tsx
|
|
786
|
+
var import_react8 = require("react");
|
|
787
|
+
var import_react_native12 = require("react-native");
|
|
788
|
+
var import_core6 = require("@onlynative/core");
|
|
789
|
+
|
|
790
|
+
// src/icon-button/styles.ts
|
|
791
|
+
var import_react_native11 = require("react-native");
|
|
792
|
+
function createStyles2(theme) {
|
|
793
|
+
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
794
|
+
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
795
|
+
const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest;
|
|
796
|
+
return import_react_native11.StyleSheet.create({
|
|
797
|
+
container: {
|
|
798
|
+
borderRadius: theme.shape.cornerFull,
|
|
799
|
+
alignItems: "center",
|
|
800
|
+
justifyContent: "center",
|
|
801
|
+
cursor: "pointer"
|
|
802
|
+
},
|
|
803
|
+
sizeSmall: {
|
|
804
|
+
width: 32,
|
|
805
|
+
height: 32
|
|
806
|
+
},
|
|
807
|
+
sizeMedium: {
|
|
808
|
+
width: 40,
|
|
809
|
+
height: 40
|
|
810
|
+
},
|
|
811
|
+
sizeLarge: {
|
|
812
|
+
width: 48,
|
|
813
|
+
height: 48
|
|
814
|
+
},
|
|
815
|
+
colorFilled: {
|
|
816
|
+
backgroundColor: theme.colors.primary,
|
|
817
|
+
borderColor: theme.colors.primary,
|
|
818
|
+
borderWidth: 0
|
|
819
|
+
},
|
|
820
|
+
colorFilledToggleUnselected: {
|
|
821
|
+
backgroundColor: toggleUnselectedContainerColor,
|
|
822
|
+
borderColor: toggleUnselectedContainerColor,
|
|
823
|
+
borderWidth: 0
|
|
824
|
+
},
|
|
825
|
+
colorFilledToggleSelected: {
|
|
826
|
+
backgroundColor: theme.colors.primary,
|
|
827
|
+
borderColor: theme.colors.primary,
|
|
828
|
+
borderWidth: 0
|
|
829
|
+
},
|
|
830
|
+
colorTonal: {
|
|
831
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
832
|
+
borderColor: theme.colors.secondaryContainer,
|
|
833
|
+
borderWidth: 0
|
|
834
|
+
},
|
|
835
|
+
colorTonalToggleUnselected: {
|
|
836
|
+
backgroundColor: toggleUnselectedContainerColor,
|
|
837
|
+
borderColor: toggleUnselectedContainerColor,
|
|
838
|
+
borderWidth: 0
|
|
839
|
+
},
|
|
840
|
+
colorTonalToggleSelected: {
|
|
841
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
842
|
+
borderColor: theme.colors.secondaryContainer,
|
|
843
|
+
borderWidth: 0
|
|
844
|
+
},
|
|
845
|
+
colorOutlined: {
|
|
846
|
+
borderColor: theme.colors.outline,
|
|
847
|
+
borderWidth: 1
|
|
848
|
+
},
|
|
849
|
+
colorOutlinedToggleSelected: {
|
|
850
|
+
backgroundColor: theme.colors.inverseSurface,
|
|
851
|
+
borderColor: theme.colors.inverseSurface,
|
|
852
|
+
borderWidth: 0
|
|
853
|
+
},
|
|
854
|
+
colorStandard: {
|
|
855
|
+
borderWidth: 0
|
|
856
|
+
},
|
|
857
|
+
colorStandardToggleSelected: {
|
|
858
|
+
borderWidth: 0
|
|
859
|
+
},
|
|
860
|
+
// Hover states (M3: 8% state layer)
|
|
861
|
+
hoveredFilled: {
|
|
862
|
+
backgroundColor: blendColor(
|
|
863
|
+
theme.colors.primary,
|
|
864
|
+
theme.colors.onPrimary,
|
|
865
|
+
theme.stateLayer.hoveredOpacity
|
|
866
|
+
)
|
|
867
|
+
},
|
|
868
|
+
hoveredFilledToggleUnselected: {
|
|
869
|
+
backgroundColor: blendColor(
|
|
870
|
+
toggleUnselectedContainerColor,
|
|
871
|
+
theme.colors.primary,
|
|
872
|
+
theme.stateLayer.hoveredOpacity
|
|
873
|
+
)
|
|
874
|
+
},
|
|
875
|
+
hoveredFilledToggleSelected: {
|
|
876
|
+
backgroundColor: blendColor(
|
|
877
|
+
theme.colors.primary,
|
|
878
|
+
theme.colors.onPrimary,
|
|
879
|
+
theme.stateLayer.hoveredOpacity
|
|
880
|
+
)
|
|
881
|
+
},
|
|
882
|
+
hoveredTonal: {
|
|
883
|
+
backgroundColor: blendColor(
|
|
884
|
+
theme.colors.secondaryContainer,
|
|
885
|
+
theme.colors.onSecondaryContainer,
|
|
886
|
+
theme.stateLayer.hoveredOpacity
|
|
887
|
+
)
|
|
888
|
+
},
|
|
889
|
+
hoveredTonalToggleUnselected: {
|
|
890
|
+
backgroundColor: blendColor(
|
|
891
|
+
toggleUnselectedContainerColor,
|
|
892
|
+
theme.colors.onSurfaceVariant,
|
|
893
|
+
theme.stateLayer.hoveredOpacity
|
|
894
|
+
)
|
|
895
|
+
},
|
|
896
|
+
hoveredTonalToggleSelected: {
|
|
897
|
+
backgroundColor: blendColor(
|
|
898
|
+
theme.colors.secondaryContainer,
|
|
899
|
+
theme.colors.onSecondaryContainer,
|
|
900
|
+
theme.stateLayer.hoveredOpacity
|
|
901
|
+
)
|
|
902
|
+
},
|
|
903
|
+
hoveredOutlined: {
|
|
904
|
+
backgroundColor: alphaColor(
|
|
905
|
+
theme.colors.onSurfaceVariant,
|
|
906
|
+
theme.stateLayer.hoveredOpacity
|
|
907
|
+
)
|
|
908
|
+
},
|
|
909
|
+
hoveredOutlinedToggleUnselected: {
|
|
910
|
+
backgroundColor: alphaColor(
|
|
911
|
+
theme.colors.onSurfaceVariant,
|
|
912
|
+
theme.stateLayer.hoveredOpacity
|
|
913
|
+
)
|
|
914
|
+
},
|
|
915
|
+
hoveredOutlinedToggleSelected: {
|
|
916
|
+
backgroundColor: blendColor(
|
|
917
|
+
theme.colors.inverseSurface,
|
|
918
|
+
theme.colors.inverseOnSurface,
|
|
919
|
+
theme.stateLayer.hoveredOpacity
|
|
920
|
+
)
|
|
921
|
+
},
|
|
922
|
+
hoveredStandard: {
|
|
923
|
+
backgroundColor: alphaColor(
|
|
924
|
+
theme.colors.onSurfaceVariant,
|
|
925
|
+
theme.stateLayer.hoveredOpacity
|
|
926
|
+
)
|
|
927
|
+
},
|
|
928
|
+
hoveredStandardToggleUnselected: {
|
|
929
|
+
backgroundColor: alphaColor(
|
|
930
|
+
theme.colors.onSurfaceVariant,
|
|
931
|
+
theme.stateLayer.hoveredOpacity
|
|
932
|
+
)
|
|
933
|
+
},
|
|
934
|
+
hoveredStandardToggleSelected: {
|
|
935
|
+
backgroundColor: alphaColor(
|
|
936
|
+
theme.colors.primary,
|
|
937
|
+
theme.stateLayer.hoveredOpacity
|
|
938
|
+
)
|
|
939
|
+
},
|
|
940
|
+
// Pressed states (M3: 12% state layer)
|
|
941
|
+
pressedFilled: {
|
|
942
|
+
backgroundColor: blendColor(
|
|
943
|
+
theme.colors.primary,
|
|
944
|
+
theme.colors.onPrimary,
|
|
945
|
+
theme.stateLayer.pressedOpacity
|
|
946
|
+
)
|
|
947
|
+
},
|
|
948
|
+
pressedFilledToggleUnselected: {
|
|
949
|
+
backgroundColor: blendColor(
|
|
950
|
+
toggleUnselectedContainerColor,
|
|
951
|
+
theme.colors.primary,
|
|
952
|
+
theme.stateLayer.pressedOpacity
|
|
953
|
+
)
|
|
954
|
+
},
|
|
955
|
+
pressedFilledToggleSelected: {
|
|
956
|
+
backgroundColor: blendColor(
|
|
957
|
+
theme.colors.primary,
|
|
958
|
+
theme.colors.onPrimary,
|
|
959
|
+
theme.stateLayer.pressedOpacity
|
|
960
|
+
)
|
|
961
|
+
},
|
|
962
|
+
pressedTonal: {
|
|
963
|
+
backgroundColor: blendColor(
|
|
964
|
+
theme.colors.secondaryContainer,
|
|
965
|
+
theme.colors.onSecondaryContainer,
|
|
966
|
+
theme.stateLayer.pressedOpacity
|
|
967
|
+
)
|
|
968
|
+
},
|
|
969
|
+
pressedTonalToggleUnselected: {
|
|
970
|
+
backgroundColor: blendColor(
|
|
971
|
+
toggleUnselectedContainerColor,
|
|
972
|
+
theme.colors.onSurfaceVariant,
|
|
973
|
+
theme.stateLayer.pressedOpacity
|
|
974
|
+
)
|
|
975
|
+
},
|
|
976
|
+
pressedTonalToggleSelected: {
|
|
977
|
+
backgroundColor: blendColor(
|
|
978
|
+
theme.colors.secondaryContainer,
|
|
979
|
+
theme.colors.onSecondaryContainer,
|
|
980
|
+
theme.stateLayer.pressedOpacity
|
|
981
|
+
)
|
|
982
|
+
},
|
|
983
|
+
pressedOutlined: {
|
|
984
|
+
backgroundColor: alphaColor(
|
|
985
|
+
theme.colors.onSurfaceVariant,
|
|
986
|
+
theme.stateLayer.pressedOpacity
|
|
987
|
+
)
|
|
988
|
+
},
|
|
989
|
+
pressedOutlinedToggleUnselected: {
|
|
990
|
+
backgroundColor: alphaColor(
|
|
991
|
+
theme.colors.onSurfaceVariant,
|
|
992
|
+
theme.stateLayer.pressedOpacity
|
|
993
|
+
)
|
|
994
|
+
},
|
|
995
|
+
pressedOutlinedToggleSelected: {
|
|
996
|
+
backgroundColor: blendColor(
|
|
997
|
+
theme.colors.inverseSurface,
|
|
998
|
+
theme.colors.inverseOnSurface,
|
|
999
|
+
theme.stateLayer.pressedOpacity
|
|
1000
|
+
)
|
|
1001
|
+
},
|
|
1002
|
+
pressedStandard: {
|
|
1003
|
+
backgroundColor: alphaColor(
|
|
1004
|
+
theme.colors.onSurfaceVariant,
|
|
1005
|
+
theme.stateLayer.pressedOpacity
|
|
1006
|
+
)
|
|
1007
|
+
},
|
|
1008
|
+
pressedStandardToggleUnselected: {
|
|
1009
|
+
backgroundColor: alphaColor(
|
|
1010
|
+
theme.colors.onSurfaceVariant,
|
|
1011
|
+
theme.stateLayer.pressedOpacity
|
|
1012
|
+
)
|
|
1013
|
+
},
|
|
1014
|
+
pressedStandardToggleSelected: {
|
|
1015
|
+
backgroundColor: alphaColor(
|
|
1016
|
+
theme.colors.primary,
|
|
1017
|
+
theme.stateLayer.pressedOpacity
|
|
1018
|
+
)
|
|
1019
|
+
},
|
|
1020
|
+
// Disabled states
|
|
1021
|
+
disabledFilled: {
|
|
1022
|
+
backgroundColor: disabledContainerColor,
|
|
1023
|
+
borderColor: disabledContainerColor,
|
|
1024
|
+
cursor: "auto"
|
|
1025
|
+
},
|
|
1026
|
+
disabledTonal: {
|
|
1027
|
+
backgroundColor: disabledContainerColor,
|
|
1028
|
+
borderColor: disabledContainerColor,
|
|
1029
|
+
cursor: "auto"
|
|
1030
|
+
},
|
|
1031
|
+
disabledOutlined: {
|
|
1032
|
+
backgroundColor: "transparent",
|
|
1033
|
+
borderColor: disabledOutlineColor,
|
|
1034
|
+
cursor: "auto"
|
|
1035
|
+
},
|
|
1036
|
+
disabledStandard: {
|
|
1037
|
+
backgroundColor: "transparent",
|
|
1038
|
+
borderColor: "transparent",
|
|
1039
|
+
cursor: "auto"
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
// src/icon-button/IconButton.tsx
|
|
1045
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1046
|
+
function getIconColor(variant, theme, disabled, isToggle, selected) {
|
|
1047
|
+
if (disabled) {
|
|
1048
|
+
return alphaColor(theme.colors.onSurface, 0.38);
|
|
1049
|
+
}
|
|
1050
|
+
if (isToggle) {
|
|
1051
|
+
if (variant === "filled") {
|
|
1052
|
+
return selected ? theme.colors.onPrimary : theme.colors.primary;
|
|
1053
|
+
}
|
|
1054
|
+
if (variant === "tonal") {
|
|
1055
|
+
return selected ? theme.colors.onSecondaryContainer : theme.colors.onSurfaceVariant;
|
|
1056
|
+
}
|
|
1057
|
+
if (variant === "outlined") {
|
|
1058
|
+
return selected ? theme.colors.inverseOnSurface : theme.colors.onSurfaceVariant;
|
|
1059
|
+
}
|
|
1060
|
+
return selected ? theme.colors.primary : theme.colors.onSurfaceVariant;
|
|
1061
|
+
}
|
|
1062
|
+
if (variant === "filled") {
|
|
1063
|
+
return theme.colors.onPrimary;
|
|
1064
|
+
}
|
|
1065
|
+
if (variant === "tonal") {
|
|
1066
|
+
return theme.colors.onSecondaryContainer;
|
|
1067
|
+
}
|
|
1068
|
+
return theme.colors.onSurfaceVariant;
|
|
1069
|
+
}
|
|
1070
|
+
function getColorStyle(styles3, variant, isToggle, selected) {
|
|
1071
|
+
if (isToggle) {
|
|
1072
|
+
if (variant === "tonal") {
|
|
1073
|
+
return selected ? styles3.colorTonalToggleSelected : styles3.colorTonalToggleUnselected;
|
|
1074
|
+
}
|
|
1075
|
+
if (variant === "outlined") {
|
|
1076
|
+
return selected ? styles3.colorOutlinedToggleSelected : styles3.colorOutlined;
|
|
1077
|
+
}
|
|
1078
|
+
if (variant === "standard") {
|
|
1079
|
+
return selected ? styles3.colorStandardToggleSelected : styles3.colorStandard;
|
|
1080
|
+
}
|
|
1081
|
+
return selected ? styles3.colorFilledToggleSelected : styles3.colorFilledToggleUnselected;
|
|
1082
|
+
}
|
|
1083
|
+
if (variant === "tonal") {
|
|
1084
|
+
return styles3.colorTonal;
|
|
1085
|
+
}
|
|
1086
|
+
if (variant === "outlined") {
|
|
1087
|
+
return styles3.colorOutlined;
|
|
1088
|
+
}
|
|
1089
|
+
if (variant === "standard") {
|
|
1090
|
+
return styles3.colorStandard;
|
|
1091
|
+
}
|
|
1092
|
+
return styles3.colorFilled;
|
|
1093
|
+
}
|
|
1094
|
+
function getSizeStyle(styles3, size) {
|
|
1095
|
+
if (size === "small") {
|
|
1096
|
+
return styles3.sizeSmall;
|
|
1097
|
+
}
|
|
1098
|
+
if (size === "large") {
|
|
1099
|
+
return styles3.sizeLarge;
|
|
1100
|
+
}
|
|
1101
|
+
return styles3.sizeMedium;
|
|
1102
|
+
}
|
|
1103
|
+
function getIconPixelSize(size) {
|
|
1104
|
+
if (size === "small") {
|
|
1105
|
+
return 18;
|
|
1106
|
+
}
|
|
1107
|
+
if (size === "large") {
|
|
1108
|
+
return 28;
|
|
1109
|
+
}
|
|
1110
|
+
return 24;
|
|
1111
|
+
}
|
|
1112
|
+
function getDefaultHitSlop(size) {
|
|
1113
|
+
if (size === "small") {
|
|
1114
|
+
return 8;
|
|
1115
|
+
}
|
|
1116
|
+
if (size === "large") {
|
|
1117
|
+
return 0;
|
|
1118
|
+
}
|
|
1119
|
+
return 4;
|
|
1120
|
+
}
|
|
1121
|
+
function getHoveredStyle(styles3, variant, isToggle, selected) {
|
|
1122
|
+
if (isToggle) {
|
|
1123
|
+
if (variant === "tonal") {
|
|
1124
|
+
return selected ? styles3.hoveredTonalToggleSelected : styles3.hoveredTonalToggleUnselected;
|
|
1125
|
+
}
|
|
1126
|
+
if (variant === "outlined") {
|
|
1127
|
+
return selected ? styles3.hoveredOutlinedToggleSelected : styles3.hoveredOutlinedToggleUnselected;
|
|
1128
|
+
}
|
|
1129
|
+
if (variant === "standard") {
|
|
1130
|
+
return selected ? styles3.hoveredStandardToggleSelected : styles3.hoveredStandardToggleUnselected;
|
|
1131
|
+
}
|
|
1132
|
+
return selected ? styles3.hoveredFilledToggleSelected : styles3.hoveredFilledToggleUnselected;
|
|
1133
|
+
}
|
|
1134
|
+
if (variant === "tonal") {
|
|
1135
|
+
return styles3.hoveredTonal;
|
|
1136
|
+
}
|
|
1137
|
+
if (variant === "outlined") {
|
|
1138
|
+
return styles3.hoveredOutlined;
|
|
1139
|
+
}
|
|
1140
|
+
if (variant === "standard") {
|
|
1141
|
+
return styles3.hoveredStandard;
|
|
1142
|
+
}
|
|
1143
|
+
return styles3.hoveredFilled;
|
|
1144
|
+
}
|
|
1145
|
+
function getPressedStyle(styles3, variant, isToggle, selected) {
|
|
1146
|
+
if (isToggle) {
|
|
1147
|
+
if (variant === "tonal") {
|
|
1148
|
+
return selected ? styles3.pressedTonalToggleSelected : styles3.pressedTonalToggleUnselected;
|
|
1149
|
+
}
|
|
1150
|
+
if (variant === "outlined") {
|
|
1151
|
+
return selected ? styles3.pressedOutlinedToggleSelected : styles3.pressedOutlinedToggleUnselected;
|
|
1152
|
+
}
|
|
1153
|
+
if (variant === "standard") {
|
|
1154
|
+
return selected ? styles3.pressedStandardToggleSelected : styles3.pressedStandardToggleUnselected;
|
|
1155
|
+
}
|
|
1156
|
+
return selected ? styles3.pressedFilledToggleSelected : styles3.pressedFilledToggleUnselected;
|
|
1157
|
+
}
|
|
1158
|
+
if (variant === "tonal") {
|
|
1159
|
+
return styles3.pressedTonal;
|
|
1160
|
+
}
|
|
1161
|
+
if (variant === "outlined") {
|
|
1162
|
+
return styles3.pressedOutlined;
|
|
1163
|
+
}
|
|
1164
|
+
if (variant === "standard") {
|
|
1165
|
+
return styles3.pressedStandard;
|
|
1166
|
+
}
|
|
1167
|
+
return styles3.pressedFilled;
|
|
1168
|
+
}
|
|
1169
|
+
function getDisabledStyle(styles3, variant) {
|
|
1170
|
+
if (variant === "tonal") {
|
|
1171
|
+
return styles3.disabledTonal;
|
|
1172
|
+
}
|
|
1173
|
+
if (variant === "outlined") {
|
|
1174
|
+
return styles3.disabledOutlined;
|
|
1175
|
+
}
|
|
1176
|
+
if (variant === "standard") {
|
|
1177
|
+
return styles3.disabledStandard;
|
|
1178
|
+
}
|
|
1179
|
+
return styles3.disabledFilled;
|
|
1180
|
+
}
|
|
1181
|
+
function IconButton({
|
|
1182
|
+
icon,
|
|
1183
|
+
selectedIcon,
|
|
1184
|
+
iconColor,
|
|
1185
|
+
contentColor,
|
|
1186
|
+
containerColor,
|
|
1187
|
+
style,
|
|
1188
|
+
onPress,
|
|
1189
|
+
disabled = false,
|
|
1190
|
+
variant = "filled",
|
|
1191
|
+
selected,
|
|
1192
|
+
size = "medium",
|
|
1193
|
+
hitSlop,
|
|
1194
|
+
accessibilityLabel,
|
|
1195
|
+
...props
|
|
1196
|
+
}) {
|
|
1197
|
+
var _a;
|
|
1198
|
+
const MaterialCommunityIcons = getMaterialCommunityIcons();
|
|
1199
|
+
const theme = (0, import_core6.useTheme)();
|
|
1200
|
+
const styles3 = (0, import_react8.useMemo)(() => createStyles2(theme), [theme]);
|
|
1201
|
+
const isDisabled = Boolean(disabled);
|
|
1202
|
+
const isToggle = selected !== void 0;
|
|
1203
|
+
const isSelected = Boolean(selected);
|
|
1204
|
+
const resolvedIconColor = (_a = contentColor != null ? contentColor : iconColor) != null ? _a : getIconColor(variant, theme, isDisabled, isToggle, isSelected);
|
|
1205
|
+
const displayIcon = isToggle && isSelected && selectedIcon ? selectedIcon : icon;
|
|
1206
|
+
const iconPixelSize = getIconPixelSize(size);
|
|
1207
|
+
const accessibilityState = isToggle ? { disabled: isDisabled, selected: isSelected } : { disabled: isDisabled };
|
|
1208
|
+
const containerOverrides = (0, import_react8.useMemo)(() => {
|
|
1209
|
+
if (!containerColor) return null;
|
|
1210
|
+
const overlay = resolvedIconColor;
|
|
1211
|
+
return {
|
|
1212
|
+
base: {
|
|
1213
|
+
backgroundColor: containerColor,
|
|
1214
|
+
borderColor: containerColor,
|
|
1215
|
+
borderWidth: 0
|
|
1216
|
+
},
|
|
1217
|
+
hovered: {
|
|
1218
|
+
backgroundColor: blendColor(
|
|
1219
|
+
containerColor,
|
|
1220
|
+
overlay,
|
|
1221
|
+
theme.stateLayer.hoveredOpacity
|
|
1222
|
+
)
|
|
1223
|
+
},
|
|
1224
|
+
pressed: {
|
|
1225
|
+
backgroundColor: blendColor(
|
|
1226
|
+
containerColor,
|
|
1227
|
+
overlay,
|
|
1228
|
+
theme.stateLayer.pressedOpacity
|
|
1229
|
+
)
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
}, [containerColor, resolvedIconColor, theme.stateLayer]);
|
|
1233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1234
|
+
import_react_native12.Pressable,
|
|
1235
|
+
{
|
|
1236
|
+
...props,
|
|
1237
|
+
accessibilityRole: "button",
|
|
1238
|
+
accessibilityLabel,
|
|
1239
|
+
accessibilityState,
|
|
1240
|
+
disabled: isDisabled,
|
|
1241
|
+
hitSlop: hitSlop != null ? hitSlop : getDefaultHitSlop(size),
|
|
1242
|
+
onPress,
|
|
1243
|
+
style: ({
|
|
1244
|
+
pressed,
|
|
1245
|
+
hovered
|
|
1246
|
+
}) => {
|
|
1247
|
+
const base = [
|
|
1248
|
+
styles3.container,
|
|
1249
|
+
getSizeStyle(styles3, size),
|
|
1250
|
+
getColorStyle(styles3, variant, isToggle, isSelected),
|
|
1251
|
+
containerOverrides == null ? void 0 : containerOverrides.base,
|
|
1252
|
+
hovered && !pressed && !isDisabled ? containerOverrides ? containerOverrides.hovered : getHoveredStyle(styles3, variant, isToggle, isSelected) : void 0,
|
|
1253
|
+
pressed && !isDisabled ? containerOverrides ? containerOverrides.pressed : getPressedStyle(styles3, variant, isToggle, isSelected) : void 0,
|
|
1254
|
+
isDisabled ? getDisabledStyle(styles3, variant) : void 0
|
|
1255
|
+
];
|
|
1256
|
+
if (typeof style === "function") {
|
|
1257
|
+
base.push(style({ pressed }));
|
|
1258
|
+
} else if (style) {
|
|
1259
|
+
base.push(style);
|
|
1260
|
+
}
|
|
1261
|
+
return base;
|
|
1262
|
+
},
|
|
1263
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1264
|
+
MaterialCommunityIcons,
|
|
1265
|
+
{
|
|
1266
|
+
name: displayIcon,
|
|
1267
|
+
size: iconPixelSize,
|
|
1268
|
+
color: resolvedIconColor
|
|
1269
|
+
}
|
|
1270
|
+
)
|
|
1271
|
+
}
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
// src/appbar/AppBar.tsx
|
|
1276
|
+
var import_react9 = require("react");
|
|
1277
|
+
var import_react_native14 = require("react-native");
|
|
1278
|
+
var import_react_native_safe_area_context2 = require("react-native-safe-area-context");
|
|
1279
|
+
var import_core8 = require("@onlynative/core");
|
|
1280
|
+
|
|
1281
|
+
// src/appbar/styles.ts
|
|
1282
|
+
var import_react_native13 = require("react-native");
|
|
1283
|
+
var import_core7 = require("@onlynative/core");
|
|
1284
|
+
function getColorSchemeColors(theme, colorScheme) {
|
|
1285
|
+
switch (colorScheme) {
|
|
1286
|
+
case "surfaceContainerLowest":
|
|
1287
|
+
return {
|
|
1288
|
+
containerColor: theme.colors.surfaceContainerLowest,
|
|
1289
|
+
elevatedContainerColor: theme.colors.surfaceContainerLowest,
|
|
1290
|
+
contentColor: theme.colors.onSurface
|
|
1291
|
+
};
|
|
1292
|
+
case "surfaceContainerLow":
|
|
1293
|
+
return {
|
|
1294
|
+
containerColor: theme.colors.surfaceContainerLow,
|
|
1295
|
+
elevatedContainerColor: theme.colors.surfaceContainerLow,
|
|
1296
|
+
contentColor: theme.colors.onSurface
|
|
1297
|
+
};
|
|
1298
|
+
case "surfaceContainer":
|
|
1299
|
+
return {
|
|
1300
|
+
containerColor: theme.colors.surfaceContainer,
|
|
1301
|
+
elevatedContainerColor: theme.colors.surfaceContainer,
|
|
1302
|
+
contentColor: theme.colors.onSurface
|
|
1303
|
+
};
|
|
1304
|
+
case "surfaceContainerHigh":
|
|
1305
|
+
return {
|
|
1306
|
+
containerColor: theme.colors.surfaceContainerHigh,
|
|
1307
|
+
elevatedContainerColor: theme.colors.surfaceContainerHigh,
|
|
1308
|
+
contentColor: theme.colors.onSurface
|
|
1309
|
+
};
|
|
1310
|
+
case "surfaceContainerHighest":
|
|
1311
|
+
return {
|
|
1312
|
+
containerColor: theme.colors.surfaceContainerHighest,
|
|
1313
|
+
elevatedContainerColor: theme.colors.surfaceContainerHighest,
|
|
1314
|
+
contentColor: theme.colors.onSurface
|
|
1315
|
+
};
|
|
1316
|
+
case "primary":
|
|
1317
|
+
return {
|
|
1318
|
+
containerColor: theme.colors.primary,
|
|
1319
|
+
elevatedContainerColor: theme.colors.primary,
|
|
1320
|
+
contentColor: theme.colors.onPrimary
|
|
1321
|
+
};
|
|
1322
|
+
case "primaryContainer":
|
|
1323
|
+
return {
|
|
1324
|
+
containerColor: theme.colors.primaryContainer,
|
|
1325
|
+
elevatedContainerColor: theme.colors.primaryContainer,
|
|
1326
|
+
contentColor: theme.colors.onPrimaryContainer
|
|
1327
|
+
};
|
|
1328
|
+
case "surface":
|
|
1329
|
+
default:
|
|
1330
|
+
return {
|
|
1331
|
+
containerColor: theme.colors.surface,
|
|
1332
|
+
elevatedContainerColor: theme.colors.surfaceContainer,
|
|
1333
|
+
contentColor: theme.colors.onSurface
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
function createStyles3(theme, schemeColors) {
|
|
1338
|
+
var _a;
|
|
1339
|
+
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core7.defaultTopAppBarTokens;
|
|
1340
|
+
return import_react_native13.StyleSheet.create({
|
|
1341
|
+
root: {
|
|
1342
|
+
backgroundColor: schemeColors.containerColor
|
|
1343
|
+
},
|
|
1344
|
+
safeArea: {
|
|
1345
|
+
backgroundColor: schemeColors.containerColor
|
|
1346
|
+
},
|
|
1347
|
+
elevatedRoot: {
|
|
1348
|
+
backgroundColor: schemeColors.elevatedContainerColor
|
|
1349
|
+
},
|
|
1350
|
+
elevatedSafeArea: {
|
|
1351
|
+
backgroundColor: schemeColors.elevatedContainerColor
|
|
1352
|
+
},
|
|
1353
|
+
smallContainer: {
|
|
1354
|
+
height: topAppBar.smallContainerHeight,
|
|
1355
|
+
position: "relative"
|
|
1356
|
+
},
|
|
1357
|
+
mediumContainer: {
|
|
1358
|
+
height: topAppBar.mediumContainerHeight
|
|
1359
|
+
},
|
|
1360
|
+
largeContainer: {
|
|
1361
|
+
height: topAppBar.largeContainerHeight
|
|
1362
|
+
},
|
|
1363
|
+
expandedContainer: {
|
|
1364
|
+
position: "relative"
|
|
1365
|
+
},
|
|
1366
|
+
topRow: {
|
|
1367
|
+
height: topAppBar.topRowHeight,
|
|
1368
|
+
paddingHorizontal: topAppBar.horizontalPadding,
|
|
1369
|
+
flexDirection: "row",
|
|
1370
|
+
alignItems: "center"
|
|
1371
|
+
},
|
|
1372
|
+
expandedTitleContainer: {
|
|
1373
|
+
flex: 1,
|
|
1374
|
+
justifyContent: "flex-end",
|
|
1375
|
+
minWidth: 0,
|
|
1376
|
+
paddingEnd: theme.spacing.md,
|
|
1377
|
+
pointerEvents: "none"
|
|
1378
|
+
},
|
|
1379
|
+
topRowSpacer: {
|
|
1380
|
+
flex: 1
|
|
1381
|
+
},
|
|
1382
|
+
sideSlot: {
|
|
1383
|
+
flexDirection: "row",
|
|
1384
|
+
alignItems: "center",
|
|
1385
|
+
minHeight: topAppBar.sideSlotMinHeight
|
|
1386
|
+
},
|
|
1387
|
+
actionsRow: {
|
|
1388
|
+
flexDirection: "row",
|
|
1389
|
+
alignItems: "center"
|
|
1390
|
+
},
|
|
1391
|
+
iconFrame: {
|
|
1392
|
+
width: topAppBar.iconFrameSize,
|
|
1393
|
+
height: topAppBar.iconFrameSize,
|
|
1394
|
+
alignItems: "center",
|
|
1395
|
+
justifyContent: "center"
|
|
1396
|
+
},
|
|
1397
|
+
overlayTitleContainer: {
|
|
1398
|
+
position: "absolute",
|
|
1399
|
+
top: 0,
|
|
1400
|
+
bottom: 0,
|
|
1401
|
+
justifyContent: "center",
|
|
1402
|
+
minWidth: 0,
|
|
1403
|
+
pointerEvents: "none"
|
|
1404
|
+
},
|
|
1405
|
+
centeredTitle: {
|
|
1406
|
+
textAlign: "center"
|
|
1407
|
+
},
|
|
1408
|
+
startAlignedTitle: {
|
|
1409
|
+
textAlign: "auto"
|
|
1410
|
+
},
|
|
1411
|
+
mediumTitlePadding: {
|
|
1412
|
+
paddingBottom: topAppBar.mediumTitleBottomPadding
|
|
1413
|
+
},
|
|
1414
|
+
largeTitlePadding: {
|
|
1415
|
+
paddingBottom: topAppBar.largeTitleBottomPadding
|
|
1416
|
+
},
|
|
1417
|
+
title: {
|
|
1418
|
+
flexShrink: 1,
|
|
1419
|
+
maxWidth: "100%",
|
|
1420
|
+
includeFontPadding: false,
|
|
1421
|
+
textAlignVertical: "center"
|
|
1422
|
+
}
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
// src/appbar/AppBar.tsx
|
|
1427
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1428
|
+
function getBackIcon() {
|
|
1429
|
+
if (import_react_native14.Platform.OS === "ios") {
|
|
1430
|
+
return selectRTL("chevron-left", "chevron-right");
|
|
1431
|
+
}
|
|
1432
|
+
return selectRTL("arrow-left", "arrow-right");
|
|
1433
|
+
}
|
|
1434
|
+
var titleVariantBySize = {
|
|
1435
|
+
small: "titleLarge",
|
|
1436
|
+
medium: "headlineSmall",
|
|
1437
|
+
large: "headlineMedium"
|
|
1438
|
+
};
|
|
1439
|
+
var APP_BAR_TITLE_TEXT_PROPS = {
|
|
1440
|
+
numberOfLines: 1,
|
|
1441
|
+
ellipsizeMode: "tail",
|
|
1442
|
+
accessibilityRole: "header"
|
|
1443
|
+
};
|
|
1444
|
+
function resolveSize(variant) {
|
|
1445
|
+
if (variant === "medium" || variant === "large") {
|
|
1446
|
+
return variant;
|
|
1447
|
+
}
|
|
1448
|
+
return "small";
|
|
1449
|
+
}
|
|
1450
|
+
function getSizeStyle2(styles3, size) {
|
|
1451
|
+
if (size === "large") {
|
|
1452
|
+
return styles3.largeContainer;
|
|
1453
|
+
}
|
|
1454
|
+
return styles3.mediumContainer;
|
|
1455
|
+
}
|
|
1456
|
+
function withTopInset(enabled, content, style) {
|
|
1457
|
+
if (enabled) {
|
|
1458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_safe_area_context2.SafeAreaView, { edges: ["top"], style, children: content });
|
|
1459
|
+
}
|
|
1460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native14.View, { style, children: content });
|
|
1461
|
+
}
|
|
1462
|
+
function measureWidth(event) {
|
|
1463
|
+
return Math.round(event.nativeEvent.layout.width);
|
|
1464
|
+
}
|
|
1465
|
+
function AppBar({
|
|
1466
|
+
title,
|
|
1467
|
+
variant = "small",
|
|
1468
|
+
colorScheme = "surface",
|
|
1469
|
+
canGoBack = false,
|
|
1470
|
+
onBackPress,
|
|
1471
|
+
insetTop = false,
|
|
1472
|
+
elevated = false,
|
|
1473
|
+
leading,
|
|
1474
|
+
trailing,
|
|
1475
|
+
actions,
|
|
1476
|
+
containerColor,
|
|
1477
|
+
contentColor,
|
|
1478
|
+
titleStyle,
|
|
1479
|
+
style
|
|
1480
|
+
}) {
|
|
1481
|
+
var _a;
|
|
1482
|
+
const theme = (0, import_core8.useTheme)();
|
|
1483
|
+
const topAppBar = (_a = theme.topAppBar) != null ? _a : import_core8.defaultTopAppBarTokens;
|
|
1484
|
+
const schemeColors = (0, import_react9.useMemo)(
|
|
1485
|
+
() => getColorSchemeColors(theme, colorScheme),
|
|
1486
|
+
[theme, colorScheme]
|
|
1487
|
+
);
|
|
1488
|
+
const resolvedContentColor = contentColor != null ? contentColor : schemeColors.contentColor;
|
|
1489
|
+
const styles3 = (0, import_react9.useMemo)(
|
|
1490
|
+
() => createStyles3(theme, schemeColors),
|
|
1491
|
+
[theme, schemeColors]
|
|
1492
|
+
);
|
|
1493
|
+
const [leadingWidth, setLeadingWidth] = (0, import_react9.useState)(0);
|
|
1494
|
+
const [actionsWidth, setActionsWidth] = (0, import_react9.useState)(0);
|
|
1495
|
+
const titleColorStyle = (0, import_react9.useMemo)(
|
|
1496
|
+
() => ({ color: resolvedContentColor }),
|
|
1497
|
+
[resolvedContentColor]
|
|
1498
|
+
);
|
|
1499
|
+
const size = resolveSize(variant);
|
|
1500
|
+
const titleVariant = titleVariantBySize[size];
|
|
1501
|
+
const isCenterAligned = variant === "center-aligned";
|
|
1502
|
+
const isExpanded = size !== "small";
|
|
1503
|
+
const titleStartInset = topAppBar.horizontalPadding + Math.max(topAppBar.titleStartInset, leadingWidth);
|
|
1504
|
+
const compactTitleEndInset = topAppBar.horizontalPadding + actionsWidth;
|
|
1505
|
+
const centeredSideInset = topAppBar.horizontalPadding + Math.max(leadingWidth, actionsWidth);
|
|
1506
|
+
const expandedTitleInsetStyle = (0, import_react9.useMemo)(
|
|
1507
|
+
() => ({ paddingStart: titleStartInset }),
|
|
1508
|
+
[titleStartInset]
|
|
1509
|
+
);
|
|
1510
|
+
const overlayTitleInsetStyle = (0, import_react9.useMemo)(
|
|
1511
|
+
() => isCenterAligned ? { start: centeredSideInset, end: centeredSideInset } : { start: titleStartInset, end: compactTitleEndInset },
|
|
1512
|
+
[centeredSideInset, compactTitleEndInset, isCenterAligned, titleStartInset]
|
|
1513
|
+
);
|
|
1514
|
+
const leadingContent = (0, import_react9.useMemo)(() => {
|
|
1515
|
+
if (leading) {
|
|
1516
|
+
return leading;
|
|
1517
|
+
}
|
|
1518
|
+
if (!canGoBack) {
|
|
1519
|
+
return null;
|
|
1520
|
+
}
|
|
1521
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native14.View, { style: styles3.iconFrame, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1522
|
+
IconButton,
|
|
1523
|
+
{
|
|
1524
|
+
icon: getBackIcon(),
|
|
1525
|
+
size: "medium",
|
|
1526
|
+
variant: "standard",
|
|
1527
|
+
iconColor: resolvedContentColor,
|
|
1528
|
+
accessibilityLabel: "Go back",
|
|
1529
|
+
onPress: onBackPress
|
|
1530
|
+
}
|
|
1531
|
+
) });
|
|
1532
|
+
}, [canGoBack, resolvedContentColor, leading, onBackPress, styles3.iconFrame]);
|
|
1533
|
+
const actionsContent = (0, import_react9.useMemo)(() => {
|
|
1534
|
+
if (trailing) {
|
|
1535
|
+
return trailing;
|
|
1536
|
+
}
|
|
1537
|
+
if (!actions || actions.length === 0) {
|
|
1538
|
+
return null;
|
|
1539
|
+
}
|
|
1540
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native14.View, { style: styles3.actionsRow, children: actions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1541
|
+
import_react_native14.View,
|
|
1542
|
+
{
|
|
1543
|
+
style: styles3.iconFrame,
|
|
1544
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1545
|
+
IconButton,
|
|
1546
|
+
{
|
|
1547
|
+
icon: action.icon,
|
|
1548
|
+
size: "medium",
|
|
1549
|
+
variant: "standard",
|
|
1550
|
+
iconColor: resolvedContentColor,
|
|
1551
|
+
accessibilityLabel: action.accessibilityLabel,
|
|
1552
|
+
onPress: action.onPress,
|
|
1553
|
+
disabled: action.disabled
|
|
1554
|
+
}
|
|
1555
|
+
)
|
|
1556
|
+
},
|
|
1557
|
+
`${String(action.icon)}-${index}`
|
|
1558
|
+
)) });
|
|
1559
|
+
}, [actions, resolvedContentColor, styles3.actionsRow, styles3.iconFrame, trailing]);
|
|
1560
|
+
const onLeadingLayout = (0, import_react9.useCallback)((event) => {
|
|
1561
|
+
const nextWidth = measureWidth(event);
|
|
1562
|
+
setLeadingWidth((currentWidth) => {
|
|
1563
|
+
if (currentWidth === nextWidth) {
|
|
1564
|
+
return currentWidth;
|
|
1565
|
+
}
|
|
1566
|
+
return nextWidth;
|
|
1567
|
+
});
|
|
1568
|
+
}, []);
|
|
1569
|
+
const onActionsLayout = (0, import_react9.useCallback)((event) => {
|
|
1570
|
+
const nextWidth = measureWidth(event);
|
|
1571
|
+
setActionsWidth((currentWidth) => {
|
|
1572
|
+
if (currentWidth === nextWidth) {
|
|
1573
|
+
return currentWidth;
|
|
1574
|
+
}
|
|
1575
|
+
return nextWidth;
|
|
1576
|
+
});
|
|
1577
|
+
}, []);
|
|
1578
|
+
const topRow = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native14.View, { style: styles3.topRow, children: [
|
|
1579
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1580
|
+
import_react_native14.View,
|
|
1581
|
+
{
|
|
1582
|
+
collapsable: false,
|
|
1583
|
+
onLayout: onLeadingLayout,
|
|
1584
|
+
style: styles3.sideSlot,
|
|
1585
|
+
children: leadingContent
|
|
1586
|
+
}
|
|
1587
|
+
),
|
|
1588
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native14.View, { style: styles3.topRowSpacer }),
|
|
1589
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1590
|
+
import_react_native14.View,
|
|
1591
|
+
{
|
|
1592
|
+
collapsable: false,
|
|
1593
|
+
onLayout: onActionsLayout,
|
|
1594
|
+
style: styles3.sideSlot,
|
|
1595
|
+
children: actionsContent
|
|
1596
|
+
}
|
|
1597
|
+
)
|
|
1598
|
+
] });
|
|
1599
|
+
const containerOverride = containerColor ? { backgroundColor: containerColor } : void 0;
|
|
1600
|
+
const rootStyle = [
|
|
1601
|
+
styles3.root,
|
|
1602
|
+
elevated ? styles3.elevatedRoot : void 0,
|
|
1603
|
+
containerOverride,
|
|
1604
|
+
style
|
|
1605
|
+
];
|
|
1606
|
+
const safeAreaStyle = [
|
|
1607
|
+
styles3.safeArea,
|
|
1608
|
+
elevated ? styles3.elevatedSafeArea : void 0,
|
|
1609
|
+
containerOverride
|
|
1610
|
+
];
|
|
1611
|
+
if (isExpanded) {
|
|
1612
|
+
const content2 = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native14.View, { style: [styles3.expandedContainer, getSizeStyle2(styles3, size)], children: [
|
|
1613
|
+
topRow,
|
|
1614
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1615
|
+
import_react_native14.View,
|
|
1616
|
+
{
|
|
1617
|
+
style: [
|
|
1618
|
+
styles3.expandedTitleContainer,
|
|
1619
|
+
size === "large" ? styles3.largeTitlePadding : styles3.mediumTitlePadding,
|
|
1620
|
+
expandedTitleInsetStyle
|
|
1621
|
+
],
|
|
1622
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1623
|
+
Typography,
|
|
1624
|
+
{
|
|
1625
|
+
...APP_BAR_TITLE_TEXT_PROPS,
|
|
1626
|
+
variant: titleVariant,
|
|
1627
|
+
style: [
|
|
1628
|
+
styles3.title,
|
|
1629
|
+
titleColorStyle,
|
|
1630
|
+
styles3.startAlignedTitle,
|
|
1631
|
+
titleStyle
|
|
1632
|
+
],
|
|
1633
|
+
children: title
|
|
1634
|
+
}
|
|
1635
|
+
)
|
|
1636
|
+
}
|
|
1637
|
+
)
|
|
1638
|
+
] });
|
|
1639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native14.View, { style: rootStyle, children: withTopInset(insetTop, content2, safeAreaStyle) });
|
|
1640
|
+
}
|
|
1641
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native14.View, { style: styles3.smallContainer, children: [
|
|
1642
|
+
topRow,
|
|
1643
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native14.View, { style: [styles3.overlayTitleContainer, overlayTitleInsetStyle], children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1644
|
+
Typography,
|
|
1645
|
+
{
|
|
1646
|
+
...APP_BAR_TITLE_TEXT_PROPS,
|
|
1647
|
+
variant: titleVariant,
|
|
1648
|
+
style: [
|
|
1649
|
+
styles3.title,
|
|
1650
|
+
titleColorStyle,
|
|
1651
|
+
isCenterAligned ? styles3.centeredTitle : styles3.startAlignedTitle,
|
|
1652
|
+
titleStyle
|
|
1653
|
+
],
|
|
1654
|
+
children: title
|
|
1655
|
+
}
|
|
1656
|
+
) })
|
|
1657
|
+
] });
|
|
1658
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native14.View, { style: rootStyle, children: withTopInset(insetTop, content, safeAreaStyle) });
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
// src/card/Card.tsx
|
|
1662
|
+
var import_react10 = require("react");
|
|
1663
|
+
var import_react_native16 = require("react-native");
|
|
1664
|
+
var import_core9 = require("@onlynative/core");
|
|
1665
|
+
|
|
1666
|
+
// src/card/styles.ts
|
|
1667
|
+
var import_react_native15 = require("react-native");
|
|
1668
|
+
function getVariantColors2(theme, variant) {
|
|
1669
|
+
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
1670
|
+
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
1671
|
+
if (variant === "outlined") {
|
|
1672
|
+
return {
|
|
1673
|
+
backgroundColor: theme.colors.surface,
|
|
1674
|
+
borderColor: theme.colors.outline,
|
|
1675
|
+
borderWidth: 1,
|
|
1676
|
+
hoveredBackgroundColor: alphaColor(
|
|
1677
|
+
theme.colors.onSurface,
|
|
1678
|
+
theme.stateLayer.hoveredOpacity
|
|
1679
|
+
),
|
|
1680
|
+
pressedBackgroundColor: alphaColor(
|
|
1681
|
+
theme.colors.onSurface,
|
|
1682
|
+
theme.stateLayer.pressedOpacity
|
|
1683
|
+
),
|
|
1684
|
+
disabledBackgroundColor: theme.colors.surface,
|
|
1685
|
+
disabledBorderColor: disabledOutlineColor
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
if (variant === "filled") {
|
|
1689
|
+
return {
|
|
1690
|
+
backgroundColor: theme.colors.surfaceContainerHighest,
|
|
1691
|
+
borderColor: "transparent",
|
|
1692
|
+
borderWidth: 0,
|
|
1693
|
+
hoveredBackgroundColor: blendColor(
|
|
1694
|
+
theme.colors.surfaceContainerHighest,
|
|
1695
|
+
theme.colors.onSurface,
|
|
1696
|
+
theme.stateLayer.hoveredOpacity
|
|
1697
|
+
),
|
|
1698
|
+
pressedBackgroundColor: blendColor(
|
|
1699
|
+
theme.colors.surfaceContainerHighest,
|
|
1700
|
+
theme.colors.onSurface,
|
|
1701
|
+
theme.stateLayer.pressedOpacity
|
|
1702
|
+
),
|
|
1703
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
1704
|
+
disabledBorderColor: "transparent"
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
return {
|
|
1708
|
+
backgroundColor: theme.colors.surface,
|
|
1709
|
+
borderColor: "transparent",
|
|
1710
|
+
borderWidth: 0,
|
|
1711
|
+
hoveredBackgroundColor: blendColor(
|
|
1712
|
+
theme.colors.surface,
|
|
1713
|
+
theme.colors.onSurface,
|
|
1714
|
+
theme.stateLayer.hoveredOpacity
|
|
1715
|
+
),
|
|
1716
|
+
pressedBackgroundColor: blendColor(
|
|
1717
|
+
theme.colors.surface,
|
|
1718
|
+
theme.colors.onSurface,
|
|
1719
|
+
theme.stateLayer.pressedOpacity
|
|
1720
|
+
),
|
|
1721
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
1722
|
+
disabledBorderColor: "transparent"
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
function applyColorOverrides2(theme, colors, containerColor) {
|
|
1726
|
+
if (!containerColor) return colors;
|
|
1727
|
+
return {
|
|
1728
|
+
...colors,
|
|
1729
|
+
backgroundColor: containerColor,
|
|
1730
|
+
borderColor: containerColor,
|
|
1731
|
+
borderWidth: 0,
|
|
1732
|
+
hoveredBackgroundColor: blendColor(
|
|
1733
|
+
containerColor,
|
|
1734
|
+
theme.colors.onSurface,
|
|
1735
|
+
theme.stateLayer.hoveredOpacity
|
|
1736
|
+
),
|
|
1737
|
+
pressedBackgroundColor: blendColor(
|
|
1738
|
+
containerColor,
|
|
1739
|
+
theme.colors.onSurface,
|
|
1740
|
+
theme.stateLayer.pressedOpacity
|
|
1741
|
+
)
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
function createStyles4(theme, variant, containerColor) {
|
|
1745
|
+
const baseColors = getVariantColors2(theme, variant);
|
|
1746
|
+
const colors = applyColorOverrides2(theme, baseColors, containerColor);
|
|
1747
|
+
const elevationLevel0 = elevationStyle(theme.elevation.level0);
|
|
1748
|
+
const elevationLevel1 = elevationStyle(theme.elevation.level1);
|
|
1749
|
+
const elevationLevel2 = elevationStyle(theme.elevation.level2);
|
|
1750
|
+
const baseElevation = variant === "elevated" ? elevationLevel1 : elevationLevel0;
|
|
1751
|
+
return import_react_native15.StyleSheet.create({
|
|
1752
|
+
container: {
|
|
1753
|
+
borderRadius: theme.shape.cornerMedium,
|
|
1754
|
+
backgroundColor: colors.backgroundColor,
|
|
1755
|
+
borderColor: colors.borderColor,
|
|
1756
|
+
borderWidth: colors.borderWidth,
|
|
1757
|
+
overflow: "hidden",
|
|
1758
|
+
...baseElevation
|
|
1759
|
+
},
|
|
1760
|
+
interactiveContainer: {
|
|
1761
|
+
cursor: "pointer"
|
|
1762
|
+
},
|
|
1763
|
+
hoveredContainer: {
|
|
1764
|
+
backgroundColor: colors.hoveredBackgroundColor,
|
|
1765
|
+
...variant === "elevated" ? elevationLevel2 : variant === "filled" ? elevationLevel1 : void 0
|
|
1766
|
+
},
|
|
1767
|
+
pressedContainer: {
|
|
1768
|
+
backgroundColor: colors.pressedBackgroundColor
|
|
1769
|
+
},
|
|
1770
|
+
disabledContainer: {
|
|
1771
|
+
backgroundColor: colors.disabledBackgroundColor,
|
|
1772
|
+
borderColor: colors.disabledBorderColor,
|
|
1773
|
+
cursor: "auto",
|
|
1774
|
+
...elevationLevel0
|
|
1775
|
+
},
|
|
1776
|
+
disabledContent: {
|
|
1777
|
+
opacity: theme.stateLayer.disabledOpacity
|
|
1778
|
+
}
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
// src/card/Card.tsx
|
|
1783
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1784
|
+
function Card({
|
|
1785
|
+
children,
|
|
1786
|
+
style,
|
|
1787
|
+
variant = "elevated",
|
|
1788
|
+
onPress,
|
|
1789
|
+
disabled = false,
|
|
1790
|
+
containerColor,
|
|
1791
|
+
...props
|
|
1792
|
+
}) {
|
|
1793
|
+
const isDisabled = Boolean(disabled);
|
|
1794
|
+
const isInteractive = onPress !== void 0;
|
|
1795
|
+
const theme = (0, import_core9.useTheme)();
|
|
1796
|
+
const styles3 = (0, import_react10.useMemo)(
|
|
1797
|
+
() => createStyles4(theme, variant, containerColor),
|
|
1798
|
+
[theme, variant, containerColor]
|
|
1799
|
+
);
|
|
1800
|
+
if (!isInteractive) {
|
|
1801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native16.View, { ...props, style: [styles3.container, style], children });
|
|
1802
|
+
}
|
|
1803
|
+
const resolvedStyle = (state) => [
|
|
1804
|
+
styles3.container,
|
|
1805
|
+
styles3.interactiveContainer,
|
|
1806
|
+
state.hovered && !state.pressed && !isDisabled ? styles3.hoveredContainer : void 0,
|
|
1807
|
+
state.pressed && !isDisabled ? styles3.pressedContainer : void 0,
|
|
1808
|
+
isDisabled ? styles3.disabledContainer : void 0,
|
|
1809
|
+
typeof style === "function" ? style(state) : style
|
|
1810
|
+
];
|
|
1811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1812
|
+
import_react_native16.Pressable,
|
|
1813
|
+
{
|
|
1814
|
+
...props,
|
|
1815
|
+
role: "button",
|
|
1816
|
+
accessibilityState: { disabled: isDisabled },
|
|
1817
|
+
hitSlop: import_react_native16.Platform.OS === "web" ? void 0 : 4,
|
|
1818
|
+
disabled: isDisabled,
|
|
1819
|
+
onPress,
|
|
1820
|
+
style: resolvedStyle,
|
|
1821
|
+
children: isDisabled ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native16.View, { style: styles3.disabledContent, children }) : children
|
|
1822
|
+
}
|
|
1823
|
+
);
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
// src/chip/Chip.tsx
|
|
1827
|
+
var import_react11 = require("react");
|
|
1828
|
+
var import_react_native18 = require("react-native");
|
|
1829
|
+
var import_core10 = require("@onlynative/core");
|
|
1830
|
+
|
|
1831
|
+
// src/chip/styles.ts
|
|
1832
|
+
var import_react_native17 = require("react-native");
|
|
1833
|
+
function getVariantColors3(theme, variant, elevated, selected) {
|
|
1834
|
+
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
1835
|
+
const disabledLabelColor = alphaColor(theme.colors.onSurface, 0.38);
|
|
1836
|
+
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
1837
|
+
if (variant === "filter" && selected) {
|
|
1838
|
+
return {
|
|
1839
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
1840
|
+
textColor: theme.colors.onSecondaryContainer,
|
|
1841
|
+
borderColor: "transparent",
|
|
1842
|
+
borderWidth: 0,
|
|
1843
|
+
hoveredBackgroundColor: blendColor(
|
|
1844
|
+
theme.colors.secondaryContainer,
|
|
1845
|
+
theme.colors.onSecondaryContainer,
|
|
1846
|
+
theme.stateLayer.hoveredOpacity
|
|
1847
|
+
),
|
|
1848
|
+
pressedBackgroundColor: blendColor(
|
|
1849
|
+
theme.colors.secondaryContainer,
|
|
1850
|
+
theme.colors.onSecondaryContainer,
|
|
1851
|
+
theme.stateLayer.pressedOpacity
|
|
1852
|
+
),
|
|
1853
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
1854
|
+
disabledTextColor: disabledLabelColor,
|
|
1855
|
+
disabledBorderColor: "transparent"
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
if (elevated && variant !== "input") {
|
|
1859
|
+
const textColor2 = variant === "assist" ? theme.colors.onSurface : theme.colors.onSurfaceVariant;
|
|
1860
|
+
return {
|
|
1861
|
+
backgroundColor: theme.colors.surfaceContainerLow,
|
|
1862
|
+
textColor: textColor2,
|
|
1863
|
+
borderColor: "transparent",
|
|
1864
|
+
borderWidth: 0,
|
|
1865
|
+
hoveredBackgroundColor: blendColor(
|
|
1866
|
+
theme.colors.surfaceContainerLow,
|
|
1867
|
+
textColor2,
|
|
1868
|
+
theme.stateLayer.hoveredOpacity
|
|
1869
|
+
),
|
|
1870
|
+
pressedBackgroundColor: blendColor(
|
|
1871
|
+
theme.colors.surfaceContainerLow,
|
|
1872
|
+
textColor2,
|
|
1873
|
+
theme.stateLayer.pressedOpacity
|
|
1874
|
+
),
|
|
1875
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
1876
|
+
disabledTextColor: disabledLabelColor,
|
|
1877
|
+
disabledBorderColor: "transparent"
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
const textColor = variant === "assist" ? theme.colors.onSurface : theme.colors.onSurfaceVariant;
|
|
1881
|
+
return {
|
|
1882
|
+
backgroundColor: theme.colors.surface,
|
|
1883
|
+
textColor,
|
|
1884
|
+
borderColor: theme.colors.outline,
|
|
1885
|
+
borderWidth: 1,
|
|
1886
|
+
hoveredBackgroundColor: blendColor(
|
|
1887
|
+
theme.colors.surface,
|
|
1888
|
+
textColor,
|
|
1889
|
+
theme.stateLayer.hoveredOpacity
|
|
1890
|
+
),
|
|
1891
|
+
pressedBackgroundColor: blendColor(
|
|
1892
|
+
theme.colors.surface,
|
|
1893
|
+
textColor,
|
|
1894
|
+
theme.stateLayer.pressedOpacity
|
|
1895
|
+
),
|
|
1896
|
+
disabledBackgroundColor: disabledContainerColor,
|
|
1897
|
+
disabledTextColor: disabledLabelColor,
|
|
1898
|
+
disabledBorderColor: disabledOutlineColor
|
|
1899
|
+
};
|
|
1900
|
+
}
|
|
1901
|
+
function applyColorOverrides3(theme, colors, containerColor, contentColor) {
|
|
1902
|
+
if (!containerColor && !contentColor) return colors;
|
|
1903
|
+
const result = { ...colors };
|
|
1904
|
+
if (contentColor) {
|
|
1905
|
+
result.textColor = contentColor;
|
|
1906
|
+
}
|
|
1907
|
+
if (containerColor) {
|
|
1908
|
+
const overlay = contentColor != null ? contentColor : colors.textColor;
|
|
1909
|
+
result.backgroundColor = containerColor;
|
|
1910
|
+
result.borderColor = containerColor;
|
|
1911
|
+
result.hoveredBackgroundColor = blendColor(
|
|
1912
|
+
containerColor,
|
|
1913
|
+
overlay,
|
|
1914
|
+
theme.stateLayer.hoveredOpacity
|
|
1915
|
+
);
|
|
1916
|
+
result.pressedBackgroundColor = blendColor(
|
|
1917
|
+
containerColor,
|
|
1918
|
+
overlay,
|
|
1919
|
+
theme.stateLayer.pressedOpacity
|
|
1920
|
+
);
|
|
1921
|
+
} else if (contentColor) {
|
|
1922
|
+
if (colors.backgroundColor === "transparent") {
|
|
1923
|
+
result.hoveredBackgroundColor = alphaColor(
|
|
1924
|
+
contentColor,
|
|
1925
|
+
theme.stateLayer.hoveredOpacity
|
|
1926
|
+
);
|
|
1927
|
+
result.pressedBackgroundColor = alphaColor(
|
|
1928
|
+
contentColor,
|
|
1929
|
+
theme.stateLayer.pressedOpacity
|
|
1930
|
+
);
|
|
1931
|
+
} else {
|
|
1932
|
+
result.hoveredBackgroundColor = blendColor(
|
|
1933
|
+
colors.backgroundColor,
|
|
1934
|
+
contentColor,
|
|
1935
|
+
theme.stateLayer.hoveredOpacity
|
|
1936
|
+
);
|
|
1937
|
+
result.pressedBackgroundColor = blendColor(
|
|
1938
|
+
colors.backgroundColor,
|
|
1939
|
+
contentColor,
|
|
1940
|
+
theme.stateLayer.pressedOpacity
|
|
1941
|
+
);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
return result;
|
|
1945
|
+
}
|
|
1946
|
+
function createStyles5(theme, variant, elevated, selected, hasLeadingContent, hasTrailingContent, containerColor, contentColor) {
|
|
1947
|
+
const baseColors = getVariantColors3(theme, variant, elevated, selected);
|
|
1948
|
+
const colors = applyColorOverrides3(
|
|
1949
|
+
theme,
|
|
1950
|
+
baseColors,
|
|
1951
|
+
containerColor,
|
|
1952
|
+
contentColor
|
|
1953
|
+
);
|
|
1954
|
+
const labelStyle = theme.typography.labelLarge;
|
|
1955
|
+
const elevationLevel0 = elevationStyle(theme.elevation.level0);
|
|
1956
|
+
const elevationLevel1 = elevationStyle(theme.elevation.level1);
|
|
1957
|
+
const elevationLevel2 = elevationStyle(theme.elevation.level2);
|
|
1958
|
+
const isElevated = elevated && variant !== "input";
|
|
1959
|
+
const baseElevation = isElevated ? elevationLevel1 : elevationLevel0;
|
|
1960
|
+
return import_react_native17.StyleSheet.create({
|
|
1961
|
+
container: {
|
|
1962
|
+
alignSelf: "flex-start",
|
|
1963
|
+
alignItems: "center",
|
|
1964
|
+
flexDirection: "row",
|
|
1965
|
+
height: 32,
|
|
1966
|
+
paddingStart: hasLeadingContent ? 8 : 16,
|
|
1967
|
+
paddingEnd: hasTrailingContent ? 8 : 16,
|
|
1968
|
+
borderRadius: theme.shape.cornerSmall,
|
|
1969
|
+
backgroundColor: colors.backgroundColor,
|
|
1970
|
+
borderColor: colors.borderColor,
|
|
1971
|
+
borderWidth: colors.borderWidth,
|
|
1972
|
+
cursor: "pointer",
|
|
1973
|
+
...baseElevation
|
|
1974
|
+
},
|
|
1975
|
+
hoveredContainer: {
|
|
1976
|
+
backgroundColor: colors.hoveredBackgroundColor,
|
|
1977
|
+
...isElevated ? elevationLevel2 : void 0
|
|
1978
|
+
},
|
|
1979
|
+
pressedContainer: {
|
|
1980
|
+
backgroundColor: colors.pressedBackgroundColor
|
|
1981
|
+
},
|
|
1982
|
+
disabledContainer: {
|
|
1983
|
+
backgroundColor: colors.disabledBackgroundColor,
|
|
1984
|
+
borderColor: colors.disabledBorderColor,
|
|
1985
|
+
cursor: "auto",
|
|
1986
|
+
...elevationLevel0
|
|
1987
|
+
},
|
|
1988
|
+
label: {
|
|
1989
|
+
fontFamily: labelStyle.fontFamily,
|
|
1990
|
+
fontSize: labelStyle.fontSize,
|
|
1991
|
+
lineHeight: labelStyle.lineHeight,
|
|
1992
|
+
fontWeight: labelStyle.fontWeight,
|
|
1993
|
+
letterSpacing: labelStyle.letterSpacing,
|
|
1994
|
+
color: colors.textColor
|
|
1995
|
+
},
|
|
1996
|
+
disabledLabel: {
|
|
1997
|
+
color: colors.disabledTextColor
|
|
1998
|
+
},
|
|
1999
|
+
leadingIcon: {
|
|
2000
|
+
marginEnd: theme.spacing.sm
|
|
2001
|
+
},
|
|
2002
|
+
avatar: {
|
|
2003
|
+
marginEnd: theme.spacing.sm,
|
|
2004
|
+
width: 24,
|
|
2005
|
+
height: 24,
|
|
2006
|
+
borderRadius: 12,
|
|
2007
|
+
overflow: "hidden"
|
|
2008
|
+
},
|
|
2009
|
+
closeButton: {
|
|
2010
|
+
marginStart: theme.spacing.sm
|
|
2011
|
+
}
|
|
2012
|
+
});
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
// src/chip/Chip.tsx
|
|
2016
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2017
|
+
function resolveStyle2(containerStyle, hoveredContainerStyle, pressedContainerStyle, disabledContainerStyle, disabled, style) {
|
|
2018
|
+
if (typeof style === "function") {
|
|
2019
|
+
return (state) => [
|
|
2020
|
+
containerStyle,
|
|
2021
|
+
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
2022
|
+
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
2023
|
+
disabled ? disabledContainerStyle : void 0,
|
|
2024
|
+
style(state)
|
|
2025
|
+
];
|
|
2026
|
+
}
|
|
2027
|
+
return (state) => [
|
|
2028
|
+
containerStyle,
|
|
2029
|
+
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
2030
|
+
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
2031
|
+
disabled ? disabledContainerStyle : void 0,
|
|
2032
|
+
style
|
|
2033
|
+
];
|
|
2034
|
+
}
|
|
2035
|
+
function Chip({
|
|
2036
|
+
children,
|
|
2037
|
+
style,
|
|
2038
|
+
variant = "assist",
|
|
2039
|
+
elevated = false,
|
|
2040
|
+
selected = false,
|
|
2041
|
+
leadingIcon,
|
|
2042
|
+
iconSize = 18,
|
|
2043
|
+
avatar,
|
|
2044
|
+
onClose,
|
|
2045
|
+
containerColor,
|
|
2046
|
+
contentColor,
|
|
2047
|
+
labelStyle: labelStyleOverride,
|
|
2048
|
+
disabled = false,
|
|
2049
|
+
...props
|
|
2050
|
+
}) {
|
|
2051
|
+
const isDisabled = Boolean(disabled);
|
|
2052
|
+
const isSelected = variant === "filter" ? Boolean(selected) : false;
|
|
2053
|
+
const showCloseIcon = onClose !== void 0 && (variant === "input" || variant === "filter" && isSelected);
|
|
2054
|
+
const hasLeadingContent = Boolean(
|
|
2055
|
+
variant === "input" && avatar || leadingIcon || variant === "filter" && isSelected
|
|
2056
|
+
);
|
|
2057
|
+
const needsIcons = Boolean(leadingIcon) || variant === "filter" && isSelected || showCloseIcon;
|
|
2058
|
+
const MaterialCommunityIcons = needsIcons ? getMaterialCommunityIcons() : null;
|
|
2059
|
+
const theme = (0, import_core10.useTheme)();
|
|
2060
|
+
const styles3 = (0, import_react11.useMemo)(
|
|
2061
|
+
() => createStyles5(
|
|
2062
|
+
theme,
|
|
2063
|
+
variant,
|
|
2064
|
+
elevated,
|
|
2065
|
+
isSelected,
|
|
2066
|
+
hasLeadingContent,
|
|
2067
|
+
showCloseIcon,
|
|
2068
|
+
containerColor,
|
|
2069
|
+
contentColor
|
|
2070
|
+
),
|
|
2071
|
+
[
|
|
2072
|
+
theme,
|
|
2073
|
+
variant,
|
|
2074
|
+
elevated,
|
|
2075
|
+
isSelected,
|
|
2076
|
+
hasLeadingContent,
|
|
2077
|
+
showCloseIcon,
|
|
2078
|
+
containerColor,
|
|
2079
|
+
contentColor
|
|
2080
|
+
]
|
|
2081
|
+
);
|
|
2082
|
+
const resolvedIconColor = (0, import_react11.useMemo)(() => {
|
|
2083
|
+
const base = import_react_native18.StyleSheet.flatten([
|
|
2084
|
+
styles3.label,
|
|
2085
|
+
isDisabled ? styles3.disabledLabel : void 0
|
|
2086
|
+
]);
|
|
2087
|
+
return typeof (base == null ? void 0 : base.color) === "string" ? base.color : void 0;
|
|
2088
|
+
}, [styles3.label, styles3.disabledLabel, isDisabled]);
|
|
2089
|
+
const computedLabelStyle = (0, import_react11.useMemo)(
|
|
2090
|
+
() => [
|
|
2091
|
+
styles3.label,
|
|
2092
|
+
isDisabled ? styles3.disabledLabel : void 0,
|
|
2093
|
+
labelStyleOverride
|
|
2094
|
+
],
|
|
2095
|
+
[isDisabled, styles3.disabledLabel, styles3.label, labelStyleOverride]
|
|
2096
|
+
);
|
|
2097
|
+
const renderLeadingContent = () => {
|
|
2098
|
+
if (variant === "input" && avatar) {
|
|
2099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native18.View, { style: styles3.avatar, children: avatar });
|
|
2100
|
+
}
|
|
2101
|
+
if (leadingIcon) {
|
|
2102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2103
|
+
MaterialCommunityIcons,
|
|
2104
|
+
{
|
|
2105
|
+
name: leadingIcon,
|
|
2106
|
+
size: iconSize,
|
|
2107
|
+
color: resolvedIconColor,
|
|
2108
|
+
style: styles3.leadingIcon
|
|
2109
|
+
}
|
|
2110
|
+
);
|
|
2111
|
+
}
|
|
2112
|
+
if (variant === "filter" && isSelected) {
|
|
2113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2114
|
+
MaterialCommunityIcons,
|
|
2115
|
+
{
|
|
2116
|
+
name: "check",
|
|
2117
|
+
size: iconSize,
|
|
2118
|
+
color: resolvedIconColor,
|
|
2119
|
+
style: styles3.leadingIcon
|
|
2120
|
+
}
|
|
2121
|
+
);
|
|
2122
|
+
}
|
|
2123
|
+
return null;
|
|
2124
|
+
};
|
|
2125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2126
|
+
import_react_native18.Pressable,
|
|
2127
|
+
{
|
|
2128
|
+
...props,
|
|
2129
|
+
accessibilityRole: "button",
|
|
2130
|
+
accessibilityState: {
|
|
2131
|
+
disabled: isDisabled,
|
|
2132
|
+
...variant === "filter" ? { selected: isSelected } : void 0
|
|
2133
|
+
},
|
|
2134
|
+
hitSlop: import_react_native18.Platform.OS === "web" ? void 0 : 4,
|
|
2135
|
+
disabled: isDisabled,
|
|
2136
|
+
style: resolveStyle2(
|
|
2137
|
+
styles3.container,
|
|
2138
|
+
styles3.hoveredContainer,
|
|
2139
|
+
styles3.pressedContainer,
|
|
2140
|
+
styles3.disabledContainer,
|
|
2141
|
+
isDisabled,
|
|
2142
|
+
style
|
|
2143
|
+
),
|
|
2144
|
+
children: [
|
|
2145
|
+
renderLeadingContent(),
|
|
2146
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native18.Text, { style: computedLabelStyle, children }),
|
|
2147
|
+
showCloseIcon ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2148
|
+
import_react_native18.Pressable,
|
|
2149
|
+
{
|
|
2150
|
+
onPress: onClose,
|
|
2151
|
+
accessibilityRole: "button",
|
|
2152
|
+
accessibilityLabel: "Remove",
|
|
2153
|
+
hitSlop: 4,
|
|
2154
|
+
style: styles3.closeButton,
|
|
2155
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2156
|
+
MaterialCommunityIcons,
|
|
2157
|
+
{
|
|
2158
|
+
name: "close",
|
|
2159
|
+
size: iconSize,
|
|
2160
|
+
color: resolvedIconColor
|
|
2161
|
+
}
|
|
2162
|
+
)
|
|
2163
|
+
}
|
|
2164
|
+
) : null
|
|
2165
|
+
]
|
|
2166
|
+
}
|
|
2167
|
+
);
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
// src/checkbox/Checkbox.tsx
|
|
2171
|
+
var import_react12 = require("react");
|
|
2172
|
+
var import_react_native20 = require("react-native");
|
|
2173
|
+
var import_core11 = require("@onlynative/core");
|
|
2174
|
+
|
|
2175
|
+
// src/checkbox/styles.ts
|
|
2176
|
+
var import_react_native19 = require("react-native");
|
|
2177
|
+
function getColors(theme, checked) {
|
|
2178
|
+
const disabledOnSurface38 = alphaColor(theme.colors.onSurface, 0.38);
|
|
2179
|
+
if (checked) {
|
|
2180
|
+
return {
|
|
2181
|
+
backgroundColor: theme.colors.primary,
|
|
2182
|
+
borderColor: "transparent",
|
|
2183
|
+
borderWidth: 0,
|
|
2184
|
+
iconColor: theme.colors.onPrimary,
|
|
2185
|
+
hoveredBackgroundColor: blendColor(
|
|
2186
|
+
theme.colors.primary,
|
|
2187
|
+
theme.colors.onPrimary,
|
|
2188
|
+
theme.stateLayer.hoveredOpacity
|
|
2189
|
+
),
|
|
2190
|
+
pressedBackgroundColor: blendColor(
|
|
2191
|
+
theme.colors.primary,
|
|
2192
|
+
theme.colors.onPrimary,
|
|
2193
|
+
theme.stateLayer.pressedOpacity
|
|
2194
|
+
),
|
|
2195
|
+
disabledBackgroundColor: disabledOnSurface38,
|
|
2196
|
+
disabledBorderColor: "transparent",
|
|
2197
|
+
disabledBorderWidth: 0,
|
|
2198
|
+
disabledIconColor: theme.colors.surface
|
|
2199
|
+
};
|
|
2200
|
+
}
|
|
2201
|
+
return {
|
|
2202
|
+
backgroundColor: "transparent",
|
|
2203
|
+
borderColor: theme.colors.onSurfaceVariant,
|
|
2204
|
+
borderWidth: 2,
|
|
2205
|
+
iconColor: "transparent",
|
|
2206
|
+
hoveredBackgroundColor: alphaColor(
|
|
2207
|
+
theme.colors.onSurface,
|
|
2208
|
+
theme.stateLayer.hoveredOpacity
|
|
2209
|
+
),
|
|
2210
|
+
pressedBackgroundColor: alphaColor(
|
|
2211
|
+
theme.colors.onSurface,
|
|
2212
|
+
theme.stateLayer.pressedOpacity
|
|
2213
|
+
),
|
|
2214
|
+
disabledBackgroundColor: "transparent",
|
|
2215
|
+
disabledBorderColor: disabledOnSurface38,
|
|
2216
|
+
disabledBorderWidth: 2,
|
|
2217
|
+
disabledIconColor: "transparent"
|
|
2218
|
+
};
|
|
2219
|
+
}
|
|
2220
|
+
function applyColorOverrides4(theme, colors, containerColor, contentColor) {
|
|
2221
|
+
if (!containerColor && !contentColor) return colors;
|
|
2222
|
+
const result = { ...colors };
|
|
2223
|
+
if (contentColor) {
|
|
2224
|
+
result.iconColor = contentColor;
|
|
2225
|
+
}
|
|
2226
|
+
if (containerColor) {
|
|
2227
|
+
const overlay = contentColor != null ? contentColor : colors.iconColor;
|
|
2228
|
+
result.backgroundColor = containerColor;
|
|
2229
|
+
result.borderColor = containerColor;
|
|
2230
|
+
result.hoveredBackgroundColor = blendColor(
|
|
2231
|
+
containerColor,
|
|
2232
|
+
overlay,
|
|
2233
|
+
theme.stateLayer.hoveredOpacity
|
|
2234
|
+
);
|
|
2235
|
+
result.pressedBackgroundColor = blendColor(
|
|
2236
|
+
containerColor,
|
|
2237
|
+
overlay,
|
|
2238
|
+
theme.stateLayer.pressedOpacity
|
|
2239
|
+
);
|
|
2240
|
+
}
|
|
2241
|
+
return result;
|
|
2242
|
+
}
|
|
2243
|
+
function createStyles6(theme, checked, containerColor, contentColor) {
|
|
2244
|
+
const colors = applyColorOverrides4(
|
|
2245
|
+
theme,
|
|
2246
|
+
getColors(theme, checked),
|
|
2247
|
+
containerColor,
|
|
2248
|
+
contentColor
|
|
2249
|
+
);
|
|
2250
|
+
const size = 18;
|
|
2251
|
+
const touchTarget = 48;
|
|
2252
|
+
return import_react_native19.StyleSheet.create({
|
|
2253
|
+
container: {
|
|
2254
|
+
width: touchTarget,
|
|
2255
|
+
height: touchTarget,
|
|
2256
|
+
alignItems: "center",
|
|
2257
|
+
justifyContent: "center",
|
|
2258
|
+
cursor: "pointer"
|
|
2259
|
+
},
|
|
2260
|
+
hoveredContainer: {
|
|
2261
|
+
borderRadius: touchTarget / 2,
|
|
2262
|
+
backgroundColor: colors.hoveredBackgroundColor
|
|
2263
|
+
},
|
|
2264
|
+
pressedContainer: {
|
|
2265
|
+
borderRadius: touchTarget / 2,
|
|
2266
|
+
backgroundColor: colors.pressedBackgroundColor
|
|
2267
|
+
},
|
|
2268
|
+
disabledContainer: {
|
|
2269
|
+
cursor: "auto"
|
|
2270
|
+
},
|
|
2271
|
+
box: {
|
|
2272
|
+
width: size,
|
|
2273
|
+
height: size,
|
|
2274
|
+
borderRadius: theme.shape.cornerExtraSmall,
|
|
2275
|
+
backgroundColor: colors.backgroundColor,
|
|
2276
|
+
borderColor: colors.borderColor,
|
|
2277
|
+
borderWidth: colors.borderWidth,
|
|
2278
|
+
alignItems: "center",
|
|
2279
|
+
justifyContent: "center"
|
|
2280
|
+
},
|
|
2281
|
+
disabledBox: {
|
|
2282
|
+
backgroundColor: colors.disabledBackgroundColor,
|
|
2283
|
+
borderColor: colors.disabledBorderColor,
|
|
2284
|
+
borderWidth: colors.disabledBorderWidth
|
|
2285
|
+
},
|
|
2286
|
+
iconColor: {
|
|
2287
|
+
color: colors.iconColor
|
|
2288
|
+
},
|
|
2289
|
+
disabledIconColor: {
|
|
2290
|
+
color: colors.disabledIconColor
|
|
2291
|
+
}
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
// src/checkbox/Checkbox.tsx
|
|
2296
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2297
|
+
function resolveStyle3(containerStyle, hoveredContainerStyle, pressedContainerStyle, disabledContainerStyle, disabled, style) {
|
|
2298
|
+
if (typeof style === "function") {
|
|
2299
|
+
return (state) => [
|
|
2300
|
+
containerStyle,
|
|
2301
|
+
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
2302
|
+
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
2303
|
+
disabled ? disabledContainerStyle : void 0,
|
|
2304
|
+
style(state)
|
|
2305
|
+
];
|
|
2306
|
+
}
|
|
2307
|
+
return (state) => [
|
|
2308
|
+
containerStyle,
|
|
2309
|
+
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
2310
|
+
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
2311
|
+
disabled ? disabledContainerStyle : void 0,
|
|
2312
|
+
style
|
|
2313
|
+
];
|
|
2314
|
+
}
|
|
2315
|
+
function Checkbox({
|
|
2316
|
+
style,
|
|
2317
|
+
value = false,
|
|
2318
|
+
onValueChange,
|
|
2319
|
+
containerColor,
|
|
2320
|
+
contentColor,
|
|
2321
|
+
disabled = false,
|
|
2322
|
+
...props
|
|
2323
|
+
}) {
|
|
2324
|
+
const isDisabled = Boolean(disabled);
|
|
2325
|
+
const isChecked = Boolean(value);
|
|
2326
|
+
const MaterialCommunityIcons = isChecked ? getMaterialCommunityIcons() : null;
|
|
2327
|
+
const theme = (0, import_core11.useTheme)();
|
|
2328
|
+
const styles3 = (0, import_react12.useMemo)(
|
|
2329
|
+
() => createStyles6(theme, isChecked, containerColor, contentColor),
|
|
2330
|
+
[theme, isChecked, containerColor, contentColor]
|
|
2331
|
+
);
|
|
2332
|
+
const resolvedIconColor = (0, import_react12.useMemo)(() => {
|
|
2333
|
+
const base = import_react_native20.StyleSheet.flatten([
|
|
2334
|
+
styles3.iconColor,
|
|
2335
|
+
isDisabled ? styles3.disabledIconColor : void 0
|
|
2336
|
+
]);
|
|
2337
|
+
return typeof (base == null ? void 0 : base.color) === "string" ? base.color : void 0;
|
|
2338
|
+
}, [styles3.iconColor, styles3.disabledIconColor, isDisabled]);
|
|
2339
|
+
const handlePress = () => {
|
|
2340
|
+
if (!isDisabled) {
|
|
2341
|
+
onValueChange == null ? void 0 : onValueChange(!isChecked);
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2344
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2345
|
+
import_react_native20.Pressable,
|
|
2346
|
+
{
|
|
2347
|
+
...props,
|
|
2348
|
+
accessibilityRole: "checkbox",
|
|
2349
|
+
accessibilityState: {
|
|
2350
|
+
disabled: isDisabled,
|
|
2351
|
+
checked: isChecked
|
|
2352
|
+
},
|
|
2353
|
+
hitSlop: import_react_native20.Platform.OS === "web" ? void 0 : 4,
|
|
2354
|
+
disabled: isDisabled,
|
|
2355
|
+
onPress: handlePress,
|
|
2356
|
+
style: resolveStyle3(
|
|
2357
|
+
styles3.container,
|
|
2358
|
+
styles3.hoveredContainer,
|
|
2359
|
+
styles3.pressedContainer,
|
|
2360
|
+
styles3.disabledContainer,
|
|
2361
|
+
isDisabled,
|
|
2362
|
+
style
|
|
2363
|
+
),
|
|
2364
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native20.View, { style: [styles3.box, isDisabled ? styles3.disabledBox : void 0], children: isChecked ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2365
|
+
MaterialCommunityIcons,
|
|
2366
|
+
{
|
|
2367
|
+
name: "check",
|
|
2368
|
+
size: 14,
|
|
2369
|
+
color: resolvedIconColor
|
|
2370
|
+
}
|
|
2371
|
+
) : null })
|
|
2372
|
+
}
|
|
2373
|
+
);
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
// src/radio/Radio.tsx
|
|
2377
|
+
var import_react13 = require("react");
|
|
2378
|
+
var import_react_native22 = require("react-native");
|
|
2379
|
+
var import_core12 = require("@onlynative/core");
|
|
2380
|
+
|
|
2381
|
+
// src/radio/styles.ts
|
|
2382
|
+
var import_react_native21 = require("react-native");
|
|
2383
|
+
function getColors2(theme, selected) {
|
|
2384
|
+
const disabledOnSurface38 = alphaColor(theme.colors.onSurface, 0.38);
|
|
2385
|
+
if (selected) {
|
|
2386
|
+
return {
|
|
2387
|
+
borderColor: theme.colors.primary,
|
|
2388
|
+
dotColor: theme.colors.primary,
|
|
2389
|
+
hoveredBackgroundColor: alphaColor(
|
|
2390
|
+
theme.colors.primary,
|
|
2391
|
+
theme.stateLayer.hoveredOpacity
|
|
2392
|
+
),
|
|
2393
|
+
pressedBackgroundColor: alphaColor(
|
|
2394
|
+
theme.colors.primary,
|
|
2395
|
+
theme.stateLayer.pressedOpacity
|
|
2396
|
+
),
|
|
2397
|
+
disabledBorderColor: disabledOnSurface38,
|
|
2398
|
+
disabledDotColor: disabledOnSurface38
|
|
2399
|
+
};
|
|
2400
|
+
}
|
|
2401
|
+
return {
|
|
2402
|
+
borderColor: theme.colors.onSurfaceVariant,
|
|
2403
|
+
dotColor: "transparent",
|
|
2404
|
+
hoveredBackgroundColor: alphaColor(
|
|
2405
|
+
theme.colors.onSurface,
|
|
2406
|
+
theme.stateLayer.hoveredOpacity
|
|
2407
|
+
),
|
|
2408
|
+
pressedBackgroundColor: alphaColor(
|
|
2409
|
+
theme.colors.onSurface,
|
|
2410
|
+
theme.stateLayer.pressedOpacity
|
|
2411
|
+
),
|
|
2412
|
+
disabledBorderColor: disabledOnSurface38,
|
|
2413
|
+
disabledDotColor: "transparent"
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
function applyColorOverrides5(theme, colors, containerColor, contentColor) {
|
|
2417
|
+
if (!containerColor && !contentColor) return colors;
|
|
2418
|
+
const result = { ...colors };
|
|
2419
|
+
if (containerColor) {
|
|
2420
|
+
result.borderColor = containerColor;
|
|
2421
|
+
result.dotColor = containerColor;
|
|
2422
|
+
result.hoveredBackgroundColor = alphaColor(
|
|
2423
|
+
containerColor,
|
|
2424
|
+
theme.stateLayer.hoveredOpacity
|
|
2425
|
+
);
|
|
2426
|
+
result.pressedBackgroundColor = alphaColor(
|
|
2427
|
+
containerColor,
|
|
2428
|
+
theme.stateLayer.pressedOpacity
|
|
2429
|
+
);
|
|
2430
|
+
}
|
|
2431
|
+
if (contentColor) {
|
|
2432
|
+
result.borderColor = contentColor;
|
|
2433
|
+
}
|
|
2434
|
+
return result;
|
|
2435
|
+
}
|
|
2436
|
+
function createStyles7(theme, selected, containerColor, contentColor) {
|
|
2437
|
+
const colors = applyColorOverrides5(
|
|
2438
|
+
theme,
|
|
2439
|
+
getColors2(theme, selected),
|
|
2440
|
+
containerColor,
|
|
2441
|
+
contentColor
|
|
2442
|
+
);
|
|
2443
|
+
const outerSize = 20;
|
|
2444
|
+
const innerSize = 10;
|
|
2445
|
+
const touchTarget = 48;
|
|
2446
|
+
return import_react_native21.StyleSheet.create({
|
|
2447
|
+
container: {
|
|
2448
|
+
width: touchTarget,
|
|
2449
|
+
height: touchTarget,
|
|
2450
|
+
alignItems: "center",
|
|
2451
|
+
justifyContent: "center",
|
|
2452
|
+
cursor: "pointer"
|
|
2453
|
+
},
|
|
2454
|
+
hoveredContainer: {
|
|
2455
|
+
borderRadius: touchTarget / 2,
|
|
2456
|
+
backgroundColor: colors.hoveredBackgroundColor
|
|
2457
|
+
},
|
|
2458
|
+
pressedContainer: {
|
|
2459
|
+
borderRadius: touchTarget / 2,
|
|
2460
|
+
backgroundColor: colors.pressedBackgroundColor
|
|
2461
|
+
},
|
|
2462
|
+
disabledContainer: {
|
|
2463
|
+
cursor: "auto"
|
|
2464
|
+
},
|
|
2465
|
+
outer: {
|
|
2466
|
+
width: outerSize,
|
|
2467
|
+
height: outerSize,
|
|
2468
|
+
borderRadius: outerSize / 2,
|
|
2469
|
+
borderWidth: 2,
|
|
2470
|
+
borderColor: colors.borderColor,
|
|
2471
|
+
alignItems: "center",
|
|
2472
|
+
justifyContent: "center"
|
|
2473
|
+
},
|
|
2474
|
+
disabledOuter: {
|
|
2475
|
+
borderColor: colors.disabledBorderColor
|
|
2476
|
+
},
|
|
2477
|
+
inner: {
|
|
2478
|
+
width: innerSize,
|
|
2479
|
+
height: innerSize,
|
|
2480
|
+
borderRadius: innerSize / 2,
|
|
2481
|
+
backgroundColor: colors.dotColor
|
|
2482
|
+
},
|
|
2483
|
+
disabledInner: {
|
|
2484
|
+
backgroundColor: colors.disabledDotColor
|
|
2485
|
+
}
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
// src/radio/Radio.tsx
|
|
2490
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2491
|
+
function resolveStyle4(containerStyle, hoveredContainerStyle, pressedContainerStyle, disabledContainerStyle, disabled, style) {
|
|
2492
|
+
if (typeof style === "function") {
|
|
2493
|
+
return (state) => [
|
|
2494
|
+
containerStyle,
|
|
2495
|
+
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
2496
|
+
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
2497
|
+
disabled ? disabledContainerStyle : void 0,
|
|
2498
|
+
style(state)
|
|
2499
|
+
];
|
|
2500
|
+
}
|
|
2501
|
+
return (state) => [
|
|
2502
|
+
containerStyle,
|
|
2503
|
+
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
2504
|
+
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
2505
|
+
disabled ? disabledContainerStyle : void 0,
|
|
2506
|
+
style
|
|
2507
|
+
];
|
|
2508
|
+
}
|
|
2509
|
+
function Radio({
|
|
2510
|
+
style,
|
|
2511
|
+
value = false,
|
|
2512
|
+
onValueChange,
|
|
2513
|
+
containerColor,
|
|
2514
|
+
contentColor,
|
|
2515
|
+
disabled = false,
|
|
2516
|
+
...props
|
|
2517
|
+
}) {
|
|
2518
|
+
const isDisabled = Boolean(disabled);
|
|
2519
|
+
const isSelected = Boolean(value);
|
|
2520
|
+
const theme = (0, import_core12.useTheme)();
|
|
2521
|
+
const styles3 = (0, import_react13.useMemo)(
|
|
2522
|
+
() => createStyles7(theme, isSelected, containerColor, contentColor),
|
|
2523
|
+
[theme, isSelected, containerColor, contentColor]
|
|
2524
|
+
);
|
|
2525
|
+
const handlePress = () => {
|
|
2526
|
+
if (!isDisabled) {
|
|
2527
|
+
onValueChange == null ? void 0 : onValueChange(!isSelected);
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2531
|
+
import_react_native22.Pressable,
|
|
2532
|
+
{
|
|
2533
|
+
...props,
|
|
2534
|
+
accessibilityRole: "radio",
|
|
2535
|
+
accessibilityState: {
|
|
2536
|
+
disabled: isDisabled,
|
|
2537
|
+
checked: isSelected
|
|
2538
|
+
},
|
|
2539
|
+
hitSlop: import_react_native22.Platform.OS === "web" ? void 0 : 4,
|
|
2540
|
+
disabled: isDisabled,
|
|
2541
|
+
onPress: handlePress,
|
|
2542
|
+
style: resolveStyle4(
|
|
2543
|
+
styles3.container,
|
|
2544
|
+
styles3.hoveredContainer,
|
|
2545
|
+
styles3.pressedContainer,
|
|
2546
|
+
styles3.disabledContainer,
|
|
2547
|
+
isDisabled,
|
|
2548
|
+
style
|
|
2549
|
+
),
|
|
2550
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2551
|
+
import_react_native22.View,
|
|
2552
|
+
{
|
|
2553
|
+
style: [styles3.outer, isDisabled ? styles3.disabledOuter : void 0],
|
|
2554
|
+
children: isSelected ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2555
|
+
import_react_native22.View,
|
|
2556
|
+
{
|
|
2557
|
+
style: [
|
|
2558
|
+
styles3.inner,
|
|
2559
|
+
isDisabled ? styles3.disabledInner : void 0
|
|
2560
|
+
]
|
|
2561
|
+
}
|
|
2562
|
+
) : null
|
|
2563
|
+
}
|
|
2564
|
+
)
|
|
2565
|
+
}
|
|
2566
|
+
);
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
// src/switch/Switch.tsx
|
|
2570
|
+
var import_react14 = require("react");
|
|
2571
|
+
var import_react_native24 = require("react-native");
|
|
2572
|
+
var import_core13 = require("@onlynative/core");
|
|
2573
|
+
|
|
2574
|
+
// src/switch/styles.ts
|
|
2575
|
+
var import_react_native23 = require("react-native");
|
|
2576
|
+
function getColors3(theme, selected) {
|
|
2577
|
+
const disabledOnSurface12 = alphaColor(theme.colors.onSurface, 0.12);
|
|
2578
|
+
const disabledOnSurface38 = alphaColor(theme.colors.onSurface, 0.38);
|
|
2579
|
+
if (selected) {
|
|
2580
|
+
return {
|
|
2581
|
+
trackColor: theme.colors.primary,
|
|
2582
|
+
thumbColor: theme.colors.onPrimary,
|
|
2583
|
+
iconColor: theme.colors.onPrimaryContainer,
|
|
2584
|
+
hoveredTrackColor: blendColor(
|
|
2585
|
+
theme.colors.primary,
|
|
2586
|
+
theme.colors.onPrimary,
|
|
2587
|
+
theme.stateLayer.hoveredOpacity
|
|
2588
|
+
),
|
|
2589
|
+
pressedTrackColor: blendColor(
|
|
2590
|
+
theme.colors.primary,
|
|
2591
|
+
theme.colors.onPrimary,
|
|
2592
|
+
theme.stateLayer.pressedOpacity
|
|
2593
|
+
),
|
|
2594
|
+
borderColor: "transparent",
|
|
2595
|
+
borderWidth: 0,
|
|
2596
|
+
disabledTrackColor: disabledOnSurface12,
|
|
2597
|
+
disabledThumbColor: theme.colors.surface,
|
|
2598
|
+
disabledBorderColor: "transparent",
|
|
2599
|
+
disabledBorderWidth: 0
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
return {
|
|
2603
|
+
trackColor: theme.colors.surfaceContainerHighest,
|
|
2604
|
+
thumbColor: theme.colors.outline,
|
|
2605
|
+
iconColor: theme.colors.surfaceContainerHighest,
|
|
2606
|
+
hoveredTrackColor: blendColor(
|
|
2607
|
+
theme.colors.surfaceContainerHighest,
|
|
2608
|
+
theme.colors.onSurface,
|
|
2609
|
+
theme.stateLayer.hoveredOpacity
|
|
2610
|
+
),
|
|
2611
|
+
pressedTrackColor: blendColor(
|
|
2612
|
+
theme.colors.surfaceContainerHighest,
|
|
2613
|
+
theme.colors.onSurface,
|
|
2614
|
+
theme.stateLayer.pressedOpacity
|
|
2615
|
+
),
|
|
2616
|
+
borderColor: theme.colors.outline,
|
|
2617
|
+
borderWidth: 2,
|
|
2618
|
+
disabledTrackColor: disabledOnSurface12,
|
|
2619
|
+
disabledThumbColor: disabledOnSurface38,
|
|
2620
|
+
disabledBorderColor: disabledOnSurface12,
|
|
2621
|
+
disabledBorderWidth: 2
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
2624
|
+
function applyColorOverrides6(theme, colors, containerColor, contentColor) {
|
|
2625
|
+
if (!containerColor && !contentColor) return colors;
|
|
2626
|
+
const result = { ...colors };
|
|
2627
|
+
if (contentColor) {
|
|
2628
|
+
result.thumbColor = contentColor;
|
|
2629
|
+
result.iconColor = contentColor;
|
|
2630
|
+
}
|
|
2631
|
+
if (containerColor) {
|
|
2632
|
+
const overlay = contentColor != null ? contentColor : colors.thumbColor;
|
|
2633
|
+
result.trackColor = containerColor;
|
|
2634
|
+
result.borderColor = containerColor;
|
|
2635
|
+
result.hoveredTrackColor = blendColor(
|
|
2636
|
+
containerColor,
|
|
2637
|
+
overlay,
|
|
2638
|
+
theme.stateLayer.hoveredOpacity
|
|
2639
|
+
);
|
|
2640
|
+
result.pressedTrackColor = blendColor(
|
|
2641
|
+
containerColor,
|
|
2642
|
+
overlay,
|
|
2643
|
+
theme.stateLayer.pressedOpacity
|
|
2644
|
+
);
|
|
2645
|
+
if (contentColor) {
|
|
2646
|
+
result.iconColor = containerColor;
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
return result;
|
|
2650
|
+
}
|
|
2651
|
+
function createStyles8(theme, selected, hasIcon, containerColor, contentColor) {
|
|
2652
|
+
const colors = applyColorOverrides6(
|
|
2653
|
+
theme,
|
|
2654
|
+
getColors3(theme, selected),
|
|
2655
|
+
containerColor,
|
|
2656
|
+
contentColor
|
|
2657
|
+
);
|
|
2658
|
+
const thumbSize = selected || hasIcon ? 24 : 16;
|
|
2659
|
+
const trackWidth = 52;
|
|
2660
|
+
const trackHeight = 32;
|
|
2661
|
+
const trackPadding = 4;
|
|
2662
|
+
const thumbOffset = selected ? trackWidth - trackPadding - thumbSize : trackPadding;
|
|
2663
|
+
return import_react_native23.StyleSheet.create({
|
|
2664
|
+
track: {
|
|
2665
|
+
width: trackWidth,
|
|
2666
|
+
height: trackHeight,
|
|
2667
|
+
borderRadius: trackHeight / 2,
|
|
2668
|
+
backgroundColor: colors.trackColor,
|
|
2669
|
+
borderColor: colors.borderColor,
|
|
2670
|
+
borderWidth: colors.borderWidth,
|
|
2671
|
+
justifyContent: "center",
|
|
2672
|
+
cursor: "pointer"
|
|
2673
|
+
},
|
|
2674
|
+
hoveredTrack: {
|
|
2675
|
+
backgroundColor: colors.hoveredTrackColor
|
|
2676
|
+
},
|
|
2677
|
+
pressedTrack: {
|
|
2678
|
+
backgroundColor: colors.pressedTrackColor
|
|
2679
|
+
},
|
|
2680
|
+
disabledTrack: {
|
|
2681
|
+
backgroundColor: colors.disabledTrackColor,
|
|
2682
|
+
borderColor: colors.disabledBorderColor,
|
|
2683
|
+
borderWidth: colors.disabledBorderWidth,
|
|
2684
|
+
cursor: "auto"
|
|
2685
|
+
},
|
|
2686
|
+
thumb: {
|
|
2687
|
+
width: thumbSize,
|
|
2688
|
+
height: thumbSize,
|
|
2689
|
+
borderRadius: thumbSize / 2,
|
|
2690
|
+
backgroundColor: colors.thumbColor,
|
|
2691
|
+
marginStart: thumbOffset,
|
|
2692
|
+
alignItems: "center",
|
|
2693
|
+
justifyContent: "center"
|
|
2694
|
+
},
|
|
2695
|
+
disabledThumb: {
|
|
2696
|
+
backgroundColor: colors.disabledThumbColor
|
|
2697
|
+
},
|
|
2698
|
+
iconColor: {
|
|
2699
|
+
color: colors.iconColor
|
|
2700
|
+
},
|
|
2701
|
+
disabledIconColor: {
|
|
2702
|
+
color: alphaColor(theme.colors.onSurface, 0.38)
|
|
2703
|
+
}
|
|
2704
|
+
});
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
// src/switch/Switch.tsx
|
|
2708
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2709
|
+
function resolveStyle5(trackStyle, hoveredTrackStyle, pressedTrackStyle, disabledTrackStyle, disabled, style) {
|
|
2710
|
+
if (typeof style === "function") {
|
|
2711
|
+
return (state) => [
|
|
2712
|
+
trackStyle,
|
|
2713
|
+
state.hovered && !state.pressed && !disabled ? hoveredTrackStyle : void 0,
|
|
2714
|
+
state.pressed && !disabled ? pressedTrackStyle : void 0,
|
|
2715
|
+
disabled ? disabledTrackStyle : void 0,
|
|
2716
|
+
style(state)
|
|
2717
|
+
];
|
|
2718
|
+
}
|
|
2719
|
+
return (state) => [
|
|
2720
|
+
trackStyle,
|
|
2721
|
+
state.hovered && !state.pressed && !disabled ? hoveredTrackStyle : void 0,
|
|
2722
|
+
state.pressed && !disabled ? pressedTrackStyle : void 0,
|
|
2723
|
+
disabled ? disabledTrackStyle : void 0,
|
|
2724
|
+
style
|
|
2725
|
+
];
|
|
2726
|
+
}
|
|
2727
|
+
function Switch({
|
|
2728
|
+
style,
|
|
2729
|
+
value = false,
|
|
2730
|
+
onValueChange,
|
|
2731
|
+
selectedIcon = "check",
|
|
2732
|
+
unselectedIcon,
|
|
2733
|
+
containerColor,
|
|
2734
|
+
contentColor,
|
|
2735
|
+
disabled = false,
|
|
2736
|
+
...props
|
|
2737
|
+
}) {
|
|
2738
|
+
const isDisabled = Boolean(disabled);
|
|
2739
|
+
const isSelected = Boolean(value);
|
|
2740
|
+
const hasIcon = isSelected || Boolean(unselectedIcon);
|
|
2741
|
+
const theme = (0, import_core13.useTheme)();
|
|
2742
|
+
const styles3 = (0, import_react14.useMemo)(
|
|
2743
|
+
() => createStyles8(theme, isSelected, hasIcon, containerColor, contentColor),
|
|
2744
|
+
[theme, isSelected, hasIcon, containerColor, contentColor]
|
|
2745
|
+
);
|
|
2746
|
+
const resolvedIconColor = (0, import_react14.useMemo)(() => {
|
|
2747
|
+
const base = import_react_native24.StyleSheet.flatten([
|
|
2748
|
+
styles3.iconColor,
|
|
2749
|
+
isDisabled ? styles3.disabledIconColor : void 0
|
|
2750
|
+
]);
|
|
2751
|
+
return typeof (base == null ? void 0 : base.color) === "string" ? base.color : void 0;
|
|
2752
|
+
}, [styles3.iconColor, styles3.disabledIconColor, isDisabled]);
|
|
2753
|
+
const handlePress = () => {
|
|
2754
|
+
if (!isDisabled) {
|
|
2755
|
+
onValueChange == null ? void 0 : onValueChange(!isSelected);
|
|
2756
|
+
}
|
|
2757
|
+
};
|
|
2758
|
+
const iconName = isSelected ? selectedIcon : unselectedIcon;
|
|
2759
|
+
const MaterialCommunityIcons = iconName ? getMaterialCommunityIcons() : null;
|
|
2760
|
+
const iconSize = 16;
|
|
2761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2762
|
+
import_react_native24.Pressable,
|
|
2763
|
+
{
|
|
2764
|
+
...props,
|
|
2765
|
+
accessibilityRole: "switch",
|
|
2766
|
+
accessibilityState: {
|
|
2767
|
+
disabled: isDisabled,
|
|
2768
|
+
checked: isSelected
|
|
2769
|
+
},
|
|
2770
|
+
hitSlop: import_react_native24.Platform.OS === "web" ? void 0 : 4,
|
|
2771
|
+
disabled: isDisabled,
|
|
2772
|
+
onPress: handlePress,
|
|
2773
|
+
style: resolveStyle5(
|
|
2774
|
+
styles3.track,
|
|
2775
|
+
styles3.hoveredTrack,
|
|
2776
|
+
styles3.pressedTrack,
|
|
2777
|
+
styles3.disabledTrack,
|
|
2778
|
+
isDisabled,
|
|
2779
|
+
style
|
|
2780
|
+
),
|
|
2781
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2782
|
+
import_react_native24.View,
|
|
2783
|
+
{
|
|
2784
|
+
style: [styles3.thumb, isDisabled ? styles3.disabledThumb : void 0],
|
|
2785
|
+
children: iconName ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2786
|
+
MaterialCommunityIcons,
|
|
2787
|
+
{
|
|
2788
|
+
name: iconName,
|
|
2789
|
+
size: iconSize,
|
|
2790
|
+
color: resolvedIconColor
|
|
2791
|
+
}
|
|
2792
|
+
) : null
|
|
2793
|
+
}
|
|
2794
|
+
)
|
|
2795
|
+
}
|
|
2796
|
+
);
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
// src/text-field/TextField.tsx
|
|
2800
|
+
var import_react15 = require("react");
|
|
2801
|
+
var import_react_native26 = require("react-native");
|
|
2802
|
+
var import_core14 = require("@onlynative/core");
|
|
2803
|
+
|
|
2804
|
+
// src/text-field/styles.ts
|
|
2805
|
+
var import_react_native25 = require("react-native");
|
|
2806
|
+
var CONTAINER_HEIGHT = 56;
|
|
2807
|
+
var ICON_SIZE = 24;
|
|
2808
|
+
var LABEL_FLOATED_LINE_HEIGHT = 16;
|
|
2809
|
+
var FILLED_LABEL_RESTING_TOP = 16;
|
|
2810
|
+
var FILLED_LABEL_FLOATED_TOP = 8;
|
|
2811
|
+
var FILLED_INPUT_TOP = 24;
|
|
2812
|
+
var FILLED_INPUT_BOTTOM = 8;
|
|
2813
|
+
var OUTLINED_INPUT_VERTICAL = 16;
|
|
2814
|
+
var OUTLINED_LABEL_RESTING_TOP = 16;
|
|
2815
|
+
var OUTLINED_LABEL_FLOATED_TOP = -(LABEL_FLOATED_LINE_HEIGHT / 2);
|
|
2816
|
+
var labelPositions = {
|
|
2817
|
+
filledRestingTop: FILLED_LABEL_RESTING_TOP,
|
|
2818
|
+
filledFloatedTop: FILLED_LABEL_FLOATED_TOP,
|
|
2819
|
+
outlinedRestingTop: OUTLINED_LABEL_RESTING_TOP,
|
|
2820
|
+
outlinedFloatedTop: OUTLINED_LABEL_FLOATED_TOP
|
|
2821
|
+
};
|
|
2822
|
+
function getVariantColors4(theme, variant) {
|
|
2823
|
+
const disabledOpacity = theme.stateLayer.disabledOpacity;
|
|
2824
|
+
const common = {
|
|
2825
|
+
focusedBorderColor: theme.colors.primary,
|
|
2826
|
+
errorBorderColor: theme.colors.error,
|
|
2827
|
+
focusedLabelColor: theme.colors.primary,
|
|
2828
|
+
errorLabelColor: theme.colors.error,
|
|
2829
|
+
textColor: theme.colors.onSurface,
|
|
2830
|
+
disabledTextColor: alphaColor(theme.colors.onSurface, disabledOpacity),
|
|
2831
|
+
disabledLabelColor: alphaColor(theme.colors.onSurface, disabledOpacity),
|
|
2832
|
+
disabledBorderColor: alphaColor(theme.colors.onSurface, 0.12),
|
|
2833
|
+
placeholderColor: theme.colors.onSurfaceVariant,
|
|
2834
|
+
supportingTextColor: theme.colors.onSurfaceVariant,
|
|
2835
|
+
errorSupportingTextColor: theme.colors.error,
|
|
2836
|
+
iconColor: theme.colors.onSurfaceVariant,
|
|
2837
|
+
errorIconColor: theme.colors.error,
|
|
2838
|
+
disabledIconColor: alphaColor(theme.colors.onSurface, disabledOpacity)
|
|
2839
|
+
};
|
|
2840
|
+
if (variant === "outlined") {
|
|
2841
|
+
return {
|
|
2842
|
+
...common,
|
|
2843
|
+
backgroundColor: "transparent",
|
|
2844
|
+
borderColor: theme.colors.outline,
|
|
2845
|
+
disabledBackgroundColor: "transparent",
|
|
2846
|
+
labelColor: theme.colors.onSurfaceVariant
|
|
2847
|
+
};
|
|
2848
|
+
}
|
|
2849
|
+
return {
|
|
2850
|
+
...common,
|
|
2851
|
+
backgroundColor: theme.colors.surfaceContainerHighest,
|
|
2852
|
+
borderColor: theme.colors.onSurfaceVariant,
|
|
2853
|
+
disabledBackgroundColor: alphaColor(theme.colors.onSurface, 0.04),
|
|
2854
|
+
labelColor: theme.colors.onSurfaceVariant
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2857
|
+
function createStyles9(theme, variant) {
|
|
2858
|
+
const colors = getVariantColors4(theme, variant);
|
|
2859
|
+
const bodyLarge = theme.typography.bodyLarge;
|
|
2860
|
+
const bodySmall = theme.typography.bodySmall;
|
|
2861
|
+
const isFilled = variant === "filled";
|
|
2862
|
+
return {
|
|
2863
|
+
colors,
|
|
2864
|
+
styles: import_react_native25.StyleSheet.create({
|
|
2865
|
+
root: {
|
|
2866
|
+
alignSelf: "stretch"
|
|
2867
|
+
},
|
|
2868
|
+
container: {
|
|
2869
|
+
minHeight: CONTAINER_HEIGHT,
|
|
2870
|
+
flexDirection: "row",
|
|
2871
|
+
alignItems: "stretch",
|
|
2872
|
+
backgroundColor: colors.backgroundColor,
|
|
2873
|
+
paddingHorizontal: theme.spacing.md,
|
|
2874
|
+
...isFilled ? {
|
|
2875
|
+
borderTopStartRadius: theme.shape.cornerExtraSmall,
|
|
2876
|
+
borderTopEndRadius: theme.shape.cornerExtraSmall
|
|
2877
|
+
} : {
|
|
2878
|
+
borderRadius: theme.shape.cornerExtraSmall,
|
|
2879
|
+
borderWidth: 1,
|
|
2880
|
+
borderColor: colors.borderColor
|
|
2881
|
+
}
|
|
2882
|
+
},
|
|
2883
|
+
containerFocused: isFilled ? {} : {
|
|
2884
|
+
borderWidth: 2,
|
|
2885
|
+
borderColor: colors.focusedBorderColor,
|
|
2886
|
+
paddingHorizontal: theme.spacing.md - 1
|
|
2887
|
+
},
|
|
2888
|
+
containerError: isFilled ? {} : {
|
|
2889
|
+
borderWidth: 2,
|
|
2890
|
+
borderColor: colors.errorBorderColor,
|
|
2891
|
+
paddingHorizontal: theme.spacing.md - 1
|
|
2892
|
+
},
|
|
2893
|
+
containerDisabled: isFilled ? { backgroundColor: colors.disabledBackgroundColor } : {
|
|
2894
|
+
borderColor: colors.disabledBorderColor
|
|
2895
|
+
},
|
|
2896
|
+
indicator: {
|
|
2897
|
+
position: "absolute",
|
|
2898
|
+
start: 0,
|
|
2899
|
+
end: 0,
|
|
2900
|
+
bottom: 0,
|
|
2901
|
+
height: 1,
|
|
2902
|
+
backgroundColor: colors.borderColor
|
|
2903
|
+
},
|
|
2904
|
+
indicatorFocused: {
|
|
2905
|
+
height: 2,
|
|
2906
|
+
backgroundColor: colors.focusedBorderColor
|
|
2907
|
+
},
|
|
2908
|
+
indicatorError: {
|
|
2909
|
+
height: 2,
|
|
2910
|
+
backgroundColor: colors.errorBorderColor
|
|
2911
|
+
},
|
|
2912
|
+
indicatorDisabled: {
|
|
2913
|
+
backgroundColor: colors.disabledBorderColor
|
|
2914
|
+
},
|
|
2915
|
+
inputWrapper: {
|
|
2916
|
+
flex: 1,
|
|
2917
|
+
justifyContent: "center"
|
|
2918
|
+
},
|
|
2919
|
+
// When label is present, use explicit padding so the input position
|
|
2920
|
+
// matches the label resting top exactly.
|
|
2921
|
+
inputWrapperWithLabel: {
|
|
2922
|
+
justifyContent: "flex-start",
|
|
2923
|
+
paddingTop: isFilled ? FILLED_INPUT_TOP : OUTLINED_INPUT_VERTICAL,
|
|
2924
|
+
paddingBottom: isFilled ? FILLED_INPUT_BOTTOM : OUTLINED_INPUT_VERTICAL
|
|
2925
|
+
},
|
|
2926
|
+
label: {
|
|
2927
|
+
position: "absolute",
|
|
2928
|
+
zIndex: 1,
|
|
2929
|
+
fontFamily: bodySmall.fontFamily,
|
|
2930
|
+
fontSize: bodySmall.fontSize,
|
|
2931
|
+
lineHeight: bodySmall.lineHeight,
|
|
2932
|
+
fontWeight: bodySmall.fontWeight,
|
|
2933
|
+
letterSpacing: bodySmall.letterSpacing,
|
|
2934
|
+
color: colors.labelColor,
|
|
2935
|
+
transformOrigin: transformOrigin("top")
|
|
2936
|
+
},
|
|
2937
|
+
labelNotch: {
|
|
2938
|
+
paddingHorizontal: 4
|
|
2939
|
+
},
|
|
2940
|
+
input: {
|
|
2941
|
+
fontFamily: bodyLarge.fontFamily,
|
|
2942
|
+
fontSize: bodyLarge.fontSize,
|
|
2943
|
+
lineHeight: bodyLarge.lineHeight,
|
|
2944
|
+
fontWeight: bodyLarge.fontWeight,
|
|
2945
|
+
letterSpacing: bodyLarge.letterSpacing,
|
|
2946
|
+
color: colors.textColor,
|
|
2947
|
+
paddingVertical: 0,
|
|
2948
|
+
paddingHorizontal: 0,
|
|
2949
|
+
margin: 0,
|
|
2950
|
+
includeFontPadding: false
|
|
2951
|
+
},
|
|
2952
|
+
inputDisabled: {
|
|
2953
|
+
color: colors.disabledTextColor
|
|
2954
|
+
},
|
|
2955
|
+
leadingIcon: {
|
|
2956
|
+
alignSelf: "center",
|
|
2957
|
+
marginStart: -4,
|
|
2958
|
+
// 16dp container padding → 12dp icon inset per M3
|
|
2959
|
+
marginEnd: theme.spacing.md,
|
|
2960
|
+
width: ICON_SIZE,
|
|
2961
|
+
height: ICON_SIZE,
|
|
2962
|
+
alignItems: "center",
|
|
2963
|
+
justifyContent: "center"
|
|
2964
|
+
},
|
|
2965
|
+
trailingIcon: {
|
|
2966
|
+
alignSelf: "center",
|
|
2967
|
+
marginStart: theme.spacing.md,
|
|
2968
|
+
marginEnd: -4,
|
|
2969
|
+
// 16dp container padding → 12dp icon inset per M3
|
|
2970
|
+
width: ICON_SIZE,
|
|
2971
|
+
height: ICON_SIZE,
|
|
2972
|
+
alignItems: "center",
|
|
2973
|
+
justifyContent: "center"
|
|
2974
|
+
},
|
|
2975
|
+
trailingIconPressable: {
|
|
2976
|
+
alignSelf: "center"
|
|
2977
|
+
},
|
|
2978
|
+
supportingTextRow: {
|
|
2979
|
+
paddingHorizontal: theme.spacing.md,
|
|
2980
|
+
paddingTop: theme.spacing.xs
|
|
2981
|
+
},
|
|
2982
|
+
supportingText: {
|
|
2983
|
+
fontFamily: bodySmall.fontFamily,
|
|
2984
|
+
fontSize: bodySmall.fontSize,
|
|
2985
|
+
lineHeight: bodySmall.lineHeight,
|
|
2986
|
+
fontWeight: bodySmall.fontWeight,
|
|
2987
|
+
letterSpacing: bodySmall.letterSpacing,
|
|
2988
|
+
color: colors.supportingTextColor
|
|
2989
|
+
},
|
|
2990
|
+
errorSupportingText: {
|
|
2991
|
+
color: colors.errorSupportingTextColor
|
|
2992
|
+
}
|
|
2993
|
+
})
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2997
|
+
// src/text-field/TextField.tsx
|
|
2998
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2999
|
+
var ICON_SIZE2 = 24;
|
|
3000
|
+
var ICON_WITH_GAP = 12 + 24 + 16;
|
|
3001
|
+
function TextField({
|
|
3002
|
+
value,
|
|
3003
|
+
onChangeText,
|
|
3004
|
+
label,
|
|
3005
|
+
placeholder,
|
|
3006
|
+
variant = "filled",
|
|
3007
|
+
supportingText,
|
|
3008
|
+
errorText,
|
|
3009
|
+
error = false,
|
|
3010
|
+
disabled = false,
|
|
3011
|
+
leadingIcon,
|
|
3012
|
+
trailingIcon,
|
|
3013
|
+
onTrailingIconPress,
|
|
3014
|
+
multiline = false,
|
|
3015
|
+
onFocus,
|
|
3016
|
+
onBlur,
|
|
3017
|
+
style,
|
|
3018
|
+
containerColor,
|
|
3019
|
+
contentColor,
|
|
3020
|
+
inputStyle,
|
|
3021
|
+
...textInputProps
|
|
3022
|
+
}) {
|
|
3023
|
+
const theme = (0, import_core14.useTheme)();
|
|
3024
|
+
const isDisabled = Boolean(disabled);
|
|
3025
|
+
const isError = Boolean(error) || Boolean(errorText);
|
|
3026
|
+
const isFilled = variant === "filled";
|
|
3027
|
+
const hasLeadingIcon = Boolean(leadingIcon);
|
|
3028
|
+
const MaterialCommunityIcons = leadingIcon || trailingIcon ? getMaterialCommunityIcons() : null;
|
|
3029
|
+
const { colors, styles: styles3 } = (0, import_react15.useMemo)(
|
|
3030
|
+
() => createStyles9(theme, variant),
|
|
3031
|
+
[theme, variant]
|
|
3032
|
+
);
|
|
3033
|
+
const [isFocused, setIsFocused] = (0, import_react15.useState)(false);
|
|
3034
|
+
const [internalHasText, setInternalHasText] = (0, import_react15.useState)(
|
|
3035
|
+
() => value !== void 0 && value !== ""
|
|
3036
|
+
);
|
|
3037
|
+
const inputRef = (0, import_react15.useRef)(null);
|
|
3038
|
+
const isControlled = value !== void 0;
|
|
3039
|
+
const hasValue = isControlled ? value !== "" : internalHasText;
|
|
3040
|
+
const isLabelFloated = isFocused || hasValue;
|
|
3041
|
+
const labelAnimRef = (0, import_react15.useRef)(new import_react_native26.Animated.Value(isLabelFloated ? 1 : 0));
|
|
3042
|
+
const labelAnim = labelAnimRef.current;
|
|
3043
|
+
(0, import_react15.useEffect)(() => {
|
|
3044
|
+
import_react_native26.Animated.timing(labelAnim, {
|
|
3045
|
+
toValue: isLabelFloated ? 1 : 0,
|
|
3046
|
+
duration: 150,
|
|
3047
|
+
useNativeDriver: import_react_native26.Platform.OS !== "web"
|
|
3048
|
+
}).start();
|
|
3049
|
+
}, [isLabelFloated, labelAnim]);
|
|
3050
|
+
const labelScale = (0, import_react15.useMemo)(() => {
|
|
3051
|
+
const restingScale = theme.typography.bodyLarge.fontSize / theme.typography.bodySmall.fontSize;
|
|
3052
|
+
return labelAnim.interpolate({
|
|
3053
|
+
inputRange: [0, 1],
|
|
3054
|
+
outputRange: [restingScale, 1]
|
|
3055
|
+
});
|
|
3056
|
+
}, [
|
|
3057
|
+
labelAnim,
|
|
3058
|
+
theme.typography.bodyLarge.fontSize,
|
|
3059
|
+
theme.typography.bodySmall.fontSize
|
|
3060
|
+
]);
|
|
3061
|
+
const labelTranslateY = (0, import_react15.useMemo)(() => {
|
|
3062
|
+
const restingTop = isFilled ? labelPositions.filledRestingTop : labelPositions.outlinedRestingTop;
|
|
3063
|
+
const floatedTop = isFilled ? labelPositions.filledFloatedTop : labelPositions.outlinedFloatedTop;
|
|
3064
|
+
const restingOffset = restingTop - floatedTop;
|
|
3065
|
+
return labelAnim.interpolate({
|
|
3066
|
+
inputRange: [0, 1],
|
|
3067
|
+
outputRange: [restingOffset, 0]
|
|
3068
|
+
});
|
|
3069
|
+
}, [isFilled, labelAnim]);
|
|
3070
|
+
const labelStart = theme.spacing.md + (hasLeadingIcon ? ICON_WITH_GAP - theme.spacing.md : 0);
|
|
3071
|
+
const labelStaticTop = isFilled ? labelPositions.filledFloatedTop : labelPositions.outlinedFloatedTop;
|
|
3072
|
+
const handleChangeText = (0, import_react15.useCallback)(
|
|
3073
|
+
(text) => {
|
|
3074
|
+
if (!isControlled) {
|
|
3075
|
+
setInternalHasText(text !== "");
|
|
3076
|
+
}
|
|
3077
|
+
onChangeText == null ? void 0 : onChangeText(text);
|
|
3078
|
+
},
|
|
3079
|
+
[isControlled, onChangeText]
|
|
3080
|
+
);
|
|
3081
|
+
const handleFocus = (0, import_react15.useCallback)(
|
|
3082
|
+
(event) => {
|
|
3083
|
+
if (isDisabled) return;
|
|
3084
|
+
setIsFocused(true);
|
|
3085
|
+
onFocus == null ? void 0 : onFocus(event);
|
|
3086
|
+
},
|
|
3087
|
+
[isDisabled, onFocus]
|
|
3088
|
+
);
|
|
3089
|
+
const handleBlur = (0, import_react15.useCallback)(
|
|
3090
|
+
(event) => {
|
|
3091
|
+
setIsFocused(false);
|
|
3092
|
+
onBlur == null ? void 0 : onBlur(event);
|
|
3093
|
+
},
|
|
3094
|
+
[onBlur]
|
|
3095
|
+
);
|
|
3096
|
+
const handleContainerPress = (0, import_react15.useCallback)(() => {
|
|
3097
|
+
var _a;
|
|
3098
|
+
if (!isDisabled) {
|
|
3099
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
3100
|
+
}
|
|
3101
|
+
}, [isDisabled]);
|
|
3102
|
+
const labelColor = isDisabled ? colors.disabledLabelColor : isError ? colors.errorLabelColor : isFocused ? colors.focusedLabelColor : colors.labelColor;
|
|
3103
|
+
const labelBackgroundColor = variant === "outlined" && isLabelFloated ? theme.colors.surface : "transparent";
|
|
3104
|
+
const iconColor = isDisabled ? colors.disabledIconColor : isError ? colors.errorIconColor : contentColor != null ? contentColor : colors.iconColor;
|
|
3105
|
+
const containerStyle = (0, import_react15.useMemo)(
|
|
3106
|
+
() => [
|
|
3107
|
+
styles3.container,
|
|
3108
|
+
containerColor && !isDisabled ? { backgroundColor: containerColor } : void 0,
|
|
3109
|
+
isFocused && styles3.containerFocused,
|
|
3110
|
+
isError && !isFocused && styles3.containerError,
|
|
3111
|
+
isDisabled && styles3.containerDisabled
|
|
3112
|
+
],
|
|
3113
|
+
[styles3, isFocused, isError, isDisabled, containerColor]
|
|
3114
|
+
);
|
|
3115
|
+
const indicatorStyle = (0, import_react15.useMemo)(
|
|
3116
|
+
() => [
|
|
3117
|
+
styles3.indicator,
|
|
3118
|
+
isFocused && styles3.indicatorFocused,
|
|
3119
|
+
isError && !isFocused && styles3.indicatorError,
|
|
3120
|
+
isDisabled && styles3.indicatorDisabled
|
|
3121
|
+
],
|
|
3122
|
+
[styles3, isFocused, isError, isDisabled]
|
|
3123
|
+
);
|
|
3124
|
+
const displaySupportingText = isError ? errorText : supportingText;
|
|
3125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native26.View, { style: [styles3.root, style], children: [
|
|
3126
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native26.Pressable, { onPress: handleContainerPress, disabled: isDisabled, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native26.View, { style: containerStyle, children: [
|
|
3127
|
+
leadingIcon ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native26.View, { style: styles3.leadingIcon, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3128
|
+
MaterialCommunityIcons,
|
|
3129
|
+
{
|
|
3130
|
+
name: leadingIcon,
|
|
3131
|
+
size: ICON_SIZE2,
|
|
3132
|
+
color: iconColor
|
|
3133
|
+
}
|
|
3134
|
+
) }) : null,
|
|
3135
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3136
|
+
import_react_native26.View,
|
|
3137
|
+
{
|
|
3138
|
+
style: [
|
|
3139
|
+
styles3.inputWrapper,
|
|
3140
|
+
label ? styles3.inputWrapperWithLabel : void 0
|
|
3141
|
+
],
|
|
3142
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3143
|
+
import_react_native26.TextInput,
|
|
3144
|
+
{
|
|
3145
|
+
ref: inputRef,
|
|
3146
|
+
...textInputProps,
|
|
3147
|
+
value,
|
|
3148
|
+
onChangeText: handleChangeText,
|
|
3149
|
+
editable: !isDisabled,
|
|
3150
|
+
onFocus: handleFocus,
|
|
3151
|
+
onBlur: handleBlur,
|
|
3152
|
+
placeholder: isLabelFloated || !label ? placeholder : void 0,
|
|
3153
|
+
placeholderTextColor: colors.placeholderColor,
|
|
3154
|
+
multiline,
|
|
3155
|
+
style: [
|
|
3156
|
+
styles3.input,
|
|
3157
|
+
isDisabled ? styles3.inputDisabled : void 0,
|
|
3158
|
+
contentColor && !isDisabled ? { color: contentColor } : void 0,
|
|
3159
|
+
inputStyle
|
|
3160
|
+
],
|
|
3161
|
+
accessibilityLabel: label || void 0,
|
|
3162
|
+
accessibilityState: { disabled: isDisabled },
|
|
3163
|
+
accessibilityHint: isError && errorText ? errorText : void 0
|
|
3164
|
+
}
|
|
3165
|
+
)
|
|
3166
|
+
}
|
|
3167
|
+
),
|
|
3168
|
+
trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3169
|
+
import_react_native26.Pressable,
|
|
3170
|
+
{
|
|
3171
|
+
onPress: onTrailingIconPress,
|
|
3172
|
+
disabled: isDisabled || !onTrailingIconPress,
|
|
3173
|
+
accessibilityRole: "button",
|
|
3174
|
+
hitSlop: 12,
|
|
3175
|
+
style: styles3.trailingIconPressable,
|
|
3176
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native26.View, { style: styles3.trailingIcon, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3177
|
+
MaterialCommunityIcons,
|
|
3178
|
+
{
|
|
3179
|
+
name: trailingIcon,
|
|
3180
|
+
size: ICON_SIZE2,
|
|
3181
|
+
color: iconColor
|
|
3182
|
+
}
|
|
3183
|
+
) })
|
|
3184
|
+
}
|
|
3185
|
+
) : null,
|
|
3186
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3187
|
+
import_react_native26.Animated.Text,
|
|
3188
|
+
{
|
|
3189
|
+
numberOfLines: 1,
|
|
3190
|
+
style: [
|
|
3191
|
+
styles3.label,
|
|
3192
|
+
{
|
|
3193
|
+
top: labelStaticTop,
|
|
3194
|
+
start: labelStart,
|
|
3195
|
+
color: labelColor,
|
|
3196
|
+
backgroundColor: labelBackgroundColor,
|
|
3197
|
+
transform: [
|
|
3198
|
+
{ translateY: labelTranslateY },
|
|
3199
|
+
{ scale: labelScale }
|
|
3200
|
+
]
|
|
3201
|
+
},
|
|
3202
|
+
variant === "outlined" && isLabelFloated ? styles3.labelNotch : void 0
|
|
3203
|
+
],
|
|
3204
|
+
children: label
|
|
3205
|
+
}
|
|
3206
|
+
) : null,
|
|
3207
|
+
isFilled ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native26.View, { style: indicatorStyle }) : null
|
|
3208
|
+
] }) }),
|
|
3209
|
+
displaySupportingText ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native26.View, { style: styles3.supportingTextRow, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3210
|
+
import_react_native26.Text,
|
|
3211
|
+
{
|
|
3212
|
+
style: [
|
|
3213
|
+
styles3.supportingText,
|
|
3214
|
+
isError ? styles3.errorSupportingText : void 0
|
|
3215
|
+
],
|
|
3216
|
+
children: displaySupportingText
|
|
3217
|
+
}
|
|
3218
|
+
) }) : null
|
|
3219
|
+
] });
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
// src/list/List.tsx
|
|
3223
|
+
var import_react16 = require("react");
|
|
3224
|
+
var import_react_native28 = require("react-native");
|
|
3225
|
+
var import_core15 = require("@onlynative/core");
|
|
3226
|
+
|
|
3227
|
+
// src/list/styles.ts
|
|
3228
|
+
var import_react_native27 = require("react-native");
|
|
3229
|
+
var ITEM_PADDING_VERTICAL = 12;
|
|
3230
|
+
var INSET_START = 56;
|
|
3231
|
+
var MIN_HEIGHT = {
|
|
3232
|
+
1: 56,
|
|
3233
|
+
2: 72,
|
|
3234
|
+
3: 88
|
|
3235
|
+
};
|
|
3236
|
+
function createListStyles(theme) {
|
|
3237
|
+
return import_react_native27.StyleSheet.create({
|
|
3238
|
+
container: {
|
|
3239
|
+
paddingVertical: theme.spacing.sm
|
|
3240
|
+
}
|
|
3241
|
+
});
|
|
3242
|
+
}
|
|
3243
|
+
function getItemColors(theme, containerColor) {
|
|
3244
|
+
const base = containerColor != null ? containerColor : "transparent";
|
|
3245
|
+
if (containerColor) {
|
|
3246
|
+
return {
|
|
3247
|
+
backgroundColor: containerColor,
|
|
3248
|
+
hoveredBackgroundColor: blendColor(
|
|
3249
|
+
containerColor,
|
|
3250
|
+
theme.colors.onSurface,
|
|
3251
|
+
theme.stateLayer.hoveredOpacity
|
|
3252
|
+
),
|
|
3253
|
+
pressedBackgroundColor: blendColor(
|
|
3254
|
+
containerColor,
|
|
3255
|
+
theme.colors.onSurface,
|
|
3256
|
+
theme.stateLayer.pressedOpacity
|
|
3257
|
+
)
|
|
3258
|
+
};
|
|
3259
|
+
}
|
|
3260
|
+
return {
|
|
3261
|
+
backgroundColor: base,
|
|
3262
|
+
hoveredBackgroundColor: alphaColor(
|
|
3263
|
+
theme.colors.onSurface,
|
|
3264
|
+
theme.stateLayer.hoveredOpacity
|
|
3265
|
+
),
|
|
3266
|
+
pressedBackgroundColor: alphaColor(
|
|
3267
|
+
theme.colors.onSurface,
|
|
3268
|
+
theme.stateLayer.pressedOpacity
|
|
3269
|
+
)
|
|
3270
|
+
};
|
|
3271
|
+
}
|
|
3272
|
+
function createListItemStyles(theme, lines, containerColor) {
|
|
3273
|
+
const colors = getItemColors(theme, containerColor);
|
|
3274
|
+
return import_react_native27.StyleSheet.create({
|
|
3275
|
+
container: {
|
|
3276
|
+
flexDirection: "row",
|
|
3277
|
+
alignItems: lines === 3 ? "flex-start" : "center",
|
|
3278
|
+
minHeight: MIN_HEIGHT[lines],
|
|
3279
|
+
paddingHorizontal: theme.spacing.md,
|
|
3280
|
+
paddingVertical: ITEM_PADDING_VERTICAL,
|
|
3281
|
+
backgroundColor: colors.backgroundColor
|
|
3282
|
+
},
|
|
3283
|
+
interactiveContainer: {
|
|
3284
|
+
cursor: "pointer"
|
|
3285
|
+
},
|
|
3286
|
+
hoveredContainer: {
|
|
3287
|
+
backgroundColor: colors.hoveredBackgroundColor
|
|
3288
|
+
},
|
|
3289
|
+
pressedContainer: {
|
|
3290
|
+
backgroundColor: colors.pressedBackgroundColor
|
|
3291
|
+
},
|
|
3292
|
+
disabledContainer: {
|
|
3293
|
+
cursor: "auto"
|
|
3294
|
+
},
|
|
3295
|
+
disabledContentWrapper: {
|
|
3296
|
+
flexDirection: "row",
|
|
3297
|
+
flex: 1,
|
|
3298
|
+
opacity: theme.stateLayer.disabledOpacity
|
|
3299
|
+
},
|
|
3300
|
+
leadingContent: {
|
|
3301
|
+
marginEnd: theme.spacing.md
|
|
3302
|
+
},
|
|
3303
|
+
textBlock: {
|
|
3304
|
+
flex: 1
|
|
3305
|
+
},
|
|
3306
|
+
overlineText: {
|
|
3307
|
+
...theme.typography.labelSmall,
|
|
3308
|
+
color: theme.colors.onSurfaceVariant
|
|
3309
|
+
},
|
|
3310
|
+
headlineText: {
|
|
3311
|
+
...theme.typography.bodyLarge,
|
|
3312
|
+
color: theme.colors.onSurface
|
|
3313
|
+
},
|
|
3314
|
+
supportingText: {
|
|
3315
|
+
...theme.typography.bodyMedium,
|
|
3316
|
+
color: theme.colors.onSurfaceVariant
|
|
3317
|
+
},
|
|
3318
|
+
trailingBlock: {
|
|
3319
|
+
marginStart: theme.spacing.md,
|
|
3320
|
+
alignItems: "flex-end"
|
|
3321
|
+
},
|
|
3322
|
+
trailingSupportingText: {
|
|
3323
|
+
...theme.typography.labelSmall,
|
|
3324
|
+
color: theme.colors.onSurfaceVariant
|
|
3325
|
+
}
|
|
3326
|
+
});
|
|
3327
|
+
}
|
|
3328
|
+
function createDividerStyles(theme, inset) {
|
|
3329
|
+
return import_react_native27.StyleSheet.create({
|
|
3330
|
+
divider: {
|
|
3331
|
+
height: 1,
|
|
3332
|
+
backgroundColor: theme.colors.outlineVariant,
|
|
3333
|
+
...inset ? { marginStart: INSET_START } : void 0
|
|
3334
|
+
}
|
|
3335
|
+
});
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3338
|
+
// src/list/List.tsx
|
|
3339
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3340
|
+
function List({ children, style, ...props }) {
|
|
3341
|
+
const theme = (0, import_core15.useTheme)();
|
|
3342
|
+
const styles3 = (0, import_react16.useMemo)(() => createListStyles(theme), [theme]);
|
|
3343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native28.View, { ...props, style: [styles3.container, style], children });
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3346
|
+
// src/list/ListItem.tsx
|
|
3347
|
+
var import_react17 = require("react");
|
|
3348
|
+
var import_react_native29 = require("react-native");
|
|
3349
|
+
var import_core16 = require("@onlynative/core");
|
|
3350
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3351
|
+
function getLines(supportingText, overlineText, supportingTextNumberOfLines) {
|
|
3352
|
+
if (supportingText && overlineText || supportingText && supportingTextNumberOfLines && supportingTextNumberOfLines > 1) {
|
|
3353
|
+
return 3;
|
|
3354
|
+
}
|
|
3355
|
+
if (supportingText || overlineText) return 2;
|
|
3356
|
+
return 1;
|
|
3357
|
+
}
|
|
3358
|
+
function ListItem({
|
|
3359
|
+
headlineText,
|
|
3360
|
+
supportingText,
|
|
3361
|
+
overlineText,
|
|
3362
|
+
trailingSupportingText,
|
|
3363
|
+
leadingContent,
|
|
3364
|
+
trailingContent,
|
|
3365
|
+
onPress,
|
|
3366
|
+
disabled = false,
|
|
3367
|
+
containerColor,
|
|
3368
|
+
supportingTextNumberOfLines = 1,
|
|
3369
|
+
style,
|
|
3370
|
+
...props
|
|
3371
|
+
}) {
|
|
3372
|
+
const isDisabled = Boolean(disabled);
|
|
3373
|
+
const isInteractive = onPress !== void 0;
|
|
3374
|
+
const theme = (0, import_core16.useTheme)();
|
|
3375
|
+
const lines = getLines(supportingText, overlineText, supportingTextNumberOfLines);
|
|
3376
|
+
const styles3 = (0, import_react17.useMemo)(
|
|
3377
|
+
() => createListItemStyles(theme, lines, containerColor),
|
|
3378
|
+
[theme, lines, containerColor]
|
|
3379
|
+
);
|
|
3380
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
3381
|
+
leadingContent != null && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native29.View, { style: styles3.leadingContent, children: leadingContent }),
|
|
3382
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native29.View, { style: styles3.textBlock, children: [
|
|
3383
|
+
overlineText != null && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native29.Text, { style: styles3.overlineText, numberOfLines: 1, children: overlineText }),
|
|
3384
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native29.Text, { style: styles3.headlineText, numberOfLines: 1, children: headlineText }),
|
|
3385
|
+
supportingText != null && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3386
|
+
import_react_native29.Text,
|
|
3387
|
+
{
|
|
3388
|
+
style: styles3.supportingText,
|
|
3389
|
+
numberOfLines: supportingTextNumberOfLines,
|
|
3390
|
+
children: supportingText
|
|
3391
|
+
}
|
|
3392
|
+
)
|
|
3393
|
+
] }),
|
|
3394
|
+
(trailingContent != null || trailingSupportingText != null) && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native29.View, { style: styles3.trailingBlock, children: [
|
|
3395
|
+
trailingSupportingText != null && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native29.Text, { style: styles3.trailingSupportingText, numberOfLines: 1, children: trailingSupportingText }),
|
|
3396
|
+
trailingContent
|
|
3397
|
+
] })
|
|
3398
|
+
] });
|
|
3399
|
+
if (!isInteractive) {
|
|
3400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native29.View, { ...props, style: [styles3.container, style], children: content });
|
|
3401
|
+
}
|
|
3402
|
+
const resolvedStyle = (state) => [
|
|
3403
|
+
styles3.container,
|
|
3404
|
+
styles3.interactiveContainer,
|
|
3405
|
+
state.hovered && !state.pressed && !isDisabled ? styles3.hoveredContainer : void 0,
|
|
3406
|
+
state.pressed && !isDisabled ? styles3.pressedContainer : void 0,
|
|
3407
|
+
isDisabled ? styles3.disabledContainer : void 0,
|
|
3408
|
+
typeof style === "function" ? style(state) : style
|
|
3409
|
+
];
|
|
3410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3411
|
+
import_react_native29.Pressable,
|
|
3412
|
+
{
|
|
3413
|
+
...props,
|
|
3414
|
+
role: "button",
|
|
3415
|
+
accessibilityState: { disabled: isDisabled },
|
|
3416
|
+
hitSlop: import_react_native29.Platform.OS === "web" ? void 0 : 4,
|
|
3417
|
+
disabled: isDisabled,
|
|
3418
|
+
onPress,
|
|
3419
|
+
style: resolvedStyle,
|
|
3420
|
+
children: isDisabled ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native29.View, { style: styles3.disabledContentWrapper, children: content }) : content
|
|
3421
|
+
}
|
|
3422
|
+
);
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
// src/list/ListDivider.tsx
|
|
3426
|
+
var import_react18 = require("react");
|
|
3427
|
+
var import_react_native30 = require("react-native");
|
|
3428
|
+
var import_core17 = require("@onlynative/core");
|
|
3429
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3430
|
+
function ListDivider({
|
|
3431
|
+
inset = false,
|
|
3432
|
+
style,
|
|
3433
|
+
...props
|
|
3434
|
+
}) {
|
|
3435
|
+
const theme = (0, import_core17.useTheme)();
|
|
3436
|
+
const styles3 = (0, import_react18.useMemo)(
|
|
3437
|
+
() => createDividerStyles(theme, inset),
|
|
3438
|
+
[theme, inset]
|
|
3439
|
+
);
|
|
3440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native30.View, { ...props, style: [styles3.divider, style] });
|
|
3441
|
+
}
|
|
3442
|
+
|
|
3443
|
+
// src/keyboard-avoiding-wrapper/KeyboardAvoidingWrapper.tsx
|
|
3444
|
+
var import_react19 = require("react");
|
|
3445
|
+
var import_react_native32 = require("react-native");
|
|
3446
|
+
|
|
3447
|
+
// src/keyboard-avoiding-wrapper/styles.ts
|
|
3448
|
+
var import_react_native31 = require("react-native");
|
|
3449
|
+
var styles2 = import_react_native31.StyleSheet.create({
|
|
3450
|
+
root: {
|
|
3451
|
+
flex: 1
|
|
3452
|
+
},
|
|
3453
|
+
container: {
|
|
3454
|
+
flexGrow: 1
|
|
3455
|
+
}
|
|
3456
|
+
});
|
|
3457
|
+
|
|
3458
|
+
// src/keyboard-avoiding-wrapper/KeyboardAvoidingWrapper.tsx
|
|
3459
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3460
|
+
var isIOS = import_react_native32.Platform.OS === "ios";
|
|
3461
|
+
function KeyboardAvoidingWrapper({
|
|
3462
|
+
children,
|
|
3463
|
+
behavior = "padding",
|
|
3464
|
+
keyboardVerticalOffset = 0,
|
|
3465
|
+
enabled = true,
|
|
3466
|
+
scrollViewProps,
|
|
3467
|
+
onKeyboardShow,
|
|
3468
|
+
onKeyboardHide,
|
|
3469
|
+
style,
|
|
3470
|
+
contentContainerStyle
|
|
3471
|
+
}) {
|
|
3472
|
+
(0, import_react19.useEffect)(() => {
|
|
3473
|
+
const subscriptions = [];
|
|
3474
|
+
if (onKeyboardShow) {
|
|
3475
|
+
const showEvent = isIOS ? "keyboardWillShow" : "keyboardDidShow";
|
|
3476
|
+
subscriptions.push(
|
|
3477
|
+
import_react_native32.Keyboard.addListener(showEvent, onKeyboardShow)
|
|
3478
|
+
);
|
|
3479
|
+
}
|
|
3480
|
+
if (onKeyboardHide) {
|
|
3481
|
+
const hideEvent = isIOS ? "keyboardWillHide" : "keyboardDidHide";
|
|
3482
|
+
subscriptions.push(
|
|
3483
|
+
import_react_native32.Keyboard.addListener(hideEvent, onKeyboardHide)
|
|
3484
|
+
);
|
|
3485
|
+
}
|
|
3486
|
+
return () => {
|
|
3487
|
+
subscriptions.forEach((sub) => sub.remove());
|
|
3488
|
+
};
|
|
3489
|
+
}, [onKeyboardShow, onKeyboardHide]);
|
|
3490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3491
|
+
import_react_native32.KeyboardAvoidingView,
|
|
3492
|
+
{
|
|
3493
|
+
style: [styles2.root, style],
|
|
3494
|
+
behavior,
|
|
3495
|
+
keyboardVerticalOffset,
|
|
3496
|
+
enabled: !isIOS && enabled,
|
|
3497
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3498
|
+
import_react_native32.ScrollView,
|
|
3499
|
+
{
|
|
3500
|
+
automaticallyAdjustKeyboardInsets: isIOS && enabled,
|
|
3501
|
+
keyboardShouldPersistTaps: "handled",
|
|
3502
|
+
showsVerticalScrollIndicator: false,
|
|
3503
|
+
...scrollViewProps,
|
|
3504
|
+
contentContainerStyle: [styles2.container, contentContainerStyle],
|
|
3505
|
+
children
|
|
3506
|
+
}
|
|
3507
|
+
)
|
|
3508
|
+
}
|
|
3509
|
+
);
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3512
|
+
// src/avatar/Avatar.tsx
|
|
3513
|
+
var import_react20 = require("react");
|
|
3514
|
+
var import_react_native34 = require("react-native");
|
|
3515
|
+
var import_core18 = require("@onlynative/core");
|
|
3516
|
+
|
|
3517
|
+
// src/avatar/styles.ts
|
|
3518
|
+
var import_react_native33 = require("react-native");
|
|
3519
|
+
function createStyles10(theme) {
|
|
3520
|
+
return import_react_native33.StyleSheet.create({
|
|
3521
|
+
container: {
|
|
3522
|
+
borderRadius: theme.shape.cornerFull,
|
|
3523
|
+
alignItems: "center",
|
|
3524
|
+
justifyContent: "center",
|
|
3525
|
+
overflow: "hidden"
|
|
3526
|
+
},
|
|
3527
|
+
interactive: {
|
|
3528
|
+
cursor: "pointer"
|
|
3529
|
+
},
|
|
3530
|
+
sizeXSmall: { width: 24, height: 24 },
|
|
3531
|
+
sizeSmall: { width: 32, height: 32 },
|
|
3532
|
+
sizeMedium: { width: 40, height: 40 },
|
|
3533
|
+
sizeLarge: { width: 56, height: 56 },
|
|
3534
|
+
sizeXLarge: { width: 112, height: 112 },
|
|
3535
|
+
image: {
|
|
3536
|
+
width: "100%",
|
|
3537
|
+
height: "100%"
|
|
3538
|
+
}
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
// src/avatar/Avatar.tsx
|
|
3543
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3544
|
+
var ICON_PX = {
|
|
3545
|
+
xSmall: 14,
|
|
3546
|
+
small: 18,
|
|
3547
|
+
medium: 24,
|
|
3548
|
+
large: 32,
|
|
3549
|
+
xLarge: 56
|
|
3550
|
+
};
|
|
3551
|
+
var LABEL_FONT_SIZE = {
|
|
3552
|
+
xSmall: 10,
|
|
3553
|
+
small: 12,
|
|
3554
|
+
medium: 14,
|
|
3555
|
+
large: 22,
|
|
3556
|
+
xLarge: 36
|
|
3557
|
+
};
|
|
3558
|
+
function getSizeStyle3(styles3, size) {
|
|
3559
|
+
if (size === "xSmall") return styles3.sizeXSmall;
|
|
3560
|
+
if (size === "small") return styles3.sizeSmall;
|
|
3561
|
+
if (size === "large") return styles3.sizeLarge;
|
|
3562
|
+
if (size === "xLarge") return styles3.sizeXLarge;
|
|
3563
|
+
return styles3.sizeMedium;
|
|
3564
|
+
}
|
|
3565
|
+
function Avatar({
|
|
3566
|
+
imageUri,
|
|
3567
|
+
icon,
|
|
3568
|
+
label,
|
|
3569
|
+
size = "medium",
|
|
3570
|
+
containerColor,
|
|
3571
|
+
contentColor,
|
|
3572
|
+
style,
|
|
3573
|
+
onPress,
|
|
3574
|
+
accessibilityLabel,
|
|
3575
|
+
...props
|
|
3576
|
+
}) {
|
|
3577
|
+
const MaterialCommunityIcons = getMaterialCommunityIcons();
|
|
3578
|
+
const theme = (0, import_core18.useTheme)();
|
|
3579
|
+
const styles3 = (0, import_react20.useMemo)(() => createStyles10(theme), [theme]);
|
|
3580
|
+
const bgColor = containerColor != null ? containerColor : theme.colors.primaryContainer;
|
|
3581
|
+
const fgColor = contentColor != null ? contentColor : theme.colors.onPrimaryContainer;
|
|
3582
|
+
const isInteractive = onPress !== void 0;
|
|
3583
|
+
const sizeStyle = getSizeStyle3(styles3, size);
|
|
3584
|
+
const iconPx = ICON_PX[size];
|
|
3585
|
+
const labelFontSize = LABEL_FONT_SIZE[size];
|
|
3586
|
+
const initials = label ? label.slice(0, 2).toUpperCase() : void 0;
|
|
3587
|
+
const initialsStyle = (0, import_react20.useMemo)(
|
|
3588
|
+
() => ({
|
|
3589
|
+
color: fgColor,
|
|
3590
|
+
fontSize: labelFontSize,
|
|
3591
|
+
fontWeight: "500"
|
|
3592
|
+
}),
|
|
3593
|
+
[fgColor, labelFontSize]
|
|
3594
|
+
);
|
|
3595
|
+
const containerOverrides = (0, import_react20.useMemo)(
|
|
3596
|
+
() => ({
|
|
3597
|
+
base: { backgroundColor: bgColor },
|
|
3598
|
+
hovered: {
|
|
3599
|
+
backgroundColor: blendColor(
|
|
3600
|
+
bgColor,
|
|
3601
|
+
fgColor,
|
|
3602
|
+
theme.stateLayer.hoveredOpacity
|
|
3603
|
+
)
|
|
3604
|
+
},
|
|
3605
|
+
pressed: {
|
|
3606
|
+
backgroundColor: blendColor(
|
|
3607
|
+
bgColor,
|
|
3608
|
+
fgColor,
|
|
3609
|
+
theme.stateLayer.pressedOpacity
|
|
3610
|
+
)
|
|
3611
|
+
}
|
|
3612
|
+
}),
|
|
3613
|
+
[bgColor, fgColor, theme.stateLayer]
|
|
3614
|
+
);
|
|
3615
|
+
const content = imageUri ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react_native34.Image, { source: { uri: imageUri }, style: styles3.image, accessible: false }) : label && !icon ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react_native34.Text, { style: initialsStyle, numberOfLines: 1, allowFontScaling: false, children: initials }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3616
|
+
MaterialCommunityIcons,
|
|
3617
|
+
{
|
|
3618
|
+
name: icon != null ? icon : "account",
|
|
3619
|
+
size: iconPx,
|
|
3620
|
+
color: fgColor
|
|
3621
|
+
}
|
|
3622
|
+
);
|
|
3623
|
+
if (!isInteractive) {
|
|
3624
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3625
|
+
import_react_native34.View,
|
|
3626
|
+
{
|
|
3627
|
+
...props,
|
|
3628
|
+
accessibilityLabel,
|
|
3629
|
+
style: [styles3.container, sizeStyle, containerOverrides.base, style],
|
|
3630
|
+
children: content
|
|
3631
|
+
}
|
|
3632
|
+
);
|
|
3633
|
+
}
|
|
3634
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3635
|
+
import_react_native34.Pressable,
|
|
3636
|
+
{
|
|
3637
|
+
...props,
|
|
3638
|
+
accessibilityRole: "button",
|
|
3639
|
+
accessibilityLabel,
|
|
3640
|
+
onPress,
|
|
3641
|
+
style: ({
|
|
3642
|
+
pressed,
|
|
3643
|
+
hovered
|
|
3644
|
+
}) => {
|
|
3645
|
+
return [
|
|
3646
|
+
styles3.container,
|
|
3647
|
+
sizeStyle,
|
|
3648
|
+
containerOverrides.base,
|
|
3649
|
+
styles3.interactive,
|
|
3650
|
+
hovered && !pressed ? containerOverrides.hovered : void 0,
|
|
3651
|
+
pressed ? containerOverrides.pressed : void 0,
|
|
3652
|
+
style
|
|
3653
|
+
];
|
|
3654
|
+
},
|
|
3655
|
+
children: content
|
|
3656
|
+
}
|
|
3657
|
+
);
|
|
3658
|
+
}
|
|
3659
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3660
|
+
0 && (module.exports = {
|
|
3661
|
+
AppBar,
|
|
3662
|
+
Avatar,
|
|
3663
|
+
Box,
|
|
3664
|
+
Button,
|
|
3665
|
+
Card,
|
|
3666
|
+
Checkbox,
|
|
3667
|
+
Chip,
|
|
3668
|
+
Column,
|
|
3669
|
+
Grid,
|
|
3670
|
+
IconButton,
|
|
3671
|
+
KeyboardAvoidingWrapper,
|
|
3672
|
+
Layout,
|
|
3673
|
+
List,
|
|
3674
|
+
ListDivider,
|
|
3675
|
+
ListItem,
|
|
3676
|
+
Radio,
|
|
3677
|
+
Row,
|
|
3678
|
+
Switch,
|
|
3679
|
+
TextField,
|
|
3680
|
+
Typography
|
|
3681
|
+
});
|