glints-aries 4.0.320 → 4.0.322
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/AuthenticationInput/AuthenticationInput.d.ts +10 -0
- package/es/@next/AuthenticationInput/AuthenticationInput.js +97 -0
- package/es/@next/AuthenticationInput/AuthenticationInput.stories.d.ts +4 -0
- package/es/@next/AuthenticationInput/AuthenticationInputSingle.d.ts +13 -0
- package/es/@next/AuthenticationInput/AuthenticationInputSingle.js +54 -0
- package/es/@next/AuthenticationInput/AuthenticationInputStyle.d.ts +1 -0
- package/es/@next/AuthenticationInput/AuthenticationInputStyle.js +6 -0
- package/es/@next/AuthenticationInput/index.d.ts +1 -0
- package/es/@next/AuthenticationInput/index.js +1 -0
- package/es/@next/Input/Input.d.ts +1 -0
- package/es/@next/Input/Input.js +3 -1
- package/es/@next/Input/InputStyle.js +1 -1
- package/es/@next/Tag/Tag.d.ts +3 -0
- package/es/@next/Tag/Tag.js +14 -5
- package/es/@next/Tag/Tag.stories.d.ts +1 -0
- package/es/@next/Tag/TagStyle.d.ts +1 -0
- package/es/@next/Tag/TagStyle.js +12 -8
- package/es/@next/index.d.ts +2 -0
- package/es/@next/index.js +1 -0
- package/lib/@next/AuthenticationInput/AuthenticationInput.d.ts +10 -0
- package/lib/@next/AuthenticationInput/AuthenticationInput.js +105 -0
- package/lib/@next/AuthenticationInput/AuthenticationInput.stories.d.ts +4 -0
- package/lib/@next/AuthenticationInput/AuthenticationInputSingle.d.ts +13 -0
- package/lib/@next/AuthenticationInput/AuthenticationInputSingle.js +62 -0
- package/lib/@next/AuthenticationInput/AuthenticationInputStyle.d.ts +1 -0
- package/lib/@next/AuthenticationInput/AuthenticationInputStyle.js +12 -0
- package/lib/@next/AuthenticationInput/index.d.ts +1 -0
- package/lib/@next/AuthenticationInput/index.js +9 -0
- package/lib/@next/Input/Input.d.ts +1 -0
- package/lib/@next/Input/Input.js +3 -1
- package/lib/@next/Input/InputStyle.js +1 -1
- package/lib/@next/Tag/Tag.d.ts +3 -0
- package/lib/@next/Tag/Tag.js +13 -4
- package/lib/@next/Tag/Tag.stories.d.ts +1 -0
- package/lib/@next/Tag/TagStyle.d.ts +1 -0
- package/lib/@next/Tag/TagStyle.js +12 -7
- package/lib/@next/index.d.ts +2 -0
- package/lib/@next/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { RefObject } from 'react';
|
|
2
|
+
export interface AuthenticationInputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
3
|
+
numberOfInputs: number;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
error?: boolean;
|
|
6
|
+
forwardedRef?: RefObject<HTMLDivElement>;
|
|
7
|
+
/** will always return null when not all inputs are filled */
|
|
8
|
+
onChange?: (value: string | null) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const AuthenticationInput: React.ForwardRefExoticComponent<AuthenticationInputProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["numberOfInputs", "error", "onChange", "forwardedRef"];
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { StyledInputsContainer } from './AuthenticationInputStyle';
|
|
6
|
+
import { AuthenticationInputSingle } from './AuthenticationInputSingle';
|
|
7
|
+
var AuthenticationInputComponent = function AuthenticationInputComponent(_ref) {
|
|
8
|
+
var _ref$numberOfInputs = _ref.numberOfInputs,
|
|
9
|
+
numberOfInputs = _ref$numberOfInputs === void 0 ? 6 : _ref$numberOfInputs,
|
|
10
|
+
error = _ref.error,
|
|
11
|
+
onChange = _ref.onChange,
|
|
12
|
+
forwardedRef = _ref.forwardedRef,
|
|
13
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
14
|
+
var _useState = useState(new Array(numberOfInputs).fill('')),
|
|
15
|
+
inputValues = _useState[0],
|
|
16
|
+
setInputValues = _useState[1];
|
|
17
|
+
var _useState2 = useState(0),
|
|
18
|
+
currentIndex = _useState2[0],
|
|
19
|
+
setCurrentIndex = _useState2[1];
|
|
20
|
+
var inputArray = new Array(numberOfInputs).fill('');
|
|
21
|
+
var onChangeRef = useRef(null);
|
|
22
|
+
onChangeRef.current = onChange;
|
|
23
|
+
useEffect(function () {
|
|
24
|
+
if (inputValues.some(function (v) {
|
|
25
|
+
return !Number.isInteger(v);
|
|
26
|
+
})) {
|
|
27
|
+
onChangeRef.current == null ? void 0 : onChangeRef.current(null);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
onChangeRef.current == null ? void 0 : onChangeRef.current(inputValues.join(''));
|
|
31
|
+
}, [inputValues]);
|
|
32
|
+
var handleOnChange = function handleOnChange(value, index) {
|
|
33
|
+
if (!Number.isInteger(value)) {
|
|
34
|
+
var _newInputValues = [].concat(inputValues);
|
|
35
|
+
_newInputValues[index] = '';
|
|
36
|
+
setInputValues(_newInputValues);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var newInputValues = [].concat(inputValues);
|
|
40
|
+
newInputValues[index] = value;
|
|
41
|
+
setInputValues(newInputValues);
|
|
42
|
+
var nextInputIndex = index + 1;
|
|
43
|
+
if (nextInputIndex <= numberOfInputs - 1) {
|
|
44
|
+
setCurrentIndex(nextInputIndex);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var handlePaste = function handlePaste(event) {
|
|
48
|
+
var pastedData = event.clipboardData.getData('text') || '';
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
var pastedDataArray = pastedData.split('');
|
|
51
|
+
if (pastedDataArray.length === 0) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
var newValues = new Array(numberOfInputs).fill('');
|
|
55
|
+
for (var i = 0; i < numberOfInputs; i++) {
|
|
56
|
+
var currentValue = i >= pastedDataArray.length ? null : pastedDataArray[i];
|
|
57
|
+
var currentValueAsNumber = Number(currentValue);
|
|
58
|
+
if (Number.isNaN(currentValueAsNumber)) {
|
|
59
|
+
console.warn(currentValue + " is not a number, paste is skipped");
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
newValues[i] = currentValueAsNumber;
|
|
63
|
+
}
|
|
64
|
+
setInputValues(newValues);
|
|
65
|
+
setCurrentIndex(numberOfInputs - 1);
|
|
66
|
+
};
|
|
67
|
+
return /*#__PURE__*/React.createElement(StyledInputsContainer, {
|
|
68
|
+
className: "authentication-inputs-container",
|
|
69
|
+
onPaste: handlePaste,
|
|
70
|
+
ref: forwardedRef
|
|
71
|
+
}, inputArray.map(function (_value, index) {
|
|
72
|
+
return /*#__PURE__*/React.createElement(AuthenticationInputSingle, _extends({
|
|
73
|
+
key: index,
|
|
74
|
+
className: "authentication-input",
|
|
75
|
+
index: index,
|
|
76
|
+
shouldFocus: currentIndex === index,
|
|
77
|
+
isLast: index === numberOfInputs - 1,
|
|
78
|
+
onChange: handleOnChange,
|
|
79
|
+
value: inputValues[index],
|
|
80
|
+
error: error,
|
|
81
|
+
onPaste: handlePaste,
|
|
82
|
+
onIndexChanged: function onIndexChanged(index) {
|
|
83
|
+
if (index >= numberOfInputs || index < 0) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
setCurrentIndex(index);
|
|
87
|
+
}
|
|
88
|
+
}, rest));
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
91
|
+
var forwardRef = function forwardRef(props, ref) {
|
|
92
|
+
return /*#__PURE__*/React.createElement(AuthenticationInputComponent, _extends({}, props, {
|
|
93
|
+
forwardedRef: ref
|
|
94
|
+
}));
|
|
95
|
+
};
|
|
96
|
+
forwardRef.displayName = AuthenticationInputComponent.name;
|
|
97
|
+
export var AuthenticationInput = /*#__PURE__*/React.forwardRef(forwardRef);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface AuthenticationInputSingleProps extends Omit<React.HTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
3
|
+
index: number;
|
|
4
|
+
value: number | '';
|
|
5
|
+
shouldFocus?: boolean;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
isLast?: boolean;
|
|
9
|
+
onIndexChanged?: (index: number) => void;
|
|
10
|
+
onChange: (value: number | '', index: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const AuthenticationInputSingle: ({ index, onChange, value, shouldFocus, isLast, onIndexChanged, ...rest }: AuthenticationInputSingleProps) => JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["index", "onChange", "value", "shouldFocus", "isLast", "onIndexChanged"];
|
|
4
|
+
import React, { useEffect, useRef } from 'react';
|
|
5
|
+
import { NumberInput } from '../NumberInput';
|
|
6
|
+
export var AuthenticationInputSingle = function AuthenticationInputSingle(_ref) {
|
|
7
|
+
var index = _ref.index,
|
|
8
|
+
_onChange = _ref.onChange,
|
|
9
|
+
value = _ref.value,
|
|
10
|
+
shouldFocus = _ref.shouldFocus,
|
|
11
|
+
isLast = _ref.isLast,
|
|
12
|
+
onIndexChanged = _ref.onIndexChanged,
|
|
13
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
14
|
+
var ref = useRef(null);
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
if (shouldFocus) {
|
|
17
|
+
var _ref$current, _ref$current2;
|
|
18
|
+
ref == null ? void 0 : (_ref$current = ref.current) == null ? void 0 : _ref$current.focus();
|
|
19
|
+
ref == null ? void 0 : (_ref$current2 = ref.current) == null ? void 0 : _ref$current2.select();
|
|
20
|
+
}
|
|
21
|
+
}, [shouldFocus]);
|
|
22
|
+
return /*#__PURE__*/React.createElement(NumberInput, _extends({}, rest, {
|
|
23
|
+
maxLength: 1,
|
|
24
|
+
onFocus: function onFocus(e) {
|
|
25
|
+
e.currentTarget.select();
|
|
26
|
+
onIndexChanged == null ? void 0 : onIndexChanged(index);
|
|
27
|
+
},
|
|
28
|
+
inputRef: ref,
|
|
29
|
+
value: value,
|
|
30
|
+
onChange: function onChange(e) {
|
|
31
|
+
var currentValue = e.currentTarget.valueAsNumber;
|
|
32
|
+
_onChange(currentValue, index);
|
|
33
|
+
if (isLast && currentValue) {
|
|
34
|
+
var _ref$current3;
|
|
35
|
+
ref == null ? void 0 : (_ref$current3 = ref.current) == null ? void 0 : _ref$current3.blur();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
onKeyDown: function onKeyDown(e) {
|
|
39
|
+
var allowedKeys = ['Backspace', 'Delete', ' ', 'Tab', 'Enter'];
|
|
40
|
+
if (allowedKeys.includes(e.key) || e.metaKey || e.ctrlKey) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
var reg = new RegExp('^[0-9]$');
|
|
44
|
+
if (!reg.test(e.key)) {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
onKeyUp: function onKeyUp(e) {
|
|
49
|
+
if (e.key === 'Backspace') {
|
|
50
|
+
onIndexChanged(index - 1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledInputsContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { space8 } from '../utilities/spacing';
|
|
3
|
+
export var StyledInputsContainer = styled.div.withConfig({
|
|
4
|
+
displayName: "AuthenticationInputStyle__StyledInputsContainer",
|
|
5
|
+
componentId: "sc-1bj7ddw-0"
|
|
6
|
+
})(["display:flex;gap:", ";width:fit-content;.authentication-input{width:36px;height:36px;}"], space8);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AuthenticationInput';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AuthenticationInput';
|
|
@@ -3,5 +3,6 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
3
3
|
error?: boolean;
|
|
4
4
|
prefix?: React.ReactNode;
|
|
5
5
|
suffix?: React.ReactNode;
|
|
6
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
6
7
|
}
|
|
7
8
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
package/es/@next/Input/Input.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["error", "disabled", "prefix", "suffix"];
|
|
3
|
+
var _excluded = ["error", "disabled", "prefix", "suffix", "inputRef"];
|
|
4
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) {
|
|
@@ -8,6 +8,7 @@ export var Input = /*#__PURE__*/React.forwardRef(function Input(_ref, ref) {
|
|
|
8
8
|
disabled = _ref.disabled,
|
|
9
9
|
prefix = _ref.prefix,
|
|
10
10
|
suffix = _ref.suffix,
|
|
11
|
+
inputRef = _ref.inputRef,
|
|
11
12
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
12
13
|
var hasPrefix = !!prefix;
|
|
13
14
|
var hasSuffix = !!suffix;
|
|
@@ -50,6 +51,7 @@ export var Input = /*#__PURE__*/React.forwardRef(function Input(_ref, ref) {
|
|
|
50
51
|
prefixWidth: prefixWidth,
|
|
51
52
|
suffixWidth: suffixWidth
|
|
52
53
|
}, /*#__PURE__*/React.createElement(Prefix, null), /*#__PURE__*/React.createElement(StyledInput, _extends({
|
|
54
|
+
ref: inputRef,
|
|
53
55
|
disabled: disabled
|
|
54
56
|
}, props)), /*#__PURE__*/React.createElement(Suffix, null));
|
|
55
57
|
});
|
|
@@ -7,7 +7,7 @@ import { borderRadius4 } from '../utilities/borderRadius';
|
|
|
7
7
|
export var StyledContainer = styled.div.withConfig({
|
|
8
8
|
displayName: "InputStyle__StyledContainer",
|
|
9
9
|
componentId: "sc-15z2mnd-0"
|
|
10
|
-
})(["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) {
|
|
10
|
+
})(["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:", ";cursor:not-allowed;}&[data-disabled='true'] input::placeholder{color:", ";}&[data-disabled='true'] svg{fill:", ";}&[data-disabled='true'] div{color:", ";}"], function (props) {
|
|
11
11
|
return props.prefixWidth;
|
|
12
12
|
}, function (props) {
|
|
13
13
|
return props.suffixWidth;
|
package/es/@next/Tag/Tag.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { IconNames } from '../Icon/icons/icons';
|
|
2
3
|
export interface TagProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
children?: React.ReactNode;
|
|
4
5
|
value?: string;
|
|
5
6
|
onRemove?: (() => void) | null | void;
|
|
6
7
|
textColor?: string;
|
|
7
8
|
disabled?: boolean;
|
|
9
|
+
contentType?: 'neutral' | 'success' | 'warning';
|
|
10
|
+
iconName?: IconNames;
|
|
8
11
|
}
|
|
9
12
|
export declare type TagRemoveContainerProps = React.HTMLAttributes<HTMLDivElement>;
|
|
10
13
|
export declare type TagContentProps = React.HTMLAttributes<HTMLSpanElement> & TagProps;
|
package/es/@next/Tag/Tag.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["children", "onRemove", "value", "textColor", "onClick", "disabled"];
|
|
3
|
+
var _excluded = ["children", "onRemove", "value", "textColor", "onClick", "disabled", "contentType", "iconName"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { Icon } from '../Icon';
|
|
6
6
|
import { Typography } from '../Typography';
|
|
7
7
|
import { Neutral } from '../utilities/colors';
|
|
8
|
-
import { TagContentStyle, TagIconWrapper, TagRemoveContainerStyle, TagStyle } from './TagStyle';
|
|
8
|
+
import { TagContentStyle, TagIconWrapper, TagRemoveContainerStyle, TagStyle, TagContentWrapper } from './TagStyle';
|
|
9
9
|
export var Tag = /*#__PURE__*/React.forwardRef(function Tag(_ref, ref) {
|
|
10
10
|
var children = _ref.children,
|
|
11
11
|
onRemove = _ref.onRemove,
|
|
@@ -13,6 +13,9 @@ export var Tag = /*#__PURE__*/React.forwardRef(function Tag(_ref, ref) {
|
|
|
13
13
|
textColor = _ref.textColor,
|
|
14
14
|
onClick = _ref.onClick,
|
|
15
15
|
disabled = _ref.disabled,
|
|
16
|
+
_ref$contentType = _ref.contentType,
|
|
17
|
+
contentType = _ref$contentType === void 0 ? 'neutral' : _ref$contentType,
|
|
18
|
+
iconName = _ref.iconName,
|
|
16
19
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
17
20
|
var handleTextColor = function handleTextColor() {
|
|
18
21
|
if (disabled) {
|
|
@@ -34,8 +37,8 @@ export var Tag = /*#__PURE__*/React.forwardRef(function Tag(_ref, ref) {
|
|
|
34
37
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
35
38
|
name: "ri-close",
|
|
36
39
|
fill: Neutral.B40,
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
onClick: onRemove,
|
|
41
|
+
className: "remove-button-icon"
|
|
39
42
|
})));
|
|
40
43
|
return /*#__PURE__*/React.createElement(TagStyle, _extends({
|
|
41
44
|
ref: ref
|
|
@@ -43,10 +46,16 @@ export var Tag = /*#__PURE__*/React.forwardRef(function Tag(_ref, ref) {
|
|
|
43
46
|
value: value,
|
|
44
47
|
onClick: !disabled && onClick,
|
|
45
48
|
"data-clickable": !!onClick,
|
|
49
|
+
"data-removeable": !!onRemove,
|
|
50
|
+
"data-content-type": contentType,
|
|
46
51
|
role: !!onClick ? 'button' : undefined,
|
|
47
52
|
"data-disabled": disabled,
|
|
48
53
|
as: !!onClick ? 'button' : 'div'
|
|
49
54
|
}), /*#__PURE__*/React.createElement(TagContentStyle, {
|
|
50
55
|
"data-removeable": !!onRemove
|
|
51
|
-
},
|
|
56
|
+
}, iconName && /*#__PURE__*/React.createElement(Icon, {
|
|
57
|
+
name: iconName,
|
|
58
|
+
fill: Neutral.B40,
|
|
59
|
+
height: 20
|
|
60
|
+
}), /*#__PURE__*/React.createElement(TagContentWrapper, null, content)), removeButton);
|
|
52
61
|
});
|
|
@@ -2,6 +2,7 @@ import { Meta } from '@storybook/react';
|
|
|
2
2
|
declare const _default: Meta<import("@storybook/react").Args>;
|
|
3
3
|
export default _default;
|
|
4
4
|
export declare const Default: any;
|
|
5
|
+
export declare const WithIcon: any;
|
|
5
6
|
export declare const Removeable: any;
|
|
6
7
|
export declare const Clickable: any;
|
|
7
8
|
export declare const ClickableDisabled: any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TagProps, TagRemoveContainerProps } from './Tag';
|
|
3
3
|
export declare const TagContentStyle: import("styled-components").StyledComponent<"span", any, import("react").HTMLAttributes<HTMLSpanElement> & TagProps, never>;
|
|
4
|
+
export declare const TagContentWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
5
|
export declare const TagRemoveContainerStyle: import("styled-components").StyledComponent<"div", any, TagRemoveContainerProps, never>;
|
|
5
6
|
export declare const TagIconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
7
|
export declare const TagStyle: import("styled-components").StyledComponent<"div", any, TagProps, never>;
|
package/es/@next/Tag/TagStyle.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { Breakpoints } from '..';
|
|
3
3
|
import { borderRadius4, borderRadiusHalf } from '../utilities/borderRadius';
|
|
4
|
-
import { Blue, Neutral } from '../utilities/colors';
|
|
5
|
-
import { space4
|
|
4
|
+
import { Blue, Green, Orange, Neutral } from '../utilities/colors';
|
|
5
|
+
import { space4 } from '../utilities/spacing';
|
|
6
6
|
export var TagContentStyle = styled.span.withConfig({
|
|
7
7
|
displayName: "TagStyle__TagContentStyle",
|
|
8
8
|
componentId: "sc-r1wv7a-0"
|
|
9
|
-
})(["padding:", "
|
|
9
|
+
})(["display:inline-flex;padding:", ";white-space:nowrap;transform:translateY(1px);&[data-removeable='true']{padding-right:0;}"], space4);
|
|
10
|
+
export var TagContentWrapper = styled.div.withConfig({
|
|
11
|
+
displayName: "TagStyle__TagContentWrapper",
|
|
12
|
+
componentId: "sc-r1wv7a-1"
|
|
13
|
+
})(["padding:0 ", ";"], space4);
|
|
10
14
|
export var TagRemoveContainerStyle = styled.div.withConfig({
|
|
11
15
|
displayName: "TagStyle__TagRemoveContainerStyle",
|
|
12
|
-
componentId: "sc-r1wv7a-
|
|
13
|
-
})(["padding:", ";display:flex;"], space4);
|
|
16
|
+
componentId: "sc-r1wv7a-2"
|
|
17
|
+
})(["padding:", " ", " ", " 0;display:flex;.remove-button-icon{svg{width:20px;height:20px;}}@media (max-width:", "){.remove-button-icon{svg{width:18px;height:18px;}}}"], space4, space4, space4, Breakpoints.large);
|
|
14
18
|
export var TagIconWrapper = styled.div.withConfig({
|
|
15
19
|
displayName: "TagStyle__TagIconWrapper",
|
|
16
|
-
componentId: "sc-r1wv7a-
|
|
20
|
+
componentId: "sc-r1wv7a-3"
|
|
17
21
|
})(["display:flex;justify-content:center;align-items:center;&:focus-visible{margin:-2px;outline:none;border:2px solid ", ";border-radius:", ";}"], Blue.S100, borderRadius4);
|
|
18
22
|
export var TagStyle = styled.div.withConfig({
|
|
19
23
|
displayName: "TagStyle",
|
|
20
|
-
componentId: "sc-r1wv7a-
|
|
21
|
-
})(["display:inline-flex;align-items:center;background-color:", ";border:0;border-radius:", ";width:fit-content;padding:0
|
|
24
|
+
componentId: "sc-r1wv7a-4"
|
|
25
|
+
})(["display:inline-flex;align-items:center;background-color:", ";border:0;border-radius:", ";width:fit-content;padding:0;&:not([data-removeable='true']):not([data-clickable='true']){&[data-content-type='neutral']{background-color:", ";}&[data-content-type='success']{background-color:", ";}&[data-content-type='warning']{background-color:", ";}}&[data-clickable='true']{cursor:pointer;background-color:", ";&:hover{outline:1px solid ", "E6;}&:active{outline:1px solid ", ";}&:focus-visible{outline:1px solid ", ";box-shadow:0px 0px 0px 2px ", ",0px 0px 0px 4px ", ";}&[data-disabled='true']{cursor:not-allowed;outline:none;background-color:", ";&:focus-visible{outline:none;box-shadow:none;}}}& svg{padding:0;width:20px;height:20px;}& svg:hover{cursor:pointer;background-color:", ";border-radius:", ";}& svg:active{cursor:pointer;background-color:", ";fill:", ";border-radius:", ";}@media (max-width:", "){& svg{width:18px;height:18px;}}"], Blue.S08, borderRadius4, Neutral.B95, Green.B89, Orange.S21, Blue.S08, Blue.S100, Blue.S100, Blue.S100, Neutral.B100, Blue.S54, Neutral.B95, Neutral.B95, borderRadiusHalf, Neutral.B40, Neutral.B100, borderRadiusHalf, Breakpoints.large);
|
package/es/@next/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type { ActionListProps, Item as ActionListItem, Section as ActionListSect
|
|
|
8
8
|
export { ActionList } from './ActionList';
|
|
9
9
|
export type { AlertContextProps, AlertProps } from './Alert';
|
|
10
10
|
export { Alert, AlertContext, AlertProvider, AlertWithProvider, useAlert, } from './Alert';
|
|
11
|
+
export { AuthenticationInput } from './AuthenticationInput';
|
|
12
|
+
export type { AuthenticationInputProps } from './AuthenticationInput';
|
|
11
13
|
export type { AvatarProps } from './Avatar';
|
|
12
14
|
export { Avatar } from './Avatar';
|
|
13
15
|
export type { BadgeProps } from './Badge';
|
package/es/@next/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import * as Fonts from './utilities/fonts';
|
|
|
7
7
|
import * as Spacing from './utilities/spacing';
|
|
8
8
|
export { ActionList } from './ActionList';
|
|
9
9
|
export { Alert, AlertContext, AlertProvider, AlertWithProvider, useAlert } from './Alert';
|
|
10
|
+
export { AuthenticationInput } from './AuthenticationInput';
|
|
10
11
|
export { Avatar } from './Avatar';
|
|
11
12
|
export { Badge } from './Badge';
|
|
12
13
|
export { Banner } from './Banner';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { RefObject } from 'react';
|
|
2
|
+
export interface AuthenticationInputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
3
|
+
numberOfInputs: number;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
error?: boolean;
|
|
6
|
+
forwardedRef?: RefObject<HTMLDivElement>;
|
|
7
|
+
/** will always return null when not all inputs are filled */
|
|
8
|
+
onChange?: (value: string | null) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const AuthenticationInput: React.ForwardRefExoticComponent<AuthenticationInputProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.AuthenticationInput = void 0;
|
|
6
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _AuthenticationInputStyle = require("./AuthenticationInputStyle");
|
|
10
|
+
var _AuthenticationInputSingle = require("./AuthenticationInputSingle");
|
|
11
|
+
var _excluded = ["numberOfInputs", "error", "onChange", "forwardedRef"];
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
var AuthenticationInputComponent = function AuthenticationInputComponent(_ref) {
|
|
15
|
+
var _ref$numberOfInputs = _ref.numberOfInputs,
|
|
16
|
+
numberOfInputs = _ref$numberOfInputs === void 0 ? 6 : _ref$numberOfInputs,
|
|
17
|
+
error = _ref.error,
|
|
18
|
+
onChange = _ref.onChange,
|
|
19
|
+
forwardedRef = _ref.forwardedRef,
|
|
20
|
+
rest = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
21
|
+
var _useState = (0, _react.useState)(new Array(numberOfInputs).fill('')),
|
|
22
|
+
inputValues = _useState[0],
|
|
23
|
+
setInputValues = _useState[1];
|
|
24
|
+
var _useState2 = (0, _react.useState)(0),
|
|
25
|
+
currentIndex = _useState2[0],
|
|
26
|
+
setCurrentIndex = _useState2[1];
|
|
27
|
+
var inputArray = new Array(numberOfInputs).fill('');
|
|
28
|
+
var onChangeRef = (0, _react.useRef)(null);
|
|
29
|
+
onChangeRef.current = onChange;
|
|
30
|
+
(0, _react.useEffect)(function () {
|
|
31
|
+
if (inputValues.some(function (v) {
|
|
32
|
+
return !Number.isInteger(v);
|
|
33
|
+
})) {
|
|
34
|
+
onChangeRef.current == null ? void 0 : onChangeRef.current(null);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
onChangeRef.current == null ? void 0 : onChangeRef.current(inputValues.join(''));
|
|
38
|
+
}, [inputValues]);
|
|
39
|
+
var handleOnChange = function handleOnChange(value, index) {
|
|
40
|
+
if (!Number.isInteger(value)) {
|
|
41
|
+
var _newInputValues = [].concat(inputValues);
|
|
42
|
+
_newInputValues[index] = '';
|
|
43
|
+
setInputValues(_newInputValues);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
var newInputValues = [].concat(inputValues);
|
|
47
|
+
newInputValues[index] = value;
|
|
48
|
+
setInputValues(newInputValues);
|
|
49
|
+
var nextInputIndex = index + 1;
|
|
50
|
+
if (nextInputIndex <= numberOfInputs - 1) {
|
|
51
|
+
setCurrentIndex(nextInputIndex);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var handlePaste = function handlePaste(event) {
|
|
55
|
+
var pastedData = event.clipboardData.getData('text') || '';
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
var pastedDataArray = pastedData.split('');
|
|
58
|
+
if (pastedDataArray.length === 0) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var newValues = new Array(numberOfInputs).fill('');
|
|
62
|
+
for (var i = 0; i < numberOfInputs; i++) {
|
|
63
|
+
var currentValue = i >= pastedDataArray.length ? null : pastedDataArray[i];
|
|
64
|
+
var currentValueAsNumber = Number(currentValue);
|
|
65
|
+
if (Number.isNaN(currentValueAsNumber)) {
|
|
66
|
+
console.warn(currentValue + " is not a number, paste is skipped");
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
newValues[i] = currentValueAsNumber;
|
|
70
|
+
}
|
|
71
|
+
setInputValues(newValues);
|
|
72
|
+
setCurrentIndex(numberOfInputs - 1);
|
|
73
|
+
};
|
|
74
|
+
return /*#__PURE__*/_react["default"].createElement(_AuthenticationInputStyle.StyledInputsContainer, {
|
|
75
|
+
className: "authentication-inputs-container",
|
|
76
|
+
onPaste: handlePaste,
|
|
77
|
+
ref: forwardedRef
|
|
78
|
+
}, inputArray.map(function (_value, index) {
|
|
79
|
+
return /*#__PURE__*/_react["default"].createElement(_AuthenticationInputSingle.AuthenticationInputSingle, (0, _extends2["default"])({
|
|
80
|
+
key: index,
|
|
81
|
+
className: "authentication-input",
|
|
82
|
+
index: index,
|
|
83
|
+
shouldFocus: currentIndex === index,
|
|
84
|
+
isLast: index === numberOfInputs - 1,
|
|
85
|
+
onChange: handleOnChange,
|
|
86
|
+
value: inputValues[index],
|
|
87
|
+
error: error,
|
|
88
|
+
onPaste: handlePaste,
|
|
89
|
+
onIndexChanged: function onIndexChanged(index) {
|
|
90
|
+
if (index >= numberOfInputs || index < 0) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
setCurrentIndex(index);
|
|
94
|
+
}
|
|
95
|
+
}, rest));
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
98
|
+
var forwardRef = function forwardRef(props, ref) {
|
|
99
|
+
return /*#__PURE__*/_react["default"].createElement(AuthenticationInputComponent, (0, _extends2["default"])({}, props, {
|
|
100
|
+
forwardedRef: ref
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
103
|
+
forwardRef.displayName = AuthenticationInputComponent.name;
|
|
104
|
+
var AuthenticationInput = /*#__PURE__*/_react["default"].forwardRef(forwardRef);
|
|
105
|
+
exports.AuthenticationInput = AuthenticationInput;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface AuthenticationInputSingleProps extends Omit<React.HTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
3
|
+
index: number;
|
|
4
|
+
value: number | '';
|
|
5
|
+
shouldFocus?: boolean;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
isLast?: boolean;
|
|
9
|
+
onIndexChanged?: (index: number) => void;
|
|
10
|
+
onChange: (value: number | '', index: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const AuthenticationInputSingle: ({ index, onChange, value, shouldFocus, isLast, onIndexChanged, ...rest }: AuthenticationInputSingleProps) => JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.AuthenticationInputSingle = void 0;
|
|
6
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _NumberInput = require("../NumberInput");
|
|
10
|
+
var _excluded = ["index", "onChange", "value", "shouldFocus", "isLast", "onIndexChanged"];
|
|
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; }
|
|
13
|
+
var AuthenticationInputSingle = function AuthenticationInputSingle(_ref) {
|
|
14
|
+
var index = _ref.index,
|
|
15
|
+
_onChange = _ref.onChange,
|
|
16
|
+
value = _ref.value,
|
|
17
|
+
shouldFocus = _ref.shouldFocus,
|
|
18
|
+
isLast = _ref.isLast,
|
|
19
|
+
onIndexChanged = _ref.onIndexChanged,
|
|
20
|
+
rest = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
21
|
+
var ref = (0, _react.useRef)(null);
|
|
22
|
+
(0, _react.useEffect)(function () {
|
|
23
|
+
if (shouldFocus) {
|
|
24
|
+
var _ref$current, _ref$current2;
|
|
25
|
+
ref == null ? void 0 : (_ref$current = ref.current) == null ? void 0 : _ref$current.focus();
|
|
26
|
+
ref == null ? void 0 : (_ref$current2 = ref.current) == null ? void 0 : _ref$current2.select();
|
|
27
|
+
}
|
|
28
|
+
}, [shouldFocus]);
|
|
29
|
+
return /*#__PURE__*/_react["default"].createElement(_NumberInput.NumberInput, (0, _extends2["default"])({}, rest, {
|
|
30
|
+
maxLength: 1,
|
|
31
|
+
onFocus: function onFocus(e) {
|
|
32
|
+
e.currentTarget.select();
|
|
33
|
+
onIndexChanged == null ? void 0 : onIndexChanged(index);
|
|
34
|
+
},
|
|
35
|
+
inputRef: ref,
|
|
36
|
+
value: value,
|
|
37
|
+
onChange: function onChange(e) {
|
|
38
|
+
var currentValue = e.currentTarget.valueAsNumber;
|
|
39
|
+
_onChange(currentValue, index);
|
|
40
|
+
if (isLast && currentValue) {
|
|
41
|
+
var _ref$current3;
|
|
42
|
+
ref == null ? void 0 : (_ref$current3 = ref.current) == null ? void 0 : _ref$current3.blur();
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
onKeyDown: function onKeyDown(e) {
|
|
46
|
+
var allowedKeys = ['Backspace', 'Delete', ' ', 'Tab', 'Enter'];
|
|
47
|
+
if (allowedKeys.includes(e.key) || e.metaKey || e.ctrlKey) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
var reg = new RegExp('^[0-9]$');
|
|
51
|
+
if (!reg.test(e.key)) {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
onKeyUp: function onKeyUp(e) {
|
|
56
|
+
if (e.key === 'Backspace') {
|
|
57
|
+
onIndexChanged(index - 1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
exports.AuthenticationInputSingle = AuthenticationInputSingle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledInputsContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.StyledInputsContainer = void 0;
|
|
6
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
7
|
+
var _spacing = require("../utilities/spacing");
|
|
8
|
+
var StyledInputsContainer = _styledComponents["default"].div.withConfig({
|
|
9
|
+
displayName: "AuthenticationInputStyle__StyledInputsContainer",
|
|
10
|
+
componentId: "sc-1bj7ddw-0"
|
|
11
|
+
})(["display:flex;gap:", ";width:fit-content;.authentication-input{width:36px;height:36px;}"], _spacing.space8);
|
|
12
|
+
exports.StyledInputsContainer = StyledInputsContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AuthenticationInput';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
var _AuthenticationInput = require("./AuthenticationInput");
|
|
5
|
+
Object.keys(_AuthenticationInput).forEach(function (key) {
|
|
6
|
+
if (key === "default" || key === "__esModule") return;
|
|
7
|
+
if (key in exports && exports[key] === _AuthenticationInput[key]) return;
|
|
8
|
+
exports[key] = _AuthenticationInput[key];
|
|
9
|
+
});
|
|
@@ -3,5 +3,6 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
3
3
|
error?: boolean;
|
|
4
4
|
prefix?: React.ReactNode;
|
|
5
5
|
suffix?: React.ReactNode;
|
|
6
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
6
7
|
}
|
|
7
8
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
package/lib/@next/Input/Input.js
CHANGED
|
@@ -7,7 +7,7 @@ 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
9
|
var _InputStyle = require("./InputStyle");
|
|
10
|
-
var _excluded = ["error", "disabled", "prefix", "suffix"];
|
|
10
|
+
var _excluded = ["error", "disabled", "prefix", "suffix", "inputRef"];
|
|
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 Input = /*#__PURE__*/_react["default"].forwardRef(function Input(_ref, ref) {
|
|
@@ -15,6 +15,7 @@ var Input = /*#__PURE__*/_react["default"].forwardRef(function Input(_ref, ref)
|
|
|
15
15
|
disabled = _ref.disabled,
|
|
16
16
|
prefix = _ref.prefix,
|
|
17
17
|
suffix = _ref.suffix,
|
|
18
|
+
inputRef = _ref.inputRef,
|
|
18
19
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
19
20
|
var hasPrefix = !!prefix;
|
|
20
21
|
var hasSuffix = !!suffix;
|
|
@@ -57,6 +58,7 @@ var Input = /*#__PURE__*/_react["default"].forwardRef(function Input(_ref, ref)
|
|
|
57
58
|
prefixWidth: prefixWidth,
|
|
58
59
|
suffixWidth: suffixWidth
|
|
59
60
|
}, /*#__PURE__*/_react["default"].createElement(Prefix, null), /*#__PURE__*/_react["default"].createElement(_InputStyle.StyledInput, (0, _extends2["default"])({
|
|
61
|
+
ref: inputRef,
|
|
60
62
|
disabled: disabled
|
|
61
63
|
}, props)), /*#__PURE__*/_react["default"].createElement(Suffix, null));
|
|
62
64
|
});
|
|
@@ -14,7 +14,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
14
14
|
var StyledContainer = _styledComponents["default"].div.withConfig({
|
|
15
15
|
displayName: "InputStyle__StyledContainer",
|
|
16
16
|
componentId: "sc-15z2mnd-0"
|
|
17
|
-
})(["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) {
|
|
17
|
+
})(["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:", ";cursor:not-allowed;}&[data-disabled='true'] input::placeholder{color:", ";}&[data-disabled='true'] svg{fill:", ";}&[data-disabled='true'] div{color:", ";}"], function (props) {
|
|
18
18
|
return props.prefixWidth;
|
|
19
19
|
}, function (props) {
|
|
20
20
|
return props.suffixWidth;
|
package/lib/@next/Tag/Tag.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { IconNames } from '../Icon/icons/icons';
|
|
2
3
|
export interface TagProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
children?: React.ReactNode;
|
|
4
5
|
value?: string;
|
|
5
6
|
onRemove?: (() => void) | null | void;
|
|
6
7
|
textColor?: string;
|
|
7
8
|
disabled?: boolean;
|
|
9
|
+
contentType?: 'neutral' | 'success' | 'warning';
|
|
10
|
+
iconName?: IconNames;
|
|
8
11
|
}
|
|
9
12
|
export declare type TagRemoveContainerProps = React.HTMLAttributes<HTMLDivElement>;
|
|
10
13
|
export declare type TagContentProps = React.HTMLAttributes<HTMLSpanElement> & TagProps;
|
package/lib/@next/Tag/Tag.js
CHANGED
|
@@ -10,7 +10,7 @@ var _Icon = require("../Icon");
|
|
|
10
10
|
var _Typography = require("../Typography");
|
|
11
11
|
var _colors = require("../utilities/colors");
|
|
12
12
|
var _TagStyle = require("./TagStyle");
|
|
13
|
-
var _excluded = ["children", "onRemove", "value", "textColor", "onClick", "disabled"];
|
|
13
|
+
var _excluded = ["children", "onRemove", "value", "textColor", "onClick", "disabled", "contentType", "iconName"];
|
|
14
14
|
var Tag = /*#__PURE__*/_react["default"].forwardRef(function Tag(_ref, ref) {
|
|
15
15
|
var children = _ref.children,
|
|
16
16
|
onRemove = _ref.onRemove,
|
|
@@ -18,6 +18,9 @@ var Tag = /*#__PURE__*/_react["default"].forwardRef(function Tag(_ref, ref) {
|
|
|
18
18
|
textColor = _ref.textColor,
|
|
19
19
|
onClick = _ref.onClick,
|
|
20
20
|
disabled = _ref.disabled,
|
|
21
|
+
_ref$contentType = _ref.contentType,
|
|
22
|
+
contentType = _ref$contentType === void 0 ? 'neutral' : _ref$contentType,
|
|
23
|
+
iconName = _ref.iconName,
|
|
21
24
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
22
25
|
var handleTextColor = function handleTextColor() {
|
|
23
26
|
if (disabled) {
|
|
@@ -39,8 +42,8 @@ var Tag = /*#__PURE__*/_react["default"].forwardRef(function Tag(_ref, ref) {
|
|
|
39
42
|
}, /*#__PURE__*/_react["default"].createElement(_Icon.Icon, {
|
|
40
43
|
name: "ri-close",
|
|
41
44
|
fill: _colors.Neutral.B40,
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
onClick: onRemove,
|
|
46
|
+
className: "remove-button-icon"
|
|
44
47
|
})));
|
|
45
48
|
return /*#__PURE__*/_react["default"].createElement(_TagStyle.TagStyle, (0, _extends2["default"])({
|
|
46
49
|
ref: ref
|
|
@@ -48,11 +51,17 @@ var Tag = /*#__PURE__*/_react["default"].forwardRef(function Tag(_ref, ref) {
|
|
|
48
51
|
value: value,
|
|
49
52
|
onClick: !disabled && onClick,
|
|
50
53
|
"data-clickable": !!onClick,
|
|
54
|
+
"data-removeable": !!onRemove,
|
|
55
|
+
"data-content-type": contentType,
|
|
51
56
|
role: !!onClick ? 'button' : undefined,
|
|
52
57
|
"data-disabled": disabled,
|
|
53
58
|
as: !!onClick ? 'button' : 'div'
|
|
54
59
|
}), /*#__PURE__*/_react["default"].createElement(_TagStyle.TagContentStyle, {
|
|
55
60
|
"data-removeable": !!onRemove
|
|
56
|
-
},
|
|
61
|
+
}, iconName && /*#__PURE__*/_react["default"].createElement(_Icon.Icon, {
|
|
62
|
+
name: iconName,
|
|
63
|
+
fill: _colors.Neutral.B40,
|
|
64
|
+
height: 20
|
|
65
|
+
}), /*#__PURE__*/_react["default"].createElement(_TagStyle.TagContentWrapper, null, content)), removeButton);
|
|
57
66
|
});
|
|
58
67
|
exports.Tag = Tag;
|
|
@@ -2,6 +2,7 @@ import { Meta } from '@storybook/react';
|
|
|
2
2
|
declare const _default: Meta<import("@storybook/react").Args>;
|
|
3
3
|
export default _default;
|
|
4
4
|
export declare const Default: any;
|
|
5
|
+
export declare const WithIcon: any;
|
|
5
6
|
export declare const Removeable: any;
|
|
6
7
|
export declare const Clickable: any;
|
|
7
8
|
export declare const ClickableDisabled: any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TagProps, TagRemoveContainerProps } from './Tag';
|
|
3
3
|
export declare const TagContentStyle: import("styled-components").StyledComponent<"span", any, import("react").HTMLAttributes<HTMLSpanElement> & TagProps, never>;
|
|
4
|
+
export declare const TagContentWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
5
|
export declare const TagRemoveContainerStyle: import("styled-components").StyledComponent<"div", any, TagRemoveContainerProps, never>;
|
|
5
6
|
export declare const TagIconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
7
|
export declare const TagStyle: import("styled-components").StyledComponent<"div", any, TagProps, never>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.TagStyle = exports.TagRemoveContainerStyle = exports.TagIconWrapper = exports.TagContentStyle = void 0;
|
|
5
|
+
exports.TagStyle = exports.TagRemoveContainerStyle = exports.TagIconWrapper = exports.TagContentWrapper = exports.TagContentStyle = void 0;
|
|
6
6
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
7
7
|
var _ = require("..");
|
|
8
8
|
var _borderRadius = require("../utilities/borderRadius");
|
|
@@ -11,20 +11,25 @@ var _spacing = require("../utilities/spacing");
|
|
|
11
11
|
var TagContentStyle = _styledComponents["default"].span.withConfig({
|
|
12
12
|
displayName: "TagStyle__TagContentStyle",
|
|
13
13
|
componentId: "sc-r1wv7a-0"
|
|
14
|
-
})(["padding:", "
|
|
14
|
+
})(["display:inline-flex;padding:", ";white-space:nowrap;transform:translateY(1px);&[data-removeable='true']{padding-right:0;}"], _spacing.space4);
|
|
15
15
|
exports.TagContentStyle = TagContentStyle;
|
|
16
|
+
var TagContentWrapper = _styledComponents["default"].div.withConfig({
|
|
17
|
+
displayName: "TagStyle__TagContentWrapper",
|
|
18
|
+
componentId: "sc-r1wv7a-1"
|
|
19
|
+
})(["padding:0 ", ";"], _spacing.space4);
|
|
20
|
+
exports.TagContentWrapper = TagContentWrapper;
|
|
16
21
|
var TagRemoveContainerStyle = _styledComponents["default"].div.withConfig({
|
|
17
22
|
displayName: "TagStyle__TagRemoveContainerStyle",
|
|
18
|
-
componentId: "sc-r1wv7a-
|
|
19
|
-
})(["padding:", ";display:flex;"], _spacing.space4);
|
|
23
|
+
componentId: "sc-r1wv7a-2"
|
|
24
|
+
})(["padding:", " ", " ", " 0;display:flex;.remove-button-icon{svg{width:20px;height:20px;}}@media (max-width:", "){.remove-button-icon{svg{width:18px;height:18px;}}}"], _spacing.space4, _spacing.space4, _spacing.space4, _.Breakpoints.large);
|
|
20
25
|
exports.TagRemoveContainerStyle = TagRemoveContainerStyle;
|
|
21
26
|
var TagIconWrapper = _styledComponents["default"].div.withConfig({
|
|
22
27
|
displayName: "TagStyle__TagIconWrapper",
|
|
23
|
-
componentId: "sc-r1wv7a-
|
|
28
|
+
componentId: "sc-r1wv7a-3"
|
|
24
29
|
})(["display:flex;justify-content:center;align-items:center;&:focus-visible{margin:-2px;outline:none;border:2px solid ", ";border-radius:", ";}"], _colors.Blue.S100, _borderRadius.borderRadius4);
|
|
25
30
|
exports.TagIconWrapper = TagIconWrapper;
|
|
26
31
|
var TagStyle = _styledComponents["default"].div.withConfig({
|
|
27
32
|
displayName: "TagStyle",
|
|
28
|
-
componentId: "sc-r1wv7a-
|
|
29
|
-
})(["display:inline-flex;align-items:center;background-color:", ";border:0;border-radius:", ";width:fit-content;padding:0
|
|
33
|
+
componentId: "sc-r1wv7a-4"
|
|
34
|
+
})(["display:inline-flex;align-items:center;background-color:", ";border:0;border-radius:", ";width:fit-content;padding:0;&:not([data-removeable='true']):not([data-clickable='true']){&[data-content-type='neutral']{background-color:", ";}&[data-content-type='success']{background-color:", ";}&[data-content-type='warning']{background-color:", ";}}&[data-clickable='true']{cursor:pointer;background-color:", ";&:hover{outline:1px solid ", "E6;}&:active{outline:1px solid ", ";}&:focus-visible{outline:1px solid ", ";box-shadow:0px 0px 0px 2px ", ",0px 0px 0px 4px ", ";}&[data-disabled='true']{cursor:not-allowed;outline:none;background-color:", ";&:focus-visible{outline:none;box-shadow:none;}}}& svg{padding:0;width:20px;height:20px;}& svg:hover{cursor:pointer;background-color:", ";border-radius:", ";}& svg:active{cursor:pointer;background-color:", ";fill:", ";border-radius:", ";}@media (max-width:", "){& svg{width:18px;height:18px;}}"], _colors.Blue.S08, _borderRadius.borderRadius4, _colors.Neutral.B95, _colors.Green.B89, _colors.Orange.S21, _colors.Blue.S08, _colors.Blue.S100, _colors.Blue.S100, _colors.Blue.S100, _colors.Neutral.B100, _colors.Blue.S54, _colors.Neutral.B95, _colors.Neutral.B95, _borderRadius.borderRadiusHalf, _colors.Neutral.B40, _colors.Neutral.B100, _borderRadius.borderRadiusHalf, _.Breakpoints.large);
|
|
30
35
|
exports.TagStyle = TagStyle;
|
package/lib/@next/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type { ActionListProps, Item as ActionListItem, Section as ActionListSect
|
|
|
8
8
|
export { ActionList } from './ActionList';
|
|
9
9
|
export type { AlertContextProps, AlertProps } from './Alert';
|
|
10
10
|
export { Alert, AlertContext, AlertProvider, AlertWithProvider, useAlert, } from './Alert';
|
|
11
|
+
export { AuthenticationInput } from './AuthenticationInput';
|
|
12
|
+
export type { AuthenticationInputProps } from './AuthenticationInput';
|
|
11
13
|
export type { AvatarProps } from './Avatar';
|
|
12
14
|
export { Avatar } from './Avatar';
|
|
13
15
|
export type { BadgeProps } from './Badge';
|
package/lib/@next/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.useModal = exports.useIndexResourceState = exports.useAlert = exports.Upload = exports.Typography = exports.Tooltip = exports.TextInput = exports.TextArea = exports.Tag = exports.Tabs = exports.Tab = exports.Switch = exports.Spinner = exports.Spacing = exports.SkeletonText = exports.SkeletonImageSquare = exports.SkeletonImageCircle = exports.SimplePagination = exports.SideSheet = exports.Select = exports.RadioButton = exports.PrimaryButton = exports.Portal = exports.Popover = exports.PasswordInput = exports.Pagination = exports.OutlineMonochromeButton = exports.OutlineButton = exports.NumberInput = exports.ModalWithProvider = exports.ModalProvider = exports.ModalContext = exports.Modal = exports.Menu = exports.Link = exports.InlineError = exports.IndexTable = exports.IconPagination = exports.Icon = exports.Fonts = exports.EmptyState = exports.DropShadow = exports.Divider = exports.DestructiveButton = exports.DataTable = exports.CurrencyInput = exports.Combobox = exports.Colors = exports.Checkbox = exports.Carousel = exports.Card = exports.ButtonGroup = exports.Button = exports.Breakpoints = exports.BorderRadius = exports.Bar = exports.Banner = exports.Badge = exports.Avatar = exports.AlertWithProvider = exports.AlertProvider = exports.AlertContext = exports.Alert = exports.ActionList = void 0;
|
|
4
|
+
exports.useModal = exports.useIndexResourceState = exports.useAlert = exports.Upload = exports.Typography = exports.Tooltip = exports.TextInput = exports.TextArea = exports.Tag = exports.Tabs = exports.Tab = exports.Switch = exports.Spinner = exports.Spacing = exports.SkeletonText = exports.SkeletonImageSquare = exports.SkeletonImageCircle = exports.SimplePagination = exports.SideSheet = exports.Select = exports.RadioButton = exports.PrimaryButton = exports.Portal = exports.Popover = exports.PasswordInput = exports.Pagination = exports.OutlineMonochromeButton = exports.OutlineButton = exports.NumberInput = exports.ModalWithProvider = exports.ModalProvider = exports.ModalContext = exports.Modal = exports.Menu = exports.Link = exports.InlineError = exports.IndexTable = exports.IconPagination = exports.Icon = exports.Fonts = exports.EmptyState = exports.DropShadow = exports.Divider = exports.DestructiveButton = exports.DataTable = exports.CurrencyInput = exports.Combobox = exports.Colors = exports.Checkbox = exports.Carousel = exports.Card = exports.ButtonGroup = exports.Button = exports.Breakpoints = exports.BorderRadius = exports.Bar = exports.Banner = exports.Badge = exports.Avatar = exports.AuthenticationInput = exports.AlertWithProvider = exports.AlertProvider = exports.AlertContext = exports.Alert = exports.ActionList = void 0;
|
|
5
5
|
var BorderRadius = _interopRequireWildcard(require("./utilities/borderRadius"));
|
|
6
6
|
exports.BorderRadius = BorderRadius;
|
|
7
7
|
var Breakpoints = _interopRequireWildcard(require("./utilities/breakpoints"));
|
|
@@ -22,6 +22,8 @@ exports.AlertContext = _Alert.AlertContext;
|
|
|
22
22
|
exports.AlertProvider = _Alert.AlertProvider;
|
|
23
23
|
exports.AlertWithProvider = _Alert.AlertWithProvider;
|
|
24
24
|
exports.useAlert = _Alert.useAlert;
|
|
25
|
+
var _AuthenticationInput = require("./AuthenticationInput");
|
|
26
|
+
exports.AuthenticationInput = _AuthenticationInput.AuthenticationInput;
|
|
25
27
|
var _Avatar = require("./Avatar");
|
|
26
28
|
exports.Avatar = _Avatar.Avatar;
|
|
27
29
|
var _Badge = require("./Badge");
|