@transferwise/components 0.0.0-experimental-72362bd → 0.0.0-experimental-b20fb95
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/build/field/Field.js +32 -60
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +34 -62
- package/build/field/Field.mjs.map +1 -1
- package/build/flowNavigation/FlowNavigation.js +2 -4
- package/build/flowNavigation/FlowNavigation.js.map +1 -1
- package/build/flowNavigation/FlowNavigation.mjs +2 -4
- package/build/flowNavigation/FlowNavigation.mjs.map +1 -1
- package/build/i18n/en.json +0 -1
- package/build/i18n/en.json.js +0 -1
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +0 -1
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/inputs/TextArea.js +0 -5
- package/build/inputs/TextArea.js.map +1 -1
- package/build/inputs/TextArea.mjs +1 -6
- package/build/inputs/TextArea.mjs.map +1 -1
- package/build/inputs/contexts.js +0 -16
- package/build/inputs/contexts.js.map +1 -1
- package/build/inputs/contexts.mjs +2 -16
- package/build/inputs/contexts.mjs.map +1 -1
- package/build/main.css +2 -18
- package/build/styles/field/Field.css +2 -16
- package/build/styles/main.css +2 -18
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
- package/build/types/inputs/TextArea.d.ts.map +1 -1
- package/build/types/inputs/contexts.d.ts +0 -6
- package/build/types/inputs/contexts.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +0 -2
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/field/Field.css +2 -16
- package/src/field/Field.less +2 -14
- package/src/field/Field.story.tsx +1 -5
- package/src/field/Field.tsx +37 -80
- package/src/flowNavigation/FlowNavigation.story.tsx +14 -9
- package/src/flowNavigation/FlowNavigation.test.js +2 -2
- package/src/flowNavigation/FlowNavigation.test.story.tsx +77 -0
- package/src/flowNavigation/FlowNavigation.tsx +2 -5
- package/src/i18n/en.json +0 -1
- package/src/inputs/TextArea.tsx +2 -7
- package/src/inputs/contexts.tsx +1 -18
- package/src/main.css +2 -18
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +0 -1
- package/build/field/Field.messages.js +0 -14
- package/build/field/Field.messages.js.map +0 -1
- package/build/field/Field.messages.mjs +0 -10
- package/build/field/Field.messages.mjs.map +0 -1
- package/build/types/field/Field.messages.d.ts +0 -8
- package/build/types/field/Field.messages.d.ts.map +0 -1
- package/src/field/Field.messages.ts +0 -8
- package/src/inputs/TextArea.story.tsx +0 -56
|
@@ -95,16 +95,13 @@ const FlowNavigation = ({
|
|
|
95
95
|
</div>
|
|
96
96
|
}
|
|
97
97
|
bottomContent={
|
|
98
|
-
!done &&
|
|
99
|
-
(steps.length > 0 ? (
|
|
98
|
+
!done && steps.length > 0 ? (
|
|
100
99
|
<Stepper
|
|
101
100
|
activeStep={activeStep}
|
|
102
101
|
steps={steps}
|
|
103
102
|
className={clsx('np-flow-navigation__stepper')}
|
|
104
103
|
/>
|
|
105
|
-
) :
|
|
106
|
-
<div className="np-flow-navigation__stepper" />
|
|
107
|
-
))
|
|
104
|
+
) : null
|
|
108
105
|
}
|
|
109
106
|
layout={!screenLg ? Layout.VERTICAL : Layout.HORIZONTAL}
|
|
110
107
|
/>
|
package/src/i18n/en.json
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"neptune.Expander.expandAriaLabel": "Expand",
|
|
21
21
|
"neptune.ExpressiveMoneyInput.currency.search.placeholder": "Type a currency / country",
|
|
22
22
|
"neptune.ExpressiveMoneyInput.currency.select.currency": "Select currency",
|
|
23
|
-
"neptune.Field.characterCount": "{current} of {max} characters used",
|
|
24
23
|
"neptune.FlowNavigation.back": "back to previous step",
|
|
25
24
|
"neptune.Info.ariaLabel": "More information",
|
|
26
25
|
"neptune.Label.optional": "(Optional)",
|
package/src/inputs/TextArea.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
|
|
4
4
|
import { Merge } from '../utils';
|
|
5
5
|
import { inputClassNameBase } from './_common';
|
|
6
|
-
import {
|
|
6
|
+
import { useInputAttributes } from './contexts';
|
|
7
7
|
|
|
8
8
|
export interface TextAreaProps extends Merge<
|
|
9
9
|
React.ComponentPropsWithRef<'textarea'>,
|
|
@@ -13,20 +13,15 @@ export interface TextAreaProps extends Merge<
|
|
|
13
13
|
> {}
|
|
14
14
|
|
|
15
15
|
export const TextArea = forwardRef(function TextArea(
|
|
16
|
-
{ className,
|
|
16
|
+
{ className, ...restProps }: TextAreaProps,
|
|
17
17
|
reference: React.ForwardedRef<HTMLTextAreaElement | null>,
|
|
18
18
|
) {
|
|
19
19
|
const inputAttributes = useInputAttributes();
|
|
20
|
-
const value = restProps.value ?? restProps.defaultValue ?? '';
|
|
21
|
-
const currentLength = typeof value === 'string' ? value.length : String(value).length;
|
|
22
|
-
|
|
23
|
-
useTextareaCharacterCount(currentLength, maxLength);
|
|
24
20
|
|
|
25
21
|
return (
|
|
26
22
|
<textarea
|
|
27
23
|
ref={reference}
|
|
28
24
|
className={clsx(className, inputClassNameBase(), 'np-text-area')}
|
|
29
|
-
maxLength={maxLength}
|
|
30
25
|
{...inputAttributes}
|
|
31
26
|
{...restProps}
|
|
32
27
|
/>
|
package/src/inputs/contexts.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, useContext
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
2
|
|
|
3
3
|
type FieldLabelContextType = {
|
|
4
4
|
id?: string;
|
|
@@ -36,23 +36,6 @@ export function useFieldLabelRef() {
|
|
|
36
36
|
return useContext(FieldLabelContext)?.ref;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export type TextareaCharacterCountState = { current: number; max: number } | null;
|
|
40
|
-
|
|
41
|
-
const TextareaCharacterCountContext = createContext<
|
|
42
|
-
((state: TextareaCharacterCountState) => void) | undefined
|
|
43
|
-
>(undefined);
|
|
44
|
-
export const TextareaCharacterCountProvider = TextareaCharacterCountContext.Provider;
|
|
45
|
-
|
|
46
|
-
export function useTextareaCharacterCount(current: number, max: number | undefined) {
|
|
47
|
-
const setCharacterCount = useContext(TextareaCharacterCountContext);
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (setCharacterCount && max != null) {
|
|
50
|
-
setCharacterCount({ current, max });
|
|
51
|
-
return () => setCharacterCount(null);
|
|
52
|
-
}
|
|
53
|
-
}, [setCharacterCount, current, max]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
39
|
export interface WithInputAttributesProps {
|
|
57
40
|
inputAttributes: ReturnType<typeof useInputAttributes>;
|
|
58
41
|
}
|
package/src/main.css
CHANGED
|
@@ -30193,28 +30193,12 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
30193
30193
|
stroke-dasharray: var(--wds-list-item-spotlight-strokeDashSize) var(--wds-list-item-spotlight-strokeDashSize);
|
|
30194
30194
|
}
|
|
30195
30195
|
|
|
30196
|
-
.np-field-control
|
|
30196
|
+
.np-field-control,
|
|
30197
|
+
.np-field__prompt {
|
|
30197
30198
|
margin-top: 4px;
|
|
30198
30199
|
margin-top: var(--size-4);
|
|
30199
30200
|
}
|
|
30200
30201
|
|
|
30201
|
-
.np-field-validation {
|
|
30202
|
-
display: flex;
|
|
30203
|
-
align-items: flex-start;
|
|
30204
|
-
margin-top: 4px;
|
|
30205
|
-
margin-top: var(--size-4);
|
|
30206
|
-
gap: 8px;
|
|
30207
|
-
gap: var(--size-8);
|
|
30208
|
-
}
|
|
30209
|
-
|
|
30210
|
-
.np-field-textarea-char-counter {
|
|
30211
|
-
margin-left: auto;
|
|
30212
|
-
padding: 4px 0;
|
|
30213
|
-
padding: var(--size-4) 0;
|
|
30214
|
-
color: #768e9c;
|
|
30215
|
-
color: var(--color-content-tertiary);
|
|
30216
|
-
}
|
|
30217
|
-
|
|
30218
30202
|
.np-field .form-group--typeahead[class],
|
|
30219
30203
|
.np-field .np-checkbox-label[class] {
|
|
30220
30204
|
margin-bottom: 0;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var reactIntl = require('react-intl');
|
|
6
|
-
|
|
7
|
-
var messages = reactIntl.defineMessages({
|
|
8
|
-
characterCount: {
|
|
9
|
-
id: "neptune.Field.characterCount"
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
exports.default = messages;
|
|
14
|
-
//# sourceMappingURL=Field.messages.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Field.messages.js","sources":["../../src/field/Field.messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n characterCount: {\n id: 'neptune.Field.characterCount',\n defaultMessage: '{current} of {max} characters used',\n },\n});\n"],"names":["defineMessages","characterCount","id"],"mappings":";;;;;;AAEA,eAAeA,wBAAc,CAAC;AAC5BC,EAAAA,cAAc,EAAE;IACdC,EAAE,EAAA;AAEH;AACF,CAAA,CAAC;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Field.messages.mjs","sources":["../../src/field/Field.messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n characterCount: {\n id: 'neptune.Field.characterCount',\n defaultMessage: '{current} of {max} characters used',\n },\n});\n"],"names":["defineMessages","characterCount","id"],"mappings":";;AAEA,eAAeA,cAAc,CAAC;AAC5BC,EAAAA,cAAc,EAAE;IACdC,EAAE,EAAA;AAEH;AACF,CAAA,CAAC;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Field.messages.d.ts","sourceRoot":"","sources":["../../../src/field/Field.messages.ts"],"names":[],"mappings":";;;;;;AAEA,wBAKG"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
|
-
|
|
4
|
-
import { Field } from '../field/Field';
|
|
5
|
-
import { Sentiment } from '../common';
|
|
6
|
-
import { TextArea } from './TextArea';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof TextArea> = {
|
|
9
|
-
title: 'Forms/TextArea',
|
|
10
|
-
component: TextArea,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default meta;
|
|
14
|
-
type Story = StoryObj<typeof TextArea>;
|
|
15
|
-
|
|
16
|
-
export const Basic: Story = {
|
|
17
|
-
render: () => {
|
|
18
|
-
const [value, setValue] = useState('');
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Field label="Message" required={false}>
|
|
22
|
-
<TextArea maxLength={200} value={value} onChange={({ target }) => setValue(target.value)} />
|
|
23
|
-
</Field>
|
|
24
|
-
);
|
|
25
|
-
},
|
|
26
|
-
parameters: {
|
|
27
|
-
docs: {
|
|
28
|
-
source: {
|
|
29
|
-
code: `<Field label="Message" required={false}>
|
|
30
|
-
<TextArea
|
|
31
|
-
maxLength={200}
|
|
32
|
-
value={value}
|
|
33
|
-
onChange={({ target }) => setValue(target.value)}
|
|
34
|
-
/>
|
|
35
|
-
</Field>`,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const WithError: Story = {
|
|
42
|
-
render: () => {
|
|
43
|
-
const [value, setValue] = useState('');
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<Field
|
|
47
|
-
label="Message"
|
|
48
|
-
required={false}
|
|
49
|
-
sentiment={Sentiment.NEGATIVE}
|
|
50
|
-
message="You have exceeded the character limit"
|
|
51
|
-
>
|
|
52
|
-
<TextArea maxLength={200} value={value} onChange={({ target }) => setValue(target.value)} />
|
|
53
|
-
</Field>
|
|
54
|
-
);
|
|
55
|
-
},
|
|
56
|
-
};
|