@onlynative/components 0.0.0-alpha.0 → 0.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/appbar/index.js +27 -26
- package/dist/avatar/index.js +7 -6
- package/dist/button/index.js +34 -31
- package/dist/card/index.js +34 -18
- package/dist/checkbox/index.js +35 -30
- package/dist/chip/index.js +37 -32
- package/dist/icon-button/index.js +5 -4
- package/dist/index.js +185 -252
- package/dist/list/index.js +52 -30
- package/dist/radio/index.js +27 -28
- package/dist/switch/index.js +35 -30
- package/dist/text-field/index.js +19 -18
- package/llms.txt +2 -2
- package/package.json +3 -18
package/dist/list/index.js
CHANGED
|
@@ -28,15 +28,16 @@ module.exports = __toCommonJS(list_exports);
|
|
|
28
28
|
|
|
29
29
|
// src/list/List.tsx
|
|
30
30
|
var import_react = require("react");
|
|
31
|
-
var
|
|
31
|
+
var import_react_native5 = require("react-native");
|
|
32
32
|
var import_core = require("@onlynative/core");
|
|
33
33
|
|
|
34
34
|
// src/list/styles.ts
|
|
35
|
-
var
|
|
35
|
+
var import_react_native4 = require("react-native");
|
|
36
36
|
|
|
37
37
|
// ../utils/dist/index.mjs
|
|
38
38
|
var import_react_native = require("react-native");
|
|
39
39
|
var import_react_native2 = require("react-native");
|
|
40
|
+
var import_react_native3 = require("react-native");
|
|
40
41
|
function parseHexColor(color) {
|
|
41
42
|
const normalized = color.replace("#", "");
|
|
42
43
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -79,6 +80,24 @@ function blendColor(base, overlay, overlayAlpha) {
|
|
|
79
80
|
);
|
|
80
81
|
return `rgb(${r}, ${g}, ${b})`;
|
|
81
82
|
}
|
|
83
|
+
function resolvePressableStyle(base, hovered, pressed, disabled, isDisabled, style) {
|
|
84
|
+
if (typeof style === "function") {
|
|
85
|
+
return (state) => [
|
|
86
|
+
base,
|
|
87
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
88
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
89
|
+
isDisabled ? disabled : void 0,
|
|
90
|
+
style(state)
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
return (state) => [
|
|
94
|
+
base,
|
|
95
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
96
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
97
|
+
isDisabled ? disabled : void 0,
|
|
98
|
+
style
|
|
99
|
+
];
|
|
100
|
+
}
|
|
82
101
|
|
|
83
102
|
// src/list/styles.ts
|
|
84
103
|
var ITEM_PADDING_VERTICAL = 12;
|
|
@@ -89,7 +108,7 @@ var MIN_HEIGHT = {
|
|
|
89
108
|
3: 88
|
|
90
109
|
};
|
|
91
110
|
function createListStyles(theme) {
|
|
92
|
-
return
|
|
111
|
+
return import_react_native4.StyleSheet.create({
|
|
93
112
|
container: {
|
|
94
113
|
paddingVertical: theme.spacing.sm
|
|
95
114
|
}
|
|
@@ -126,7 +145,7 @@ function getItemColors(theme, containerColor) {
|
|
|
126
145
|
}
|
|
127
146
|
function createListItemStyles(theme, lines, containerColor) {
|
|
128
147
|
const colors = getItemColors(theme, containerColor);
|
|
129
|
-
return
|
|
148
|
+
return import_react_native4.StyleSheet.create({
|
|
130
149
|
container: {
|
|
131
150
|
flexDirection: "row",
|
|
132
151
|
alignItems: lines === 3 ? "flex-start" : "center",
|
|
@@ -181,7 +200,7 @@ function createListItemStyles(theme, lines, containerColor) {
|
|
|
181
200
|
});
|
|
182
201
|
}
|
|
183
202
|
function createDividerStyles(theme, inset) {
|
|
184
|
-
return
|
|
203
|
+
return import_react_native4.StyleSheet.create({
|
|
185
204
|
divider: {
|
|
186
205
|
height: 1,
|
|
187
206
|
backgroundColor: theme.colors.outlineVariant,
|
|
@@ -195,12 +214,12 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
195
214
|
function List({ children, style, ...props }) {
|
|
196
215
|
const theme = (0, import_core.useTheme)();
|
|
197
216
|
const styles = (0, import_react.useMemo)(() => createListStyles(theme), [theme]);
|
|
198
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { ...props, style: [styles.container, style], children });
|
|
199
218
|
}
|
|
200
219
|
|
|
201
220
|
// src/list/ListItem.tsx
|
|
202
221
|
var import_react2 = require("react");
|
|
203
|
-
var
|
|
222
|
+
var import_react_native6 = require("react-native");
|
|
204
223
|
var import_core2 = require("@onlynative/core");
|
|
205
224
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
206
225
|
function getLines(supportingText, overlineText, supportingTextNumberOfLines) {
|
|
@@ -227,18 +246,22 @@ function ListItem({
|
|
|
227
246
|
const isDisabled = Boolean(disabled);
|
|
228
247
|
const isInteractive = onPress !== void 0;
|
|
229
248
|
const theme = (0, import_core2.useTheme)();
|
|
230
|
-
const lines = getLines(
|
|
249
|
+
const lines = getLines(
|
|
250
|
+
supportingText,
|
|
251
|
+
overlineText,
|
|
252
|
+
supportingTextNumberOfLines
|
|
253
|
+
);
|
|
231
254
|
const styles = (0, import_react2.useMemo)(
|
|
232
255
|
() => createListItemStyles(theme, lines, containerColor),
|
|
233
256
|
[theme, lines, containerColor]
|
|
234
257
|
);
|
|
235
258
|
const content = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
236
|
-
leadingContent != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
237
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
238
|
-
overlineText != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
239
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
259
|
+
leadingContent != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.View, { style: styles.leadingContent, children: leadingContent }),
|
|
260
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native6.View, { style: styles.textBlock, children: [
|
|
261
|
+
overlineText != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.Text, { style: styles.overlineText, numberOfLines: 1, children: overlineText }),
|
|
262
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.Text, { style: styles.headlineText, numberOfLines: 1, children: headlineText }),
|
|
240
263
|
supportingText != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
241
|
-
|
|
264
|
+
import_react_native6.Text,
|
|
242
265
|
{
|
|
243
266
|
style: styles.supportingText,
|
|
244
267
|
numberOfLines: supportingTextNumberOfLines,
|
|
@@ -246,40 +269,39 @@ function ListItem({
|
|
|
246
269
|
}
|
|
247
270
|
)
|
|
248
271
|
] }),
|
|
249
|
-
(trailingContent != null || trailingSupportingText != null) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
250
|
-
trailingSupportingText != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
272
|
+
(trailingContent != null || trailingSupportingText != null) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native6.View, { style: styles.trailingBlock, children: [
|
|
273
|
+
trailingSupportingText != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.Text, { style: styles.trailingSupportingText, numberOfLines: 1, children: trailingSupportingText }),
|
|
251
274
|
trailingContent
|
|
252
275
|
] })
|
|
253
276
|
] });
|
|
254
277
|
if (!isInteractive) {
|
|
255
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.View, { ...props, style: [styles.container, style], children: content });
|
|
256
279
|
}
|
|
257
|
-
const resolvedStyle = (state) => [
|
|
258
|
-
styles.container,
|
|
259
|
-
styles.interactiveContainer,
|
|
260
|
-
state.hovered && !state.pressed && !isDisabled ? styles.hoveredContainer : void 0,
|
|
261
|
-
state.pressed && !isDisabled ? styles.pressedContainer : void 0,
|
|
262
|
-
isDisabled ? styles.disabledContainer : void 0,
|
|
263
|
-
typeof style === "function" ? style(state) : style
|
|
264
|
-
];
|
|
265
280
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
266
|
-
|
|
281
|
+
import_react_native6.Pressable,
|
|
267
282
|
{
|
|
268
283
|
...props,
|
|
269
284
|
role: "button",
|
|
270
285
|
accessibilityState: { disabled: isDisabled },
|
|
271
|
-
hitSlop:
|
|
286
|
+
hitSlop: import_react_native6.Platform.OS === "web" ? void 0 : 4,
|
|
272
287
|
disabled: isDisabled,
|
|
273
288
|
onPress,
|
|
274
|
-
style:
|
|
275
|
-
|
|
289
|
+
style: resolvePressableStyle(
|
|
290
|
+
[styles.container, styles.interactiveContainer],
|
|
291
|
+
styles.hoveredContainer,
|
|
292
|
+
styles.pressedContainer,
|
|
293
|
+
styles.disabledContainer,
|
|
294
|
+
isDisabled,
|
|
295
|
+
style
|
|
296
|
+
),
|
|
297
|
+
children: isDisabled ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.View, { style: styles.disabledContentWrapper, children: content }) : content
|
|
276
298
|
}
|
|
277
299
|
);
|
|
278
300
|
}
|
|
279
301
|
|
|
280
302
|
// src/list/ListDivider.tsx
|
|
281
303
|
var import_react3 = require("react");
|
|
282
|
-
var
|
|
304
|
+
var import_react_native7 = require("react-native");
|
|
283
305
|
var import_core3 = require("@onlynative/core");
|
|
284
306
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
285
307
|
function ListDivider({
|
|
@@ -292,7 +314,7 @@ function ListDivider({
|
|
|
292
314
|
() => createDividerStyles(theme, inset),
|
|
293
315
|
[theme, inset]
|
|
294
316
|
);
|
|
295
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
317
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native7.View, { ...props, style: [styles.divider, style] });
|
|
296
318
|
}
|
|
297
319
|
// Annotate the CommonJS export names for ESM import in node:
|
|
298
320
|
0 && (module.exports = {
|
package/dist/radio/index.js
CHANGED
|
@@ -26,15 +26,13 @@ module.exports = __toCommonJS(radio_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/radio/Radio.tsx
|
|
28
28
|
var import_react = require("react");
|
|
29
|
-
var
|
|
29
|
+
var import_react_native5 = require("react-native");
|
|
30
30
|
var import_core = require("@onlynative/core");
|
|
31
31
|
|
|
32
|
-
// src/radio/styles.ts
|
|
33
|
-
var import_react_native3 = require("react-native");
|
|
34
|
-
|
|
35
32
|
// ../utils/dist/index.mjs
|
|
36
33
|
var import_react_native = require("react-native");
|
|
37
34
|
var import_react_native2 = require("react-native");
|
|
35
|
+
var import_react_native3 = require("react-native");
|
|
38
36
|
function parseHexColor(color) {
|
|
39
37
|
const normalized = color.replace("#", "");
|
|
40
38
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -59,8 +57,27 @@ function alphaColor(color, alpha) {
|
|
|
59
57
|
}
|
|
60
58
|
return `rgba(${channels.r}, ${channels.g}, ${channels.b}, ${boundedAlpha})`;
|
|
61
59
|
}
|
|
60
|
+
function resolvePressableStyle(base, hovered, pressed, disabled, isDisabled, style) {
|
|
61
|
+
if (typeof style === "function") {
|
|
62
|
+
return (state) => [
|
|
63
|
+
base,
|
|
64
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
65
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
66
|
+
isDisabled ? disabled : void 0,
|
|
67
|
+
style(state)
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
return (state) => [
|
|
71
|
+
base,
|
|
72
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
73
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
74
|
+
isDisabled ? disabled : void 0,
|
|
75
|
+
style
|
|
76
|
+
];
|
|
77
|
+
}
|
|
62
78
|
|
|
63
79
|
// src/radio/styles.ts
|
|
80
|
+
var import_react_native4 = require("react-native");
|
|
64
81
|
function getColors(theme, selected) {
|
|
65
82
|
const disabledOnSurface38 = alphaColor(theme.colors.onSurface, 0.38);
|
|
66
83
|
if (selected) {
|
|
@@ -124,7 +141,7 @@ function createStyles(theme, selected, containerColor, contentColor) {
|
|
|
124
141
|
const outerSize = 20;
|
|
125
142
|
const innerSize = 10;
|
|
126
143
|
const touchTarget = 48;
|
|
127
|
-
return
|
|
144
|
+
return import_react_native4.StyleSheet.create({
|
|
128
145
|
container: {
|
|
129
146
|
width: touchTarget,
|
|
130
147
|
height: touchTarget,
|
|
@@ -169,24 +186,6 @@ function createStyles(theme, selected, containerColor, contentColor) {
|
|
|
169
186
|
|
|
170
187
|
// src/radio/Radio.tsx
|
|
171
188
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
172
|
-
function resolveStyle(containerStyle, hoveredContainerStyle, pressedContainerStyle, disabledContainerStyle, disabled, style) {
|
|
173
|
-
if (typeof style === "function") {
|
|
174
|
-
return (state) => [
|
|
175
|
-
containerStyle,
|
|
176
|
-
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
177
|
-
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
178
|
-
disabled ? disabledContainerStyle : void 0,
|
|
179
|
-
style(state)
|
|
180
|
-
];
|
|
181
|
-
}
|
|
182
|
-
return (state) => [
|
|
183
|
-
containerStyle,
|
|
184
|
-
state.hovered && !state.pressed && !disabled ? hoveredContainerStyle : void 0,
|
|
185
|
-
state.pressed && !disabled ? pressedContainerStyle : void 0,
|
|
186
|
-
disabled ? disabledContainerStyle : void 0,
|
|
187
|
-
style
|
|
188
|
-
];
|
|
189
|
-
}
|
|
190
189
|
function Radio({
|
|
191
190
|
style,
|
|
192
191
|
value = false,
|
|
@@ -209,7 +208,7 @@ function Radio({
|
|
|
209
208
|
}
|
|
210
209
|
};
|
|
211
210
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
212
|
-
|
|
211
|
+
import_react_native5.Pressable,
|
|
213
212
|
{
|
|
214
213
|
...props,
|
|
215
214
|
accessibilityRole: "radio",
|
|
@@ -217,10 +216,10 @@ function Radio({
|
|
|
217
216
|
disabled: isDisabled,
|
|
218
217
|
checked: isSelected
|
|
219
218
|
},
|
|
220
|
-
hitSlop:
|
|
219
|
+
hitSlop: import_react_native5.Platform.OS === "web" ? void 0 : 4,
|
|
221
220
|
disabled: isDisabled,
|
|
222
221
|
onPress: handlePress,
|
|
223
|
-
style:
|
|
222
|
+
style: resolvePressableStyle(
|
|
224
223
|
styles.container,
|
|
225
224
|
styles.hoveredContainer,
|
|
226
225
|
styles.pressedContainer,
|
|
@@ -229,11 +228,11 @@ function Radio({
|
|
|
229
228
|
style
|
|
230
229
|
),
|
|
231
230
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
232
|
-
|
|
231
|
+
import_react_native5.View,
|
|
233
232
|
{
|
|
234
233
|
style: [styles.outer, isDisabled ? styles.disabledOuter : void 0],
|
|
235
234
|
children: isSelected ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
236
|
-
|
|
235
|
+
import_react_native5.View,
|
|
237
236
|
{
|
|
238
237
|
style: [
|
|
239
238
|
styles.inner,
|
package/dist/switch/index.js
CHANGED
|
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(switch_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/switch/Switch.tsx
|
|
28
28
|
var import_react = require("react");
|
|
29
|
-
var
|
|
29
|
+
var import_react_native5 = require("react-native");
|
|
30
30
|
var import_core = require("@onlynative/core");
|
|
31
31
|
|
|
32
32
|
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
@@ -40,6 +40,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
40
40
|
// ../utils/dist/index.mjs
|
|
41
41
|
var import_react_native = require("react-native");
|
|
42
42
|
var import_react_native2 = require("react-native");
|
|
43
|
+
var import_react_native3 = require("react-native");
|
|
43
44
|
function parseHexColor(color) {
|
|
44
45
|
const normalized = color.replace("#", "");
|
|
45
46
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -101,9 +102,31 @@ function getMaterialCommunityIcons() {
|
|
|
101
102
|
}
|
|
102
103
|
return _MCIcons;
|
|
103
104
|
}
|
|
105
|
+
function resolvePressableStyle(base, hovered, pressed, disabled, isDisabled, style) {
|
|
106
|
+
if (typeof style === "function") {
|
|
107
|
+
return (state) => [
|
|
108
|
+
base,
|
|
109
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
110
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
111
|
+
isDisabled ? disabled : void 0,
|
|
112
|
+
style(state)
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
return (state) => [
|
|
116
|
+
base,
|
|
117
|
+
state.hovered && !state.pressed && !isDisabled ? hovered : void 0,
|
|
118
|
+
state.pressed && !isDisabled ? pressed : void 0,
|
|
119
|
+
isDisabled ? disabled : void 0,
|
|
120
|
+
style
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
function resolveColorFromStyle(...styles) {
|
|
124
|
+
const flattened = import_react_native2.StyleSheet.flatten(styles);
|
|
125
|
+
return typeof (flattened == null ? void 0 : flattened.color) === "string" ? flattened.color : void 0;
|
|
126
|
+
}
|
|
104
127
|
|
|
105
128
|
// src/switch/styles.ts
|
|
106
|
-
var
|
|
129
|
+
var import_react_native4 = require("react-native");
|
|
107
130
|
function getColors(theme, selected) {
|
|
108
131
|
const disabledOnSurface12 = alphaColor(theme.colors.onSurface, 0.12);
|
|
109
132
|
const disabledOnSurface38 = alphaColor(theme.colors.onSurface, 0.38);
|
|
@@ -191,7 +214,7 @@ function createStyles(theme, selected, hasIcon, containerColor, contentColor) {
|
|
|
191
214
|
const trackHeight = 32;
|
|
192
215
|
const trackPadding = 4;
|
|
193
216
|
const thumbOffset = selected ? trackWidth - trackPadding - thumbSize : trackPadding;
|
|
194
|
-
return
|
|
217
|
+
return import_react_native4.StyleSheet.create({
|
|
195
218
|
track: {
|
|
196
219
|
width: trackWidth,
|
|
197
220
|
height: trackHeight,
|
|
@@ -237,24 +260,6 @@ function createStyles(theme, selected, hasIcon, containerColor, contentColor) {
|
|
|
237
260
|
|
|
238
261
|
// src/switch/Switch.tsx
|
|
239
262
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
240
|
-
function resolveStyle(trackStyle, hoveredTrackStyle, pressedTrackStyle, disabledTrackStyle, disabled, style) {
|
|
241
|
-
if (typeof style === "function") {
|
|
242
|
-
return (state) => [
|
|
243
|
-
trackStyle,
|
|
244
|
-
state.hovered && !state.pressed && !disabled ? hoveredTrackStyle : void 0,
|
|
245
|
-
state.pressed && !disabled ? pressedTrackStyle : void 0,
|
|
246
|
-
disabled ? disabledTrackStyle : void 0,
|
|
247
|
-
style(state)
|
|
248
|
-
];
|
|
249
|
-
}
|
|
250
|
-
return (state) => [
|
|
251
|
-
trackStyle,
|
|
252
|
-
state.hovered && !state.pressed && !disabled ? hoveredTrackStyle : void 0,
|
|
253
|
-
state.pressed && !disabled ? pressedTrackStyle : void 0,
|
|
254
|
-
disabled ? disabledTrackStyle : void 0,
|
|
255
|
-
style
|
|
256
|
-
];
|
|
257
|
-
}
|
|
258
263
|
function Switch({
|
|
259
264
|
style,
|
|
260
265
|
value = false,
|
|
@@ -274,13 +279,13 @@ function Switch({
|
|
|
274
279
|
() => createStyles(theme, isSelected, hasIcon, containerColor, contentColor),
|
|
275
280
|
[theme, isSelected, hasIcon, containerColor, contentColor]
|
|
276
281
|
);
|
|
277
|
-
const resolvedIconColor = (0, import_react.useMemo)(
|
|
278
|
-
|
|
282
|
+
const resolvedIconColor = (0, import_react.useMemo)(
|
|
283
|
+
() => resolveColorFromStyle(
|
|
279
284
|
styles.iconColor,
|
|
280
285
|
isDisabled ? styles.disabledIconColor : void 0
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
286
|
+
),
|
|
287
|
+
[styles.iconColor, styles.disabledIconColor, isDisabled]
|
|
288
|
+
);
|
|
284
289
|
const handlePress = () => {
|
|
285
290
|
if (!isDisabled) {
|
|
286
291
|
onValueChange == null ? void 0 : onValueChange(!isSelected);
|
|
@@ -290,7 +295,7 @@ function Switch({
|
|
|
290
295
|
const MaterialCommunityIcons = iconName ? getMaterialCommunityIcons() : null;
|
|
291
296
|
const iconSize = 16;
|
|
292
297
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
293
|
-
|
|
298
|
+
import_react_native5.Pressable,
|
|
294
299
|
{
|
|
295
300
|
...props,
|
|
296
301
|
accessibilityRole: "switch",
|
|
@@ -298,10 +303,10 @@ function Switch({
|
|
|
298
303
|
disabled: isDisabled,
|
|
299
304
|
checked: isSelected
|
|
300
305
|
},
|
|
301
|
-
hitSlop:
|
|
306
|
+
hitSlop: import_react_native5.Platform.OS === "web" ? void 0 : 4,
|
|
302
307
|
disabled: isDisabled,
|
|
303
308
|
onPress: handlePress,
|
|
304
|
-
style:
|
|
309
|
+
style: resolvePressableStyle(
|
|
305
310
|
styles.track,
|
|
306
311
|
styles.hoveredTrack,
|
|
307
312
|
styles.pressedTrack,
|
|
@@ -310,7 +315,7 @@ function Switch({
|
|
|
310
315
|
style
|
|
311
316
|
),
|
|
312
317
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
313
|
-
|
|
318
|
+
import_react_native5.View,
|
|
314
319
|
{
|
|
315
320
|
style: [styles.thumb, isDisabled ? styles.disabledThumb : void 0],
|
|
316
321
|
children: iconName ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
package/dist/text-field/index.js
CHANGED
|
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(text_field_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/text-field/TextField.tsx
|
|
28
28
|
var import_react = require("react");
|
|
29
|
-
var
|
|
29
|
+
var import_react_native5 = require("react-native");
|
|
30
30
|
var import_core = require("@onlynative/core");
|
|
31
31
|
|
|
32
32
|
// ../utils/dist/chunk-OQRDRRQA.mjs
|
|
@@ -40,6 +40,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
40
40
|
// ../utils/dist/index.mjs
|
|
41
41
|
var import_react_native = require("react-native");
|
|
42
42
|
var import_react_native2 = require("react-native");
|
|
43
|
+
var import_react_native3 = require("react-native");
|
|
43
44
|
function parseHexColor(color) {
|
|
44
45
|
const normalized = color.replace("#", "");
|
|
45
46
|
if (normalized.length !== 6 && normalized.length !== 8) {
|
|
@@ -84,11 +85,11 @@ function getMaterialCommunityIcons() {
|
|
|
84
85
|
return _MCIcons;
|
|
85
86
|
}
|
|
86
87
|
function transformOrigin(vertical = "top") {
|
|
87
|
-
return
|
|
88
|
+
return import_react_native3.I18nManager.isRTL ? `right ${vertical}` : `left ${vertical}`;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
// src/text-field/styles.ts
|
|
91
|
-
var
|
|
92
|
+
var import_react_native4 = require("react-native");
|
|
92
93
|
var CONTAINER_HEIGHT = 56;
|
|
93
94
|
var ICON_SIZE = 24;
|
|
94
95
|
var LABEL_FLOATED_LINE_HEIGHT = 16;
|
|
@@ -147,7 +148,7 @@ function createStyles(theme, variant) {
|
|
|
147
148
|
const isFilled = variant === "filled";
|
|
148
149
|
return {
|
|
149
150
|
colors,
|
|
150
|
-
styles:
|
|
151
|
+
styles: import_react_native4.StyleSheet.create({
|
|
151
152
|
root: {
|
|
152
153
|
alignSelf: "stretch"
|
|
153
154
|
},
|
|
@@ -324,13 +325,13 @@ function TextField({
|
|
|
324
325
|
const isControlled = value !== void 0;
|
|
325
326
|
const hasValue = isControlled ? value !== "" : internalHasText;
|
|
326
327
|
const isLabelFloated = isFocused || hasValue;
|
|
327
|
-
const labelAnimRef = (0, import_react.useRef)(new
|
|
328
|
+
const labelAnimRef = (0, import_react.useRef)(new import_react_native5.Animated.Value(isLabelFloated ? 1 : 0));
|
|
328
329
|
const labelAnim = labelAnimRef.current;
|
|
329
330
|
(0, import_react.useEffect)(() => {
|
|
330
|
-
|
|
331
|
+
import_react_native5.Animated.timing(labelAnim, {
|
|
331
332
|
toValue: isLabelFloated ? 1 : 0,
|
|
332
333
|
duration: 150,
|
|
333
|
-
useNativeDriver:
|
|
334
|
+
useNativeDriver: import_react_native5.Platform.OS !== "web"
|
|
334
335
|
}).start();
|
|
335
336
|
}, [isLabelFloated, labelAnim]);
|
|
336
337
|
const labelScale = (0, import_react.useMemo)(() => {
|
|
@@ -408,9 +409,9 @@ function TextField({
|
|
|
408
409
|
[styles, isFocused, isError, isDisabled]
|
|
409
410
|
);
|
|
410
411
|
const displaySupportingText = isError ? errorText : supportingText;
|
|
411
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
412
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
413
|
-
leadingIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native5.View, { style: [styles.root, style], children: [
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Pressable, { onPress: handleContainerPress, disabled: isDisabled, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native5.View, { style: containerStyle, children: [
|
|
414
|
+
leadingIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: styles.leadingIcon, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
414
415
|
MaterialCommunityIcons,
|
|
415
416
|
{
|
|
416
417
|
name: leadingIcon,
|
|
@@ -419,14 +420,14 @@ function TextField({
|
|
|
419
420
|
}
|
|
420
421
|
) }) : null,
|
|
421
422
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
422
|
-
|
|
423
|
+
import_react_native5.View,
|
|
423
424
|
{
|
|
424
425
|
style: [
|
|
425
426
|
styles.inputWrapper,
|
|
426
427
|
label ? styles.inputWrapperWithLabel : void 0
|
|
427
428
|
],
|
|
428
429
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
429
|
-
|
|
430
|
+
import_react_native5.TextInput,
|
|
430
431
|
{
|
|
431
432
|
ref: inputRef,
|
|
432
433
|
...textInputProps,
|
|
@@ -452,14 +453,14 @@ function TextField({
|
|
|
452
453
|
}
|
|
453
454
|
),
|
|
454
455
|
trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
455
|
-
|
|
456
|
+
import_react_native5.Pressable,
|
|
456
457
|
{
|
|
457
458
|
onPress: onTrailingIconPress,
|
|
458
459
|
disabled: isDisabled || !onTrailingIconPress,
|
|
459
460
|
accessibilityRole: "button",
|
|
460
461
|
hitSlop: 12,
|
|
461
462
|
style: styles.trailingIconPressable,
|
|
462
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
463
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: styles.trailingIcon, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
463
464
|
MaterialCommunityIcons,
|
|
464
465
|
{
|
|
465
466
|
name: trailingIcon,
|
|
@@ -470,7 +471,7 @@ function TextField({
|
|
|
470
471
|
}
|
|
471
472
|
) : null,
|
|
472
473
|
label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
473
|
-
|
|
474
|
+
import_react_native5.Animated.Text,
|
|
474
475
|
{
|
|
475
476
|
numberOfLines: 1,
|
|
476
477
|
style: [
|
|
@@ -490,10 +491,10 @@ function TextField({
|
|
|
490
491
|
children: label
|
|
491
492
|
}
|
|
492
493
|
) : null,
|
|
493
|
-
isFilled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
494
|
+
isFilled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: indicatorStyle }) : null
|
|
494
495
|
] }) }),
|
|
495
|
-
displaySupportingText ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
496
|
-
|
|
496
|
+
displaySupportingText ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: styles.supportingTextRow, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
497
|
+
import_react_native5.Text,
|
|
497
498
|
{
|
|
498
499
|
style: [
|
|
499
500
|
styles.supportingText,
|
package/llms.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @onlynative/components — MD3 UI Components for React Native
|
|
2
2
|
|
|
3
|
-
> Version: 0.
|
|
4
|
-
> Peer deps: @onlynative/core >=0.
|
|
3
|
+
> Version: 0.0.0-alpha.1
|
|
4
|
+
> Peer deps: @onlynative/core >=0.0.0-alpha.1, react >=18, react-native >=0.72, react-native-safe-area-context >=4
|
|
5
5
|
> Optional: @expo/vector-icons >=14 (only needed for icon props)
|
|
6
6
|
|
|
7
7
|
## Usage
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlynative/components",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
4
|
-
"description": "Material Design 3 UI components for React Native
|
|
3
|
+
"version": "0.0.0-alpha.1",
|
|
4
|
+
"description": "Material Design 3 UI components for React Native, part of OnlyNative UI.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -13,91 +13,76 @@
|
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"react-native": "./src/index.ts",
|
|
16
|
-
"browser": "./src/index.ts",
|
|
17
16
|
"default": "./dist/index.js"
|
|
18
17
|
},
|
|
19
18
|
"./typography": {
|
|
20
19
|
"types": "./dist/typography/index.d.ts",
|
|
21
20
|
"react-native": "./src/typography/index.ts",
|
|
22
|
-
"browser": "./src/typography/index.ts",
|
|
23
21
|
"default": "./dist/typography/index.js"
|
|
24
22
|
},
|
|
25
23
|
"./layout": {
|
|
26
24
|
"types": "./dist/layout/index.d.ts",
|
|
27
25
|
"react-native": "./src/layout/index.ts",
|
|
28
|
-
"browser": "./src/layout/index.ts",
|
|
29
26
|
"default": "./dist/layout/index.js"
|
|
30
27
|
},
|
|
31
28
|
"./button": {
|
|
32
29
|
"types": "./dist/button/index.d.ts",
|
|
33
30
|
"react-native": "./src/button/index.ts",
|
|
34
|
-
"browser": "./src/button/index.ts",
|
|
35
31
|
"default": "./dist/button/index.js"
|
|
36
32
|
},
|
|
37
33
|
"./icon-button": {
|
|
38
34
|
"types": "./dist/icon-button/index.d.ts",
|
|
39
35
|
"react-native": "./src/icon-button/index.ts",
|
|
40
|
-
"browser": "./src/icon-button/index.ts",
|
|
41
36
|
"default": "./dist/icon-button/index.js"
|
|
42
37
|
},
|
|
43
38
|
"./appbar": {
|
|
44
39
|
"types": "./dist/appbar/index.d.ts",
|
|
45
40
|
"react-native": "./src/appbar/index.ts",
|
|
46
|
-
"browser": "./src/appbar/index.ts",
|
|
47
41
|
"default": "./dist/appbar/index.js"
|
|
48
42
|
},
|
|
49
43
|
"./card": {
|
|
50
44
|
"types": "./dist/card/index.d.ts",
|
|
51
45
|
"react-native": "./src/card/index.ts",
|
|
52
|
-
"browser": "./src/card/index.ts",
|
|
53
46
|
"default": "./dist/card/index.js"
|
|
54
47
|
},
|
|
55
48
|
"./chip": {
|
|
56
49
|
"types": "./dist/chip/index.d.ts",
|
|
57
50
|
"react-native": "./src/chip/index.ts",
|
|
58
|
-
"browser": "./src/chip/index.ts",
|
|
59
51
|
"default": "./dist/chip/index.js"
|
|
60
52
|
},
|
|
61
53
|
"./checkbox": {
|
|
62
54
|
"types": "./dist/checkbox/index.d.ts",
|
|
63
55
|
"react-native": "./src/checkbox/index.ts",
|
|
64
|
-
"browser": "./src/checkbox/index.ts",
|
|
65
56
|
"default": "./dist/checkbox/index.js"
|
|
66
57
|
},
|
|
67
58
|
"./radio": {
|
|
68
59
|
"types": "./dist/radio/index.d.ts",
|
|
69
60
|
"react-native": "./src/radio/index.ts",
|
|
70
|
-
"browser": "./src/radio/index.ts",
|
|
71
61
|
"default": "./dist/radio/index.js"
|
|
72
62
|
},
|
|
73
63
|
"./switch": {
|
|
74
64
|
"types": "./dist/switch/index.d.ts",
|
|
75
65
|
"react-native": "./src/switch/index.ts",
|
|
76
|
-
"browser": "./src/switch/index.ts",
|
|
77
66
|
"default": "./dist/switch/index.js"
|
|
78
67
|
},
|
|
79
68
|
"./text-field": {
|
|
80
69
|
"types": "./dist/text-field/index.d.ts",
|
|
81
70
|
"react-native": "./src/text-field/index.ts",
|
|
82
|
-
"browser": "./src/text-field/index.ts",
|
|
83
71
|
"default": "./dist/text-field/index.js"
|
|
84
72
|
},
|
|
85
73
|
"./list": {
|
|
86
74
|
"types": "./dist/list/index.d.ts",
|
|
87
75
|
"react-native": "./src/list/index.ts",
|
|
88
|
-
"browser": "./src/list/index.ts",
|
|
89
76
|
"default": "./dist/list/index.js"
|
|
90
77
|
},
|
|
91
78
|
"./keyboard-avoiding-wrapper": {
|
|
92
79
|
"types": "./dist/keyboard-avoiding-wrapper/index.d.ts",
|
|
93
80
|
"react-native": "./src/keyboard-avoiding-wrapper/index.ts",
|
|
94
|
-
"browser": "./src/keyboard-avoiding-wrapper/index.ts",
|
|
95
81
|
"default": "./dist/keyboard-avoiding-wrapper/index.js"
|
|
96
82
|
},
|
|
97
83
|
"./avatar": {
|
|
98
84
|
"types": "./dist/avatar/index.d.ts",
|
|
99
85
|
"react-native": "./src/avatar/index.ts",
|
|
100
|
-
"browser": "./src/avatar/index.ts",
|
|
101
86
|
"default": "./dist/avatar/index.js"
|
|
102
87
|
}
|
|
103
88
|
},
|
|
@@ -175,7 +160,7 @@
|
|
|
175
160
|
},
|
|
176
161
|
"peerDependencies": {
|
|
177
162
|
"@expo/vector-icons": ">=14.0.0",
|
|
178
|
-
"@onlynative/core": ">=0.0.0-alpha.
|
|
163
|
+
"@onlynative/core": ">=0.0.0-alpha.1",
|
|
179
164
|
"react": ">=18.0.0",
|
|
180
165
|
"react-native": ">=0.72.0",
|
|
181
166
|
"react-native-safe-area-context": ">=4.0.0"
|