@synerise/ds-list-item 0.0.1

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Synerise
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ ---
2
+ id: list-item
3
+ title: ListItem
4
+ ---
5
+
6
+ ListItem UI Component
7
+
8
+ ## Installation
9
+ ```
10
+ npm i @synerise/ds-list-item
11
+ or
12
+ yarn add @synerise/ds-list-item
13
+ ```
14
+
15
+ ## Usage
16
+ ```
17
+ import ListItem from '@synerise/ds-list-item'
18
+
19
+ <ListItem />
20
+
21
+ ```
22
+
23
+ ## Demo
24
+
25
+ <iframe src="/storybook-static/iframe.html?id=components-list-item--default"></iframe>
26
+
27
+ ## API
28
+
29
+
30
+ | Property | Description | Type | Default |
31
+ |-----------------------------|---------------------------|--------------------|------------|
32
+ | className | Extra styles | string | - |
33
+ | children | ListItem content | React.ReactNode | - |
34
+ | icon | Icon for ListItem | React.ReactNode | - |
35
+ | switch | Switch for ListItem | boolean | false |
36
+ | title | Text for tooltip | string | - |
37
+ | danger | Danger color for ListItem | boolean | false |
38
+ | prefixCls | Adjust base className | string | 'ant-menu' |
39
+ | direction | Text direction | 'ltr' &#124; 'rtl' | 'ltr' | - |
40
+ | disableListItemTitleTooltip | Disable tooltip | boolean | true |
41
+ | noHover | Disable hover | boolean &#124; undefined | false | - |
42
+ | size | ListItem size | 'default' &#124; 'large' | default | - |
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ export type ListItemProps = {
3
+ className?: string;
4
+ children?: React.ReactNode;
5
+ icon?: React.ReactNode;
6
+ danger?: boolean;
7
+ prefixCls?: string;
8
+ direction?: 'ltr' | 'rtl';
9
+ switch?: boolean;
10
+ title?: string;
11
+ noHover?: boolean;
12
+ size?: 'default' | 'large';
13
+ selectable?: boolean;
14
+ } & React.HTMLAttributes<HTMLDivElement>;
15
+ declare const ListItem: (props: ListItemProps) => JSX.Element;
16
+ export default ListItem;
@@ -0,0 +1,56 @@
1
+ var _excluded = ["className", "children", "icon", "danger", "prefixCls", "title", "noHover", "size", "selectable"];
2
+
3
+ function _extends() { _extends = Object.assign || 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); }
4
+
5
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
+
7
+ import React, { useState } from 'react';
8
+ import StyledListItem, { StyledIconWrapper } from './ListItem.styles';
9
+
10
+ var ListItem = function ListItem(props) {
11
+ var className = props.className,
12
+ children = props.children,
13
+ icon = props.icon,
14
+ danger = props.danger,
15
+ _props$prefixCls = props.prefixCls,
16
+ prefixCls = _props$prefixCls === void 0 ? 'ant-menu' : _props$prefixCls,
17
+ title = props.title,
18
+ noHover = props.noHover,
19
+ size = props.size,
20
+ _props$selectable = props.selectable,
21
+ selectable = _props$selectable === void 0 ? true : _props$selectable,
22
+ rest = _objectWithoutPropertiesLoose(props, _excluded);
23
+
24
+ var _useState = useState(false),
25
+ isSelected = _useState[0],
26
+ setIsSelected = _useState[1];
27
+
28
+ var handleClick = function handleClick() {
29
+ setIsSelected(true);
30
+ };
31
+
32
+ var handleMouseLeave = function handleMouseLeave() {
33
+ setIsSelected(false);
34
+ };
35
+
36
+ var renderItemChildren = function renderItemChildren() {
37
+ return /*#__PURE__*/React.createElement("span", {
38
+ className: prefixCls + "-title-content"
39
+ }, children);
40
+ };
41
+
42
+ var listItemNode = /*#__PURE__*/React.createElement(StyledListItem, _extends({
43
+ className: "ds-search-item " + className + " " + (isSelected ? 'selected' : ''),
44
+ title: title || (typeof children === 'string' ? children : undefined),
45
+ onClick: handleClick,
46
+ onMouseLeave: handleMouseLeave,
47
+ tabIndex: 0,
48
+ noHover: noHover,
49
+ size: size,
50
+ selectable: selectable,
51
+ isSelected: isSelected
52
+ }, rest), icon && /*#__PURE__*/React.createElement(StyledIconWrapper, null, icon), renderItemChildren());
53
+ return listItemNode;
54
+ };
55
+
56
+ export default ListItem;
@@ -0,0 +1,22 @@
1
+ import { ReactNode } from 'react';
2
+ type StyledListItemProps = {
3
+ disabled?: boolean;
4
+ selected?: boolean;
5
+ prefixel?: ReactNode;
6
+ suffixel?: boolean;
7
+ description?: ReactNode;
8
+ ordered?: boolean;
9
+ active?: boolean;
10
+ indentLevel?: number;
11
+ visible?: boolean;
12
+ highlight?: boolean;
13
+ danger?: boolean;
14
+ noHover?: boolean;
15
+ switch?: boolean;
16
+ isSelected?: boolean;
17
+ selectable?: boolean;
18
+ size?: 'default' | 'large';
19
+ };
20
+ declare const StyledListItem: import("styled-components").StyledComponent<"div", any, StyledListItemProps, never>;
21
+ export declare const StyledIconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
22
+ export default StyledListItem;
@@ -0,0 +1,55 @@
1
+ import styled, { css } from 'styled-components';
2
+ var baseStyles = css(["display:flex;align-items:center;min-width:200px;margin:0;padding-left:", ";padding-right:12px;font-size:13px;line-height:1.39;font-weight:500;user-select:none;border-radius:3px;transition:background-color 0.2s ease-out,color 0.2s ease-out;min-height:", ";background:none;border:none;color:", ";cursor:pointer;opacity:1;"], function (props) {
3
+ return props.prefixel ? '8px' : '12px';
4
+ }, function (props) {
5
+ return props.size === 'large' ? '50px' : '32px';
6
+ }, function (props) {
7
+ return props.theme.palette['grey-700'];
8
+ });
9
+ var disabledStyle = css(["cursor:not-allowed;opacity:0.4;"]);
10
+ var selectedStyle = css(["background:", ";color:", ";border:1px solid ", ";"], function (props) {
11
+ return props.theme.palette['blue-050'];
12
+ }, function (props) {
13
+ return props.theme.palette['blue-600'];
14
+ }, function (props) {
15
+ return props.theme.palette['blue-600'];
16
+ });
17
+ var hoverStyle = css(["&:hover{background:", ";color:", ";}"], function (props) {
18
+ return props.theme.palette['grey-050'];
19
+ }, function (props) {
20
+ return props.noHover ? props.theme.palette['grey-700'] : props.theme.palette['blue-600'];
21
+ });
22
+ var focusStyle = css(["&:focus,&.selected{box-shadow:", ";outline:none;}"], function (props) {
23
+ return props["switch"] ? 'none' : "inset 0 0 0 2px " + props.theme.palette['blue-600'];
24
+ });
25
+ var nonSelectableStyle = css(["pointer-events:none;cursor:default;"]);
26
+ var highlightStyle = css(["font-weight:400;& > .search-highlight{font-weight:600;}"]);
27
+ var orderedStyle = css(["&::before{content:none;}"]);
28
+ var dangerStyle = css(["&:hover{color:", ";background:", ";border-color:", ";}"], function (props) {
29
+ return props.theme.palette['red-600'];
30
+ }, function (props) {
31
+ return props.theme.palette['red-050'];
32
+ }, function (props) {
33
+ return props.theme.palette['red-600'];
34
+ });
35
+ var StyledListItem = styled.div.withConfig({
36
+ displayName: "ListItemstyles__StyledListItem",
37
+ componentId: "sc-127s7ku-0"
38
+ })(["", " ", " ", " ", " ", " ", " ", " ", " ", ""], baseStyles, function (props) {
39
+ return props.disabled && disabledStyle;
40
+ }, function (props) {
41
+ return props.selected && !props["switch"] && selectedStyle;
42
+ }, hoverStyle, focusStyle, function (props) {
43
+ return !props.selectable && !props.noHover && nonSelectableStyle;
44
+ }, function (props) {
45
+ return props.highlight && highlightStyle;
46
+ }, function (props) {
47
+ return !props.ordered && orderedStyle;
48
+ }, function (props) {
49
+ return props.danger && dangerStyle;
50
+ });
51
+ export var StyledIconWrapper = styled.div.withConfig({
52
+ displayName: "ListItemstyles__StyledIconWrapper",
53
+ componentId: "sc-127s7ku-1"
54
+ })(["margin-right:12px;"]);
55
+ export default StyledListItem;
@@ -0,0 +1 @@
1
+ export { default } from './ListItem';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from './ListItem';
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom/extend-expect';
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@synerise/ds-list-item",
3
+ "version": "0.0.1",
4
+ "description": "ListItem UI Component for the Synerise Design System",
5
+ "license": "ISC",
6
+ "repository": "Synerise/synerise-design",
7
+ "main": "dist/index.js",
8
+ "files": [
9
+ "/dist",
10
+ "CHANGELOG.md",
11
+ "README.md",
12
+ "package.json",
13
+ "LICENSE.md"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "build": "npm run build:js && npm run build:css && npm run defs",
20
+ "build:css": "node ../../../scripts/style/less.js",
21
+ "build:js": "babel --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
22
+ "build:watch": "npm run build:js -- --watch",
23
+ "defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
24
+ "pack:ci": "npm pack --pack-destination ../../portal/storybook-static/static",
25
+ "prepublish": "npm run build",
26
+ "test": "jest",
27
+ "test:watch": "npm run test -- --watchAll",
28
+ "types": "tsc --noEmit"
29
+ },
30
+ "sideEffects": [
31
+ "dist/style/*",
32
+ "*.less"
33
+ ],
34
+ "types": "dist/index.d.ts",
35
+ "dependencies": {
36
+ "@synerise/ds-switch": "^0.4.49"
37
+ },
38
+ "peerDependencies": {
39
+ "@synerise/ds-core": "*",
40
+ "antd": "4.7.0",
41
+ "react": ">=16.9.0 < 17.0.0",
42
+ "styled-components": "5.0.1"
43
+ },
44
+ "devDependencies": {
45
+ "@synerise/ds-utils": "^0.24.21",
46
+ "@testing-library/jest-dom": "5.1.1",
47
+ "@testing-library/react": "10.0.1"
48
+ },
49
+ "gitHead": "fb43cead2fb83955fec72f72adf6b27a876f3369"
50
+ }