@onlynative/components 0.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -0
- package/dist/appbar/index.d.ts +90 -0
- package/dist/appbar/index.js +1030 -0
- package/dist/avatar/index.d.ts +46 -0
- package/dist/avatar/index.js +250 -0
- package/dist/button/index.d.ts +41 -0
- package/dist/button/index.js +468 -0
- package/dist/card/index.d.ts +31 -0
- package/dist/card/index.js +263 -0
- package/dist/checkbox/index.d.ts +25 -0
- package/dist/checkbox/index.js +308 -0
- package/dist/chip/index.d.ts +62 -0
- package/dist/chip/index.js +467 -0
- package/dist/icon-button/index.d.ts +10 -0
- package/dist/icon-button/index.js +592 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +3681 -0
- package/dist/keyboard-avoiding-wrapper/index.d.ts +36 -0
- package/dist/keyboard-avoiding-wrapper/index.js +98 -0
- package/dist/layout/index.d.ts +98 -0
- package/dist/layout/index.js +282 -0
- package/dist/list/index.d.ts +60 -0
- package/dist/list/index.js +302 -0
- package/dist/radio/index.d.ts +25 -0
- package/dist/radio/index.js +252 -0
- package/dist/switch/index.d.ts +37 -0
- package/dist/switch/index.js +332 -0
- package/dist/text-field/index.d.ts +52 -0
- package/dist/text-field/index.js +510 -0
- package/dist/types-D3hlyvz-.d.ts +51 -0
- package/dist/typography/index.d.ts +28 -0
- package/dist/typography/index.js +78 -0
- package/llms.txt +458 -0
- package/package.json +202 -0
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/icon-button/index.ts
|
|
21
|
+
var icon_button_exports = {};
|
|
22
|
+
__export(icon_button_exports, {
|
|
23
|
+
IconButton: () => IconButton
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(icon_button_exports);
|
|
26
|
+
|
|
27
|
+
// src/icon-button/IconButton.tsx
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_react_native4 = require("react-native");
|
|
30
|
+
var import_core = require("@onlynative/core");
|
|
31
|
+
|
|
32
|
+
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
33
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
34
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
35
|
+
}) : x)(function(x) {
|
|
36
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
37
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// ../utils/dist/index.mjs
|
|
41
|
+
var import_react_native = require("react-native");
|
|
42
|
+
var import_react_native2 = require("react-native");
|
|
43
|
+
function parseHexColor(color) {
|
|
44
|
+
const normalized = color.replace("#", "");
|
|
45
|
+
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const r = Number.parseInt(normalized.slice(0, 2), 16);
|
|
49
|
+
const g = Number.parseInt(normalized.slice(2, 4), 16);
|
|
50
|
+
const b = Number.parseInt(normalized.slice(4, 6), 16);
|
|
51
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return { r, g, b };
|
|
55
|
+
}
|
|
56
|
+
function clampAlpha(alpha) {
|
|
57
|
+
return Math.max(0, Math.min(1, alpha));
|
|
58
|
+
}
|
|
59
|
+
function alphaColor(color, alpha) {
|
|
60
|
+
const channels = parseHexColor(color);
|
|
61
|
+
const boundedAlpha = clampAlpha(alpha);
|
|
62
|
+
if (!channels) {
|
|
63
|
+
return color;
|
|
64
|
+
}
|
|
65
|
+
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
66
|
+
}
|
|
67
|
+
function blendColor(base, overlay, overlayAlpha) {
|
|
68
|
+
const baseChannels = parseHexColor(base);
|
|
69
|
+
const overlayChannels = parseHexColor(overlay);
|
|
70
|
+
const boundedAlpha = clampAlpha(overlayAlpha);
|
|
71
|
+
if (!baseChannels || !overlayChannels) {
|
|
72
|
+
return alphaColor(overlay, boundedAlpha);
|
|
73
|
+
}
|
|
74
|
+
const r = Math.round(
|
|
75
|
+
(1 - boundedAlpha) * baseChannels.r + boundedAlpha * overlayChannels.r
|
|
76
|
+
);
|
|
77
|
+
const g = Math.round(
|
|
78
|
+
(1 - boundedAlpha) * baseChannels.g + boundedAlpha * overlayChannels.g
|
|
79
|
+
);
|
|
80
|
+
const b = Math.round(
|
|
81
|
+
(1 - boundedAlpha) * baseChannels.b + boundedAlpha * overlayChannels.b
|
|
82
|
+
);
|
|
83
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
84
|
+
}
|
|
85
|
+
var _MCIcons = null;
|
|
86
|
+
var _resolved = false;
|
|
87
|
+
function getMaterialCommunityIcons() {
|
|
88
|
+
if (!_resolved) {
|
|
89
|
+
_resolved = true;
|
|
90
|
+
try {
|
|
91
|
+
const mod = __require("@expo/vector-icons/MaterialCommunityIcons");
|
|
92
|
+
_MCIcons = mod.default || mod;
|
|
93
|
+
} catch {
|
|
94
|
+
_MCIcons = null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!_MCIcons) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
"@expo/vector-icons is required for icon support. Install it with: npx expo install @expo/vector-icons"
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return _MCIcons;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/icon-button/styles.ts
|
|
106
|
+
var import_react_native3 = require("react-native");
|
|
107
|
+
function createStyles(theme) {
|
|
108
|
+
const disabledContainerColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
109
|
+
const disabledOutlineColor = alphaColor(theme.colors.onSurface, 0.12);
|
|
110
|
+
const toggleUnselectedContainerColor = theme.colors.surfaceContainerHighest;
|
|
111
|
+
return import_react_native3.StyleSheet.create({
|
|
112
|
+
container: {
|
|
113
|
+
borderRadius: theme.shape.cornerFull,
|
|
114
|
+
alignItems: "center",
|
|
115
|
+
justifyContent: "center",
|
|
116
|
+
cursor: "pointer"
|
|
117
|
+
},
|
|
118
|
+
sizeSmall: {
|
|
119
|
+
width: 32,
|
|
120
|
+
height: 32
|
|
121
|
+
},
|
|
122
|
+
sizeMedium: {
|
|
123
|
+
width: 40,
|
|
124
|
+
height: 40
|
|
125
|
+
},
|
|
126
|
+
sizeLarge: {
|
|
127
|
+
width: 48,
|
|
128
|
+
height: 48
|
|
129
|
+
},
|
|
130
|
+
colorFilled: {
|
|
131
|
+
backgroundColor: theme.colors.primary,
|
|
132
|
+
borderColor: theme.colors.primary,
|
|
133
|
+
borderWidth: 0
|
|
134
|
+
},
|
|
135
|
+
colorFilledToggleUnselected: {
|
|
136
|
+
backgroundColor: toggleUnselectedContainerColor,
|
|
137
|
+
borderColor: toggleUnselectedContainerColor,
|
|
138
|
+
borderWidth: 0
|
|
139
|
+
},
|
|
140
|
+
colorFilledToggleSelected: {
|
|
141
|
+
backgroundColor: theme.colors.primary,
|
|
142
|
+
borderColor: theme.colors.primary,
|
|
143
|
+
borderWidth: 0
|
|
144
|
+
},
|
|
145
|
+
colorTonal: {
|
|
146
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
147
|
+
borderColor: theme.colors.secondaryContainer,
|
|
148
|
+
borderWidth: 0
|
|
149
|
+
},
|
|
150
|
+
colorTonalToggleUnselected: {
|
|
151
|
+
backgroundColor: toggleUnselectedContainerColor,
|
|
152
|
+
borderColor: toggleUnselectedContainerColor,
|
|
153
|
+
borderWidth: 0
|
|
154
|
+
},
|
|
155
|
+
colorTonalToggleSelected: {
|
|
156
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
157
|
+
borderColor: theme.colors.secondaryContainer,
|
|
158
|
+
borderWidth: 0
|
|
159
|
+
},
|
|
160
|
+
colorOutlined: {
|
|
161
|
+
borderColor: theme.colors.outline,
|
|
162
|
+
borderWidth: 1
|
|
163
|
+
},
|
|
164
|
+
colorOutlinedToggleSelected: {
|
|
165
|
+
backgroundColor: theme.colors.inverseSurface,
|
|
166
|
+
borderColor: theme.colors.inverseSurface,
|
|
167
|
+
borderWidth: 0
|
|
168
|
+
},
|
|
169
|
+
colorStandard: {
|
|
170
|
+
borderWidth: 0
|
|
171
|
+
},
|
|
172
|
+
colorStandardToggleSelected: {
|
|
173
|
+
borderWidth: 0
|
|
174
|
+
},
|
|
175
|
+
// Hover states (M3: 8% state layer)
|
|
176
|
+
hoveredFilled: {
|
|
177
|
+
backgroundColor: blendColor(
|
|
178
|
+
theme.colors.primary,
|
|
179
|
+
theme.colors.onPrimary,
|
|
180
|
+
theme.stateLayer.hoveredOpacity
|
|
181
|
+
)
|
|
182
|
+
},
|
|
183
|
+
hoveredFilledToggleUnselected: {
|
|
184
|
+
backgroundColor: blendColor(
|
|
185
|
+
toggleUnselectedContainerColor,
|
|
186
|
+
theme.colors.primary,
|
|
187
|
+
theme.stateLayer.hoveredOpacity
|
|
188
|
+
)
|
|
189
|
+
},
|
|
190
|
+
hoveredFilledToggleSelected: {
|
|
191
|
+
backgroundColor: blendColor(
|
|
192
|
+
theme.colors.primary,
|
|
193
|
+
theme.colors.onPrimary,
|
|
194
|
+
theme.stateLayer.hoveredOpacity
|
|
195
|
+
)
|
|
196
|
+
},
|
|
197
|
+
hoveredTonal: {
|
|
198
|
+
backgroundColor: blendColor(
|
|
199
|
+
theme.colors.secondaryContainer,
|
|
200
|
+
theme.colors.onSecondaryContainer,
|
|
201
|
+
theme.stateLayer.hoveredOpacity
|
|
202
|
+
)
|
|
203
|
+
},
|
|
204
|
+
hoveredTonalToggleUnselected: {
|
|
205
|
+
backgroundColor: blendColor(
|
|
206
|
+
toggleUnselectedContainerColor,
|
|
207
|
+
theme.colors.onSurfaceVariant,
|
|
208
|
+
theme.stateLayer.hoveredOpacity
|
|
209
|
+
)
|
|
210
|
+
},
|
|
211
|
+
hoveredTonalToggleSelected: {
|
|
212
|
+
backgroundColor: blendColor(
|
|
213
|
+
theme.colors.secondaryContainer,
|
|
214
|
+
theme.colors.onSecondaryContainer,
|
|
215
|
+
theme.stateLayer.hoveredOpacity
|
|
216
|
+
)
|
|
217
|
+
},
|
|
218
|
+
hoveredOutlined: {
|
|
219
|
+
backgroundColor: alphaColor(
|
|
220
|
+
theme.colors.onSurfaceVariant,
|
|
221
|
+
theme.stateLayer.hoveredOpacity
|
|
222
|
+
)
|
|
223
|
+
},
|
|
224
|
+
hoveredOutlinedToggleUnselected: {
|
|
225
|
+
backgroundColor: alphaColor(
|
|
226
|
+
theme.colors.onSurfaceVariant,
|
|
227
|
+
theme.stateLayer.hoveredOpacity
|
|
228
|
+
)
|
|
229
|
+
},
|
|
230
|
+
hoveredOutlinedToggleSelected: {
|
|
231
|
+
backgroundColor: blendColor(
|
|
232
|
+
theme.colors.inverseSurface,
|
|
233
|
+
theme.colors.inverseOnSurface,
|
|
234
|
+
theme.stateLayer.hoveredOpacity
|
|
235
|
+
)
|
|
236
|
+
},
|
|
237
|
+
hoveredStandard: {
|
|
238
|
+
backgroundColor: alphaColor(
|
|
239
|
+
theme.colors.onSurfaceVariant,
|
|
240
|
+
theme.stateLayer.hoveredOpacity
|
|
241
|
+
)
|
|
242
|
+
},
|
|
243
|
+
hoveredStandardToggleUnselected: {
|
|
244
|
+
backgroundColor: alphaColor(
|
|
245
|
+
theme.colors.onSurfaceVariant,
|
|
246
|
+
theme.stateLayer.hoveredOpacity
|
|
247
|
+
)
|
|
248
|
+
},
|
|
249
|
+
hoveredStandardToggleSelected: {
|
|
250
|
+
backgroundColor: alphaColor(
|
|
251
|
+
theme.colors.primary,
|
|
252
|
+
theme.stateLayer.hoveredOpacity
|
|
253
|
+
)
|
|
254
|
+
},
|
|
255
|
+
// Pressed states (M3: 12% state layer)
|
|
256
|
+
pressedFilled: {
|
|
257
|
+
backgroundColor: blendColor(
|
|
258
|
+
theme.colors.primary,
|
|
259
|
+
theme.colors.onPrimary,
|
|
260
|
+
theme.stateLayer.pressedOpacity
|
|
261
|
+
)
|
|
262
|
+
},
|
|
263
|
+
pressedFilledToggleUnselected: {
|
|
264
|
+
backgroundColor: blendColor(
|
|
265
|
+
toggleUnselectedContainerColor,
|
|
266
|
+
theme.colors.primary,
|
|
267
|
+
theme.stateLayer.pressedOpacity
|
|
268
|
+
)
|
|
269
|
+
},
|
|
270
|
+
pressedFilledToggleSelected: {
|
|
271
|
+
backgroundColor: blendColor(
|
|
272
|
+
theme.colors.primary,
|
|
273
|
+
theme.colors.onPrimary,
|
|
274
|
+
theme.stateLayer.pressedOpacity
|
|
275
|
+
)
|
|
276
|
+
},
|
|
277
|
+
pressedTonal: {
|
|
278
|
+
backgroundColor: blendColor(
|
|
279
|
+
theme.colors.secondaryContainer,
|
|
280
|
+
theme.colors.onSecondaryContainer,
|
|
281
|
+
theme.stateLayer.pressedOpacity
|
|
282
|
+
)
|
|
283
|
+
},
|
|
284
|
+
pressedTonalToggleUnselected: {
|
|
285
|
+
backgroundColor: blendColor(
|
|
286
|
+
toggleUnselectedContainerColor,
|
|
287
|
+
theme.colors.onSurfaceVariant,
|
|
288
|
+
theme.stateLayer.pressedOpacity
|
|
289
|
+
)
|
|
290
|
+
},
|
|
291
|
+
pressedTonalToggleSelected: {
|
|
292
|
+
backgroundColor: blendColor(
|
|
293
|
+
theme.colors.secondaryContainer,
|
|
294
|
+
theme.colors.onSecondaryContainer,
|
|
295
|
+
theme.stateLayer.pressedOpacity
|
|
296
|
+
)
|
|
297
|
+
},
|
|
298
|
+
pressedOutlined: {
|
|
299
|
+
backgroundColor: alphaColor(
|
|
300
|
+
theme.colors.onSurfaceVariant,
|
|
301
|
+
theme.stateLayer.pressedOpacity
|
|
302
|
+
)
|
|
303
|
+
},
|
|
304
|
+
pressedOutlinedToggleUnselected: {
|
|
305
|
+
backgroundColor: alphaColor(
|
|
306
|
+
theme.colors.onSurfaceVariant,
|
|
307
|
+
theme.stateLayer.pressedOpacity
|
|
308
|
+
)
|
|
309
|
+
},
|
|
310
|
+
pressedOutlinedToggleSelected: {
|
|
311
|
+
backgroundColor: blendColor(
|
|
312
|
+
theme.colors.inverseSurface,
|
|
313
|
+
theme.colors.inverseOnSurface,
|
|
314
|
+
theme.stateLayer.pressedOpacity
|
|
315
|
+
)
|
|
316
|
+
},
|
|
317
|
+
pressedStandard: {
|
|
318
|
+
backgroundColor: alphaColor(
|
|
319
|
+
theme.colors.onSurfaceVariant,
|
|
320
|
+
theme.stateLayer.pressedOpacity
|
|
321
|
+
)
|
|
322
|
+
},
|
|
323
|
+
pressedStandardToggleUnselected: {
|
|
324
|
+
backgroundColor: alphaColor(
|
|
325
|
+
theme.colors.onSurfaceVariant,
|
|
326
|
+
theme.stateLayer.pressedOpacity
|
|
327
|
+
)
|
|
328
|
+
},
|
|
329
|
+
pressedStandardToggleSelected: {
|
|
330
|
+
backgroundColor: alphaColor(
|
|
331
|
+
theme.colors.primary,
|
|
332
|
+
theme.stateLayer.pressedOpacity
|
|
333
|
+
)
|
|
334
|
+
},
|
|
335
|
+
// Disabled states
|
|
336
|
+
disabledFilled: {
|
|
337
|
+
backgroundColor: disabledContainerColor,
|
|
338
|
+
borderColor: disabledContainerColor,
|
|
339
|
+
cursor: "auto"
|
|
340
|
+
},
|
|
341
|
+
disabledTonal: {
|
|
342
|
+
backgroundColor: disabledContainerColor,
|
|
343
|
+
borderColor: disabledContainerColor,
|
|
344
|
+
cursor: "auto"
|
|
345
|
+
},
|
|
346
|
+
disabledOutlined: {
|
|
347
|
+
backgroundColor: "transparent",
|
|
348
|
+
borderColor: disabledOutlineColor,
|
|
349
|
+
cursor: "auto"
|
|
350
|
+
},
|
|
351
|
+
disabledStandard: {
|
|
352
|
+
backgroundColor: "transparent",
|
|
353
|
+
borderColor: "transparent",
|
|
354
|
+
cursor: "auto"
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// src/icon-button/IconButton.tsx
|
|
360
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
361
|
+
function getIconColor(variant, theme, disabled, isToggle, selected) {
|
|
362
|
+
if (disabled) {
|
|
363
|
+
return alphaColor(theme.colors.onSurface, 0.38);
|
|
364
|
+
}
|
|
365
|
+
if (isToggle) {
|
|
366
|
+
if (variant === "filled") {
|
|
367
|
+
return selected ? theme.colors.onPrimary : theme.colors.primary;
|
|
368
|
+
}
|
|
369
|
+
if (variant === "tonal") {
|
|
370
|
+
return selected ? theme.colors.onSecondaryContainer : theme.colors.onSurfaceVariant;
|
|
371
|
+
}
|
|
372
|
+
if (variant === "outlined") {
|
|
373
|
+
return selected ? theme.colors.inverseOnSurface : theme.colors.onSurfaceVariant;
|
|
374
|
+
}
|
|
375
|
+
return selected ? theme.colors.primary : theme.colors.onSurfaceVariant;
|
|
376
|
+
}
|
|
377
|
+
if (variant === "filled") {
|
|
378
|
+
return theme.colors.onPrimary;
|
|
379
|
+
}
|
|
380
|
+
if (variant === "tonal") {
|
|
381
|
+
return theme.colors.onSecondaryContainer;
|
|
382
|
+
}
|
|
383
|
+
return theme.colors.onSurfaceVariant;
|
|
384
|
+
}
|
|
385
|
+
function getColorStyle(styles, variant, isToggle, selected) {
|
|
386
|
+
if (isToggle) {
|
|
387
|
+
if (variant === "tonal") {
|
|
388
|
+
return selected ? styles.colorTonalToggleSelected : styles.colorTonalToggleUnselected;
|
|
389
|
+
}
|
|
390
|
+
if (variant === "outlined") {
|
|
391
|
+
return selected ? styles.colorOutlinedToggleSelected : styles.colorOutlined;
|
|
392
|
+
}
|
|
393
|
+
if (variant === "standard") {
|
|
394
|
+
return selected ? styles.colorStandardToggleSelected : styles.colorStandard;
|
|
395
|
+
}
|
|
396
|
+
return selected ? styles.colorFilledToggleSelected : styles.colorFilledToggleUnselected;
|
|
397
|
+
}
|
|
398
|
+
if (variant === "tonal") {
|
|
399
|
+
return styles.colorTonal;
|
|
400
|
+
}
|
|
401
|
+
if (variant === "outlined") {
|
|
402
|
+
return styles.colorOutlined;
|
|
403
|
+
}
|
|
404
|
+
if (variant === "standard") {
|
|
405
|
+
return styles.colorStandard;
|
|
406
|
+
}
|
|
407
|
+
return styles.colorFilled;
|
|
408
|
+
}
|
|
409
|
+
function getSizeStyle(styles, size) {
|
|
410
|
+
if (size === "small") {
|
|
411
|
+
return styles.sizeSmall;
|
|
412
|
+
}
|
|
413
|
+
if (size === "large") {
|
|
414
|
+
return styles.sizeLarge;
|
|
415
|
+
}
|
|
416
|
+
return styles.sizeMedium;
|
|
417
|
+
}
|
|
418
|
+
function getIconPixelSize(size) {
|
|
419
|
+
if (size === "small") {
|
|
420
|
+
return 18;
|
|
421
|
+
}
|
|
422
|
+
if (size === "large") {
|
|
423
|
+
return 28;
|
|
424
|
+
}
|
|
425
|
+
return 24;
|
|
426
|
+
}
|
|
427
|
+
function getDefaultHitSlop(size) {
|
|
428
|
+
if (size === "small") {
|
|
429
|
+
return 8;
|
|
430
|
+
}
|
|
431
|
+
if (size === "large") {
|
|
432
|
+
return 0;
|
|
433
|
+
}
|
|
434
|
+
return 4;
|
|
435
|
+
}
|
|
436
|
+
function getHoveredStyle(styles, variant, isToggle, selected) {
|
|
437
|
+
if (isToggle) {
|
|
438
|
+
if (variant === "tonal") {
|
|
439
|
+
return selected ? styles.hoveredTonalToggleSelected : styles.hoveredTonalToggleUnselected;
|
|
440
|
+
}
|
|
441
|
+
if (variant === "outlined") {
|
|
442
|
+
return selected ? styles.hoveredOutlinedToggleSelected : styles.hoveredOutlinedToggleUnselected;
|
|
443
|
+
}
|
|
444
|
+
if (variant === "standard") {
|
|
445
|
+
return selected ? styles.hoveredStandardToggleSelected : styles.hoveredStandardToggleUnselected;
|
|
446
|
+
}
|
|
447
|
+
return selected ? styles.hoveredFilledToggleSelected : styles.hoveredFilledToggleUnselected;
|
|
448
|
+
}
|
|
449
|
+
if (variant === "tonal") {
|
|
450
|
+
return styles.hoveredTonal;
|
|
451
|
+
}
|
|
452
|
+
if (variant === "outlined") {
|
|
453
|
+
return styles.hoveredOutlined;
|
|
454
|
+
}
|
|
455
|
+
if (variant === "standard") {
|
|
456
|
+
return styles.hoveredStandard;
|
|
457
|
+
}
|
|
458
|
+
return styles.hoveredFilled;
|
|
459
|
+
}
|
|
460
|
+
function getPressedStyle(styles, variant, isToggle, selected) {
|
|
461
|
+
if (isToggle) {
|
|
462
|
+
if (variant === "tonal") {
|
|
463
|
+
return selected ? styles.pressedTonalToggleSelected : styles.pressedTonalToggleUnselected;
|
|
464
|
+
}
|
|
465
|
+
if (variant === "outlined") {
|
|
466
|
+
return selected ? styles.pressedOutlinedToggleSelected : styles.pressedOutlinedToggleUnselected;
|
|
467
|
+
}
|
|
468
|
+
if (variant === "standard") {
|
|
469
|
+
return selected ? styles.pressedStandardToggleSelected : styles.pressedStandardToggleUnselected;
|
|
470
|
+
}
|
|
471
|
+
return selected ? styles.pressedFilledToggleSelected : styles.pressedFilledToggleUnselected;
|
|
472
|
+
}
|
|
473
|
+
if (variant === "tonal") {
|
|
474
|
+
return styles.pressedTonal;
|
|
475
|
+
}
|
|
476
|
+
if (variant === "outlined") {
|
|
477
|
+
return styles.pressedOutlined;
|
|
478
|
+
}
|
|
479
|
+
if (variant === "standard") {
|
|
480
|
+
return styles.pressedStandard;
|
|
481
|
+
}
|
|
482
|
+
return styles.pressedFilled;
|
|
483
|
+
}
|
|
484
|
+
function getDisabledStyle(styles, variant) {
|
|
485
|
+
if (variant === "tonal") {
|
|
486
|
+
return styles.disabledTonal;
|
|
487
|
+
}
|
|
488
|
+
if (variant === "outlined") {
|
|
489
|
+
return styles.disabledOutlined;
|
|
490
|
+
}
|
|
491
|
+
if (variant === "standard") {
|
|
492
|
+
return styles.disabledStandard;
|
|
493
|
+
}
|
|
494
|
+
return styles.disabledFilled;
|
|
495
|
+
}
|
|
496
|
+
function IconButton({
|
|
497
|
+
icon,
|
|
498
|
+
selectedIcon,
|
|
499
|
+
iconColor,
|
|
500
|
+
contentColor,
|
|
501
|
+
containerColor,
|
|
502
|
+
style,
|
|
503
|
+
onPress,
|
|
504
|
+
disabled = false,
|
|
505
|
+
variant = "filled",
|
|
506
|
+
selected,
|
|
507
|
+
size = "medium",
|
|
508
|
+
hitSlop,
|
|
509
|
+
accessibilityLabel,
|
|
510
|
+
...props
|
|
511
|
+
}) {
|
|
512
|
+
var _a;
|
|
513
|
+
const MaterialCommunityIcons = getMaterialCommunityIcons();
|
|
514
|
+
const theme = (0, import_core.useTheme)();
|
|
515
|
+
const styles = (0, import_react.useMemo)(() => createStyles(theme), [theme]);
|
|
516
|
+
const isDisabled = Boolean(disabled);
|
|
517
|
+
const isToggle = selected !== void 0;
|
|
518
|
+
const isSelected = Boolean(selected);
|
|
519
|
+
const resolvedIconColor = (_a = contentColor != null ? contentColor : iconColor) != null ? _a : getIconColor(variant, theme, isDisabled, isToggle, isSelected);
|
|
520
|
+
const displayIcon = isToggle && isSelected && selectedIcon ? selectedIcon : icon;
|
|
521
|
+
const iconPixelSize = getIconPixelSize(size);
|
|
522
|
+
const accessibilityState = isToggle ? { disabled: isDisabled, selected: isSelected } : { disabled: isDisabled };
|
|
523
|
+
const containerOverrides = (0, import_react.useMemo)(() => {
|
|
524
|
+
if (!containerColor) return null;
|
|
525
|
+
const overlay = resolvedIconColor;
|
|
526
|
+
return {
|
|
527
|
+
base: {
|
|
528
|
+
backgroundColor: containerColor,
|
|
529
|
+
borderColor: containerColor,
|
|
530
|
+
borderWidth: 0
|
|
531
|
+
},
|
|
532
|
+
hovered: {
|
|
533
|
+
backgroundColor: blendColor(
|
|
534
|
+
containerColor,
|
|
535
|
+
overlay,
|
|
536
|
+
theme.stateLayer.hoveredOpacity
|
|
537
|
+
)
|
|
538
|
+
},
|
|
539
|
+
pressed: {
|
|
540
|
+
backgroundColor: blendColor(
|
|
541
|
+
containerColor,
|
|
542
|
+
overlay,
|
|
543
|
+
theme.stateLayer.pressedOpacity
|
|
544
|
+
)
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
}, [containerColor, resolvedIconColor, theme.stateLayer]);
|
|
548
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
549
|
+
import_react_native4.Pressable,
|
|
550
|
+
{
|
|
551
|
+
...props,
|
|
552
|
+
accessibilityRole: "button",
|
|
553
|
+
accessibilityLabel,
|
|
554
|
+
accessibilityState,
|
|
555
|
+
disabled: isDisabled,
|
|
556
|
+
hitSlop: hitSlop != null ? hitSlop : getDefaultHitSlop(size),
|
|
557
|
+
onPress,
|
|
558
|
+
style: ({
|
|
559
|
+
pressed,
|
|
560
|
+
hovered
|
|
561
|
+
}) => {
|
|
562
|
+
const base = [
|
|
563
|
+
styles.container,
|
|
564
|
+
getSizeStyle(styles, size),
|
|
565
|
+
getColorStyle(styles, variant, isToggle, isSelected),
|
|
566
|
+
containerOverrides == null ? void 0 : containerOverrides.base,
|
|
567
|
+
hovered && !pressed && !isDisabled ? containerOverrides ? containerOverrides.hovered : getHoveredStyle(styles, variant, isToggle, isSelected) : void 0,
|
|
568
|
+
pressed && !isDisabled ? containerOverrides ? containerOverrides.pressed : getPressedStyle(styles, variant, isToggle, isSelected) : void 0,
|
|
569
|
+
isDisabled ? getDisabledStyle(styles, variant) : void 0
|
|
570
|
+
];
|
|
571
|
+
if (typeof style === "function") {
|
|
572
|
+
base.push(style({ pressed }));
|
|
573
|
+
} else if (style) {
|
|
574
|
+
base.push(style);
|
|
575
|
+
}
|
|
576
|
+
return base;
|
|
577
|
+
},
|
|
578
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
579
|
+
MaterialCommunityIcons,
|
|
580
|
+
{
|
|
581
|
+
name: displayIcon,
|
|
582
|
+
size: iconPixelSize,
|
|
583
|
+
color: resolvedIconColor
|
|
584
|
+
}
|
|
585
|
+
)
|
|
586
|
+
}
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
590
|
+
0 && (module.exports = {
|
|
591
|
+
IconButton
|
|
592
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { Typography, TypographyProps, TypographyVariant } from './typography/index.js';
|
|
2
|
+
export { Box, BoxProps, Column, ColumnProps, Grid, GridProps, Layout, LayoutProps, Row, RowProps, SpacingValue } from './layout/index.js';
|
|
3
|
+
export { Button, ButtonProps, ButtonVariant } from './button/index.js';
|
|
4
|
+
export { IconButton } from './icon-button/index.js';
|
|
5
|
+
export { I as IconButtonProps, a as IconButtonSize, b as IconButtonVariant } from './types-D3hlyvz-.js';
|
|
6
|
+
export { AppBar, AppBarAction, AppBarColorScheme, AppBarProps, AppBarVariant } from './appbar/index.js';
|
|
7
|
+
export { Card, CardProps, CardVariant } from './card/index.js';
|
|
8
|
+
export { Chip, ChipProps, ChipVariant } from './chip/index.js';
|
|
9
|
+
export { Checkbox, CheckboxProps } from './checkbox/index.js';
|
|
10
|
+
export { Radio, RadioProps } from './radio/index.js';
|
|
11
|
+
export { Switch, SwitchProps } from './switch/index.js';
|
|
12
|
+
export { TextField, TextFieldProps, TextFieldVariant } from './text-field/index.js';
|
|
13
|
+
export { List, ListDivider, ListDividerProps, ListItem, ListItemLines, ListItemProps, ListProps } from './list/index.js';
|
|
14
|
+
export { KeyboardAvoidingWrapper, KeyboardAvoidingWrapperProps } from './keyboard-avoiding-wrapper/index.js';
|
|
15
|
+
export { Avatar, AvatarProps, AvatarSize } from './avatar/index.js';
|
|
16
|
+
import 'react/jsx-runtime';
|
|
17
|
+
import 'react';
|
|
18
|
+
import 'react-native';
|
|
19
|
+
import 'react-native-safe-area-context';
|
|
20
|
+
import '@onlynative/core';
|
|
21
|
+
import '@expo/vector-icons/MaterialCommunityIcons';
|