@transferwise/components 0.0.0-experimental-ea80215 → 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.
Files changed (70) hide show
  1. package/build/dateLookup/dateTrigger/DateTrigger.js +8 -4
  2. package/build/dateLookup/dateTrigger/DateTrigger.js.map +1 -1
  3. package/build/dateLookup/dateTrigger/DateTrigger.mjs +8 -4
  4. package/build/dateLookup/dateTrigger/DateTrigger.mjs.map +1 -1
  5. package/build/field/Field.js +9 -2
  6. package/build/field/Field.js.map +1 -1
  7. package/build/field/Field.mjs +9 -2
  8. package/build/field/Field.mjs.map +1 -1
  9. package/build/i18n/en.json +3 -1
  10. package/build/i18n/en.json.js +3 -1
  11. package/build/i18n/en.json.js.map +1 -1
  12. package/build/i18n/en.json.mjs +3 -1
  13. package/build/i18n/en.json.mjs.map +1 -1
  14. package/build/inputs/SelectInput.js +36 -100
  15. package/build/inputs/SelectInput.js.map +1 -1
  16. package/build/inputs/SelectInput.mjs +38 -102
  17. package/build/inputs/SelectInput.mjs.map +1 -1
  18. package/build/label/Label.js +29 -1
  19. package/build/label/Label.js.map +1 -1
  20. package/build/label/Label.messages.js +15 -0
  21. package/build/label/Label.messages.js.map +1 -0
  22. package/build/label/Label.messages.mjs +13 -0
  23. package/build/label/Label.messages.mjs.map +1 -0
  24. package/build/label/Label.mjs +30 -2
  25. package/build/label/Label.mjs.map +1 -1
  26. package/build/main.css +0 -18
  27. package/build/styles/dateLookup/dateTrigger/DateTrigger.css +0 -8
  28. package/build/styles/inputs/SelectInput.css +0 -10
  29. package/build/styles/main.css +0 -18
  30. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
  31. package/build/types/field/Field.d.ts +4 -2
  32. package/build/types/field/Field.d.ts.map +1 -1
  33. package/build/types/index.d.ts +1 -1
  34. package/build/types/index.d.ts.map +1 -1
  35. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  36. package/build/types/label/Label.d.ts +10 -1
  37. package/build/types/label/Label.d.ts.map +1 -1
  38. package/build/types/label/Label.messages.d.ts +12 -0
  39. package/build/types/label/Label.messages.d.ts.map +1 -0
  40. package/build/types/label/index.d.ts +3 -0
  41. package/build/types/label/index.d.ts.map +1 -0
  42. package/package.json +5 -6
  43. package/src/dateInput/DateInput.tests.story.tsx +8 -32
  44. package/src/dateLookup/DateLookup.rtl.spec.tsx +1 -1
  45. package/src/dateLookup/dateTrigger/DateTrigger.css +0 -8
  46. package/src/dateLookup/dateTrigger/DateTrigger.less +0 -8
  47. package/src/dateLookup/dateTrigger/DateTrigger.spec.js +1 -1
  48. package/src/dateLookup/dateTrigger/DateTrigger.tsx +9 -4
  49. package/src/field/Field.spec.tsx +3 -3
  50. package/src/field/Field.story.tsx +81 -3
  51. package/src/field/Field.tsx +10 -4
  52. package/src/i18n/en.json +3 -1
  53. package/src/index.ts +1 -1
  54. package/src/inlineAlert/InlineAlert.story.tsx +8 -21
  55. package/src/inputs/InputGroup.spec.tsx +1 -1
  56. package/src/inputs/SearchInput.spec.tsx +1 -1
  57. package/src/inputs/SelectInput.css +0 -10
  58. package/src/inputs/SelectInput.less +0 -12
  59. package/src/inputs/SelectInput.spec.tsx +1 -1
  60. package/src/inputs/SelectInput.story.tsx +0 -20
  61. package/src/inputs/SelectInput.tsx +46 -139
  62. package/src/label/Label.messages.tsx +12 -0
  63. package/src/label/Label.story.tsx +30 -21
  64. package/src/label/Label.tsx +43 -2
  65. package/src/label/index.ts +2 -0
  66. package/src/main.css +0 -18
  67. package/src/radioGroup/RadioGroup.rtl.spec.tsx +1 -1
  68. package/src/select/Select.rtl.spec.tsx +1 -1
  69. package/src/switch/Switch.spec.tsx +1 -1
  70. 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("span", {
39
- className: "control-label small m-r-1",
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("span", {
42
- className: "font-weight-normal",
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=\"control-label small m-r-1\">{label}</span>}\n {selectedDate ? (\n <span className=\"font-weight-normal\">\n {formatDate(selectedDate, locale, {\n day: 'numeric',\n month: monthFormat,\n year: 'numeric',\n })}\n </span>\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","formatDate","day","month","year","Chevron","orientation","Position","BOTTOM","CloseButton","messages","ariaLabel","SMALL","event","stopPropagation","preventDefault"],"mappings":";;;;;;;;;;;;;AAsBMA,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;A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AAA,EAAA;AAAKF,QAAAA,SAAS,EAAC,UAAA;OACf,CAAA,eAAAE,cAAA,CAAA,MAAA,EAAA;AAAMF,QAAAA,SAAS,EAAC,mBAAmB;QAAAD,QAAA,eACjCG,cAAA,CAACS,uBAAW,EAAA;UACVX,SAAS,EAAE,CAAwBlB,qBAAAA,EAAAA,MAAI,CAAG,CAAA;UAC1C,YAAY,EAAA,CAAA,EAAGU,aAAa,CAACoB,oBAAQ,CAACC,SAAS,CAAC,CAAI3B,CAAAA,EAAAA,KAAK,CAAG,CAAA;UAC5DJ,IAAI,EAAEC,SAAI,CAAC+B,KAAM;UACjBzB,OAAO,EAAG0B,KAA0C,IAAI;YACtDA,KAAK,CAACC,eAAe,EAAE,CAAA;YACvBD,KAAK,CAACE,cAAc,EAAE,CAAA;AACtB3B,YAAAA,OAAO,EAAE,CAAA;AACX,WAAA;SAEJ,CAAA;AAAA,OAAM,CACR,CAAA;KAAA,CAAG,GACD,IAAI,CAAA;AAAA,GACV,CAAG,CAAA;AAEP;;;;"}
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,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B,QAAAA,QAAQ,EAAEA,QAAAA;OAAS,CAAG,GAAG,IAAI,CAAA;AAAA,KAC1E,CACR,EAACE,OAAO,gBACNO,eAAA,CAAAC,mBAAA,EAAA;AAAAC,MAAAA,QAAA,gBACEG,cAAA,CAAA,KAAA,EAAA;AAAKF,QAAAA,SAAS,EAAC,UAAA;OACf,CAAA,eAAAE,cAAA,CAAA,MAAA,EAAA;AAAMF,QAAAA,SAAS,EAAC,mBAAmB;QAAAD,QAAA,eACjCG,cAAA,CAACa,uBAAW,EAAA;UACVf,SAAS,EAAE,CAAwBlB,qBAAAA,EAAAA,MAAI,CAAG,CAAA;UAC1C,YAAY,EAAA,CAAA,EAAGU,aAAa,CAACwB,oBAAQ,CAACC,SAAS,CAAC,CAAI/B,CAAAA,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("span", {
37
- className: "control-label small m-r-1",
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("span", {
40
- className: "font-weight-normal",
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=\"control-label small m-r-1\">{label}</span>}\n {selectedDate ? (\n <span className=\"font-weight-normal\">\n {formatDate(selectedDate, locale, {\n day: 'numeric',\n month: monthFormat,\n year: 'numeric',\n })}\n </span>\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","formatDate","day","month","year","Chevron","orientation","Position","BOTTOM","CloseButton","messages","ariaLabel","SMALL","event","stopPropagation","preventDefault"],"mappings":";;;;;;;;;;;AAsBMA,MAAAA,WAAW,GAA+BA,CAAC;EAC/CC,YAAY;EACZC,IAAI,GAAGC,IAAI,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,OAAO,EAAE,CAAA;AAE3C,EAAA,MAAMC,SAAS,GAAGC,UAAU,CAACC,gBAAgB,CAAC,CAAA;EAE9C,oBACEC,IAAA,CAAAC,QAAA,EAAA;AAAAC,IAAAA,QAAA,gBACEF,IAAA,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,IAAI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AAA,EAAAA,KAAK,CAAG,CAAA;UAC5DJ,IAAI,EAAEC,IAAI,CAAC+B,KAAM;UACjBzB,OAAO,EAAG0B,KAA0C,IAAI;YACtDA,KAAK,CAACC,eAAe,EAAE,CAAA;YACvBD,KAAK,CAACE,cAAc,EAAE,CAAA;AACtB3B,YAAAA,OAAO,EAAE,CAAA;AACX,WAAA;SAEJ,CAAA;AAAA,OAAM,CACR,CAAA;KAAA,CAAG,GACD,IAAI,CAAA;AAAA,GACV,CAAG,CAAA;AAEP;;;;"}
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,MAAAA,WAAW,GAA+BA,CAAC;EAC/CC,YAAY;EACZC,IAAI,GAAGC,IAAI,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,OAAO,EAAE,CAAA;AAE3C,EAAA,MAAMC,SAAS,GAAGC,UAAU,CAACC,gBAAgB,CAAC,CAAA;EAE9C,oBACEC,IAAA,CAAAC,QAAA,EAAA;AAAAC,IAAAA,QAAA,gBACEF,IAAA,CAAA,QAAA,EAAA;AACE,MAAA,eAAA,EAAc,QAAQ;MACtB,eAAeH,EAAAA,SAAS,IAAI,I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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;;;;"}
@@ -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 = props.error || props.hint || propMessage;
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, children]
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,
@@ -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/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 /** @deprecated use `message` and `type={Sentiment.NEUTRAL}` prop instead */\n hint?: React.ReactNode;\n message?: 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 message: propMessage,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = props.error || props.hint || propMessage;\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 {label}\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","message","propMessage","sentiment","propType","Sentiment","NEUTRAL","className","children","props","error","NEGATIVE","hint","hasError","labelId","useId","fallbackInputId","inputId","undefined","descriptionId","_jsx","FieldLabelIdContextProvider","value","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","POSITIVE","WARNING","Label","htmlFor","InlineAlert","type"],"mappings":";;;;;;;;;;AA4BO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,OAAO,EAAEC,WAAW;AACpBC,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,MAAMH,OAAO,GAAGQ,KAAK,CAACC,KAAK,IAAID,KAAK,CAACG,IAAI,IAAIV,WAAW,CAAA;AACxD,EAAA,MAAMW,QAAQ,GAAGV,WAAS,KAAKE,mBAAS,CAACM,QAAQ,CAAA;AAEjD,EAAA,MAAMG,OAAO,GAAGC,WAAK,EAAE,CAAA;AAEvB,EAAA,MAAMC,eAAe,GAAGD,WAAK,EAAE,CAAA;EAC/B,MAAME,OAAO,GAAGlB,EAAE,KAAK,IAAI,GAAIA,EAAE,IAAIiB,eAAe,GAAIE,SAAS,CAAA;AAEjE,EAAA,MAAMC,aAAa,GAAGJ,WAAK,EAAE,CAAA;EAE7B,oBACEK,cAAA,CAACC,oCAA2B,EAAA;AAACC,IAAAA,KAAK,EAAER,OAAQ;IAAAN,QAAA,eAC1CY,cAAA,CAACG,+BAAsB,EAAA;AAACD,MAAAA,KAAK,EAAEL,OAAQ;MAAAT,QAAA,eACrCY,cAAA,CAACI,iCAAwB,EAAA;AAACF,QAAAA,KAAK,EAAErB,OAAO,GAAGkB,aAAa,GAAGD,SAAU;QAAAV,QAAA,eACnEY,cAAA,CAACK,6BAAoB,EAAA;AAACH,UAAAA,KAAK,EAAET,QAAS;AAAAL,UAAAA,QAAA,eACpCkB,eAAA,CAAA,KAAA,EAAA;AACEnB,YAAAA,SAAS,EAAEoB,SAAI,CACb,oBAAoB,EACpB;AACE,cAAA,aAAa,EAAExB,WAAS,KAAKE,mBAAS,CAACuB,QAAQ;AAC/C,cAAA,aAAa,EAAEzB,WAAS,KAAKE,mBAAS,CAACwB,OAAO;AAC9C,cAAA,WAAW,EAAEhB,QAAQ;AACrB,cAAA,UAAU,EAAEV,WAAS,KAAKE,mBAAS,CAACC,OAAAA;aACrC,EACDC,SAAS,CACT;AAAAC,YAAAA,QAAA,GAEDR,KAAK,IAAI,IAAI,gBACZ0B,eAAA,CAACI,WAAK,EAAA;AAAC/B,cAAAA,EAAE,EAAEe,OAAQ;AAACiB,cAAAA,OAAO,EAAEd,OAAQ;cAAAT,QAAA,EAAA,CAClCR,KAAK,EACLQ,QAAQ,CAAA;aACJ,CAAC,GAERA,QACD,EAEAP,OAAO,iBACNmB,cAAA,CAACY,WAAW,EAAA;AAACC,cAAAA,IAAI,EAAE9B,WAAU;AAACJ,cAAAA,EAAE,EAAEoB,aAAc;AAAAX,cAAAA,QAAA,EAC7CP,OAAAA;AAAO,aACG,CACd,CAAA;WACE,CAAA;SACe,CAAA;OACE,CAAA;KACJ,CAAA;AAC1B,GAA6B,CAAC,CAAA;AAElC;;;;"}
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,+B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,CAAA;AAC1B,GAA6B,CAAC,CAAA;AAElC;;;;"}
@@ -9,14 +9,17 @@ 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 = props.error || props.hint || propMessage;
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, children]
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/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 /** @deprecated use `message` and `type={Sentiment.NEUTRAL}` prop instead */\n hint?: React.ReactNode;\n message?: 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 message: propMessage,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = props.error || props.hint || propMessage;\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 {label}\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","message","propMessage","sentiment","propType","Sentiment","NEUTRAL","className","children","props","error","NEGATIVE","hint","hasError","labelId","useId","fallbackInputId","inputId","undefined","descriptionId","_jsx","FieldLabelIdContextProvider","value","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","POSITIVE","WARNING","Label","htmlFor","InlineAlert","type"],"mappings":";;;;;;;;AA4BO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,OAAO,EAAEC,WAA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,cAAA,UAAU,EAAEV,SAAS,KAAKE,SAAS,CAACC,OAAAA;aACrC,EACDC,SAAS,CACT;AAAAC,YAAAA,QAAA,GAEDR,KAAK,IAAI,IAAI,gBACZ0B,IAAA,CAACI,KAAK,EAAA;AAAC/B,cAAAA,EAAE,EAAEe,OAAQ;AAACiB,cAAAA,OAAO,EAAEd,OAAQ;cAAAT,QAAA,EAAA,CAClCR,KAAK,EACLQ,QAAQ,CAAA;aACJ,CAAC,GAERA,QACD,EAEAP,OAAO,iBACNmB,GAAA,CAACY,WAAW,EAAA;AAACC,cAAAA,IAAI,EAAE9B,SAAU;AAACJ,cAAAA,EAAE,EAAEoB,aAAc;AAAAX,cAAAA,QAAA,EAC7CP,OAAAA;AAAO,aACG,CACd,CAAA;WACE,CAAA;SACe,CAAA;OACE,CAAA;KACJ,CAAA;AAC1B,GAA6B,CAAC,CAAA;AAElC;;;;"}
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;AAClB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KE,SAAS,CAACC,OAAAA;aACrC,EACDC,SAAS,CACT;AAAAC,YAAAA,QAAA,GAEDX,KAAK,IAAI,IAAI,gBACZ4B,IAAA,CAACI,KAAK,EAAA;AAACjC,cAAAA,EAAE,EAAEiB,OAAQ;AAACiB,cAAAA,OAAO,EAAEd,OAAQ;cAAAR,QAAA,EAAA,CAClCV,QAAQ,GAAGD,KAAK,gBAAGsB,GAAA,CAACU,KAAK,CAACE,QAAQ,EAAA;AAAAvB,gBAAAA,QAAA,EAAEX,KAAAA;eAAsB,CAAC,EAC3DK,WAAW,iBAAIiB,GAAA,CAACU,KAAK,CAACG,WAAW,EAAA;AAAAxB,gBAAAA,QAAA,EAAEN,WAAAA;eAA+B,CAAC,EACnEM,QAAQ,CAAA;aACJ,CAAC,GAERA,QACD,EAEAT,OAAO,iBACNoB,GAAA,CAACc,WAAW,EAAA;AAACC,cAAAA,IAAI,EAAE/B,SAAU;AAACP,cAAAA,EAAE,EAAEsB,aAAc;AAAAV,cAAAA,QAAA,EAC7CT,OAAAA;AAAO,aACG,CACd,CAAA;WACE,CAAA;SACe,CAAA;OACE,CAAA;KACJ,CAAA;AAC1B,GAA6B,CAAC,CAAA;AAElC;;;;"}
@@ -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
  }
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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
  }
