@transferwise/components 0.0.0-experimental-ad2ab5f → 0.0.0-experimental-c98fba0

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 (73) hide show
  1. package/build/alert/Alert.js +1 -1
  2. package/build/alert/Alert.mjs +1 -1
  3. package/build/button/Button.js +1 -4
  4. package/build/button/Button.js.map +1 -1
  5. package/build/button/Button.messages.js.map +1 -1
  6. package/build/button/Button.messages.mjs.map +1 -1
  7. package/build/button/Button.mjs +1 -4
  8. package/build/button/Button.mjs.map +1 -1
  9. package/build/button/classMap.js.map +1 -1
  10. package/build/button/classMap.mjs.map +1 -1
  11. package/build/button/legacyUtils/legacyUtils.js +7 -6
  12. package/build/button/legacyUtils/legacyUtils.js.map +1 -1
  13. package/build/button/legacyUtils/legacyUtils.mjs +7 -6
  14. package/build/button/legacyUtils/legacyUtils.mjs.map +1 -1
  15. package/build/checkbox/Checkbox.js +1 -1
  16. package/build/checkbox/Checkbox.mjs +1 -1
  17. package/build/checkboxOption/CheckboxOption.js +1 -1
  18. package/build/checkboxOption/CheckboxOption.mjs +1 -1
  19. package/build/drawer/Drawer.js +1 -1
  20. package/build/drawer/Drawer.mjs +1 -1
  21. package/build/index.js +2 -2
  22. package/build/index.mjs +1 -1
  23. package/build/markdown/Markdown.js +1 -1
  24. package/build/markdown/Markdown.mjs +1 -1
  25. package/build/popover/Popover.js +1 -1
  26. package/build/popover/Popover.mjs +1 -1
  27. package/build/stepper/deviceDetection.js +2 -3
  28. package/build/stepper/deviceDetection.js.map +1 -1
  29. package/build/stepper/deviceDetection.mjs +2 -3
  30. package/build/stepper/deviceDetection.mjs.map +1 -1
  31. package/build/types/button/Button.d.ts.map +1 -1
  32. package/build/types/button/Button.messages.d.ts +7 -7
  33. package/build/types/button/Button.messages.d.ts.map +1 -1
  34. package/build/types/button/classMap.d.ts +10 -10
  35. package/build/types/button/classMap.d.ts.map +1 -1
  36. package/build/types/button/legacyUtils/index.d.ts +1 -1
  37. package/build/types/button/legacyUtils/index.d.ts.map +1 -1
  38. package/build/types/button/legacyUtils/legacyUtils.d.ts +20 -6
  39. package/build/types/button/legacyUtils/legacyUtils.d.ts.map +1 -1
  40. package/build/types/checkboxButton/index.d.ts +1 -1
  41. package/build/types/checkboxButton/index.d.ts.map +1 -1
  42. package/build/types/stepper/deviceDetection.d.ts +1 -1
  43. package/build/types/stepper/deviceDetection.d.ts.map +1 -1
  44. package/build/types/utilities/deprecatedProperty/deprecatedProperty.d.ts +6 -8
  45. package/build/types/utilities/deprecatedProperty/deprecatedProperty.d.ts.map +1 -1
  46. package/build/types/utilities/deprecatedProperty/index.d.ts +1 -1
  47. package/build/types/utilities/deprecatedProperty/index.d.ts.map +1 -1
  48. package/build/types/utilities/index.d.ts +2 -2
  49. package/build/types/utilities/index.d.ts.map +1 -1
  50. package/build/types/utilities/logActionRequired.d.ts +2 -2
  51. package/build/types/utilities/logActionRequired.d.ts.map +1 -1
  52. package/build/utilities/logActionRequired.js.map +1 -1
  53. package/build/utilities/logActionRequired.mjs.map +1 -1
  54. package/package.json +3 -3
  55. package/src/button/Button.tsx +0 -3
  56. package/src/button/legacyUtils/legacyUtils.ts +74 -0
  57. package/src/flowNavigation/{FlowNavigation.story.js → FlowNavigation.story.tsx} +34 -16
  58. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.js +85 -0
  59. package/src/select/{Select.story.js → Select.story.tsx} +97 -47
  60. package/src/stepper/{deviceDetection.js → deviceDetection.ts} +2 -6
  61. package/src/utilities/deprecatedProperty/{deprecatedProperty.ts → deprecatedProperty.js} +4 -23
  62. package/src/utilities/{logActionRequired.ts → logActionRequired.js} +2 -2
  63. package/build/types/test-utils/style-mock.d.ts +0 -1
  64. package/build/types/test-utils/style-mock.d.ts.map +0 -1
  65. package/src/button/legacyUtils/legacyUtils.js +0 -54
  66. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +0 -78
  67. /package/src/button/{Button.messages.js → Button.messages.ts} +0 -0
  68. /package/src/button/{classMap.js → classMap.ts} +0 -0
  69. /package/src/button/legacyUtils/{index.js → index.ts} +0 -0
  70. /package/src/checkboxButton/{index.js → index.ts} +0 -0
  71. /package/src/test-utils/{style-mock.ts → style-mock.js} +0 -0
  72. /package/src/utilities/deprecatedProperty/{index.ts → index.js} +0 -0
  73. /package/src/utilities/{index.ts → index.js} +0 -0
