@transferwise/components 0.0.0-experimental-fd70ead → 0.0.0-experimental-2384dbf

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 (71) hide show
  1. package/build/i18n/cs.json +3 -0
  2. package/build/i18n/de.json +3 -0
  3. package/build/i18n/es.json +3 -0
  4. package/build/i18n/fr.json +3 -0
  5. package/build/i18n/hu.json +3 -0
  6. package/build/i18n/id.json +3 -0
  7. package/build/i18n/it.json +3 -0
  8. package/build/i18n/ja.json +3 -0
  9. package/build/i18n/pl.json +3 -0
  10. package/build/i18n/pt.json +3 -0
  11. package/build/i18n/ro.json +3 -0
  12. package/build/i18n/ru.json +3 -0
  13. package/build/i18n/th.json +3 -0
  14. package/build/i18n/tr.json +3 -0
  15. package/build/i18n/uk.json +3 -0
  16. package/build/i18n/zh-CN.json +3 -0
  17. package/build/index.esm.js +166 -2
  18. package/build/index.esm.js.map +1 -1
  19. package/build/index.js +166 -1
  20. package/build/index.js.map +1 -1
  21. package/build/main.css +1 -1
  22. package/build/styles/inputs/InputGroup.css +1 -0
  23. package/build/styles/main.css +1 -1
  24. package/build/types/body/Body.d.ts +2 -2
  25. package/build/types/common/hooks/useEffectEvent.d.ts +2 -0
  26. package/build/types/common/hooks/useEffectEvent.d.ts.map +1 -0
  27. package/build/types/common/hooks/useResizeObserver.d.ts +3 -0
  28. package/build/types/common/hooks/useResizeObserver.d.ts.map +1 -0
  29. package/build/types/common/panel/Panel.d.ts +1 -1
  30. package/build/types/common/responsivePanel/ResponsivePanel.d.ts +1 -1
  31. package/build/types/dimmer/Dimmer.d.ts +1 -1
  32. package/build/types/index.d.ts +2 -0
  33. package/build/types/index.d.ts.map +1 -1
  34. package/build/types/inputs/Input.d.ts +1 -1
  35. package/build/types/inputs/Input.d.ts.map +1 -1
  36. package/build/types/inputs/InputGroup.d.ts +21 -0
  37. package/build/types/inputs/InputGroup.d.ts.map +1 -0
  38. package/build/types/inputs/TextArea.d.ts +1 -1
  39. package/build/types/select/searchBox/SearchBox.d.ts +1 -1
  40. package/build/types/utilities/cssValueWithUnit.d.ts +2 -0
  41. package/build/types/utilities/cssValueWithUnit.d.ts.map +1 -0
  42. package/package.json +4 -4
  43. package/src/common/hooks/useEffectEvent.ts +22 -0
  44. package/src/common/hooks/useResizeObserver.ts +22 -0
  45. package/src/i18n/cs.json +3 -0
  46. package/src/i18n/de.json +3 -0
  47. package/src/i18n/es.json +3 -0
  48. package/src/i18n/fr.json +3 -0
  49. package/src/i18n/hu.json +3 -0
  50. package/src/i18n/id.json +3 -0
  51. package/src/i18n/it.json +3 -0
  52. package/src/i18n/ja.json +3 -0
  53. package/src/i18n/pl.json +3 -0
  54. package/src/i18n/pt.json +3 -0
  55. package/src/i18n/ro.json +3 -0
  56. package/src/i18n/ru.json +3 -0
  57. package/src/i18n/th.json +3 -0
  58. package/src/i18n/tr.json +3 -0
  59. package/src/i18n/uk.json +3 -0
  60. package/src/i18n/zh-CN.json +3 -0
  61. package/src/index.ts +2 -0
  62. package/src/inputs/Input.tsx +5 -0
  63. package/src/inputs/InputGroup.css +1 -0
  64. package/src/inputs/InputGroup.less +61 -0
  65. package/src/inputs/InputGroup.story.tsx +73 -0
  66. package/src/inputs/InputGroup.tsx +142 -0
  67. package/src/main.css +1 -1
  68. package/src/main.less +1 -0
  69. package/src/utilities/cssValueWithUnit.ts +3 -0
  70. package/build/i18n/zh-HK.json +0 -41
  71. package/src/i18n/zh-HK.json +0 -41
