@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.
@@ -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
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
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
- import_get_font_sized = require("@tamagui/get-font-sized"),
28
- import_get_token = require("@tamagui/get-token"),
29
- import_helpers = require("@tamagui/helpers"),
30
- import_helpers_tamagui = require("@tamagui/helpers-tamagui"),
31
- import_stacks = require("@tamagui/stacks"),
32
- import_text = require("@tamagui/text"),
33
- import_web = require("@tamagui/web"),
34
- import_jsx_runtime = require("react/jsx-runtime");
35
- const NAME = "ListItem",
36
- context = (0, import_web.createStyledContext)({
37
- size: void 0,
38
- variant: void 0,
39
- color: void 0
40
- }),
41
- ListItemFrame = (0, import_web.styled)(import_web.View, {
42
- context,
43
- name: NAME,
44
- render: "li",
45
- role: "listitem",
46
- variants: {
47
- unstyled: {
48
- false: {
49
- size: "$true",
50
- alignItems: "center",
51
- justifyContent: "space-between",
52
- flexWrap: "nowrap",
53
- borderColor: "$borderColor",
54
- width: "100%",
55
- maxWidth: "100%",
56
- overflow: "hidden",
57
- flexDirection: "row",
58
- backgroundColor: "$background",
59
- cursor: "default",
60
- hoverStyle: {
61
- backgroundColor: "$backgroundHover",
62
- borderColor: "$borderColorHover"
63
- },
64
- pressStyle: {
65
- backgroundColor: "$backgroundPress",
66
- borderColor: "$borderColorPress"
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
- variant: {
71
- outlined: process.env.TAMAGUI_HEADLESS === "1" ? {} : {
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
- borderWidth: 1,
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
- size: {
86
- "...size": (val, {
87
- tokens
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
- defaultVariants: {
111
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
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
- defaultVariants: {
130
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
107
+ disabled: {
108
+ true: {
109
+ opacity: 0.5,
110
+ pointerEvents: "none"
111
+ }
131
112
  }
132
- }),
133
- ListItemSubtitle = (0, import_web.styled)(ListItemText, {
134
- name: "ListItemSubtitle",
135
- context,
136
- variants: {
137
- unstyled: {
138
- false: {
139
- opacity: 0.6,
140
- maxWidth: "100%",
141
- color: "$color"
142
- }
143
- },
144
- size: {
145
- "...size": (val, extras) => {
146
- const oneSmaller = (0, import_get_token.getSize)(val, {
147
- shift: -1,
148
- excludeHalfSteps: !0
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
- ListItemTitle = (0, import_web.styled)(ListItemText, {
159
- name: "ListItemTitle",
160
- context,
161
- variants: {
162
- unstyled: {
163
- false: {}
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
- defaultVariants: {
167
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
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
- ListItemComponent = ListItemFrame.styleable(function (propsIn, ref) {
186
- const {
187
- children,
188
- icon,
189
- iconAfter,
190
- scaleIcon = 1,
191
- unstyled = !1,
192
- subTitle,
193
- title,
194
- iconSize,
195
- ...rest
196
- } = propsIn,
197
- size = propsIn.size || "$true",
198
- styledContext = context.useStyledContext(),
199
- iconSizeNumber = (0, import_font_size.getFontSize)(iconSize || size) * scaleIcon,
200
- [themedIcon, themedIconAfter] = [icon, iconAfter].map((icon2, i) => {
201
- if (!icon2) return null;
202
- const isBefore = i === 0;
203
- return (0, import_helpers_tamagui.getIcon)(icon2, {
204
- size: iconSizeNumber,
205
- color: styledContext?.color,
206
- [isBefore ? "marginRight" : "marginLeft"]: `${iconSizeNumber * 0.4}%`
207
- });
208
- }),
209
- wrappedChildren = (0, import_text.wrapChildrenInText)(ListItemText, {
210
- children
211
- }, propsIn.unstyled !== !0 ? {
212
- unstyled: process.env.TAMAGUI_HEADLESS === "1",
213
- fontSize: propsIn.size
214
- } : void 0);
215
- return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(ListItemFrame, {
216
- ref,
217
- ...rest,
218
- children: [themedIcon, title || subTitle ? /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_stacks.YStack, {
219
- flex: 1,
220
- children: [title ? typeof title == "string" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ListItemTitle, {
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: title
224
- }) : title : null, subTitle ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
225
- children: typeof subTitle == "string" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ListItemSubtitle, {
226
- unstyled,
227
- size,
228
- children: subTitle
229
- }) : subTitle
230
- }) : null, wrappedChildren]
231
- }) : wrappedChildren, themedIconAfter]
232
- });
233
- }),
234
- ListItem2 = (0, import_helpers.withStaticProperties)(ListItemComponent, {
235
- Apply: context.Provider,
236
- Frame: ListItemFrame,
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
+ });