@artsy/palette 35.1.0 → 36.0.0-canary.1250.28474.0
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/elements/BorderedRadio/BorderedRadio.d.ts +20 -20
- package/dist/elements/Input/Input.d.ts +3 -0
- package/dist/elements/Input/Input.js +59 -15
- package/dist/elements/Input/Input.js.map +1 -1
- package/dist/elements/Input/Input.story.js +14 -0
- package/dist/elements/Input/Input.story.js.map +1 -1
- package/dist/elements/Input/tokens.js +7 -6
- package/dist/elements/Input/tokens.js.map +1 -1
- package/dist/elements/Input/types.d.ts +1 -1
- package/dist/elements/Input/types.js.map +1 -1
- package/dist/elements/Label/Label.js +2 -2
- package/dist/elements/Label/Label.js.map +1 -1
- package/dist/elements/LabeledInput/LabeledInput.d.ts +2 -1
- package/dist/elements/LabeledInput/LabeledInput.js +12 -10
- package/dist/elements/LabeledInput/LabeledInput.js.map +1 -1
- package/dist/elements/LabeledInput/LabeledInput.story.js +12 -0
- package/dist/elements/LabeledInput/LabeledInput.story.js.map +1 -1
- package/dist/elements/PhoneInput/PhoneInput.d.ts +33 -0
- package/dist/elements/PhoneInput/PhoneInput.js +319 -0
- package/dist/elements/PhoneInput/PhoneInput.js.map +1 -0
- package/dist/elements/PhoneInput/PhoneInput.story.d.ts +5 -0
- package/dist/elements/PhoneInput/PhoneInput.story.js +207 -0
- package/dist/elements/PhoneInput/PhoneInput.story.js.map +1 -0
- package/dist/elements/PhoneInput/index.d.ts +1 -0
- package/dist/elements/PhoneInput/index.js +17 -0
- package/dist/elements/PhoneInput/index.js.map +1 -0
- package/dist/elements/PhoneInput/tokens.d.ts +9 -0
- package/dist/elements/PhoneInput/tokens.js +19 -0
- package/dist/elements/PhoneInput/tokens.js.map +1 -0
- package/dist/elements/Select/Select.d.ts +0 -2
- package/dist/elements/Select/Select.js +25 -28
- package/dist/elements/Select/Select.js.map +1 -1
- package/dist/elements/Select/Select.story.d.ts +0 -1
- package/dist/elements/Select/Select.story.js +16 -34
- package/dist/elements/Select/Select.story.js.map +1 -1
- package/dist/elements/Select/tokens.d.ts +2 -7
- package/dist/elements/Select/tokens.js +6 -5
- package/dist/elements/Select/tokens.js.map +1 -1
- package/dist/elements/Select/types.d.ts +1 -2
- package/dist/elements/Select/types.js.map +1 -1
- package/dist/elements/TextArea/TextArea.d.ts +1 -1
- package/dist/elements/TextArea/TextArea.js +34 -26
- package/dist/elements/TextArea/TextArea.js.map +1 -1
- package/dist/elements/TextArea/tokens.js +7 -6
- package/dist/elements/TextArea/tokens.js.map +1 -1
- package/dist/elements/TextArea/types.d.ts +1 -1
- package/dist/elements/TextArea/types.js.map +1 -1
- package/dist/elements/index.d.ts +1 -0
- package/dist/elements/index.js +11 -0
- package/dist/elements/index.js.map +1 -1
- package/dist/shared/RequiredField.d.ts +3 -0
- package/dist/shared/RequiredField.js +20 -0
- package/dist/shared/RequiredField.js.map +1 -0
- package/dist/themes/Themes.story.js +0 -38
- package/dist/themes/Themes.story.js.map +1 -1
- package/package.json +3 -3
|
@@ -115,14 +115,14 @@ export declare const BorderedRadio: import("styled-components").StyledComponentC
|
|
|
115
115
|
suppressHydrationWarning?: boolean | undefined;
|
|
116
116
|
accessKey?: string | undefined;
|
|
117
117
|
className?: string | undefined;
|
|
118
|
-
contentEditable?: "inherit" | (boolean | "
|
|
118
|
+
contentEditable?: "inherit" | (boolean | "false" | "true") | undefined;
|
|
119
119
|
contextMenu?: string | undefined;
|
|
120
120
|
dir?: string | undefined;
|
|
121
|
-
draggable?: (boolean | "
|
|
121
|
+
draggable?: (boolean | "false" | "true") | undefined;
|
|
122
122
|
id?: string | undefined;
|
|
123
123
|
lang?: string | undefined;
|
|
124
124
|
placeholder?: string | undefined;
|
|
125
|
-
spellCheck?: (boolean | "
|
|
125
|
+
spellCheck?: (boolean | "false" | "true") | undefined;
|
|
126
126
|
tabIndex?: number | undefined;
|
|
127
127
|
radioGroup?: string | undefined;
|
|
128
128
|
role?: string | undefined;
|
|
@@ -147,47 +147,47 @@ export declare const BorderedRadio: import("styled-components").StyledComponentC
|
|
|
147
147
|
inputMode?: "none" | "text" | "search" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
|
148
148
|
is?: string | undefined;
|
|
149
149
|
'aria-activedescendant'?: string | undefined;
|
|
150
|
-
'aria-atomic'?: boolean | "
|
|
150
|
+
'aria-atomic'?: boolean | "false" | "true" | undefined;
|
|
151
151
|
'aria-autocomplete'?: "none" | "inline" | "list" | "both" | undefined;
|
|
152
|
-
'aria-busy'?: boolean | "
|
|
153
|
-
'aria-checked'?: boolean | "
|
|
152
|
+
'aria-busy'?: boolean | "false" | "true" | undefined;
|
|
153
|
+
'aria-checked'?: boolean | "false" | "true" | "mixed" | undefined;
|
|
154
154
|
'aria-colcount'?: number | undefined;
|
|
155
155
|
'aria-colindex'?: number | undefined;
|
|
156
156
|
'aria-colspan'?: number | undefined;
|
|
157
157
|
'aria-controls'?: string | undefined;
|
|
158
|
-
'aria-current'?: boolean | "time" | "
|
|
158
|
+
'aria-current'?: boolean | "time" | "false" | "true" | "page" | "step" | "location" | "date" | undefined;
|
|
159
159
|
'aria-describedby'?: string | undefined;
|
|
160
160
|
'aria-details'?: string | undefined;
|
|
161
|
-
'aria-disabled'?: boolean | "
|
|
161
|
+
'aria-disabled'?: boolean | "false" | "true" | undefined;
|
|
162
162
|
'aria-dropeffect'?: "none" | "link" | "copy" | "execute" | "move" | "popup" | undefined;
|
|
163
163
|
'aria-errormessage'?: string | undefined;
|
|
164
|
-
'aria-expanded'?: boolean | "
|
|
164
|
+
'aria-expanded'?: boolean | "false" | "true" | undefined;
|
|
165
165
|
'aria-flowto'?: string | undefined;
|
|
166
|
-
'aria-grabbed'?: boolean | "
|
|
167
|
-
'aria-haspopup'?: boolean | "grid" | "dialog" | "menu" | "
|
|
168
|
-
'aria-hidden'?: boolean | "
|
|
169
|
-
'aria-invalid'?: boolean | "
|
|
166
|
+
'aria-grabbed'?: boolean | "false" | "true" | undefined;
|
|
167
|
+
'aria-haspopup'?: boolean | "grid" | "dialog" | "menu" | "false" | "true" | "listbox" | "tree" | undefined;
|
|
168
|
+
'aria-hidden'?: boolean | "false" | "true" | undefined;
|
|
169
|
+
'aria-invalid'?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
|
170
170
|
'aria-keyshortcuts'?: string | undefined;
|
|
171
171
|
'aria-label'?: string | undefined;
|
|
172
172
|
'aria-labelledby'?: string | undefined;
|
|
173
173
|
'aria-level'?: number | undefined;
|
|
174
174
|
'aria-live'?: "off" | "assertive" | "polite" | undefined;
|
|
175
|
-
'aria-modal'?: boolean | "
|
|
176
|
-
'aria-multiline'?: boolean | "
|
|
177
|
-
'aria-multiselectable'?: boolean | "
|
|
175
|
+
'aria-modal'?: boolean | "false" | "true" | undefined;
|
|
176
|
+
'aria-multiline'?: boolean | "false" | "true" | undefined;
|
|
177
|
+
'aria-multiselectable'?: boolean | "false" | "true" | undefined;
|
|
178
178
|
'aria-orientation'?: "horizontal" | "vertical" | undefined;
|
|
179
179
|
'aria-owns'?: string | undefined;
|
|
180
180
|
'aria-placeholder'?: string | undefined;
|
|
181
181
|
'aria-posinset'?: number | undefined;
|
|
182
|
-
'aria-pressed'?: boolean | "
|
|
183
|
-
'aria-readonly'?: boolean | "
|
|
182
|
+
'aria-pressed'?: boolean | "false" | "true" | "mixed" | undefined;
|
|
183
|
+
'aria-readonly'?: boolean | "false" | "true" | undefined;
|
|
184
184
|
'aria-relevant'?: "all" | "text" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
|
|
185
|
-
'aria-required'?: boolean | "
|
|
185
|
+
'aria-required'?: boolean | "false" | "true" | undefined;
|
|
186
186
|
'aria-roledescription'?: string | undefined;
|
|
187
187
|
'aria-rowcount'?: number | undefined;
|
|
188
188
|
'aria-rowindex'?: number | undefined;
|
|
189
189
|
'aria-rowspan'?: number | undefined;
|
|
190
|
-
'aria-selected'?: boolean | "
|
|
190
|
+
'aria-selected'?: boolean | "false" | "true" | undefined;
|
|
191
191
|
'aria-setsize'?: number | undefined;
|
|
192
192
|
'aria-sort'?: "none" | "ascending" | "descending" | "other" | undefined;
|
|
193
193
|
'aria-valuemax'?: number | undefined;
|
|
@@ -9,6 +9,9 @@ export interface InputProps extends BoxProps, Omit<React.InputHTMLAttributes<HTM
|
|
|
9
9
|
hover?: boolean;
|
|
10
10
|
required?: boolean;
|
|
11
11
|
title?: string;
|
|
12
|
+
prefixOffset?: number;
|
|
13
|
+
suffixOffset?: number;
|
|
14
|
+
showCounter?: boolean;
|
|
12
15
|
}
|
|
13
16
|
/** Input component */
|
|
14
17
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & {
|
|
@@ -9,10 +9,12 @@ var _themeGet = require("@styled-system/theme-get");
|
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
11
11
|
var _styledSystem = require("styled-system");
|
|
12
|
+
var _RequiredField = require("../../shared/RequiredField");
|
|
12
13
|
var _Box = require("../Box");
|
|
13
14
|
var _Text = require("../Text");
|
|
15
|
+
var _Tooltip = require("../Tooltip");
|
|
14
16
|
var _tokens = require("./tokens");
|
|
15
|
-
var _excluded = ["children", "className", "description", "disabled", "error", "required", "focus", "hover", "title", "height"];
|
|
17
|
+
var _excluded = ["children", "className", "description", "disabled", "error", "required", "focus", "hover", "title", "height", "prefixOffset", "suffixOffset", "showCounter"];
|
|
16
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -37,25 +39,35 @@ var Input = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
37
39
|
hover = _ref.hover,
|
|
38
40
|
title = _ref.title,
|
|
39
41
|
height = _ref.height,
|
|
42
|
+
prefixOffset = _ref.prefixOffset,
|
|
43
|
+
suffixOffset = _ref.suffixOffset,
|
|
44
|
+
showCounter = _ref.showCounter,
|
|
40
45
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
41
46
|
var _splitBoxProps = (0, _Box.splitBoxProps)(rest),
|
|
42
47
|
_splitBoxProps2 = _slicedToArray(_splitBoxProps, 2),
|
|
43
48
|
boxProps = _splitBoxProps2[0],
|
|
44
49
|
inputProps = _splitBoxProps2[1];
|
|
50
|
+
var _React$useState = _react.default.useState(0),
|
|
51
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
52
|
+
charCount = _React$useState2[0],
|
|
53
|
+
setCharCount = _React$useState2[1];
|
|
54
|
+
var inputName = inputProps.name || "palette-input";
|
|
55
|
+
var countChars = function countChars(e) {
|
|
56
|
+
setCharCount(e.target.value.length);
|
|
57
|
+
};
|
|
45
58
|
return /*#__PURE__*/_react.default.createElement(_Box.Box, _extends({
|
|
46
59
|
width: "100%",
|
|
47
60
|
className: className
|
|
48
|
-
}, boxProps),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, "*")), description && /*#__PURE__*/_react.default.createElement(_Text.Text, {
|
|
61
|
+
}, boxProps), !!description && /*#__PURE__*/_react.default.createElement(_Tooltip.Tooltip, {
|
|
62
|
+
pointer: true,
|
|
63
|
+
content: description,
|
|
64
|
+
placement: "top-end"
|
|
65
|
+
}, /*#__PURE__*/_react.default.createElement(_Text.Text, {
|
|
54
66
|
variant: "xs",
|
|
55
|
-
color: "black60"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
color: "black60",
|
|
68
|
+
textAlign: "right"
|
|
69
|
+
}, /*#__PURE__*/_react.default.createElement("u", null, "What is this?"))), /*#__PURE__*/_react.default.createElement(_Box.Box, {
|
|
70
|
+
position: "relative"
|
|
59
71
|
}, /*#__PURE__*/_react.default.createElement(StyledInput, _extends({
|
|
60
72
|
ref: ref,
|
|
61
73
|
disabled: disabled,
|
|
@@ -63,10 +75,35 @@ var Input = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
63
75
|
hover: hover,
|
|
64
76
|
error: !!error,
|
|
65
77
|
required: required,
|
|
66
|
-
height: height !== null && height !== void 0 ? height : 50
|
|
67
|
-
|
|
78
|
+
height: height !== null && height !== void 0 ? height : 50,
|
|
79
|
+
name: inputName,
|
|
80
|
+
title: title,
|
|
81
|
+
suffixOffset: suffixOffset,
|
|
82
|
+
prefixOffset: prefixOffset,
|
|
83
|
+
onChange: function onChange(e) {
|
|
84
|
+
var _inputProps$onChange;
|
|
85
|
+
(_inputProps$onChange = inputProps.onChange) === null || _inputProps$onChange === void 0 ? void 0 : _inputProps$onChange.call(inputProps, e);
|
|
86
|
+
if (inputProps.maxLength) countChars(e);
|
|
87
|
+
},
|
|
88
|
+
placeholder: inputProps.placeholder || " "
|
|
89
|
+
}, inputProps)), !!title && /*#__PURE__*/_react.default.createElement(StyledLabel, {
|
|
90
|
+
prefixOffset: prefixOffset,
|
|
91
|
+
htmlFor: inputName
|
|
92
|
+
}, title), children), (required || (inputProps === null || inputProps === void 0 ? void 0 : inputProps.maxLength) && showCounter) && !(error && typeof error === "string") && /*#__PURE__*/_react.default.createElement(_Box.Box, {
|
|
93
|
+
display: "flex",
|
|
94
|
+
mt: 0.5,
|
|
95
|
+
mx: 1
|
|
96
|
+
}, required && /*#__PURE__*/_react.default.createElement(_RequiredField.RequiredField, {
|
|
97
|
+
flex: 1
|
|
98
|
+
}), !!(inputProps !== null && inputProps !== void 0 && inputProps.maxLength) && showCounter && /*#__PURE__*/_react.default.createElement(_Text.Text, {
|
|
99
|
+
flex: 1,
|
|
100
|
+
variant: "xs",
|
|
101
|
+
color: "black60",
|
|
102
|
+
textAlign: "right"
|
|
103
|
+
}, charCount, "/", inputProps.maxLength)), error && typeof error === "string" && /*#__PURE__*/_react.default.createElement(_Text.Text, {
|
|
68
104
|
variant: "xs",
|
|
69
105
|
mt: 0.5,
|
|
106
|
+
ml: 1,
|
|
70
107
|
color: "red100"
|
|
71
108
|
}, error));
|
|
72
109
|
});
|
|
@@ -75,7 +112,14 @@ Input.displayName = "Input";
|
|
|
75
112
|
var StyledInput = _styledComponents.default.input.withConfig({
|
|
76
113
|
displayName: "Input__StyledInput",
|
|
77
114
|
componentId: "bysdh7-0"
|
|
78
|
-
})(["width:100%;padding:0 ", ";appearance:none;line-height:1;border:
|
|
79
|
-
return (0, _styledComponents.css)(["", " ", " ", " ", " ", " ", " &:hover{", "}&:focus{outline:none;", ":not(:placeholder-shown){", " ", "}}&:disabled{cursor:default;", "}"], _tokens.INPUT_STATES.default, props.hover && _tokens.INPUT_STATES.hover, props.focus && _tokens.INPUT_STATES.focus, props.active && _tokens.INPUT_STATES.active, props.disabled && _tokens.INPUT_STATES.disabled, props.error && _tokens.INPUT_STATES.error, _tokens.INPUT_STATES.hover, _tokens.INPUT_STATES.focus, _tokens.INPUT_STATES.active, props.error && _tokens.INPUT_STATES.error, _tokens.INPUT_STATES.disabled);
|
|
115
|
+
})(["width:100%;padding:0 ", ";appearance:none;line-height:1;border:1px solid;border-radius:3px;transition:border-color 0.25s,color 0.25s;font-family:", ";", ";::placeholder{transition:color 0.25s,opacity 0.25s;}&:-webkit-autofill,&:-webkit-autofill:hover,&:-webkit-autofill:focus{-webkit-box-shadow:0 0 0px 100px ", " inset;}", ";"], (0, _themeGet.themeGet)("space.1"), (0, _themeGet.themeGet)("fonts.sans"), _styledSystem.height, (0, _themeGet.themeGet)("colors.white100"), function (props) {
|
|
116
|
+
return (0, _styledComponents.css)(["", " ", " ", " ", " ", " ", " ", " ", " &:hover{", "}&:not(:placeholder-shown){", " ", "}&:focus{outline:none;", ":not(:placeholder-shown){", " ", "}}&:disabled{cursor:default;", "}", ""], _tokens.INPUT_STATES.default, props.hover && _tokens.INPUT_STATES.hover, props.focus && _tokens.INPUT_STATES.focus, props.active && _tokens.INPUT_STATES.active, props.disabled && _tokens.INPUT_STATES.disabled, props.error && _tokens.INPUT_STATES.error, !!props.prefixOffset && (0, _styledComponents.css)(["padding-left:", "px;"], props.prefixOffset), !!props.suffixOffset && (0, _styledComponents.css)(["padding-right:", "px;"], props.suffixOffset), _tokens.INPUT_STATES.hover, _tokens.INPUT_STATES.completed, props.error && _tokens.INPUT_STATES.error, _tokens.INPUT_STATES.focus, _tokens.INPUT_STATES.active, props.error && _tokens.INPUT_STATES.error, _tokens.INPUT_STATES.disabled, props.title && (0, _styledComponents.css)(["::placeholder{opacity:0;}"]));
|
|
117
|
+
});
|
|
118
|
+
var StyledLabel = _styledComponents.default.label.withConfig({
|
|
119
|
+
displayName: "Input__StyledLabel",
|
|
120
|
+
componentId: "bysdh7-1"
|
|
121
|
+
})(["position:absolute;top:50%;left:5px;padding:0 5px;background-color:", ";transform:translateY(-50%);transition:0.25s cubic-bezier(0.64,0.05,0.36,1);transition-property:color,transform,padding,font-size;font-family:", ";pointer-events:none;", ""], (0, _themeGet.themeGet)("colors.white100"), (0, _themeGet.themeGet)("fonts.sans"), function (_ref2) {
|
|
122
|
+
var prefixOffset = _ref2.prefixOffset;
|
|
123
|
+
return !!prefixOffset && (0, _styledComponents.css)(["padding-left:", "px;"], prefixOffset - 5);
|
|
80
124
|
});
|
|
81
125
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","names":["_themeGet","require","_react","_interopRequireDefault","_styledComponents","_interopRequireWildcard","_styledSystem","_Box","_Text","_tokens","_excluded","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","_slicedToArray","arr","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","toString","slice","constructor","name","Array","from","test","len","arr2","_i","Symbol","iterator","_s","_e","_x","_r","_arr","_n","_d","next","done","push","value","err","return","isArray","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","Input","React","forwardRef","_ref","ref","children","className","description","disabled","error","required","focus","hover","title","height","rest","_splitBoxProps","splitBoxProps","_splitBoxProps2","boxProps","inputProps","createElement","Box","width","Fragment","Text","variant","as","color","position","mt","StyledInput","exports","displayName","styled","input","withConfig","componentId","themeGet","systemHeight","props","css","INPUT_STATES","active"],"sources":["../../../src/elements/Input/Input.tsx"],"sourcesContent":["import { themeGet } from \"@styled-system/theme-get\"\nimport React from \"react\"\nimport styled, { css } from \"styled-components\"\nimport { height as systemHeight } from \"styled-system\"\nimport { Box, BoxProps, splitBoxProps } from \"../Box\"\nimport { Text } from \"../Text\"\nimport { INPUT_STATES } from \"./tokens\"\n\nexport interface InputProps\n extends BoxProps,\n Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n \"size\" | \"width\" | \"height\" | \"capture\"\n > {\n active?: boolean\n description?: string\n disabled?: boolean\n error?: string | boolean\n focus?: boolean\n hover?: boolean\n required?: boolean\n title?: string\n}\n\n/** Input component */\nexport const Input: React.ForwardRefExoticComponent<\n InputProps & { ref?: React.Ref<HTMLInputElement> }\n> = React.forwardRef(\n (\n {\n children,\n className,\n description,\n disabled,\n error,\n required,\n focus,\n hover,\n title,\n height,\n ...rest\n },\n ref\n ) => {\n const [boxProps, inputProps] = splitBoxProps(rest)\n\n return (\n <Box width=\"100%\" className={className} {...boxProps}>\n {(title || description) && (\n <>\n {title && (\n <Text variant=\"xs\">\n {title}\n {required && (\n <Box as=\"span\" color=\"brand\">\n *\n </Box>\n )}\n </Text>\n )}\n\n {description && (\n <Text variant=\"xs\" color=\"black60\">\n {description}\n </Text>\n )}\n </>\n )}\n\n <Box position=\"relative\" mt={title || description ? 0.5 : 0}>\n <StyledInput\n ref={ref as any}\n disabled={disabled}\n focus={focus}\n hover={hover}\n error={!!error}\n required={required}\n height={(height ?? 50) as any}\n {...inputProps}\n />\n\n {children}\n </Box>\n\n {error && typeof error === \"string\" && (\n <Text variant=\"xs\" mt={0.5} color=\"red100\">\n {error}\n </Text>\n )}\n </Box>\n )\n }\n)\n\nInput.displayName = \"Input\"\n\ntype StyledInputProps = Pick<\n InputProps,\n \"disabled\" | \"error\" | \"hover\" | \"focus\" | \"active\"\n>\n\nconst StyledInput = styled.input<StyledInputProps>`\n width: 100%;\n padding: 0 ${themeGet(\"space.1\")};\n appearance: none;\n line-height: 1;\n border: 0;\n border-bottom: 1px solid;\n border-radius: 0;\n transition: border-color 0.25s, color 0.25s;\n font-family: ${themeGet(\"fonts.sans\")};\n ${systemHeight};\n\n ::placeholder {\n transition: color 0.25s;\n }\n\n ${(props) => {\n return css`\n ${INPUT_STATES.default}\n ${props.hover && INPUT_STATES.hover}\n ${props.focus && INPUT_STATES.focus}\n ${props.active && INPUT_STATES.active}\n ${props.disabled && INPUT_STATES.disabled}\n ${props.error && INPUT_STATES.error}\n\n &:hover {\n ${INPUT_STATES.hover}\n }\n\n &:focus {\n outline: none;\n ${INPUT_STATES.focus}\n\n :not(:placeholder-shown) {\n ${INPUT_STATES.active}\n ${props.error && INPUT_STATES.error}\n }\n }\n\n &:disabled {\n cursor: default;\n ${INPUT_STATES.disabled}\n }\n `\n }};\n`\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAAuC,IAAAS,SAAA;AAAA,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAP,wBAAAW,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,4BAAAG,OAAA,EAAAH,GAAA,UAAAI,KAAA,GAAAT,wBAAA,CAAAC,WAAA,OAAAQ,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAL,GAAA,YAAAI,KAAA,CAAAE,GAAA,CAAAN,GAAA,SAAAO,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAZ,GAAA,QAAAY,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAf,GAAA,EAAAY,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,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G,KAAK,CAAC5B,KAAK,IAAI8B,oBAAY,CAAC9B,KAAK,EACjC4B,KAAK,CAAC7B,KAAK,IAAI+B,oBAAY,CAAC/B,KAAK,EACjC6B,KAAK,CAACG,MAAM,IAAID,oBAAY,CAACC,MAAM,EACnCH,KAAK,CAAChC,QAAQ,IAAIkC,oBAAY,CAAClC,QAAQ,EACvCgC,KAAK,CAAC/B,KAAK,IAAIiC,oBAAY,CAACjC,KAAK,EAG/BiC,oBAAY,CAAC9B,KAAK,EAKlB8B,oBAAY,CAAC/B,KAAK,EAGhB+B,oBAAY,CAACC,MAAM,EACnBH,KAAK,CAAC/B,KAAK,IAAIiC,oBAAY,CAACjC,KAAK,EAMnCiC,oBAAY,CAAClC,QAAQ;AAG7B,CAAC,CACF"}
|
|
1
|
+
{"version":3,"file":"Input.js","names":["_themeGet","require","_react","_interopRequireDefault","_styledComponents","_interopRequireWildcard","_styledSystem","_RequiredField","_Box","_Text","_Tooltip","_tokens","_excluded","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","_slicedToArray","arr","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","toString","slice","constructor","name","Array","from","test","len","arr2","_i","Symbol","iterator","_s","_e","_x","_r","_arr","_n","_d","next","done","push","value","err","return","isArray","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","Input","React","forwardRef","_ref","ref","children","className","description","disabled","error","required","focus","hover","title","height","prefixOffset","suffixOffset","showCounter","rest","_splitBoxProps","splitBoxProps","_splitBoxProps2","boxProps","inputProps","_React$useState","useState","_React$useState2","charCount","setCharCount","inputName","countChars","e","createElement","Box","width","Tooltip","pointer","content","placement","Text","variant","color","textAlign","position","StyledInput","onChange","_inputProps$onChange","maxLength","placeholder","StyledLabel","htmlFor","display","mt","mx","RequiredField","flex","ml","exports","displayName","styled","input","withConfig","componentId","themeGet","systemHeight","props","css","INPUT_STATES","active","completed","label","_ref2"],"sources":["../../../src/elements/Input/Input.tsx"],"sourcesContent":["import { themeGet } from \"@styled-system/theme-get\"\nimport React from \"react\"\nimport styled, { css } from \"styled-components\"\nimport { height as systemHeight } from \"styled-system\"\nimport { RequiredField } from \"../../shared/RequiredField\"\nimport { Box, BoxProps, splitBoxProps } from \"../Box\"\nimport { Text } from \"../Text\"\nimport { Tooltip } from \"../Tooltip\"\nimport { INPUT_STATES } from \"./tokens\"\n\nexport interface InputProps\n extends BoxProps,\n Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n \"size\" | \"width\" | \"height\" | \"capture\"\n > {\n active?: boolean\n description?: string\n disabled?: boolean\n error?: string | boolean\n focus?: boolean\n hover?: boolean\n required?: boolean\n title?: string\n prefixOffset?: number\n suffixOffset?: number\n showCounter?: boolean\n}\n\n/** Input component */\nexport const Input: React.ForwardRefExoticComponent<\n InputProps & { ref?: React.Ref<HTMLInputElement> }\n> = React.forwardRef(\n (\n {\n children,\n className,\n description,\n disabled,\n error,\n required,\n focus,\n hover,\n title,\n height,\n prefixOffset,\n suffixOffset,\n showCounter,\n ...rest\n },\n ref\n ) => {\n const [boxProps, inputProps] = splitBoxProps(rest)\n const [charCount, setCharCount] = React.useState(0)\n\n const inputName = inputProps.name || \"palette-input\"\n\n const countChars = (e: React.ChangeEvent<HTMLInputElement>) => {\n setCharCount(e.target.value.length)\n }\n\n return (\n <Box width=\"100%\" className={className} {...boxProps}>\n {!!description && (\n <Tooltip pointer content={description} placement=\"top-end\">\n <Text variant=\"xs\" color=\"black60\" textAlign=\"right\">\n <u>What is this?</u>\n </Text>\n </Tooltip>\n )}\n\n <Box position=\"relative\">\n <StyledInput\n ref={ref as any}\n disabled={disabled}\n focus={focus}\n hover={hover}\n error={!!error}\n required={required}\n height={(height ?? 50) as any}\n name={inputName}\n title={title}\n suffixOffset={suffixOffset}\n prefixOffset={prefixOffset}\n onChange={(e) => {\n inputProps.onChange?.(e)\n if (inputProps.maxLength) countChars(e)\n }}\n placeholder={inputProps.placeholder || \" \"}\n {...inputProps}\n />\n\n {!!title && (\n <StyledLabel prefixOffset={prefixOffset} htmlFor={inputName}>\n {title}\n </StyledLabel>\n )}\n\n {children}\n </Box>\n\n {(required || (inputProps?.maxLength && showCounter)) &&\n !(error && typeof error === \"string\") && (\n <Box display=\"flex\" mt={0.5} mx={1}>\n {required && <RequiredField flex={1} />}\n\n {!!inputProps?.maxLength && showCounter && (\n <Text flex={1} variant=\"xs\" color=\"black60\" textAlign=\"right\">\n {charCount}/{inputProps.maxLength}\n </Text>\n )}\n </Box>\n )}\n\n {error && typeof error === \"string\" && (\n <Text variant=\"xs\" mt={0.5} ml={1} color=\"red100\">\n {error}\n </Text>\n )}\n </Box>\n )\n }\n)\n\nInput.displayName = \"Input\"\n\ntype StyledInputProps = Pick<\n InputProps,\n | \"disabled\"\n | \"error\"\n | \"hover\"\n | \"focus\"\n | \"active\"\n | \"title\"\n | \"suffixOffset\"\n | \"prefixOffset\"\n>\n\nconst StyledInput = styled.input<StyledInputProps>`\n width: 100%;\n padding: 0 ${themeGet(\"space.1\")};\n appearance: none;\n line-height: 1;\n border: 1px solid;\n border-radius: 3px;\n transition: border-color 0.25s, color 0.25s;\n font-family: ${themeGet(\"fonts.sans\")};\n ${systemHeight};\n\n ::placeholder {\n transition: color 0.25s, opacity 0.25s;\n }\n\n &:-webkit-autofill,\n &:-webkit-autofill:hover,\n &:-webkit-autofill:focus {\n -webkit-box-shadow: 0 0 0px 100px ${themeGet(\"colors.white100\")} inset;\n }\n\n ${(props) => {\n return css`\n ${INPUT_STATES.default}\n ${props.hover && INPUT_STATES.hover}\n ${props.focus && INPUT_STATES.focus}\n ${props.active && INPUT_STATES.active}\n ${props.disabled && INPUT_STATES.disabled}\n ${props.error && INPUT_STATES.error}\n ${!!props.prefixOffset &&\n css`\n padding-left: ${props.prefixOffset}px;\n `}\n ${!!props.suffixOffset &&\n css`\n padding-right: ${props.suffixOffset}px;\n `}\n\n &:hover {\n ${INPUT_STATES.hover}\n }\n\n &:not(:placeholder-shown) {\n ${INPUT_STATES.completed}\n ${props.error && INPUT_STATES.error}\n }\n\n &:focus {\n outline: none;\n ${INPUT_STATES.focus}\n\n :not(:placeholder-shown) {\n ${INPUT_STATES.active}\n ${props.error && INPUT_STATES.error}\n }\n }\n\n &:disabled {\n cursor: default;\n ${INPUT_STATES.disabled}\n }\n\n ${props.title &&\n css`\n ::placeholder {\n opacity: 0;\n }\n `}\n `\n }};\n`\n\nconst StyledLabel = styled.label<StyledInputProps>`\n position: absolute;\n top: 50%;\n left: 5px;\n padding: 0 5px;\n background-color: ${themeGet(\"colors.white100\")};\n transform: translateY(-50%);\n transition: 0.25s cubic-bezier(0.64, 0.05, 0.36, 1);\n transition-property: color, transform, padding, font-size;\n font-family: ${themeGet(\"fonts.sans\")};\n pointer-events: none;\n\n ${({ prefixOffset }) =>\n !!prefixOffset &&\n css`\n padding-left: ${prefixOffset - 5}px;\n `}\n`\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAAuC,IAAAW,SAAA;AAAA,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF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ACzD,QAAQ,IAAI2D,oBAAY,CAAC3D,QAAQ,EACvCyD,KAAK,CAACxD,KAAK,IAAI0D,oBAAY,CAAC1D,KAAK,EACjC,CAAC,CAACwD,KAAK,CAAClD,YAAY,QACtBmD,qBAAG,4BACeD,KAAK,CAAClD,YAAY,CACnC,EACC,CAAC,CAACkD,KAAK,CAACjD,YAAY,QACtBkD,qBAAG,6BACgBD,KAAK,CAACjD,YAAY,CACpC,EAGGmD,oBAAY,CAACvD,KAAK,EAIlBuD,oBAAY,CAACE,SAAS,EACtBJ,KAAK,CAACxD,KAAK,IAAI0D,oBAAY,CAAC1D,KAAK,EAKjC0D,oBAAY,CAACxD,KAAK,EAGhBwD,oBAAY,CAACC,MAAM,EACnBH,KAAK,CAACxD,KAAK,IAAI0D,oBAAY,CAAC1D,KAAK,EAMnC0D,oBAAY,CAAC3D,QAAQ,EAGvByD,KAAK,CAACpD,KAAK,QACbqD,qBAAG,gCAIF;AAEL,CAAC,CACF;AAED,IAAMjB,WAAW,GAAGU,yBAAM,CAACW,KAAK,CAAAT,UAAA;EAAAH,WAAA;EAAAI,WAAA;AAAA,0PAKV,IAAAC,kBAAQ,EAAC,iBAAiB,CAAC,EAIhC,IAAAA,kBAAQ,EAAC,YAAY,CAAC,EAGnC,UAAAQ,KAAA;EAAA,IAAGxD,YAAY,GAAAwD,KAAA,CAAZxD,YAAY;EAAA,OACf,CAAC,CAACA,YAAY,QACdmD,qBAAG,4BACenD,YAAY,GAAG,CAAC,CACjC;AAAA,EACJ"}
|
|
@@ -32,9 +32,23 @@ var Default = function Default() {
|
|
|
32
32
|
}, {
|
|
33
33
|
title: "Your offer",
|
|
34
34
|
name: "offer"
|
|
35
|
+
}, {
|
|
36
|
+
title: "Your offer with a big title",
|
|
37
|
+
name: "offer-big-title"
|
|
38
|
+
}, {
|
|
39
|
+
title: "Your offer with a really really long title",
|
|
40
|
+
name: "offer-really-long-title"
|
|
35
41
|
}, {
|
|
36
42
|
title: "Your offer",
|
|
37
43
|
required: true
|
|
44
|
+
}, {
|
|
45
|
+
title: "Your offer",
|
|
46
|
+
maxLength: 50
|
|
47
|
+
}, {
|
|
48
|
+
title: "Your offer",
|
|
49
|
+
required: true,
|
|
50
|
+
maxLength: 50,
|
|
51
|
+
showCounter: true
|
|
38
52
|
}, {
|
|
39
53
|
title: "Your offer",
|
|
40
54
|
description: "This is my description"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.story.js","names":["_react","_interopRequireDefault","require","_storybookStates","_styledComponents","_Button","_Input","obj","__esModule","default","_default","title","exports","Default","createElement","States","states","focus","hover","active","error","disabled","value","name","required","description","width","Input","placeholder","displayName","StyledInput","styled","withConfig","componentId","Styled","Required","mt","type","Button","CustomHeight","height"],"sources":["../../../src/elements/Input/Input.story.tsx"],"sourcesContent":["import React from \"react\"\nimport { States } from \"storybook-states\"\nimport styled from \"styled-components\"\nimport { Button } from \"../Button\"\nimport { Input, InputProps } from \"./Input\"\n\nexport default {\n title: \"Components/Input\",\n}\n\nexport const Default = () => {\n return (\n <States<InputProps>\n states={[\n {},\n { focus: true },\n { hover: true },\n { active: true },\n { error: \"Something went wrong.\" },\n { disabled: true },\n { disabled: true, value: \"Example value\" },\n { title: \"Your offer\", name: \"offer\" },\n { title: \"Your offer\", required: true },\n { title: \"Your offer\", description: \"This is my description\" },\n { width: \"50%\" },\n ]}\n >\n <Input placeholder=\"Start typing…\" />\n </States>\n )\n}\n\nconst StyledInput = styled(Input)`\n border: 1px solid red;\n\n > input {\n border: 2px solid green;\n }\n`\n\nexport const Styled = () => {\n return <StyledInput placeholder=\"style should target container div\" />\n}\n\nexport const Required = () => {\n return (\n <form>\n <Input\n title=\"Example\"\n required\n placeholder=\"Submission should be blocked unless this has a value\"\n />\n\n <Input\n mt={1}\n title=\"Email\"\n required\n placeholder=\"Requires a valid email\"\n type=\"email\"\n />\n\n <Button mt={1}>Submit</Button>\n </form>\n )\n}\n\nexport const CustomHeight = () => {\n return <Input height={40} placeholder=\"Input is 40px in height\" />\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAA2C,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAE5B;EACbC,KAAK,EAAE;AACT,CAAC;AAAAC,OAAA,CAAAH,OAAA,GAAAC,QAAA;AAEM,IAAMG,OAAO,GAAG,SAAVA,OAAOA,CAAA,EAAS;EAC3B,oBACEb,MAAA,CAAAS,OAAA,CAAAK,aAAA,CAACX,gBAAA,CAAAY,MAAM;IACLC,MAAM,EAAE,CACN,CAAC,CAAC,EACF;MAAEC,KAAK,EAAE;IAAK,CAAC,EACf;MAAEC,KAAK,EAAE;IAAK,CAAC,EACf;MAAEC,MAAM,EAAE;IAAK,CAAC,EAChB;MAAEC,KAAK,EAAE;IAAwB,CAAC,EAClC;MAAEC,QAAQ,EAAE;IAAK,CAAC,EAClB;MAAEA,QAAQ,EAAE,IAAI;MAAEC,KAAK,EAAE;IAAgB,CAAC,EAC1C;MAAEX,KAAK,EAAE,YAAY;MAAEY,IAAI,EAAE;IAAQ,CAAC,EACtC;MAAEZ,KAAK,EAAE,YAAY;MAAEa,QAAQ,EAAE;IAAK,CAAC,EACvC;MAAEb,KAAK,EAAE,YAAY;MAAEc,WAAW,EAAE;IAAyB,CAAC,EAC9D;MAAEC,KAAK,EAAE;IAAM,CAAC;EAChB,
|
|
1
|
+
{"version":3,"file":"Input.story.js","names":["_react","_interopRequireDefault","require","_storybookStates","_styledComponents","_Button","_Input","obj","__esModule","default","_default","title","exports","Default","createElement","States","states","focus","hover","active","error","disabled","value","name","required","maxLength","showCounter","description","width","Input","placeholder","displayName","StyledInput","styled","withConfig","componentId","Styled","Required","mt","type","Button","CustomHeight","height"],"sources":["../../../src/elements/Input/Input.story.tsx"],"sourcesContent":["import React from \"react\"\nimport { States } from \"storybook-states\"\nimport styled from \"styled-components\"\nimport { Button } from \"../Button\"\nimport { Input, InputProps } from \"./Input\"\n\nexport default {\n title: \"Components/Input\",\n}\n\nexport const Default = () => {\n return (\n <States<InputProps>\n states={[\n {},\n { focus: true },\n { hover: true },\n { active: true },\n { error: \"Something went wrong.\" },\n { disabled: true },\n { disabled: true, value: \"Example value\" },\n { title: \"Your offer\", name: \"offer\" },\n { title: \"Your offer with a big title\", name: \"offer-big-title\" },\n {\n title: \"Your offer with a really really long title\",\n name: \"offer-really-long-title\",\n },\n { title: \"Your offer\", required: true },\n { title: \"Your offer\", maxLength: 50 },\n {\n title: \"Your offer\",\n required: true,\n maxLength: 50,\n showCounter: true,\n },\n { title: \"Your offer\", description: \"This is my description\" },\n { width: \"50%\" },\n ]}\n >\n <Input placeholder=\"Start typing…\" />\n </States>\n )\n}\n\nconst StyledInput = styled(Input)`\n border: 1px solid red;\n\n > input {\n border: 2px solid green;\n }\n`\n\nexport const Styled = () => {\n return <StyledInput placeholder=\"style should target container div\" />\n}\n\nexport const Required = () => {\n return (\n <form>\n <Input\n title=\"Example\"\n required\n placeholder=\"Submission should be blocked unless this has a value\"\n />\n\n <Input\n mt={1}\n title=\"Email\"\n required\n placeholder=\"Requires a valid email\"\n type=\"email\"\n />\n\n <Button mt={1}>Submit</Button>\n </form>\n )\n}\n\nexport const CustomHeight = () => {\n return <Input height={40} placeholder=\"Input is 40px in height\" />\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAA2C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AC;EAAyB,EAAG;AACpE,CAAC;AAAAlB,OAAA,CAAA6B,YAAA,GAAAA,YAAA;AAFYA,YAAY,CAAAV,WAAA"}
|
|
@@ -7,12 +7,13 @@ exports.INPUT_STATES = void 0;
|
|
|
7
7
|
var _themeGet = require("@styled-system/theme-get");
|
|
8
8
|
var _styledComponents = require("styled-components");
|
|
9
9
|
var INPUT_STATES = {
|
|
10
|
-
default: (0, _styledComponents.css)(["font-size:", ";color:", ";border-color:", ";::placeholder{color:", ";}"], (0, _themeGet.themeGet)("textVariants.sm.fontSize"), (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.black30"), (0, _themeGet.themeGet)("colors.black60")),
|
|
11
|
-
focus: (0, _styledComponents.css)(["color:", ";border-color:", ";::placeholder{color:", ";}"], (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.black60"), (0, _themeGet.themeGet)("colors.
|
|
12
|
-
hover: (0, _styledComponents.css)(["color:", ";border-color:", ";::placeholder{color:", ";}"], (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.black60"), (0, _themeGet.themeGet)("colors.black100")),
|
|
13
|
-
active: (0, _styledComponents.css)(["color:", ";border-color:", ";::placeholder{color:", ";}"], (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.blue100"), (0, _themeGet.themeGet)("colors.black100")),
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
default: (0, _styledComponents.css)(["font-size:", ";color:", ";border-color:", ";::placeholder{color:", ";}& + label{color:", ";font-size:", ";}"], (0, _themeGet.themeGet)("textVariants.sm-display.fontSize"), (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.black30"), (0, _themeGet.themeGet)("colors.black60"), (0, _themeGet.themeGet)("colors.black60"), (0, _themeGet.themeGet)("textVariants.sm-display.fontSize")),
|
|
11
|
+
focus: (0, _styledComponents.css)(["color:", ";border-color:", ";::placeholder{color:", ";opacity:1;}& + label{color:", ";transform:translateY(-150%);font-size:", ";padding:0 5px;}"], (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.blue100"), (0, _themeGet.themeGet)("colors.black60"), (0, _themeGet.themeGet)("colors.blue100"), (0, _themeGet.themeGet)("textVariants.xs.fontSize")),
|
|
12
|
+
hover: (0, _styledComponents.css)(["color:", ";border-color:", ";::placeholder{color:", ";}& + label{color:", ";}"], (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.black60"), (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.black100")),
|
|
13
|
+
active: (0, _styledComponents.css)(["color:", ";border-color:", ";::placeholder{color:", ";}& + label{color:", ";transform:translateY(-150%);font-size:", ";padding:0 5px;}"], (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.blue100"), (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.blue100"), (0, _themeGet.themeGet)("textVariants.xs.fontSize")),
|
|
14
|
+
completed: (0, _styledComponents.css)(["color:", ";border-color:", ";& + label{color:", ";transform:translateY(-150%);font-size:", ";padding:0 5px;}"], (0, _themeGet.themeGet)("colors.black100"), (0, _themeGet.themeGet)("colors.black60"), (0, _themeGet.themeGet)("colors.blue60"), (0, _themeGet.themeGet)("textVariants.xs.fontSize")),
|
|
15
|
+
disabled: (0, _styledComponents.css)(["color:", ";border-color:", ";background-color:transparent;-webkit-text-fill-color:", ";opacity:1;::placeholder{color:", ";}&:not(:placeholder-shown) + label{color:", ";transform:translateY(-150%);font-size:", ";}&:placeholder-shown + label{color:", ";}"], (0, _themeGet.themeGet)("colors.black30"), (0, _themeGet.themeGet)("colors.black30"), (0, _themeGet.themeGet)("colors.black30"), (0, _themeGet.themeGet)("colors.black30"), (0, _themeGet.themeGet)("colors.black30"), (0, _themeGet.themeGet)("textVariants.xs.fontSize"), (0, _themeGet.themeGet)("colors.black30")),
|
|
16
|
+
error: (0, _styledComponents.css)(["border-color:", ";& + label{color:", ";transform:translateY(-150%);font-size:", ";padding:0 5px;}"], (0, _themeGet.themeGet)("colors.red100"), (0, _themeGet.themeGet)("colors.red100"), (0, _themeGet.themeGet)("textVariants.xs.fontSize"))
|
|
16
17
|
};
|
|
17
18
|
exports.INPUT_STATES = INPUT_STATES;
|
|
18
19
|
//# sourceMappingURL=tokens.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","names":["_themeGet","require","_styledComponents","INPUT_STATES","default","css","themeGet","focus","hover","active","disabled","error","exports"],"sources":["../../../src/elements/Input/tokens.ts"],"sourcesContent":["import { themeGet } from \"@styled-system/theme-get\"\nimport { css } from \"styled-components\"\nimport { State } from \"./types\"\n\nexport const INPUT_STATES: Record<State, any> = {\n default: css`\n font-size: ${themeGet(\"textVariants.sm.fontSize\")};\n color: ${themeGet(\"colors.black100\")};\n border-color: ${themeGet(\"colors.black30\")};\n\n ::placeholder {\n color: ${themeGet(\"colors.black60\")};\n }\n `,\n focus: css`\n color: ${themeGet(\"colors.black100\")};\n border-color: ${themeGet(\"colors.
|
|
1
|
+
{"version":3,"file":"tokens.js","names":["_themeGet","require","_styledComponents","INPUT_STATES","default","css","themeGet","focus","hover","active","completed","disabled","error","exports"],"sources":["../../../src/elements/Input/tokens.ts"],"sourcesContent":["import { themeGet } from \"@styled-system/theme-get\"\nimport { css } from \"styled-components\"\nimport { State } from \"./types\"\n\nexport const INPUT_STATES: Record<State, any> = {\n default: css`\n font-size: ${themeGet(\"textVariants.sm-display.fontSize\")};\n color: ${themeGet(\"colors.black100\")};\n border-color: ${themeGet(\"colors.black30\")};\n\n ::placeholder {\n color: ${themeGet(\"colors.black60\")};\n }\n\n & + label {\n color: ${themeGet(\"colors.black60\")};\n font-size: ${themeGet(\"textVariants.sm-display.fontSize\")};\n }\n `,\n focus: css`\n color: ${themeGet(\"colors.black100\")};\n border-color: ${themeGet(\"colors.blue100\")};\n\n ::placeholder {\n color: ${themeGet(\"colors.black60\")};\n opacity: 1;\n }\n\n & + label {\n color: ${themeGet(\"colors.blue100\")};\n transform: translateY(-150%);\n font-size: ${themeGet(\"textVariants.xs.fontSize\")};\n padding: 0 5px;\n }\n `,\n hover: css`\n color: ${themeGet(\"colors.black100\")};\n border-color: ${themeGet(\"colors.black60\")};\n\n ::placeholder {\n color: ${themeGet(\"colors.black100\")};\n }\n\n & + label {\n color: ${themeGet(\"colors.black100\")};\n }\n `,\n active: css`\n color: ${themeGet(\"colors.black100\")};\n border-color: ${themeGet(\"colors.blue100\")};\n\n ::placeholder {\n color: ${themeGet(\"colors.black100\")};\n }\n\n & + label {\n color: ${themeGet(\"colors.blue100\")};\n transform: translateY(-150%);\n font-size: ${themeGet(\"textVariants.xs.fontSize\")};\n padding: 0 5px;\n }\n `,\n completed: css`\n color: ${themeGet(\"colors.black100\")};\n border-color: ${themeGet(\"colors.black60\")};\n\n & + label {\n color: ${themeGet(\"colors.blue60\")};\n transform: translateY(-150%);\n font-size: ${themeGet(\"textVariants.xs.fontSize\")};\n padding: 0 5px;\n }\n `,\n disabled: css`\n color: ${themeGet(\"colors.black30\")};\n border-color: ${themeGet(\"colors.black30\")};\n background-color: transparent;\n /* For Safari: */\n -webkit-text-fill-color: ${themeGet(\"colors.black30\")};\n /* For iOS */\n opacity: 1;\n\n ::placeholder {\n color: ${themeGet(\"colors.black30\")};\n }\n\n &:not(:placeholder-shown) + label {\n color: ${themeGet(\"colors.black30\")};\n transform: translateY(-150%);\n font-size: ${themeGet(\"textVariants.xs.fontSize\")};\n }\n\n &:placeholder-shown + label {\n color: ${themeGet(\"colors.black30\")};\n }\n `,\n error: css`\n border-color: ${themeGet(\"colors.red100\")};\n\n & + label {\n color: ${themeGet(\"colors.red100\")};\n transform: translateY(-150%);\n font-size: ${themeGet(\"textVariants.xs.fontSize\")};\n padding: 0 5px;\n }\n `,\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAGO,IAAME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AG,oQACF,IAAAC,kBAAQ,EAAC,gBAAgB,CAAC,EACnB,IAAAA,kBAAQ,EAAC,gBAAgB,CAAC,EAGf,IAAAA,kBAAQ,EAAC,gBAAgB,CAAC,EAK1C,IAAAA,kBAAQ,EAAC,gBAAgB,CAAC,EAI1B,IAAAA,kBAAQ,EAAC,gBAAgB,CAAC,EAEtB,IAAAA,kBAAQ,EAAC,0BAA0B,CAAC,EAIxC,IAAAA,kBAAQ,EAAC,gBAAgB,CAAC,CAEtC;EACDM,KAAK,MAAEP,qBAAG,yGACQ,IAAAC,kBAAQ,EAAC,eAAe,CAAC,EAG9B,IAAAA,kBAAQ,EAAC,eAAe,CAAC,EAErB,IAAAA,kBAAQ,EAAC,0BAA0B,CAAC;AAIvD,CAAC;AAAAO,OAAA,CAAAV,YAAA,GAAAA,YAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare type State = "active" | "default" | "disabled" | "error" | "focus" | "hover";
|
|
1
|
+
export declare type State = "active" | "default" | "disabled" | "error" | "focus" | "hover" | "completed";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/elements/Input/types.ts"],"sourcesContent":["export type State =\n | \"active\"\n | \"default\"\n | \"disabled\"\n | \"error\"\n | \"focus\"\n | \"hover\"\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/elements/Input/types.ts"],"sourcesContent":["export type State =\n | \"active\"\n | \"default\"\n | \"disabled\"\n | \"error\"\n | \"focus\"\n | \"hover\"\n | \"completed\"\n"],"mappings":""}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.Label = exports.LABEL_VARIANTS = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _Text = require("../Text");
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
11
|
var _styledSystem = require("styled-system");
|
|
@@ -38,7 +38,7 @@ var Label = function Label(_ref) {
|
|
|
38
38
|
return /*#__PURE__*/React.createElement(Container, _extends({
|
|
39
39
|
display: "inline-flex",
|
|
40
40
|
maxWidth: "100%"
|
|
41
|
-
}, rest), /*#__PURE__*/React.createElement(
|
|
41
|
+
}, rest), /*#__PURE__*/React.createElement(_Text.Text, {
|
|
42
42
|
variant: "xs",
|
|
43
43
|
px: 0.5,
|
|
44
44
|
overflowEllipsis: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.js","names":["
|
|
1
|
+
{"version":3,"file":"Label.js","names":["_Text","require","React","_interopRequireWildcard","_styledComponents","_interopRequireDefault","_styledSystem","_Box","_excluded","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","LABEL_VARIANTS","light","backgroundColor","color","dark","brand","exports","Label","_ref","children","rest","createElement","Container","display","maxWidth","Text","variant","px","overflowEllipsis","displayName","defaultProps","styled","Box","withConfig","componentId","variants"],"sources":["../../../src/elements/Label/Label.tsx"],"sourcesContent":["import { Text } from \"../Text\"\nimport * as React from \"react\"\nimport styled from \"styled-components\"\nimport { variant } from \"styled-system\"\nimport { Box, BoxProps } from \"../Box\"\n\nexport const LABEL_VARIANTS = {\n light: {\n backgroundColor: \"black10\",\n color: \"black100\",\n },\n dark: {\n backgroundColor: \"black100\",\n color: \"white100\",\n },\n brand: {\n backgroundColor: \"blue100\",\n color: \"white100\",\n },\n}\n\nexport type LabelVariant = keyof typeof LABEL_VARIANTS\n\nexport interface LabelProps extends BoxProps {\n variant?: LabelVariant\n children: React.ReactNode\n}\n\nexport const Label: React.FC<LabelProps> = ({ children, ...rest }) => {\n return (\n <Container display=\"inline-flex\" maxWidth=\"100%\" {...rest}>\n <Text variant=\"xs\" px={0.5} overflowEllipsis>\n {children}\n </Text>\n </Container>\n )\n}\n\nLabel.defaultProps = {\n variant: \"light\",\n}\n\nconst Container = styled(Box)`\n ${variant({ variants: LABEL_VARIANTS })}\n`\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AAAsC,IAAAO,SAAA;AAAA,SAAAH,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAV,wBAAAM,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAQ,OAAA,CAAAR,GAAA,yBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAS,KAAA,GAAAN,wBAAA,CAAAC,WAAA,OAAAK,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAV,GAAA,YAAAS,KAAA,CAAAE,GAAA,CAAAX,GAAA,SAAAY,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAjB,GAAA,QAAAi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C,OAAO,EAAC,IAAI;IAACC,EAAE,EAAE,GAAI;IAACC,gBAAgB;EAAA,GACzCT,QAAQ,CACJ,CACG;AAEhB,CAAC;AAAAH,OAAA,CAAAC,KAAA,GAAAA,KAAA;AARYA,KAA2B,CAAAY,WAAA;AAUxCZ,KAAK,CAACa,YAAY,GAAG;EACnBJ,OAAO,EAAE;AACX,CAAC;AAED,IAAMJ,SAAS,GAAG,IAAAS,yBAAM,EAACC,QAAG,CAAC,CAAAC,UAAA;EAAAJ,WAAA;EAAAK,WAAA;AAAA,aACzB,IAAAR,qBAAO,EAAC;EAAES,QAAQ,EAAEzB;AAAe,CAAC,CAAC,CACxC"}
|
|
@@ -2,8 +2,9 @@ import React from "react";
|
|
|
2
2
|
import { InputProps } from "../Input";
|
|
3
3
|
export interface LabeledInputProps extends InputProps {
|
|
4
4
|
label: React.ReactNode;
|
|
5
|
+
variant?: "suffix" | "prefix";
|
|
5
6
|
}
|
|
6
|
-
/** Input with a right-aligned label */
|
|
7
|
+
/** Input with a right-aligned or left-aligned label */
|
|
7
8
|
export declare const LabeledInput: React.ForwardRefExoticComponent<LabeledInputProps & {
|
|
8
9
|
ref?: React.Ref<HTMLInputElement>;
|
|
9
10
|
}>;
|
|
@@ -10,10 +10,13 @@ var _isText2 = require("../../helpers/isText");
|
|
|
10
10
|
var _Box = require("../Box");
|
|
11
11
|
var _Input = require("../Input");
|
|
12
12
|
var _Text = require("../Text");
|
|
13
|
-
var _excluded = ["label", "height"];
|
|
13
|
+
var _excluded = ["label", "height", "variant"];
|
|
14
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
16
|
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); }
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
20
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
21
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
22
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -22,10 +25,12 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
22
25
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
26
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
24
27
|
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; }
|
|
25
|
-
/** Input with a right-aligned label */
|
|
28
|
+
/** Input with a right-aligned or left-aligned label */
|
|
26
29
|
var LabeledInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, forwardedRef) {
|
|
27
30
|
var label = _ref.label,
|
|
28
31
|
height = _ref.height,
|
|
32
|
+
_ref$variant = _ref.variant,
|
|
33
|
+
variant = _ref$variant === void 0 ? "suffix" : _ref$variant,
|
|
29
34
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
30
35
|
var labelRef = (0, _react.useRef)(null);
|
|
31
36
|
var _useState = (0, _react.useState)(0),
|
|
@@ -41,27 +46,24 @@ var LabeledInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, forwar
|
|
|
41
46
|
boxProps = _splitBoxProps2[0],
|
|
42
47
|
inputProps = _splitBoxProps2[1];
|
|
43
48
|
var isText = (0, _isText2.isText)(label);
|
|
49
|
+
var isPrefix = variant === "prefix";
|
|
44
50
|
return /*#__PURE__*/_react.default.createElement(_Box.Box, _extends({
|
|
45
51
|
position: "relative"
|
|
46
52
|
}, boxProps), /*#__PURE__*/_react.default.createElement(_Input.Input, _extends({
|
|
47
53
|
ref: forwardedRef,
|
|
48
|
-
height: height
|
|
49
|
-
|
|
50
|
-
paddingRight: "".concat(offset + 10, "px")
|
|
51
|
-
}
|
|
52
|
-
}, inputProps), /*#__PURE__*/_react.default.createElement(_Box.Box, {
|
|
54
|
+
height: height
|
|
55
|
+
}, _defineProperty({}, isPrefix ? "prefixOffset" : "suffixOffset", offset + 15), inputProps), /*#__PURE__*/_react.default.createElement(_Box.Box, _extends({
|
|
53
56
|
ref: labelRef,
|
|
54
57
|
position: "absolute",
|
|
55
58
|
display: "flex",
|
|
56
59
|
alignItems: "center",
|
|
57
|
-
right: 1,
|
|
58
60
|
top: 0,
|
|
59
61
|
bottom: 0,
|
|
60
62
|
style: {
|
|
61
63
|
pointerEvents: isText ? "none" : undefined
|
|
62
64
|
}
|
|
63
|
-
}, isText ? /*#__PURE__*/_react.default.createElement(_Text.Text, {
|
|
64
|
-
variant: "
|
|
65
|
+
}, _defineProperty({}, isPrefix ? "left" : "right", 1)), isText ? /*#__PURE__*/_react.default.createElement(_Text.Text, {
|
|
66
|
+
variant: "sm-display",
|
|
65
67
|
color: "black60",
|
|
66
68
|
lineHeight: 1
|
|
67
69
|
}, label) : label)));
|