glints-aries 4.0.193 → 4.0.194
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/es/@next/CurrencyInput/CurrencyInput.d.ts +4 -0
- package/es/@next/CurrencyInput/CurrencyInput.js +26 -4
- package/es/@next/Input/Input.js +31 -4
- package/es/@next/Input/InputStyle.d.ts +6 -1
- package/es/@next/Input/InputStyle.js +8 -3
- package/es/@next/Popover/popoverStoryHelper/SalarySelector.js +2 -0
- package/lib/@next/CurrencyInput/CurrencyInput.d.ts +4 -0
- package/lib/@next/CurrencyInput/CurrencyInput.js +26 -4
- package/lib/@next/Input/Input.js +33 -4
- package/lib/@next/Input/InputStyle.d.ts +6 -1
- package/lib/@next/Input/InputStyle.js +8 -3
- package/lib/@next/Popover/popoverStoryHelper/SalarySelector.js +2 -0
- package/package.json +1 -1
- package/es/@next/CurrencyInput/CurrencyStyles.d.ts +0 -2
- package/es/@next/CurrencyInput/CurrencyStyles.js +0 -7
- package/lib/@next/CurrencyInput/CurrencyStyles.d.ts +0 -2
- package/lib/@next/CurrencyInput/CurrencyStyles.js +0 -13
|
@@ -4,9 +4,13 @@ export declare type CurrencyInputProps = Omit<InputProps, 'type' | 'prefix' | 'o
|
|
|
4
4
|
locale?: string;
|
|
5
5
|
value?: number;
|
|
6
6
|
onChange?: (value: number) => void;
|
|
7
|
+
currencyCode: string;
|
|
8
|
+
currencySymbol?: string;
|
|
7
9
|
};
|
|
8
10
|
export declare const CurrencyInput: React.ForwardRefExoticComponent<Omit<InputProps, "type" | "value" | "prefix" | "onChange"> & {
|
|
9
11
|
locale?: string;
|
|
10
12
|
value?: number;
|
|
11
13
|
onChange?: (value: number) => void;
|
|
14
|
+
currencyCode: string;
|
|
15
|
+
currencySymbol?: string;
|
|
12
16
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["locale", "value", "onChange"];
|
|
3
|
+
var _excluded = ["locale", "value", "onChange", "currencyCode", "currencySymbol"];
|
|
4
4
|
import React, { useState } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { Input } from '../Input/Input';
|
|
6
6
|
export var CurrencyInput = /*#__PURE__*/React.forwardRef(function CurrencyInput(_ref, ref) {
|
|
7
7
|
var _ref$locale = _ref.locale,
|
|
8
8
|
locale = _ref$locale === void 0 ? 'en' : _ref$locale,
|
|
9
9
|
_ref$value = _ref.value,
|
|
10
10
|
value = _ref$value === void 0 ? 0 : _ref$value,
|
|
11
11
|
onChange = _ref.onChange,
|
|
12
|
+
currencyCode = _ref.currencyCode,
|
|
13
|
+
currencySymbol = _ref.currencySymbol,
|
|
12
14
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
13
15
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14
16
|
// @ts-ignore
|
|
@@ -28,6 +30,26 @@ export var CurrencyInput = /*#__PURE__*/React.forwardRef(function CurrencyInput(
|
|
|
28
30
|
var cleanedValue = parseFloat(value.replace(new RegExp('\\' + thousandSeparator, 'g'), '').replace(new RegExp('\\' + decimalSeparator), '.'));
|
|
29
31
|
return Number.isNaN(cleanedValue) ? 0 : cleanedValue;
|
|
30
32
|
};
|
|
33
|
+
var getCurrencySymbol = function getCurrencySymbol(locale, currencyCode, currencySymbol) {
|
|
34
|
+
if (currencySymbol) {
|
|
35
|
+
return currencySymbol;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
var _parts$find;
|
|
39
|
+
var _formatter = new Intl.NumberFormat(locale, {
|
|
40
|
+
style: 'currency',
|
|
41
|
+
currency: currencyCode
|
|
42
|
+
});
|
|
43
|
+
var parts = _formatter.formatToParts(0);
|
|
44
|
+
var returnedCurrencySymbol = (_parts$find = parts.find(function (part) {
|
|
45
|
+
return part.type === 'currency';
|
|
46
|
+
})) == null ? void 0 : _parts$find.value;
|
|
47
|
+
return returnedCurrencySymbol;
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.warn("Currency code of " + currencyCode + " is unsupported, \"$\" will be used");
|
|
50
|
+
}
|
|
51
|
+
return '$';
|
|
52
|
+
};
|
|
31
53
|
var _useState = useState(formatter.format(getRawNumber(value.toString()))),
|
|
32
54
|
formattedValue = _useState[0],
|
|
33
55
|
setFormattedValue = _useState[1];
|
|
@@ -36,10 +58,10 @@ export var CurrencyInput = /*#__PURE__*/React.forwardRef(function CurrencyInput(
|
|
|
36
58
|
onChange(rawValue);
|
|
37
59
|
setFormattedValue(formatter.format(rawValue));
|
|
38
60
|
};
|
|
39
|
-
return /*#__PURE__*/React.createElement(
|
|
61
|
+
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
40
62
|
ref: ref,
|
|
41
63
|
type: "text",
|
|
42
|
-
prefix: /*#__PURE__*/React.createElement("div", null,
|
|
64
|
+
prefix: /*#__PURE__*/React.createElement("div", null, getCurrencySymbol(localeValue, currencyCode, currencySymbol))
|
|
43
65
|
}, props, {
|
|
44
66
|
value: formattedValue === '0' ? '' : formattedValue,
|
|
45
67
|
onChange: handleChange
|
package/es/@next/Input/Input.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
3
|
var _excluded = ["error", "disabled", "prefix", "suffix"];
|
|
4
|
-
import React from 'react';
|
|
4
|
+
import React, { useEffect, useRef } from 'react';
|
|
5
5
|
import { StyledContainer, StyledInput, StyledPrefixContainer, StyledSuffixContainer } from './InputStyle';
|
|
6
6
|
export var Input = /*#__PURE__*/React.forwardRef(function Input(_ref, ref) {
|
|
7
7
|
var error = _ref.error,
|
|
@@ -11,17 +11,44 @@ export var Input = /*#__PURE__*/React.forwardRef(function Input(_ref, ref) {
|
|
|
11
11
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
12
12
|
var hasPrefix = !!prefix;
|
|
13
13
|
var hasSuffix = !!suffix;
|
|
14
|
+
var prefixRef = useRef(null);
|
|
15
|
+
var suffixRef = useRef(null);
|
|
14
16
|
var Prefix = function Prefix() {
|
|
15
|
-
return hasPrefix ? /*#__PURE__*/React.createElement(StyledPrefixContainer,
|
|
17
|
+
return hasPrefix ? /*#__PURE__*/React.createElement(StyledPrefixContainer, {
|
|
18
|
+
ref: prefixRef
|
|
19
|
+
}, prefix) : null;
|
|
16
20
|
};
|
|
17
21
|
var Suffix = function Suffix() {
|
|
18
|
-
return hasSuffix ? /*#__PURE__*/React.createElement(StyledSuffixContainer,
|
|
22
|
+
return hasSuffix ? /*#__PURE__*/React.createElement(StyledSuffixContainer, {
|
|
23
|
+
ref: suffixRef
|
|
24
|
+
}, suffix) : null;
|
|
19
25
|
};
|
|
26
|
+
var _React$useState = React.useState(0),
|
|
27
|
+
prefixWidth = _React$useState[0],
|
|
28
|
+
setPrefixWidth = _React$useState[1];
|
|
29
|
+
var _React$useState2 = React.useState(0),
|
|
30
|
+
suffixWidth = _React$useState2[0],
|
|
31
|
+
setSuffixWidth = _React$useState2[1];
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
if (hasPrefix) {
|
|
34
|
+
var _prefixWidth = prefixRef.current.getBoundingClientRect().width;
|
|
35
|
+
setPrefixWidth(_prefixWidth);
|
|
36
|
+
}
|
|
37
|
+
}, [hasPrefix, prefix]);
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (hasSuffix) {
|
|
40
|
+
var _suffixWidth = suffixRef.current.getBoundingClientRect().width;
|
|
41
|
+
setSuffixWidth(_suffixWidth);
|
|
42
|
+
}
|
|
43
|
+
}, [hasSuffix, suffix]);
|
|
20
44
|
return /*#__PURE__*/React.createElement(StyledContainer, {
|
|
21
45
|
ref: ref,
|
|
22
46
|
"data-prefix": hasPrefix,
|
|
47
|
+
"data-suffix": hasSuffix,
|
|
23
48
|
"data-error": error,
|
|
24
|
-
"data-disabled": disabled
|
|
49
|
+
"data-disabled": disabled,
|
|
50
|
+
prefixWidth: prefixWidth,
|
|
51
|
+
suffixWidth: suffixWidth
|
|
25
52
|
}, /*#__PURE__*/React.createElement(Prefix, null), /*#__PURE__*/React.createElement(StyledInput, _extends({
|
|
26
53
|
disabled: disabled
|
|
27
54
|
}, props)), /*#__PURE__*/React.createElement(Suffix, null));
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { InputProps } from './Input';
|
|
2
|
-
|
|
2
|
+
interface PreffixSuffixWidthProps {
|
|
3
|
+
prefixWidth: number;
|
|
4
|
+
suffixWidth: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const StyledContainer: import("styled-components").StyledComponent<"div", any, InputProps & PreffixSuffixWidthProps, never>;
|
|
3
7
|
export declare const StyledPrefixContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
8
|
export declare const StyledSuffixContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
9
|
export declare const StyledInput: import("styled-components").StyledComponent<"input", any, InputProps, never>;
|
|
10
|
+
export {};
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import * as Breakpoints from '../utilities/breakpoints';
|
|
3
3
|
import { Neutral, Red } from '../utilities/colors';
|
|
4
|
+
import { space12, space4, space8 } from '../utilities/spacing';
|
|
4
5
|
export var StyledContainer = styled.div.withConfig({
|
|
5
6
|
displayName: "InputStyle__StyledContainer",
|
|
6
7
|
componentId: "sc-15z2mnd-0"
|
|
7
|
-
})(["position:relative;display:flex;flex-direction:column;flex:1;flex-basis:100%;font-family:'Noto Sans',sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:150%;&[data-prefix='true'] input{padding-left:
|
|
8
|
+
})(["position:relative;display:flex;flex-direction:column;flex:1;flex-basis:100%;font-family:'Noto Sans',sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:150%;&[data-prefix='true'] input{padding-left:", "px;}&[data-suffix='true'] input{padding-right:", "px;}&[data-error='true'] input{border:1px solid ", ";}&[data-error='true'] input:focus{box-shadow:none;}&[data-disabled='true'] input{border:1px solid ", ";background:", ";color:", ";}&[data-disabled='true'] input::placeholder{color:", ";}&[data-disabled='true'] svg{fill:", ";}&[data-disabled='true'] div{color:", ";}"], function (props) {
|
|
9
|
+
return props.prefixWidth;
|
|
10
|
+
}, function (props) {
|
|
11
|
+
return props.suffixWidth;
|
|
12
|
+
}, Red.B93, Neutral.B85, Neutral.B95, Neutral.B85, Neutral.B85, Neutral.B85, Neutral.B85);
|
|
8
13
|
export var StyledPrefixContainer = styled.div.withConfig({
|
|
9
14
|
displayName: "InputStyle__StyledPrefixContainer",
|
|
10
15
|
componentId: "sc-15z2mnd-1"
|
|
11
|
-
})(["position:absolute;
|
|
16
|
+
})(["position:absolute;left:0;color:", ";display:flex;align-items:center;height:36px;padding:0px ", " 0 ", ";svg{height:17px;width:17px;fill:", ";}"], Neutral.B40, space8, space12, Neutral.B40);
|
|
12
17
|
export var StyledSuffixContainer = styled(StyledPrefixContainer).withConfig({
|
|
13
18
|
displayName: "InputStyle__StyledSuffixContainer",
|
|
14
19
|
componentId: "sc-15z2mnd-2"
|
|
15
|
-
})(["left:auto;right:0;"]);
|
|
20
|
+
})(["left:auto;right:0;padding:0px ", " 0 ", ";"], space12, space4);
|
|
16
21
|
export var StyledInput = styled.input.withConfig({
|
|
17
22
|
displayName: "InputStyle__StyledInput",
|
|
18
23
|
componentId: "sc-15z2mnd-3"
|
|
@@ -15,8 +15,10 @@ export var SalarySelector = function SalarySelector(_ref) {
|
|
|
15
15
|
as: "div",
|
|
16
16
|
variant: "caption"
|
|
17
17
|
}, "IDR"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CurrencyInput, {
|
|
18
|
+
currencyCode: "USD",
|
|
18
19
|
onChange: onFromChanged
|
|
19
20
|
})), /*#__PURE__*/React.createElement("div", null, "-"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CurrencyInput, {
|
|
21
|
+
currencyCode: "USD",
|
|
20
22
|
onChange: onToChanged
|
|
21
23
|
}))));
|
|
22
24
|
};
|
|
@@ -4,9 +4,13 @@ export declare type CurrencyInputProps = Omit<InputProps, 'type' | 'prefix' | 'o
|
|
|
4
4
|
locale?: string;
|
|
5
5
|
value?: number;
|
|
6
6
|
onChange?: (value: number) => void;
|
|
7
|
+
currencyCode: string;
|
|
8
|
+
currencySymbol?: string;
|
|
7
9
|
};
|
|
8
10
|
export declare const CurrencyInput: React.ForwardRefExoticComponent<Omit<InputProps, "type" | "value" | "prefix" | "onChange"> & {
|
|
9
11
|
locale?: string;
|
|
10
12
|
value?: number;
|
|
11
13
|
onChange?: (value: number) => void;
|
|
14
|
+
currencyCode: string;
|
|
15
|
+
currencySymbol?: string;
|
|
12
16
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -6,8 +6,8 @@ exports.CurrencyInput = void 0;
|
|
|
6
6
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
7
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var
|
|
10
|
-
var _excluded = ["locale", "value", "onChange"];
|
|
9
|
+
var _Input = require("../Input/Input");
|
|
10
|
+
var _excluded = ["locale", "value", "onChange", "currencyCode", "currencySymbol"];
|
|
11
11
|
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); }
|
|
12
12
|
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; }
|
|
13
13
|
var CurrencyInput = /*#__PURE__*/_react["default"].forwardRef(function CurrencyInput(_ref, ref) {
|
|
@@ -16,6 +16,8 @@ var CurrencyInput = /*#__PURE__*/_react["default"].forwardRef(function CurrencyI
|
|
|
16
16
|
_ref$value = _ref.value,
|
|
17
17
|
value = _ref$value === void 0 ? 0 : _ref$value,
|
|
18
18
|
onChange = _ref.onChange,
|
|
19
|
+
currencyCode = _ref.currencyCode,
|
|
20
|
+
currencySymbol = _ref.currencySymbol,
|
|
19
21
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
20
22
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
21
23
|
// @ts-ignore
|
|
@@ -35,6 +37,26 @@ var CurrencyInput = /*#__PURE__*/_react["default"].forwardRef(function CurrencyI
|
|
|
35
37
|
var cleanedValue = parseFloat(value.replace(new RegExp('\\' + thousandSeparator, 'g'), '').replace(new RegExp('\\' + decimalSeparator), '.'));
|
|
36
38
|
return Number.isNaN(cleanedValue) ? 0 : cleanedValue;
|
|
37
39
|
};
|
|
40
|
+
var getCurrencySymbol = function getCurrencySymbol(locale, currencyCode, currencySymbol) {
|
|
41
|
+
if (currencySymbol) {
|
|
42
|
+
return currencySymbol;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
var _parts$find;
|
|
46
|
+
var _formatter = new Intl.NumberFormat(locale, {
|
|
47
|
+
style: 'currency',
|
|
48
|
+
currency: currencyCode
|
|
49
|
+
});
|
|
50
|
+
var parts = _formatter.formatToParts(0);
|
|
51
|
+
var returnedCurrencySymbol = (_parts$find = parts.find(function (part) {
|
|
52
|
+
return part.type === 'currency';
|
|
53
|
+
})) == null ? void 0 : _parts$find.value;
|
|
54
|
+
return returnedCurrencySymbol;
|
|
55
|
+
} catch (e) {
|
|
56
|
+
console.warn("Currency code of " + currencyCode + " is unsupported, \"$\" will be used");
|
|
57
|
+
}
|
|
58
|
+
return '$';
|
|
59
|
+
};
|
|
38
60
|
var _useState = (0, _react.useState)(formatter.format(getRawNumber(value.toString()))),
|
|
39
61
|
formattedValue = _useState[0],
|
|
40
62
|
setFormattedValue = _useState[1];
|
|
@@ -43,10 +65,10 @@ var CurrencyInput = /*#__PURE__*/_react["default"].forwardRef(function CurrencyI
|
|
|
43
65
|
onChange(rawValue);
|
|
44
66
|
setFormattedValue(formatter.format(rawValue));
|
|
45
67
|
};
|
|
46
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
68
|
+
return /*#__PURE__*/_react["default"].createElement(_Input.Input, (0, _extends2["default"])({
|
|
47
69
|
ref: ref,
|
|
48
70
|
type: "text",
|
|
49
|
-
prefix: /*#__PURE__*/_react["default"].createElement("div", null,
|
|
71
|
+
prefix: /*#__PURE__*/_react["default"].createElement("div", null, getCurrencySymbol(localeValue, currencyCode, currencySymbol))
|
|
50
72
|
}, props, {
|
|
51
73
|
value: formattedValue === '0' ? '' : formattedValue,
|
|
52
74
|
onChange: handleChange
|
package/lib/@next/Input/Input.js
CHANGED
|
@@ -5,9 +5,11 @@ exports.__esModule = true;
|
|
|
5
5
|
exports.Input = void 0;
|
|
6
6
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
7
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _InputStyle = require("./InputStyle");
|
|
10
10
|
var _excluded = ["error", "disabled", "prefix", "suffix"];
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
11
13
|
var Input = /*#__PURE__*/_react["default"].forwardRef(function Input(_ref, ref) {
|
|
12
14
|
var error = _ref.error,
|
|
13
15
|
disabled = _ref.disabled,
|
|
@@ -16,17 +18,44 @@ var Input = /*#__PURE__*/_react["default"].forwardRef(function Input(_ref, ref)
|
|
|
16
18
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
17
19
|
var hasPrefix = !!prefix;
|
|
18
20
|
var hasSuffix = !!suffix;
|
|
21
|
+
var prefixRef = (0, _react.useRef)(null);
|
|
22
|
+
var suffixRef = (0, _react.useRef)(null);
|
|
19
23
|
var Prefix = function Prefix() {
|
|
20
|
-
return hasPrefix ? /*#__PURE__*/_react["default"].createElement(_InputStyle.StyledPrefixContainer,
|
|
24
|
+
return hasPrefix ? /*#__PURE__*/_react["default"].createElement(_InputStyle.StyledPrefixContainer, {
|
|
25
|
+
ref: prefixRef
|
|
26
|
+
}, prefix) : null;
|
|
21
27
|
};
|
|
22
28
|
var Suffix = function Suffix() {
|
|
23
|
-
return hasSuffix ? /*#__PURE__*/_react["default"].createElement(_InputStyle.StyledSuffixContainer,
|
|
29
|
+
return hasSuffix ? /*#__PURE__*/_react["default"].createElement(_InputStyle.StyledSuffixContainer, {
|
|
30
|
+
ref: suffixRef
|
|
31
|
+
}, suffix) : null;
|
|
24
32
|
};
|
|
33
|
+
var _React$useState = _react["default"].useState(0),
|
|
34
|
+
prefixWidth = _React$useState[0],
|
|
35
|
+
setPrefixWidth = _React$useState[1];
|
|
36
|
+
var _React$useState2 = _react["default"].useState(0),
|
|
37
|
+
suffixWidth = _React$useState2[0],
|
|
38
|
+
setSuffixWidth = _React$useState2[1];
|
|
39
|
+
(0, _react.useEffect)(function () {
|
|
40
|
+
if (hasPrefix) {
|
|
41
|
+
var _prefixWidth = prefixRef.current.getBoundingClientRect().width;
|
|
42
|
+
setPrefixWidth(_prefixWidth);
|
|
43
|
+
}
|
|
44
|
+
}, [hasPrefix, prefix]);
|
|
45
|
+
(0, _react.useEffect)(function () {
|
|
46
|
+
if (hasSuffix) {
|
|
47
|
+
var _suffixWidth = suffixRef.current.getBoundingClientRect().width;
|
|
48
|
+
setSuffixWidth(_suffixWidth);
|
|
49
|
+
}
|
|
50
|
+
}, [hasSuffix, suffix]);
|
|
25
51
|
return /*#__PURE__*/_react["default"].createElement(_InputStyle.StyledContainer, {
|
|
26
52
|
ref: ref,
|
|
27
53
|
"data-prefix": hasPrefix,
|
|
54
|
+
"data-suffix": hasSuffix,
|
|
28
55
|
"data-error": error,
|
|
29
|
-
"data-disabled": disabled
|
|
56
|
+
"data-disabled": disabled,
|
|
57
|
+
prefixWidth: prefixWidth,
|
|
58
|
+
suffixWidth: suffixWidth
|
|
30
59
|
}, /*#__PURE__*/_react["default"].createElement(Prefix, null), /*#__PURE__*/_react["default"].createElement(_InputStyle.StyledInput, (0, _extends2["default"])({
|
|
31
60
|
disabled: disabled
|
|
32
61
|
}, props)), /*#__PURE__*/_react["default"].createElement(Suffix, null));
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { InputProps } from './Input';
|
|
2
|
-
|
|
2
|
+
interface PreffixSuffixWidthProps {
|
|
3
|
+
prefixWidth: number;
|
|
4
|
+
suffixWidth: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const StyledContainer: import("styled-components").StyledComponent<"div", any, InputProps & PreffixSuffixWidthProps, never>;
|
|
3
7
|
export declare const StyledPrefixContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
8
|
export declare const StyledSuffixContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
9
|
export declare const StyledInput: import("styled-components").StyledComponent<"input", any, InputProps, never>;
|
|
10
|
+
export {};
|
|
@@ -6,22 +6,27 @@ exports.StyledSuffixContainer = exports.StyledPrefixContainer = exports.StyledIn
|
|
|
6
6
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
7
7
|
var Breakpoints = _interopRequireWildcard(require("../utilities/breakpoints"));
|
|
8
8
|
var _colors = require("../utilities/colors");
|
|
9
|
+
var _spacing = require("../utilities/spacing");
|
|
9
10
|
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); }
|
|
10
11
|
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; }
|
|
11
12
|
var StyledContainer = _styledComponents["default"].div.withConfig({
|
|
12
13
|
displayName: "InputStyle__StyledContainer",
|
|
13
14
|
componentId: "sc-15z2mnd-0"
|
|
14
|
-
})(["position:relative;display:flex;flex-direction:column;flex:1;flex-basis:100%;font-family:'Noto Sans',sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:150%;&[data-prefix='true'] input{padding-left:
|
|
15
|
+
})(["position:relative;display:flex;flex-direction:column;flex:1;flex-basis:100%;font-family:'Noto Sans',sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:150%;&[data-prefix='true'] input{padding-left:", "px;}&[data-suffix='true'] input{padding-right:", "px;}&[data-error='true'] input{border:1px solid ", ";}&[data-error='true'] input:focus{box-shadow:none;}&[data-disabled='true'] input{border:1px solid ", ";background:", ";color:", ";}&[data-disabled='true'] input::placeholder{color:", ";}&[data-disabled='true'] svg{fill:", ";}&[data-disabled='true'] div{color:", ";}"], function (props) {
|
|
16
|
+
return props.prefixWidth;
|
|
17
|
+
}, function (props) {
|
|
18
|
+
return props.suffixWidth;
|
|
19
|
+
}, _colors.Red.B93, _colors.Neutral.B85, _colors.Neutral.B95, _colors.Neutral.B85, _colors.Neutral.B85, _colors.Neutral.B85, _colors.Neutral.B85);
|
|
15
20
|
exports.StyledContainer = StyledContainer;
|
|
16
21
|
var StyledPrefixContainer = _styledComponents["default"].div.withConfig({
|
|
17
22
|
displayName: "InputStyle__StyledPrefixContainer",
|
|
18
23
|
componentId: "sc-15z2mnd-1"
|
|
19
|
-
})(["position:absolute;
|
|
24
|
+
})(["position:absolute;left:0;color:", ";display:flex;align-items:center;height:36px;padding:0px ", " 0 ", ";svg{height:17px;width:17px;fill:", ";}"], _colors.Neutral.B40, _spacing.space8, _spacing.space12, _colors.Neutral.B40);
|
|
20
25
|
exports.StyledPrefixContainer = StyledPrefixContainer;
|
|
21
26
|
var StyledSuffixContainer = (0, _styledComponents["default"])(StyledPrefixContainer).withConfig({
|
|
22
27
|
displayName: "InputStyle__StyledSuffixContainer",
|
|
23
28
|
componentId: "sc-15z2mnd-2"
|
|
24
|
-
})(["left:auto;right:0;"]);
|
|
29
|
+
})(["left:auto;right:0;padding:0px ", " 0 ", ";"], _spacing.space12, _spacing.space4);
|
|
25
30
|
exports.StyledSuffixContainer = StyledSuffixContainer;
|
|
26
31
|
var StyledInput = _styledComponents["default"].input.withConfig({
|
|
27
32
|
displayName: "InputStyle__StyledInput",
|
|
@@ -20,8 +20,10 @@ var SalarySelector = function SalarySelector(_ref) {
|
|
|
20
20
|
as: "div",
|
|
21
21
|
variant: "caption"
|
|
22
22
|
}, "IDR"), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_CurrencyInput.CurrencyInput, {
|
|
23
|
+
currencyCode: "USD",
|
|
23
24
|
onChange: onFromChanged
|
|
24
25
|
})), /*#__PURE__*/_react["default"].createElement("div", null, "-"), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_CurrencyInput.CurrencyInput, {
|
|
26
|
+
currencyCode: "USD",
|
|
25
27
|
onChange: onToChanged
|
|
26
28
|
}))));
|
|
27
29
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { Input } from '../Input/Input';
|
|
3
|
-
import { space24 } from '../utilities/spacing';
|
|
4
|
-
export var StyledCurrency = styled(Input).withConfig({
|
|
5
|
-
displayName: "CurrencyStyles__StyledCurrency",
|
|
6
|
-
componentId: "sc-lcby3l-0"
|
|
7
|
-
})(["padding-left:", " !important;"], space24);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.StyledCurrency = void 0;
|
|
6
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
7
|
-
var _Input = require("../Input/Input");
|
|
8
|
-
var _spacing = require("../utilities/spacing");
|
|
9
|
-
var StyledCurrency = (0, _styledComponents["default"])(_Input.Input).withConfig({
|
|
10
|
-
displayName: "CurrencyStyles__StyledCurrency",
|
|
11
|
-
componentId: "sc-lcby3l-0"
|
|
12
|
-
})(["padding-left:", " !important;"], _spacing.space24);
|
|
13
|
-
exports.StyledCurrency = StyledCurrency;
|