@via-profit/ui-kit 0.1.0-rc.60 → 0.1.0-rc.62

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.
@@ -35,7 +35,7 @@ const StyledModalInner = styled_1.default.div `
35
35
  (0, react_2.css) `
36
36
  opacity: 1;
37
37
  transform: translate(-50%, -50%);
38
- ransition:
38
+ transition:
39
39
  transform 240ms ease-out,
40
40
  opacity 100ms ease-out;
41
41
  `}
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { TextFieldIconWrapperProps } from '../TextField/TextFieldIconWrapper';
3
+ export type TextAreaIconWrapperProps = TextFieldIconWrapperProps;
4
+ declare const _default: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLDivElement> & {
5
+ readonly position: "end" | "start";
6
+ readonly error?: boolean | undefined;
7
+ readonly focused?: boolean | undefined;
8
+ } & React.RefAttributes<HTMLDivElement>>;
9
+ export default _default;
@@ -0,0 +1,53 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __rest = (this && this.__rest) || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const React = __importStar(require("react"));
41
+ const styled_1 = __importDefault(require("@emotion/styled"));
42
+ const TextFieldIconWrapper_1 = __importDefault(require("../TextField/TextFieldIconWrapper"));
43
+ const StyledTextFieldIconWrapper = (0, styled_1.default)(TextFieldIconWrapper_1.default) `
44
+ align-items: flex-start;
45
+ & > svg {
46
+ margin: 1em;
47
+ }
48
+ `;
49
+ const TextAreaIconWrapper = (props, ref) => {
50
+ const { children } = props, restProps = __rest(props, ["children"]);
51
+ return (React.createElement(StyledTextFieldIconWrapper, Object.assign({}, restProps, { ref: ref }), children));
52
+ };
53
+ exports.default = React.forwardRef(TextAreaIconWrapper);
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ export interface TextAreaInputProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
3
+ readonly hasStartIcon: boolean;
4
+ readonly hasEndIcon: boolean;
5
+ }
6
+ declare const _default: React.ForwardRefExoticComponent<TextAreaInputProps & React.RefAttributes<HTMLTextAreaElement>>;
7
+ export default _default;
@@ -0,0 +1,72 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __rest = (this && this.__rest) || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const React = __importStar(require("react"));
41
+ const styled_1 = __importDefault(require("@emotion/styled"));
42
+ const react_1 = require("@emotion/react");
43
+ const TextareaNative = styled_1.default.textarea `
44
+ resize: none;
45
+ padding: 1em 1.2em;
46
+ font-size: 1em;
47
+ background: none;
48
+ border-radius: inherit;
49
+ margin: 0;
50
+ border: 0;
51
+ width: ${({ cols }) => (typeof cols !== 'undefined' ? 'auto' : '100%')};
52
+ color: currentColor;
53
+ ${({ $hasStartIcon }) => $hasStartIcon &&
54
+ (0, react_1.css) `
55
+ padding-left: 0;
56
+ `};
57
+ ${({ $hasEndIcon }) => $hasEndIcon &&
58
+ (0, react_1.css) `
59
+ padding-right: 0;
60
+ `};
61
+ &:focus {
62
+ outline: none;
63
+ }
64
+ &::placeholder {
65
+ font-style: italic;
66
+ }
67
+ `;
68
+ const TextAreaInput = (props, ref) => {
69
+ const { hasEndIcon, hasStartIcon } = props, nativeProps = __rest(props, ["hasEndIcon", "hasStartIcon"]);
70
+ return (React.createElement(TextareaNative, Object.assign({}, nativeProps, { "$hasEndIcon": hasEndIcon, "$hasStartIcon": hasStartIcon, ref: ref })));
71
+ };
72
+ exports.default = React.forwardRef(TextAreaInput);
@@ -0,0 +1,80 @@
1
+ import * as React from 'react';
2
+ import { TextFieldContainerProps } from '../TextField/TextFieldContainer';
3
+ import { TextFieldLabelProps } from '../TextField/TextFieldLabel';
4
+ import { TextFieldLabelAsteriskProps } from '../TextField/TextFieldLabelAsterisk';
5
+ import { TextFieldInputWrapperProps } from '../TextField/TextFieldInputWrapper';
6
+ import { TextAreaInputProps } from '../TextArea/TextAreaInput';
7
+ import { TextFieldErrorTextProps } from '../TextField/TextFieldErrorText';
8
+ import { TextAreaIconWrapperProps } from './TextAreaIconWrapper';
9
+ export interface TextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
10
+ /**
11
+ * If true then `errorText` value will be displayed under the TextField element
12
+ */
13
+ readonly error?: boolean;
14
+ /**
15
+ * If is true then the asterisk will be displayed in label\
16
+ * If is ReactNode then ReactNode will be displayed in label
17
+ */
18
+ readonly requiredAsterisk?: boolean | React.ReactNode;
19
+ /**
20
+ * Text or ReactNode to show in error element\
21
+ * Will be displaed only if `error` property is tru
22
+ */
23
+ readonly errorText?: React.ReactNode;
24
+ /**
25
+ * If true then TextField will be filled in full width on horizontal
26
+ */
27
+ readonly fullWidth?: boolean;
28
+ /**
29
+ * Native <input> element reference
30
+ */
31
+ readonly inputRef?: React.MutableRefObject<HTMLTextAreaElement | null> | React.RefCallback<HTMLTextAreaElement | null>;
32
+ /**
33
+ * Field label text or element
34
+ */
35
+ readonly label?: React.ReactNode;
36
+ /**
37
+ * End icon component
38
+ */
39
+ readonly endIcon?: React.ReactElement;
40
+ /**
41
+ * Start icon component
42
+ */
43
+ readonly startIcon?: React.ReactElement;
44
+ /**
45
+ * Overridable components map
46
+ */
47
+ readonly overrides?: TextAreaOverrides;
48
+ }
49
+ export interface TextAreaOverrides {
50
+ /**
51
+ * Native `input` component
52
+ */
53
+ readonly Input?: React.ForwardRefExoticComponent<TextAreaInputProps & React.RefAttributes<HTMLTextAreaElement>>;
54
+ /**
55
+ * Component for display error text
56
+ */
57
+ readonly ErrorText?: React.ForwardRefExoticComponent<TextFieldErrorTextProps & React.RefAttributes<HTMLDivElement>>;
58
+ /**
59
+ * Icons wrapper component
60
+ */
61
+ readonly IconWrapper?: React.ForwardRefExoticComponent<TextAreaIconWrapperProps & React.RefAttributes<HTMLDivElement>>;
62
+ /**
63
+ * input field wrapper component
64
+ */
65
+ readonly InputWrapper?: React.ForwardRefExoticComponent<TextFieldInputWrapperProps & React.RefAttributes<HTMLDivElement>>;
66
+ /**
67
+ * label component
68
+ */
69
+ readonly Label?: React.ForwardRefExoticComponent<TextFieldLabelProps & React.RefAttributes<HTMLLabelElement>>;
70
+ /**
71
+ * label asterisk component
72
+ */
73
+ readonly Asterisk?: React.ForwardRefExoticComponent<TextFieldLabelAsteriskProps & React.RefAttributes<HTMLSpanElement>>;
74
+ /**
75
+ * label component
76
+ */
77
+ readonly Container?: React.ForwardRefExoticComponent<TextFieldContainerProps & React.RefAttributes<HTMLDivElement>>;
78
+ }
79
+ declare const _default: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLDivElement>>;
80
+ export default _default;
@@ -0,0 +1,100 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __rest = (this && this.__rest) || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const React = __importStar(require("react"));
41
+ const TextFieldContainer_1 = __importDefault(require("../TextField/TextFieldContainer"));
42
+ const TextFieldLabel_1 = __importDefault(require("../TextField/TextFieldLabel"));
43
+ const TextFieldLabelAsterisk_1 = __importDefault(require("../TextField/TextFieldLabelAsterisk"));
44
+ const TextFieldInputWrapper_1 = __importDefault(require("../TextField/TextFieldInputWrapper"));
45
+ const TextAreaInput_1 = __importDefault(require("../TextArea/TextAreaInput"));
46
+ const TextFieldErrorText_1 = __importDefault(require("../TextField/TextFieldErrorText"));
47
+ const TextAreaIconWrapper_1 = __importDefault(require("./TextAreaIconWrapper"));
48
+ const TextArea = (props, ref) => {
49
+ const { error, fullWidth, inputRef, label, id, errorText, className, style, endIcon, startIcon, requiredAsterisk, overrides, onChange, onFocus, onBlur } = props, nativeInputProps = __rest(props, ["error", "fullWidth", "inputRef", "label", "id", "errorText", "className", "style", "endIcon", "startIcon", "requiredAsterisk", "overrides", "onChange", "onFocus", "onBlur"]);
50
+ const [focused, setFocused] = React.useState(false);
51
+ const inputID = React.useMemo(() => {
52
+ if (typeof id === 'string') {
53
+ return id;
54
+ }
55
+ const u = Date.now().toString(16) + Math.random().toString(16) + '0'.repeat(16);
56
+ const guid = [
57
+ u.substring(0, 8),
58
+ u.substring(8, 12),
59
+ '4000-8' + u.substring(13, 16),
60
+ u.substring(16, 28),
61
+ ].join('-');
62
+ return guid;
63
+ }, [id]);
64
+ const inputChange = React.useCallback(event => {
65
+ if (onChange) {
66
+ onChange(event);
67
+ }
68
+ }, [onChange]);
69
+ const inputFocus = React.useCallback(event => {
70
+ setFocused(true);
71
+ if (typeof onFocus === 'function') {
72
+ onFocus(event);
73
+ }
74
+ }, [onFocus]);
75
+ const inputBlur = React.useCallback(event => {
76
+ setFocused(false);
77
+ if (typeof onBlur === 'function') {
78
+ onBlur(event);
79
+ }
80
+ }, [onBlur]);
81
+ const hasStartIcon = React.useMemo(() => typeof startIcon !== 'undefined' && startIcon !== null, [startIcon]);
82
+ const hasEndIcon = React.useMemo(() => typeof endIcon !== 'undefined' && endIcon !== null, [endIcon]);
83
+ const overridesMap = React.useMemo(() => (Object.assign({ Label: TextFieldLabel_1.default,
84
+ Input: TextAreaInput_1.default,
85
+ Asterisk: TextFieldLabelAsterisk_1.default,
86
+ Container: TextFieldContainer_1.default,
87
+ ErrorText: TextFieldErrorText_1.default,
88
+ IconWrapper: TextAreaIconWrapper_1.default,
89
+ InputWrapper: TextFieldInputWrapper_1.default }, overrides)), [overrides]);
90
+ return (React.createElement(overridesMap.Container, { ref: ref, fullWidth: fullWidth, className: className, style: style, focused: focused },
91
+ typeof label !== 'undefined' && label !== null && (React.createElement(overridesMap.Label, { htmlFor: inputID, error: error },
92
+ label,
93
+ typeof requiredAsterisk !== 'undefined' && requiredAsterisk !== null && (React.createElement(overridesMap.Asterisk, null, typeof requiredAsterisk === 'boolean' ? '*' : requiredAsterisk)))),
94
+ React.createElement(overridesMap.InputWrapper, { error: error, focused: focused, fullWidth: fullWidth },
95
+ hasStartIcon && (React.createElement(overridesMap.IconWrapper, { position: "start" }, startIcon)),
96
+ React.createElement(overridesMap.Input, Object.assign({}, nativeInputProps, { hasStartIcon: hasStartIcon, hasEndIcon: hasEndIcon, ref: inputRef, id: inputID, onChange: inputChange, onFocus: inputFocus, onBlur: inputBlur })),
97
+ hasEndIcon && (React.createElement(overridesMap.IconWrapper, { position: "end" }, endIcon))),
98
+ React.createElement(overridesMap.ErrorText, { error: error, focused: focused }, errorText)));
99
+ };
100
+ exports.default = React.forwardRef(TextArea);
@@ -42,6 +42,7 @@ const styled_1 = __importDefault(require("@emotion/styled"));
42
42
  const NoSSR_1 = __importDefault(require("../NoSSR"));
43
43
  const ErrorTextContainer = styled_1.default.div `
44
44
  margin-left: 0.5em;
45
+ max-height: 0;
45
46
  max-height: ${({ $maxHeight }) => typeof $maxHeight === 'number' ? `${$maxHeight}px` : $maxHeight};
46
47
  transition: max-height 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
47
48
  overflow: hidden;
@@ -56,7 +57,7 @@ const ErrorTextInner = styled_1.default.div `
56
57
  const TextFieldErrorText = (props, ref) => {
57
58
  const { children, error, focused } = props, nativeProps = __rest(props, ["children", "error", "focused"]);
58
59
  const innerRef = React.useRef(null);
59
- const [maxHeight, setMaxHeight] = React.useState('auto');
60
+ const [maxHeight, setMaxHeight] = React.useState('initial');
60
61
  React.useEffect(() => {
61
62
  const updateMaxHeight = () => {
62
63
  if (innerRef.current && innerRef.current.getBoundingClientRect().height > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@via-profit/ui-kit",
3
- "version": "0.1.0-rc.60",
3
+ "version": "0.1.0-rc.62",
4
4
  "description": "UI Kit",
5
5
  "repository": {
6
6
  "type": "git",