@tamagui/list-item 1.0.1-beta.100
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/Button.js +249 -0
- package/dist/cjs/Button.js.map +7 -0
- package/dist/cjs/ListItem.js +203 -0
- package/dist/cjs/ListItem.js.map +7 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/useCurrentColor.js +41 -0
- package/dist/cjs/useCurrentColor.js.map +7 -0
- package/dist/cjs/useGetThemedIcon.js +45 -0
- package/dist/cjs/useGetThemedIcon.js.map +7 -0
- package/dist/cjs/wrapStringChildrenInText.js +111 -0
- package/dist/cjs/wrapStringChildrenInText.js.map +7 -0
- package/dist/esm/Button.js +190 -0
- package/dist/esm/Button.js.map +7 -0
- package/dist/esm/ListItem.js +183 -0
- package/dist/esm/ListItem.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/useCurrentColor.js +19 -0
- package/dist/esm/useCurrentColor.js.map +7 -0
- package/dist/esm/useGetThemedIcon.js +20 -0
- package/dist/esm/useGetThemedIcon.js.map +7 -0
- package/dist/esm/wrapStringChildrenInText.js +53 -0
- package/dist/esm/wrapStringChildrenInText.js.map +7 -0
- package/dist/jsx/Button.js +177 -0
- package/dist/jsx/ListItem.js +139 -0
- package/dist/jsx/ListItem.js.map +7 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +7 -0
- package/dist/jsx/useCurrentColor.js +18 -0
- package/dist/jsx/useGetThemedIcon.js +19 -0
- package/dist/jsx/wrapStringChildrenInText.js +47 -0
- package/package.json +39 -0
- package/src/ListItem.tsx +200 -0
- package/src/index.ts +1 -0
- package/types/Button.d.ts +127 -0
- package/types/Button.d.ts.map +1 -0
- package/types/ListItem.d.ts +278 -0
- package/types/ListItem.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
- package/types/useCurrentColor.d.ts +5 -0
- package/types/useCurrentColor.d.ts.map +1 -0
- package/types/useGetThemedIcon.d.ts +6 -0
- package/types/useGetThemedIcon.d.ts.map +1 -0
- package/types/wrapStringChildrenInText.d.ts +8 -0
- package/types/wrapStringChildrenInText.d.ts.map +1 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
50
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
51
|
+
var wrapStringChildrenInText_exports = {};
|
|
52
|
+
__export(wrapStringChildrenInText_exports, {
|
|
53
|
+
wrapStringChildrenInText: () => wrapStringChildrenInText
|
|
54
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(wrapStringChildrenInText_exports);
|
|
56
|
+
var import_react = __toESM(require("react"));
|
|
57
|
+
var import_ListItem = require("./ListItem");
|
|
58
|
+
function wrapStringChildrenInText(_a) {
|
|
59
|
+
var _b = _a, {
|
|
60
|
+
children,
|
|
61
|
+
textProps,
|
|
62
|
+
size,
|
|
63
|
+
noTextWrap
|
|
64
|
+
} = _b, directTextProps = __objRest(_b, [
|
|
65
|
+
"children",
|
|
66
|
+
"textProps",
|
|
67
|
+
"size",
|
|
68
|
+
"noTextWrap"
|
|
69
|
+
]);
|
|
70
|
+
if (noTextWrap || !children) {
|
|
71
|
+
return children;
|
|
72
|
+
}
|
|
73
|
+
let allChildren = import_react.default.Children.toArray(children);
|
|
74
|
+
let nextChildren = [];
|
|
75
|
+
let lastIsString = false;
|
|
76
|
+
function concatStringChildren() {
|
|
77
|
+
if (!lastIsString)
|
|
78
|
+
return;
|
|
79
|
+
const index = nextChildren.length - 1;
|
|
80
|
+
const childrenStrings = nextChildren[index];
|
|
81
|
+
nextChildren[index] = /* @__PURE__ */ import_react.default.createElement(import_ListItem.ListItemText, __spreadValues(__spreadProps(__spreadValues({
|
|
82
|
+
key: index
|
|
83
|
+
}, directTextProps), {
|
|
84
|
+
size
|
|
85
|
+
}), textProps), childrenStrings);
|
|
86
|
+
}
|
|
87
|
+
__name(concatStringChildren, "concatStringChildren");
|
|
88
|
+
for (const child of allChildren) {
|
|
89
|
+
const last = nextChildren[nextChildren.length - 1];
|
|
90
|
+
const isString = typeof child === "string";
|
|
91
|
+
if (isString) {
|
|
92
|
+
if (lastIsString) {
|
|
93
|
+
last.push(child);
|
|
94
|
+
} else {
|
|
95
|
+
nextChildren.push([child]);
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
concatStringChildren();
|
|
99
|
+
nextChildren.push(child);
|
|
100
|
+
}
|
|
101
|
+
lastIsString = isString;
|
|
102
|
+
}
|
|
103
|
+
concatStringChildren();
|
|
104
|
+
return nextChildren;
|
|
105
|
+
}
|
|
106
|
+
__name(wrapStringChildrenInText, "wrapStringChildrenInText");
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
wrapStringChildrenInText
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=wrapStringChildrenInText.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapStringChildrenInText.tsx"],
|
|
4
|
+
"sourcesContent": ["import { SizeTokens } from '@tamagui/core'\nimport React from 'react'\n\nimport { ListItemText, TextOnlyStyles } from './ListItem'\n\nexport function wrapStringChildrenInText({\n children,\n textProps,\n size,\n noTextWrap,\n ...directTextProps\n}: TextOnlyStyles & { children?: React.ReactNode; size?: SizeTokens }) {\n if (noTextWrap || !children) {\n return children\n }\n\n // in the case of using variables, like so:\n // <ListItem>Hello, {name}</ListItem>\n // it gives us props.children as ['Hello, ', 'name']\n // but we don't want to wrap multiple SizableText around each part\n // so we group them\n let allChildren = React.Children.toArray(children)\n let nextChildren: any[] = []\n let lastIsString = false\n\n function concatStringChildren() {\n if (!lastIsString) return\n const index = nextChildren.length - 1\n const childrenStrings = nextChildren[index]\n nextChildren[index] = (\n <ListItemText key={index} {...directTextProps} size={size} {...textProps}>\n {childrenStrings}\n </ListItemText>\n )\n }\n\n for (const child of allChildren) {\n const last = nextChildren[nextChildren.length - 1]\n const isString = typeof child === 'string'\n if (isString) {\n if (lastIsString) {\n last.push(child)\n } else {\n nextChildren.push([child])\n }\n } else {\n concatStringChildren()\n nextChildren.push(child)\n }\n lastIsString = isString\n }\n concatStringChildren()\n\n return nextChildren\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAElB,sBAA6C;AAEtC,kCAAkC,IAM8B;AAN9B,eACvC;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAJuC,IAKpC,4BALoC,IAKpC;AAAA,IAJH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,MAAI,cAAc,CAAC,UAAU;AAC3B,WAAO;AAAA,EACT;AAOA,MAAI,cAAc,qBAAM,SAAS,QAAQ,QAAQ;AACjD,MAAI,eAAsB,CAAC;AAC3B,MAAI,eAAe;AAEnB,kCAAgC;AAC9B,QAAI,CAAC;AAAc;AACnB,UAAM,QAAQ,aAAa,SAAS;AACpC,UAAM,kBAAkB,aAAa;AACrC,iBAAa,SACX,mDAAC;AAAA,MAAa,KAAK;AAAA,OAAW,kBAA7B;AAAA,MAA8C;AAAA,QAAgB,YAC5D,eACH;AAAA,EAEJ;AATS;AAWT,aAAW,SAAS,aAAa;AAC/B,UAAM,OAAO,aAAa,aAAa,SAAS;AAChD,UAAM,WAAW,OAAO,UAAU;AAClC,QAAI,UAAU;AACZ,UAAI,cAAc;AAChB,aAAK,KAAK,KAAK;AAAA,MACjB,OAAO;AACL,qBAAa,KAAK,CAAC,KAAK,CAAC;AAAA,MAC3B;AAAA,IACF,OAAO;AACL,2BAAqB;AACrB,mBAAa,KAAK,KAAK;AAAA,IACzB;AACA,mBAAe;AAAA,EACjB;AACA,uBAAqB;AAErB,SAAO;AACT;AAjDgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import {
|
|
4
|
+
ButtonInsideButtonContext,
|
|
5
|
+
getButtonSize,
|
|
6
|
+
getVariableValue,
|
|
7
|
+
spacedChildren,
|
|
8
|
+
styled,
|
|
9
|
+
themeable,
|
|
10
|
+
useTheme
|
|
11
|
+
} from "@tamagui/core";
|
|
12
|
+
import { getFontSize } from "@tamagui/font-size";
|
|
13
|
+
import { ThemeableStack } from "@tamagui/stacks";
|
|
14
|
+
import { SizableText } from "@tamagui/text";
|
|
15
|
+
import React, { forwardRef, isValidElement, useContext } from "react";
|
|
16
|
+
React["createElement"];
|
|
17
|
+
const ButtonFrame = styled(ThemeableStack, {
|
|
18
|
+
name: "Button",
|
|
19
|
+
tag: "button",
|
|
20
|
+
hoverable: true,
|
|
21
|
+
pressable: true,
|
|
22
|
+
backgrounded: true,
|
|
23
|
+
borderWidth: 1,
|
|
24
|
+
borderColor: "transparent",
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
flexWrap: "nowrap",
|
|
28
|
+
flexDirection: "row",
|
|
29
|
+
cursor: "pointer",
|
|
30
|
+
pressStyle: {
|
|
31
|
+
borderColor: "transparent"
|
|
32
|
+
},
|
|
33
|
+
hoverStyle: {
|
|
34
|
+
borderColor: "transparent"
|
|
35
|
+
},
|
|
36
|
+
focusStyle: {
|
|
37
|
+
borderColor: "$borderColorFocus"
|
|
38
|
+
},
|
|
39
|
+
variants: {
|
|
40
|
+
size: {
|
|
41
|
+
"...size": getButtonSize
|
|
42
|
+
},
|
|
43
|
+
active: {
|
|
44
|
+
true: {
|
|
45
|
+
hoverStyle: {
|
|
46
|
+
backgroundColor: "$background"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
disabled: {
|
|
51
|
+
true: {
|
|
52
|
+
opacity: 0.5,
|
|
53
|
+
pointerEvents: "none"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
size: "$4"
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const ButtonText = styled(SizableText, {
|
|
62
|
+
color: "$color",
|
|
63
|
+
selectable: false,
|
|
64
|
+
flexGrow: 1,
|
|
65
|
+
flexShrink: 1,
|
|
66
|
+
ellipse: true
|
|
67
|
+
});
|
|
68
|
+
const ButtonComponent = forwardRef((props, ref) => {
|
|
69
|
+
const {
|
|
70
|
+
children,
|
|
71
|
+
icon,
|
|
72
|
+
iconAfter,
|
|
73
|
+
noTextWrap,
|
|
74
|
+
theme: themeName,
|
|
75
|
+
space,
|
|
76
|
+
spaceFlex,
|
|
77
|
+
scaleIcon = 1,
|
|
78
|
+
scaleSpace = 0.5,
|
|
79
|
+
color: colorProp,
|
|
80
|
+
fontWeight,
|
|
81
|
+
letterSpacing,
|
|
82
|
+
fontSize,
|
|
83
|
+
fontFamily,
|
|
84
|
+
textAlign,
|
|
85
|
+
textProps,
|
|
86
|
+
...rest
|
|
87
|
+
} = props;
|
|
88
|
+
const isInsideButton = useContext(ButtonInsideButtonContext);
|
|
89
|
+
const theme = useTheme();
|
|
90
|
+
const size = props.size || "$4";
|
|
91
|
+
let color;
|
|
92
|
+
if (theme && colorProp && colorProp in theme) {
|
|
93
|
+
color = theme[colorProp];
|
|
94
|
+
} else if (colorProp) {
|
|
95
|
+
color = colorProp;
|
|
96
|
+
} else {
|
|
97
|
+
color = theme == null ? void 0 : theme.color;
|
|
98
|
+
}
|
|
99
|
+
color = color == null ? void 0 : color.toString();
|
|
100
|
+
const iconSize = getFontSize(size) * scaleIcon;
|
|
101
|
+
const addTheme = /* @__PURE__ */ __name((el) => {
|
|
102
|
+
if (isValidElement(el)) {
|
|
103
|
+
return el;
|
|
104
|
+
}
|
|
105
|
+
if (el) {
|
|
106
|
+
return React.createElement(el, {
|
|
107
|
+
color,
|
|
108
|
+
size: iconSize
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return el;
|
|
112
|
+
}, "addTheme");
|
|
113
|
+
const themedIcon = icon ? addTheme(icon) : null;
|
|
114
|
+
const themedIconAfter = iconAfter ? addTheme(iconAfter) : null;
|
|
115
|
+
let contents = children;
|
|
116
|
+
if (!noTextWrap && children) {
|
|
117
|
+
let concatStringChildren = function() {
|
|
118
|
+
if (!lastIsString)
|
|
119
|
+
return;
|
|
120
|
+
const index = nextChildren.length - 1;
|
|
121
|
+
const childrenStrings = nextChildren[index];
|
|
122
|
+
nextChildren[index] = /* @__PURE__ */ React.createElement(ButtonText, {
|
|
123
|
+
key: index,
|
|
124
|
+
...{
|
|
125
|
+
fontWeight,
|
|
126
|
+
letterSpacing,
|
|
127
|
+
fontSize,
|
|
128
|
+
fontFamily,
|
|
129
|
+
textAlign,
|
|
130
|
+
size
|
|
131
|
+
},
|
|
132
|
+
...colorProp && {
|
|
133
|
+
color: colorProp
|
|
134
|
+
},
|
|
135
|
+
...textProps
|
|
136
|
+
}, childrenStrings);
|
|
137
|
+
};
|
|
138
|
+
__name(concatStringChildren, "concatStringChildren");
|
|
139
|
+
let allChildren = React.Children.toArray(children);
|
|
140
|
+
let nextChildren = [];
|
|
141
|
+
let lastIsString = false;
|
|
142
|
+
for (const child of allChildren) {
|
|
143
|
+
const last = nextChildren[nextChildren.length - 1];
|
|
144
|
+
const isString = typeof child === "string";
|
|
145
|
+
if (isString) {
|
|
146
|
+
if (lastIsString) {
|
|
147
|
+
last.push(child);
|
|
148
|
+
} else {
|
|
149
|
+
nextChildren.push([child]);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
concatStringChildren();
|
|
153
|
+
nextChildren.push(child);
|
|
154
|
+
}
|
|
155
|
+
lastIsString = isString;
|
|
156
|
+
}
|
|
157
|
+
concatStringChildren();
|
|
158
|
+
contents = nextChildren;
|
|
159
|
+
}
|
|
160
|
+
return /* @__PURE__ */ React.createElement(ButtonInsideButtonContext.Provider, {
|
|
161
|
+
value: true
|
|
162
|
+
}, /* @__PURE__ */ React.createElement(ButtonFrame, {
|
|
163
|
+
fontFamily,
|
|
164
|
+
...isInsideButton && {
|
|
165
|
+
tag: "span"
|
|
166
|
+
},
|
|
167
|
+
ref,
|
|
168
|
+
...rest
|
|
169
|
+
}, themedIcon || themedIconAfter ? spacedChildren({
|
|
170
|
+
space: getVariableValue(iconSize) * scaleSpace,
|
|
171
|
+
spaceFlex,
|
|
172
|
+
direction: props.flexDirection || "row",
|
|
173
|
+
children: [themedIcon, contents, themedIconAfter]
|
|
174
|
+
}) : contents));
|
|
175
|
+
});
|
|
176
|
+
const Button = ButtonFrame.extractable(themeable(ButtonComponent), {
|
|
177
|
+
inlineProps: /* @__PURE__ */ new Set([
|
|
178
|
+
"color",
|
|
179
|
+
"fontWeight",
|
|
180
|
+
"fontSize",
|
|
181
|
+
"fontFamily",
|
|
182
|
+
"letterSpacing",
|
|
183
|
+
"textAlign"
|
|
184
|
+
])
|
|
185
|
+
});
|
|
186
|
+
export {
|
|
187
|
+
Button,
|
|
188
|
+
ButtonText
|
|
189
|
+
};
|
|
190
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Button.tsx"],
|
|
4
|
+
"sourcesContent": ["import {\n ButtonInsideButtonContext,\n GetProps,\n ReactComponentWithRef,\n ThemeableProps,\n getButtonSize,\n getVariableValue,\n spacedChildren,\n styled,\n themeable,\n useTheme,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, SizableTextProps } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef, isValidElement, useContext } from 'react'\nimport { View } from 'react-native'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n // add icon before, passes color and size automatically if Component\n icon?: IconProp\n // add icon after, passes color and size automatically if Component\n iconAfter?: IconProp\n // adjust icon relative to size\n // default: -1\n scaleIcon?: number\n // dont wrap inner contents in a text element\n noTextWrap?: boolean\n // make the spacing elements flex\n spaceFlex?: number | boolean\n // adjust internal space relative to icon size\n scaleSpace?: number\n\n // pass text properties:\n color?: SizableTextProps['color']\n fontWeight?: SizableTextProps['fontWeight']\n fontSize?: SizableTextProps['fontSize']\n fontFamily?: SizableTextProps['fontFamily']\n letterSpacing?: SizableTextProps['letterSpacing']\n textAlign?: SizableTextProps['textAlign']\n\n // all the other text controls\n textProps?: Partial<SizableTextProps>\n }\n\nconst ButtonFrame = styled(ThemeableStack, {\n name: 'Button',\n tag: 'button',\n hoverable: true,\n pressable: true,\n backgrounded: true,\n borderWidth: 1,\n borderColor: 'transparent',\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n\n // if we wanted this only when pressable = true, we'd need to merge variants?\n cursor: 'pointer',\n\n pressStyle: {\n borderColor: 'transparent',\n },\n\n hoverStyle: {\n borderColor: 'transparent',\n },\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n\n variants: {\n size: {\n '...size': getButtonSize,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n opacity: 0.5,\n // TODO breaking types\n pointerEvents: 'none' as any,\n },\n },\n },\n\n defaultVariants: {\n size: '$4',\n },\n})\n\n// see TODO breaking types\n// type x = GetProps<typeof ButtonFrame>\n// type y = x['size']\n\nexport const ButtonText = styled(SizableText, {\n color: '$color',\n selectable: false,\n flexGrow: 1,\n flexShrink: 1,\n ellipse: true,\n})\n\nconst ButtonComponent = forwardRef((props: ButtonProps, ref) => {\n // careful not to desctructure and re-order props, order is important\n const {\n children,\n icon,\n iconAfter,\n noTextWrap,\n theme: themeName,\n space,\n spaceFlex,\n scaleIcon = 1,\n scaleSpace = 0.5,\n\n // text props\n color: colorProp,\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n textAlign,\n textProps,\n ...rest\n } = props as ButtonProps\n\n const isInsideButton = useContext(ButtonInsideButtonContext)\n const theme = useTheme()\n const size = props.size || '$4'\n\n // get color from prop or theme\n let color: any\n // @ts-expect-error\n if (theme && colorProp && colorProp in theme) {\n // @ts-expect-error\n color = theme[colorProp]\n } else if (colorProp) {\n color = colorProp\n } else {\n color = theme?.color\n }\n color = color?.toString()\n\n const iconSize = getFontSize(size) * scaleIcon\n\n const addTheme = (el: any) => {\n if (isValidElement(el)) {\n return el\n }\n if (el) {\n return React.createElement(el, {\n color,\n size: iconSize,\n })\n }\n return el\n }\n const themedIcon = icon ? addTheme(icon) : null\n const themedIconAfter = iconAfter ? addTheme(iconAfter) : null\n\n let contents = children\n\n if (!noTextWrap && children) {\n // in the case of using variables, like so:\n // <Button>Hello, {name}</Button>\n // it gives us props.children as ['Hello, ', 'name']\n // but we don't want to wrap multiple SizableText around each part\n // so we group them\n let allChildren = React.Children.toArray(children)\n let nextChildren: any[] = []\n let lastIsString = false\n\n function concatStringChildren() {\n if (!lastIsString) return\n const index = nextChildren.length - 1\n const childrenStrings = nextChildren[index]\n nextChildren[index] = (\n <ButtonText\n key={index}\n {...{\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n textAlign,\n size,\n }}\n {...(colorProp && {\n color: colorProp,\n })}\n {...textProps}\n >\n {childrenStrings}\n </ButtonText>\n )\n }\n\n for (const child of allChildren) {\n const last = nextChildren[nextChildren.length - 1]\n const isString = typeof child === 'string'\n if (isString) {\n if (lastIsString) {\n last.push(child)\n } else {\n nextChildren.push([child])\n }\n } else {\n concatStringChildren()\n nextChildren.push(child)\n }\n lastIsString = isString\n }\n concatStringChildren()\n\n contents = nextChildren\n }\n\n return (\n // careful not to desctructure and re-order props, order is important\n <ButtonInsideButtonContext.Provider value={true}>\n <ButtonFrame\n fontFamily={fontFamily}\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n {...(isInsideButton && {\n tag: 'span',\n })}\n ref={ref as any}\n {...rest}\n >\n {themedIcon || themedIconAfter\n ? spacedChildren({\n // a bit arbitrary but scaling to font size is necessary so long as button does\n space: getVariableValue(iconSize) * scaleSpace,\n spaceFlex,\n direction: props.flexDirection || 'row',\n children: [themedIcon, contents, themedIconAfter],\n })\n : contents}\n </ButtonFrame>\n </ButtonInsideButtonContext.Provider>\n )\n})\n\nexport const Button: ReactComponentWithRef<ButtonProps, HTMLButtonElement | View> =\n ButtonFrame.extractable(themeable(ButtonComponent as any) as any, {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'letterSpacing',\n 'textAlign',\n ]),\n })\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAAA;AAAA;AAAA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AAC,KAAK,CAAC;AAAA,QAC3B;AAAA,MACF,OAAO;AACL,6BAAqB;AACrB,qBAAa,KAAK,KAAK;AAAA,MACzB;AACA,qBAAe;AAAA,IACjB;AACA,yBAAqB;AAErB,eAAW;AAAA,EACb;AAEA,SAEE,oCAAC,0BAA0B,UAA1B;AAAA,IAAmC,OAAO;AAAA,KACzC,oCAAC;AAAA,IACC;AAAA,OAEK,kBAAkB;AAAA,MACrB,KAAK;AAAA,IACP;AAAA,IACA;AAAA,OACI;AAAA,KAEH,cAAc,kBACX,eAAe;AAAA,IAEb,OAAO,iBAAiB,QAAQ,IAAI;AAAA,IACpC;AAAA,IACA,WAAW,MAAM,iBAAiB;AAAA,IAClC,UAAU,CAAC,YAAY,UAAU,eAAe;AAAA,EAClD,CAAC,IACD,QACN,CACF;AAEJ,CAAC;AAEM,MAAM,SACX,YAAY,YAAY,UAAU,eAAsB,GAAU;AAAA,EAChE,aAAa,oBAAI,IAAI;AAAA,IAEnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
import {
|
|
30
|
+
Spacer,
|
|
31
|
+
getSize,
|
|
32
|
+
getVariableValue,
|
|
33
|
+
styled,
|
|
34
|
+
themeable,
|
|
35
|
+
withStaticProperties
|
|
36
|
+
} from "@tamagui/core";
|
|
37
|
+
import { getFontSize } from "@tamagui/font-size";
|
|
38
|
+
import { useGetThemedIcon } from "@tamagui/helpers-tamagui";
|
|
39
|
+
import { ThemeableStack, YStack } from "@tamagui/stacks";
|
|
40
|
+
import { SizableText, wrapChildrenInText } from "@tamagui/text";
|
|
41
|
+
import React, { forwardRef } from "react";
|
|
42
|
+
React["createElement"];
|
|
43
|
+
const ListItemFrame = styled(ThemeableStack, {
|
|
44
|
+
name: "ListItem",
|
|
45
|
+
tag: "li",
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
flexWrap: "nowrap",
|
|
48
|
+
width: "100%",
|
|
49
|
+
borderColor: "$borderColor",
|
|
50
|
+
maxWidth: "100%",
|
|
51
|
+
overflow: "hidden",
|
|
52
|
+
flexDirection: "row",
|
|
53
|
+
variants: {
|
|
54
|
+
size: {
|
|
55
|
+
"...size": (val, { tokens }) => {
|
|
56
|
+
return {
|
|
57
|
+
minHeight: tokens.size[val],
|
|
58
|
+
paddingHorizontal: tokens.space[val]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
active: {
|
|
63
|
+
true: {
|
|
64
|
+
hoverStyle: {
|
|
65
|
+
backgroundColor: "$background"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
disabled: {
|
|
70
|
+
true: {
|
|
71
|
+
opacity: 0.5,
|
|
72
|
+
pointerEvents: "none"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
defaultVariants: {
|
|
77
|
+
size: "$4"
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const ListItemText = styled(SizableText, {
|
|
81
|
+
name: "ListItemText",
|
|
82
|
+
color: "$color",
|
|
83
|
+
selectable: false,
|
|
84
|
+
flexGrow: 1,
|
|
85
|
+
flexShrink: 1,
|
|
86
|
+
ellipse: true
|
|
87
|
+
});
|
|
88
|
+
const ListItemSubtitle = styled(ListItemText, {
|
|
89
|
+
name: "ListItemSubtitle",
|
|
90
|
+
color: "$colorPress",
|
|
91
|
+
marginTop: "$-2",
|
|
92
|
+
opacity: 0.65,
|
|
93
|
+
ellipse: true,
|
|
94
|
+
maxWidth: "100%",
|
|
95
|
+
size: "$3"
|
|
96
|
+
});
|
|
97
|
+
const ListItemTitle = styled(ListItemText, {
|
|
98
|
+
name: "ListItemTitle",
|
|
99
|
+
ellipse: true
|
|
100
|
+
});
|
|
101
|
+
const ListItemComponent = forwardRef((props, ref) => {
|
|
102
|
+
const _a = props, {
|
|
103
|
+
children,
|
|
104
|
+
icon,
|
|
105
|
+
iconAfter,
|
|
106
|
+
noTextWrap,
|
|
107
|
+
theme: themeName,
|
|
108
|
+
space,
|
|
109
|
+
spaceFlex,
|
|
110
|
+
scaleIcon = 1,
|
|
111
|
+
scaleSpace = 1,
|
|
112
|
+
subTitle,
|
|
113
|
+
color,
|
|
114
|
+
fontWeight,
|
|
115
|
+
letterSpacing,
|
|
116
|
+
fontSize,
|
|
117
|
+
fontFamily,
|
|
118
|
+
textAlign,
|
|
119
|
+
textProps,
|
|
120
|
+
title
|
|
121
|
+
} = _a, rest = __objRest(_a, [
|
|
122
|
+
"children",
|
|
123
|
+
"icon",
|
|
124
|
+
"iconAfter",
|
|
125
|
+
"noTextWrap",
|
|
126
|
+
"theme",
|
|
127
|
+
"space",
|
|
128
|
+
"spaceFlex",
|
|
129
|
+
"scaleIcon",
|
|
130
|
+
"scaleSpace",
|
|
131
|
+
"subTitle",
|
|
132
|
+
"color",
|
|
133
|
+
"fontWeight",
|
|
134
|
+
"letterSpacing",
|
|
135
|
+
"fontSize",
|
|
136
|
+
"fontFamily",
|
|
137
|
+
"textAlign",
|
|
138
|
+
"textProps",
|
|
139
|
+
"title"
|
|
140
|
+
]);
|
|
141
|
+
const size = props.size || "$4";
|
|
142
|
+
const subtitleSizeToken = getSize(size, -3);
|
|
143
|
+
const subtitleSize = `$${subtitleSizeToken.key}`;
|
|
144
|
+
const iconSize = getFontSize(size) * scaleIcon;
|
|
145
|
+
const getThemedIcon = useGetThemedIcon({ size: iconSize, color });
|
|
146
|
+
const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon);
|
|
147
|
+
const spaceSize = getVariableValue(iconSize) * scaleSpace;
|
|
148
|
+
const contents = wrapChildrenInText(ListItemText, props);
|
|
149
|
+
return /* @__PURE__ */ React.createElement(ListItemFrame, __spreadValues({
|
|
150
|
+
fontFamily,
|
|
151
|
+
ref
|
|
152
|
+
}, rest), themedIcon ? /* @__PURE__ */ React.createElement(React.Fragment, null, themedIcon, /* @__PURE__ */ React.createElement(Spacer, {
|
|
153
|
+
size: spaceSize
|
|
154
|
+
})) : null, Boolean(title || subTitle) ? /* @__PURE__ */ React.createElement(YStack, {
|
|
155
|
+
flex: 1
|
|
156
|
+
}, /* @__PURE__ */ React.createElement(ListItemTitle, null, title), subTitle ? typeof subTitle === "string" ? /* @__PURE__ */ React.createElement(ListItemSubtitle, {
|
|
157
|
+
size: subtitleSize
|
|
158
|
+
}, subTitle) : subTitle : null, contents) : contents, themedIconAfter ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Spacer, {
|
|
159
|
+
flex: true,
|
|
160
|
+
size: spaceSize
|
|
161
|
+
}), themedIconAfter) : null);
|
|
162
|
+
});
|
|
163
|
+
const ListItemInner = ListItemFrame.extractable(themeable(ListItemComponent), {
|
|
164
|
+
inlineProps: /* @__PURE__ */ new Set([
|
|
165
|
+
"color",
|
|
166
|
+
"fontWeight",
|
|
167
|
+
"fontSize",
|
|
168
|
+
"fontFamily",
|
|
169
|
+
"letterSpacing",
|
|
170
|
+
"textAlign"
|
|
171
|
+
])
|
|
172
|
+
});
|
|
173
|
+
const ListItem = withStaticProperties(ListItemInner, {
|
|
174
|
+
Text: ListItemText,
|
|
175
|
+
Subtitle: ListItemSubtitle
|
|
176
|
+
});
|
|
177
|
+
export {
|
|
178
|
+
ListItem,
|
|
179
|
+
ListItemFrame,
|
|
180
|
+
ListItemSubtitle,
|
|
181
|
+
ListItemText
|
|
182
|
+
};
|
|
183
|
+
//# sourceMappingURL=ListItem.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ListItem.tsx"],
|
|
4
|
+
"sourcesContent": ["import {\n FontSizeTokens,\n GetProps,\n Spacer,\n TamaguiComponent,\n ThemeableProps,\n getSize,\n getVariableValue,\n styled,\n themeable,\n withStaticProperties,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { TextParentStyles, useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack, YStack } from '@tamagui/stacks'\nimport { SizableText, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef } from 'react'\nimport { View } from 'react-native'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\ntype ListItemIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ListItemIconProps> | null\n\nexport type ListItemProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ListItemFrame> &\n ThemeableProps & {\n // add icon before, passes color and size automatically if Component\n icon?: IconProp\n // add icon after, passes color and size automatically if Component\n iconAfter?: IconProp\n // adjust icon relative to size\n // default: -1\n scaleIcon?: number\n // make the spacing elements flex\n spaceFlex?: number | boolean\n // adjust internal space relative to icon size\n scaleSpace?: number\n // title\n title?: React.ReactNode\n // subtitle\n subTitle?: React.ReactNode\n }\n\nexport const ListItemFrame = styled(ThemeableStack, {\n name: 'ListItem',\n tag: 'li',\n alignItems: 'center',\n flexWrap: 'nowrap',\n width: '100%',\n borderColor: '$borderColor',\n maxWidth: '100%',\n overflow: 'hidden',\n flexDirection: 'row',\n\n variants: {\n size: {\n '...size': (val, { tokens }) => {\n return {\n minHeight: tokens.size[val],\n paddingHorizontal: tokens.space[val],\n }\n },\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n opacity: 0.5,\n // TODO breaking types\n pointerEvents: 'none' as any,\n },\n },\n },\n\n defaultVariants: {\n size: '$4',\n },\n})\n\nexport const ListItemText = styled(SizableText, {\n name: 'ListItemText',\n color: '$color',\n selectable: false,\n flexGrow: 1,\n flexShrink: 1,\n ellipse: true,\n})\n\nexport const ListItemSubtitle = styled(ListItemText, {\n name: 'ListItemSubtitle',\n color: '$colorPress',\n marginTop: '$-2',\n opacity: 0.65,\n ellipse: true,\n maxWidth: '100%',\n size: '$3',\n})\n\nconst ListItemTitle = styled(ListItemText, {\n name: 'ListItemTitle',\n ellipse: true,\n})\n\nconst ListItemComponent = forwardRef((props: ListItemProps, ref) => {\n // careful not to desctructure and re-order props, order is important\n const {\n children,\n icon,\n iconAfter,\n noTextWrap,\n theme: themeName,\n space,\n spaceFlex,\n scaleIcon = 1,\n scaleSpace = 1,\n subTitle,\n\n // text props\n color,\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n textAlign,\n textProps,\n title,\n ...rest\n } = props as ListItemProps\n\n const size = props.size || '$4'\n const subtitleSizeToken = getSize(size, -3)\n const subtitleSize = `$${subtitleSizeToken.key}` as FontSizeTokens\n const iconSize = getFontSize(size) * scaleIcon\n const getThemedIcon = useGetThemedIcon({ size: iconSize, color })\n const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)\n const spaceSize = getVariableValue(iconSize) * scaleSpace\n const contents = wrapChildrenInText(ListItemText, props)\n\n return (\n <ListItemFrame fontFamily={fontFamily} ref={ref as any} {...rest}>\n {themedIcon ? (\n <>\n {themedIcon}\n <Spacer size={spaceSize} />\n </>\n ) : null}\n {/* helper for common title/subtitle pttern */}\n {Boolean(title || subTitle) ? (\n <YStack flex={1}>\n <ListItemTitle>{title}</ListItemTitle>\n {subTitle ? (\n typeof subTitle === 'string' ? (\n // TODO can use theme but we need to standardize to alt themes\n // or standardize on subtle colors in themes\n <ListItemSubtitle size={subtitleSize}>{subTitle}</ListItemSubtitle>\n ) : (\n subTitle\n )\n ) : null}\n {contents}\n </YStack>\n ) : (\n contents\n )}\n {themedIconAfter ? (\n <>\n <Spacer flex size={spaceSize} />\n {themedIconAfter}\n </>\n ) : null}\n </ListItemFrame>\n )\n})\n\nconst ListItemInner: TamaguiComponent<ListItemProps, HTMLLIElement | View> =\n ListItemFrame.extractable(themeable(ListItemComponent as any) as any, {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract listItem anyway)\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'letterSpacing',\n 'textAlign',\n ]),\n })\n\nexport const ListItem = withStaticProperties(ListItemInner, {\n Text: ListItemText,\n Subtitle: ListItemSubtitle,\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA;AACA;AACA;AACA;AACA;AAIA,MAAM;AAyBC,MAAM,gBAAgB,OAAO,gBA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AEI,MAAM,WAAW,qBAAqB,eAAe;AAAA,EAC1D,MAAM;AAAA,EACN,UAAU;AACZ,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useTheme } from "@tamagui/core";
|
|
4
|
+
const useCurrentColor = /* @__PURE__ */ __name((colorProp) => {
|
|
5
|
+
const theme = useTheme();
|
|
6
|
+
let color;
|
|
7
|
+
if (theme && colorProp && colorProp in theme) {
|
|
8
|
+
color = theme[colorProp];
|
|
9
|
+
} else if (colorProp) {
|
|
10
|
+
color = colorProp;
|
|
11
|
+
} else {
|
|
12
|
+
color = theme == null ? void 0 : theme.color;
|
|
13
|
+
}
|
|
14
|
+
return (color == null ? void 0 : color.toString()) || "";
|
|
15
|
+
}, "useCurrentColor");
|
|
16
|
+
export {
|
|
17
|
+
useCurrentColor
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=useCurrentColor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useCurrentColor.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ColorTokens, ThemeValueFallback, useTheme } from '@tamagui/core'\nimport { TextStyle } from 'react-native'\n\nexport const useCurrentColor = (colorProp: ColorProp) => {\n const theme = useTheme()\n // get color from prop or theme\n let color: any\n // @ts-expect-error\n if (theme && colorProp && colorProp in theme) {\n // @ts-expect-error\n color = theme[colorProp]\n } else if (colorProp) {\n color = colorProp\n } else {\n color = theme?.color\n }\n return color?.toString() || ('' as string)\n}\n\nexport type ColorProp = ThemeValueFallback | ColorTokens | TextStyle['color'] | undefined\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAGO,MAAM,kBAAkB,wBAAC,cAAyB;AACvD,QAAM,QAAQ,SAAS;AAEvB,MAAI;AAEJ,MAAI,SAAS,aAAa,aAAa,OAAO;AAE5C,YAAQ,MAAM;AAAA,EAChB,WAAW,WAAW;AACpB,YAAQ;AAAA,EACV,OAAO;AACL,YAAQ,+BAAO;AAAA,EACjB;AACA,SAAO,gCAAO,eAAe;AAC/B,GAd+B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import React, { isValidElement } from "react";
|
|
4
|
+
import { useCurrentColor } from "./useCurrentColor";
|
|
5
|
+
const useGetThemedIcon = /* @__PURE__ */ __name((props) => {
|
|
6
|
+
const color = useCurrentColor(props.color);
|
|
7
|
+
return (el) => {
|
|
8
|
+
if (isValidElement(el)) {
|
|
9
|
+
return el;
|
|
10
|
+
}
|
|
11
|
+
if (el) {
|
|
12
|
+
return React.createElement(el, props);
|
|
13
|
+
}
|
|
14
|
+
return el;
|
|
15
|
+
};
|
|
16
|
+
}, "useGetThemedIcon");
|
|
17
|
+
export {
|
|
18
|
+
useGetThemedIcon
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useGetThemedIcon.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useGetThemedIcon.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { isValidElement } from 'react'\n\nimport { ColorProp, useCurrentColor } from './useCurrentColor'\n\nexport const useGetThemedIcon = (props: { color: ColorProp; size: number }) => {\n const color = useCurrentColor(props.color)\n return (el: any) => {\n if (isValidElement(el)) {\n return el\n }\n if (el) {\n return React.createElement(el, props)\n }\n return el\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AAEO,MAAM,mBAAmB,wBAAC,UAA8C;AAC7E,QAAM,QAAQ,gBAAgB,MAAM,KAAK;AACzC,SAAO,CAAC,OAAY;AAClB,QAAI,eAAe,EAAE,GAAG;AACtB,aAAO;AAAA,IACT;AACA,QAAI,IAAI;AACN,aAAO,MAAM,cAAc,IAAI,KAAK;AAAA,IACtC;AACA,WAAO;AAAA,EACT;AACF,GAXgC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { ListItemText } from "./ListItem";
|
|
5
|
+
function wrapStringChildrenInText({
|
|
6
|
+
children,
|
|
7
|
+
textProps,
|
|
8
|
+
size,
|
|
9
|
+
noTextWrap,
|
|
10
|
+
...directTextProps
|
|
11
|
+
}) {
|
|
12
|
+
if (noTextWrap || !children) {
|
|
13
|
+
return children;
|
|
14
|
+
}
|
|
15
|
+
let allChildren = React.Children.toArray(children);
|
|
16
|
+
let nextChildren = [];
|
|
17
|
+
let lastIsString = false;
|
|
18
|
+
function concatStringChildren() {
|
|
19
|
+
if (!lastIsString)
|
|
20
|
+
return;
|
|
21
|
+
const index = nextChildren.length - 1;
|
|
22
|
+
const childrenStrings = nextChildren[index];
|
|
23
|
+
nextChildren[index] = /* @__PURE__ */ React.createElement(ListItemText, {
|
|
24
|
+
key: index,
|
|
25
|
+
...directTextProps,
|
|
26
|
+
size,
|
|
27
|
+
...textProps
|
|
28
|
+
}, childrenStrings);
|
|
29
|
+
}
|
|
30
|
+
__name(concatStringChildren, "concatStringChildren");
|
|
31
|
+
for (const child of allChildren) {
|
|
32
|
+
const last = nextChildren[nextChildren.length - 1];
|
|
33
|
+
const isString = typeof child === "string";
|
|
34
|
+
if (isString) {
|
|
35
|
+
if (lastIsString) {
|
|
36
|
+
last.push(child);
|
|
37
|
+
} else {
|
|
38
|
+
nextChildren.push([child]);
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
concatStringChildren();
|
|
42
|
+
nextChildren.push(child);
|
|
43
|
+
}
|
|
44
|
+
lastIsString = isString;
|
|
45
|
+
}
|
|
46
|
+
concatStringChildren();
|
|
47
|
+
return nextChildren;
|
|
48
|
+
}
|
|
49
|
+
__name(wrapStringChildrenInText, "wrapStringChildrenInText");
|
|
50
|
+
export {
|
|
51
|
+
wrapStringChildrenInText
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=wrapStringChildrenInText.js.map
|