@transferwise/components 0.0.0-experimental-8d46704 → 0.0.0-experimental-c8ab32e
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 +13 -4
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +13 -4
- package/build/field/Field.mjs.map +1 -1
- package/build/i18n/en.json +3 -1
- package/build/i18n/en.json.js +3 -1
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +3 -1
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/inputs/SelectInput.js +33 -51
- package/build/inputs/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput.mjs +34 -52
- package/build/inputs/SelectInput.mjs.map +1 -1
- package/build/label/Label.js +29 -1
- package/build/label/Label.js.map +1 -1
- package/build/label/Label.messages.js +15 -0
- package/build/label/Label.messages.js.map +1 -0
- package/build/label/Label.messages.mjs +13 -0
- package/build/label/Label.messages.mjs.map +1 -0
- package/build/label/Label.mjs +30 -2
- package/build/label/Label.mjs.map +1 -1
- package/build/main.css +0 -3
- package/build/styles/inputs/SelectInput.css +0 -3
- package/build/styles/main.css +0 -3
- package/build/types/field/Field.d.ts +4 -2
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/label/Label.d.ts +10 -1
- package/build/types/label/Label.d.ts.map +1 -1
- package/build/types/label/Label.messages.d.ts +12 -0
- package/build/types/label/Label.messages.d.ts.map +1 -0
- package/build/types/label/index.d.ts +3 -0
- package/build/types/label/index.d.ts.map +1 -0
- package/package.json +4 -5
- package/src/dateInput/DateInput.story.tsx +6 -1
- package/src/dateLookup/DateLookup.rtl.spec.tsx +1 -1
- package/src/field/Field.spec.tsx +4 -3
- package/src/field/Field.story.tsx +38 -4
- package/src/field/Field.tests.story.tsx +4 -2
- package/src/field/Field.tsx +17 -8
- package/src/i18n/en.json +3 -1
- package/src/index.ts +1 -1
- package/src/inlineAlert/InlineAlert.story.tsx +11 -14
- package/src/inputs/InputGroup.spec.tsx +1 -1
- package/src/inputs/SearchInput.spec.tsx +1 -1
- package/src/inputs/SelectInput.css +0 -3
- package/src/inputs/SelectInput.less +0 -4
- package/src/inputs/SelectInput.spec.tsx +1 -1
- package/src/inputs/SelectInput.story.tsx +0 -20
- package/src/inputs/SelectInput.tsx +40 -82
- package/src/label/Label.messages.tsx +12 -0
- package/src/label/Label.story.tsx +37 -21
- package/src/label/Label.tsx +42 -2
- package/src/label/index.ts +2 -0
- package/src/main.css +0 -3
- package/src/radioGroup/RadioGroup.rtl.spec.tsx +1 -1
- package/src/select/Select.rtl.spec.tsx +1 -1
- package/src/switch/Switch.spec.tsx +1 -1
package/build/field/Field.js
CHANGED
|
@@ -15,15 +15,20 @@ var classNames__default = /*#__PURE__*/_interopDefault(classNames);
|
|
|
15
15
|
const Field = ({
|
|
16
16
|
id,
|
|
17
17
|
label,
|
|
18
|
+
required = false,
|
|
18
19
|
message: propMessage,
|
|
20
|
+
description: propDescription,
|
|
19
21
|
sentiment: propType = sentiment.Sentiment.NEUTRAL,
|
|
20
22
|
className,
|
|
21
23
|
children,
|
|
22
24
|
...props
|
|
23
25
|
}) => {
|
|
24
26
|
const sentiment$1 = props.error ? sentiment.Sentiment.NEGATIVE : propType;
|
|
25
|
-
const message = props.error || props.hint
|
|
27
|
+
const message = propMessage || props.error || props.hint;
|
|
26
28
|
const hasError = sentiment$1 === sentiment.Sentiment.NEGATIVE;
|
|
29
|
+
const hasInfo = sentiment$1 === sentiment.Sentiment.NEUTRAL && (!!props.hint || !!message);
|
|
30
|
+
const description = propDescription || hasInfo && (props.hint || message);
|
|
31
|
+
console.log('hasInfo', hasInfo, 'description', description);
|
|
27
32
|
const labelId = React.useId();
|
|
28
33
|
const fallbackInputId = React.useId();
|
|
29
34
|
const inputId = id !== null ? id ?? fallbackInputId : undefined;
|
|
@@ -41,13 +46,17 @@ const Field = ({
|
|
|
41
46
|
'has-success': sentiment$1 === sentiment.Sentiment.POSITIVE,
|
|
42
47
|
'has-warning': sentiment$1 === sentiment.Sentiment.WARNING,
|
|
43
48
|
'has-error': hasError,
|
|
44
|
-
'has-info':
|
|
49
|
+
'has-info': hasInfo
|
|
45
50
|
}, className),
|
|
46
51
|
children: [label != null ? /*#__PURE__*/jsxRuntime.jsxs(Label.Label, {
|
|
47
52
|
id: labelId,
|
|
48
53
|
htmlFor: inputId,
|
|
49
|
-
children: [label,
|
|
50
|
-
|
|
54
|
+
children: [required ? label : /*#__PURE__*/jsxRuntime.jsx(Label.Label.Optional, {
|
|
55
|
+
children: label
|
|
56
|
+
}), description && /*#__PURE__*/jsxRuntime.jsx(Label.Label.Description, {
|
|
57
|
+
children: description
|
|
58
|
+
}), children]
|
|
59
|
+
}) : children, message && !hasInfo && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
51
60
|
type: sentiment$1,
|
|
52
61
|
id: descriptionId,
|
|
53
62
|
children: message
|
package/build/field/Field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sources":["../../src/field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useId } from 'react';\n\nimport { Sentiment } from '../common';\nimport InlineAlert from '../inlineAlert/InlineAlert';\nimport {\n FieldLabelIdContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label
|
|
1
|
+
{"version":3,"file":"Field.js","sources":["../../src/field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ReactNode, useId } from 'react';\n\nimport { Sentiment } from '../common';\nimport InlineAlert from '../inlineAlert/InlineAlert';\nimport {\n FieldLabelIdContextProvider,\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 required?: boolean;\n /** @deprecated use `description` prop instead */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n description?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */\n error?: React.ReactNode;\n sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = false,\n message: propMessage,\n description: propDescription,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error || props.hint;\n const hasError = sentiment === Sentiment.NEGATIVE;\n const hasInfo: boolean = sentiment === Sentiment.NEUTRAL && (!!props.hint || !!message);\n const description: ReactNode = propDescription || (hasInfo && (props.hint || message));\n\n console.log('hasInfo', hasInfo, 'description', description);\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const descriptionId = useId();\n\n return (\n <FieldLabelIdContextProvider value={labelId}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={message ? descriptionId : undefined}>\n <InputInvalidProvider value={hasError}>\n <div\n className={classNames(\n 'form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': hasInfo,\n },\n className,\n )}\n >\n {label != null ? (\n <Label id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n {description && <Label.Description>{description}</Label.Description>}\n {children}\n </Label>\n ) : (\n children\n )}\n\n {message && !hasInfo && (\n <InlineAlert type={sentiment} id={descriptionId}>\n {message}\n </InlineAlert>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelIdContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","description","propDescription","sentiment","propType","Sentiment","NEUTRAL","className","children","props","error","NEGATIVE","hint","hasError","hasInfo","console","log","labelId","useId","fallbackInputId","inputId","undefined","descriptionId","_jsx","FieldLabelIdContextProvider","value","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","classNames","POSITIVE","WARNING","Label","htmlFor","Optional","Description","InlineAlert","type"],"mappings":";;;;;;;;;;;;;;AA8BO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,OAAO,EAAEC,WAAW;AACpBC,EAAAA,WAAW,EAAEC,eAAe;AAC5BC,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,mBAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC,KAAAA;AAAK,CACG,KAAI;EACf,MAAMN,WAAS,GAAGM,KAAK,CAACC,KAAK,GAAGL,mBAAS,CAACM,QAAQ,GAAGP,QAAQ,CAAA;EAC7D,MAAML,OAAO,GAAGC,WAAW,IAAIS,KAAK,CAACC,KAAK,IAAID,KAAK,CAACG,IAAI,CAAA;AACxD,EAAA,MAAMC,QAAQ,GAAGV,WAAS,KAAKE,mBAAS,CAACM,QAAQ,CAAA;AACjD,EAAA,MAAMG,OAAO,GAAYX,WAAS,KAAKE,mBAAS,CAACC,OAAO,KAAK,CAAC,CAACG,KAAK,CAACG,IAAI,IAAI,CAAC,CAACb,OAAO,CAAC,CAAA;EACvF,MAAME,WAAW,GAAcC,eAAe,IAAKY,OAAO,KAAKL,KAAK,CAACG,IAAI,IAAIb,OAAO,CAAE,CAAA;EAEtFgB,OAAO,CAACC,GAAG,CAAC,SAAS,EAAEF,OAAO,EAAE,aAAa,EAAEb,WAAW,CAAC,CAAA;AAE3D,EAAA,MAAM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WAAK,CAACG,WAAW,EAAA;AAAA5B,gBAAAA,QAAA,EAAEP,WAAAA;eAA+B,CAAC,EACnEO,QAAQ,CAAA;aACJ,CAAC,GAERA,QACD,EAEAT,OAAO,IAAI,CAACe,OAAO,iBAClBS,cAAA,CAACc,WAAW,EAAA;AAACC,cAAAA,IAAI,EAAEnC,WAAU;AAACP,cAAAA,EAAE,EAAE0B,aAAc;AAAAd,cAAAA,QAAA,EAC7CT,OAAAA;AAAO,aACG,CACd,CAAA;WACE,CAAA;SACe,CAAA;OACE,CAAA;KACJ,CAAA;AAC1B,GAA6B,CAAC,CAAA;AAElC;;;;"}
|
package/build/field/Field.mjs
CHANGED
|
@@ -9,15 +9,20 @@ import { Sentiment } from '../common/propsValues/sentiment.mjs';
|
|
|
9
9
|
const Field = ({
|
|
10
10
|
id,
|
|
11
11
|
label,
|
|
12
|
+
required = false,
|
|
12
13
|
message: propMessage,
|
|
14
|
+
description: propDescription,
|
|
13
15
|
sentiment: propType = Sentiment.NEUTRAL,
|
|
14
16
|
className,
|
|
15
17
|
children,
|
|
16
18
|
...props
|
|
17
19
|
}) => {
|
|
18
20
|
const sentiment = props.error ? Sentiment.NEGATIVE : propType;
|
|
19
|
-
const message = props.error || props.hint
|
|
21
|
+
const message = propMessage || props.error || props.hint;
|
|
20
22
|
const hasError = sentiment === Sentiment.NEGATIVE;
|
|
23
|
+
const hasInfo = sentiment === Sentiment.NEUTRAL && (!!props.hint || !!message);
|
|
24
|
+
const description = propDescription || hasInfo && (props.hint || message);
|
|
25
|
+
console.log('hasInfo', hasInfo, 'description', description);
|
|
21
26
|
const labelId = useId();
|
|
22
27
|
const fallbackInputId = useId();
|
|
23
28
|
const inputId = id !== null ? id ?? fallbackInputId : undefined;
|
|
@@ -35,13 +40,17 @@ const Field = ({
|
|
|
35
40
|
'has-success': sentiment === Sentiment.POSITIVE,
|
|
36
41
|
'has-warning': sentiment === Sentiment.WARNING,
|
|
37
42
|
'has-error': hasError,
|
|
38
|
-
'has-info':
|
|
43
|
+
'has-info': hasInfo
|
|
39
44
|
}, className),
|
|
40
45
|
children: [label != null ? /*#__PURE__*/jsxs(Label, {
|
|
41
46
|
id: labelId,
|
|
42
47
|
htmlFor: inputId,
|
|
43
|
-
children: [label,
|
|
44
|
-
|
|
48
|
+
children: [required ? label : /*#__PURE__*/jsx(Label.Optional, {
|
|
49
|
+
children: label
|
|
50
|
+
}), description && /*#__PURE__*/jsx(Label.Description, {
|
|
51
|
+
children: description
|
|
52
|
+
}), children]
|
|
53
|
+
}) : children, message && !hasInfo && /*#__PURE__*/jsx(InlineAlert, {
|
|
45
54
|
type: sentiment,
|
|
46
55
|
id: descriptionId,
|
|
47
56
|
children: message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.mjs","sources":["../../src/field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useId } from 'react';\n\nimport { Sentiment } from '../common';\nimport InlineAlert from '../inlineAlert/InlineAlert';\nimport {\n FieldLabelIdContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label
|
|
1
|
+
{"version":3,"file":"Field.mjs","sources":["../../src/field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ReactNode, useId } from 'react';\n\nimport { Sentiment } from '../common';\nimport InlineAlert from '../inlineAlert/InlineAlert';\nimport {\n FieldLabelIdContextProvider,\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 required?: boolean;\n /** @deprecated use `description` prop instead */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n description?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */\n error?: React.ReactNode;\n sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = false,\n message: propMessage,\n description: propDescription,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error || props.hint;\n const hasError = sentiment === Sentiment.NEGATIVE;\n const hasInfo: boolean = sentiment === Sentiment.NEUTRAL && (!!props.hint || !!message);\n const description: ReactNode = propDescription || (hasInfo && (props.hint || message));\n\n console.log('hasInfo', hasInfo, 'description', description);\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const descriptionId = useId();\n\n return (\n <FieldLabelIdContextProvider value={labelId}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={message ? descriptionId : undefined}>\n <InputInvalidProvider value={hasError}>\n <div\n className={classNames(\n 'form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': hasInfo,\n },\n className,\n )}\n >\n {label != null ? (\n <Label id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n {description && <Label.Description>{description}</Label.Description>}\n {children}\n </Label>\n ) : (\n children\n )}\n\n {message && !hasInfo && (\n <InlineAlert type={sentiment} id={descriptionId}>\n {message}\n </InlineAlert>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelIdContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","description","propDescription","sentiment","propType","Sentiment","NEUTRAL","className","children","props","error","NEGATIVE","hint","hasError","hasInfo","console","log","labelId","useId","fallbackInputId","inputId","undefined","descriptionId","_jsx","FieldLabelIdContextProvider","value","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","classNames","POSITIVE","WARNING","Label","htmlFor","Optional","Description","InlineAlert","type"],"mappings":";;;;;;;;AA8BO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,OAAO,EAAEC,WAAW;AACpBC,EAAAA,WAAW,EAAEC,eAAe;AAC5BC,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,SAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC,KAAAA;AAAK,CACG,KAAI;EACf,MAAMN,SAAS,GAAGM,KAAK,CAACC,KAAK,GAAGL,SAAS,CAACM,QAAQ,GAAGP,QAAQ,CAAA;EAC7D,MAAML,OAAO,GAAGC,WAAW,IAAIS,KAAK,CAACC,KAAK,IAAID,KAAK,CAACG,IAAI,CAAA;AACxD,EAAA,MAAMC,QAAQ,GAAGV,SAAS,KAAKE,SAAS,CAACM,QAAQ,CAAA;AACjD,EAAA,MAAMG,OAAO,GAAYX,SAAS,KAAKE,SAAS,CAACC,OAAO,KAAK,CAAC,CAACG,KAAK,CAACG,IAAI,IAAI,CAAC,CAACb,OAAO,CAAC,CAAA;EACvF,MAAME,WAAW,GAAcC,eAAe,IAAKY,OAAO,KAAKL,KAAK,CAACG,IAAI,IAAIb,OAAO,CAAE,CAAA;EAEtFgB,OAAO,CAACC,GAAG,CAAC,SAAS,EAAEF,OAAO,EAAE,aAAa,EAAEb,WAAW,CAAC,CAAA;AAE3D,EAAA,MAAMgB,OAAO,GAAGC,KAAK,EAAE,CAAA;AAEvB,EAAA,MAAMC,eAAe,GAAGD,KAAK,EAAE,CAAA;EAC/B,MAAME,OAAO,GAAGxB,EAAE,KAAK,IAAI,GAAIA,EAAE,IAAIuB,eAAe,GAAIE,SAAS,CAAA;AAEjE,EAAA,MAAMC,aAAa,GAAGJ,KAAK,EAAE,CAAA;EAE7B,oBACE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;AAAAd,cAAAA,QAAA,EAC7CT,OAAAA;AAAO,aACG,CACd,CAAA;WACE,CAAA;SACe,CAAA;OACE,CAAA;KACJ,CAAA;AAC1B,GAA6B,CAAC,CAAA;AAElC;;;;"}
|
package/build/i18n/en.json
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"neptune.DateLookup.year": "year",
|
|
19
19
|
"neptune.FlowNavigation.back": "back to previous step",
|
|
20
20
|
"neptune.Info.ariaLabel": "More information",
|
|
21
|
+
"neptune.Label.optional": "(Optional)",
|
|
21
22
|
"neptune.Link.opensInNewTab": "(opens in new tab)",
|
|
22
23
|
"neptune.MoneyInput.Select.placeholder": "Select an option...",
|
|
23
24
|
"neptune.PhoneNumberInput.SelectInput.placeholder": "Select an option...",
|
|
@@ -55,5 +56,6 @@
|
|
|
55
56
|
"neptune.UploadItem.uploaded": "Uploaded",
|
|
56
57
|
"neptune.UploadItem.uploadedFile": "Uploaded file",
|
|
57
58
|
"neptune.UploadItem.uploading": "Uploading...",
|
|
58
|
-
"neptune.UploadItem.uploadingFailed": "Uploading failed"
|
|
59
|
+
"neptune.UploadItem.uploadingFailed": "Uploading failed",
|
|
60
|
+
"neptune.aria.Label.optional": "This field is optional"
|
|
59
61
|
}
|
package/build/i18n/en.json.js
CHANGED
|
@@ -20,6 +20,7 @@ var en = {
|
|
|
20
20
|
"neptune.DateLookup.year": "year",
|
|
21
21
|
"neptune.FlowNavigation.back": "back to previous step",
|
|
22
22
|
"neptune.Info.ariaLabel": "More information",
|
|
23
|
+
"neptune.Label.optional": "(Optional)",
|
|
23
24
|
"neptune.Link.opensInNewTab": "(opens in new tab)",
|
|
24
25
|
"neptune.MoneyInput.Select.placeholder": "Select an option...",
|
|
25
26
|
"neptune.PhoneNumberInput.SelectInput.placeholder": "Select an option...",
|
|
@@ -57,7 +58,8 @@ var en = {
|
|
|
57
58
|
"neptune.UploadItem.uploaded": "Uploaded",
|
|
58
59
|
"neptune.UploadItem.uploadedFile": "Uploaded file",
|
|
59
60
|
"neptune.UploadItem.uploading": "Uploading...",
|
|
60
|
-
"neptune.UploadItem.uploadingFailed": "Uploading failed"
|
|
61
|
+
"neptune.UploadItem.uploadingFailed": "Uploading failed",
|
|
62
|
+
"neptune.aria.Label.optional": "This field is optional"
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
module.exports = en;
|
|
@@ -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
|
@@ -18,6 +18,7 @@ var en = {
|
|
|
18
18
|
"neptune.DateLookup.year": "year",
|
|
19
19
|
"neptune.FlowNavigation.back": "back to previous step",
|
|
20
20
|
"neptune.Info.ariaLabel": "More information",
|
|
21
|
+
"neptune.Label.optional": "(Optional)",
|
|
21
22
|
"neptune.Link.opensInNewTab": "(opens in new tab)",
|
|
22
23
|
"neptune.MoneyInput.Select.placeholder": "Select an option...",
|
|
23
24
|
"neptune.PhoneNumberInput.SelectInput.placeholder": "Select an option...",
|
|
@@ -55,7 +56,8 @@ var en = {
|
|
|
55
56
|
"neptune.UploadItem.uploaded": "Uploaded",
|
|
56
57
|
"neptune.UploadItem.uploadedFile": "Uploaded file",
|
|
57
58
|
"neptune.UploadItem.uploading": "Uploading...",
|
|
58
|
-
"neptune.UploadItem.uploadingFailed": "Uploading failed"
|
|
59
|
+
"neptune.UploadItem.uploadingFailed": "Uploading failed",
|
|
60
|
+
"neptune.aria.Label.optional": "This field is optional"
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
export { en as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -6,7 +6,6 @@ var classNames = require('classnames');
|
|
|
6
6
|
var mergeProps = require('merge-props');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var reactIntl = require('react-intl');
|
|
9
|
-
var virtua = require('virtua');
|
|
10
9
|
var useEffectEvent = require('../common/hooks/useEffectEvent.js');
|
|
11
10
|
var useScreenSize = require('../common/hooks/useScreenSize.js');
|
|
12
11
|
var PolymorphicWithOverrides = require('../common/polymorphicWithOverrides/PolymorphicWithOverrides.js');
|
|
@@ -26,7 +25,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
26
25
|
var classNames__default = /*#__PURE__*/_interopDefault(classNames);
|
|
27
26
|
var mergeProps__default = /*#__PURE__*/_interopDefault(mergeProps);
|
|
28
27
|
|
|
29
|
-
const MAX_ITEMS_WITHOUT_VIRTUALIZATION = 50;
|
|
30
28
|
function searchableString(value) {
|
|
31
29
|
return value.trim().replace(/\s+/gu, ' ').normalize('NFKC').toLowerCase();
|
|
32
30
|
}
|
|
@@ -70,19 +68,19 @@ function dedupeSelectInputItems(items) {
|
|
|
70
68
|
return item;
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
|
-
function
|
|
71
|
+
function filterSelectInputOptionItem(item, needle) {
|
|
74
72
|
return inferSearchableStrings(item.filterMatchers ?? item.value).some(haystack => haystack.includes(needle));
|
|
75
73
|
}
|
|
76
|
-
function filterSelectInputItems(items,
|
|
74
|
+
function filterSelectInputItems(items, needle) {
|
|
77
75
|
return items.filter(item => {
|
|
78
76
|
switch (item.type) {
|
|
79
77
|
case 'option':
|
|
80
78
|
{
|
|
81
|
-
return
|
|
79
|
+
return filterSelectInputOptionItem(item, needle);
|
|
82
80
|
}
|
|
83
81
|
case 'group':
|
|
84
82
|
{
|
|
85
|
-
return item.options.some(option =>
|
|
83
|
+
return item.options.some(option => filterSelectInputOptionItem(option, needle));
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
return false;
|
|
@@ -183,15 +181,12 @@ function SelectInput({
|
|
|
183
181
|
}
|
|
184
182
|
}, [handleClose, open]);
|
|
185
183
|
const [filterQuery, _setFilterQuery] = React.useState('');
|
|
186
|
-
const deferredFilterQuery = React.useDeferredValue(filterQuery);
|
|
187
184
|
const setFilterQuery = useEffectEvent.useEffectEvent(query => {
|
|
188
185
|
_setFilterQuery(query);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
});
|
|
194
|
-
}
|
|
186
|
+
onFilterChange({
|
|
187
|
+
query,
|
|
188
|
+
queryNormalized: query ? searchableString(query) : null
|
|
189
|
+
});
|
|
195
190
|
});
|
|
196
191
|
const triggerRef = React.useRef(null);
|
|
197
192
|
const screenSm = useScreenSize.useScreenSize(breakpoint.Breakpoint.SMALL);
|
|
@@ -203,7 +198,10 @@ function SelectInput({
|
|
|
203
198
|
name: name,
|
|
204
199
|
multiple: multiple,
|
|
205
200
|
defaultValue: defaultValue,
|
|
206
|
-
value: controlledValue
|
|
201
|
+
value: controlledValue
|
|
202
|
+
// TODO: Remove assertion when upgrading TypeScript to v5
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
204
|
+
,
|
|
207
205
|
by: compareValues,
|
|
208
206
|
disabled: disabled,
|
|
209
207
|
onChange: value => {
|
|
@@ -268,7 +266,9 @@ function SelectInput({
|
|
|
268
266
|
setOpen(false);
|
|
269
267
|
},
|
|
270
268
|
onCloseEnd: () => {
|
|
271
|
-
|
|
269
|
+
if (filterQuery !== '') {
|
|
270
|
+
setFilterQuery('');
|
|
271
|
+
}
|
|
272
272
|
},
|
|
273
273
|
children: /*#__PURE__*/jsxRuntime.jsx(SelectInputOptions, {
|
|
274
274
|
items: items,
|
|
@@ -278,8 +278,7 @@ function SelectInput({
|
|
|
278
278
|
filterPlaceholder: filterPlaceholder,
|
|
279
279
|
searchInputRef: searchInputRef,
|
|
280
280
|
listboxRef: listboxRef,
|
|
281
|
-
|
|
282
|
-
filterQuery: deferredFilterQuery,
|
|
281
|
+
filterQuery: filterQuery,
|
|
283
282
|
onFilterChange: setFilterQuery
|
|
284
283
|
})
|
|
285
284
|
});
|
|
@@ -352,7 +351,6 @@ function SelectInputOptions({
|
|
|
352
351
|
filterPlaceholder,
|
|
353
352
|
searchInputRef,
|
|
354
353
|
listboxRef,
|
|
355
|
-
value,
|
|
356
354
|
filterQuery,
|
|
357
355
|
onFilterChange
|
|
358
356
|
}) {
|
|
@@ -364,8 +362,7 @@ function SelectInputOptions({
|
|
|
364
362
|
}
|
|
365
363
|
return undefined;
|
|
366
364
|
}, [filterQuery, filterable]);
|
|
367
|
-
const
|
|
368
|
-
const resultsEmpty = needle != null && filteredItems.length === 0;
|
|
365
|
+
const resultsEmpty = needle != null && filterSelectInputItems(items, needle).length === 0;
|
|
369
366
|
const listboxContainerRef = React.useRef(null);
|
|
370
367
|
React.useEffect(() => {
|
|
371
368
|
if (listboxContainerRef.current != null) {
|
|
@@ -375,22 +372,6 @@ function SelectInputOptions({
|
|
|
375
372
|
const showStatus = resultsEmpty;
|
|
376
373
|
const statusId = React.useId();
|
|
377
374
|
const listboxId = React.useId();
|
|
378
|
-
const virtualized = filteredItems.length > MAX_ITEMS_WITHOUT_VIRTUALIZATION;
|
|
379
|
-
const values = React.useMemo(() => new Set(Array.isArray(value) ? value : [value]), [value]);
|
|
380
|
-
const listboxProps = {
|
|
381
|
-
id: listboxId,
|
|
382
|
-
role: 'listbox',
|
|
383
|
-
'aria-orientation': 'vertical',
|
|
384
|
-
tabIndex: 0,
|
|
385
|
-
className: 'np-select-input-listbox',
|
|
386
|
-
children: (needle != null ? dedupeSelectInputItems(items) : items).map((item, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
|
|
387
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
388
|
-
, {
|
|
389
|
-
item: item,
|
|
390
|
-
renderValue: renderValue,
|
|
391
|
-
needle: needle
|
|
392
|
-
}, index))
|
|
393
|
-
};
|
|
394
375
|
return /*#__PURE__*/jsxRuntime.jsxs(react.Listbox.Options, {
|
|
395
376
|
as: SelectInputOptionsContainer,
|
|
396
377
|
static: true,
|
|
@@ -417,7 +398,7 @@ function SelectInputOptions({
|
|
|
417
398
|
ref: searchInputRef,
|
|
418
399
|
shape: "rectangle",
|
|
419
400
|
placeholder: filterPlaceholder,
|
|
420
|
-
|
|
401
|
+
value: filterQuery,
|
|
421
402
|
"aria-controls": listboxId,
|
|
422
403
|
"aria-describedby": showStatus ? statusId : undefined,
|
|
423
404
|
onKeyDown: event => {
|
|
@@ -434,7 +415,7 @@ function SelectInputOptions({
|
|
|
434
415
|
}) : null, /*#__PURE__*/jsxRuntime.jsxs("section", {
|
|
435
416
|
ref: listboxContainerRef,
|
|
436
417
|
tabIndex: -1,
|
|
437
|
-
className: classNames__default.default('np-select-input-listbox-container',
|
|
418
|
+
className: classNames__default.default('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
|
|
438
419
|
children: [resultsEmpty ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
439
420
|
id: statusId,
|
|
440
421
|
className: "np-select-input-options-status",
|
|
@@ -442,19 +423,20 @@ function SelectInputOptions({
|
|
|
442
423
|
size: 16,
|
|
443
424
|
className: "np-select-input-options-status-icon"
|
|
444
425
|
}), intl.formatMessage(SelectInput_messages.noResultsFound)]
|
|
445
|
-
}) : null,
|
|
426
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
446
427
|
ref: listboxRef,
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
428
|
+
id: listboxId,
|
|
429
|
+
role: "listbox",
|
|
430
|
+
"aria-orientation": "vertical",
|
|
431
|
+
tabIndex: 0,
|
|
432
|
+
className: "np-select-input-listbox",
|
|
433
|
+
children: (needle != null ? dedupeSelectInputItems(items) : items).map((item, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
|
|
434
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
435
|
+
, {
|
|
436
|
+
item: item,
|
|
437
|
+
renderValue: renderValue,
|
|
438
|
+
needle: needle
|
|
439
|
+
}, index))
|
|
458
440
|
}), renderFooter != null ? /*#__PURE__*/jsxRuntime.jsx("footer", {
|
|
459
441
|
className: "np-select-input-footer",
|
|
460
442
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -482,7 +464,7 @@ function SelectInputItemView({
|
|
|
482
464
|
switch (item.type) {
|
|
483
465
|
case 'option':
|
|
484
466
|
{
|
|
485
|
-
if (item.value != null && (needle == null ||
|
|
467
|
+
if (item.value != null && (needle == null || filterSelectInputOptionItem(item, needle))) {
|
|
486
468
|
return /*#__PURE__*/jsxRuntime.jsx(SelectInputOption, {
|
|
487
469
|
value: item.value,
|
|
488
470
|
disabled: item.disabled,
|