@sellout/ui 0.0.71 → 0.0.73

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,32 @@
1
+ import React from "react";
2
+ export declare enum InputFormats {
3
+ Price = "Price",
4
+ Percent = "Percent"
5
+ }
6
+ export declare type InputProps = {
7
+ inputRef?: React.Ref<HTMLInputElement>;
8
+ autoFocus?: boolean | undefined;
9
+ placeholder?: string;
10
+ value: string;
11
+ defaultValue?: string;
12
+ type?: string;
13
+ format?: InputFormats;
14
+ onMouseEnter?: any;
15
+ onMouseLeave?: any;
16
+ onChange?: any;
17
+ onFocus?: any;
18
+ onBlur?: any;
19
+ onSubmit?: Function;
20
+ canSubmit?: boolean;
21
+ loading?: boolean;
22
+ margin?: string;
23
+ width?: string;
24
+ onEnter?: Function;
25
+ label?: string;
26
+ subLabel?: string;
27
+ tip?: string;
28
+ maxLength?: number;
29
+ validationError?: string;
30
+ disabled?: boolean;
31
+ };
32
+ export default function Input({ inputRef, autoFocus, placeholder, value, defaultValue, format, type, onMouseEnter, onMouseLeave, onChange, onFocus, onBlur, onSubmit, canSubmit, loading, margin, width, onEnter, label, subLabel, tip, maxLength, validationError, disabled, }: InputProps): JSX.Element;
@@ -0,0 +1,84 @@
1
+ import { Colors } from '../Colors.js';
2
+ import { __makeTemplateObject } from '../_virtual/_tslib.js';
3
+ import React, { useState } from 'react';
4
+ import styled from 'styled-components';
5
+ import { darken } from 'polished';
6
+ import Icon, { Icons } from './Icon.js';
7
+ import Label from './Label.js';
8
+ import Flex from './Flex.js';
9
+ import MaxLength from './MaxLength.js';
10
+ import ValidationError from './ValidationError.js';
11
+ import { media } from '../utils/MediaQuery.js';
12
+
13
+ var InputFormats;
14
+ (function (InputFormats) {
15
+ InputFormats["Price"] = "Price";
16
+ InputFormats["Percent"] = "Percent";
17
+ })(InputFormats || (InputFormats = {}));
18
+ var Container = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: ", ";\n"], ["\n width: ", ";\n"])), function (props) { return props.width; });
19
+ var Form = styled.form(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin: ", ";\n width: ", ";\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n position: relative;\n border-radius: 10px;\n transition: all 0.2s;\n border: 1px solid\n ", ";\n overflow: hidden;\n"], ["\n margin: ", ";\n width: ", ";\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n position: relative;\n border-radius: 10px;\n transition: all 0.2s;\n border: 1px solid\n ",
20
+ ";\n overflow: hidden;\n"])), function (props) { return props.margin; }, function (props) { return props.width; }, function (props) {
21
+ if (props.focused)
22
+ return Colors.Grey4;
23
+ if (props.hovered)
24
+ return darken(0.05, Colors.Grey5);
25
+ return Colors.Grey5;
26
+ });
27
+ var PriceContainer = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 25px;\n background-color: ", ";\n"], ["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 25px;\n background-color: ", ";\n"])), Colors.Grey5);
28
+ var InputStyled = styled.input(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background-color: ", ";\n color: ", ";\n outline: none;\n border: 0px;\n height: 38px;\n width: 40px;\n font-family: \"neue-haas-grotesk-display\", sans-serif;\n font-weight: 500;\n text-indent: 1px;\n transition: all 0.2s;\n padding: 0 16px;\n text-align: right;\n\n ", ";\n\n ", ";\n\n ::placeholder {\n color: ", ";\n }\n"], ["\n background-color: ",
29
+ ";\n color: ", ";\n outline: none;\n border: 0px;\n height: 38px;\n width: 40px;\n font-family: \"neue-haas-grotesk-display\", sans-serif;\n font-weight: 500;\n text-indent: 1px;\n transition: all 0.2s;\n padding: 0 16px;\n text-align: right;\n\n ",
30
+ ";\n\n ",
31
+ ";\n\n ::placeholder {\n color: ", ";\n }\n"])), function (props) {
32
+ return props.disabled ? Colors.Grey6 + " !important" : null;
33
+ }, function (props) { return (props.disabled ? Colors.Grey4 : Colors.Grey1); }, media.mobile(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: 1.6rem;\n "], ["\n font-size: 1.6rem;\n "]))), media.desktop(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n font-size: 1.4rem;\n "], ["\n font-size: 1.4rem;\n "]))), Colors.Grey4);
34
+ function Input(_a) {
35
+ var inputRef = _a.inputRef, autoFocus = _a.autoFocus, placeholder = _a.placeholder, value = _a.value, defaultValue = _a.defaultValue, _b = _a.format, format = _b === void 0 ? InputFormats.Price : _b, _c = _a.type, type = _c === void 0 ? "text" : _c, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, onChange = _a.onChange, onFocus = _a.onFocus, onBlur = _a.onBlur, onSubmit = _a.onSubmit, _d = _a.canSubmit, canSubmit = _d === void 0 ? true : _d, loading = _a.loading, margin = _a.margin, width = _a.width, onEnter = _a.onEnter, label = _a.label, subLabel = _a.subLabel, tip = _a.tip, maxLength = _a.maxLength, validationError = _a.validationError, _e = _a.disabled, disabled = _e === void 0 ? false : _e;
36
+ var _f = useState(false), hovered = _f[0], setHovered = _f[1];
37
+ var _g = useState(false), focused = _g[0], setFocused = _g[1];
38
+ var submit = function (event) {
39
+ event.preventDefault();
40
+ if (onSubmit && canSubmit && !loading) {
41
+ onSubmit();
42
+ }
43
+ else if (onEnter && !loading) {
44
+ onEnter();
45
+ }
46
+ };
47
+ return (React.createElement(Container, { width: width },
48
+ React.createElement(Flex, { justify: "space-between" },
49
+ label && React.createElement(Label, { text: label, subText: subLabel, tip: tip }),
50
+ maxLength && React.createElement(MaxLength, { value: value, maxLength: maxLength })),
51
+ React.createElement(Form, { hovered: hovered, focused: focused, onSubmit: function (event) { return submit(event); }, width: width, margin: margin, noValidate // disables default html5 validation
52
+ : true, disabled: disabled },
53
+ format === InputFormats.Price && (React.createElement(PriceContainer, null,
54
+ React.createElement(Icon, { icon: Icons.Dollar, size: 14, color: Colors.Grey3 }))),
55
+ React.createElement(InputStyled, { ref: inputRef, disabled: disabled, autoFocus: autoFocus, placeholder: placeholder, value: value, defaultValue: defaultValue, type: type, onChange: function (e) {
56
+ if (maxLength && e.currentTarget.value.length > maxLength) ;
57
+ else {
58
+ onChange(e);
59
+ }
60
+ }, onFocus: function (event) {
61
+ setFocused(true);
62
+ if (onFocus)
63
+ onFocus(event);
64
+ }, onBlur: function (event) {
65
+ setFocused(false);
66
+ if (onFocus)
67
+ onBlur(event);
68
+ }, onMouseEnter: function (event) {
69
+ setHovered(true);
70
+ if (onMouseEnter)
71
+ onMouseEnter(event);
72
+ }, onMouseLeave: function (event) {
73
+ setHovered(false);
74
+ if (onMouseLeave)
75
+ onMouseLeave(event);
76
+ } }),
77
+ format === InputFormats.Percent && (React.createElement(PriceContainer, null,
78
+ React.createElement(Icon, { icon: Icons.GiftRegular, size: 14, color: Colors.Grey3 })))),
79
+ validationError && (React.createElement(ValidationError, { validationError: validationError }))));
80
+ }
81
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
82
+
83
+ export default Input;
84
+ export { InputFormats };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Colors } from "../Colors";
3
2
  export declare const Icons: {
4
3
  Amex: import("@fortawesome/fontawesome-common-types").IconDefinition;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Colors } from "./../Colors";