@@ -1,11 +1,11 @@
1
- export namespace typeClassMap {
2
- let accent: string;
3
- let positive: string;
4
- let negative: string;
5
- }
6
- export namespace priorityClassMap {
7
- let primary: string;
8
- let secondary: string;
9
- let tertiary: string;
10
- }
1
+ export declare const typeClassMap: {
2
+ accent: string;
3
+ positive: string;
4
+ negative: string;
5
+ };
6
+ export declare const priorityClassMap: {
7
+ primary: string;
8
+ secondary: string;
9
+ tertiary: string;
10
+ };
11
11
  //# sourceMappingURL=classMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"classMap.d.ts","sourceRoot":"","sources":["../../../src/button/classMap.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"classMap.d.ts","sourceRoot":"","sources":["../../../src/button/classMap.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;CAIxB,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC"}
@@ -1,2 +1,2 @@
1
- export { establishNewPriority, establishNewType, logDeprecationNotices } from "./legacyUtils";
1
+ export { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/button/legacyUtils/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/button/legacyUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC"}
@@ -1,7 +1,21 @@
1
- export function establishNewType(originalType: any): any;
2
- export function establishNewPriority(originalPriority: any, originalType: any): any;
3
- export function logDeprecationNotices({ size, type }: {
4
- size: any;
5
- type: any;
6
- }): void;
1
+ import { ControlType, Priority, Size, Type } from '../../common';
2
+ type OldTypeKeys = Type.DANGER | Type.LINK | Type.SECONDARY;
3
+ declare const deprecatedTypeMapMessage: {
4
+ danger: string;
5
+ link: string;
6
+ pay: string;
7
+ primary: string;
8
+ secondary: string;
9
+ };
10
+ type EstablishNewTypeType = (originalType: Type | (string & Record<never, never>) | null) => `${ControlType}` | string | null;
11
+ export declare const establishNewType: EstablishNewTypeType;
12
+ type EstablishNewPriorityType = (originalPriority?: Priority | (string & Record<never, never>) | null, originalType?: OldTypeKeys | (string & Record<never, never>) | null) => `${ControlType}` | string | null | undefined;
13
+ export declare const establishNewPriority: EstablishNewPriorityType;
14
+ type DeprecatedTypeMapMessageType = keyof typeof deprecatedTypeMapMessage;
15
+ type LogDeprecationNoticesType = (params: {
16
+ size: `${Size}`;
17
+ type: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;
18
+ }) => void;
19
+ export declare const logDeprecationNotices: LogDeprecationNoticesType;
20
+ export {};
7
21
  //# sourceMappingURL=legacyUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacyUtils.d.ts","sourceRoot":"","sources":["../../../../src/button/legacyUtils/legacyUtils.js"],"names":[],"mappings":"AA2BO,yDAA0F;AAE1F,oFAaN;AAEM;;;SASN"}
1
+ {"version":3,"file":"legacyUtils.d.ts","sourceRoot":"","sources":["../../../../src/button/legacyUtils/legacyUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAWjE,KAAK,WAAW,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;AAO5D,QAAA,MAAM,wBAAwB;;;;;;CAM7B,CAAC;AAIF,KAAK,oBAAoB,GAAG,CAC1B,YAAY,EAAE,IAAI,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,KACxD,GAAG,WAAW,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;AAEtC,eAAO,MAAM,gBAAgB,EAAE,oBAGb,CAAC;AAEnB,KAAK,wBAAwB,GAAG,CAC9B,gBAAgB,CAAC,EAAE,QAAQ,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,EACpE,YAAY,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,KAChE,GAAG,WAAW,EAAE,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAElD,eAAO,MAAM,oBAAoB,EAAE,wBAalC,CAAC;AAEF,KAAK,4BAA4B,GAAG,MAAM,OAAO,wBAAwB,CAAC;AAC1E,KAAK,yBAAyB,GAAG,CAAC,MAAM,EAAE;IACxC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;IAChB,IAAI,EAAE,4BAA4B,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC;CAC7E,KAAK,IAAI,CAAC;AACX,eAAO,MAAM,qBAAqB,EAAE,yBAWnC,CAAC"}
@@ -1,2 +1,2 @@
1
- export { default } from "./CheckboxButton";
1
+ export { default } from './CheckboxButton';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/checkboxButton/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/checkboxButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1,2 +1,2 @@
1
- export function isTouchDevice(): boolean;
1
+ export declare function isTouchDevice(): boolean;
2
2
  //# sourceMappingURL=deviceDetection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deviceDetection.d.ts","sourceRoot":"","sources":["../../../src/stepper/deviceDetection.js"],"names":[],"mappings":"AA2BA,yCAEC"}
1
+ {"version":3,"file":"deviceDetection.d.ts","sourceRoot":"","sources":["../../../src/stepper/deviceDetection.ts"],"names":[],"mappings":"AAuBA,wBAAgB,aAAa,YAE5B"}
@@ -1,10 +1,8 @@
1
- type ValidatorType = (props: Record<string, any>, propName: string, ...rest: any[]) => Error | null;
2
- type DeprecatedOptionsType = {
3
- component: string;
4
- message?: string;
5
- newProp?: string;
6
- expiryDate?: Date;
7
- };
8
- declare const deprecated: (validator: ValidatorType, { component, message, newProp: newProperty, expiryDate }: DeprecatedOptionsType) => (props: Record<string, any>, propertyName: string, ...rest: any[]) => Error | null;
9
1
  export default deprecated;
2
+ declare function deprecated(validator: any, { component, message, newProp: newProperty, expiryDate }: {
3
+ component: any;
4
+ message?: string | undefined;
5
+ newProp?: null | undefined;
6
+ expiryDate?: null | undefined;
7
+ }): (props: any, propertyName: any, ...rest: any[]) => any;
10
8
  //# sourceMappingURL=deprecatedProperty.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deprecatedProperty.d.ts","sourceRoot":"","sources":["../../../../src/utilities/deprecatedProperty/deprecatedProperty.ts"],"names":[],"mappings":"AASA,KAAK,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,CAAC;AAEpG,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB,CAAC;AAsBF,QAAA,MAAM,UAAU,cAED,aAAa,4DACuC,qBAAqB,aAE9E,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,gBAAgB,MAAM,WAAW,GAAG,EAAE,iBAchE,CAAC;AAEJ,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"deprecatedProperty.d.ts","sourceRoot":"","sources":["../../../../src/utilities/deprecatedProperty/deprecatedProperty.js"],"names":[],"mappings":";AAsBA;;;;;2DAgBG"}
@@ -1,2 +1,2 @@
1
- export { default } from './deprecatedProperty';
1
+ export { default } from "./deprecatedProperty";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utilities/deprecatedProperty/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utilities/deprecatedProperty/index.js"],"names":[],"mappings":""}
@@ -1,3 +1,3 @@
1
- export { default as deprecated } from './deprecatedProperty';
2
- export { logActionRequired, logActionRequiredIf } from './logActionRequired';
1
+ export { default as deprecated } from "./deprecatedProperty";
2
+ export { logActionRequired, logActionRequiredIf } from "./logActionRequired";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/index.js"],"names":[],"mappings":""}
@@ -1,3 +1,3 @@
1
- export declare function logActionRequired(message: string): void;
2
- export declare function logActionRequiredIf(message: string, conditional: boolean): void;
1
+ export function logActionRequired(message: any): void;
2
+ export function logActionRequiredIf(message: any, conditional: any): void;
3
3
  //# sourceMappingURL=logActionRequired.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logActionRequired.d.ts","sourceRoot":"","sources":["../../../src/utilities/logActionRequired.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,QAKhD;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,QAIxE"}
1
+ {"version":3,"file":"logActionRequired.d.ts","sourceRoot":"","sources":["../../../src/utilities/logActionRequired.js"],"names":[],"mappings":"AAAA,sDAKC;AAED,0EAIC"}
@@ -1 +1 @@
1
- {"version":3,"file":"logActionRequired.js","sources":["../../src/utilities/logActionRequired.ts"],"sourcesContent":["export function logActionRequired(message: string) {\n if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(message);\n }\n}\n\nexport function logActionRequiredIf(message: string, conditional: boolean) {\n if (conditional) {\n logActionRequired(message);\n }\n}\n"],"names":["logActionRequired","message","process","env","NODE_ENV","console","warn","logActionRequiredIf","conditional"],"mappings":";;AAAM,SAAUA,iBAAiBA,CAACC,OAAe,EAAA;AAC/C,EAAA,IAAI,OAAOC,OAAO,KAAK,WAAW,IAAIA,OAAO,CAACC,GAAG,EAAEC,QAAQ,KAAK,YAAY,EAAE;AAC5E;AACAC,IAAAA,OAAO,CAACC,IAAI,CAACL,OAAO,CAAC,CAAA;AACvB,GAAA;AACF,CAAA;AAEgB,SAAAM,mBAAmBA,CAACN,OAAe,EAAEO,WAAoB,EAAA;AACvE,EAAA,IAAIA,WAAW,EAAE;IACfR,iBAAiB,CAACC,OAAO,CAAC,CAAA;AAC5B,GAAA;AACF;;;;;"}
1
+ {"version":3,"file":"logActionRequired.js","sources":["../../src/utilities/logActionRequired.js"],"sourcesContent":["export function logActionRequired(message) {\n if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(message);\n }\n}\n\nexport function logActionRequiredIf(message, conditional) {\n if (conditional) {\n logActionRequired(message);\n }\n}\n"],"names":["logActionRequired","message","process","env","NODE_ENV","console","warn","logActionRequiredIf","conditional"],"mappings":";;AAAO,SAASA,iBAAiBA,CAACC,OAAO,EAAE;AACzC,EAAA,IAAI,OAAOC,OAAO,KAAK,WAAW,IAAIA,OAAO,CAACC,GAAG,EAAEC,QAAQ,KAAK,YAAY,EAAE;AAC5E;AACAC,IAAAA,OAAO,CAACC,IAAI,CAACL,OAAO,CAAC,CAAA;AACvB,GAAA;AACF,CAAA;AAEO,SAASM,mBAAmBA,CAACN,OAAO,EAAEO,WAAW,EAAE;AACxD,EAAA,IAAIA,WAAW,EAAE;IACfR,iBAAiB,CAACC,OAAO,CAAC,CAAA;AAC5B,GAAA;AACF;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"logActionRequired.mjs","sources":["../../src/utilities/logActionRequired.ts"],"sourcesContent":["export function logActionRequired(message: string) {\n if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(message);\n }\n}\n\nexport function logActionRequiredIf(message: string, conditional: boolean) {\n if (conditional) {\n logActionRequired(message);\n }\n}\n"],"names":["logActionRequired","message","process","env","NODE_ENV","console","warn","logActionRequiredIf","conditional"],"mappings":"AAAM,SAAUA,iBAAiBA,CAACC,OAAe,EAAA;AAC/C,EAAA,IAAI,OAAOC,OAAO,KAAK,WAAW,IAAIA,OAAO,CAACC,GAAG,EAAEC,QAAQ,KAAK,YAAY,EAAE;AAC5E;AACAC,IAAAA,OAAO,CAACC,IAAI,CAACL,OAAO,CAAC,CAAA;AACvB,GAAA;AACF,CAAA;AAEgB,SAAAM,mBAAmBA,CAACN,OAAe,EAAEO,WAAoB,EAAA;AACvE,EAAA,IAAIA,WAAW,EAAE;IACfR,iBAAiB,CAACC,OAAO,CAAC,CAAA;AAC5B,GAAA;AACF;;;;"}
1
+ {"version":3,"file":"logActionRequired.mjs","sources":["../../src/utilities/logActionRequired.js"],"sourcesContent":["export function logActionRequired(message) {\n if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(message);\n }\n}\n\nexport function logActionRequiredIf(message, conditional) {\n if (conditional) {\n logActionRequired(message);\n }\n}\n"],"names":["logActionRequired","message","process","env","NODE_ENV","console","warn","logActionRequiredIf","conditional"],"mappings":"AAAO,SAASA,iBAAiBA,CAACC,OAAO,EAAE;AACzC,EAAA,IAAI,OAAOC,OAAO,KAAK,WAAW,IAAIA,OAAO,CAACC,GAAG,EAAEC,QAAQ,KAAK,YAAY,EAAE;AAC5E;AACAC,IAAAA,OAAO,CAACC,IAAI,CAACL,OAAO,CAAC,CAAA;AACvB,GAAA;AACF,CAAA;AAEO,SAASM,mBAAmBA,CAACN,OAAO,EAAEO,WAAW,EAAE;AACxD,EAAA,IAAIA,WAAW,EAAE;IACfR,iBAAiB,CAACC,OAAO,CAAC,CAAA;AAC5B,GAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-ad2ab5f",
3
+ "version": "0.0.0-experimental-c98fba0",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -91,9 +91,9 @@
91
91
  "rollup": "^4.18.1",
92
92
  "rollup-preserve-directives": "^1.1.1",
93
93
  "storybook": "^8.2.2",
94
+ "@transferwise/less-config": "3.1.0",
94
95
  "@transferwise/neptune-css": "14.19.0",
95
- "@wise/components-theming": "1.6.0",
96
- "@transferwise/less-config": "3.1.0"
96
+ "@wise/components-theming": "1.6.0"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "@transferwise/icons": "^3.13.1",
@@ -72,12 +72,9 @@ const Button = forwardRef<ButtonReferenceType, Props>(
72
72
  ) => {
73
73
  const intl = useIntl();
74
74
 
75
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
76
75
  logDeprecationNotices({ size, type });
77
76
 
78
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
79
77
  const newType = establishNewType(type);
80
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
81
78
  const newPriority = establishNewPriority(priority, type);
82
79
 
83
80
  const classes = clsx(
@@ -0,0 +1,74 @@
1
+ import { ControlType, Priority, Size, Type } from '../../common';
2
+ import { logActionRequired, logActionRequiredIf } from '../../utilities';
3
+
4
+ const deprecatedTypeMap: Record<Type, ControlType> = {
5
+ [Type.PRIMARY]: ControlType.ACCENT,
6
+ [Type.SECONDARY]: ControlType.ACCENT,
7
+ [Type.LINK]: ControlType.ACCENT,
8
+ [Type.PAY]: ControlType.POSITIVE,
9
+ [Type.DANGER]: ControlType.NEGATIVE,
10
+ };
11
+
12
+ type OldTypeKeys = Type.DANGER | Type.LINK | Type.SECONDARY;
13
+ const oldTypePriorityMap: Record<OldTypeKeys, Priority> = {
14
+ [Type.DANGER]: Priority.SECONDARY,
15
+ [Type.LINK]: Priority.TERTIARY,
16
+ [Type.SECONDARY]: Priority.SECONDARY,
17
+ };
18
+
19
+ const deprecatedTypeMapMessage = {
20
+ [Type.DANGER]: 'Type.NEGATIVE',
21
+ [Type.LINK]: 'ControlType.ACCENT with priority Priority.TERTIARY',
22
+ [Type.PAY]: 'ControlType.POSITIVE',
23
+ [Type.PRIMARY]: 'ControlType.ACCENT',
24
+ [Type.SECONDARY]: 'ControlType.ACCENT with priority Priority.SECONDARY',
25
+ };
26
+
27
+ const deprecatedTypes = Object.keys(deprecatedTypeMap);
28
+
29
+ type EstablishNewTypeType = (
30
+ originalType: Type | (string & Record<never, never>) | null,
31
+ ) => `${ControlType}` | string | null;
32
+
33
+ export const establishNewType: EstablishNewTypeType = (originalType) =>
34
+ originalType && originalType in deprecatedTypeMap
35
+ ? deprecatedTypeMap[originalType as Type]
36
+ : originalType;
37
+
38
+ type EstablishNewPriorityType = (
39
+ originalPriority?: Priority | (string & Record<never, never>) | null,
40
+ originalType?: OldTypeKeys | (string & Record<never, never>) | null,
41
+ ) => `${ControlType}` | string | null | undefined;
42
+
43
+ export const establishNewPriority: EstablishNewPriorityType = (originalPriority, originalType) => {
44
+ const type = originalType ? establishNewType(originalType) : '';
45
+
46
+ // The old SECONDARY and LINK types now map to priorities. If they're still using one of
47
+ // these old types, ignore whatever priority they've passed and use this instead.
48
+ if (originalType && originalType in oldTypePriorityMap) {
49
+ return oldTypePriorityMap[originalType as OldTypeKeys];
50
+ }
51
+ // Only ControlType.ACCENT supports tertiary styles
52
+ if (originalPriority === Priority.TERTIARY && type !== ControlType.ACCENT) {
53
+ return Priority.SECONDARY;
54
+ }
55
+ return originalPriority;
56
+ };
57
+
58
+ type DeprecatedTypeMapMessageType = keyof typeof deprecatedTypeMapMessage;
59
+ type LogDeprecationNoticesType = (params: {
60
+ size: `${Size}`;
61
+ type: DeprecatedTypeMapMessageType | (string & Record<never, never>) | null;
62
+ }) => void;
63
+ export const logDeprecationNotices: LogDeprecationNoticesType = ({ size, type }) => {
64
+ logActionRequiredIf(
65
+ 'Button has deprecated the `Size.EXTRA_SMALL` value for the `size` prop. Please use Size.SMALL instead.',
66
+ size === Size.EXTRA_SMALL,
67
+ );
68
+
69
+ if (type && deprecatedTypes.includes(type) && type in deprecatedTypeMapMessage) {
70
+ logActionRequired(
71
+ `Button has deprecated the ${type} value for the \`type\` prop. Please update to ${deprecatedTypeMapMessage[type as DeprecatedTypeMapMessageType]}.`,
72
+ );
73
+ }
74
+ };
@@ -24,6 +24,10 @@ const avatarProfiles = {
24
24
  Business: <BriefcaseIcon />,
25
25
  Profile: <ProfileIcon />,
26
26
  };
27
+ type ProfileTypeKeys = keyof typeof ProfileType;
28
+
29
+ const getAvatarProfile = (showAvatar: string) =>
30
+ showAvatar in avatarProfiles ? avatarProfiles[showAvatar as keyof typeof avatarProfiles] : null;
27
31
 
28
32
  export const Variants = () => {
29
33
  const [activeStep, setActiveStep] = useState(2);
@@ -32,7 +36,11 @@ export const Variants = () => {
32
36
  const showCloseButton = boolean('show closeButton', true);
33
37
  const showMobileBackButton = boolean('show mobile backButton', true);
34
38
  const done = boolean('done', false);
35
- const profileType = select('profileType', Object.keys(ProfileType));
39
+ const profileType: ProfileTypeKeys | undefined = select(
40
+ 'profileType',
41
+ Object.keys(ProfileType) as ProfileTypeKeys[],
42
+ undefined,
43
+ );
36
44
  const avatarURL = text(
37
45
  'avatarURL',
38
46
  'https://wise.com/web-art/assets/illustrations/heart-small@2x.webp',
@@ -44,7 +52,7 @@ export const Variants = () => {
44
52
  avatar={
45
53
  !showAvatar ? null : (
46
54
  <Avatar type={AvatarType.ICON} size={Size.MEDIUM}>
47
- {avatarProfiles[showAvatar]}
55
+ {getAvatarProfile(showAvatar)}
48
56
  </Avatar>
49
57
  )
50
58
  }
@@ -70,9 +78,11 @@ export const Variants = () => {
70
78
  onClick: () => setActiveStep(4),
71
79
  },
72
80
  ]}
73
- onClose={showCloseButton && (() => setClosed(true))}
81
+ onClose={showCloseButton ? () => setClosed(true) : undefined}
74
82
  onGoBack={
75
- showMobileBackButton && (() => setActiveStep(activeStep > 0 ? activeStep - 1 : 0))
83
+ showMobileBackButton
84
+ ? () => setActiveStep(activeStep > 0 ? activeStep - 1 : 0)
85
+ : undefined
76
86
  }
77
87
  />
78
88
 
@@ -112,9 +122,11 @@ export const Variants = () => {
112
122
  onClick: () => setActiveStep(4),
113
123
  },
114
124
  ]}
115
- onClose={showCloseButton && (() => setClosed(true))}
125
+ onClose={showCloseButton ? () => setClosed(true) : undefined}
116
126
  onGoBack={
117
- showMobileBackButton && (() => setActiveStep(activeStep - 1 > 0 ? activeStep - 1 : 0))
127
+ showMobileBackButton
128
+ ? () => setActiveStep(activeStep - 1 > 0 ? activeStep - 1 : 0)
129
+ : undefined
118
130
  }
119
131
  />
120
132
 
@@ -155,9 +167,11 @@ export const Variants = () => {
155
167
  onClick: () => setActiveStep(4),
156
168
  },
157
169
  ]}
158
- onClose={showCloseButton && (() => setClosed(true))}
170
+ onClose={showCloseButton ? () => setClosed(true) : undefined}
159
171
  onGoBack={
160
- showMobileBackButton && (() => setActiveStep(activeStep - 1 > 0 ? activeStep - 1 : 0))
172
+ showMobileBackButton
173
+ ? () => setActiveStep(activeStep - 1 > 0 ? activeStep - 1 : 0)
174
+ : undefined
161
175
  }
162
176
  />
163
177
 
@@ -171,9 +185,11 @@ export const Variants = () => {
171
185
  { label: 'Review', hoverLabel: 'Antonio Dozortevo', onClick: () => setActiveStep(1) },
172
186
  { label: 'Pay', hoverLabel: 'Enrico Gusso', onClick: () => setActiveStep(2) },
173
187
  ]}
174
- onClose={showCloseButton && (() => setClosed(true))}
188
+ onClose={showCloseButton ? () => setClosed(true) : undefined}
175
189
  onGoBack={
176
- showMobileBackButton && (() => setActiveStep(activeStep - 1 > 0 ? activeStep - 1 : 0))
190
+ showMobileBackButton
191
+ ? () => setActiveStep(activeStep - 1 > 0 ? activeStep - 1 : 0)
192
+ : undefined
177
193
  }
178
194
  />
179
195
 
@@ -216,7 +232,7 @@ export const SendFlow = () => {
216
232
  ...(activeStep > 3 && { onClick: handleStepClick(3) }),
217
233
  },
218
234
  ];
219
- function handleStepClick(step) {
235
+ function handleStepClick(step: number) {
220
236
  return () => {
221
237
  setActiveStep(step);
222
238
  };
@@ -268,16 +284,18 @@ export const WithOverlayHeaderComparison = () => {
268
284
  avatar={
269
285
  showAvatar ? (
270
286
  <Avatar type={AvatarType.ICON} size={Size.MEDIUM}>
271
- {avatarProfiles[showAvatar]}
287
+ {getAvatarProfile(showAvatar)}
272
288
  </Avatar>
273
289
  ) : null
274
290
  }
275
291
  activeStep={activeStep}
276
292
  done={done}
277
293
  steps={[]}
278
- onClose={showCloseButton && (() => setClosed(true))}
294
+ onClose={showCloseButton ? () => setClosed(true) : undefined}
279
295
  onGoBack={
280
- showMobileBackButton && (() => setActiveStep(activeStep > 0 ? activeStep - 1 : 0))
296
+ showMobileBackButton
297
+ ? () => setActiveStep(activeStep > 0 ? activeStep - 1 : 0)
298
+ : undefined
281
299
  }
282
300
  />
283
301
  </div>
@@ -286,11 +304,11 @@ export const WithOverlayHeaderComparison = () => {
286
304
  avatar={
287
305
  showAvatar ? (
288
306
  <Avatar type={AvatarType.ICON} size={Size.MEDIUM}>
289
- {avatarProfiles[showAvatar]}
307
+ {getAvatarProfile(showAvatar)}
290
308
  </Avatar>
291
309
  ) : null
292
310
  }
293
- onClose={showCloseButton && (() => setClosed(true))}
311
+ onClose={showCloseButton ? () => setClosed(true) : undefined}
294
312
  />
295
313
  </div>
296
314
  </>
@@ -0,0 +1,85 @@
1
+ import { text } from '@storybook/addon-knobs';
2
+ import { userEvent, within } from '@storybook/test';
3
+
4
+ import InputWithDisplayFormat from '.';
5
+ import { Field } from '../field/Field';
6
+
7
+ export default {
8
+ component: InputWithDisplayFormat,
9
+ title: 'Forms/InputWithDisplayFormat',
10
+ };
11
+
12
+ export const Basic = () => {
13
+ const placeholder = text('Placeholder', '**-**-**');
14
+ const displayPattern = text('DisplayPattern', '**-**-**');
15
+
16
+ return (
17
+ <Field label="Display pattern is controlled via knobs" id="Basic">
18
+ <InputWithDisplayFormat
19
+ id="Basic"
20
+ placeholder={placeholder}
21
+ displayPattern={displayPattern}
22
+ className="form-control"
23
+ onChange={(v) => console.log(v)}
24
+ onBlur={(v) => console.log(v)}
25
+ onFocus={(v) => console.log(v)}
26
+ />
27
+ </Field>
28
+ );
29
+ };
30
+
31
+ const Template = (args) => {
32
+ const placeholder = args.pattern;
33
+ const displayPattern = args.pattern;
34
+ const label = args.label;
35
+ const id = label.replaceAll(' ', '-').toLowerCase();
36
+
37
+ return (
38
+ <Field label={label} id={id}>
39
+ <InputWithDisplayFormat
40
+ id={id}
41
+ placeholder={placeholder}
42
+ displayPattern={displayPattern}
43
+ className="form-control"
44
+ onChange={(v) => console.log(v)}
45
+ onBlur={(v) => console.log(v)}
46
+ onFocus={(v) => console.log(v)}
47
+ />
48
+ </Field>
49
+ );
50
+ };
51
+
52
+ export const CardNumber = Template.bind({});
53
+ CardNumber.args = {
54
+ label: 'Card Number',
55
+ pattern: '**** **** **** **** ***',
56
+ };
57
+
58
+ export const CVC = Template.bind({});
59
+ CVC.args = {
60
+ label: 'CVC',
61
+ pattern: '***',
62
+ };
63
+
64
+ export const ExpiryDate = Template.bind({});
65
+ ExpiryDate.args = {
66
+ label: 'Expiry Date',
67
+ pattern: '** / **',
68
+ };
69
+
70
+ export const SecurityPin = Template.bind({});
71
+ SecurityPin.args = {
72
+ label: 'Security Pin',
73
+ pattern: '*-*-*-*-*-*',
74
+ };
75
+
76
+ export const SecurityPinPlay = Template.bind({});
77
+ SecurityPinPlay.args = {
78
+ label: 'Security Pin',
79
+ pattern: '*-*-*-*-*-*',
80
+ };
81
+
82
+ SecurityPinPlay.play = async ({ canvasElement }) => {
83
+ const canvas = within(canvasElement);
84
+ await userEvent.type(canvas.getByPlaceholderText('*-*-*-*-*-*'), '123456');
85
+ };