@tamagui/list-item 2.0.0-rc.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ListItem.cjs +219 -204
- package/dist/cjs/ListItem.native.js +225 -213
- package/dist/cjs/ListItem.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/ListItem.mjs +198 -185
- package/dist/esm/ListItem.mjs.map +1 -1
- package/dist/esm/ListItem.native.js +205 -195
- package/dist/esm/ListItem.native.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/jsx/ListItem.mjs +198 -185
- package/dist/jsx/ListItem.mjs.map +1 -1
- package/dist/jsx/ListItem.native.js +225 -213
- package/dist/jsx/ListItem.native.js.map +1 -1
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/package.json +13 -16
- package/src/ListItem.tsx +15 -11
- package/types/ListItem.d.ts.map +1 -1
- package/dist/cjs/ListItem.js +0 -203
- package/dist/cjs/ListItem.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/esm/ListItem.js +0 -195
- package/dist/esm/ListItem.js.map +0 -6
- package/dist/jsx/ListItem.js +0 -195
- package/dist/jsx/ListItem.js.map +0 -6
package/dist/cjs/ListItem.cjs
CHANGED
|
@@ -3,239 +3,254 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var ListItem_exports = {};
|
|
22
24
|
__export(ListItem_exports, {
|
|
23
25
|
ListItem: () => ListItem2
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(ListItem_exports);
|
|
26
|
-
var import_font_size = require("@tamagui/font-size")
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const NAME = "ListItem"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
28
|
+
var import_font_size = require("@tamagui/font-size");
|
|
29
|
+
var import_get_font_sized = require("@tamagui/get-font-sized");
|
|
30
|
+
var import_get_token = require("@tamagui/get-token");
|
|
31
|
+
var import_helpers = require("@tamagui/helpers");
|
|
32
|
+
var import_helpers_tamagui = require("@tamagui/helpers-tamagui");
|
|
33
|
+
var import_stacks = require("@tamagui/stacks");
|
|
34
|
+
var import_text = require("@tamagui/text");
|
|
35
|
+
var import_web = require("@tamagui/web");
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
const NAME = "ListItem";
|
|
38
|
+
const context = (0, import_web.createStyledContext)({
|
|
39
|
+
size: void 0,
|
|
40
|
+
variant: void 0,
|
|
41
|
+
color: void 0
|
|
42
|
+
});
|
|
43
|
+
const ListItemFrame = (0, import_web.styled)(import_web.View, {
|
|
44
|
+
context,
|
|
45
|
+
name: NAME,
|
|
46
|
+
render: "li",
|
|
47
|
+
role: "listitem",
|
|
48
|
+
variants: {
|
|
49
|
+
unstyled: {
|
|
50
|
+
false: {
|
|
51
|
+
size: "$true",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
justifyContent: "space-between",
|
|
54
|
+
flexWrap: "nowrap",
|
|
55
|
+
borderColor: "$borderColor",
|
|
56
|
+
width: "100%",
|
|
57
|
+
maxWidth: "100%",
|
|
58
|
+
overflow: "hidden",
|
|
59
|
+
flexDirection: "row",
|
|
60
|
+
backgroundColor: "$background",
|
|
61
|
+
cursor: "default",
|
|
62
|
+
hoverStyle: {
|
|
63
|
+
backgroundColor: "$backgroundHover",
|
|
64
|
+
borderColor: "$borderColorHover"
|
|
65
|
+
},
|
|
66
|
+
pressStyle: {
|
|
67
|
+
backgroundColor: "$backgroundPress",
|
|
68
|
+
borderColor: "$borderColorPress"
|
|
68
69
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
variant: {
|
|
73
|
+
outlined: process.env.TAMAGUI_HEADLESS === "1" ? {} : {
|
|
74
|
+
backgroundColor: "transparent",
|
|
75
|
+
borderWidth: 1,
|
|
76
|
+
borderColor: "$borderColor",
|
|
77
|
+
hoverStyle: {
|
|
78
|
+
backgroundColor: "transparent",
|
|
79
|
+
borderColor: "$borderColorHover"
|
|
80
|
+
},
|
|
81
|
+
pressStyle: {
|
|
72
82
|
backgroundColor: "transparent",
|
|
73
|
-
|
|
74
|
-
borderColor: "$borderColor",
|
|
75
|
-
hoverStyle: {
|
|
76
|
-
backgroundColor: "transparent",
|
|
77
|
-
borderColor: "$borderColorHover"
|
|
78
|
-
},
|
|
79
|
-
pressStyle: {
|
|
80
|
-
backgroundColor: "transparent",
|
|
81
|
-
borderColor: "$borderColorPress"
|
|
82
|
-
}
|
|
83
|
+
borderColor: "$borderColorPress"
|
|
83
84
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
size: {
|
|
88
|
+
"...size": (val, {
|
|
89
|
+
tokens
|
|
90
|
+
}) => {
|
|
91
|
+
return {
|
|
89
92
|
minHeight: tokens.size[val],
|
|
90
93
|
paddingHorizontal: tokens.space[val],
|
|
91
94
|
paddingVertical: (0, import_get_token.getSpace)(tokens.space[val], {
|
|
92
95
|
shift: -4
|
|
93
96
|
})
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
active: {
|
|
97
|
-
true: {
|
|
98
|
-
hoverStyle: {
|
|
99
|
-
backgroundColor: "$background"
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
disabled: {
|
|
104
|
-
true: {
|
|
105
|
-
opacity: 0.5,
|
|
106
|
-
pointerEvents: "none"
|
|
107
|
-
}
|
|
97
|
+
};
|
|
108
98
|
}
|
|
109
99
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
ListItemText = (0, import_web.styled)(import_text.SizableText, {
|
|
115
|
-
context,
|
|
116
|
-
name: "ListItemText",
|
|
117
|
-
variants: {
|
|
118
|
-
unstyled: {
|
|
119
|
-
false: {
|
|
120
|
-
color: "$color",
|
|
121
|
-
size: "$true",
|
|
122
|
-
flexGrow: 1,
|
|
123
|
-
flexShrink: 1,
|
|
124
|
-
ellipsis: !0,
|
|
125
|
-
cursor: "inherit"
|
|
100
|
+
active: {
|
|
101
|
+
true: {
|
|
102
|
+
hoverStyle: {
|
|
103
|
+
backgroundColor: "$background"
|
|
126
104
|
}
|
|
127
105
|
}
|
|
128
106
|
},
|
|
129
|
-
|
|
130
|
-
|
|
107
|
+
disabled: {
|
|
108
|
+
true: {
|
|
109
|
+
opacity: 0.5,
|
|
110
|
+
pointerEvents: "none"
|
|
111
|
+
}
|
|
131
112
|
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
150
|
-
return (0, import_get_font_sized.getFontSized)(oneSmaller.key, extras);
|
|
151
|
-
}
|
|
113
|
+
},
|
|
114
|
+
defaultVariants: {
|
|
115
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const ListItemText = (0, import_web.styled)(import_text.SizableText, {
|
|
119
|
+
context,
|
|
120
|
+
name: "ListItemText",
|
|
121
|
+
variants: {
|
|
122
|
+
unstyled: {
|
|
123
|
+
false: {
|
|
124
|
+
color: "$color",
|
|
125
|
+
size: "$true",
|
|
126
|
+
flexGrow: 1,
|
|
127
|
+
flexShrink: 1,
|
|
128
|
+
ellipsis: true,
|
|
129
|
+
cursor: "inherit"
|
|
152
130
|
}
|
|
153
|
-
},
|
|
154
|
-
defaultVariants: {
|
|
155
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
156
131
|
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
132
|
+
},
|
|
133
|
+
defaultVariants: {
|
|
134
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
const ListItemSubtitle = (0, import_web.styled)(ListItemText, {
|
|
138
|
+
name: "ListItemSubtitle",
|
|
139
|
+
context,
|
|
140
|
+
variants: {
|
|
141
|
+
unstyled: {
|
|
142
|
+
false: {
|
|
143
|
+
opacity: 0.6,
|
|
144
|
+
maxWidth: "100%",
|
|
145
|
+
color: "$color"
|
|
164
146
|
}
|
|
165
147
|
},
|
|
166
|
-
|
|
167
|
-
|
|
148
|
+
size: {
|
|
149
|
+
"...size": (val, extras) => {
|
|
150
|
+
const oneSmaller = (0, import_get_token.getSize)(val, {
|
|
151
|
+
shift: -1,
|
|
152
|
+
excludeHalfSteps: true
|
|
153
|
+
});
|
|
154
|
+
const fontStyle = (0, import_get_font_sized.getFontSized)(oneSmaller.key, extras);
|
|
155
|
+
return fontStyle;
|
|
156
|
+
}
|
|
168
157
|
}
|
|
169
|
-
}),
|
|
170
|
-
ListItemIcon = props => {
|
|
171
|
-
const {
|
|
172
|
-
children,
|
|
173
|
-
size,
|
|
174
|
-
scaleIcon = 1
|
|
175
|
-
} = props,
|
|
176
|
-
styledContext = context.useStyledContext();
|
|
177
|
-
if (!styledContext) throw new Error("ListItem.Icon must be used within a ListItem");
|
|
178
|
-
const sizeToken = size ?? styledContext.size ?? "$true",
|
|
179
|
-
iconSize = (0, import_font_size.getFontSize)(sizeToken) * scaleIcon;
|
|
180
|
-
return (0, import_helpers_tamagui.getIcon)(children, {
|
|
181
|
-
size: iconSize,
|
|
182
|
-
color: styledContext.color
|
|
183
|
-
});
|
|
184
158
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
159
|
+
defaultVariants: {
|
|
160
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
const ListItemTitle = (0, import_web.styled)(ListItemText, {
|
|
164
|
+
name: "ListItemTitle",
|
|
165
|
+
context,
|
|
166
|
+
variants: {
|
|
167
|
+
unstyled: {
|
|
168
|
+
false: {}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
defaultVariants: {
|
|
172
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
const ListItemIcon = props => {
|
|
176
|
+
const {
|
|
177
|
+
children,
|
|
178
|
+
size,
|
|
179
|
+
scaleIcon = 1
|
|
180
|
+
} = props;
|
|
181
|
+
const styledContext = context.useStyledContext();
|
|
182
|
+
if (!styledContext) {
|
|
183
|
+
throw new Error("ListItem.Icon must be used within a ListItem");
|
|
184
|
+
}
|
|
185
|
+
const sizeToken = size ?? styledContext.size ?? "$true";
|
|
186
|
+
const iconColor = (0, import_helpers_tamagui.useCurrentColor)(styledContext.color);
|
|
187
|
+
const iconSize = (0, import_font_size.getFontSize)(sizeToken) * scaleIcon;
|
|
188
|
+
return (0, import_helpers_tamagui.getIcon)(children, {
|
|
189
|
+
size: iconSize,
|
|
190
|
+
color: iconColor
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
const ListItemComponent = ListItemFrame.styleable(function ListItem(propsIn, ref) {
|
|
194
|
+
const {
|
|
195
|
+
children,
|
|
196
|
+
icon,
|
|
197
|
+
iconAfter,
|
|
198
|
+
scaleIcon = 1,
|
|
199
|
+
unstyled = false,
|
|
200
|
+
subTitle,
|
|
201
|
+
title,
|
|
202
|
+
iconSize,
|
|
203
|
+
...rest
|
|
204
|
+
} = propsIn;
|
|
205
|
+
const size = propsIn.size || "$true";
|
|
206
|
+
const styledContext = context.useStyledContext();
|
|
207
|
+
const iconColor = (0, import_helpers_tamagui.useCurrentColor)(styledContext?.color);
|
|
208
|
+
const iconSizeNumber = (0, import_font_size.getFontSize)(iconSize || size) * scaleIcon;
|
|
209
|
+
const iconSpacing = iconSizeNumber * 0.4;
|
|
210
|
+
const themedIcon = icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_web.View, {
|
|
211
|
+
marginRight: iconSpacing,
|
|
212
|
+
children: (0, import_helpers_tamagui.getIcon)(icon, {
|
|
213
|
+
size: iconSizeNumber,
|
|
214
|
+
color: iconColor
|
|
215
|
+
})
|
|
216
|
+
}) : null;
|
|
217
|
+
const themedIconAfter = iconAfter ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_web.View, {
|
|
218
|
+
marginLeft: iconSpacing,
|
|
219
|
+
children: (0, import_helpers_tamagui.getIcon)(iconAfter, {
|
|
220
|
+
size: iconSizeNumber,
|
|
221
|
+
color: iconColor
|
|
222
|
+
})
|
|
223
|
+
}) : null;
|
|
224
|
+
const wrappedChildren = (0, import_text.wrapChildrenInText)(ListItemText, {
|
|
225
|
+
children
|
|
226
|
+
}, propsIn.unstyled !== true ? {
|
|
227
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1",
|
|
228
|
+
fontSize: propsIn.size
|
|
229
|
+
} : void 0);
|
|
230
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(ListItemFrame, {
|
|
231
|
+
ref,
|
|
232
|
+
...rest,
|
|
233
|
+
children: [themedIcon, title || subTitle ? /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_stacks.YStack, {
|
|
234
|
+
flex: 1,
|
|
235
|
+
children: [title ? typeof title === "string" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ListItemTitle, {
|
|
236
|
+
unstyled,
|
|
237
|
+
size,
|
|
238
|
+
children: title
|
|
239
|
+
}) : title : null, subTitle ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
240
|
+
children: typeof subTitle === "string" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ListItemSubtitle, {
|
|
221
241
|
unstyled,
|
|
222
242
|
size,
|
|
223
|
-
children:
|
|
224
|
-
}) :
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
Text: ListItemText,
|
|
238
|
-
Subtitle: ListItemSubtitle,
|
|
239
|
-
Icon: ListItemIcon,
|
|
240
|
-
Title: ListItemTitle
|
|
241
|
-
});
|
|
243
|
+
children: subTitle
|
|
244
|
+
}) : subTitle
|
|
245
|
+
}) : null, wrappedChildren]
|
|
246
|
+
}) : wrappedChildren, themedIconAfter]
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
const ListItem2 = (0, import_helpers.withStaticProperties)(ListItemComponent, {
|
|
250
|
+
Apply: context.Provider,
|
|
251
|
+
Frame: ListItemFrame,
|
|
252
|
+
Text: ListItemText,
|
|
253
|
+
Subtitle: ListItemSubtitle,
|
|
254
|
+
Icon: ListItemIcon,
|
|
255
|
+
Title: ListItemTitle
|
|
256
|
+
});
|