@os-design/core 1.0.169 → 1.0.170
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/index.js +28 -45
- package/dist/cjs/ListItem/index.js.map +1 -1
- package/dist/cjs/ListItemActions/index.js +118 -0
- package/dist/cjs/ListItemActions/index.js.map +1 -0
- package/dist/cjs/ListItemLink/index.js +18 -55
- package/dist/cjs/ListItemLink/index.js.map +1 -1
- package/dist/cjs/ListSkeleton/index.js +16 -7
- package/dist/cjs/ListSkeleton/index.js.map +1 -1
- package/dist/esm/ListItem/index.js +29 -55
- package/dist/esm/ListItem/index.js.map +1 -1
- package/dist/esm/ListItemActions/index.js +121 -0
- package/dist/esm/ListItemActions/index.js.map +1 -0
- package/dist/esm/ListItemLink/index.js +27 -63
- package/dist/esm/ListItemLink/index.js.map +1 -1
- package/dist/esm/ListSkeleton/index.js +11 -3
- package/dist/esm/ListSkeleton/index.js.map +1 -1
- package/dist/types/ListItem/index.d.ts +8 -8
- package/dist/types/ListItem/index.d.ts.map +1 -1
- package/dist/types/ListItemActions/index.d.ts +13 -0
- package/dist/types/ListItemActions/index.d.ts.map +1 -0
- package/dist/types/ListItemLink/index.d.ts +3 -3
- package/dist/types/ListItemLink/index.d.ts.map +1 -1
- package/dist/types/ListSkeleton/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/ListItem/ListItemContent.js +0 -99
- package/dist/cjs/ListItem/ListItemContent.js.map +0 -1
- package/dist/esm/ListItem/ListItemContent.js +0 -92
- package/dist/esm/ListItem/ListItemContent.js.map +0 -1
- package/dist/types/ListItem/ListItemContent.d.ts +0 -25
- package/dist/types/ListItem/ListItemContent.d.ts.map +0 -1
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import styled from '@emotion/styled';
|
|
4
|
-
import { clr } from '@os-design/theming';
|
|
5
|
-
import { ellipsisStyles, horizontalPaddingStyles, transitionStyles } from '@os-design/styles';
|
|
6
|
-
import { omitEmotionProps } from '@os-design/utils';
|
|
7
|
-
import { css } from '@emotion/react';
|
|
8
|
-
import Button from '../Button';
|
|
9
|
-
const Content = styled.div`
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
`;
|
|
12
|
-
const Title = styled.div`
|
|
13
|
-
color: ${p => clr(p.theme.colorText)};
|
|
14
|
-
font-weight: 500;
|
|
15
|
-
${ellipsisStyles};
|
|
16
|
-
`;
|
|
17
|
-
const Description = styled.div`
|
|
18
|
-
color: ${p => clr(p.theme.listItemColorDescription)};
|
|
19
|
-
font-size: ${p => p.theme.sizes.small}em;
|
|
20
|
-
${ellipsisStyles};
|
|
21
|
-
`;
|
|
22
|
-
export const LeftAddon = styled.div`
|
|
23
|
-
color: ${p => clr(p.theme.colorText)};
|
|
24
|
-
padding-right: ${p => p.theme.listItemAddonPaddingHorizontal}em;
|
|
25
|
-
`;
|
|
26
|
-
export const RightAddon = styled.div`
|
|
27
|
-
color: ${p => clr(p.theme.colorText)};
|
|
28
|
-
margin-left: auto;
|
|
29
|
-
padding-left: ${p => p.theme.listItemAddonPaddingHorizontal}em;
|
|
30
|
-
`;
|
|
31
|
-
const hasSwipeStyles = p => p.hasSwipe && css`
|
|
32
|
-
transform: translateX(100%);
|
|
33
|
-
${transitionStyles('transform')(p)};
|
|
34
|
-
`;
|
|
35
|
-
const openedStyles = p => p.opened && css`
|
|
36
|
-
transform: translateX(0);
|
|
37
|
-
`;
|
|
38
|
-
const Actions = styled('nav', omitEmotionProps('hasSwipe', 'opened'))`
|
|
39
|
-
position: absolute;
|
|
40
|
-
top: 0;
|
|
41
|
-
right: 0;
|
|
42
|
-
bottom: 0;
|
|
43
|
-
|
|
44
|
-
display: flex;
|
|
45
|
-
align-items: center;
|
|
46
|
-
|
|
47
|
-
padding-left: ${p => p.theme.listItemActionsPaddingLeft}em;
|
|
48
|
-
background: linear-gradient(
|
|
49
|
-
to right,
|
|
50
|
-
${p => clr([...p.theme.colorBg.slice(0, 3), 0])},
|
|
51
|
-
${p => clr(p.theme.colorBg)}
|
|
52
|
-
${p => p.theme.listItemActionsPaddingLeft}em
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
${hasSwipeStyles};
|
|
56
|
-
${openedStyles};
|
|
57
|
-
${horizontalPaddingStyles('right')};
|
|
58
|
-
`;
|
|
59
|
-
let actionIndex = 0;
|
|
60
|
-
|
|
61
|
-
// Used by ListItem, ListItemLink
|
|
62
|
-
const ListItemContent = ({
|
|
63
|
-
title,
|
|
64
|
-
description,
|
|
65
|
-
left,
|
|
66
|
-
right,
|
|
67
|
-
actions = [],
|
|
68
|
-
hasSwipe,
|
|
69
|
-
opened
|
|
70
|
-
}) => /*#__PURE__*/React.createElement(React.Fragment, null, left && /*#__PURE__*/React.createElement(LeftAddon, null, left), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(Title, null, title), description && /*#__PURE__*/React.createElement(Description, null, description)), right && /*#__PURE__*/React.createElement(RightAddon, null, right), actions.length > 0 && /*#__PURE__*/React.createElement(Actions, {
|
|
71
|
-
hasSwipe: hasSwipe,
|
|
72
|
-
opened: opened
|
|
73
|
-
}, actions.map(({
|
|
74
|
-
icon,
|
|
75
|
-
onClick = () => {},
|
|
76
|
-
...actionRest
|
|
77
|
-
}) => {
|
|
78
|
-
actionIndex += 1;
|
|
79
|
-
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
80
|
-
type: "ghost",
|
|
81
|
-
wide: "never",
|
|
82
|
-
size: "small",
|
|
83
|
-
key: actionIndex,
|
|
84
|
-
onClick: e => {
|
|
85
|
-
e.preventDefault();
|
|
86
|
-
onClick(e);
|
|
87
|
-
}
|
|
88
|
-
}, actionRest), icon);
|
|
89
|
-
})));
|
|
90
|
-
ListItemContent.displayName = 'ListItemContent';
|
|
91
|
-
export default ListItemContent;
|
|
92
|
-
//# sourceMappingURL=ListItemContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemContent.js","names":["React","styled","clr","ellipsisStyles","horizontalPaddingStyles","transitionStyles","omitEmotionProps","css","Button","Content","div","Title","p","theme","colorText","Description","listItemColorDescription","sizes","small","LeftAddon","listItemAddonPaddingHorizontal","RightAddon","hasSwipeStyles","hasSwipe","openedStyles","opened","Actions","listItemActionsPaddingLeft","colorBg","slice","actionIndex","ListItemContent","title","description","left","right","actions","length","map","icon","onClick","actionRest","e","preventDefault","displayName"],"sources":["../../../src/ListItem/ListItemContent.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { clr, Color } from '@os-design/theming';\nimport {\n ellipsisStyles,\n horizontalPaddingStyles,\n transitionStyles,\n} from '@os-design/styles';\nimport { omitEmotionProps } from '@os-design/utils';\nimport { css } from '@emotion/react';\nimport Button, { ButtonProps } from '../Button';\n\nexport interface ListItemAction\n extends Omit<ButtonProps, 'leftIcon' | 'rightIcon' | 'wide'> {\n icon: React.ReactElement;\n}\n\nexport interface ListItemContentProps {\n /**\n * The title of the item.\n */\n title: string;\n /**\n * The description of the item.\n * @default undefined\n */\n description?: string;\n /**\n * The component located on the left side.\n * For example, avatar, button, checkbox.\n * @default undefined\n */\n left?: React.ReactNode;\n /**\n * The component located on the right side.\n * For example, date.\n */\n right?: React.ReactNode;\n /**\n * Buttons to control the item.\n * For example, edit, delete.\n * @default undefined\n */\n actions?: ListItemAction[];\n\n hasSwipe: boolean;\n opened: boolean;\n}\n\nconst Content = styled.div`\n overflow: hidden;\n`;\n\nconst Title = styled.div`\n color: ${(p) => clr(p.theme.colorText)};\n font-weight: 500;\n ${ellipsisStyles};\n`;\n\nconst Description = styled.div`\n color: ${(p) => clr(p.theme.listItemColorDescription)};\n font-size: ${(p) => p.theme.sizes.small}em;\n ${ellipsisStyles};\n`;\n\nexport const LeftAddon = styled.div`\n color: ${(p) => clr(p.theme.colorText)};\n padding-right: ${(p) => p.theme.listItemAddonPaddingHorizontal}em;\n`;\n\nexport const RightAddon = styled.div`\n color: ${(p) => clr(p.theme.colorText)};\n margin-left: auto;\n padding-left: ${(p) => p.theme.listItemAddonPaddingHorizontal}em;\n`;\n\nconst hasSwipeStyles = (p) =>\n p.hasSwipe &&\n css`\n transform: translateX(100%);\n ${transitionStyles('transform')(p)};\n `;\n\nconst openedStyles = (p) =>\n p.opened &&\n css`\n transform: translateX(0);\n `;\n\ninterface ActionsProps {\n hasSwipe: boolean;\n opened: boolean;\n}\nconst Actions = styled(\n 'nav',\n omitEmotionProps('hasSwipe', 'opened')\n)<ActionsProps>`\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n\n display: flex;\n align-items: center;\n\n padding-left: ${(p) => p.theme.listItemActionsPaddingLeft}em;\n background: linear-gradient(\n to right,\n ${(p) => clr([...p.theme.colorBg.slice(0, 3), 0] as Color)},\n ${(p) => clr(p.theme.colorBg)}\n ${(p) => p.theme.listItemActionsPaddingLeft}em\n );\n\n ${hasSwipeStyles};\n ${openedStyles};\n ${horizontalPaddingStyles('right')};\n`;\n\nlet actionIndex = 0;\n\n// Used by ListItem, ListItemLink\nconst ListItemContent: React.FC<ListItemContentProps> = ({\n title,\n description,\n left,\n right,\n actions = [],\n hasSwipe,\n opened,\n}) => (\n <>\n {left && <LeftAddon>{left}</LeftAddon>}\n\n <Content>\n <Title>{title}</Title>\n {description && <Description>{description}</Description>}\n </Content>\n\n {right && <RightAddon>{right}</RightAddon>}\n\n {actions.length > 0 && (\n <Actions hasSwipe={hasSwipe} opened={opened}>\n {actions.map(({ icon, onClick = () => {}, ...actionRest }) => {\n actionIndex += 1;\n return (\n <Button\n type='ghost'\n wide='never'\n size='small'\n key={actionIndex}\n onClick={(e) => {\n e.preventDefault();\n onClick(e);\n }}\n {...actionRest}\n >\n {icon}\n </Button>\n );\n })}\n </Actions>\n )}\n </>\n);\n\nListItemContent.displayName = 'ListItemContent';\n\nexport default ListItemContent;\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,GAAG,QAAe,oBAAoB;AAC/C,SACEC,cAAc,EACdC,uBAAuB,EACvBC,gBAAgB,QACX,mBAAmB;AAC1B,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,MAAM,MAAuB,WAAW;AAuC/C,MAAMC,OAAO,GAAGR,MAAM,CAACS,GAAI;AAC3B;AACA,CAAC;AAED,MAAMC,KAAK,GAAGV,MAAM,CAACS,GAAI;AACzB,WAAYE,CAAC,IAAKV,GAAG,CAACU,CAAC,CAACC,KAAK,CAACC,SAAS,CAAE;AACzC;AACA,IAAIX,cAAe;AACnB,CAAC;AAED,MAAMY,WAAW,GAAGd,MAAM,CAACS,GAAI;AAC/B,WAAYE,CAAC,IAAKV,GAAG,CAACU,CAAC,CAACC,KAAK,CAACG,wBAAwB,CAAE;AACxD,eAAgBJ,CAAC,IAAKA,CAAC,CAACC,KAAK,CAACI,KAAK,CAACC,KAAM;AAC1C,IAAIf,cAAe;AACnB,CAAC;AAED,OAAO,MAAMgB,SAAS,GAAGlB,MAAM,CAACS,GAAI;AACpC,WAAYE,CAAC,IAAKV,GAAG,CAACU,CAAC,CAACC,KAAK,CAACC,SAAS,CAAE;AACzC,mBAAoBF,CAAC,IAAKA,CAAC,CAACC,KAAK,CAACO,8BAA+B;AACjE,CAAC;AAED,OAAO,MAAMC,UAAU,GAAGpB,MAAM,CAACS,GAAI;AACrC,WAAYE,CAAC,IAAKV,GAAG,CAACU,CAAC,CAACC,KAAK,CAACC,SAAS,CAAE;AACzC;AACA,kBAAmBF,CAAC,IAAKA,CAAC,CAACC,KAAK,CAACO,8BAA+B;AAChE,CAAC;AAED,MAAME,cAAc,GAAI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,GAAG,CAAC,iBACjB,oBAAC,OAAO;EAAC,QAAQ,EAAEd,QAAS;EAAC,MAAM,EAAEE;AAAO,GACzCW,OAAO,CAACE,GAAG,CAAC,CAAC;EAAEC,IAAI;EAAEC,OAAO,GAAG,MAAM,CAAC,CAAC;EAAE,GAAGC;AAAW,CAAC,KAAK;EAC5DX,WAAW,IAAI,CAAC;EAChB,oBACE,oBAAC,MAAM;IACL,IAAI,EAAC,OAAO;IACZ,IAAI,EAAC,OAAO;IACZ,IAAI,EAAC,OAAO;IACZ,GAAG,EAAEA,WAAY;IACjB,OAAO,EAAGY,CAAC,IAAK;MACdA,CAAC,CAACC,cAAc,EAAE;MAClBH,OAAO,CAACE,CAAC,CAAC;IACZ;EAAE,GACED,UAAU,GAEbF,IAAI,CACE;AAEb,CAAC,CAAC,CAEL,CAEJ;AAEDR,eAAe,CAACa,WAAW,GAAG,iBAAiB;AAE/C,eAAeb,eAAe"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ButtonProps } from '../Button';
|
|
3
|
-
export interface ListItemAction extends Omit<ButtonProps, 'leftIcon' | 'rightIcon' | 'wide'> {
|
|
4
|
-
icon: React.ReactElement;
|
|
5
|
-
}
|
|
6
|
-
export interface ListItemContentProps {
|
|
7
|
-
title: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
left?: React.ReactNode;
|
|
10
|
-
right?: React.ReactNode;
|
|
11
|
-
actions?: ListItemAction[];
|
|
12
|
-
hasSwipe: boolean;
|
|
13
|
-
opened: boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare const LeftAddon: import("@emotion/styled").StyledComponent<{
|
|
16
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
17
|
-
as?: React.ElementType<any> | undefined;
|
|
18
|
-
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
19
|
-
export declare const RightAddon: import("@emotion/styled").StyledComponent<{
|
|
20
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
21
|
-
as?: React.ElementType<any> | undefined;
|
|
22
|
-
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
23
|
-
declare const ListItemContent: React.FC<ListItemContentProps>;
|
|
24
|
-
export default ListItemContent;
|
|
25
|
-
//# sourceMappingURL=ListItemContent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemContent.d.ts","sourceRoot":"","sources":["../../../src/ListItem/ListItemContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;IAC5D,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IAInC,KAAK,EAAE,MAAM,CAAC;IAKd,WAAW,CAAC,EAAE,MAAM,CAAC;IAMrB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAKvB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAMxB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAE3B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB;AAkBD,eAAO,MAAM,SAAS;;;qFAGrB,CAAC;AAEF,eAAO,MAAM,UAAU;;;qFAItB,CAAC;AA+CF,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA0CnD,CAAC;AAIF,eAAe,eAAe,CAAC"}
|