package/build/index.js CHANGED
@@ -6100,6 +6100,124 @@ InlineAlert.defaultProps = {
6100
6100
  };
6101
6101
  var InlineAlert$1 = InlineAlert;
6102
6102
 
6103
+ /*
6104
+ * Inspired by:
6105
+ *
6106
+ * - https://react.dev/learn/separating-events-from-effects#declaring-an-effect-event
6107
+ * - https://legacy.reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
6108
+ */
6109
+ function useEffectEvent(callback) {
6110
+ const ref = React.useRef(() => {
6111
+ throw new Error('Cannot call an event handler while rendering.');
6112
+ });
6113
+ React.useEffect(() => {
6114
+ ref.current = callback;
6115
+ });
6116
+ return React.useCallback((...args) => ref.current(...args), []);
6117
+ }
6118
+
6119
+ function useResizeObserver(ref, callback) {
6120
+ const handleCallback = useEffectEvent(callback);
6121
+ React.useEffect(() => {
6122
+ if (ref.current != null) {
6123
+ const resizeObserver = new ResizeObserver(([entry]) => {
6124
+ handleCallback(entry);
6125
+ });
6126
+ resizeObserver.observe(ref.current, {
6127
+ box: 'border-box'
6128
+ });
6129
+ return () => {
6130
+ resizeObserver.disconnect();
6131
+ };
6132
+ }
6133
+ return () => {};
6134
+ }, [handleCallback, ref]);
6135
+ }
6136
+
6137
+ function cssValueWithUnit(value) {
6138
+ return typeof value === 'number' ? `${value}px` : value;
6139
+ }
6140
+
6141
+ const InputPaddingStartContext = /*#__PURE__*/React.createContext([undefined, () => {}]);
6142
+ const InputPaddingEndContext = /*#__PURE__*/React.createContext([undefined, () => {}]);
6143
+ function useInputPaddings() {
6144
+ const [paddingStart] = React.useContext(InputPaddingStartContext);
6145
+ const [paddingEnd] = React.useContext(InputPaddingEndContext);
6146
+ return {
6147
+ paddingInlineStart: paddingStart,
6148
+ paddingInlineEnd: paddingEnd
6149
+ };
6150
+ }
6151
+ function inputPaddingInitialState({
6152
+ initialContentWidth,
6153
+ padding = inputAddonDefaultPadding
6154
+ } = {}) {
6155
+ return () => initialContentWidth != null ? `calc(${cssValueWithUnit(initialContentWidth)} + ${cssValueWithUnit(inputAddonContentWidthAddendByPadding[padding])})` : undefined;
6156
+ }
6157
+ function InputGroup({
6158
+ addonStart,
6159
+ addonEnd,
6160
+ disabled,
6161
+ className,
6162
+ children
6163
+ }) {
6164
+ const [paddingStart, setPaddingStart] = React.useState(inputPaddingInitialState(addonStart));
6165
+ const [paddingEnd, setPaddingEnd] = React.useState(inputPaddingInitialState(addonEnd));
6166
+ return /*#__PURE__*/jsxRuntime.jsx(InputPaddingStartContext.Provider, {
6167
+ value: React.useMemo(() => [paddingStart, setPaddingStart], [paddingStart]),
6168
+ children: /*#__PURE__*/jsxRuntime.jsx(InputPaddingEndContext.Provider, {
6169
+ value: React.useMemo(() => [paddingEnd, setPaddingEnd], [paddingEnd]),
6170
+ children: /*#__PURE__*/jsxRuntime.jsxs("fieldset", {
6171
+ disabled: disabled,
6172
+ className: classNames__default.default(className, 'np-input-group'),
6173
+ children: [addonStart != null ? /*#__PURE__*/jsxRuntime.jsx(InputAddon, {
6174
+ placement: "start",
6175
+ ...addonStart
6176
+ }) : null, children, addonEnd != null ? /*#__PURE__*/jsxRuntime.jsx(InputAddon, {
6177
+ placement: "end",
6178
+ ...addonEnd
6179
+ }) : null]
6180
+ })
6181
+ })
6182
+ });
6183
+ }
6184
+ const inputAddonContentWidthAddendByPadding = {
6185
+ none: 0,
6186
+ sm: '1rem',
6187
+ md: '1.5rem'
6188
+ };
6189
+ const inputAddonDefaultPadding = 'md';
6190
+ function InputAddon({
6191
+ placement,
6192
+ content,
6193
+ interactive,
6194
+ padding = inputAddonDefaultPadding
6195
+ }) {
6196
+ const [, setInputPadding] = React.useContext(placement === 'start' ? InputPaddingStartContext : InputPaddingEndContext);
6197
+ const ref = React.useRef(null);
6198
+ useResizeObserver(ref, entry => {
6199
+ // TODO: Remove fallback once most browsers support `borderBoxSize`
6200
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
6201
+ if (entry.borderBoxSize != null) {
6202
+ setInputPadding(entry.borderBoxSize[0].inlineSize);
6203
+ } else {
6204
+ const targetStyle = getComputedStyle(entry.target);
6205
+ setInputPadding(entry.contentRect.width + Number.parseFloat(targetStyle.paddingInlineStart) + Number.parseFloat(targetStyle.paddingInlineEnd));
6206
+ }
6207
+ });
6208
+ return /*#__PURE__*/jsxRuntime.jsx("span", {
6209
+ ref: ref,
6210
+ className: classNames__default.default('np-input-addon', {
6211
+ 'np-input-addon--placement-start': placement === 'start',
6212
+ 'np-input-addon--placement-end': placement === 'end'
6213
+ }, interactive && 'np-input-addon--interactive', {
6214
+ 'np-input-addon--padding-sm': padding === 'sm',
6215
+ 'np-input-addon--padding-md': padding === 'md'
6216
+ }),
6217
+ children: content
6218
+ });
6219
+ }
6220
+
6103
6221
  function formControlClassNameBase({
6104
6222
  size = 'auto'
6105
6223
  } = {}) {
@@ -6118,11 +6236,15 @@ const Input = /*#__PURE__*/React.forwardRef(function Input({
6118
6236
  className,
6119
6237
  ...restProps
6120
6238
  }, reference) {
6239
+ const inputPaddings = useInputPaddings();
6121
6240
  return /*#__PURE__*/jsxRuntime.jsx("input", {
6122
6241
  ref: reference,
6123
6242
  className: classNames__default.default(className, formControlClassNameBase({
6124
6243
  size
6125
- })),
6244
+ }))
6245
+ // eslint-disable-next-line react/forbid-dom-props
6246
+ ,
6247
+ style: inputPaddings,
6126
6248
  ...restProps
6127
6249
  });