@@ -38,6 +36,8 @@ function inferSearchableStrings(value) {
38
36
  }
39
37
  return [];
40
38
  }
39
+ const SelectInputTriggerButtonPropsContext = /*#__PURE__*/React.createContext({});
40
+ const SelectInputOptionContentWithinTriggerContext = /*#__PURE__*/React.createContext(false);
41
41
  function dedupeSelectInputOptionItem(item, existingValues) {
42
42
  if (!existingValues.has(item.value)) {
43
43
  existingValues.add(item.value);
@@ -48,11 +48,6 @@ function dedupeSelectInputOptionItem(item, existingValues) {
48
48
  value: undefined
49
49
  };
50
50
  }
51
- /**
52
- * Sets the `value` of duplicate option items to `undefined`, hiding them when
53
- * rendered. Indexes are kept intact within groups to preserve the active item
54
- * between filter changes when possible.
55
- */
56
51
  function dedupeSelectInputItems(items) {
57
52
  const existingValues = new Set();
58
53
  return items.map(item => {
@@ -72,19 +67,19 @@ function dedupeSelectInputItems(items) {
72
67
  return item;
73
68
  });
74
69
  }
75
- function selectInputOptionItemIncludesNeedle(item, needle) {
70
+ function filterSelectInputOptionItem(item, needle) {
76
71
  return inferSearchableStrings(item.filterMatchers ?? item.value).some(haystack => haystack.includes(needle));
77
72
  }
78
- function filterSelectInputItems(items, predicate) {
73
+ function filterSelectInputItems(items, needle) {
79
74
  return items.filter(item => {
80
75
  switch (item.type) {
81
76
  case 'option':
82
77
  {
83
- return predicate(item);
78
+ return filterSelectInputOptionItem(item, needle);
84
79
  }
85
80
  case 'group':
86
81
  {
87
- return item.options.some(option => predicate(option));
82
+ return item.options.some(option => filterSelectInputOptionItem(option, needle));
88
83
  }
89
84
  }
90
85
  return false;
@@ -185,15 +180,12 @@ function SelectInput({
185
180
  }
186
181
  }, [handleClose, open]);
187
182
  const [filterQuery, _setFilterQuery] = React.useState('');
188
- const deferredFilterQuery = React.useDeferredValue(filterQuery);
189
183
  const setFilterQuery = useEffectEvent.useEffectEvent(query => {
190
184
  _setFilterQuery(query);
191
- if (query !== filterQuery) {
192
- onFilterChange({
193
- query,
194
- queryNormalized: query ? searchableString(query) : null
195
- });
196
- }
185
+ onFilterChange({
186
+ query,
187
+ queryNormalized: query ? searchableString(query) : null
188
+ });
197
189
  });
198
190
  const triggerRef = React.useRef(null);
199
191
  const screenSm = useScreenSize.useScreenSize(breakpoint.Breakpoint.SMALL);
@@ -205,7 +197,10 @@ function SelectInput({
205
197
  name: name,
206
198
  multiple: multiple,
207
199
  defaultValue: defaultValue,
208
- 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
+ ,
209
204
  by: compareValues,
210
205
  disabled: disabled,
211
206
  onChange: value => {
@@ -270,7 +265,9 @@ function SelectInput({
270
265
  setOpen(false);
271
266
  },
272
267
  onCloseEnd: () => {
273
- setFilterQuery('');
268
+ if (filterQuery !== '') {
269
+ setFilterQuery('');
270
+ }
274
271
  },
275
272
  children: /*#__PURE__*/jsxRuntime.jsx(SelectInputOptions, {
276
273
  items: items,
@@ -280,14 +277,13 @@ function SelectInput({
280
277
  filterPlaceholder: filterPlaceholder,
281
278
  searchInputRef: searchInputRef,
282
279
  listboxRef: listboxRef,
283
- filterQuery: deferredFilterQuery,
280
+ filterQuery: filterQuery,
284
281
  onFilterChange: setFilterQuery
285
282
  })
286
283
  });
287
284
  }
288
285
  });
289
286
  }
290
- const SelectInputTriggerButtonPropsContext = /*#__PURE__*/React.createContext({});
291
287
  function SelectInputTriggerButton({
292
288
  as = 'button',
293
289
  ...restProps
@@ -365,37 +361,7 @@ function SelectInputOptions({
365
361
  }
366
362
  return undefined;
367
363
  }, [filterQuery, filterable]);
368
- React.useEffect(() => {
369
- if (needle) {
370
- // Ensure having an active option while filtering
371
- requestAnimationFrame(() => {
372
- if (controllerRef.current != null && !controllerRef.current.hasAttribute('aria-activedescendant')) {
373
- // Activate first option via synthetic key press
374
- controllerRef.current.dispatchEvent(new KeyboardEvent('keydown', {
375
- key: 'Home',
376
- bubbles: true
377
- }));
378
- }
379
- });
380
- }
381
- }, [controllerRef, needle]);
382
- const filteredItems = needle != null ? filterSelectInputItems(dedupeSelectInputItems(items), item => selectInputOptionItemIncludesNeedle(item, needle)) : items;
383
- const resultsEmpty = needle != null && filteredItems.length === 0;
384
- const virtualized = filteredItems.length > MAX_ITEMS_WITHOUT_VIRTUALIZATION;
385
- // Items shown once shall be kept mounted until the needle changes, otherwise
386
- // the scroll position may jump around inadvertently. Pattern adopted from:
387
- // https://inokawa.github.io/virtua/?path=/story/advanced-keep-offscreen-items--append-only
388
- const [mountedIndexes, setMountedIndexes] = React.useState([]);
389
- React.useEffect(() => {
390
- // Ensure the 'End' key works as intended by keeping the last item mounted
391
- setMountedIndexes(prevMountedIndexes => {
392
- const indexes = new Set(prevMountedIndexes);
393
- indexes.add(filteredItems.length - 1);
394
- return [...indexes]; // Sorting is redundant by nature here
395
- });
396
- }, [needle,
397
- // Needed as `filteredItems.length` may be equal between two updates
398
- filteredItems.length]);
364
+ const resultsEmpty = needle != null && filterSelectInputItems(items, needle).length === 0;
399
365
  const listboxContainerRef = React.useRef(null);
400
366
  React.useEffect(() => {
401
367
  if (listboxContainerRef.current != null) {
@@ -405,16 +371,6 @@ function SelectInputOptions({
405
371
  const showStatus = resultsEmpty;
406
372
  const statusId = React.useId();
407
373
  const listboxId = React.useId();
408
- const getItemNode = index => {
409
- const item = filteredItems[index];
410
- return /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
411
- // eslint-disable-next-line react/no-array-index-key
412
- , {
413
- item: item,
414
- renderValue: renderValue,
415
- needle: needle
416
- }, index);
417
- };
418
374
  return /*#__PURE__*/jsxRuntime.jsxs(react.Listbox.Options, {
419
375
  as: SelectInputOptionsContainer,
420
376
  static: true,
@@ -425,6 +381,13 @@ function SelectInputOptions({
425
381
  controllerRef.current.setAttribute('aria-activedescendant', value);
426
382
  } else {
427
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
+ }
428
391
  }
429
392
  }
430
393
  },
@@ -434,7 +397,7 @@ function SelectInputOptions({
434
397
  ref: searchInputRef,
435
398
  shape: "rectangle",
436
399
  placeholder: filterPlaceholder,
437
- defaultValue: filterQuery,
400
+ value: filterQuery,
438
401
  "aria-controls": listboxId,
439
402
  "aria-describedby": showStatus ? statusId : undefined,
440
403
  onKeyDown: event => {
@@ -445,18 +408,13 @@ function SelectInputOptions({
445
408
  }
446
409
  },
447
410
  onChange: event => {
448
- // Free up resources and ensure not to go out of bounds when the
449
- // resulting item count is less than before
450
- setMountedIndexes([]);
451
411
  onFilterChange(event.currentTarget.value);
452
412
  }
453
413
  })
454
414
  }) : null, /*#__PURE__*/jsxRuntime.jsxs("section", {
455
415
  ref: listboxContainerRef,
456
416
  tabIndex: -1,
457
- className: clsx.clsx('np-select-input-listbox-container', virtualized && 'np-select-input-listbox-container--virtualized', needle == null &&
458
- // Groups aren't shown when filtering
459
- 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'),
460
418
  children: [resultsEmpty ? /*#__PURE__*/jsxRuntime.jsxs("div", {
461
419
  id: statusId,
462
420
  className: "np-select-input-options-status",
@@ -471,28 +429,13 @@ function SelectInputOptions({
471
429
  "aria-orientation": "vertical",
472
430
  tabIndex: 0,
473
431
  className: "np-select-input-listbox",
474
- children: !virtualized ? filteredItems.map((_, index) => getItemNode(index)) : /*#__PURE__*/jsxRuntime.jsx(virtua.Virtualizer, {
475
- count: filteredItems.length,
476
- keepMounted: mountedIndexes,
477
- scrollRef: listboxRef // `VList` doesn't expose this
478
- ,
479
- onRangeChange: (startIndex, endIndex) => {
480
- setMountedIndexes(prevMountedIndexes => {
481
- const indexes = new Set(prevMountedIndexes);
482
- for (let index = startIndex; index <= endIndex; index += 1) {
483
- indexes.add(index);
484
- }
485
- return [...indexes].sort((a, b) => a - b);
486
- });
487
- },
488
- children: index => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemsCountContext.Provider, {
489
- value: filteredItems.length,
490
- children: /*#__PURE__*/jsxRuntime.jsx(SelectInputItemPositionContext.Provider, {
491
- value: index + 1,
492
- children: getItemNode(index)
493
- })
494
- })
495
- }, 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))
496
439
  }), renderFooter != null ? /*#__PURE__*/jsxRuntime.jsx("footer", {
497
440
  className: "np-select-input-footer",
498
441
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -520,7 +463,7 @@ function SelectInputItemView({
520
463
  switch (item.type) {
521
464
  case 'option':
522
465
  {
523
- if (item.value != null && (needle == null || selectInputOptionItemIncludesNeedle(item, needle))) {
466
+ if (item.value != null && (needle == null || filterSelectInputOptionItem(item, needle))) {
524
467
  return /*#__PURE__*/jsxRuntime.jsx(SelectInputOption, {
525
468
  value: item.value,
526
469
  disabled: item.disabled,
@@ -578,20 +521,14 @@ function SelectInputGroupItemView({
578
521
  })
579
522
  );
580
523
  }
581
- const SelectInputItemsCountContext = /*#__PURE__*/React.createContext(undefined);
582
- const SelectInputItemPositionContext = /*#__PURE__*/React.createContext(undefined);
583
524
  function SelectInputOption({
584
525
  value,
585
526
  disabled,
586
527
  children
587
528
  }) {
588
- const itemsCount = React.useContext(SelectInputItemsCountContext);
589
- const itemPosition = React.useContext(SelectInputItemPositionContext);
590
529
  return /*#__PURE__*/jsxRuntime.jsx(react.Listbox.Option, {
591
530
  as: "div",
592
531
  value: value,
593
- "aria-setsize": itemsCount,
594
- "aria-posinset": itemPosition,
595
532
  disabled: disabled,
596
533
  className: ({
597
534
  active,
@@ -610,7 +547,6 @@ function SelectInputOption({
610
547
  })
611
548
  });
612
549
  }
613
- const SelectInputOptionContentWithinTriggerContext = /*#__PURE__*/React.createContext(false);
614
550
  function SelectInputOptionContent({
615
551
  title,
616
552
  note,