@transferwise/components 0.0.0-experimental-b20133d → 0.0.0-experimental-a2f9b4e
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 +1 -14
- package/build/styles/field/Field.css +1 -13
- package/build/styles/main.css +1 -14
- 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 +1 -13
- package/src/field/Field.less +1 -11
- package/src/field/Field.story.tsx +1 -5
- package/src/field/Field.tsx +37 -80
- package/src/flowNavigation/FlowNavigation.test.js +2 -2
- package/src/flowNavigation/FlowNavigation.test.story.tsx +88 -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 +1 -14
- 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
package/build/field/Field.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var clsx = require('clsx');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var reactIntl = require('react-intl');
|
|
6
|
-
var Body = require('../body/Body.js');
|
|
7
5
|
require('../common/theme.js');
|
|
8
6
|
require('../common/direction.js');
|
|
9
7
|
require('../common/propsValues/control.js');
|
|
@@ -25,10 +23,11 @@ require('../common/propsValues/markdownNodeType.js');
|
|
|
25
23
|
require('../common/fileType.js');
|
|
26
24
|
require('@transferwise/formatting');
|
|
27
25
|
require('@transferwise/icons');
|
|
26
|
+
require('react-intl');
|
|
28
27
|
require('../common/closeButton/CloseButton.messages.js');
|
|
29
28
|
var jsxRuntime = require('react/jsx-runtime');
|
|
30
|
-
var Field_messages = require('./Field.messages.js');
|
|
31
29
|
var InlinePrompt = require('../prompt/InlinePrompt/InlinePrompt.js');
|
|
30
|
+
require('../body/Body.js');
|
|
32
31
|
require('../button/Button.resolver.js');
|
|
33
32
|
require('../prompt/PrimitivePrompt/PrimitivePrompt.js');
|
|
34
33
|
require('../badge/Badge.js');
|
|
@@ -57,9 +56,6 @@ const Field = ({
|
|
|
57
56
|
children,
|
|
58
57
|
...props
|
|
59
58
|
}) => {
|
|
60
|
-
const {
|
|
61
|
-
formatMessage
|
|
62
|
-
} = reactIntl.useIntl();
|
|
63
59
|
const labelRef = React.useRef(null);
|
|
64
60
|
const sentiment$1 = props.error ? sentiment.Sentiment.NEGATIVE : propType;
|
|
65
61
|
const message = propMessage || props.error;
|
|
@@ -69,9 +65,6 @@ const Field = ({
|
|
|
69
65
|
const inputId = id !== null ? id ?? fallbackInputId : undefined;
|
|
70
66
|
const messageId = React.useId();
|
|
71
67
|
const descriptionId = React.useId();
|
|
72
|
-
const counterId = React.useId();
|
|
73
|
-
const [textareaCharacterCount, setTextareaCharacterCount] = React.useState(null);
|
|
74
|
-
const handleTextareaCharacterCount = React.useCallback(state => setTextareaCharacterCount(state), []);
|
|
75
68
|
/**
|
|
76
69
|
* form control can have multiple messages to describe it,
|
|
77
70
|
* e.g the description underneath the label and inline alert
|
|
@@ -84,9 +77,6 @@ const Field = ({
|
|
|
84
77
|
if (message) {
|
|
85
78
|
messageIds.push(messageId);
|
|
86
79
|
}
|
|
87
|
-
if (textareaCharacterCount) {
|
|
88
|
-
messageIds.push(counterId);
|
|
89
|
-
}
|
|
90
80
|
return messageIds.length > 0 ? messageIds.join(' ') : undefined;
|
|
91
81
|
}
|
|
92
82
|
return /*#__PURE__*/jsxRuntime.jsx(contexts.FieldLabelContextProvider, {
|
|
@@ -100,55 +90,37 @@ const Field = ({
|
|
|
100
90
|
value: ariaDescribedbyByIds(),
|
|
101
91
|
children: /*#__PURE__*/jsxRuntime.jsx(contexts.InputInvalidProvider, {
|
|
102
92
|
value: hasError,
|
|
103
|
-
children: /*#__PURE__*/jsxRuntime.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
className: "np-field-control",
|
|
125
|
-
children: children
|
|
126
|
-
})]
|
|
127
|
-
}) : children, (message || textareaCharacterCount) && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
128
|
-
className: "np-field-footer",
|
|
129
|
-
children: [message && /*#__PURE__*/jsxRuntime.jsx(InlinePrompt.InlinePrompt, {
|
|
130
|
-
sentiment: sentiment$1,
|
|
131
|
-
id: messageId,
|
|
132
|
-
mediaLabel: messageIconLabel,
|
|
133
|
-
className: "np-field__prompt",
|
|
134
|
-
loading: messageLoading,
|
|
135
|
-
width: "full",
|
|
136
|
-
children: message
|
|
137
|
-
}), textareaCharacterCount && /*#__PURE__*/jsxRuntime.jsxs(Body.default, {
|
|
138
|
-
as: "span",
|
|
139
|
-
id: counterId,
|
|
140
|
-
role: "status",
|
|
141
|
-
"aria-live": textareaCharacterCount.current >= textareaCharacterCount.max * 0.8 ? 'polite' : 'off',
|
|
142
|
-
"aria-atomic": "true",
|
|
143
|
-
"aria-label": formatMessage(Field_messages.default.characterCount, {
|
|
144
|
-
current: textareaCharacterCount.current,
|
|
145
|
-
max: textareaCharacterCount.max
|
|
146
|
-
}),
|
|
147
|
-
className: "np-field-counter",
|
|
148
|
-
children: [textareaCharacterCount.current, "/", textareaCharacterCount.max]
|
|
149
|
-
})]
|
|
93
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
94
|
+
className: clsx.clsx('np-field form-group d-block', {
|
|
95
|
+
'has-success': sentiment$1 === sentiment.Sentiment.POSITIVE,
|
|
96
|
+
'has-warning': sentiment$1 === sentiment.Sentiment.WARNING,
|
|
97
|
+
'has-error': hasError,
|
|
98
|
+
'has-info': sentiment$1 === sentiment.Sentiment.NEUTRAL
|
|
99
|
+
}, className),
|
|
100
|
+
children: [label != null ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
101
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label.Label, {
|
|
102
|
+
ref: labelRef,
|
|
103
|
+
id: labelId,
|
|
104
|
+
htmlFor: inputId,
|
|
105
|
+
children: required ? label : /*#__PURE__*/jsxRuntime.jsx(Label.Label.Optional, {
|
|
106
|
+
children: label
|
|
107
|
+
})
|
|
108
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Label.Label.Description, {
|
|
109
|
+
id: descriptionId,
|
|
110
|
+
children: description
|
|
111
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
112
|
+
className: "np-field-control",
|
|
113
|
+
children: children
|
|
150
114
|
})]
|
|
151
|
-
})
|
|
115
|
+
}) : children, message && /*#__PURE__*/jsxRuntime.jsx(InlinePrompt.InlinePrompt, {
|
|
116
|
+
sentiment: sentiment$1,
|
|
117
|
+
id: messageId,
|
|
118
|
+
mediaLabel: messageIconLabel,
|
|
119
|
+
className: "np-field__prompt",
|
|
120
|
+
loading: messageLoading,
|
|
121
|
+
width: "full",
|
|
122
|
+
children: message
|
|
123
|
+
})]
|
|
152
124
|
})
|
|
153
125
|
})
|
|
154
126
|
})
|
package/build/field/Field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sources":["../../src/field/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useCallback, useId, useRef, useState } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport Body from '../body';\nimport { Sentiment } from '../common';\nimport messages from './Field.messages';\nimport { InlinePrompt, type InlinePromptProps } from '../prompt';\nimport {\n TextareaCharacterCountProvider,\n type TextareaCharacterCountState,\n FieldLabelContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n /** @default true */\n required?: boolean;\n /** @deprecated Use `description` prop instead. */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /**\n * Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n messageIconLabel?: string;\n /**\n * If true, shows a loading spinner in place of the message icon of the InlinePrompt\n * @default false\n */\n messageLoading?: boolean;\n description?: React.ReactNode;\n /** @deprecated Use `message` and `type={Sentiment.NEGATIVE}` prop instead. */\n error?: React.ReactNode;\n /** @default Sentiment.NEUTRAL */\n sentiment?: InlinePromptProps['sentiment'];\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = true,\n message: propMessage,\n messageIconLabel,\n messageLoading,\n hint,\n description = hint,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const { formatMessage } = useIntl();\n const labelRef = useRef<HTMLLabelElement>(null);\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const messageId = useId();\n const descriptionId = useId();\n const counterId = useId();\n\n const [textareaCharacterCount, setTextareaCharacterCount] =\n useState<TextareaCharacterCountState>(null);\n const handleTextareaCharacterCount = useCallback(\n (state: TextareaCharacterCountState) => setTextareaCharacterCount(state),\n [],\n );\n\n /**\n * form control can have multiple messages to describe it,\n * e.g the description underneath the label and inline alert\n */\n function ariaDescribedbyByIds() {\n const messageIds = [];\n if (description) {\n messageIds.push(descriptionId);\n }\n if (message) {\n messageIds.push(messageId);\n }\n if (textareaCharacterCount) {\n messageIds.push(counterId);\n }\n return messageIds.length > 0 ? messageIds.join(' ') : undefined;\n }\n\n return (\n <FieldLabelContextProvider value={{ id: labelId, ref: labelRef }}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={ariaDescribedbyByIds()}>\n <InputInvalidProvider value={hasError}>\n <TextareaCharacterCountProvider value={handleTextareaCharacterCount}>\n <div\n className={clsx(\n 'np-field form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <>\n <Label ref={labelRef} id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n </Label>\n <Label.Description id={descriptionId}>{description}</Label.Description>\n <div className=\"np-field-control\">{children}</div>\n </>\n ) : (\n children\n )}\n\n {(message || textareaCharacterCount) && (\n <div className=\"np-field-footer\">\n {message && (\n <InlinePrompt\n sentiment={sentiment}\n id={messageId}\n mediaLabel={messageIconLabel}\n className=\"np-field__prompt\"\n loading={messageLoading}\n width=\"full\"\n >\n {message}\n </InlinePrompt>\n )}\n {textareaCharacterCount && (\n <Body\n as=\"span\"\n id={counterId}\n role=\"status\"\n aria-live={\n textareaCharacterCount.current >= textareaCharacterCount.max * 0.8\n ? 'polite'\n : 'off'\n }\n aria-atomic=\"true\"\n aria-label={formatMessage(messages.characterCount, {\n current: textareaCharacterCount.current,\n max: textareaCharacterCount.max,\n })}\n className=\"np-field-counter\"\n >\n {textareaCharacterCount.current}/{textareaCharacterCount.max}\n </Body>\n )}\n </div>\n )}\n </div>\n </TextareaCharacterCountProvider>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","messageIconLabel","messageLoading","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","formatMessage","useIntl","labelRef","useRef","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","messageId","descriptionId","counterId","textareaCharacterCount","setTextareaCharacterCount","useState","handleTextareaCharacterCount","useCallback","state","ariaDescribedbyByIds","messageIds","push","length","join","_jsx","FieldLabelContextProvider","value","ref","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","TextareaCharacterCountProvider","_jsxs","clsx","POSITIVE","WARNING","_Fragment","Label","htmlFor","Optional","Description","InlinePrompt","mediaLabel","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AACHC,kBAAAA,EAAE,EAAC,MAAM;AACThE,kBAAAA,EAAE,EAAE8B,SAAU;AACdmC,kBAAAA,IAAI,EAAC,QAAQ;AACb,kBAAA,WAAA,EACElC,sBAAsB,CAACmC,OAAO,IAAInC,sBAAsB,CAACoC,GAAG,GAAG,GAAG,GAC9D,QAAQ,GACR,KACL;AACD,kBAAA,aAAA,EAAY,MAAM;AAClB,kBAAA,YAAA,EAAYnD,aAAa,CAACoD,sBAAQ,CAACC,cAAc,EAAE;oBACjDH,OAAO,EAAEnC,sBAAsB,CAACmC,OAAO;oBACvCC,GAAG,EAAEpC,sBAAsB,CAACoC;AAC7B,mBAAA,CAAE;AACHtD,kBAAAA,SAAS,EAAC,kBAAkB;kBAAAC,QAAA,EAAA,CAE3BiB,sBAAsB,CAACmC,OAAO,EAAC,GAAC,EAACnC,sBAAsB,CAACoC,GAAG;AAAA,iBACxD,CACP;AAAA,eACE,CACN;aACE;WACyB;SACZ;OACE;KACJ;AAC1B,GAA2B,CAAC;AAEhC;;;;"}
|
|
1
|
+
{"version":3,"file":"Field.js","sources":["../../src/field/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useId, useRef } from 'react';\n\nimport { Sentiment } from '../common';\nimport { InlinePrompt, type InlinePromptProps } from '../prompt';\nimport {\n FieldLabelContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n /** @default true */\n required?: boolean;\n /** @deprecated Use `description` prop instead. */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /**\n * Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n messageIconLabel?: string;\n /**\n * If true, shows a loading spinner in place of the message icon of the InlinePrompt\n * @default false\n */\n messageLoading?: boolean;\n description?: React.ReactNode;\n /** @deprecated Use `message` and `type={Sentiment.NEGATIVE}` prop instead. */\n error?: React.ReactNode;\n /** @default Sentiment.NEUTRAL */\n sentiment?: InlinePromptProps['sentiment'];\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = true,\n message: propMessage,\n messageIconLabel,\n messageLoading,\n hint,\n description = hint,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const labelRef = useRef<HTMLLabelElement>(null);\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const messageId = useId();\n const descriptionId = useId();\n\n /**\n * form control can have multiple messages to describe it,\n * e.g the description underneath the label and inline alert\n */\n function ariaDescribedbyByIds() {\n const messageIds = [];\n if (description) {\n messageIds.push(descriptionId);\n }\n if (message) {\n messageIds.push(messageId);\n }\n return messageIds.length > 0 ? messageIds.join(' ') : undefined;\n }\n\n return (\n <FieldLabelContextProvider value={{ id: labelId, ref: labelRef }}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={ariaDescribedbyByIds()}>\n <InputInvalidProvider value={hasError}>\n <div\n className={clsx(\n 'np-field form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <>\n <Label ref={labelRef} id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n </Label>\n <Label.Description id={descriptionId}>{description}</Label.Description>\n <div className=\"np-field-control\">{children}</div>\n </>\n ) : (\n children\n )}\n\n {message && (\n <InlinePrompt\n sentiment={sentiment}\n id={messageId}\n mediaLabel={messageIconLabel}\n className=\"np-field__prompt\"\n loading={messageLoading}\n width=\"full\"\n >\n {message}\n </InlinePrompt>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","messageIconLabel","messageLoading","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","labelRef","useRef","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","messageId","descriptionId","ariaDescribedbyByIds","messageIds","push","length","join","_jsx","FieldLabelContextProvider","value","ref","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","POSITIVE","WARNING","_Fragment","Label","htmlFor","Optional","Description","InlinePrompt","mediaLabel","loading","width"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,QAAQ,GAAG,IAAI;AACfC,EAAAA,OAAO,EAAEC,WAAW;EACpBC,gBAAgB;EAChBC,cAAc;EACdC,IAAI;AACJC,EAAAA,WAAW,GAAGD,IAAI;AAClBE,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,mBAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC;AAAK,CACG,KAAI;AACf,EAAA,MAAMC,QAAQ,GAAGC,YAAM,CAAmB,IAAI,CAAC;EAC/C,MAAMR,WAAS,GAAGM,KAAK,CAACG,KAAK,GAAGP,mBAAS,CAACQ,QAAQ,GAAGT,QAAQ;AAC7D,EAAA,MAAMP,OAAO,GAAGC,WAAW,IAAIW,KAAK,CAACG,KAAK;AAC1C,EAAA,MAAME,QAAQ,GAAGX,WAAS,KAAKE,mBAAS,CAACQ,QAAQ;AAEjD,EAAA,MAAME,OAAO,GAAGC,WAAK,EAAE;AAEvB,EAAA,MAAMC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
|
-
import Body from '../body/Body.mjs';
|
|
2
|
+
import { useRef, useId } from 'react';
|
|
5
3
|
import '../common/theme.mjs';
|
|
6
4
|
import '../common/direction.mjs';
|
|
7
5
|
import '../common/propsValues/control.mjs';
|
|
@@ -23,10 +21,11 @@ import '../common/propsValues/markdownNodeType.mjs';
|
|
|
23
21
|
import '../common/fileType.mjs';
|
|
24
22
|
import '@transferwise/formatting';
|
|
25
23
|
import '@transferwise/icons';
|
|
24
|
+
import 'react-intl';
|
|
26
25
|
import '../common/closeButton/CloseButton.messages.mjs';
|
|
27
26
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
28
|
-
import messages from './Field.messages.mjs';
|
|
29
27
|
import { InlinePrompt } from '../prompt/InlinePrompt/InlinePrompt.mjs';
|
|
28
|
+
import '../body/Body.mjs';
|
|
30
29
|
import '../button/Button.resolver.mjs';
|
|
31
30
|
import '../prompt/PrimitivePrompt/PrimitivePrompt.mjs';
|
|
32
31
|
import '../badge/Badge.mjs';
|
|
@@ -38,7 +37,7 @@ import '../primitives/PrimitiveButton/PrimitiveButton.mjs';
|
|
|
38
37
|
import '../primitives/PrimitiveAnchor/PrimitiveAnchor.mjs';
|
|
39
38
|
import '../link/Link.messages.mjs';
|
|
40
39
|
import '../prompt/common/Expander/Expander.messages.mjs';
|
|
41
|
-
import { FieldLabelContextProvider, InputIdContextProvider, InputDescribedByProvider, InputInvalidProvider
|
|
40
|
+
import { FieldLabelContextProvider, InputIdContextProvider, InputDescribedByProvider, InputInvalidProvider } from '../inputs/contexts.mjs';
|
|
42
41
|
import { Label as LabelNamespace } from '../label/Label.mjs';
|
|
43
42
|
|
|
44
43
|
const Field = ({
|
|
@@ -55,9 +54,6 @@ const Field = ({
|
|
|
55
54
|
children,
|
|
56
55
|
...props
|
|
57
56
|
}) => {
|
|
58
|
-
const {
|
|
59
|
-
formatMessage
|
|
60
|
-
} = useIntl();
|
|
61
57
|
const labelRef = useRef(null);
|
|
62
58
|
const sentiment = props.error ? Sentiment.NEGATIVE : propType;
|
|
63
59
|
const message = propMessage || props.error;
|
|
@@ -67,9 +63,6 @@ const Field = ({
|
|
|
67
63
|
const inputId = id !== null ? id ?? fallbackInputId : undefined;
|
|
68
64
|
const messageId = useId();
|
|
69
65
|
const descriptionId = useId();
|
|
70
|
-
const counterId = useId();
|
|
71
|
-
const [textareaCharacterCount, setTextareaCharacterCount] = useState(null);
|
|
72
|
-
const handleTextareaCharacterCount = useCallback(state => setTextareaCharacterCount(state), []);
|
|
73
66
|
/**
|
|
74
67
|
* form control can have multiple messages to describe it,
|
|
75
68
|
* e.g the description underneath the label and inline alert
|
|
@@ -82,9 +75,6 @@ const Field = ({
|
|
|
82
75
|
if (message) {
|
|
83
76
|
messageIds.push(messageId);
|
|
84
77
|
}
|
|
85
|
-
if (textareaCharacterCount) {
|
|
86
|
-
messageIds.push(counterId);
|
|
87
|
-
}
|
|
88
78
|
return messageIds.length > 0 ? messageIds.join(' ') : undefined;
|
|
89
79
|
}
|
|
90
80
|
return /*#__PURE__*/jsx(FieldLabelContextProvider, {
|
|
@@ -98,55 +88,37 @@ const Field = ({
|
|
|
98
88
|
value: ariaDescribedbyByIds(),
|
|
99
89
|
children: /*#__PURE__*/jsx(InputInvalidProvider, {
|
|
100
90
|
value: hasError,
|
|
101
|
-
children: /*#__PURE__*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
className: "np-field-control",
|
|
123
|
-
children: children
|
|
124
|
-
})]
|
|
125
|
-
}) : children, (message || textareaCharacterCount) && /*#__PURE__*/jsxs("div", {
|
|
126
|
-
className: "np-field-footer",
|
|
127
|
-
children: [message && /*#__PURE__*/jsx(InlinePrompt, {
|
|
128
|
-
sentiment: sentiment,
|
|
129
|
-
id: messageId,
|
|
130
|
-
mediaLabel: messageIconLabel,
|
|
131
|
-
className: "np-field__prompt",
|
|
132
|
-
loading: messageLoading,
|
|
133
|
-
width: "full",
|
|
134
|
-
children: message
|
|
135
|
-
}), textareaCharacterCount && /*#__PURE__*/jsxs(Body, {
|
|
136
|
-
as: "span",
|
|
137
|
-
id: counterId,
|
|
138
|
-
role: "status",
|
|
139
|
-
"aria-live": textareaCharacterCount.current >= textareaCharacterCount.max * 0.8 ? 'polite' : 'off',
|
|
140
|
-
"aria-atomic": "true",
|
|
141
|
-
"aria-label": formatMessage(messages.characterCount, {
|
|
142
|
-
current: textareaCharacterCount.current,
|
|
143
|
-
max: textareaCharacterCount.max
|
|
144
|
-
}),
|
|
145
|
-
className: "np-field-counter",
|
|
146
|
-
children: [textareaCharacterCount.current, "/", textareaCharacterCount.max]
|
|
147
|
-
})]
|
|
91
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
92
|
+
className: clsx('np-field form-group d-block', {
|
|
93
|
+
'has-success': sentiment === Sentiment.POSITIVE,
|
|
94
|
+
'has-warning': sentiment === Sentiment.WARNING,
|
|
95
|
+
'has-error': hasError,
|
|
96
|
+
'has-info': sentiment === Sentiment.NEUTRAL
|
|
97
|
+
}, className),
|
|
98
|
+
children: [label != null ? /*#__PURE__*/jsxs(Fragment, {
|
|
99
|
+
children: [/*#__PURE__*/jsx(LabelNamespace, {
|
|
100
|
+
ref: labelRef,
|
|
101
|
+
id: labelId,
|
|
102
|
+
htmlFor: inputId,
|
|
103
|
+
children: required ? label : /*#__PURE__*/jsx(LabelNamespace.Optional, {
|
|
104
|
+
children: label
|
|
105
|
+
})
|
|
106
|
+
}), /*#__PURE__*/jsx(LabelNamespace.Description, {
|
|
107
|
+
id: descriptionId,
|
|
108
|
+
children: description
|
|
109
|
+
}), /*#__PURE__*/jsx("div", {
|
|
110
|
+
className: "np-field-control",
|
|
111
|
+
children: children
|
|
148
112
|
})]
|
|
149
|
-
})
|
|
113
|
+
}) : children, message && /*#__PURE__*/jsx(InlinePrompt, {
|
|
114
|
+
sentiment: sentiment,
|
|
115
|
+
id: messageId,
|
|
116
|
+
mediaLabel: messageIconLabel,
|
|
117
|
+
className: "np-field__prompt",
|
|
118
|
+
loading: messageLoading,
|
|
119
|
+
width: "full",
|
|
120
|
+
children: message
|
|
121
|
+
})]
|
|
150
122
|
})
|
|
151
123
|
})
|
|
152
124
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.mjs","sources":["../../src/field/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useCallback, useId, useRef, useState } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport Body from '../body';\nimport { Sentiment } from '../common';\nimport messages from './Field.messages';\nimport { InlinePrompt, type InlinePromptProps } from '../prompt';\nimport {\n TextareaCharacterCountProvider,\n type TextareaCharacterCountState,\n FieldLabelContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n /** @default true */\n required?: boolean;\n /** @deprecated Use `description` prop instead. */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /**\n * Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n messageIconLabel?: string;\n /**\n * If true, shows a loading spinner in place of the message icon of the InlinePrompt\n * @default false\n */\n messageLoading?: boolean;\n description?: React.ReactNode;\n /** @deprecated Use `message` and `type={Sentiment.NEGATIVE}` prop instead. */\n error?: React.ReactNode;\n /** @default Sentiment.NEUTRAL */\n sentiment?: InlinePromptProps['sentiment'];\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = true,\n message: propMessage,\n messageIconLabel,\n messageLoading,\n hint,\n description = hint,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const { formatMessage } = useIntl();\n const labelRef = useRef<HTMLLabelElement>(null);\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const messageId = useId();\n const descriptionId = useId();\n const counterId = useId();\n\n const [textareaCharacterCount, setTextareaCharacterCount] =\n useState<TextareaCharacterCountState>(null);\n const handleTextareaCharacterCount = useCallback(\n (state: TextareaCharacterCountState) => setTextareaCharacterCount(state),\n [],\n );\n\n /**\n * form control can have multiple messages to describe it,\n * e.g the description underneath the label and inline alert\n */\n function ariaDescribedbyByIds() {\n const messageIds = [];\n if (description) {\n messageIds.push(descriptionId);\n }\n if (message) {\n messageIds.push(messageId);\n }\n if (textareaCharacterCount) {\n messageIds.push(counterId);\n }\n return messageIds.length > 0 ? messageIds.join(' ') : undefined;\n }\n\n return (\n <FieldLabelContextProvider value={{ id: labelId, ref: labelRef }}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={ariaDescribedbyByIds()}>\n <InputInvalidProvider value={hasError}>\n <TextareaCharacterCountProvider value={handleTextareaCharacterCount}>\n <div\n className={clsx(\n 'np-field form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <>\n <Label ref={labelRef} id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n </Label>\n <Label.Description id={descriptionId}>{description}</Label.Description>\n <div className=\"np-field-control\">{children}</div>\n </>\n ) : (\n children\n )}\n\n {(message || textareaCharacterCount) && (\n <div className=\"np-field-footer\">\n {message && (\n <InlinePrompt\n sentiment={sentiment}\n id={messageId}\n mediaLabel={messageIconLabel}\n className=\"np-field__prompt\"\n loading={messageLoading}\n width=\"full\"\n >\n {message}\n </InlinePrompt>\n )}\n {textareaCharacterCount && (\n <Body\n as=\"span\"\n id={counterId}\n role=\"status\"\n aria-live={\n textareaCharacterCount.current >= textareaCharacterCount.max * 0.8\n ? 'polite'\n : 'off'\n }\n aria-atomic=\"true\"\n aria-label={formatMessage(messages.characterCount, {\n current: textareaCharacterCount.current,\n max: textareaCharacterCount.max,\n })}\n className=\"np-field-counter\"\n >\n {textareaCharacterCount.current}/{textareaCharacterCount.max}\n </Body>\n )}\n </div>\n )}\n </div>\n </TextareaCharacterCountProvider>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","messageIconLabel","messageLoading","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","formatMessage","useIntl","labelRef","useRef","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","messageId","descriptionId","counterId","textareaCharacterCount","setTextareaCharacterCount","useState","handleTextareaCharacterCount","useCallback","state","ariaDescribedbyByIds","messageIds","push","length","join","_jsx","FieldLabelContextProvider","value","ref","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","TextareaCharacterCountProvider","_jsxs","clsx","POSITIVE","WARNING","_Fragment","Label","htmlFor","Optional","Description","InlinePrompt","mediaLabel","loading","width","Body","as","role","current","max","messages","characterCount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,QAAQ,GAAG,IAAI;AACfC,EAAAA,OAAO,EAAEC,WAAW;EACpBC,gBAAgB;EAChBC,cAAc;EACdC,IAAI;AACJC,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Aa,CAACoD,QAAQ,CAACC,cAAc,EAAE;oBACjDH,OAAO,EAAEnC,sBAAsB,CAACmC,OAAO;oBACvCC,GAAG,EAAEpC,sBAAsB,CAACoC;AAC7B,mBAAA,CAAE;AACHtD,kBAAAA,SAAS,EAAC,kBAAkB;kBAAAC,QAAA,EAAA,CAE3BiB,sBAAsB,CAACmC,OAAO,EAAC,GAAC,EAACnC,sBAAsB,CAACoC,GAAG;AAAA,iBACxD,CACP;AAAA,eACE,CACN;aACE;WACyB;SACZ;OACE;KACJ;AAC1B,GAA2B,CAAC;AAEhC;;;;"}
|
|
1
|
+
{"version":3,"file":"Field.mjs","sources":["../../src/field/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useId, useRef } from 'react';\n\nimport { Sentiment } from '../common';\nimport { InlinePrompt, type InlinePromptProps } from '../prompt';\nimport {\n FieldLabelContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n /** @default true */\n required?: boolean;\n /** @deprecated Use `description` prop instead. */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /**\n * Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n messageIconLabel?: string;\n /**\n * If true, shows a loading spinner in place of the message icon of the InlinePrompt\n * @default false\n */\n messageLoading?: boolean;\n description?: React.ReactNode;\n /** @deprecated Use `message` and `type={Sentiment.NEGATIVE}` prop instead. */\n error?: React.ReactNode;\n /** @default Sentiment.NEUTRAL */\n sentiment?: InlinePromptProps['sentiment'];\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = true,\n message: propMessage,\n messageIconLabel,\n messageLoading,\n hint,\n description = hint,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const labelRef = useRef<HTMLLabelElement>(null);\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const messageId = useId();\n const descriptionId = useId();\n\n /**\n * form control can have multiple messages to describe it,\n * e.g the description underneath the label and inline alert\n */\n function ariaDescribedbyByIds() {\n const messageIds = [];\n if (description) {\n messageIds.push(descriptionId);\n }\n if (message) {\n messageIds.push(messageId);\n }\n return messageIds.length > 0 ? messageIds.join(' ') : undefined;\n }\n\n return (\n <FieldLabelContextProvider value={{ id: labelId, ref: labelRef }}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={ariaDescribedbyByIds()}>\n <InputInvalidProvider value={hasError}>\n <div\n className={clsx(\n 'np-field form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <>\n <Label ref={labelRef} id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n </Label>\n <Label.Description id={descriptionId}>{description}</Label.Description>\n <div className=\"np-field-control\">{children}</div>\n </>\n ) : (\n children\n )}\n\n {message && (\n <InlinePrompt\n sentiment={sentiment}\n id={messageId}\n mediaLabel={messageIconLabel}\n className=\"np-field__prompt\"\n loading={messageLoading}\n width=\"full\"\n >\n {message}\n </InlinePrompt>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","messageIconLabel","messageLoading","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","labelRef","useRef","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","messageId","descriptionId","ariaDescribedbyByIds","messageIds","push","length","join","_jsx","FieldLabelContextProvider","value","ref","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","POSITIVE","WARNING","_Fragment","Label","htmlFor","Optional","Description","InlinePrompt","mediaLabel","loading","width"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,QAAQ,GAAG,IAAI;AACfC,EAAAA,OAAO,EAAEC,WAAW;EACpBC,gBAAgB;EAChBC,cAAc;EACdC,IAAI;AACJC,EAAAA,WAAW,GAAGD,IAAI;AAClBE,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,SAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC;AAAK,CACG,KAAI;AACf,EAAA,MAAMC,QAAQ,GAAGC,MAAM,CAAmB,IAAI,CAAC;EAC/C,MAAMR,SAAS,GAAGM,KAAK,CAACG,KAAK,GAAGP,SAAS,CAACQ,QAAQ,GAAGT,QAAQ;AAC7D,EAAA,MAAMP,OAAO,GAAGC,WAAW,IAAIW,KAAK,CAACG,KAAK;AAC1C,EAAA,MAAME,QAAQ,GAAGX,SAAS,KAAKE,SAAS,CAACQ,QAAQ;AAEjD,EAAA,MAAME,OAAO,GAAGC,KAAK,EAAE;AAEvB,EAAA,MAAMC,eAAe,GAAGD,KAAK,EAAE;EAC/B,MAAME,OAAO,GAAGxB,EAAE,KAAK,IAAI,GAAIA,EAAE,IAAIuB,eAAe,GAAIE,SAAS;AAEjE,EAAA,MAAMC,SAAS,GAAGJ,KAAK,EAAE;AACzB,EAAA,MAAMK,aAAa,GAAGL,KAAK,EAAE;AAE7B;;;AAGG;EACH,SAASM,oBAAoBA,GAAA;IAC3B,MAAMC,UAAU,GAAG,EAAE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;AAACyB,gBAAAA,OAAO,EAAEtB,OAAQ;gBAAAV,QAAA,EACjDZ,QAAQ,GAAGD,KAAK,gBAAGgC,GAAA,CAACY,cAAK,CAACE,QAAQ,EAAA;AAAAjC,kBAAAA,QAAA,EAAEb;iBAAsB;AAAC,eACvD,CACP,eAAAgC,GAAA,CAACY,cAAK,CAACG,WAAW,EAAA;AAAChD,gBAAAA,EAAE,EAAE2B,aAAc;AAAAb,gBAAAA,QAAA,EAAEN;eAA+B,CACtE,eAAAyB,GAAA,CAAA,KAAA,EAAA;AAAKpB,gBAAAA,SAAS,EAAC,kBAAkB;AAAAC,gBAAAA,QAAA,EAAEA;AAAQ,eAAM,CACnD;aAAA,CAAG,GAEHA,QACD,EAEAX,OAAO,iBACN8B,GAAA,CAACgB,YAAY,EAAA;AACXxC,cAAAA,SAAS,EAAEA,SAAU;AACrBT,cAAAA,EAAE,EAAE0B,SAAU;AACdwB,cAAAA,UAAU,EAAE7C,gBAAiB;AAC7BQ,cAAAA,SAAS,EAAC,kBAAkB;AAC5BsC,cAAAA,OAAO,EAAE7C,cAAe;AACxB8C,cAAAA,KAAK,EAAC,MAAM;AAAAtC,cAAAA,QAAA,EAEXX;AAAO,aACI,CACf;WACE;SACe;OACE;KACJ;AAC1B,GAA2B,CAAC;AAEhC;;;;"}
|
|
@@ -88,13 +88,11 @@ const FlowNavigation = ({
|
|
|
88
88
|
className: "m-x-1"
|
|
89
89
|
}), closeButton]
|
|
90
90
|
}),
|
|
91
|
-
bottomContent: !done &&
|
|
91
|
+
bottomContent: !done && steps.length > 0 ? /*#__PURE__*/jsxRuntime.jsx(Stepper.default, {
|
|
92
92
|
activeStep: activeStep,
|
|
93
93
|
steps: steps,
|
|
94
94
|
className: clsx.clsx('np-flow-navigation__stepper')
|
|
95
|
-
}) :
|
|
96
|
-
className: "np-flow-navigation__stepper"
|
|
97
|
-
})),
|
|
95
|
+
}) : null,
|
|
98
96
|
layout: !screenLg ? layouts.Layout.VERTICAL : layouts.Layout.HORIZONTAL
|
|
99
97
|
})
|
|
100
98
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowNavigation.js","sources":["../../src/flowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\n\nimport { Breakpoint, Layout } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport FlowHeader from '../common/flowHeader/FlowHeader';\nimport Logo from '../logo';\nimport Stepper, { type Step } from '../stepper/Stepper';\n\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport messages from './FlowNavigation.messages';\nimport AnimatedLabel from './animatedLabel';\nimport IconButton from '../iconButton';\nimport { ArrowLeft } from '@transferwise/icons';\n\nexport interface FlowNavigationProps {\n /** @default 0 */\n activeStep?: number;\n avatar?: React.ReactNode;\n /** @default <Logo /> */\n logo?: React.ReactNode;\n /** @default false */\n done?: boolean;\n /** Called when the close button is clicked. If not provided the close button won't show */\n onClose?: () => void;\n /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */\n onGoBack?: () => void;\n /** Steps to be displayed in stepper. If you don't need the stepper, please use OverlayHeader instead */\n steps: readonly Step[];\n}\n\nconst FlowNavigation = ({\n activeStep = 0,\n avatar,\n logo = <Logo />,\n done = false,\n onClose,\n onGoBack,\n steps,\n}: FlowNavigationProps) => {\n const intl = useIntl();\n\n const closeButton = onClose != null && <CloseButton size=\"lg\" onClick={onClose} />;\n\n const screenSm = useScreenSize(Breakpoint.SMALL);\n const screenLg = useScreenSize(Breakpoint.LARGE);\n\n const newAvatar = done ? null : avatar;\n\n const displayGoBack = onGoBack != null && activeStep > 0;\n\n return (\n <div\n className={clsx('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {\n 'np-flow-navigation--border-bottom': !done,\n })}\n >\n <FlowHeader\n className={clsx(\n 'np-flow-navigation__content p-x-3',\n screenSm == null\n ? 'np-flow-navigation--hidden'\n : {\n 'np-flow-navigation--xs-max': !screenSm,\n // Size switches on parent container which may or may not have the same size as the window.\n 'np-flow-navigation--sm': screenSm,\n 'np-flow-navigation--lg': screenLg,\n },\n )}\n leftContent={\n <>\n {!screenSm && displayGoBack ? (\n <IconButton\n size={40}\n priority=\"tertiary\"\n type=\"default\"\n aria-label={intl.formatMessage(messages.back)}\n onClick={onGoBack}\n >\n <ArrowLeft />\n </IconButton>\n ) : (\n <div className=\"np-flow-header__left\">{logo}</div>\n )}\n {!screenSm && !done && (\n <AnimatedLabel className=\"m-x-1\" steps={steps} activeLabel={activeStep} />\n )}\n </>\n }\n rightContent={\n <div className=\"np-flow-header__right d-flex align-items-center justify-content-end order-2--lg\">\n {newAvatar}\n {newAvatar && closeButton && <span className=\"m-x-1\" />}\n {closeButton}\n </div>\n }\n bottomContent={\n !done
|
|
1
|
+
{"version":3,"file":"FlowNavigation.js","sources":["../../src/flowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\n\nimport { Breakpoint, Layout } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport FlowHeader from '../common/flowHeader/FlowHeader';\nimport Logo from '../logo';\nimport Stepper, { type Step } from '../stepper/Stepper';\n\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport messages from './FlowNavigation.messages';\nimport AnimatedLabel from './animatedLabel';\nimport IconButton from '../iconButton';\nimport { ArrowLeft } from '@transferwise/icons';\n\nexport interface FlowNavigationProps {\n /** @default 0 */\n activeStep?: number;\n avatar?: React.ReactNode;\n /** @default <Logo /> */\n logo?: React.ReactNode;\n /** @default false */\n done?: boolean;\n /** Called when the close button is clicked. If not provided the close button won't show */\n onClose?: () => void;\n /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */\n onGoBack?: () => void;\n /** Steps to be displayed in stepper. If you don't need the stepper, please use OverlayHeader instead */\n steps: readonly Step[];\n}\n\nconst FlowNavigation = ({\n activeStep = 0,\n avatar,\n logo = <Logo />,\n done = false,\n onClose,\n onGoBack,\n steps,\n}: FlowNavigationProps) => {\n const intl = useIntl();\n\n const closeButton = onClose != null && <CloseButton size=\"lg\" onClick={onClose} />;\n\n const screenSm = useScreenSize(Breakpoint.SMALL);\n const screenLg = useScreenSize(Breakpoint.LARGE);\n\n const newAvatar = done ? null : avatar;\n\n const displayGoBack = onGoBack != null && activeStep > 0;\n\n return (\n <div\n className={clsx('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {\n 'np-flow-navigation--border-bottom': !done,\n })}\n >\n <FlowHeader\n className={clsx(\n 'np-flow-navigation__content p-x-3',\n screenSm == null\n ? 'np-flow-navigation--hidden'\n : {\n 'np-flow-navigation--xs-max': !screenSm,\n // Size switches on parent container which may or may not have the same size as the window.\n 'np-flow-navigation--sm': screenSm,\n 'np-flow-navigation--lg': screenLg,\n },\n )}\n leftContent={\n <>\n {!screenSm && displayGoBack ? (\n <IconButton\n size={40}\n priority=\"tertiary\"\n type=\"default\"\n aria-label={intl.formatMessage(messages.back)}\n onClick={onGoBack}\n >\n <ArrowLeft />\n </IconButton>\n ) : (\n <div className=\"np-flow-header__left\">{logo}</div>\n )}\n {!screenSm && !done && (\n <AnimatedLabel className=\"m-x-1\" steps={steps} activeLabel={activeStep} />\n )}\n </>\n }\n rightContent={\n <div className=\"np-flow-header__right d-flex align-items-center justify-content-end order-2--lg\">\n {newAvatar}\n {newAvatar && closeButton && <span className=\"m-x-1\" />}\n {closeButton}\n </div>\n }\n bottomContent={\n !done && steps.length > 0 ? (\n <Stepper\n activeStep={activeStep}\n steps={steps}\n className={clsx('np-flow-navigation__stepper')}\n />\n ) : null\n }\n layout={!screenLg ? Layout.VERTICAL : Layout.HORIZONTAL}\n />\n </div>\n );\n};\n\nexport default FlowNavigation;\n"],"names":["FlowNavigation","activeStep","avatar","logo","_jsx","Logo","done","onClose","onGoBack","steps","intl","useIntl","closeButton","CloseButton","size","onClick","screenSm","useScreenSize","Breakpoint","SMALL","screenLg","LARGE","newAvatar","displayGoBack","className","clsx","children","FlowHeader","leftContent","_jsxs","_Fragment","IconButton","priority","type","formatMessage","messages","back","ArrowLeft","AnimatedLabel","activeLabel","rightContent","bottomContent","length","Stepper","layout","Layout","VERTICAL","HORIZONTAL"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAMA,cAAc,GAAGA,CAAC;AACtBC,EAAAA,UAAU,GAAG,CAAC;EACdC,MAAM;AACNC,EAAAA,IAAI,gBAAGC,cAAA,CAACC,YAAI,IAAA,CAAG;AACfC,EAAAA,IAAI,GAAG,KAAK;EACZC,OAAO;EACPC,QAAQ;AACRC,EAAAA;AAAK,CACe,KAAI;AACxB,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE;EAEtB,MAAMC,WAAW,GAAGL,OAAO,IAAI,IAAI,iBAAIH,cAAA,CAACS,uBAAW,EAAA;AAACC,IAAAA,IAAI,EAAC,IAAI;AAACC,IAAAA,OAAO,EAAER;AAAQ,IAAG;AAElF,EAAA,MAAMS,QAAQ,GAAGC,2BAAa,CAACC,qBAAU,CAACC,KAAK,CAAC;AAChD,EAAA,MAAMC,QAAQ,GAAGH,2BAAa,CAACC,qBAAU,CAACG,KAAK,CAAC;AAEhD,EAAA,MAAMC,SAAS,GAAGhB,IAAI,GAAG,IAAI,GAAGJ,MAAM;EAEtC,MAAMqB,aAAa,GAAGf,QAAQ,IAAI,IAAI,IAAIP,UAAU,GAAG,CAAC;AAExD,EAAA,oBACEG,cAAA,CAAA,KAAA,EAAA;AACEoB,IAAAA,SAAS,EAAEC,SAAI,CAAC,2EAA2E,EAAE;AAC3F,MAAA,mCAAmC,EAAE,CAACnB;AACvC,KAAA,CAAE;IAAAoB,QAAA,eAEHtB,cAAA,CAACuB,kBAAU,EAAA;MACTH,SAAS,EAAEC,SAAI,CACb,mCAAmC,EACnCT,QAAQ,IAAI,IAAI,GACZ,4BAA4B,GAC5B;QACE,4BAA4B,EAAE,CAACA,QAAQ;AACvC;AACA,QAAA,wBAAwB,EAAEA,QAAQ;A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,6BAA6B;OAAE,CAC/C,GACA,IACL;MACDmB,MAAM,EAAE,CAACxB,QAAQ,GAAGyB,cAAM,CAACC,QAAQ,GAAGD,cAAM,CAACE;KAAW;AAE5D,GAAK,CAAC;AAEV;;;;"}
|
|
@@ -84,13 +84,11 @@ const FlowNavigation = ({
|
|
|
84
84
|
className: "m-x-1"
|
|
85
85
|
}), closeButton]
|
|
86
86
|
}),
|
|
87
|
-
bottomContent: !done &&
|
|
87
|
+
bottomContent: !done && steps.length > 0 ? /*#__PURE__*/jsx(Stepper, {
|
|
88
88
|
activeStep: activeStep,
|
|
89
89
|
steps: steps,
|
|
90
90
|
className: clsx('np-flow-navigation__stepper')
|
|
91
|
-
}) :
|
|
92
|
-
className: "np-flow-navigation__stepper"
|
|
93
|
-
})),
|
|
91
|
+
}) : null,
|
|
94
92
|
layout: !screenLg ? Layout.VERTICAL : Layout.HORIZONTAL
|
|
95
93
|
})
|
|
96
94
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowNavigation.mjs","sources":["../../src/flowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\n\nimport { Breakpoint, Layout } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport FlowHeader from '../common/flowHeader/FlowHeader';\nimport Logo from '../logo';\nimport Stepper, { type Step } from '../stepper/Stepper';\n\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport messages from './FlowNavigation.messages';\nimport AnimatedLabel from './animatedLabel';\nimport IconButton from '../iconButton';\nimport { ArrowLeft } from '@transferwise/icons';\n\nexport interface FlowNavigationProps {\n /** @default 0 */\n activeStep?: number;\n avatar?: React.ReactNode;\n /** @default <Logo /> */\n logo?: React.ReactNode;\n /** @default false */\n done?: boolean;\n /** Called when the close button is clicked. If not provided the close button won't show */\n onClose?: () => void;\n /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */\n onGoBack?: () => void;\n /** Steps to be displayed in stepper. If you don't need the stepper, please use OverlayHeader instead */\n steps: readonly Step[];\n}\n\nconst FlowNavigation = ({\n activeStep = 0,\n avatar,\n logo = <Logo />,\n done = false,\n onClose,\n onGoBack,\n steps,\n}: FlowNavigationProps) => {\n const intl = useIntl();\n\n const closeButton = onClose != null && <CloseButton size=\"lg\" onClick={onClose} />;\n\n const screenSm = useScreenSize(Breakpoint.SMALL);\n const screenLg = useScreenSize(Breakpoint.LARGE);\n\n const newAvatar = done ? null : avatar;\n\n const displayGoBack = onGoBack != null && activeStep > 0;\n\n return (\n <div\n className={clsx('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {\n 'np-flow-navigation--border-bottom': !done,\n })}\n >\n <FlowHeader\n className={clsx(\n 'np-flow-navigation__content p-x-3',\n screenSm == null\n ? 'np-flow-navigation--hidden'\n : {\n 'np-flow-navigation--xs-max': !screenSm,\n // Size switches on parent container which may or may not have the same size as the window.\n 'np-flow-navigation--sm': screenSm,\n 'np-flow-navigation--lg': screenLg,\n },\n )}\n leftContent={\n <>\n {!screenSm && displayGoBack ? (\n <IconButton\n size={40}\n priority=\"tertiary\"\n type=\"default\"\n aria-label={intl.formatMessage(messages.back)}\n onClick={onGoBack}\n >\n <ArrowLeft />\n </IconButton>\n ) : (\n <div className=\"np-flow-header__left\">{logo}</div>\n )}\n {!screenSm && !done && (\n <AnimatedLabel className=\"m-x-1\" steps={steps} activeLabel={activeStep} />\n )}\n </>\n }\n rightContent={\n <div className=\"np-flow-header__right d-flex align-items-center justify-content-end order-2--lg\">\n {newAvatar}\n {newAvatar && closeButton && <span className=\"m-x-1\" />}\n {closeButton}\n </div>\n }\n bottomContent={\n !done
|
|
1
|
+
{"version":3,"file":"FlowNavigation.mjs","sources":["../../src/flowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\n\nimport { Breakpoint, Layout } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport FlowHeader from '../common/flowHeader/FlowHeader';\nimport Logo from '../logo';\nimport Stepper, { type Step } from '../stepper/Stepper';\n\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport messages from './FlowNavigation.messages';\nimport AnimatedLabel from './animatedLabel';\nimport IconButton from '../iconButton';\nimport { ArrowLeft } from '@transferwise/icons';\n\nexport interface FlowNavigationProps {\n /** @default 0 */\n activeStep?: number;\n avatar?: React.ReactNode;\n /** @default <Logo /> */\n logo?: React.ReactNode;\n /** @default false */\n done?: boolean;\n /** Called when the close button is clicked. If not provided the close button won't show */\n onClose?: () => void;\n /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */\n onGoBack?: () => void;\n /** Steps to be displayed in stepper. If you don't need the stepper, please use OverlayHeader instead */\n steps: readonly Step[];\n}\n\nconst FlowNavigation = ({\n activeStep = 0,\n avatar,\n logo = <Logo />,\n done = false,\n onClose,\n onGoBack,\n steps,\n}: FlowNavigationProps) => {\n const intl = useIntl();\n\n const closeButton = onClose != null && <CloseButton size=\"lg\" onClick={onClose} />;\n\n const screenSm = useScreenSize(Breakpoint.SMALL);\n const screenLg = useScreenSize(Breakpoint.LARGE);\n\n const newAvatar = done ? null : avatar;\n\n const displayGoBack = onGoBack != null && activeStep > 0;\n\n return (\n <div\n className={clsx('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {\n 'np-flow-navigation--border-bottom': !done,\n })}\n >\n <FlowHeader\n className={clsx(\n 'np-flow-navigation__content p-x-3',\n screenSm == null\n ? 'np-flow-navigation--hidden'\n : {\n 'np-flow-navigation--xs-max': !screenSm,\n // Size switches on parent container which may or may not have the same size as the window.\n 'np-flow-navigation--sm': screenSm,\n 'np-flow-navigation--lg': screenLg,\n },\n )}\n leftContent={\n <>\n {!screenSm && displayGoBack ? (\n <IconButton\n size={40}\n priority=\"tertiary\"\n type=\"default\"\n aria-label={intl.formatMessage(messages.back)}\n onClick={onGoBack}\n >\n <ArrowLeft />\n </IconButton>\n ) : (\n <div className=\"np-flow-header__left\">{logo}</div>\n )}\n {!screenSm && !done && (\n <AnimatedLabel className=\"m-x-1\" steps={steps} activeLabel={activeStep} />\n )}\n </>\n }\n rightContent={\n <div className=\"np-flow-header__right d-flex align-items-center justify-content-end order-2--lg\">\n {newAvatar}\n {newAvatar && closeButton && <span className=\"m-x-1\" />}\n {closeButton}\n </div>\n }\n bottomContent={\n !done && steps.length > 0 ? (\n <Stepper\n activeStep={activeStep}\n steps={steps}\n className={clsx('np-flow-navigation__stepper')}\n />\n ) : null\n }\n layout={!screenLg ? Layout.VERTICAL : Layout.HORIZONTAL}\n />\n </div>\n );\n};\n\nexport default FlowNavigation;\n"],"names":["FlowNavigation","activeStep","avatar","logo","_jsx","Logo","done","onClose","onGoBack","steps","intl","useIntl","closeButton","CloseButton","size","onClick","screenSm","useScreenSize","Breakpoint","SMALL","screenLg","LARGE","newAvatar","displayGoBack","className","clsx","children","FlowHeader","leftContent","_jsxs","_Fragment","IconButton","priority","type","formatMessage","messages","back","ArrowLeft","AnimatedLabel","activeLabel","rightContent","bottomContent","length","Stepper","layout","Layout","VERTICAL","HORIZONTAL"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAMA,cAAc,GAAGA,CAAC;AACtBC,EAAAA,UAAU,GAAG,CAAC;EACdC,MAAM;AACNC,EAAAA,IAAI,gBAAGC,GAAA,CAACC,IAAI,IAAA,CAAG;AACfC,EAAAA,IAAI,GAAG,KAAK;EACZC,OAAO;EACPC,QAAQ;AACRC,EAAAA;AAAK,CACe,KAAI;AACxB,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE;EAEtB,MAAMC,WAAW,GAAGL,OAAO,IAAI,IAAI,iBAAIH,GAAA,CAACS,WAAW,EAAA;AAACC,IAAAA,IAAI,EAAC,IAAI;AAACC,IAAAA,OAAO,EAAER;AAAQ,IAAG;AAElF,EAAA,MAAMS,QAAQ,GAAGC,aAAa,CAACC,UAAU,CAACC,KAAK,CAAC;AAChD,EAAA,MAAMC,QAAQ,GAA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AEA,KAAM;AAAC8B,UAAAA,WAAW,EAAEtC;AAAW,SAAA,CACxE;AAAA,OACH,CACD;AACDuC,MAAAA,YAAY,eACVX,IAAA,CAAA,KAAA,EAAA;AAAKL,QAAAA,SAAS,EAAC,iFAAiF;AAAAE,QAAAA,QAAA,GAC7FJ,SAAS,EACTA,SAAS,IAAIV,WAAW,iBAAIR,GAAA,CAAA,MAAA,EAAA;AAAMoB,UAAAA,SAAS,EAAC;SAAO,CAAG,EACtDZ,WAAW;AAAA,OACT,CACN;AACD6B,MAAAA,aAAa,EACX,CAACnC,IAAI,IAAIG,KAAK,CAACiC,MAAM,GAAG,CAAC,gBACvBtC,GAAA,CAACuC,OAAO,EAAA;AACN1C,QAAAA,UAAU,EAAEA,UAAW;AACvBQ,QAAAA,KAAK,EAAEA,KAAM;QACbe,SAAS,EAAEC,IAAI,CAAC,6BAA6B;OAAE,CAC/C,GACA,IACL;MACDmB,MAAM,EAAE,CAACxB,QAAQ,GAAGyB,MAAM,CAACC,QAAQ,GAAGD,MAAM,CAACE;KAAW;AAE5D,GAAK,CAAC;AAEV;;;;"}
|
package/build/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/build/i18n/en.json.js
CHANGED
|
@@ -24,7 +24,6 @@ var en = {
|
|
|
24
24
|
"neptune.Expander.expandAriaLabel": "Expand",
|
|
25
25
|
"neptune.ExpressiveMoneyInput.currency.search.placeholder": "Type a currency / country",
|
|
26
26
|
"neptune.ExpressiveMoneyInput.currency.select.currency": "Select currency",
|
|
27
|
-
"neptune.Field.characterCount": "{current} of {max} characters used",
|
|
28
27
|
"neptune.FlowNavigation.back": "back to previous step",
|
|
29
28
|
"neptune.Info.ariaLabel": "More information",
|
|
30
29
|
"neptune.Label.optional": "(Optional)",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/i18n/en.json.mjs
CHANGED
|
@@ -20,7 +20,6 @@ var en = {
|
|
|
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)",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/inputs/TextArea.js
CHANGED
|
@@ -8,17 +8,12 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
8
8
|
|
|
9
9
|
const TextArea = /*#__PURE__*/React.forwardRef(function TextArea({
|
|
10
10
|
className,
|
|
11
|
-
maxLength,
|
|
12
11
|
...restProps
|
|
13
12
|
}, reference) {
|
|
14
13
|
const inputAttributes = contexts.useInputAttributes();
|
|
15
|
-
const value = restProps.value ?? restProps.defaultValue ?? '';
|
|
16
|
-
const currentLength = typeof value === 'string' ? value.length : String(value).length;
|
|
17
|
-
contexts.useTextareaCharacterCount(currentLength, maxLength);
|
|
18
14
|
return /*#__PURE__*/jsxRuntime.jsx("textarea", {
|
|
19
15
|
ref: reference,
|
|
20
16
|
className: clsx.clsx(className, _common.inputClassNameBase(), 'np-text-area'),
|
|
21
|
-
maxLength: maxLength,
|
|
22
17
|
...inputAttributes,
|
|
23
18
|
...restProps
|
|
24
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.js","sources":["../../src/inputs/TextArea.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef } from 'react';\n\nimport { Merge } from '../utils';\nimport { inputClassNameBase } from './_common';\nimport {
|
|
1
|
+
{"version":3,"file":"TextArea.js","sources":["../../src/inputs/TextArea.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef } from 'react';\n\nimport { Merge } from '../utils';\nimport { inputClassNameBase } from './_common';\nimport { useInputAttributes } from './contexts';\n\nexport interface TextAreaProps extends Merge<\n React.ComponentPropsWithRef<'textarea'>,\n {\n 'aria-invalid'?: boolean;\n }\n> {}\n\nexport const TextArea = forwardRef(function TextArea(\n { className, ...restProps }: TextAreaProps,\n reference: React.ForwardedRef<HTMLTextAreaElement | null>,\n) {\n const inputAttributes = useInputAttributes();\n\n return (\n <textarea\n ref={reference}\n className={clsx(className, inputClassNameBase(), 'np-text-area')}\n {...inputAttributes}\n {...restProps}\n />\n );\n});\n"],"names":["TextArea","forwardRef","className","restProps","reference","inputAttributes","useInputAttributes","_jsx","ref","clsx","inputClassNameBase"],"mappings":";;;;;;;;MAcaA,QAAQ,gBAAGC,gBAAU,CAAC,SAASD,QAAQA,CAClD;EAAEE,SAAS;EAAE,GAAGC;AAAS,CAAiB,EAC1CC,SAAyD,EAAA;AAEzD,EAAA,MAAMC,eAAe,GAAGC,2BAAkB,EAAE;AAE5C,EAAA,oBACEC,cAAA,CAAA,UAAA,EAAA;AACEC,IAAAA,GAAG,EAAEJ,SAAU;IACfF,SAAS,EAAEO,SAAI,CAACP,SAAS,EAAEQ,0BAAkB,EAAE,EAAE,cAAc,CAAE;AAAA,IAAA,GAC7DL,eAAe;IAAA,GACfF;AAAS,GAAC,CACd;AAEN,CAAC;;;;"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { inputClassNameBase } from './_common.mjs';
|
|
4
|
-
import { useInputAttributes
|
|
4
|
+
import { useInputAttributes } from './contexts.mjs';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
const TextArea = /*#__PURE__*/forwardRef(function TextArea({
|
|
8
8
|
className,
|
|
9
|
-
maxLength,
|
|
10
9
|
...restProps
|
|
11
10
|
}, reference) {
|
|
12
11
|
const inputAttributes = useInputAttributes();
|
|
13
|
-
const value = restProps.value ?? restProps.defaultValue ?? '';
|
|
14
|
-
const currentLength = typeof value === 'string' ? value.length : String(value).length;
|
|
15
|
-
useTextareaCharacterCount(currentLength, maxLength);
|
|
16
12
|
return /*#__PURE__*/jsx("textarea", {
|
|
17
13
|
ref: reference,
|
|
18
14
|
className: clsx(className, inputClassNameBase(), 'np-text-area'),
|
|
19
|
-
maxLength: maxLength,
|
|
20
15
|
...inputAttributes,
|
|
21
16
|
...restProps
|
|
22
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.mjs","sources":["../../src/inputs/TextArea.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef } from 'react';\n\nimport { Merge } from '../utils';\nimport { inputClassNameBase } from './_common';\nimport {
|
|
1
|
+
{"version":3,"file":"TextArea.mjs","sources":["../../src/inputs/TextArea.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef } from 'react';\n\nimport { Merge } from '../utils';\nimport { inputClassNameBase } from './_common';\nimport { useInputAttributes } from './contexts';\n\nexport interface TextAreaProps extends Merge<\n React.ComponentPropsWithRef<'textarea'>,\n {\n 'aria-invalid'?: boolean;\n }\n> {}\n\nexport const TextArea = forwardRef(function TextArea(\n { className, ...restProps }: TextAreaProps,\n reference: React.ForwardedRef<HTMLTextAreaElement | null>,\n) {\n const inputAttributes = useInputAttributes();\n\n return (\n <textarea\n ref={reference}\n className={clsx(className, inputClassNameBase(), 'np-text-area')}\n {...inputAttributes}\n {...restProps}\n />\n );\n});\n"],"names":["TextArea","forwardRef","className","restProps","reference","inputAttributes","useInputAttributes","_jsx","ref","clsx","inputClassNameBase"],"mappings":";;;;;;MAcaA,QAAQ,gBAAGC,UAAU,CAAC,SAASD,QAAQA,CAClD;EAAEE,SAAS;EAAE,GAAGC;AAAS,CAAiB,EAC1CC,SAAyD,EAAA;AAEzD,EAAA,MAAMC,eAAe,GAAGC,kBAAkB,EAAE;AAE5C,EAAA,oBACEC,GAAA,CAAA,UAAA,EAAA;AACEC,IAAAA,GAAG,EAAEJ,SAAU;IACfF,SAAS,EAAEO,IAAI,CAACP,SAAS,EAAEQ,kBAAkB,EAAE,EAAE,cAAc,CAAE;AAAA,IAAA,GAC7DL,eAAe;IAAA,GACfF;AAAS,GAAC,CACd;AAEN,CAAC;;;;"}
|