@smart-react-components/ui 2.0.0-alpha-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.
@@ -0,0 +1,9 @@
1
+ import { StyledProps } from '@smart-react-components/core/styled-props';
2
+ import { Partial, ResponsiveProp } from '@smart-react-components/core/types';
3
+ export interface Props extends StyledProps, Partial<ResponsiveProp<'col', number>>, Partial<ResponsiveProp<'pos', number>> {
4
+ }
5
+ declare const _default: import("styled-components").StyledComponent<"div", any, StyledProps & {
6
+ getCol: (v: any) => string;
7
+ getPos: (v: any) => string;
8
+ } & Props, "getCol" | "getPos">;
9
+ export default _default;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ const grid_1 = require("../../constants/grid");
9
+ exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
10
+ getCol: v => `
11
+ flex: 0 0 ${grid_1.columns[v]}%;
12
+ max-width: ${grid_1.columns[v]}%;
13
+ `,
14
+ getPos: v => `
15
+ margin-left: ${v < 0 ? '-' : ''}${grid_1.columns[Math.abs(v)]}%;
16
+ `,
17
+ }) `
18
+ box-sizing: border-box;
19
+ width: 100%;
20
+ `;
@@ -0,0 +1,3 @@
1
+ import { StyledProps } from '@smart-react-components/core/styled-props';
2
+ declare const _default: import("styled-components").StyledComponent<"div", any, StyledProps, never>;
3
+ export default _default;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ marginHorizontal = 'auto' }) => ({
9
+ marginHorizontal,
10
+ maxWidthSm: '{length.grid.containerWidth.small}px',
11
+ maxWidthMd: '{length.grid.containerWidth.medium}px',
12
+ maxWidthLg: '{length.grid.containerWidth.large}px',
13
+ maxWidthXl: '{length.grid.containerWidth.xlarge}px',
14
+ })) `
15
+ box-sizing: border-box;
16
+ max-width: 100%;
17
+ `;
@@ -0,0 +1,3 @@
1
+ import { StyledProps } from '@smart-react-components/core/styled-props';
2
+ declare const _default: import("styled-components").StyledComponent<"div", any, StyledProps, never>;
3
+ export default _default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ exports.default = (0, styled_components_1.default)(Div_1.default) `
9
+ box-sizing: border-box;
10
+ display: flex;
11
+ flex-wrap: wrap;
12
+ `;
@@ -0,0 +1,3 @@
1
+ export { default as Column } from './Column';
2
+ export { default as Container } from './Container';
3
+ export { default as Row } from './Row';
package/Grid/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Row = exports.Container = exports.Column = void 0;
7
+ var Column_1 = require("./Column");
8
+ Object.defineProperty(exports, "Column", { enumerable: true, get: function () { return __importDefault(Column_1).default; } });
9
+ var Container_1 = require("./Container");
10
+ Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return __importDefault(Container_1).default; } });
11
+ var Row_1 = require("./Row");
12
+ Object.defineProperty(exports, "Row", { enumerable: true, get: function () { return __importDefault(Row_1).default; } });
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Cevad Tokatlı
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
13
+ all 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
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # UI
2
+
3
+ `@smart-react-components/ui` includes UI React and Styled components.
4
+
5
+ ```sh
6
+ # NPM
7
+ $ npm install --save @smart-react-components/ui
8
+
9
+ # Yarn
10
+ $ yarn add @smart-react-components/ui
11
+ ```
12
+
13
+ > [The core](https://github.com/cevadtokatli/smart-react-components/tree/v2/core), [router](https://github.com/cevadtokatli/smart-react-components/tree/v2/router), and [transition](https://github.com/cevadtokatli/smart-react-components/tree/v2/transition) are required for the UI components.
@@ -0,0 +1,10 @@
1
+ import { PaletteProp } from '@smart-react-components/core/types';
2
+ interface Props {
3
+ duration: number;
4
+ left: number;
5
+ palette: PaletteProp;
6
+ scale: number;
7
+ top: number;
8
+ }
9
+ declare const _default: import("styled-components").StyledComponent<"div", any, import("@smart-react-components/core").StyledProps & Props, never>;
10
+ export default _default;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ exports.default = (0, styled_components_1.default)(Div_1.default)(({ duration, left, palette, scale, theme, top }) => `
9
+ background: ${theme.$.palette[palette].waveEffect};
10
+ border-radius: 50%;
11
+ height: 100px;
12
+ left: ${left}px;
13
+ margin: -50px 0 0 -50px;
14
+ opacity: .75;
15
+ pointer-events: none;
16
+ position: absolute;
17
+ transform: scale(${scale});
18
+ top: ${top}px;
19
+ width: 100px;
20
+
21
+ &.src-wave-effect-show {
22
+ opacity: 0;
23
+ transform: scale(0);
24
+ }
25
+
26
+ &.src-wave-effect-show-active {
27
+ opacity: .75;
28
+ transform: scale(${scale});
29
+ }
30
+
31
+ &.src-wave-effect-hide-active {
32
+ opacity: 0;
33
+ }
34
+
35
+ &.src-wave-effect-show-active,
36
+ &.src-wave-effect-hide-active {
37
+ transition: ease-out ${duration}ms;
38
+ transition-property: opacity, transform;
39
+ }
40
+ `);
@@ -0,0 +1,9 @@
1
+ import { PaletteProp } from '@smart-react-components/core/types';
2
+ import React from 'react';
3
+ export interface Props {
4
+ children: JSX.Element;
5
+ duration?: number;
6
+ palette?: PaletteProp;
7
+ }
8
+ declare const WaveEffect: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
9
+ export default WaveEffect;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const dom_1 = require("@smart-react-components/core/util/dom");
7
+ const CSSTransitionGroup_1 = __importDefault(require("@smart-react-components/transition/CSSTransitionGroup"));
8
+ const react_1 = __importDefault(require("react"));
9
+ const styled_components_1 = require("styled-components");
10
+ const WaveEffectElement_1 = __importDefault(require("./WaveEffectElement"));
11
+ const WaveEffect = react_1.default.forwardRef(({ children, duration, palette = 'light' }, forwardRef) => {
12
+ var _a;
13
+ const theme = react_1.default.useContext(styled_components_1.ThemeContext);
14
+ const [effectItems, setEffectItems] = react_1.default.useState(() => []);
15
+ const isProcessing = react_1.default.useRef(false);
16
+ const ref = (_a = (forwardRef !== null && forwardRef !== void 0 ? forwardRef : children.ref)) !== null && _a !== void 0 ? _a : react_1.default.useRef(null);
17
+ const getDuration = () => duration !== null && duration !== void 0 ? duration : theme.$.transition.waveEffectDuration;
18
+ react_1.default.useEffect(() => {
19
+ if (effectItems.length > 0) {
20
+ (0, dom_1.addEventListener)(window, [dom_1.isMobile ? 'touchmove' : 'mousemove'], handleMove);
21
+ (0, dom_1.addEventListener)(window, [dom_1.isMobile ? 'touchend' : 'mouseup'], handleEnd);
22
+ return () => {
23
+ (0, dom_1.removeEventListener)(window, [dom_1.isMobile ? 'touchmove' : 'mousemove'], handleMove);
24
+ (0, dom_1.removeEventListener)(window, [dom_1.isMobile ? 'touchend' : 'mouseup'], handleEnd);
25
+ };
26
+ }
27
+ }, [effectItems]);
28
+ const handleMouseDown = (e) => {
29
+ var _a, _b;
30
+ (_b = (_a = children.props) === null || _a === void 0 ? void 0 : _a.onMouseDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
31
+ if (!dom_1.isMobile && e.button === 0) {
32
+ start(e);
33
+ }
34
+ };
35
+ const handleTouchStart = (e) => {
36
+ var _a, _b;
37
+ (_b = (_a = children.props) === null || _a === void 0 ? void 0 : _a.onTouchStart) === null || _b === void 0 ? void 0 : _b.call(_a, e);
38
+ start(e);
39
+ };
40
+ const start = (e) => {
41
+ isProcessing.current = true;
42
+ const rect = ref.current.getBoundingClientRect();
43
+ const scale = (ref.current.clientWidth / 100) * 2;
44
+ let left;
45
+ let top;
46
+ if (dom_1.isMobile) {
47
+ const t = e.touches[0];
48
+ left = (t.pageX - window.pageXOffset) - rect.left;
49
+ top = (t.pageY - window.pageYOffset) - rect.top;
50
+ }
51
+ else {
52
+ left = e.clientX - rect.left;
53
+ top = e.clientY - rect.top;
54
+ }
55
+ setEffectItems([
56
+ ...effectItems,
57
+ {
58
+ element: (react_1.default.createElement(WaveEffectElement_1.default, { key: new Date().getTime(), duration: getDuration() / 2, left: left, palette: palette, scale: scale, top: top })),
59
+ endTime: new Date().getTime() + getDuration(),
60
+ },
61
+ ]);
62
+ };
63
+ const handleMove = (e) => {
64
+ if (e.target !== ref.current && !ref.current.contains(e.target)) {
65
+ handleEnd();
66
+ }
67
+ };
68
+ const handleEnd = () => {
69
+ isProcessing.current = false;
70
+ const time = new Date().getTime();
71
+ setEffectItems(effectItems.filter(e => e.endTime >= time));
72
+ };
73
+ const handleAfterShow = (child) => {
74
+ if (!isProcessing.current
75
+ || (isProcessing.current
76
+ && effectItems.findIndex(e => e.element.key === child.key) + 1 < effectItems.length)) {
77
+ setEffectItems(effectItems.filter(e => e.element.key !== child.key));
78
+ }
79
+ };
80
+ return react_1.default.cloneElement(children, {
81
+ children: (react_1.default.createElement(react_1.default.Fragment, null,
82
+ children.props.children,
83
+ react_1.default.createElement(CSSTransitionGroup_1.default, { afterShow: handleAfterShow, className: "src-wave-effect", duration: getDuration() / 2 }, effectItems.map(e => e.element)))),
84
+ onMouseDown: handleMouseDown,
85
+ onTouchStart: handleTouchStart,
86
+ overflow: 'hidden',
87
+ position: 'relative',
88
+ ref,
89
+ webkitTapHighlightColor: 'transparent',
90
+ });
91
+ });
92
+ exports.default = WaveEffect;
@@ -0,0 +1 @@
1
+ export declare const columns: number[];
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.columns = void 0;
4
+ exports.columns = [0, 8.333333, 16.666667, 25, 33.333333, 41.666667, 50, 58.333333, 66.666667, 75, 83.333333, 91.666667, 100];
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './Grid';
2
+ export { default as WaveEffect } from './WaveEffect';
package/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.WaveEffect = void 0;
21
+ __exportStar(require("./Grid"), exports);
22
+ var WaveEffect_1 = require("./WaveEffect");
23
+ Object.defineProperty(exports, "WaveEffect", { enumerable: true, get: function () { return __importDefault(WaveEffect_1).default; } });
package/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "@smart-react-components/ui",
3
+ "version": "2.0.0-alpha-1",
4
+ "license": "MIT",
5
+ "main": "index.js",
6
+ "description": "SRC UI includes React and Styled components.",
7
+ "keywords": [
8
+ "javascript",
9
+ "typescript",
10
+ "react",
11
+ "styled-components",
12
+ "react-ui-library",
13
+ "alert",
14
+ "badge",
15
+ "breadcrumb",
16
+ "button",
17
+ "checkbox",
18
+ "color-picker",
19
+ "date-picker",
20
+ "dropdown",
21
+ "fixed-box",
22
+ "form",
23
+ "grid",
24
+ "input",
25
+ "loading",
26
+ "modal",
27
+ "overlay",
28
+ "pagination",
29
+ "pop-up",
30
+ "popover",
31
+ "progress-bar",
32
+ "radio",
33
+ "select",
34
+ "switch",
35
+ "table",
36
+ "textarea",
37
+ "tooltip",
38
+ "wave-effect"
39
+ ],
40
+ "author": {
41
+ "name": "Cevad Tokatlı",
42
+ "email": "cevadtokatli@hotmail.com"
43
+ },
44
+ "contributors": [
45
+ {
46
+ "name": "Cemil Tokatlı",
47
+ "email": "cemil@tokatli.me"
48
+ }
49
+ ],
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "https://github.com/cevadtokatli/smart-react-components/tree/v2/ui"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "scripts": {
58
+ "build": "yarn clear && tsc --outDir lib && yarn copy",
59
+ "clear": "rm -rf lib",
60
+ "copy": "cp package.json lib/package.json && cp README.md lib/README.md && cp ../LICENSE lib/LICENSE",
61
+ "dev": "tsc -w --outDir lib",
62
+ "lint": "eslint src",
63
+ "release": "../scripts/release.sh ui",
64
+ "test": "jest"
65
+ },
66
+ "devDependencies": {
67
+ "@smart-react-components/core": "2.0.0-alpha-8",
68
+ "@smart-react-components/router": "2.0.0-alpha-3",
69
+ "@smart-react-components/transition": "2.0.0-alpha-4",
70
+ "@testing-library/react": "13.4.0",
71
+ "@types/jest": "29.0.1",
72
+ "@types/react": "18.0.19",
73
+ "@types/react-dom": "18.0.6",
74
+ "@types/styled-components": "5.1.26",
75
+ "eslint": "8.0.1",
76
+ "jest": "29.0.3",
77
+ "jest-environment-jsdom": "29.3.1",
78
+ "jest-styled-components": "7.1.1",
79
+ "react": "18.2.0",
80
+ "react-dom": "18.2.0",
81
+ "styled-components": "5.3.5",
82
+ "ts-jest": "29.0.0",
83
+ "typescript": "4.8.3"
84
+ },
85
+ "peerDependencies": {
86
+ "@smart-react-components/core": "^2.0.0-alpha-8",
87
+ "@smart-react-components/router": "^2.0.0-alpha-3",
88
+ "@smart-react-components/transition": "^2.0.0-alpha-4",
89
+ "react": "^18.2.0",
90
+ "styled-components": "^5.3.5"
91
+ }
92
+ }
@@ -0,0 +1 @@
1
+ import 'jest-styled-components';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("jest-styled-components");