@popsure/dirty-swan 0.27.24 → 0.27.26
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/Readme.md +2 -0
- package/dist/index.js +73 -9
- package/dist/index.js.map +1 -1
- package/dist/lib/components/input/index.d.ts +7 -1
- package/package.json +4 -2
- package/src/lib/components/input/currency/index.stories.mdx +6 -0
- package/src/lib/components/input/index.stories.mdx +42 -0
- package/src/lib/components/input/index.tsx +76 -40
- package/src/lib/components/input/style.module.scss +16 -0
|
@@ -2,9 +2,15 @@ import React from 'react';
|
|
|
2
2
|
export declare type InputProps = {
|
|
3
3
|
error?: string;
|
|
4
4
|
prefix?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
hideLabel?: boolean;
|
|
5
8
|
} & Omit<JSX.IntrinsicElements['input'], 'enterKeyHint'> & Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>>;
|
|
6
9
|
declare const _default: React.ForwardRefExoticComponent<Pick<{
|
|
7
10
|
error?: string | undefined;
|
|
8
11
|
prefix?: string | undefined;
|
|
9
|
-
|
|
12
|
+
label?: string | undefined;
|
|
13
|
+
id?: string | undefined;
|
|
14
|
+
hideLabel?: boolean | undefined;
|
|
15
|
+
} & Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "enterKeyHint"> & Partial<Pick<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "enterKeyHint">>, "className" | "form" | "label" | "slot" | "style" | "title" | "pattern" | "children" | "onClick" | "error" | "hidden" | "value" | "onChange" | "dir" | "onBlur" | "onFocus" | "onKeyDown" | "tabIndex" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "list" | "step" | "disabled" | "enterKeyHint" | "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "readOnly" | "required" | "size" | "src" | "type" | "width" | "hideLabel"> & React.RefAttributes<HTMLInputElement>>;
|
|
10
16
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@popsure/dirty-swan",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.26",
|
|
4
4
|
"author": "Vincent Audoire <vincent@getpopsure.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"react-scroll-sync": "^0.9.0",
|
|
35
35
|
"remark-directive": "^2.0.1",
|
|
36
36
|
"sass": "^1.35.1",
|
|
37
|
-
"signature_pad": "^3.0.0-beta.3"
|
|
37
|
+
"signature_pad": "^3.0.0-beta.3",
|
|
38
|
+
"uuid": "^9.0.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"react": "^16.12.0",
|
|
@@ -91,6 +92,7 @@
|
|
|
91
92
|
"@types/react-dom": "^17.0.8",
|
|
92
93
|
"@types/react-scroll-sync": "^0.8.2",
|
|
93
94
|
"@types/sass": "^1.16.0",
|
|
95
|
+
"@types/uuid": "^9.0.0",
|
|
94
96
|
"babel-core": "^6.26.3",
|
|
95
97
|
"babel-runtime": "^6.26.0",
|
|
96
98
|
"cross-env": "^7.0.3",
|
|
@@ -21,5 +21,11 @@ The following will be done:
|
|
|
21
21
|
<CurrencyInput className="wmx5 mt8" />
|
|
22
22
|
<h4 className="p-h4 mt24">Filled</h4>
|
|
23
23
|
<CurrencyInput className="wmx5 mt8" value={1234567.32} />
|
|
24
|
+
<h4 className="p-h4 mt24">With placeholder</h4>
|
|
25
|
+
<CurrencyInput className="wmx5 mt8" placeholder="Amount" />
|
|
26
|
+
<h4 className="p-h4 mt24">With label</h4>
|
|
27
|
+
<CurrencyInput className="wmx5 mt8" label="Amount" placeholder="100" />
|
|
28
|
+
<h4 className="p-h4 mt24">With label and no placeholder</h4>
|
|
29
|
+
<CurrencyInput className="wmx5 mt8" label="Amount" />
|
|
24
30
|
</>
|
|
25
31
|
</Preview>
|
|
@@ -62,5 +62,47 @@ You are looking at the JSX definition of the Input component, if you want you ca
|
|
|
62
62
|
prefix="€"
|
|
63
63
|
error="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac hendrerit justo. Nunc nibh ex, vulputate ac leo id, feugiat rhoncus purus."
|
|
64
64
|
/>
|
|
65
|
+
<h1 className="p-h1 mt32">With label</h1>
|
|
66
|
+
<h4 className="p-h4 mt24">Empty</h4>
|
|
67
|
+
<Input className="wmx5 mt8" label="Email" />
|
|
68
|
+
<h4 className="p-h4 mt24">With placeholder</h4>
|
|
69
|
+
<Input
|
|
70
|
+
className="wmx5 mt8"
|
|
71
|
+
label="Email"
|
|
72
|
+
placeholder="email@feather-insurance.com"
|
|
73
|
+
/>
|
|
74
|
+
<h4 className="p-h4 mt24">Filled</h4>
|
|
75
|
+
<Input
|
|
76
|
+
className="wmx5 mt8"
|
|
77
|
+
value="email@feather-insurance.com"
|
|
78
|
+
label="Email"
|
|
79
|
+
placeholder="email@feather-insurance.com"
|
|
80
|
+
/>
|
|
81
|
+
<h4 className="p-h4 mt24">Disabled</h4>
|
|
82
|
+
<Input
|
|
83
|
+
className="wmx5 mt8"
|
|
84
|
+
label="Email"
|
|
85
|
+
placeholder="email@feather-insurance.com"
|
|
86
|
+
disabled
|
|
87
|
+
/>
|
|
88
|
+
<h4 className="p-h4 mt24">Error</h4>
|
|
89
|
+
<Input
|
|
90
|
+
className="wmx5 mt8"
|
|
91
|
+
label="Email"
|
|
92
|
+
value="invalid.email@feather-insurance.com"
|
|
93
|
+
placeholder="email@feather-insurance.com"
|
|
94
|
+
error="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
|
95
|
+
/>
|
|
96
|
+
<h4 className="p-h4 mt24">With prefix</h4>
|
|
97
|
+
<Input className="wmx5 mt8" label="Amount" value="100" prefix="€" />
|
|
98
|
+
<h4 className="p-h4 mt24">With label hidden</h4>
|
|
99
|
+
<Input
|
|
100
|
+
className="wmx5 mt8"
|
|
101
|
+
label="Amount"
|
|
102
|
+
value="100"
|
|
103
|
+
prefix="€"
|
|
104
|
+
hideLabel
|
|
105
|
+
onChange={() => {}}
|
|
106
|
+
/>
|
|
65
107
|
</>
|
|
66
108
|
</Preview>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
3
4
|
|
|
4
5
|
import styles from './style.module.scss';
|
|
5
6
|
|
|
@@ -7,53 +8,88 @@ import styles from './style.module.scss';
|
|
|
7
8
|
export type InputProps = {
|
|
8
9
|
error?: string;
|
|
9
10
|
prefix?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
hideLabel?: boolean;
|
|
10
14
|
} & Omit<JSX.IntrinsicElements['input'], 'enterKeyHint'> &
|
|
11
15
|
Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>>;
|
|
12
16
|
|
|
13
17
|
export default React.forwardRef(
|
|
14
18
|
(
|
|
15
|
-
{
|
|
19
|
+
{
|
|
20
|
+
className,
|
|
21
|
+
placeholder,
|
|
22
|
+
label,
|
|
23
|
+
id,
|
|
24
|
+
prefix,
|
|
25
|
+
error,
|
|
26
|
+
disabled,
|
|
27
|
+
hideLabel = false,
|
|
28
|
+
...props
|
|
29
|
+
}: InputProps,
|
|
16
30
|
ref?: React.ForwardedRef<HTMLInputElement>
|
|
17
|
-
) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
) => {
|
|
32
|
+
const uniqueId = id ?? uuidv4();
|
|
33
|
+
return (
|
|
34
|
+
<div className={`${styles.container} ${className ?? ''}`}>
|
|
35
|
+
{label && (
|
|
36
|
+
<label
|
|
37
|
+
htmlFor={uniqueId}
|
|
38
|
+
className={classnames('p-p', styles.label, {
|
|
39
|
+
[styles['label--with-error']]: error,
|
|
40
|
+
[styles['label--hidden']]: hideLabel,
|
|
41
|
+
})}
|
|
42
|
+
>
|
|
43
|
+
{label}
|
|
44
|
+
</label>
|
|
29
45
|
)}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
<div style={{ position: 'relative' }}>
|
|
47
|
+
<input
|
|
48
|
+
id={uniqueId}
|
|
49
|
+
data-testid="ds-input-input"
|
|
50
|
+
type="text"
|
|
51
|
+
ref={ref}
|
|
52
|
+
className={classnames(
|
|
53
|
+
error ? 'p-input--error' : 'p-input',
|
|
54
|
+
!label && placeholder && placeholder.length > 0
|
|
55
|
+
? styles.input
|
|
56
|
+
: styles['input--no-placeholder'],
|
|
57
|
+
{ [styles['input--with-prefix']]: prefix }
|
|
58
|
+
)}
|
|
59
|
+
placeholder={label ? placeholder : ' '}
|
|
60
|
+
disabled={disabled}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
{prefix && (
|
|
64
|
+
<span
|
|
65
|
+
className={classnames(
|
|
66
|
+
styles.prefix,
|
|
67
|
+
{ [styles['prefix--with-error']]: error },
|
|
68
|
+
{ [styles['prefix--disabled']]: disabled }
|
|
69
|
+
)}
|
|
70
|
+
>
|
|
71
|
+
{prefix}
|
|
72
|
+
</span>
|
|
40
73
|
)}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
74
|
+
{!label && (
|
|
75
|
+
<label
|
|
76
|
+
htmlFor={uniqueId}
|
|
77
|
+
className={classnames(
|
|
78
|
+
styles.placeholder,
|
|
79
|
+
{ [styles['placeholder--with-prefix']]: prefix },
|
|
80
|
+
{ [styles['placeholder--with-error']]: error }
|
|
81
|
+
)}
|
|
82
|
+
>
|
|
83
|
+
{placeholder}
|
|
84
|
+
</label>
|
|
85
|
+
)}
|
|
86
|
+
</div>
|
|
87
|
+
{error && (
|
|
88
|
+
<p className={`p-p--small tc-red-500 w100 ${styles.error}`}>
|
|
89
|
+
{error}
|
|
90
|
+
</p>
|
|
50
91
|
)}
|
|
51
|
-
>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{error && (
|
|
55
|
-
<p className={`p-p--small tc-red-500 w100 ${styles.error}`}>{error}</p>
|
|
56
|
-
)}
|
|
57
|
-
</div>
|
|
58
|
-
)
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
59
95
|
);
|
|
@@ -93,6 +93,22 @@
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
.label {
|
|
97
|
+
display: inline-block;
|
|
98
|
+
margin-bottom: 8px;
|
|
99
|
+
color: var(--ds-grey-600);
|
|
100
|
+
|
|
101
|
+
&--with-error {
|
|
102
|
+
color: var(--ds-red-500);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&--hidden {
|
|
106
|
+
visibility: hidden;
|
|
107
|
+
height: 0;
|
|
108
|
+
margin: 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
96
112
|
.error {
|
|
97
113
|
margin-top: 4px;
|
|
98
114
|
}
|