3
2
  export declare enum LoaderSizes {
4
3
  FuckingTiny = "FuckingTiny",
package/build/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import CodeInput from "./components/CodeInput";
4
4
  import Counter from "./components/Counter";
5
5
  import Dropdown from "./components/Dropdown";
6
6
  import Flex from "./components/Flex";
7
+ import FormattedInput, { InputFormats } from "./components/FormattedInput";
7
8
  import Icon, { Icons } from "./components/Icon";
8
9
  import Input from "./components/Input";
9
10
  import Label from "./components/Label";
@@ -21,4 +22,4 @@ import * as ErrorUtil from './utils/ErrorUtil';
21
22
  import makeEventHandler from './utils/makeEventHandler';
22
23
  import * as MediaQuery from './utils/MediaQuery';
23
24
  import * as Validation from './utils/Validation';
24
- export { Colors, Button, CodeInput, Counter, Dropdown, Flex, Icon, Icons, Input, Label, MaxLength, Loader, LoaderSizes, Motion, PhoneNumberInput, Product, TextButton, Tip, UserImage, UserInfo, ValidationError, ErrorUtil, makeEventHandler, MediaQuery, Validation, };
25
+ export { Colors, Button, CodeInput, Counter, Dropdown, Flex, FormattedInput, InputFormats, Icon, Icons, Input, Label, MaxLength, Loader, LoaderSizes, Motion, PhoneNumberInput, Product, TextButton, Tip, UserImage, UserInfo, ValidationError, ErrorUtil, makeEventHandler, MediaQuery, Validation, };
package/build/index.js CHANGED
@@ -14,6 +14,7 @@ export { Motion };
14
14
  export { default as ValidationError } from './components/ValidationError.js';
15
15
  import * as MediaQuery from './utils/MediaQuery.js';
16
16
  export { MediaQuery };
17
+ export { default as FormattedInput, InputFormats } from './components/FormattedInput.js';
17
18
  export { default as Input } from './components/Input.js';
18
19
  export { default as PhoneNumberInput } from './components/PhoneNumberInput.js';
19
20
  export { default as Product } from './components/Product.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellout/ui",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "main": "build/index.js",
5
5
  "module": "build/index.es.js",
6
6
  "files": [
@@ -56,8 +56,8 @@
56
56
  "@hapi/joi": "^17.1.1",
57
57
  "@react-pdf/primitives": "^2.0.0-beta.11",
58
58
  "@react-pdf/renderer": "^2.0.0-beta.14",
59
- "@sellout/models": "^0.0.71",
60
- "@sellout/utils": "^0.0.71",
59
+ "@sellout/models": "^0.0.73",
60
+ "@sellout/utils": "^0.0.73",
61
61
  "@types/escape-html": "^1.0.0",
62
62
  "@types/hapi__joi": "^16.0.12",
63
63
  "@types/react-pdf": "^4.0.6",
@@ -70,7 +70,7 @@
70
70
  "rollup-plugin-url": "^3.0.1",
71
71
  "shortid": "^2.2.15"
72
72
  },
73
- "gitHead": "e25d97f48309017da67c313ad792e13b2ebb8897",
73
+ "gitHead": "666f85457f55bbb2cf458f092e1013fc961de007",
74
74
  "peerDependencies": {
75
75
  "react": "^16.13.0",
76
76
  "react-dom": "^16.13.0",