@transferwise/components 0.0.0-experimental-333df2c → 0.0.0-experimental-e4e09f5
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/dateLookup/dateTrigger/DateTrigger.js +8 -4
- package/build/dateLookup/dateTrigger/DateTrigger.js.map +1 -1
- package/build/dateLookup/dateTrigger/DateTrigger.mjs +8 -4
- package/build/dateLookup/dateTrigger/DateTrigger.mjs.map +1 -1
- package/build/field/Field.js +9 -2
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +9 -2
- 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 +34 -86
- package/build/inputs/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput.mjs +36 -88
- 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 -18
- package/build/styles/dateLookup/dateTrigger/DateTrigger.css +0 -8
- package/build/styles/inputs/SelectInput.css +0 -10
- package/build/styles/main.css +0 -18
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
- 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.tests.story.tsx +8 -32
- package/src/dateLookup/DateLookup.rtl.spec.tsx +1 -1
- package/src/dateLookup/dateTrigger/DateTrigger.css +0 -8
- package/src/dateLookup/dateTrigger/DateTrigger.less +0 -8
- package/src/dateLookup/dateTrigger/DateTrigger.spec.js +1 -1
- package/src/dateLookup/dateTrigger/DateTrigger.tsx +9 -4
- package/src/field/Field.spec.tsx +3 -3
- package/src/field/Field.story.tsx +81 -3
- package/src/field/Field.tsx +10 -4
- package/src/i18n/en.json +3 -1
- package/src/index.ts +1 -1
- package/src/inlineAlert/InlineAlert.story.tsx +8 -21
- package/src/inputs/InputGroup.spec.tsx +1 -1
- package/src/inputs/SearchInput.spec.tsx +1 -1
- package/src/inputs/SelectInput.css +0 -10
- package/src/inputs/SelectInput.less +0 -12
- package/src/inputs/SelectInput.spec.tsx +1 -1
- package/src/inputs/SelectInput.story.tsx +0 -20
- package/src/inputs/SelectInput.tsx +37 -116
- package/src/label/Label.messages.tsx +12 -0
- package/src/label/Label.story.tsx +30 -21
- package/src/label/Label.tsx +43 -2
- package/src/label/index.ts +2 -0
- package/src/main.css +0 -18
- 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/src/field/Field.tests.story.tsx +0 -33
|
@@ -7,7 +7,9 @@ var CloseButton = require('../../common/closeButton/CloseButton.js');
|
|
|
7
7
|
var DateTrigger_messages = require('./DateTrigger.messages.js');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var OverlayIdProvider = require('../../provider/overlay/OverlayIdProvider.js');
|
|
10
|
+
var Body = require('../../body/Body.js');
|
|
10
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
+
var typography = require('../../common/propsValues/typography.js');
|
|
11
13
|
var position = require('../../common/propsValues/position.js');
|
|
12
14
|
var size = require('../../common/propsValues/size.js');
|
|
13
15
|
|
|
@@ -35,11 +37,13 @@ const DateTrigger = ({
|
|
|
35
37
|
disabled: disabled,
|
|
36
38
|
type: "button",
|
|
37
39
|
onClick: onClick,
|
|
38
|
-
children: [label && /*#__PURE__*/jsxRuntime.jsx(
|
|
39
|
-
|
|
40
|
+
children: [label && /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
41
|
+
as: "span",
|
|
42
|
+
className: "np-date-trigger-label m-r-1",
|
|
40
43
|
children: label
|
|
41
|
-
}), selectedDate ? /*#__PURE__*/jsxRuntime.jsx(
|
|
42
|
-
|
|
44
|
+
}), selectedDate ? /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
45
|
+
as: "span",
|
|
46
|
+
type: typography.Typography.BODY_LARGE,
|
|
43
47
|
children: formatting.formatDate(selectedDate, locale, {
|
|
44
48
|
day: 'numeric',
|
|
45
49
|
month: monthFormat,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTrigger.js","sources":["../../../src/dateLookup/dateTrigger/DateTrigger.tsx"],"sourcesContent":["import { formatDate } from '@transferwise/formatting';\nimport { useIntl } from 'react-intl';\n\nimport Chevron from '../../chevron';\nimport { Size, Position, SizeSmall, SizeMedium, SizeLarge } from '../../common';\nimport { CloseButton } from '../../common/closeButton/CloseButton';\n\nimport messages from './DateTrigger.messages';\nimport { useContext } from 'react';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\ninterface DateTriggerProps {\n selectedDate: Date | null;\n size: SizeSmall | SizeMedium | SizeLarge;\n placeholder: string;\n label: string;\n monthFormat: 'short' | 'long';\n disabled: boolean;\n onClick: () => void;\n onClear?: () => void;\n}\n\nconst DateTrigger: React.FC<DateTriggerProps> = ({\n selectedDate,\n size = Size.MEDIUM,\n placeholder,\n label,\n monthFormat,\n disabled,\n onClick,\n onClear,\n}) => {\n const { locale, formatMessage } = useIntl();\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <>\n <button\n aria-haspopup=\"dialog\"\n aria-expanded={overlayId != null}\n aria-controls={overlayId}\n className={`btn btn-${size} btn-input np-date-trigger`}\n disabled={disabled}\n type=\"button\"\n onClick={onClick}\n >\n {label && <span className=\"
|
|
1
|
+
{"version":3,"file":"DateTrigger.js","sources":["../../../src/dateLookup/dateTrigger/DateTrigger.tsx"],"sourcesContent":["import { formatDate } from '@transferwise/formatting';\nimport { useIntl } from 'react-intl';\n\nimport Chevron from '../../chevron';\nimport { Size, Position, SizeSmall, SizeMedium, SizeLarge, Typography } from '../../common';\nimport { CloseButton } from '../../common/closeButton/CloseButton';\n\nimport messages from './DateTrigger.messages';\nimport { useContext } from 'react';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\nimport Body from '../../body';\n\ninterface DateTriggerProps {\n selectedDate: Date | null;\n size: SizeSmall | SizeMedium | SizeLarge;\n placeholder: string;\n label: string;\n monthFormat: 'short' | 'long';\n disabled: boolean;\n onClick: () => void;\n onClear?: () => void;\n}\n\nconst DateTrigger: React.FC<DateTriggerProps> = ({\n selectedDate,\n size = Size.MEDIUM,\n placeholder,\n label,\n monthFormat,\n disabled,\n onClick,\n onClear,\n}) => {\n const { locale, formatMessage } = useIntl();\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <>\n <button\n aria-haspopup=\"dialog\"\n aria-expanded={overlayId != null}\n aria-controls={overlayId}\n className={`btn btn-${size} btn-input np-date-trigger`}\n disabled={disabled}\n type=\"button\"\n onClick={onClick}\n >\n {label && (\n <Body as=\"span\" className=\"np-date-trigger-label m-r-1\">\n {label}\n </Body>\n )}\n {selectedDate ? (\n <Body as=\"span\" type={Typography.BODY_LARGE}>\n {formatDate(selectedDate, locale, {\n day: 'numeric',\n month: monthFormat,\n year: 'numeric',\n })}\n </Body>\n ) : (\n <span\n className=\"form-control-placeholder visible-xs-inline visible-sm-inline\n visible-md-inline visible-lg-inline visible-xl-inline\"\n >\n {placeholder}\n </span>\n )}\n {!onClear ? <Chevron orientation={Position.BOTTOM} disabled={disabled} /> : null}\n </button>\n {onClear ? (\n <>\n <div className=\"clearfix\" />\n <span className=\"input-group-addon\">\n <CloseButton\n className={`clear-btn clear-btn--${size}`}\n aria-label={`${formatMessage(messages.ariaLabel)} ${label}`}\n size={Size.SMALL}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n event.preventDefault();\n onClear();\n }}\n />\n </span>\n </>\n ) : null}\n </>\n );\n};\n\nexport default DateTrigger;\n"],"names":["DateTrigger","selectedDate","size","Size","MEDIUM","placeholder","label","monthFormat","disabled","onClick","onClear","locale","formatMessage","useIntl","overlayId","useContext","OverlayIdContext","_jsxs","_Fragment","children","className","type","_jsx","Body","as","Typography","BODY_LARGE","formatDate","day","month","year","Chevron","orientation","Position","BOTTOM","CloseButton","messages","ariaLabel","SMALL","event","stopPropagation","preventDefault"],"mappings":";;;;;;;;;;;;;;;AAuBMA,MAAAA,WAAW,GAA+BA,CAAC;EAC/CC,YAAY;QACZC,MAAI,GAAGC,SAAI,CAACC,MAAM;EAClBC,WAAW;EACXC,KAAK;EACLC,WAAW;EACXC,QAAQ;EACRC,OAAO;AACPC,EAAAA,OAAAA;AACD,CAAA,KAAI;EACH,MAAM;IAAEC,MAAM;AAAEC,IAAAA,aAAAA;GAAe,GAAGC,iBAAO,EAAE,CAAA;AAE3C,EAAA,MAAMC,SAAS,GAAGC,gBAAU,CAACC,kCAAgB,CAAC,CAAA;EAE9C,oBACEC,eAAA,CAAAC,mBAAA,EAAA;AAAAC,IAAAA,QAAA,gBACEF,eAAA,CAAA,QAAA,EAAA;AACE,MAAA,eAAA,EAAc,QAAQ;MACtB,eAAeH,EAAAA,SAAS,IAAI,IAAK;AACjC,MAAA,eAAA,EAAeA,SAAU;MACzBM,SAAS,EAAE,CAAWlB,QAAAA,EAAAA,MAAI,CAA6B,0BAAA,CAAA;AACvDM,MAAAA,QAAQ,EAAEA,QAAS;AACnBa,MAAAA,IAAI,E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AAAA,EAAAA,KAAK,CAAG,CAAA;UAC5DJ,IAAI,EAAEC,SAAI,CAACmC,KAAM;UACjB7B,OAAO,EAAG8B,KAA0C,IAAI;YACtDA,KAAK,CAACC,eAAe,EAAE,CAAA;YACvBD,KAAK,CAACE,cAAc,EAAE,CAAA;AACtB/B,YAAAA,OAAO,EAAE,CAAA;AACX,WAAA;SAEJ,CAAA;AAAA,OAAM,CACR,CAAA;KAAA,CAAG,GACD,IAAI,CAAA;AAAA,GACV,CAAG,CAAA;AAEP;;;;"}
|
|
@@ -5,7 +5,9 @@ import { CloseButton } from '../../common/closeButton/CloseButton.mjs';
|
|
|
5
5
|
import dateTriggerMessages from './DateTrigger.messages.mjs';
|
|
6
6
|
import { useContext } from 'react';
|
|
7
7
|
import { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider.mjs';
|
|
8
|
+
import Body from '../../body/Body.mjs';
|
|
8
9
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
10
|
+
import { Typography } from '../../common/propsValues/typography.mjs';
|
|
9
11
|
import { Position } from '../../common/propsValues/position.mjs';
|
|
10
12
|
import { Size } from '../../common/propsValues/size.mjs';
|
|
11
13
|
|
|
@@ -33,11 +35,13 @@ const DateTrigger = ({
|
|
|
33
35
|
disabled: disabled,
|
|
34
36
|
type: "button",
|
|
35
37
|
onClick: onClick,
|
|
36
|
-
children: [label && /*#__PURE__*/jsx(
|
|
37
|
-
|
|
38
|
+
children: [label && /*#__PURE__*/jsx(Body, {
|
|
39
|
+
as: "span",
|
|
40
|
+
className: "np-date-trigger-label m-r-1",
|
|
38
41
|
children: label
|
|
39
|
-
}), selectedDate ? /*#__PURE__*/jsx(
|
|
40
|
-
|
|
42
|
+
}), selectedDate ? /*#__PURE__*/jsx(Body, {
|
|
43
|
+
as: "span",
|
|
44
|
+
type: Typography.BODY_LARGE,
|
|
41
45
|
children: formatDate(selectedDate, locale, {
|
|
42
46
|
day: 'numeric',
|
|
43
47
|
month: monthFormat,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTrigger.mjs","sources":["../../../src/dateLookup/dateTrigger/DateTrigger.tsx"],"sourcesContent":["import { formatDate } from '@transferwise/formatting';\nimport { useIntl } from 'react-intl';\n\nimport Chevron from '../../chevron';\nimport { Size, Position, SizeSmall, SizeMedium, SizeLarge } from '../../common';\nimport { CloseButton } from '../../common/closeButton/CloseButton';\n\nimport messages from './DateTrigger.messages';\nimport { useContext } from 'react';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\ninterface DateTriggerProps {\n selectedDate: Date | null;\n size: SizeSmall | SizeMedium | SizeLarge;\n placeholder: string;\n label: string;\n monthFormat: 'short' | 'long';\n disabled: boolean;\n onClick: () => void;\n onClear?: () => void;\n}\n\nconst DateTrigger: React.FC<DateTriggerProps> = ({\n selectedDate,\n size = Size.MEDIUM,\n placeholder,\n label,\n monthFormat,\n disabled,\n onClick,\n onClear,\n}) => {\n const { locale, formatMessage } = useIntl();\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <>\n <button\n aria-haspopup=\"dialog\"\n aria-expanded={overlayId != null}\n aria-controls={overlayId}\n className={`btn btn-${size} btn-input np-date-trigger`}\n disabled={disabled}\n type=\"button\"\n onClick={onClick}\n >\n {label && <span className=\"
|
|
1
|
+
{"version":3,"file":"DateTrigger.mjs","sources":["../../../src/dateLookup/dateTrigger/DateTrigger.tsx"],"sourcesContent":["import { formatDate } from '@transferwise/formatting';\nimport { useIntl } from 'react-intl';\n\nimport Chevron from '../../chevron';\nimport { Size, Position, SizeSmall, SizeMedium, SizeLarge, Typography } from '../../common';\nimport { CloseButton } from '../../common/closeButton/CloseButton';\n\nimport messages from './DateTrigger.messages';\nimport { useContext } from 'react';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\nimport Body from '../../body';\n\ninterface DateTriggerProps {\n selectedDate: Date | null;\n size: SizeSmall | SizeMedium | SizeLarge;\n placeholder: string;\n label: string;\n monthFormat: 'short' | 'long';\n disabled: boolean;\n onClick: () => void;\n onClear?: () => void;\n}\n\nconst DateTrigger: React.FC<DateTriggerProps> = ({\n selectedDate,\n size = Size.MEDIUM,\n placeholder,\n label,\n monthFormat,\n disabled,\n onClick,\n onClear,\n}) => {\n const { locale, formatMessage } = useIntl();\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <>\n <button\n aria-haspopup=\"dialog\"\n aria-expanded={overlayId != null}\n aria-controls={overlayId}\n className={`btn btn-${size} btn-input np-date-trigger`}\n disabled={disabled}\n type=\"button\"\n onClick={onClick}\n >\n {label && (\n <Body as=\"span\" className=\"np-date-trigger-label m-r-1\">\n {label}\n </Body>\n )}\n {selectedDate ? (\n <Body as=\"span\" type={Typography.BODY_LARGE}>\n {formatDate(selectedDate, locale, {\n day: 'numeric',\n month: monthFormat,\n year: 'numeric',\n })}\n </Body>\n ) : (\n <span\n className=\"form-control-placeholder visible-xs-inline visible-sm-inline\n visible-md-inline visible-lg-inline visible-xl-inline\"\n >\n {placeholder}\n </span>\n )}\n {!onClear ? <Chevron orientation={Position.BOTTOM} disabled={disabled} /> : null}\n </button>\n {onClear ? (\n <>\n <div className=\"clearfix\" />\n <span className=\"input-group-addon\">\n <CloseButton\n className={`clear-btn clear-btn--${size}`}\n aria-label={`${formatMessage(messages.ariaLabel)} ${label}`}\n size={Size.SMALL}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n event.preventDefault();\n onClear();\n }}\n />\n </span>\n </>\n ) : null}\n </>\n );\n};\n\nexport default DateTrigger;\n"],"names":["DateTrigger","selectedDate","size","Size","MEDIUM","placeholder","label","monthFormat","disabled","onClick","onClear","locale","formatMessage","useIntl","overlayId","useContext","OverlayIdContext","_jsxs","_Fragment","children","className","type","_jsx","Body","as","Typography","BODY_LARGE","formatDate","day","month","year","Chevron","orientation","Position","BOTTOM","CloseButton","messages","ariaLabel","SMALL","event","stopPropagation","preventDefault"],"mappings":";;;;;;;;;;;;;AAuBMA,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,EAAC,oHACuD;AAAAD,QAAAA,QAAA,EAEhEd,WAAAA;AAAW,OACR,CACP,EACA,CAACK,OAAO,gBAAGY,GAAA,CAACS,OAAO,EAAA;QAACC,WAAW,EAAEC,QAAQ,CAACC,MAAO;AAAC1B,QAAAA,QAAQ,EAAEA,QAAAA;OAAS,CAAG,GAAG,IAAI,CAAA;AAAA,KAC1E,CACR,EAACE,OAAO,gBACNO,IAAA,CAAAC,QAAA,EAAA;AAAAC,MAAAA,QAAA,gBACEG,GAAA,CAAA,KAAA,EAAA;AAAKF,QAAAA,SAAS,EAAC,UAAA;OACf,CAAA,eAAAE,GAAA,CAAA,MAAA,EAAA;AAAMF,QAAAA,SAAS,EAAC,mBAAmB;QAAAD,QAAA,eACjCG,GAAA,CAACa,WAAW,EAAA;UACVf,SAAS,EAAE,CAAwBlB,qBAAAA,EAAAA,IAAI,CAAG,CAAA;UAC1C,YAAY,EAAA,CAAA,EAAGU,aAAa,CAACwB,mBAAQ,CAACC,SAAS,CAAC,CAAI/B,CAAAA,EAAAA,KAAK,CAAG,CAAA;UAC5DJ,IAAI,EAAEC,IAAI,CAACmC,KAAM;UACjB7B,OAAO,EAAG8B,KAA0C,IAAI;YACtDA,KAAK,CAACC,eAAe,EAAE,CAAA;YACvBD,KAAK,CAACE,cAAc,EAAE,CAAA;AACtB/B,YAAAA,OAAO,EAAE,CAAA;AACX,WAAA;SAEJ,CAAA;AAAA,OAAM,CACR,CAAA;KAAA,CAAG,GACD,IAAI,CAAA;AAAA,GACV,CAAG,CAAA;AAEP;;;;"}
|
package/build/field/Field.js
CHANGED
|
@@ -11,14 +11,17 @@ var sentiment = require('../common/propsValues/sentiment.js');
|
|
|
11
11
|
const Field = ({
|
|
12
12
|
id,
|
|
13
13
|
label,
|
|
14
|
+
required = false,
|
|
14
15
|
message: propMessage,
|
|
16
|
+
hint,
|
|
17
|
+
description = hint,
|
|
15
18
|
sentiment: propType = sentiment.Sentiment.NEUTRAL,
|
|
16
19
|
className,
|
|
17
20
|
children,
|
|
18
21
|
...props
|
|
19
22
|
}) => {
|
|
20
23
|
const sentiment$1 = props.error ? sentiment.Sentiment.NEGATIVE : propType;
|
|
21
|
-
const message =
|
|
24
|
+
const message = propMessage || props.error;
|
|
22
25
|
const hasError = sentiment$1 === sentiment.Sentiment.NEGATIVE;
|
|
23
26
|
const labelId = React.useId();
|
|
24
27
|
const fallbackInputId = React.useId();
|
|
@@ -42,7 +45,11 @@ const Field = ({
|
|
|
42
45
|
children: [label != null ? /*#__PURE__*/jsxRuntime.jsxs(Label.Label, {
|
|
43
46
|
id: labelId,
|
|
44
47
|
htmlFor: inputId,
|
|
45
|
-
children: [label,
|
|
48
|
+
children: [required ? label : /*#__PURE__*/jsxRuntime.jsx(Label.Label.Optional, {
|
|
49
|
+
children: label
|
|
50
|
+
}), description && /*#__PURE__*/jsxRuntime.jsx(Label.Label.Description, {
|
|
51
|
+
children: description
|
|
52
|
+
}), children]
|
|
46
53
|
}) : children, message && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
47
54
|
type: sentiment$1,
|
|
48
55
|
id: descriptionId,
|
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 { 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 { clsx } from 'clsx';\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';\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 hint,\n description = hint,\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;\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 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={clsx(\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': sentiment === Sentiment.NEUTRAL,\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 && (\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","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","descriptionId","_jsx","FieldLabelIdContextProvider","value","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","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;EACpBC,IAAI;AACJC,EAAAA,WAAW,GAAGD,IAAI;AAClBE,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;AAC7D,EAAA,MAAML,OAAO,GAAGC,WAAW,IAAIS,KAAK,CAACC,KAAK,CAAA;AAC1C,EAAA,MAAME,QAAQ,GAAGT,WAAS,KAAKE,mBAAS,CAACM,QAAQ,CAAA;AAEjD,EAAA,MAAME,OAAO,GAAGC,WAAK,EAAE,CAAA;AAEvB,EAAA,MAAMC,eAAe,GAAGD,WAAK,EAAE,CAAA;EAC/B,MAAME,OAAO,GAAGpB,EAAE,KAAK,IAAI,GAAIA,EAAE,IAAImB,eAAe,GAAIE,SAAS,CAAA;AAEjE,EAAA,MAAMC,aAAa,GAAGJ,WAAK,EAAE,CAAA;EAE7B,oBACEK,cAAA,CAACC,oCAA2B,EAAA;AAACC,IAAAA,KAAK,EAAER,OAAQ;IAAAL,QAAA,eAC1CW,cAAA,CAACG,+BAAsB,EAAA;AAACD,MAAAA,KAAK,EAAEL,OAAQ;MAAAR,QAAA,eACrCW,cAAA,CAACI,iCAAwB,EAAA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@ 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
|
+
hint,
|
|
15
|
+
description = hint,
|
|
13
16
|
sentiment: propType = Sentiment.NEUTRAL,
|
|
14
17
|
className,
|
|
15
18
|
children,
|
|
16
19
|
...props
|
|
17
20
|
}) => {
|
|
18
21
|
const sentiment = props.error ? Sentiment.NEGATIVE : propType;
|
|
19
|
-
const message =
|
|
22
|
+
const message = propMessage || props.error;
|
|
20
23
|
const hasError = sentiment === Sentiment.NEGATIVE;
|
|
21
24
|
const labelId = useId();
|
|
22
25
|
const fallbackInputId = useId();
|
|
@@ -40,7 +43,11 @@ const Field = ({
|
|
|
40
43
|
children: [label != null ? /*#__PURE__*/jsxs(Label, {
|
|
41
44
|
id: labelId,
|
|
42
45
|
htmlFor: inputId,
|
|
43
|
-
children: [label,
|
|
46
|
+
children: [required ? label : /*#__PURE__*/jsx(Label.Optional, {
|
|
47
|
+
children: label
|
|
48
|
+
}), description && /*#__PURE__*/jsx(Label.Description, {
|
|
49
|
+
children: description
|
|
50
|
+
}), children]
|
|
44
51
|
}) : children, message && /*#__PURE__*/jsx(InlineAlert, {
|
|
45
52
|
type: sentiment,
|
|
46
53
|
id: descriptionId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.mjs","sources":["../../src/field/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\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 { clsx } from 'clsx';\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';\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 hint,\n description = hint,\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;\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 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={clsx(\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': sentiment === Sentiment.NEUTRAL,\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 && (\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","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","descriptionId","_jsx","FieldLabelIdContextProvider","value","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","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;EACpBC,IAAI;AACJC,EAAAA,WAAW,GAAGD,IAAI;AAClBE,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;AAC7D,EAAA,MAAML,OAAO,GAAGC,WAAW,IAAIS,KAAK,CAACC,KAAK,CAAA;AAC1C,EAAA,MAAME,QAAQ,GAAGT,SAAS,KAAKE,SAAS,CAACM,QAAQ,CAAA;AAEjD,EAAA,MAAME,OAAO,GAAGC,KAAK,EAAE,CAAA;AAEvB,EAAA,MAAMC,eAAe,GAAGD,KAAK,EAAE,CAAA;EAC/B,MAAME,OAAO,GAAGpB,EAAE,KAAK,IAAI,GAAIA,EAAE,IAAImB,eAAe,GAAIE,SAAS,CAAA;AAEjE,EAAA,MAAMC,aAAa,GAAGJ,KAAK,EAAE,CAAA;EAE7B,oBACEK,GAAA,CAACC,2BAA2B,EAAA;AAACC,IAAAA,KAAK,EAAER,OAAQ;I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AAA;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 clsx = require('clsx');
|
|
|
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');
|
|
@@ -25,7 +24,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
25
24
|
|
|
26
25
|
var mergeProps__default = /*#__PURE__*/_interopDefault(mergeProps);
|
|
27
26
|
|
|
28
|
-
const MAX_ITEMS_WITHOUT_VIRTUALIZATION = 50;
|
|
29
27
|
function searchableString(value) {
|
|
30
28
|
return value.trim().replace(/\s+/gu, ' ').normalize('NFKC').toLowerCase();
|
|
31
29
|
}
|
|
@@ -50,11 +48,6 @@ function dedupeSelectInputOptionItem(item, existingValues) {
|
|
|
50
48
|
value: undefined
|
|
51
49
|
};
|
|
52
50
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Sets the `value` of duplicate option items to `undefined`, hiding them when
|
|
55
|
-
* rendered. Indexes are kept intact within groups to preserve the active item
|
|
56
|
-
* between filter changes when possible.
|
|
57
|
-
*/
|
|
58
51
|
function dedupeSelectInputItems(items) {
|
|
59
52
|
const existingValues = new Set();
|
|
60
53
|
return items.map(item => {
|
|
@@ -74,19 +67,19 @@ function dedupeSelectInputItems(items) {
|
|
|
74
67
|
return item;
|
|
75
68
|
});
|
|
76
69
|
}
|
|
77
|
-
function
|
|
70
|
+
function filterSelectInputOptionItem(item, needle) {
|
|
78
71
|
return inferSearchableStrings(item.filterMatchers ?? item.value).some(haystack => haystack.includes(needle));
|
|
79
72
|
}
|
|
80
|
-
function filterSelectInputItems(items,
|
|
73
|
+
function filterSelectInputItems(items, needle) {
|
|
81
74
|
return items.filter(item => {
|
|
82
75
|
switch (item.type) {
|
|
83
76
|
case 'option':
|
|
84
77
|
{
|
|
85
|
-
return
|
|
78
|
+
return filterSelectInputOptionItem(item, needle);
|
|
86
79
|
}
|
|
87
80
|
case 'group':
|
|
88
81
|
{
|
|
89
|
-
return item.options.some(option =>
|
|
82
|
+
return item.options.some(option => filterSelectInputOptionItem(option, needle));
|
|
90
83
|
}
|
|
91
84
|
}
|
|
92
85
|
return false;
|
|
@@ -187,15 +180,12 @@ function SelectInput({
|
|
|
187
180
|
}
|
|
188
181
|
}, [handleClose, open]);
|
|
189
182
|
const [filterQuery, _setFilterQuery] = React.useState('');
|
|
190
|
-
const deferredFilterQuery = React.useDeferredValue(filterQuery);
|
|
191
183
|
const setFilterQuery = useEffectEvent.useEffectEvent(query => {
|
|
192
184
|
_setFilterQuery(query);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
});
|
|
198
|
-
}
|
|
185
|
+
onFilterChange({
|
|
186
|
+
query,
|
|
187
|
+
queryNormalized: query ? searchableString(query) : null
|
|
188
|
+
});
|
|
199
189
|
});
|
|
200
190
|
const triggerRef = React.useRef(null);
|
|
201
191
|
const screenSm = useScreenSize.useScreenSize(breakpoint.Breakpoint.SMALL);
|
|
@@ -207,7 +197,10 @@ function SelectInput({
|
|
|
207
197
|
name: name,
|
|
208
198
|
multiple: multiple,
|
|
209
199
|
defaultValue: defaultValue,
|
|
210
|
-
value: controlledValue
|
|
200
|
+
value: controlledValue
|
|
201
|
+
// TODO: Remove assertion when upgrading TypeScript to v5
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
203
|
+
,
|
|
211
204
|
by: compareValues,
|
|
212
205
|
disabled: disabled,
|
|
213
206
|
onChange: value => {
|
|
@@ -272,7 +265,9 @@ function SelectInput({
|
|
|
272
265
|
setOpen(false);
|
|
273
266
|
},
|
|
274
267
|
onCloseEnd: () => {
|
|
275
|
-
|
|
268
|
+
if (filterQuery !== '') {
|
|
269
|
+
setFilterQuery('');
|
|
270
|
+
}
|
|
276
271
|
},
|
|
277
272
|
children: /*#__PURE__*/jsxRuntime.jsx(SelectInputOptions, {
|
|
278
273
|
items: items,
|
|
@@ -282,7 +277,7 @@ function SelectInput({
|
|
|
282
277
|
filterPlaceholder: filterPlaceholder,
|
|
283
278
|
searchInputRef: searchInputRef,
|
|
284
279
|
listboxRef: listboxRef,
|
|
285
|
-
filterQuery:
|
|
280
|
+
filterQuery: filterQuery,
|
|
286
281
|
onFilterChange: setFilterQuery
|
|
287
282
|
})
|
|
288
283
|
});
|
|
@@ -366,37 +361,7 @@ function SelectInputOptions({
|
|
|
366
361
|
}
|
|
367
362
|
return undefined;
|
|
368
363
|
}, [filterQuery, filterable]);
|
|
369
|
-
|
|
370
|
-
if (needle) {
|
|
371
|
-
// Ensure having an active option while filtering
|
|
372
|
-
requestAnimationFrame(() => {
|
|
373
|
-
if (controllerRef.current != null && !controllerRef.current.hasAttribute('aria-activedescendant')) {
|
|
374
|
-
// Activate first option via synthetic key press
|
|
375
|
-
controllerRef.current.dispatchEvent(new KeyboardEvent('keydown', {
|
|
376
|
-
key: 'Home',
|
|
377
|
-
bubbles: true
|
|
378
|
-
}));
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
}, [controllerRef, needle]);
|
|
383
|
-
const filteredItems = needle != null ? filterSelectInputItems(dedupeSelectInputItems(items), item => selectInputOptionItemIncludesNeedle(item, needle)) : items;
|
|
384
|
-
const resultsEmpty = needle != null && filteredItems.length === 0;
|
|
385
|
-
const virtualized = filteredItems.length > MAX_ITEMS_WITHOUT_VIRTUALIZATION;
|
|
386
|
-
// Items shown once shall be kept mounted until the needle changes, otherwise
|
|
387
|
-
// the scroll position may jump around inadvertently. Pattern adopted from:
|
|
388
|
-
// https://inokawa.github.io/virtua/?path=/story/advanced-keep-offscreen-items--append-only
|
|
389
|
-
const [mountedIndexes, setMountedIndexes] = React.useState([]);
|
|
390
|
-
React.useEffect(() => {
|
|
391
|
-
// Ensure the 'End' key works as intended by keeping the last item mounted
|
|
392
|
-
setMountedIndexes(prevMountedIndexes => {
|
|
393
|
-
const indexes = new Set(prevMountedIndexes);
|
|
394
|
-
indexes.add(filteredItems.length - 1);
|
|
395
|
-
return [...indexes]; // Sorting is redundant by nature here
|
|
396
|
-
});
|
|
397
|
-
}, [needle,
|
|
398
|
-
// Needed as `filteredItems.length` may be equal between two updates
|
|
399
|
-
filteredItems.length]);
|
|
364
|
+
const resultsEmpty = needle != null && filterSelectInputItems(items, needle).length === 0;
|
|
400
365
|
const listboxContainerRef = React.useRef(null);
|
|
401
366
|
React.useEffect(() => {
|
|
402
367
|
if (listboxContainerRef.current != null) {
|
|
@@ -406,16 +371,6 @@ function SelectInputOptions({
|
|
|
406
371
|
const showStatus = resultsEmpty;
|
|
407
372
|
const statusId = React.useId();
|
|
408
373
|
const listboxId = React.useId();
|
|
409
|
-
const getItemNode = index => {
|
|
410
|
-
const item = filteredItems[index];
|
|
411
|
-
return /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
|
|
412
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
413
|
-
, {
|
|
414
|
-
item: item,
|
|
415
|
-
renderValue: renderValue,
|
|
416
|
-
needle: needle
|
|
417
|
-
}, index);
|
|
418
|
-
};
|
|
419
374
|
return /*#__PURE__*/jsxRuntime.jsxs(react.Listbox.Options, {
|
|
420
375
|
as: SelectInputOptionsContainer,
|
|
421
376
|
static: true,
|
|
@@ -426,6 +381,13 @@ function SelectInputOptions({
|
|
|
426
381
|
controllerRef.current.setAttribute('aria-activedescendant', value);
|
|
427
382
|
} else {
|
|
428
383
|
controllerRef.current.removeAttribute('aria-activedescendant');
|
|
384
|
+
if (filterQuery) {
|
|
385
|
+
// Ensure having an active option while filtering
|
|
386
|
+
controllerRef.current.dispatchEvent(new KeyboardEvent('keydown', {
|
|
387
|
+
key: 'Home',
|
|
388
|
+
bubbles: true
|
|
389
|
+
}));
|
|
390
|
+
}
|
|
429
391
|
}
|
|
430
392
|
}
|
|
431
393
|
},
|
|
@@ -435,7 +397,7 @@ function SelectInputOptions({
|
|
|
435
397
|
ref: searchInputRef,
|
|
436
398
|
shape: "rectangle",
|
|
437
399
|
placeholder: filterPlaceholder,
|
|
438
|
-
|
|
400
|
+
value: filterQuery,
|
|
439
401
|
"aria-controls": listboxId,
|
|
440
402
|
"aria-describedby": showStatus ? statusId : undefined,
|
|
441
403
|
onKeyDown: event => {
|
|
@@ -446,18 +408,13 @@ function SelectInputOptions({
|
|
|
446
408
|
}
|
|
447
409
|
},
|
|
448
410
|
onChange: event => {
|
|
449
|
-
// Free up resources and ensure not to go out of bounds when the
|
|
450
|
-
// resulting item count is less than before
|
|
451
|
-
setMountedIndexes([]);
|
|
452
411
|
onFilterChange(event.currentTarget.value);
|
|
453
412
|
}
|
|
454
413
|
})
|
|
455
414
|
}) : null, /*#__PURE__*/jsxRuntime.jsxs("section", {
|
|
456
415
|
ref: listboxContainerRef,
|
|
457
416
|
tabIndex: -1,
|
|
458
|
-
className: clsx.clsx('np-select-input-listbox-container',
|
|
459
|
-
// Groups aren't shown when filtering
|
|
460
|
-
items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
|
|
417
|
+
className: clsx.clsx('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
|
|
461
418
|
children: [resultsEmpty ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
462
419
|
id: statusId,
|
|
463
420
|
className: "np-select-input-options-status",
|
|
@@ -472,22 +429,13 @@ function SelectInputOptions({
|
|
|
472
429
|
"aria-orientation": "vertical",
|
|
473
430
|
tabIndex: 0,
|
|
474
431
|
className: "np-select-input-listbox",
|
|
475
|
-
children:
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
,
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
const indexes = new Set(prevMountedIndexes);
|
|
483
|
-
for (let index = startIndex; index <= endIndex; index += 1) {
|
|
484
|
-
indexes.add(index);
|
|
485
|
-
}
|
|
486
|
-
return [...indexes].sort((a, b) => a - b);
|
|
487
|
-
});
|
|
488
|
-
},
|
|
489
|
-
children: index => getItemNode(index)
|
|
490
|
-
}, needle)
|
|
432
|
+
children: (needle != null ? dedupeSelectInputItems(items) : items).map((item, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
|
|
433
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
434
|
+
, {
|
|
435
|
+
item: item,
|
|
436
|
+
renderValue: renderValue,
|
|
437
|
+
needle: needle
|
|
438
|
+
}, index))
|
|
491
439
|
}), renderFooter != null ? /*#__PURE__*/jsxRuntime.jsx("footer", {
|
|
492
440
|
className: "np-select-input-footer",
|
|
493
441
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -515,7 +463,7 @@ function SelectInputItemView({
|
|
|
515
463
|
switch (item.type) {
|
|
516
464
|
case 'option':
|
|
517
465
|
{
|
|
518
|
-
if (item.value != null && (needle == null ||
|
|
466
|
+
if (item.value != null && (needle == null || filterSelectInputOptionItem(item, needle))) {
|
|
519
467
|
return /*#__PURE__*/jsxRuntime.jsx(SelectInputOption, {
|
|
520
468
|
value: item.value,
|
|
521
469
|
disabled: item.disabled,
|