6128
6250
  });
@@ -13671,6 +13793,9 @@ var de = {
13671
13793
  "neptune.DateInput.month.label": "Monat",
13672
13794
  "neptune.DateInput.year.label": "Jahr",
13673
13795
  "neptune.MoneyInput.Select.placeholder": "Wähle eine der Möglichkeiten aus...",
13796
+ "neptune.Pagination.ariaLabel": "Seitennummer-Navigation",
13797
+ "neptune.PaginationLink.ariaLabel.active": "Weiter zur Seite {pageNumber}",
13798
+ "neptune.PaginationLink.ariaLabel.inactive": "Aktuelle Seite – Seite {pageNumber}",
13674
13799
  "neptune.Select.searchPlaceholder": "Wird gesucht...",
13675
13800
  "neptune.Summary.statusDone": "Schritt erledigt",
13676
13801
  "neptune.Summary.statusNotDone": "Schritt noch zu erledigen",
@@ -13713,6 +13838,9 @@ var es = {
13713
13838
  "neptune.DateInput.month.label": "Mes",
13714
13839
  "neptune.DateInput.year.label": "Año",
13715
13840
  "neptune.MoneyInput.Select.placeholder": "Selecciona una opción...",
13841
+ "neptune.Pagination.ariaLabel": "Navegación por las páginas",
13842
+ "neptune.PaginationLink.ariaLabel.active": "Ve a la página {pageNumber}",
13843
+ "neptune.PaginationLink.ariaLabel.inactive": "Página actual, página {pageNumber}",
13716
13844
  "neptune.Select.searchPlaceholder": "Buscar...",
13717
13845
  "neptune.Summary.statusDone": "Apartado listo",
13718
13846
  "neptune.Summary.statusNotDone": "Apartado a completar",
@@ -13755,6 +13883,9 @@ var fr = {
13755
13883
  "neptune.DateInput.month.label": "Mois",
13756
13884
  "neptune.DateInput.year.label": "Année",
13757
13885
  "neptune.MoneyInput.Select.placeholder": "Sélectionner une option...",
13886
+ "neptune.Pagination.ariaLabel": "Navigation par pagination",
13887
+ "neptune.PaginationLink.ariaLabel.active": "Aller à la page {pageNumber}",
13888
+ "neptune.PaginationLink.ariaLabel.inactive": "Page actuelle, page {pageNumber}",
13758
13889
  "neptune.Select.searchPlaceholder": "Recherche...",
13759
13890
  "neptune.Summary.statusDone": "Validé",
13760
13891
  "neptune.Summary.statusNotDone": "À compléter",
@@ -13797,6 +13928,9 @@ var hu = {
13797
13928
  "neptune.DateInput.month.label": "Hónap",
13798
13929
  "neptune.DateInput.year.label": "Év",
13799
13930
  "neptune.MoneyInput.Select.placeholder": "Válassz ki egy lehetőséget...",
13931
+ "neptune.Pagination.ariaLabel": "Lapszámos navigáció",
13932
+ "neptune.PaginationLink.ariaLabel.active": "Ugrás a(z) {pageNumber}. oldalra",
13933
+ "neptune.PaginationLink.ariaLabel.inactive": "Jelenlegi oldal, {pageNumber}. oldal",
13800
13934
  "neptune.Select.searchPlaceholder": "Keresés...",
13801
13935
  "neptune.Summary.statusDone": "Kész",
13802
13936
  "neptune.Summary.statusNotDone": "Hátravan",
@@ -13839,6 +13973,9 @@ var id = {
13839
13973
  "neptune.DateInput.month.label": "Bulan",
13840
13974
  "neptune.DateInput.year.label": "Tahun",
13841
13975
  "neptune.MoneyInput.Select.placeholder": "Pilih opsi...",
13976
+ "neptune.Pagination.ariaLabel": "Halaman navigasi",
13977
+ "neptune.PaginationLink.ariaLabel.active": "Lanjut ke halaman {pageNumber}",
13978
+ "neptune.PaginationLink.ariaLabel.inactive": "Halaman saat ini, halaman {pageNumber}",
13842
13979
  "neptune.Select.searchPlaceholder": "Cari...",
13843
13980
  "neptune.Summary.statusDone": "Item selesai",
13844
13981
  "neptune.Summary.statusNotDone": "Item yang harus dilakukan",
@@ -13881,6 +14018,9 @@ var it = {
13881
14018
  "neptune.DateInput.month.label": "Mese",
13882
14019
  "neptune.DateInput.year.label": "Anno",
13883
14020
  "neptune.MoneyInput.Select.placeholder": "Seleziona un'opzione...",
14021
+ "neptune.Pagination.ariaLabel": "Navigazione",
14022
+ "neptune.PaginationLink.ariaLabel.active": "Via a pagina {pageNumber}",
14023
+ "neptune.PaginationLink.ariaLabel.inactive": "Pagina corrente, pagina {pageNumber}",
13884
14024
  "neptune.Select.searchPlaceholder": "Cerca...",
13885
14025
  "neptune.Summary.statusDone": "Completato",
13886
14026
  "neptune.Summary.statusNotDone": "Da completare",
@@ -13923,6 +14063,9 @@ var ja = {
13923
14063
  "neptune.DateInput.month.label": "月",
13924
14064
  "neptune.DateInput.year.label": "年",
13925
14065
  "neptune.MoneyInput.Select.placeholder": "選択してください...",
14066
+ "neptune.Pagination.ariaLabel": "ページネーションナビゲーション",
14067
+ "neptune.PaginationLink.ariaLabel.active": "{pageNumber}のページへ移動します",
14068
+ "neptune.PaginationLink.ariaLabel.inactive": "現在のページ、{pageNumber}ページ",
13926
14069
  "neptune.Select.searchPlaceholder": "検索... ",
13927
14070
  "neptune.Summary.statusDone": "完了",
13928
14071
  "neptune.Summary.statusNotDone": "未対応",
@@ -13965,6 +14108,9 @@ var pl = {
13965
14108
  "neptune.DateInput.month.label": "Miesiąc",
13966
14109
  "neptune.DateInput.year.label": "Rok",
13967
14110
  "neptune.MoneyInput.Select.placeholder": "Wybierz opcję...",
14111
+ "neptune.Pagination.ariaLabel": "Nawigacja w paginacji",
14112
+ "neptune.PaginationLink.ariaLabel.active": "Przejdź do strony {pageNumber}",
14113
+ "neptune.PaginationLink.ariaLabel.inactive": "Obecna strona, strona {pageNumber}",
13968
14114
  "neptune.Select.searchPlaceholder": "Wyszukaj...",
13969
14115
  "neptune.Summary.statusDone": "Czynność wykonana",
13970
14116
  "neptune.Summary.statusNotDone": "Czynność do wykonania",
@@ -14007,6 +14153,9 @@ var pt = {
14007
14153
  "neptune.DateInput.month.label": "Mês",
14008
14154
  "neptune.DateInput.year.label": "Ano",
14009
14155
  "neptune.MoneyInput.Select.placeholder": "Escolha uma opção...",
14156
+ "neptune.Pagination.ariaLabel": "Navegação pelas páginas",
14157
+ "neptune.PaginationLink.ariaLabel.active": "Ir para a página {pageNumber}",
14158
+ "neptune.PaginationLink.ariaLabel.inactive": "Página atual, página {pageNumber}",
14010
14159
  "neptune.Select.searchPlaceholder": "Buscar...",
14011
14160
  "neptune.Summary.statusDone": "Pronto",
14012
14161
  "neptune.Summary.statusNotDone": "Não iniciado",
@@ -14049,6 +14198,9 @@ var ro = {
14049
14198
  "neptune.DateInput.month.label": "Lună",
14050
14199
  "neptune.DateInput.year.label": "An",
14051
14200
  "neptune.MoneyInput.Select.placeholder": "Selectează o opţiune...",
14201
+ "neptune.Pagination.ariaLabel": "Navigare prin pagină",
14202
+ "neptune.PaginationLink.ariaLabel.active": "Du-te la pagina {pageNumber}",
14203
+ "neptune.PaginationLink.ariaLabel.inactive": "Pagina curentă, pagina {pageNumber}",
14052
14204
  "neptune.Select.searchPlaceholder": "Caută...",
14053
14205
  "neptune.Summary.statusDone": "Finalizat",
14054
14206
  "neptune.Summary.statusNotDone": "De făcut",
@@ -14091,6 +14243,9 @@ var ru = {
14091
14243
  "neptune.DateInput.month.label": "Месяц",
14092
14244
  "neptune.DateInput.year.label": "Год",
14093
14245
  "neptune.MoneyInput.Select.placeholder": "Выберите вариант...",
14246
+ "neptune.Pagination.ariaLabel": "Постраничная навигация",
14247
+ "neptune.PaginationLink.ariaLabel.active": "Перейти на страницу {pageNumber}",
14248
+ "neptune.PaginationLink.ariaLabel.inactive": "Текущая страница, страница {pageNumber}",
14094
14249
  "neptune.Select.searchPlaceholder": "Поиск...",
14095
14250
  "neptune.Summary.statusDone": "Этап завершен",
14096
14251
  "neptune.Summary.statusNotDone": "Этап к выполнению",
@@ -14133,6 +14288,9 @@ var th = {
14133
14288
  "neptune.DateInput.month.label": "เดือน",
14134
14289
  "neptune.DateInput.year.label": "ปี",
14135
14290
  "neptune.MoneyInput.Select.placeholder": "เลือกตัวเลือก...",
14291
+ "neptune.Pagination.ariaLabel": "การนำทางเลขหน้า",
14292
+ "neptune.PaginationLink.ariaLabel.active": "ไปที่หน้า {pageNumber}",
14293
+ "neptune.PaginationLink.ariaLabel.inactive": "หน้าปัจจุบัน หน้า {pageNumber}",
14136
14294
  "neptune.Select.searchPlaceholder": "ค้นหา...",
14137
14295
  "neptune.Summary.statusDone": "รายการที่ทำแล้ว",
14138
14296
  "neptune.Summary.statusNotDone": "รายการที่ต้องทำ",
@@ -14175,6 +14333,9 @@ var tr = {
14175
14333
  "neptune.DateInput.month.label": "Ay",
14176
14334
  "neptune.DateInput.year.label": "Yıl",
14177
14335
  "neptune.MoneyInput.Select.placeholder": "Bir seçenek seçin...",
14336
+ "neptune.Pagination.ariaLabel": "Sayfalandırma gezintisi",
14337
+ "neptune.PaginationLink.ariaLabel.active": "{pageNumber} numaralı sayfaya git",
14338
+ "neptune.PaginationLink.ariaLabel.inactive": "Mevcut sayfa, sayfa {pageNumber}",
14178
14339
  "neptune.Select.searchPlaceholder": "Ara...",
14179
14340
  "neptune.Summary.statusDone": "Tamamlanan aşama",
14180
14341
  "neptune.Summary.statusNotDone": "Yapılacak",
@@ -14217,6 +14378,9 @@ var uk = {
14217
14378
  "neptune.DateInput.month.label": "Місяць",
14218
14379
  "neptune.DateInput.year.label": "Рік",
14219
14380
  "neptune.MoneyInput.Select.placeholder": "Виберіть варіант…",
14381
+ "neptune.Pagination.ariaLabel": "Перехід за сторінками",
14382
+ "neptune.PaginationLink.ariaLabel.active": "Перейти на сторінку {pageNumber}",
14383
+ "neptune.PaginationLink.ariaLabel.inactive": "Ця сторінка, сторінка {pageNumber}",
14220
14384
  "neptune.Select.searchPlaceholder": "Пошук…",
14221
14385
  "neptune.Summary.statusDone": "Виконано",
14222
14386
  "neptune.Summary.statusNotDone": "Не виконано",
@@ -14354,6 +14518,7 @@ exports.Image = Image$1;
14354
14518
  exports.Info = Info;
14355
14519
  exports.InlineAlert = InlineAlert$1;
14356
14520
  exports.Input = Input;
14521
+ exports.InputGroup = InputGroup;
14357
14522
  exports.InputWithDisplayFormat = InputWithDisplayFormat$1;
14358
14523
  exports.InstructionsList = InstructionsList$1;
14359
14524
  exports.LanguageProvider = LanguageProvider;