@tamagui/list-item 1.0.1-beta.183 → 1.0.1-beta.185
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.js +2 -2
- package/dist/cjs/ListItem.js.map +2 -2
- package/dist/esm/ListItem.js +2 -2
- package/dist/esm/ListItem.js.map +2 -2
- package/dist/jsx/ListItem.js +2 -2
- package/dist/jsx/ListItem.js.map +2 -2
- package/package.json +5 -5
- package/src/ListItem.tsx +32 -11
- package/types/ListItem.d.ts +61 -3
package/dist/cjs/ListItem.js
CHANGED
|
@@ -151,7 +151,7 @@ const useListItem = (props, {
|
|
|
151
151
|
Boolean(title || subTitle) ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stacks.YStack, {
|
|
152
152
|
flex: 1,
|
|
153
153
|
children: [
|
|
154
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Title, {
|
|
154
|
+
noTextWrap === "all" ? title : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Title, {
|
|
155
155
|
size,
|
|
156
156
|
children: title
|
|
157
157
|
}),
|
|
@@ -161,7 +161,7 @@ const useListItem = (props, {
|
|
|
161
161
|
flex: true,
|
|
162
162
|
size: spaceSize * 0.333
|
|
163
163
|
}),
|
|
164
|
-
typeof subTitle === "string" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Subtitle, {
|
|
164
|
+
typeof subTitle === "string" && noTextWrap !== "all" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Subtitle, {
|
|
165
165
|
size: subtitleSize,
|
|
166
166
|
children: subTitle
|
|
167
167
|
}) : subTitle
|
package/dist/cjs/ListItem.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ListItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n FontSizeTokens,\n GetProps,\n Spacer,\n TamaguiElement,\n ThemeableProps,\n getSize,\n getVariableValue,\n styled,\n themeable,\n useMediaPropsActive,\n withStaticProperties,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getSpace, useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack, YStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef } from 'react'\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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import {\n FontSizeTokens,\n GetProps,\n Spacer,\n TamaguiElement,\n ThemeableProps,\n getSize,\n getVariableValue,\n styled,\n themeable,\n useMediaPropsActive,\n withStaticProperties,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getSpace, useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack, YStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef } from 'react'\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' | 'noTextWrap'> &\n GetProps<typeof ListItemFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n */\n /**\n * default: -1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n * title\n */\n title?: React.ReactNode\n /**\n * subtitle\n */\n subTitle?: React.ReactNode\n /**\n * will not wrap text around `children` only, \"all\" will not wrap title or subTitle\n */\n noTextWrap?: boolean | 'all'\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 paddingVertical: getSpace(val, -2),\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 } as const,\n\n defaultVariants: {\n size: '$4',\n },\n})\n\nexport const ListItemText = styled(SizableText, {\n name: 'ListItemText',\n color: '$color',\n userSelect: 'none',\n flexGrow: 1,\n flexShrink: 1,\n ellipse: true,\n cursor: 'default',\n})\n\nexport const ListItemSubtitle = styled(ListItemText, {\n name: 'ListItemSubtitle',\n color: '$colorPress',\n marginTop: '$-2',\n opacity: 0.65,\n maxWidth: '100%',\n size: '$3',\n})\n\nexport const ListItemTitle = styled(ListItemText, {\n name: 'ListItemTitle',\n})\n\nexport const useListItem = (\n props: ListItemProps,\n {\n Text = ListItemText,\n Subtitle = ListItemSubtitle,\n Title = ListItemTitle,\n }: {\n Title?: any\n Subtitle?: any\n Text?: any\n } = { Text: ListItemText, Subtitle: ListItemSubtitle, Title: ListItemTitle }\n) => {\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\n\n const mediaActiveProps = useMediaPropsActive(props)\n const size = mediaActiveProps.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 // @ts-ignore noTextWrap = all is ok\n const contents = wrapChildrenInText(Text, mediaActiveProps)\n\n return {\n props: {\n fontFamily,\n ...rest,\n children: (\n <>\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 {noTextWrap === 'all' ? title : <Title size={size}>{title}</Title>}\n {subTitle ? (\n <>\n <Spacer flex size={spaceSize * 0.333} />\n {typeof subTitle === 'string' && noTextWrap !== 'all' ? (\n // TODO can use theme but we need to standardize to alt themes\n // or standardize on subtle colors in themes\n <Subtitle size={subtitleSize}>{subTitle}</Subtitle>\n ) : (\n subTitle\n )}\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 </>\n ),\n },\n }\n}\n\nconst ListItemComponent = forwardRef<TamaguiElement, ListItemProps>((props, ref) => {\n const { props: listItemProps } = useListItem(props)\n return <ListItemFrame ref={ref} {...listItemProps} />\n})\n\nexport const listItemStaticConfig = {\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(\n ListItemFrame.extractable(themeable(ListItemComponent), listItemStaticConfig),\n {\n Text: ListItemText,\n Subtitle: ListItemSubtitle,\n }\n)\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2LY;AA3LZ,kBAYO;AACP,uBAA4B;AAC5B,6BAA2C;AAC3C,oBAAuC;AACvC,kBAAkE;AAClE,mBAAqD;AAGrD,aAAAA,QAAM;AA6CC,MAAM,oBAAgB,oBAAO,8BAAgB;AAAA,EAClD,MAAM;AAAA,EACN,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,OAAO;AAAA,EACP,aAAa;AAAA,EACb,UAAU;AAAA,EACV,UAAU;AAAA,EACV,eAAe;AAAA,EAEf,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,KAAK,EAAE,OAAO,MAAM;AAC9B,eAAO;AAAA,UACL,WAAW,OAAO,KAAK;AAAA,UACvB,mBAAmB,OAAO,MAAM;AAAA,UAChC,qBAAiB,iCAAS,KAAK,EAAE;AAAA,QACnC;AAAA,MACF;AAAA,IACF;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,SAAS;AAAA,QAET,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AAEM,MAAM,mBAAe,oBAAO,yBAAa;AAAA,EAC9C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,QAAQ;AACV,CAAC;AAEM,MAAM,uBAAmB,oBAAO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,YACX;AAAA,6BAAe,QAAQ,QAAQ,4CAAC;AAAA,gBAAM;AAAA,gBAAa;AAAA,eAAM;AAAA,cACzD,WACC;AAAA,gBACE;AAAA,8DAAC;AAAA,oBAAO,MAAI;AAAA,oBAAC,MAAM,YAAY;AAAA,mBAAO;AAAA,kBACrC,OAAO,aAAa,YAAY,eAAe,QAG9C,4CAAC;AAAA,oBAAS,MAAM;AAAA,oBAAe;AAAA,mBAAS,IAExC;AAAA;AAAA,eAEJ,IACE;AAAA,cACH;AAAA;AAAA,WACH,IAEA;AAAA,UAED,kBACC;AAAA,YACE;AAAA,0DAAC;AAAA,gBAAO,MAAI;AAAA,gBAAC,MAAM;AAAA,eAAW;AAAA,cAC7B;AAAA;AAAA,WACH,IACE;AAAA;AAAA,OACN;AAAA,IAEJ;AAAA,EACF;AACF;AAEA,MAAM,wBAAoB,yBAA0C,CAAC,OAAO,QAAQ;AAClF,QAAM,EAAE,OAAO,cAAc,IAAI,YAAY,KAAK;AAClD,SAAO,4CAAC;AAAA,IAAc;AAAA,IAAW,GAAG;AAAA,GAAe;AACrD,CAAC;AAEM,MAAM,uBAAuB;AAAA,EAClC,aAAa,oBAAI,IAAI;AAAA,IAEnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,MAAM,eAAW;AAAA,EACtB,cAAc,gBAAY,uBAAU,iBAAiB,GAAG,oBAAoB;AAAA,EAC5E;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
package/dist/esm/ListItem.js
CHANGED
|
@@ -124,7 +124,7 @@ const useListItem = (props, {
|
|
|
124
124
|
Boolean(title || subTitle) ? /* @__PURE__ */ jsxs(YStack, {
|
|
125
125
|
flex: 1,
|
|
126
126
|
children: [
|
|
127
|
-
/* @__PURE__ */ jsx(Title, {
|
|
127
|
+
noTextWrap === "all" ? title : /* @__PURE__ */ jsx(Title, {
|
|
128
128
|
size,
|
|
129
129
|
children: title
|
|
130
130
|
}),
|
|
@@ -134,7 +134,7 @@ const useListItem = (props, {
|
|
|
134
134
|
flex: true,
|
|
135
135
|
size: spaceSize * 0.333
|
|
136
136
|
}),
|
|
137
|
-
typeof subTitle === "string" ? /* @__PURE__ */ jsx(Subtitle, {
|
|
137
|
+
typeof subTitle === "string" && noTextWrap !== "all" ? /* @__PURE__ */ jsx(Subtitle, {
|
|
138
138
|
size: subtitleSize,
|
|
139
139
|
children: subTitle
|
|
140
140
|
}) : subTitle
|
package/dist/esm/ListItem.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ListItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n FontSizeTokens,\n GetProps,\n Spacer,\n TamaguiElement,\n ThemeableProps,\n getSize,\n getVariableValue,\n styled,\n themeable,\n useMediaPropsActive,\n withStaticProperties,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getSpace, useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack, YStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef } from 'react'\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
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n FontSizeTokens,\n GetProps,\n Spacer,\n TamaguiElement,\n ThemeableProps,\n getSize,\n getVariableValue,\n styled,\n themeable,\n useMediaPropsActive,\n withStaticProperties,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getSpace, useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack, YStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef } from 'react'\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' | 'noTextWrap'> &\n GetProps<typeof ListItemFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n */\n /**\n * default: -1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n * title\n */\n title?: React.ReactNode\n /**\n * subtitle\n */\n subTitle?: React.ReactNode\n /**\n * will not wrap text around `children` only, \"all\" will not wrap title or subTitle\n */\n noTextWrap?: boolean | 'all'\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 paddingVertical: getSpace(val, -2),\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 } as const,\n\n defaultVariants: {\n size: '$4',\n },\n})\n\nexport const ListItemText = styled(SizableText, {\n name: 'ListItemText',\n color: '$color',\n userSelect: 'none',\n flexGrow: 1,\n flexShrink: 1,\n ellipse: true,\n cursor: 'default',\n})\n\nexport const ListItemSubtitle = styled(ListItemText, {\n name: 'ListItemSubtitle',\n color: '$colorPress',\n marginTop: '$-2',\n opacity: 0.65,\n maxWidth: '100%',\n size: '$3',\n})\n\nexport const ListItemTitle = styled(ListItemText, {\n name: 'ListItemTitle',\n})\n\nexport const useListItem = (\n props: ListItemProps,\n {\n Text = ListItemText,\n Subtitle = ListItemSubtitle,\n Title = ListItemTitle,\n }: {\n Title?: any\n Subtitle?: any\n Text?: any\n } = { Text: ListItemText, Subtitle: ListItemSubtitle, Title: ListItemTitle }\n) => {\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\n\n const mediaActiveProps = useMediaPropsActive(props)\n const size = mediaActiveProps.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 // @ts-ignore noTextWrap = all is ok\n const contents = wrapChildrenInText(Text, mediaActiveProps)\n\n return {\n props: {\n fontFamily,\n ...rest,\n children: (\n <>\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 {noTextWrap === 'all' ? title : <Title size={size}>{title}</Title>}\n {subTitle ? (\n <>\n <Spacer flex size={spaceSize * 0.333} />\n {typeof subTitle === 'string' && noTextWrap !== 'all' ? (\n // TODO can use theme but we need to standardize to alt themes\n // or standardize on subtle colors in themes\n <Subtitle size={subtitleSize}>{subTitle}</Subtitle>\n ) : (\n subTitle\n )}\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 </>\n ),\n },\n }\n}\n\nconst ListItemComponent = forwardRef<TamaguiElement, ListItemProps>((props, ref) => {\n const { props: listItemProps } = useListItem(props)\n return <ListItemFrame ref={ref} {...listItemProps} />\n})\n\nexport const listItemStaticConfig = {\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(\n ListItemFrame.extractable(themeable(ListItemComponent), listItemStaticConfig),\n {\n Text: ListItemText,\n Subtitle: ListItemSubtitle,\n }\n)\n"],
|
|
5
|
+
"mappings": "AA2LY,mBAEE,KAFF;AA3LZ;AAAA,EAGE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,UAAU,wBAAwB;AAC3C,SAAS,gBAAgB,cAAc;AACvC,SAAS,aAA+B,0BAA0B;AAClE,OAAO,SAA4B,kBAAkB;AAGrD,MAAM;AA6CC,MAAM,gBAAgB,OAAO,gBAAgB;AAAA,EAClD,MAAM;AAAA,EACN,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,OAAO;AAAA,EACP,aAAa;AAAA,EACb,UAAU;AAAA,EACV,UAAU;AAAA,EACV,eAAe;AAAA,EAEf,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,KAAK,EAAE,OAAO,MAAM;AAC9B,eAAO;AAAA,UACL,WAAW,OAAO,KAAK;AAAA,UACvB,mBAAmB,OAAO,MAAM;AAAA,UAChC,iBAAiB,SAAS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I;AAAA,IAEnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,MAAM,WAAW;AAAA,EACtB,cAAc,YAAY,UAAU,iBAAiB,GAAG,oBAAoB;AAAA,EAC5E;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/ListItem.js
CHANGED
|
@@ -116,10 +116,10 @@ const useListItem = (props, {
|
|
|
116
116
|
<Spacer size={spaceSize} />
|
|
117
117
|
</> : null}
|
|
118
118
|
{Boolean(title || subTitle) ? <YStack flex={1}>
|
|
119
|
-
<Title size={size}>{title}</Title>
|
|
119
|
+
{noTextWrap === "all" ? title : <Title size={size}>{title}</Title>}
|
|
120
120
|
{subTitle ? <>
|
|
121
121
|
<Spacer flex size={spaceSize * 0.333} />
|
|
122
|
-
{typeof subTitle === "string" ? <Subtitle size={subtitleSize}>{subTitle}</Subtitle> : subTitle}
|
|
122
|
+
{typeof subTitle === "string" && noTextWrap !== "all" ? <Subtitle size={subtitleSize}>{subTitle}</Subtitle> : subTitle}
|
|
123
123
|
</> : null}
|
|
124
124
|
{contents}
|
|
125
125
|
</YStack> : contents}
|
package/dist/jsx/ListItem.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ListItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n FontSizeTokens,\n GetProps,\n Spacer,\n TamaguiElement,\n ThemeableProps,\n getSize,\n getVariableValue,\n styled,\n themeable,\n useMediaPropsActive,\n withStaticProperties,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getSpace, useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack, YStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef } from 'react'\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
|
|
5
|
-
"mappings": "AAAA;AAAA,EAGE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,UAAU,wBAAwB;AAC3C,SAAS,gBAAgB,cAAc;AACvC,SAAS,aAA+B,0BAA0B;AAClE,OAAO,SAA4B,kBAAkB;AAGrD,MAAM;
|
|
4
|
+
"sourcesContent": ["import {\n FontSizeTokens,\n GetProps,\n Spacer,\n TamaguiElement,\n ThemeableProps,\n getSize,\n getVariableValue,\n styled,\n themeable,\n useMediaPropsActive,\n withStaticProperties,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getSpace, useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack, YStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef } from 'react'\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' | 'noTextWrap'> &\n GetProps<typeof ListItemFrame> &\n ThemeableProps & {\n /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n */\n /**\n * default: -1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n /**\n * title\n */\n title?: React.ReactNode\n /**\n * subtitle\n */\n subTitle?: React.ReactNode\n /**\n * will not wrap text around `children` only, \"all\" will not wrap title or subTitle\n */\n noTextWrap?: boolean | 'all'\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 paddingVertical: getSpace(val, -2),\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 } as const,\n\n defaultVariants: {\n size: '$4',\n },\n})\n\nexport const ListItemText = styled(SizableText, {\n name: 'ListItemText',\n color: '$color',\n userSelect: 'none',\n flexGrow: 1,\n flexShrink: 1,\n ellipse: true,\n cursor: 'default',\n})\n\nexport const ListItemSubtitle = styled(ListItemText, {\n name: 'ListItemSubtitle',\n color: '$colorPress',\n marginTop: '$-2',\n opacity: 0.65,\n maxWidth: '100%',\n size: '$3',\n})\n\nexport const ListItemTitle = styled(ListItemText, {\n name: 'ListItemTitle',\n})\n\nexport const useListItem = (\n props: ListItemProps,\n {\n Text = ListItemText,\n Subtitle = ListItemSubtitle,\n Title = ListItemTitle,\n }: {\n Title?: any\n Subtitle?: any\n Text?: any\n } = { Text: ListItemText, Subtitle: ListItemSubtitle, Title: ListItemTitle }\n) => {\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\n\n const mediaActiveProps = useMediaPropsActive(props)\n const size = mediaActiveProps.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 // @ts-ignore noTextWrap = all is ok\n const contents = wrapChildrenInText(Text, mediaActiveProps)\n\n return {\n props: {\n fontFamily,\n ...rest,\n children: (\n <>\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 {noTextWrap === 'all' ? title : <Title size={size}>{title}</Title>}\n {subTitle ? (\n <>\n <Spacer flex size={spaceSize * 0.333} />\n {typeof subTitle === 'string' && noTextWrap !== 'all' ? (\n // TODO can use theme but we need to standardize to alt themes\n // or standardize on subtle colors in themes\n <Subtitle size={subtitleSize}>{subTitle}</Subtitle>\n ) : (\n subTitle\n )}\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 </>\n ),\n },\n }\n}\n\nconst ListItemComponent = forwardRef<TamaguiElement, ListItemProps>((props, ref) => {\n const { props: listItemProps } = useListItem(props)\n return <ListItemFrame ref={ref} {...listItemProps} />\n})\n\nexport const listItemStaticConfig = {\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(\n ListItemFrame.extractable(themeable(ListItemComponent), listItemStaticConfig),\n {\n Text: ListItemText,\n Subtitle: ListItemSubtitle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;AAAA,aACrC,OAAO,aAAa,YAAY,eAAe,QAG9C,CAAC,SAAS,MAAM,eAAe,SAAS,EAAvC,YAED;AAAA,UAEJ,MACE;AAAA,WACH;AAAA,QACH,EAfC,UAiBD;AAAA,SAED,kBACC;AAAA,UACE,CAAC,OAAO,KAAK,MAAM,WAAW;AAAA,WAC7B;AAAA,QACH,MACE;AAAA,MACN;AAAA,IAEJ;AAAA,EACF;AACF;AAEA,MAAM,oBAAoB,WAA0C,CAAC,OAAO,QAAQ;AAClF,QAAM,EAAE,OAAO,cAAc,IAAI,YAAY,KAAK;AAClD,SAAO,CAAC,cAAc,KAAK,SAAS,eAAe;AACrD,CAAC;AAEM,MAAM,uBAAuB;AAAA,EAClC,aAAa,oBAAI,IAAI;AAAA,IAEnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,MAAM,WAAW;AAAA,EACtB,cAAc,YAAY,UAAU,iBAAiB,GAAG,oBAAoB;AAAA,EAC5E;AAAA,IACE,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/list-item",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.185",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
"watch": "tamagui-build --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
25
|
-
"@tamagui/font-size": "^1.0.1-beta.
|
|
26
|
-
"@tamagui/helpers-tamagui": "^1.0.1-beta.
|
|
24
|
+
"@tamagui/core": "^1.0.1-beta.185",
|
|
25
|
+
"@tamagui/font-size": "^1.0.1-beta.185",
|
|
26
|
+
"@tamagui/helpers-tamagui": "^1.0.1-beta.185"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
33
|
+
"@tamagui/build": "^1.0.1-beta.185",
|
|
34
34
|
"react": "*",
|
|
35
35
|
"react-dom": "*"
|
|
36
36
|
},
|
package/src/ListItem.tsx
CHANGED
|
@@ -23,24 +23,44 @@ React['createElement']
|
|
|
23
23
|
type ListItemIconProps = { color?: string; size?: number }
|
|
24
24
|
type IconProp = JSX.Element | FunctionComponent<ListItemIconProps> | null
|
|
25
25
|
|
|
26
|
-
export type ListItemProps = Omit<TextParentStyles, 'TextComponent'> &
|
|
26
|
+
export type ListItemProps = Omit<TextParentStyles, 'TextComponent' | 'noTextWrap'> &
|
|
27
27
|
GetProps<typeof ListItemFrame> &
|
|
28
28
|
ThemeableProps & {
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* add icon before, passes color and size automatically if Component
|
|
31
|
+
*/
|
|
30
32
|
icon?: IconProp
|
|
31
|
-
|
|
33
|
+
/**
|
|
34
|
+
* add icon after, passes color and size automatically if Component
|
|
35
|
+
*/
|
|
32
36
|
iconAfter?: IconProp
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
/**
|
|
38
|
+
* adjust icon relative to size
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* default: -1
|
|
42
|
+
*/
|
|
35
43
|
scaleIcon?: number
|
|
36
|
-
|
|
44
|
+
/**
|
|
45
|
+
* make the spacing elements flex
|
|
46
|
+
*/
|
|
37
47
|
spaceFlex?: number | boolean
|
|
38
|
-
|
|
48
|
+
/**
|
|
49
|
+
* adjust internal space relative to icon size
|
|
50
|
+
*/
|
|
39
51
|
scaleSpace?: number
|
|
40
|
-
|
|
52
|
+
/**
|
|
53
|
+
* title
|
|
54
|
+
*/
|
|
41
55
|
title?: React.ReactNode
|
|
42
|
-
|
|
56
|
+
/**
|
|
57
|
+
* subtitle
|
|
58
|
+
*/
|
|
43
59
|
subTitle?: React.ReactNode
|
|
60
|
+
/**
|
|
61
|
+
* will not wrap text around `children` only, "all" will not wrap title or subTitle
|
|
62
|
+
*/
|
|
63
|
+
noTextWrap?: boolean | 'all'
|
|
44
64
|
}
|
|
45
65
|
|
|
46
66
|
export const ListItemFrame = styled(ThemeableStack, {
|
|
@@ -155,6 +175,7 @@ export const useListItem = (
|
|
|
155
175
|
const getThemedIcon = useGetThemedIcon({ size: iconSize, color })
|
|
156
176
|
const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)
|
|
157
177
|
const spaceSize = getVariableValue(iconSize) * scaleSpace
|
|
178
|
+
// @ts-ignore noTextWrap = all is ok
|
|
158
179
|
const contents = wrapChildrenInText(Text, mediaActiveProps)
|
|
159
180
|
|
|
160
181
|
return {
|
|
@@ -172,11 +193,11 @@ export const useListItem = (
|
|
|
172
193
|
{/* helper for common title/subtitle pttern */}
|
|
173
194
|
{Boolean(title || subTitle) ? (
|
|
174
195
|
<YStack flex={1}>
|
|
175
|
-
<Title size={size}>{title}</Title>
|
|
196
|
+
{noTextWrap === 'all' ? title : <Title size={size}>{title}</Title>}
|
|
176
197
|
{subTitle ? (
|
|
177
198
|
<>
|
|
178
199
|
<Spacer flex size={spaceSize * 0.333} />
|
|
179
|
-
{typeof subTitle === 'string' ? (
|
|
200
|
+
{typeof subTitle === 'string' && noTextWrap !== 'all' ? (
|
|
180
201
|
// TODO can use theme but we need to standardize to alt themes
|
|
181
202
|
// or standardize on subtle colors in themes
|
|
182
203
|
<Subtitle size={subtitleSize}>{subTitle}</Subtitle>
|
package/types/ListItem.d.ts
CHANGED
|
@@ -6,14 +6,42 @@ declare type ListItemIconProps = {
|
|
|
6
6
|
size?: number;
|
|
7
7
|
};
|
|
8
8
|
declare type IconProp = JSX.Element | FunctionComponent<ListItemIconProps> | null;
|
|
9
|
-
export declare type ListItemProps = Omit<TextParentStyles, 'TextComponent'> & GetProps<typeof ListItemFrame> & ThemeableProps & {
|
|
9
|
+
export declare type ListItemProps = Omit<TextParentStyles, 'TextComponent' | 'noTextWrap'> & GetProps<typeof ListItemFrame> & ThemeableProps & {
|
|
10
|
+
/**
|
|
11
|
+
* add icon before, passes color and size automatically if Component
|
|
12
|
+
*/
|
|
10
13
|
icon?: IconProp;
|
|
14
|
+
/**
|
|
15
|
+
* add icon after, passes color and size automatically if Component
|
|
16
|
+
*/
|
|
11
17
|
iconAfter?: IconProp;
|
|
18
|
+
/**
|
|
19
|
+
* adjust icon relative to size
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* default: -1
|
|
23
|
+
*/
|
|
12
24
|
scaleIcon?: number;
|
|
25
|
+
/**
|
|
26
|
+
* make the spacing elements flex
|
|
27
|
+
*/
|
|
13
28
|
spaceFlex?: number | boolean;
|
|
29
|
+
/**
|
|
30
|
+
* adjust internal space relative to icon size
|
|
31
|
+
*/
|
|
14
32
|
scaleSpace?: number;
|
|
33
|
+
/**
|
|
34
|
+
* title
|
|
35
|
+
*/
|
|
15
36
|
title?: React.ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* subtitle
|
|
39
|
+
*/
|
|
16
40
|
subTitle?: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* will not wrap text around `children` only, "all" will not wrap title or subTitle
|
|
43
|
+
*/
|
|
44
|
+
noTextWrap?: boolean | 'all';
|
|
17
45
|
};
|
|
18
46
|
export declare const ListItemFrame: import("@tamagui/core").TamaguiComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
19
47
|
readonly fullscreen?: boolean | undefined;
|
|
@@ -339,7 +367,9 @@ export declare const useListItem: (props: ListItemProps, { Text, Subtitle, Title
|
|
|
339
367
|
accessibilityIgnoresInvertColors?: boolean | undefined;
|
|
340
368
|
dataSet?: any;
|
|
341
369
|
target?: any;
|
|
342
|
-
rel?: any;
|
|
370
|
+
rel?: any; /**
|
|
371
|
+
* add icon after, passes color and size automatically if Component
|
|
372
|
+
*/
|
|
343
373
|
download?: any;
|
|
344
374
|
href?: string | undefined;
|
|
345
375
|
hrefAttrs?: {
|
|
@@ -608,7 +638,7 @@ export declare const useListItem: (props: ListItemProps, { Text, Subtitle, Title
|
|
|
608
638
|
export declare const listItemStaticConfig: {
|
|
609
639
|
inlineProps: Set<string>;
|
|
610
640
|
};
|
|
611
|
-
export declare const ListItem: ((props: Omit<Omit<TextParentStyles, "TextComponent"> & Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
641
|
+
export declare const ListItem: ((props: Omit<Omit<TextParentStyles, "TextComponent" | "noTextWrap"> & Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
612
642
|
readonly fullscreen?: boolean | undefined;
|
|
613
643
|
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
614
644
|
} & {
|
|
@@ -669,13 +699,41 @@ export declare const ListItem: ((props: Omit<Omit<TextParentStyles, "TextCompone
|
|
|
669
699
|
readonly active?: boolean | undefined;
|
|
670
700
|
readonly disabled?: boolean | undefined;
|
|
671
701
|
}>> & ThemeableProps & {
|
|
702
|
+
/**
|
|
703
|
+
* add icon before, passes color and size automatically if Component
|
|
704
|
+
*/
|
|
672
705
|
icon?: IconProp | undefined;
|
|
706
|
+
/**
|
|
707
|
+
* add icon after, passes color and size automatically if Component
|
|
708
|
+
*/
|
|
673
709
|
iconAfter?: IconProp | undefined;
|
|
710
|
+
/**
|
|
711
|
+
* adjust icon relative to size
|
|
712
|
+
*/
|
|
713
|
+
/**
|
|
714
|
+
* default: -1
|
|
715
|
+
*/
|
|
674
716
|
scaleIcon?: number | undefined;
|
|
717
|
+
/**
|
|
718
|
+
* make the spacing elements flex
|
|
719
|
+
*/
|
|
675
720
|
spaceFlex?: number | boolean | undefined;
|
|
721
|
+
/**
|
|
722
|
+
* adjust internal space relative to icon size
|
|
723
|
+
*/
|
|
676
724
|
scaleSpace?: number | undefined;
|
|
725
|
+
/**
|
|
726
|
+
* title
|
|
727
|
+
*/
|
|
677
728
|
title?: React.ReactNode;
|
|
729
|
+
/**
|
|
730
|
+
* subtitle
|
|
731
|
+
*/
|
|
678
732
|
subTitle?: React.ReactNode;
|
|
733
|
+
/**
|
|
734
|
+
* will not wrap text around `children` only, "all" will not wrap title or subTitle
|
|
735
|
+
*/
|
|
736
|
+
noTextWrap?: boolean | "all" | undefined;
|
|
679
737
|
} & React.RefAttributes<TamaguiElement>, "theme" | "themeInverse"> & {
|
|
680
738
|
theme?: import("@tamagui/core").ThemeName | null | undefined;
|
|
681
739
|
themeInverse?: boolean | undefined;
|