@transferwise/components 46.130.0 → 46.130.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/accordion/Accordion.js.map +1 -1
- package/build/accordion/Accordion.mjs.map +1 -1
- package/build/actionButton/ActionButton.js.map +1 -1
- package/build/actionButton/ActionButton.mjs.map +1 -1
- package/build/actionOption/ActionOption.js.map +1 -1
- package/build/actionOption/ActionOption.mjs.map +1 -1
- package/build/alert/Alert.js +1 -1
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +1 -1
- package/build/alert/Alert.mjs.map +1 -1
- package/build/avatar/Avatar.js.map +1 -1
- package/build/avatar/Avatar.mjs.map +1 -1
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/badge/Badge.js.map +1 -1
- package/build/badge/Badge.mjs.map +1 -1
- package/build/body/Body.js.map +1 -1
- package/build/body/Body.mjs.map +1 -1
- package/build/button/LegacyButton.js.map +1 -1
- package/build/button/LegacyButton.mjs.map +1 -1
- package/build/card/Card.js.map +1 -1
- package/build/card/Card.mjs.map +1 -1
- package/build/checkboxButton/CheckboxButton.js.map +1 -1
- package/build/checkboxButton/CheckboxButton.mjs.map +1 -1
- package/build/checkboxOption/CheckboxOption.js.map +1 -1
- package/build/checkboxOption/CheckboxOption.mjs.map +1 -1
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/common/propsValues/type.js +1 -1
- package/build/common/propsValues/type.js.map +1 -1
- package/build/common/propsValues/type.mjs +1 -1
- package/build/common/propsValues/type.mjs.map +1 -1
- package/build/common/propsValues/typography.js +1 -1
- package/build/common/propsValues/typography.js.map +1 -1
- package/build/common/propsValues/typography.mjs +1 -1
- package/build/common/propsValues/typography.mjs.map +1 -1
- package/build/dateInput/DateInput.js.map +1 -1
- package/build/dateInput/DateInput.mjs.map +1 -1
- package/build/dimmer/Dimmer.js.map +1 -1
- package/build/dimmer/Dimmer.mjs.map +1 -1
- package/build/drawer/Drawer.js.map +1 -1
- package/build/drawer/Drawer.mjs.map +1 -1
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs.map +1 -1
- package/build/flowNavigation/FlowNavigation.js.map +1 -1
- package/build/flowNavigation/FlowNavigation.mjs.map +1 -1
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs.map +1 -1
- package/build/iconButton/IconButton.js.map +1 -1
- package/build/iconButton/IconButton.mjs.map +1 -1
- package/build/legacylistItem/LegacyListItem.js.map +1 -1
- package/build/legacylistItem/LegacyListItem.mjs.map +1 -1
- package/build/list/List.js.map +1 -1
- package/build/list/List.mjs.map +1 -1
- package/build/listItem/Button/ListItemButton.js.map +1 -1
- package/build/listItem/Button/ListItemButton.mjs.map +1 -1
- package/build/listItem/IconButton/ListItemIconButton.js.map +1 -1
- package/build/listItem/IconButton/ListItemIconButton.mjs.map +1 -1
- package/build/listItem/Image/ListItemImage.js.map +1 -1
- package/build/listItem/Image/ListItemImage.mjs.map +1 -1
- package/build/listItem/ListItem.js.map +1 -1
- package/build/listItem/ListItem.mjs.map +1 -1
- package/build/loader/Loader.js.map +1 -1
- package/build/loader/Loader.mjs.map +1 -1
- package/build/logo/Logo.js.map +1 -1
- package/build/logo/Logo.mjs.map +1 -1
- package/build/main.css +36 -36
- package/build/modal/Modal.js.map +1 -1
- package/build/modal/Modal.mjs.map +1 -1
- package/build/navigationOption/NavigationOption.js.map +1 -1
- package/build/navigationOption/NavigationOption.mjs.map +1 -1
- package/build/navigationOptionsList/NavigationOptionsList.js.map +1 -1
- package/build/navigationOptionsList/NavigationOptionsList.mjs.map +1 -1
- package/build/nudge/Nudge.js.map +1 -1
- package/build/nudge/Nudge.mjs.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
- package/build/popover/Popover.js.map +1 -1
- package/build/popover/Popover.mjs.map +1 -1
- package/build/processIndicator/ProcessIndicator.js.map +1 -1
- package/build/processIndicator/ProcessIndicator.mjs.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
- package/build/radioOption/RadioOption.js.map +1 -1
- package/build/radioOption/RadioOption.mjs.map +1 -1
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs.map +1 -1
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/styles/main.css +36 -36
- package/build/styles/sentimentSurface/SentimentSurface.css +36 -36
- package/build/summary/Summary.js +1 -1
- package/build/summary/Summary.js.map +1 -1
- package/build/summary/Summary.mjs +1 -1
- package/build/summary/Summary.mjs.map +1 -1
- package/build/switchOption/SwitchOption.js +1 -1
- package/build/switchOption/SwitchOption.js.map +1 -1
- package/build/switchOption/SwitchOption.mjs +1 -1
- package/build/switchOption/SwitchOption.mjs.map +1 -1
- package/build/tabs/Tabs.js.map +1 -1
- package/build/tabs/Tabs.mjs.map +1 -1
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/types/accordion/Accordion.d.ts +8 -2
- package/build/types/accordion/Accordion.d.ts.map +1 -1
- package/build/types/actionButton/ActionButton.d.ts +6 -4
- package/build/types/actionButton/ActionButton.d.ts.map +1 -1
- package/build/types/actionOption/ActionOption.d.ts +1 -1
- package/build/types/alert/Alert.d.ts +5 -2
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/avatar/Avatar.d.ts +4 -0
- package/build/types/avatar/Avatar.d.ts.map +1 -1
- package/build/types/avatarLayout/AvatarLayout.d.ts +5 -1
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/badge/Badge.d.ts +2 -0
- package/build/types/badge/Badge.d.ts.map +1 -1
- package/build/types/body/Body.d.ts +2 -6
- package/build/types/body/Body.d.ts.map +1 -1
- package/build/types/button/Button.types.d.ts +4 -1
- package/build/types/button/Button.types.d.ts.map +1 -1
- package/build/types/button/LegacyButton.d.ts +4 -4
- package/build/types/card/Card.d.ts +1 -0
- package/build/types/card/Card.d.ts.map +1 -1
- package/build/types/checkboxButton/CheckboxButton.d.ts +2 -0
- package/build/types/checkboxButton/CheckboxButton.d.ts.map +1 -1
- package/build/types/checkboxOption/CheckboxOption.d.ts +1 -1
- package/build/types/circularButton/CircularButton.d.ts +1 -1
- package/build/types/circularButton/CircularButton.d.ts.map +1 -1
- package/build/types/common/propsValues/type.d.ts +1 -1
- package/build/types/common/propsValues/typography.d.ts +2 -2
- package/build/types/dateInput/DateInput.d.ts +5 -0
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts +6 -0
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/drawer/Drawer.d.ts +8 -2
- package/build/types/drawer/Drawer.d.ts.map +1 -1
- package/build/types/field/Field.d.ts +5 -2
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/flowNavigation/FlowNavigation.d.ts +3 -0
- package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
- package/build/types/header/Header.d.ts +5 -1
- package/build/types/header/Header.d.ts.map +1 -1
- package/build/types/iconButton/IconButton.d.ts +6 -0
- package/build/types/iconButton/IconButton.d.ts.map +1 -1
- package/build/types/legacylistItem/LegacyListItem.d.ts +1 -1
- package/build/types/list/List.d.ts +1 -0
- package/build/types/list/List.d.ts.map +1 -1
- package/build/types/listItem/Button/ListItemButton.d.ts +4 -0
- package/build/types/listItem/Button/ListItemButton.d.ts.map +1 -1
- package/build/types/listItem/IconButton/ListItemIconButton.d.ts +3 -1
- package/build/types/listItem/IconButton/ListItemIconButton.d.ts.map +1 -1
- package/build/types/listItem/Image/ListItemImage.d.ts +2 -0
- package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -1
- package/build/types/listItem/ListItem.d.ts +3 -0
- package/build/types/listItem/ListItem.d.ts.map +1 -1
- package/build/types/loader/Loader.d.ts +5 -1
- package/build/types/loader/Loader.d.ts.map +1 -1
- package/build/types/logo/Logo.d.ts +4 -1
- package/build/types/logo/Logo.d.ts.map +1 -1
- package/build/types/modal/Modal.d.ts +6 -0
- package/build/types/modal/Modal.d.ts.map +1 -1
- package/build/types/navigationOption/NavigationOption.d.ts +1 -1
- package/build/types/navigationOptionsList/NavigationOptionsList.d.ts +1 -1
- package/build/types/nudge/Nudge.d.ts +1 -1
- package/build/types/nudge/Nudge.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +7 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts +1 -0
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/processIndicator/ProcessIndicator.d.ts +2 -0
- package/build/types/processIndicator/ProcessIndicator.d.ts.map +1 -1
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +8 -1
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +1 -0
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
- package/build/types/radioOption/RadioOption.d.ts +1 -1
- package/build/types/select/Select.d.ts +4 -0
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts +3 -1
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/build/types/summary/Summary.d.ts +7 -4
- package/build/types/summary/Summary.d.ts.map +1 -1
- package/build/types/switchOption/SwitchOption.d.ts +1 -1
- package/build/types/tabs/Tabs.d.ts +2 -0
- package/build/types/tabs/Tabs.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +14 -1
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/upload/Upload.d.ts +6 -0
- package/build/types/upload/Upload.d.ts.map +1 -1
- package/build/types/uploadInput/UploadInput.d.ts +10 -1
- package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts +3 -0
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
- package/build/upload/Upload.js.map +1 -1
- package/build/upload/Upload.mjs.map +1 -1
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs.map +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.js.map +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.mjs.map +1 -1
- package/package.json +1 -1
- package/src/accordion/Accordion.tsx +8 -2
- package/src/actionButton/ActionButton.tsx +4 -3
- package/src/actionOption/ActionOption.tsx +1 -1
- package/src/alert/Alert.tsx +5 -2
- package/src/avatar/Avatar.tsx +4 -0
- package/src/avatarLayout/AvatarLayout.tsx +5 -1
- package/src/badge/Badge.tsx +2 -0
- package/src/body/Body.tsx +2 -6
- package/src/button/Button.types.ts +4 -1
- package/src/button/LegacyButton.tsx +4 -4
- package/src/card/Card.tsx +1 -0
- package/src/checkboxButton/CheckboxButton.tsx +1 -0
- package/src/checkboxOption/CheckboxOption.tsx +1 -1
- package/src/circularButton/CircularButton.tsx +1 -2
- package/src/common/propsValues/type.ts +1 -1
- package/src/common/propsValues/typography.ts +2 -2
- package/src/dateInput/DateInput.tsx +5 -0
- package/src/dimmer/Dimmer.tsx +6 -0
- package/src/drawer/Drawer.tsx +8 -2
- package/src/field/Field.tsx +5 -2
- package/src/flowNavigation/FlowNavigation.tsx +3 -0
- package/src/header/Header.tsx +5 -1
- package/src/iconButton/IconButton.tsx +3 -0
- package/src/legacylistItem/LegacyListItem.tsx +1 -1
- package/src/list/List.tsx +1 -0
- package/src/listItem/Button/ListItemButton.tsx +2 -0
- package/src/listItem/IconButton/ListItemIconButton.tsx +3 -1
- package/src/listItem/Image/ListItemImage.tsx +2 -0
- package/src/listItem/ListItem.tsx +2 -0
- package/src/loader/Loader.tsx +6 -2
- package/src/logo/Logo.tsx +4 -1
- package/src/main.css +36 -36
- package/src/modal/Modal.tsx +6 -0
- package/src/navigationOption/NavigationOption.tsx +1 -1
- package/src/navigationOptionsList/NavigationOptionsList.tsx +1 -1
- package/src/nudge/Nudge.tsx +1 -1
- package/src/phoneNumberInput/PhoneNumberInput.tsx +7 -1
- package/src/popover/Popover.tsx +1 -0
- package/src/processIndicator/ProcessIndicator.tsx +2 -0
- package/src/prompt/ActionPrompt/ActionPrompt.tsx +8 -1
- package/src/prompt/InlinePrompt/InlinePrompt.tsx +1 -0
- package/src/radioOption/RadioOption.tsx +1 -1
- package/src/select/Select.tsx +4 -0
- package/src/sentimentSurface/SentimentSurface.css +36 -36
- package/src/sentimentSurface/SentimentSurface.less +12 -12
- package/src/statusIcon/StatusIcon.tsx +3 -1
- package/src/summary/Summary.tsx +7 -4
- package/src/switchOption/SwitchOption.tsx +1 -1
- package/src/tabs/Tabs.tsx +2 -0
- package/src/typeahead/Typeahead.tsx +14 -2
- package/src/upload/Upload.tsx +6 -0
- package/src/uploadInput/UploadInput.tsx +12 -4
- package/src/withDisplayFormat/WithDisplayFormat.tsx +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WithDisplayFormat.mjs","sources":["../../src/withDisplayFormat/WithDisplayFormat.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { HistoryNavigator } from '../common';\nimport {\n formatWithPattern,\n getCountOfSymbolsInSelection,\n getCursorPositionAfterKeystroke,\n unformatWithPattern,\n getDistanceToPreviousSymbol,\n getDistanceToNextSymbol,\n} from '../common/textFormat';\nimport { InputProps } from '../inputs/Input';\nimport { TextAreaProps } from '../inputs/TextArea';\n\ntype HTMLTextElement = HTMLInputElement | HTMLTextAreaElement;\ntype TextElementProps = InputProps | TextAreaProps;\n\nexport type EventType =\n | 'KeyDown'\n | 'Paste'\n | 'Cut'\n | 'Undo'\n | 'Redo'\n | 'Backspace'\n | 'Delete'\n | 'Initial';\n\ninterface WithDisplayFormatState {\n value: string;\n historyNavigator: HistoryNavigator;\n prevDisplayPattern: string;\n triggerType: EventType;\n triggerEvent: React.KeyboardEvent<HTMLTextElement> | null;\n pastedLength: number;\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface WithDisplayFormatProps<T extends TextElementProps = TextElementProps> extends Pick<\n TextElementProps,\n | 'className'\n | 'disabled'\n | 'id'\n | 'maxLength'\n | 'minLength'\n | 'name'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'inputMode'\n> {\n value?: string;\n displayPattern: string;\n /**\n * autocomplete hides our form help so we need to disable it when help text\n * is present. Chrome ignores autocomplete=off, the only way to disable it is\n * to provide an 'invalid' value, for which 'disabled' serves.\n */\n autoComplete?: TextElementProps['autoComplete'] | 'disabled';\n onChange?: (value: string) => void;\n onBlur?: (value: string) => void;\n onFocus?: (value: string) => void;\n render: (renderProps: T) => React.JSX.Element;\n}\n\nclass WithDisplayFormat<T extends TextElementProps> extends React.Component<\n WithDisplayFormatProps<T>,\n WithDisplayFormatState\n> {\n declare props: WithDisplayFormatProps<T> &\n Required<Pick<WithDisplayFormatProps<T>, keyof typeof WithDisplayFormat.defaultProps>>;\n static defaultProps = {\n autoComplete: 'off',\n displayPattern: '',\n value: '',\n };\n\n constructor(props: WithDisplayFormatProps) {\n super(props);\n const unformattedValue = unformatWithPattern(props.value ?? '', props.displayPattern);\n this.state = {\n value: formatWithPattern(unformattedValue, props.displayPattern),\n historyNavigator: new HistoryNavigator(),\n prevDisplayPattern: props.displayPattern,\n triggerType: 'Initial',\n triggerEvent: null,\n selectionStart: 0,\n selectionEnd: 0,\n pastedLength: 0,\n };\n }\n\n static getDerivedStateFromProps(\n { displayPattern }: WithDisplayFormatProps,\n { prevDisplayPattern = displayPattern, value, historyNavigator }: WithDisplayFormatState,\n ) {\n if (prevDisplayPattern !== displayPattern) {\n const unFormattedValue = unformatWithPattern(value, prevDisplayPattern);\n historyNavigator.reset();\n\n return {\n prevDisplayPattern: displayPattern,\n value: formatWithPattern(unFormattedValue, displayPattern),\n triggerType: null,\n triggerEvent: null,\n pastedLength: 0,\n };\n }\n return null;\n }\n\n getUserAction = (unformattedValue: string): EventType | string => {\n const { triggerEvent, triggerType, value } = this.state;\n const { displayPattern } = this.props;\n\n if (triggerEvent) {\n if (triggerType === 'Paste' || triggerType === 'Cut') {\n return triggerType;\n }\n\n if ((triggerEvent.ctrlKey || triggerEvent.metaKey) && triggerEvent.key === 'z') {\n return triggerEvent.shiftKey ? 'Redo' : 'Undo';\n }\n\n // Detect mouse event redo\n if (triggerEvent.ctrlKey && triggerEvent.key === 'd') {\n return 'Delete';\n }\n\n // Android Fix.\n if (\n typeof triggerEvent.key === 'undefined' &&\n unformattedValue.length <= unformatWithPattern(value, displayPattern).length\n ) {\n return 'Backspace';\n }\n return triggerEvent.key;\n }\n // triggerEvent can be null only in case of \"autofilling\" (via password manager extension or browser build-in one) events\n return 'Paste';\n };\n\n resetEvent = () => {\n this.setState({\n triggerType: 'Initial',\n triggerEvent: null,\n pastedLength: 0,\n });\n };\n\n detectUndoRedo = (event: React.KeyboardEvent<HTMLTextElement>) => {\n if ((event.ctrlKey || event.metaKey) && event.key === 'z') {\n return event.shiftKey ? 'Redo' : 'Undo';\n }\n return null;\n };\n\n handleOnKeyDown: React.KeyboardEventHandler<HTMLTextElement> = (event) => {\n event.persist();\n const { selectionStart, selectionEnd } = event.currentTarget;\n const { historyNavigator } = this.state;\n const { displayPattern } = this.props;\n\n // Unfortunately Undo and Redo don't trigger OnChange event so we need to handle some value logic here.\n let newFormattedValue = '';\n\n if (this.detectUndoRedo(event) === 'Undo') {\n newFormattedValue = formatWithPattern(historyNavigator.undo().toString(), displayPattern);\n this.setState({ value: newFormattedValue, triggerType: 'Undo' });\n } else if (this.detectUndoRedo(event) === 'Redo') {\n newFormattedValue = formatWithPattern(historyNavigator.redo().toString(), displayPattern);\n this.setState({ value: newFormattedValue, triggerType: 'Redo' });\n } else {\n this.setState({\n triggerEvent: event,\n triggerType: 'KeyDown',\n selectionStart: selectionStart ?? 0,\n selectionEnd: selectionEnd ?? 0,\n });\n }\n };\n\n handleOnPaste: React.ClipboardEventHandler<HTMLTextElement> = (event) => {\n const { displayPattern } = this.props;\n const pastedLength = unformatWithPattern(\n event.clipboardData.getData('Text'),\n displayPattern,\n ).length;\n\n this.setState({ triggerType: 'Paste', pastedLength });\n };\n\n handleOnCut: React.ClipboardEventHandler<HTMLTextElement> = () => {\n this.setState({ triggerType: 'Cut' });\n };\n\n isKeyAllowed = (action: EventType | string) => {\n const { displayPattern } = this.props;\n const symbolsInPattern = displayPattern.split('').filter((character) => character !== '*');\n\n return !symbolsInPattern.includes(action);\n };\n\n handleOnChange: React.ChangeEventHandler<HTMLTextElement> = (event) => {\n const { historyNavigator, triggerType } = this.state;\n const { displayPattern, onChange } = this.props;\n const { value } = event.target;\n let unformattedValue = unformatWithPattern(value, displayPattern);\n const action = this.getUserAction(unformattedValue);\n if (!this.isKeyAllowed(action) || triggerType === 'Undo' || triggerType === 'Redo') {\n return;\n }\n\n if (action === 'Backspace' || action === 'Delete') {\n unformattedValue = this.handleDelete(unformattedValue, action);\n }\n\n const newFormattedValue = formatWithPattern(unformattedValue, displayPattern);\n historyNavigator.add(unformattedValue);\n\n this.handleCursorPositioning(action);\n\n this.setState({ value: newFormattedValue }, () => {\n this.resetEvent();\n if (onChange) {\n const broadcastValue = unformatWithPattern(newFormattedValue, displayPattern);\n onChange(broadcastValue);\n }\n });\n };\n\n handleOnBlur: React.FocusEventHandler<HTMLTextElement> = (event) => {\n this.props.onBlur?.(unformatWithPattern(event.target.value, this.props.displayPattern));\n };\n\n handleOnFocus: React.FocusEventHandler<HTMLTextElement> = (event) => {\n const { displayPattern, onFocus } = this.props;\n if (onFocus) {\n onFocus(unformatWithPattern(event.target.value, displayPattern));\n }\n };\n\n handleDelete = (unformattedValue: string, action: EventType) => {\n const { displayPattern } = this.props;\n const { selectionStart, selectionEnd } = this.state;\n const newStack = [...unformattedValue];\n if (selectionStart === selectionEnd) {\n let startPosition =\n selectionStart - getCountOfSymbolsInSelection(0, selectionStart, displayPattern);\n let toDelete = 0;\n\n let count = getDistanceToNextSymbol(selectionStart, displayPattern);\n if (action === 'Backspace') {\n startPosition -= 1;\n count = getDistanceToPreviousSymbol(selectionStart, displayPattern);\n }\n\n if (startPosition >= 0 && count) {\n toDelete = 1;\n }\n\n newStack.splice(startPosition, toDelete);\n }\n\n return newStack.join('');\n };\n\n handleCursorPositioning = (action: string) => {\n const { displayPattern } = this.props;\n const { triggerEvent, selectionStart, selectionEnd, pastedLength } = this.state;\n\n const cursorPosition = getCursorPositionAfterKeystroke(\n action,\n selectionStart,\n selectionEnd,\n displayPattern,\n pastedLength,\n );\n\n setTimeout(() => {\n if (triggerEvent) {\n (triggerEvent.target as HTMLTextElement).setSelectionRange(cursorPosition, cursorPosition);\n }\n this.setState({ selectionStart: cursorPosition, selectionEnd: cursorPosition });\n }, 0);\n };\n\n render() {\n const {\n inputMode,\n className,\n id,\n name,\n placeholder,\n readOnly,\n required,\n minLength,\n maxLength,\n disabled,\n autoComplete,\n } = this.props;\n const { value } = this.state;\n const renderProps: TextElementProps = {\n inputMode,\n className,\n id,\n name,\n placeholder,\n readOnly,\n required,\n minLength,\n maxLength,\n disabled,\n autoComplete,\n value,\n onFocus: this.handleOnFocus,\n onBlur: this.handleOnBlur,\n onPaste: this.handleOnPaste,\n onKeyDown: this.handleOnKeyDown,\n onChange: this.handleOnChange,\n onCut: this.handleOnCut,\n };\n return this.props.render(renderProps as T);\n }\n}\n\nexport default WithDisplayFormat;\n"],"names":["WithDisplayFormat","React","Component","defaultProps","autoComplete","displayPattern","value","constructor","props","unformattedValue","unformatWithPattern","state","formatWithPattern","historyNavigator","HistoryNavigator","prevDisplayPattern","triggerType","triggerEvent","selectionStart","selectionEnd","pastedLength","getDerivedStateFromProps","unFormattedValue","reset","getUserAction","ctrlKey","metaKey","key","shiftKey","length","resetEvent","setState","detectUndoRedo","event","handleOnKeyDown","persist","currentTarget","newFormattedValue","undo","toString","redo","handleOnPaste","clipboardData","getData","handleOnCut","isKeyAllowed","action","symbolsInPattern","split","filter","character","includes","handleOnChange","onChange","target","handleDelete","add","handleCursorPositioning","broadcastValue","handleOnBlur","onBlur","handleOnFocus","onFocus","newStack","startPosition","getCountOfSymbolsInSelection","toDelete","count","getDistanceToNextSymbol","getDistanceToPreviousSymbol","splice","join","cursorPosition","getCursorPositionAfterKeystroke","setTimeout","setSelectionRange","render","inputMode","className","id","name","placeholder","readOnly","required","minLength","maxLength","disabled","renderProps","onPaste","onKeyDown","onCut"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,MAAMA,iBAA8C,SAAQC,KAAK,CAACC,SAGjE,CAAA;AAGC,EAAA,OAAOC,YAAY,GAAG;AACpBC,IAAAA,YAAY,EAAE,KAAK;AACnBC,IAAAA,cAAc,EAAE,EAAE;AAClBC,IAAAA,KAAK,EAAE;GACR;EAEDC,WAAAA,CAAYC,KAA6B,EAAA;IACvC,KAAK,CAACA,KAAK,CAAC;AACZ,IAAA,MAAMC,gBAAgB,GAAGC,mBAAmB,CAACF,KAAK,CAACF,KAAK,IAAI,EAAE,EAAEE,KAAK,CAACH,cAAc,CAAC;IACrF,IAAI,CAACM,KAAK,GAAG;MACXL,KAAK,EAAEM,iBAAiB,CAACH,gBAAgB,EAAED,KAAK,CAACH,cAAc,CAAC;AAChEQ,MAAAA,gBAAgB,EAAE,IAAIC,gBAAgB,EAAE;MACxCC,kBAAkB,EAAEP,KAAK,CAACH,cAAc;AACxCW,MAAAA,WAAW,EAAE,SAAS;AACtBC,MAAAA,YAAY,EAAE,IAAI;AAClBC,MAAAA,cAAc,EAAE,CAAC;AACjBC,MAAAA,YAAY,EAAE,CAAC;AACfC,MAAAA,YAAY,EAAE;KACf;AACH,EAAA;AAEA,EAAA,OAAOC,wB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,OAAO,EAAE,IAAI,CAACD,aAAa;MAC3BD,MAAM,EAAE,IAAI,CAACD,YAAY;MACzB6B,OAAO,EAAE,IAAI,CAAC/C,aAAa;MAC3BgD,SAAS,EAAE,IAAI,CAACvD,eAAe;MAC/BmB,QAAQ,EAAE,IAAI,CAACD,cAAc;MAC7BsC,KAAK,EAAE,IAAI,CAAC9C;KACb;AACD,IAAA,OAAO,IAAI,CAACpC,KAAK,CAACoE,MAAM,CAACW,WAAgB,CAAC;AAC5C,EAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"WithDisplayFormat.mjs","sources":["../../src/withDisplayFormat/WithDisplayFormat.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { HistoryNavigator } from '../common';\nimport {\n formatWithPattern,\n getCountOfSymbolsInSelection,\n getCursorPositionAfterKeystroke,\n unformatWithPattern,\n getDistanceToPreviousSymbol,\n getDistanceToNextSymbol,\n} from '../common/textFormat';\nimport { InputProps } from '../inputs/Input';\nimport { TextAreaProps } from '../inputs/TextArea';\n\ntype HTMLTextElement = HTMLInputElement | HTMLTextAreaElement;\ntype TextElementProps = InputProps | TextAreaProps;\n\nexport type EventType =\n | 'KeyDown'\n | 'Paste'\n | 'Cut'\n | 'Undo'\n | 'Redo'\n | 'Backspace'\n | 'Delete'\n | 'Initial';\n\ninterface WithDisplayFormatState {\n value: string;\n historyNavigator: HistoryNavigator;\n prevDisplayPattern: string;\n triggerType: EventType;\n triggerEvent: React.KeyboardEvent<HTMLTextElement> | null;\n pastedLength: number;\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface WithDisplayFormatProps<T extends TextElementProps = TextElementProps> extends Pick<\n TextElementProps,\n | 'className'\n | 'disabled'\n | 'id'\n | 'maxLength'\n | 'minLength'\n | 'name'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'inputMode'\n> {\n /** @default '' */\n value?: string;\n /** @default '' */\n displayPattern: string;\n /**\n * autocomplete hides our form help so we need to disable it when help text\n * is present. Chrome ignores autocomplete=off, the only way to disable it is\n * to provide an 'invalid' value, for which 'disabled' serves.\n * @default 'off'\n */\n autoComplete?: TextElementProps['autoComplete'] | 'disabled';\n onChange?: (value: string) => void;\n onBlur?: (value: string) => void;\n onFocus?: (value: string) => void;\n render: (renderProps: T) => React.JSX.Element;\n}\n\nclass WithDisplayFormat<T extends TextElementProps> extends React.Component<\n WithDisplayFormatProps<T>,\n WithDisplayFormatState\n> {\n declare props: WithDisplayFormatProps<T> &\n Required<Pick<WithDisplayFormatProps<T>, keyof typeof WithDisplayFormat.defaultProps>>;\n static defaultProps = {\n autoComplete: 'off',\n displayPattern: '',\n value: '',\n };\n\n constructor(props: WithDisplayFormatProps) {\n super(props);\n const unformattedValue = unformatWithPattern(props.value ?? '', props.displayPattern);\n this.state = {\n value: formatWithPattern(unformattedValue, props.displayPattern),\n historyNavigator: new HistoryNavigator(),\n prevDisplayPattern: props.displayPattern,\n triggerType: 'Initial',\n triggerEvent: null,\n selectionStart: 0,\n selectionEnd: 0,\n pastedLength: 0,\n };\n }\n\n static getDerivedStateFromProps(\n { displayPattern }: WithDisplayFormatProps,\n { prevDisplayPattern = displayPattern, value, historyNavigator }: WithDisplayFormatState,\n ) {\n if (prevDisplayPattern !== displayPattern) {\n const unFormattedValue = unformatWithPattern(value, prevDisplayPattern);\n historyNavigator.reset();\n\n return {\n prevDisplayPattern: displayPattern,\n value: formatWithPattern(unFormattedValue, displayPattern),\n triggerType: null,\n triggerEvent: null,\n pastedLength: 0,\n };\n }\n return null;\n }\n\n getUserAction = (unformattedValue: string): EventType | string => {\n const { triggerEvent, triggerType, value } = this.state;\n const { displayPattern } = this.props;\n\n if (triggerEvent) {\n if (triggerType === 'Paste' || triggerType === 'Cut') {\n return triggerType;\n }\n\n if ((triggerEvent.ctrlKey || triggerEvent.metaKey) && triggerEvent.key === 'z') {\n return triggerEvent.shiftKey ? 'Redo' : 'Undo';\n }\n\n // Detect mouse event redo\n if (triggerEvent.ctrlKey && triggerEvent.key === 'd') {\n return 'Delete';\n }\n\n // Android Fix.\n if (\n typeof triggerEvent.key === 'undefined' &&\n unformattedValue.length <= unformatWithPattern(value, displayPattern).length\n ) {\n return 'Backspace';\n }\n return triggerEvent.key;\n }\n // triggerEvent can be null only in case of \"autofilling\" (via password manager extension or browser build-in one) events\n return 'Paste';\n };\n\n resetEvent = () => {\n this.setState({\n triggerType: 'Initial',\n triggerEvent: null,\n pastedLength: 0,\n });\n };\n\n detectUndoRedo = (event: React.KeyboardEvent<HTMLTextElement>) => {\n if ((event.ctrlKey || event.metaKey) && event.key === 'z') {\n return event.shiftKey ? 'Redo' : 'Undo';\n }\n return null;\n };\n\n handleOnKeyDown: React.KeyboardEventHandler<HTMLTextElement> = (event) => {\n event.persist();\n const { selectionStart, selectionEnd } = event.currentTarget;\n const { historyNavigator } = this.state;\n const { displayPattern } = this.props;\n\n // Unfortunately Undo and Redo don't trigger OnChange event so we need to handle some value logic here.\n let newFormattedValue = '';\n\n if (this.detectUndoRedo(event) === 'Undo') {\n newFormattedValue = formatWithPattern(historyNavigator.undo().toString(), displayPattern);\n this.setState({ value: newFormattedValue, triggerType: 'Undo' });\n } else if (this.detectUndoRedo(event) === 'Redo') {\n newFormattedValue = formatWithPattern(historyNavigator.redo().toString(), displayPattern);\n this.setState({ value: newFormattedValue, triggerType: 'Redo' });\n } else {\n this.setState({\n triggerEvent: event,\n triggerType: 'KeyDown',\n selectionStart: selectionStart ?? 0,\n selectionEnd: selectionEnd ?? 0,\n });\n }\n };\n\n handleOnPaste: React.ClipboardEventHandler<HTMLTextElement> = (event) => {\n const { displayPattern } = this.props;\n const pastedLength = unformatWithPattern(\n event.clipboardData.getData('Text'),\n displayPattern,\n ).length;\n\n this.setState({ triggerType: 'Paste', pastedLength });\n };\n\n handleOnCut: React.ClipboardEventHandler<HTMLTextElement> = () => {\n this.setState({ triggerType: 'Cut' });\n };\n\n isKeyAllowed = (action: EventType | string) => {\n const { displayPattern } = this.props;\n const symbolsInPattern = displayPattern.split('').filter((character) => character !== '*');\n\n return !symbolsInPattern.includes(action);\n };\n\n handleOnChange: React.ChangeEventHandler<HTMLTextElement> = (event) => {\n const { historyNavigator, triggerType } = this.state;\n const { displayPattern, onChange } = this.props;\n const { value } = event.target;\n let unformattedValue = unformatWithPattern(value, displayPattern);\n const action = this.getUserAction(unformattedValue);\n if (!this.isKeyAllowed(action) || triggerType === 'Undo' || triggerType === 'Redo') {\n return;\n }\n\n if (action === 'Backspace' || action === 'Delete') {\n unformattedValue = this.handleDelete(unformattedValue, action);\n }\n\n const newFormattedValue = formatWithPattern(unformattedValue, displayPattern);\n historyNavigator.add(unformattedValue);\n\n this.handleCursorPositioning(action);\n\n this.setState({ value: newFormattedValue }, () => {\n this.resetEvent();\n if (onChange) {\n const broadcastValue = unformatWithPattern(newFormattedValue, displayPattern);\n onChange(broadcastValue);\n }\n });\n };\n\n handleOnBlur: React.FocusEventHandler<HTMLTextElement> = (event) => {\n this.props.onBlur?.(unformatWithPattern(event.target.value, this.props.displayPattern));\n };\n\n handleOnFocus: React.FocusEventHandler<HTMLTextElement> = (event) => {\n const { displayPattern, onFocus } = this.props;\n if (onFocus) {\n onFocus(unformatWithPattern(event.target.value, displayPattern));\n }\n };\n\n handleDelete = (unformattedValue: string, action: EventType) => {\n const { displayPattern } = this.props;\n const { selectionStart, selectionEnd } = this.state;\n const newStack = [...unformattedValue];\n if (selectionStart === selectionEnd) {\n let startPosition =\n selectionStart - getCountOfSymbolsInSelection(0, selectionStart, displayPattern);\n let toDelete = 0;\n\n let count = getDistanceToNextSymbol(selectionStart, displayPattern);\n if (action === 'Backspace') {\n startPosition -= 1;\n count = getDistanceToPreviousSymbol(selectionStart, displayPattern);\n }\n\n if (startPosition >= 0 && count) {\n toDelete = 1;\n }\n\n newStack.splice(startPosition, toDelete);\n }\n\n return newStack.join('');\n };\n\n handleCursorPositioning = (action: string) => {\n const { displayPattern } = this.props;\n const { triggerEvent, selectionStart, selectionEnd, pastedLength } = this.state;\n\n const cursorPosition = getCursorPositionAfterKeystroke(\n action,\n selectionStart,\n selectionEnd,\n displayPattern,\n pastedLength,\n );\n\n setTimeout(() => {\n if (triggerEvent) {\n (triggerEvent.target as HTMLTextElement).setSelectionRange(cursorPosition, cursorPosition);\n }\n this.setState({ selectionStart: cursorPosition, selectionEnd: cursorPosition });\n }, 0);\n };\n\n render() {\n const {\n inputMode,\n className,\n id,\n name,\n placeholder,\n readOnly,\n required,\n minLength,\n maxLength,\n disabled,\n autoComplete,\n } = this.props;\n const { value } = this.state;\n const renderProps: TextElementProps = {\n inputMode,\n className,\n id,\n name,\n placeholder,\n readOnly,\n required,\n minLength,\n maxLength,\n disabled,\n autoComplete,\n value,\n onFocus: this.handleOnFocus,\n onBlur: this.handleOnBlur,\n onPaste: this.handleOnPaste,\n onKeyDown: this.handleOnKeyDown,\n onChange: this.handleOnChange,\n onCut: this.handleOnCut,\n };\n return this.props.render(renderProps as T);\n }\n}\n\nexport default WithDisplayFormat;\n"],"names":["WithDisplayFormat","React","Component","defaultProps","autoComplete","displayPattern","value","constructor","props","unformattedValue","unformatWithPattern","state","formatWithPattern","historyNavigator","HistoryNavigator","prevDisplayPattern","triggerType","triggerEvent","selectionStart","selectionEnd","pastedLength","getDerivedStateFromProps","unFormattedValue","reset","getUserAction","ctrlKey","metaKey","key","shiftKey","length","resetEvent","setState","detectUndoRedo","event","handleOnKeyDown","persist","currentTarget","newFormattedValue","undo","toString","redo","handleOnPaste","clipboardData","getData","handleOnCut","isKeyAllowed","action","symbolsInPattern","split","filter","character","includes","handleOnChange","onChange","target","handleDelete","add","handleCursorPositioning","broadcastValue","handleOnBlur","onBlur","handleOnFocus","onFocus","newStack","startPosition","getCountOfSymbolsInSelection","toDelete","count","getDistanceToNextSymbol","getDistanceToPreviousSymbol","splice","join","cursorPosition","getCursorPositionAfterKeystroke","setTimeout","setSelectionRange","render","inputMode","className","id","name","placeholder","readOnly","required","minLength","maxLength","disabled","renderProps","onPaste","onKeyDown","onCut"],"mappings":";;;;;;;;;;;;;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AAY,CACb;AAEDsD,IAAAA,UAAU,CAAC,MAAK;AACd,MAAA,IAAIzD,YAAY,EAAE;QACfA,YAAY,CAACqC,MAA0B,CAACqB,iBAAiB,CAACH,cAAc,EAAEA,cAAc,CAAC;AAC5F,MAAA;MACA,IAAI,CAACzC,QAAQ,CAAC;AAAEb,QAAAA,cAAc,EAAEsD,cAAc;AAAErD,QAAAA,YAAY,EAAEqD;AAAc,OAAE,CAAC;IACjF,CAAC,EAAE,CAAC,CAAC;EACP,CAAC;AAEDI,EAAAA,MAAMA,GAAA;IACJ,MAAM;MACJC,SAAS;MACTC,SAAS;MACTC,EAAE;MACFC,IAAI;MACJC,WAAW;MACXC,QAAQ;MACRC,QAAQ;MACRC,SAAS;MACTC,SAAS;MACTC,QAAQ;AACRlF,MAAAA;KACD,GAAG,IAAI,CAACI,KAAK;IACd,MAAM;AAAEF,MAAAA;KAAO,GAAG,IAAI,CAACK,KAAK;AAC5B,IAAA,MAAM4E,WAAW,GAAqB;MACpCV,SAAS;MACTC,SAAS;MACTC,EAAE;MACFC,IAAI;MACJC,WAAW;MACXC,QAAQ;MACRC,QAAQ;MACRC,SAAS;MACTC,SAAS;MACTC,QAAQ;MACRlF,YAAY;MACZE,KAAK;MACLwD,OAAO,EAAE,IAAI,CAACD,aAAa;MAC3BD,MAAM,EAAE,IAAI,CAACD,YAAY;MACzB6B,OAAO,EAAE,IAAI,CAAC/C,aAAa;MAC3BgD,SAAS,EAAE,IAAI,CAACvD,eAAe;MAC/BmB,QAAQ,EAAE,IAAI,CAACD,cAAc;MAC7BsC,KAAK,EAAE,IAAI,CAAC9C;KACb;AACD,IAAA,OAAO,IAAI,CAACpC,KAAK,CAACoE,MAAM,CAACW,WAAgB,CAAC;AAC5C,EAAA;;;;;"}
|
package/package.json
CHANGED
|
@@ -5,13 +5,19 @@ import AccordionItem, { AccordionItemProps } from './AccordionItem';
|
|
|
5
5
|
export type AccordionItem = Omit<AccordionItemProps, 'onClick' | 'open' | 'theme'>;
|
|
6
6
|
|
|
7
7
|
export interface AccordionProps {
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* The index of the item that should be open by default.
|
|
10
|
+
* @default -1
|
|
11
|
+
*/
|
|
9
12
|
indexOpen?: number;
|
|
10
13
|
/** An array of items to display in the accordion. */
|
|
11
14
|
items: readonly AccordionItem[];
|
|
12
15
|
/** A callback function that is called when an item is clicked. */
|
|
13
16
|
onClick?: (index: number) => void;
|
|
14
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated
|
|
19
|
+
* @default 'light'
|
|
20
|
+
*/
|
|
15
21
|
theme?: 'light' | 'dark';
|
|
16
22
|
}
|
|
17
23
|
|
|
@@ -4,18 +4,19 @@ import { ButtonHTMLAttributes, forwardRef } from 'react';
|
|
|
4
4
|
import { Priority, PriorityPrimary, PrioritySecondary, PriorityTertiary } from '../common';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @deprecated
|
|
7
|
+
* @deprecated Use `<Button />` component instead with `ButtonProps`.
|
|
8
8
|
*/
|
|
9
9
|
export type ActionButtonProps = {
|
|
10
|
+
/** @default Priority.PRIMARY */
|
|
10
11
|
priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary;
|
|
11
12
|
/**
|
|
12
|
-
* @deprecated
|
|
13
|
+
* @deprecated Use `children` instead.
|
|
13
14
|
*/
|
|
14
15
|
text?: string;
|
|
15
16
|
} & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
|
-
* @deprecated
|
|
19
|
+
* @deprecated Use `<Button v2 size="sm" priority={'primary' / 'secondary-neutral' / 'tertiary'} .. />` component instead.
|
|
19
20
|
*/
|
|
20
21
|
const ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(
|
|
21
22
|
(
|
|
@@ -36,7 +36,7 @@ export type ActionOptionProps = {
|
|
|
36
36
|
AriaLabelProperty;
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* @deprecated
|
|
39
|
+
* @deprecated Use `<ListItem />` instead.
|
|
40
40
|
* @deprecatedSince 46.104.0
|
|
41
41
|
* @see [Source](../listItem/ListItem.tsx)
|
|
42
42
|
* @see [Storybook](https://storybook.wise.design/?path=/docs/content-listitem--docs)
|
package/src/alert/Alert.tsx
CHANGED
|
@@ -78,7 +78,10 @@ export interface AlertProps {
|
|
|
78
78
|
message?: string;
|
|
79
79
|
/** The presence of the onDismiss handler will trigger the visibility of the close button */
|
|
80
80
|
onDismiss?: React.MouseEventHandler<HTMLButtonElement>;
|
|
81
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* The type dictates which icon and colour will be used
|
|
83
|
+
* @default 'neutral'
|
|
84
|
+
*/
|
|
82
85
|
type?: AlertType;
|
|
83
86
|
/** @deprecated Use `InlinePrompt` instead. */
|
|
84
87
|
arrow?: `${AlertArrowPosition}`;
|
|
@@ -104,7 +107,7 @@ function resolveType(type: AlertType): AlertTypeResolved {
|
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
/**
|
|
107
|
-
* @deprecated
|
|
110
|
+
* @deprecated Use [`InfoPrompt`](https://storybook.wise.design/?path=/docs/prompts-infoprompt--docs) component instead.
|
|
108
111
|
*/
|
|
109
112
|
export default function Alert({
|
|
110
113
|
action,
|
package/src/avatar/Avatar.tsx
CHANGED
|
@@ -23,9 +23,13 @@ export interface AvatarProps {
|
|
|
23
23
|
backgroundColorSeed?: string;
|
|
24
24
|
children?: React.ReactNode;
|
|
25
25
|
className?: string;
|
|
26
|
+
/** @default false */
|
|
26
27
|
outlined?: boolean;
|
|
28
|
+
/** @default 48 */
|
|
27
29
|
size?: AvatarSize;
|
|
30
|
+
/** @default 'light' */
|
|
28
31
|
theme?: AvatarTheme;
|
|
32
|
+
/** @default 'thumbnail' */
|
|
29
33
|
type?: AvatarType;
|
|
30
34
|
'aria-label'?: string;
|
|
31
35
|
}
|
|
@@ -8,11 +8,15 @@ type SingleAvatarType = { asset?: AvatarViewProps['children'] } & Omit<
|
|
|
8
8
|
>;
|
|
9
9
|
|
|
10
10
|
export type Props = {
|
|
11
|
+
/** @default [] */
|
|
11
12
|
avatars: SingleAvatarType[];
|
|
13
|
+
/** @default 'horizontal' */
|
|
12
14
|
orientation?: 'horizontal' | 'diagonal';
|
|
15
|
+
/** @default 48 */
|
|
16
|
+
size?: AvatarViewProps['size'];
|
|
13
17
|
} & Pick<
|
|
14
18
|
AvatarViewProps,
|
|
15
|
-
'
|
|
19
|
+
'interactive' | 'className' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-hidden'
|
|
16
20
|
>;
|
|
17
21
|
|
|
18
22
|
export default function AvatarLayout({
|
package/src/badge/Badge.tsx
CHANGED
|
@@ -26,8 +26,10 @@ export type BadgeProps = {
|
|
|
26
26
|
children: ReactNode;
|
|
27
27
|
/**
|
|
28
28
|
* `md` is deprecated, it will fallback to `sm` instead.
|
|
29
|
+
* @default 'sm'
|
|
29
30
|
*/
|
|
30
31
|
size?: DeprecatedSizes | BadgeAssetsProps['size'];
|
|
32
|
+
/** @default 'light' */
|
|
31
33
|
border?: ThemeDark | ThemeLight;
|
|
32
34
|
'aria-label'?: string;
|
|
33
35
|
style?: React.CSSProperties;
|
package/src/body/Body.tsx
CHANGED
|
@@ -13,13 +13,9 @@ const bodyTypes = new Set<BodyTypes>([
|
|
|
13
13
|
]);
|
|
14
14
|
|
|
15
15
|
type Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {
|
|
16
|
-
/**
|
|
17
|
-
* Default value: {@link DEFAULT_TYPE}
|
|
18
|
-
*/
|
|
16
|
+
/** @default 'body-default' */
|
|
19
17
|
type?: BodyTypes;
|
|
20
|
-
/**
|
|
21
|
-
* Default value: `div`
|
|
22
|
-
*/
|
|
18
|
+
/** @default 'div' */
|
|
23
19
|
as?: 'span' | 'p' | 'div';
|
|
24
20
|
/**
|
|
25
21
|
* When true, preserves newline characters in the text
|
|
@@ -41,7 +41,10 @@ export interface CommonProps {
|
|
|
41
41
|
/** @default false */
|
|
42
42
|
loading?: boolean;
|
|
43
43
|
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Makes the button take up the full width of its container
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
45
48
|
block?: boolean;
|
|
46
49
|
|
|
47
50
|
/**
|
|
@@ -31,7 +31,7 @@ type DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';
|
|
|
31
31
|
type DeprecatedSizes = SizeExtraSmall;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* @deprecated
|
|
34
|
+
* @deprecated Use new button instead of these APIs.
|
|
35
35
|
* @example
|
|
36
36
|
* ```
|
|
37
37
|
* import { Button, ButtonProps } from '@transferwise/components';
|
|
@@ -68,7 +68,7 @@ export type CommonProps = {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* @deprecated
|
|
71
|
+
* @deprecated Use new button instead of APIs.
|
|
72
72
|
* @example
|
|
73
73
|
* ```
|
|
74
74
|
* import { Button, ButtonProps } from '@transferwise/components';
|
|
@@ -87,7 +87,7 @@ type AnchorProps = CommonProps &
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* @deprecated
|
|
90
|
+
* @deprecated Use new button instead of APIs.
|
|
91
91
|
* @example
|
|
92
92
|
* ```
|
|
93
93
|
* import { Button, ButtonProps } from '@transferwise/components';
|
|
@@ -98,7 +98,7 @@ type AnchorProps = CommonProps &
|
|
|
98
98
|
export type LegacyButtonProps = ButtonProps | AnchorProps;
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
* @deprecated
|
|
101
|
+
* @deprecated Use new Button component via `<Button v2 .. />` and new props.
|
|
102
102
|
*/
|
|
103
103
|
const LegacyButton = forwardRef<ButtonReferenceType, LegacyButtonProps>(
|
|
104
104
|
(
|
package/src/card/Card.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { InputHTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef
|
|
|
4
4
|
import { useInputAttributes } from '../inputs/contexts';
|
|
5
5
|
|
|
6
6
|
export type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
7
|
+
/** @default false */
|
|
7
8
|
indeterminate?: boolean;
|
|
8
9
|
};
|
|
9
10
|
|
|
@@ -16,7 +16,7 @@ export type CheckboxOptionProps = Omit<BaseOptionProps, 'onChange'> & {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @deprecated
|
|
19
|
+
* @deprecated Use `<ListItem />` instead.
|
|
20
20
|
* @deprecatedSince 46.104.0
|
|
21
21
|
* @see [Source](../listItem/ListItem.tsx)
|
|
22
22
|
* @see [Storybook](https://storybook.wise.design/?path=/docs/content-listitem--docs)
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
|
|
3
3
|
import Body from '../body/Body';
|
|
4
|
-
import { typeClassMap, priorityClassMap } from '../button/classMap';
|
|
5
4
|
import { Breakpoint, ControlType, Priority, Typography } from '../common';
|
|
6
5
|
import IconButton, { IconButtonProps } from '../iconButton';
|
|
7
6
|
import { useMedia } from '../common/hooks/useMedia';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
* @deprecated
|
|
9
|
+
* @deprecated Use `'default'` instead.
|
|
11
10
|
*/
|
|
12
11
|
type DeprecatedTypes = `${ControlType.ACCENT | ControlType.POSITIVE}`;
|
|
13
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export enum Typography {
|
|
2
2
|
/**
|
|
3
|
-
* @deprecated
|
|
3
|
+
* @deprecated Use Marketing titles or {@link Typography.DISPLAY_LARGE} instead.
|
|
4
4
|
*/
|
|
5
5
|
DISPLAY_EXTRA_LARGE = 'display-extra-large',
|
|
6
6
|
DISPLAY_LARGE = 'display-large',
|
|
@@ -24,7 +24,7 @@ export enum Typography {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* @deprecated
|
|
27
|
+
* @deprecated Use {@link Typography.DISPLAY_LARGE} instead.
|
|
28
28
|
*/
|
|
29
29
|
export type DisplayExtraLarge = 'display-extra-large';
|
|
30
30
|
export type DisplayLarge = 'display-large';
|
|
@@ -27,7 +27,9 @@ export interface DateInputProps {
|
|
|
27
27
|
/** @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead. */
|
|
28
28
|
'aria-label'?: string;
|
|
29
29
|
'aria-labelledby'?: string;
|
|
30
|
+
/** @default false */
|
|
30
31
|
disabled?: boolean;
|
|
32
|
+
/** @default 'md' */
|
|
31
33
|
size?: SizeSmall | SizeMedium | SizeLarge;
|
|
32
34
|
value?: Date | string;
|
|
33
35
|
onChange: (value: string | null) => void;
|
|
@@ -38,7 +40,9 @@ export interface DateInputProps {
|
|
|
38
40
|
monthLabel?: string;
|
|
39
41
|
yearLabel?: string;
|
|
40
42
|
yearAutoComplete?: string;
|
|
43
|
+
/** @default 'long' */
|
|
41
44
|
monthFormat?: `${MonthFormat}`;
|
|
45
|
+
/** @default 'day-month-year' */
|
|
42
46
|
mode?: `${DateMode}`;
|
|
43
47
|
placeholders?: {
|
|
44
48
|
day?: string;
|
|
@@ -46,6 +50,7 @@ export interface DateInputProps {
|
|
|
46
50
|
year?: string;
|
|
47
51
|
};
|
|
48
52
|
id?: string;
|
|
53
|
+
/** @default {} */
|
|
49
54
|
selectProps?: Partial<SelectInputProps<number | null>>;
|
|
50
55
|
}
|
|
51
56
|
|
package/src/dimmer/Dimmer.tsx
CHANGED
|
@@ -23,12 +23,18 @@ const dimmerManager = new DimmerManager();
|
|
|
23
23
|
|
|
24
24
|
export type DimmerProps = CommonProps & {
|
|
25
25
|
children?: ReactNode;
|
|
26
|
+
/** @default false */
|
|
26
27
|
disableClickToClose?: boolean;
|
|
27
28
|
contentPosition?: PositionTop | PositionCenter | PositionBottom;
|
|
29
|
+
/** @default false */
|
|
28
30
|
fadeContentOnEnter?: boolean;
|
|
31
|
+
/** @default false */
|
|
29
32
|
fadeContentOnExit?: boolean;
|
|
33
|
+
/** @default false */
|
|
30
34
|
open?: boolean;
|
|
35
|
+
/** @default false */
|
|
31
36
|
scrollable?: boolean;
|
|
37
|
+
/** @default false */
|
|
32
38
|
transparent?: boolean;
|
|
33
39
|
onClose?: (event: KeyboardEvent | MouseEvent) => void;
|
|
34
40
|
onExited?: () => void;
|
package/src/drawer/Drawer.tsx
CHANGED
|
@@ -21,9 +21,15 @@ export type DrawerProps = {
|
|
|
21
21
|
footerContent?: React.ReactNode;
|
|
22
22
|
/** The content to appear in the drawer header. */
|
|
23
23
|
headerTitle?: React.ReactNode;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The status of Drawer either open or not.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
25
28
|
open?: boolean;
|
|
26
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* The placement of Drawer on the screen either left or right. On mobile it will default to bottom.
|
|
31
|
+
* @default 'right'
|
|
32
|
+
*/
|
|
27
33
|
position?: `${Position.LEFT | Position.RIGHT | Position.BOTTOM}`;
|
|
28
34
|
/** The action to perform on close click. */
|
|
29
35
|
onClose?: (event: KeyboardEvent | React.MouseEvent) => void;
|
package/src/field/Field.tsx
CHANGED
|
@@ -16,8 +16,9 @@ export type FieldProps = {
|
|
|
16
16
|
id?: string | null;
|
|
17
17
|
/** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */
|
|
18
18
|
label?: React.ReactNode;
|
|
19
|
+
/** @default true */
|
|
19
20
|
required?: boolean;
|
|
20
|
-
/** @deprecated
|
|
21
|
+
/** @deprecated Use `description` prop instead. */
|
|
21
22
|
hint?: React.ReactNode;
|
|
22
23
|
message?: React.ReactNode;
|
|
23
24
|
/**
|
|
@@ -27,11 +28,13 @@ export type FieldProps = {
|
|
|
27
28
|
messageIconLabel?: string;
|
|
28
29
|
/**
|
|
29
30
|
* If true, shows a loading spinner in place of the message icon of the InlinePrompt
|
|
31
|
+
* @default false
|
|
30
32
|
*/
|
|
31
33
|
messageLoading?: boolean;
|
|
32
34
|
description?: React.ReactNode;
|
|
33
|
-
/** @deprecated
|
|
35
|
+
/** @deprecated Use `message` and `type={Sentiment.NEGATIVE}` prop instead. */
|
|
34
36
|
error?: React.ReactNode;
|
|
37
|
+
/** @default Sentiment.NEUTRAL */
|
|
35
38
|
sentiment?: InlinePromptProps['sentiment'];
|
|
36
39
|
className?: string;
|
|
37
40
|
children?: React.ReactNode;
|
|
@@ -14,9 +14,12 @@ import IconButton from '../iconButton';
|
|
|
14
14
|
import { ArrowLeft } from '@transferwise/icons';
|
|
15
15
|
|
|
16
16
|
export interface FlowNavigationProps {
|
|
17
|
+
/** @default 0 */
|
|
17
18
|
activeStep?: number;
|
|
18
19
|
avatar?: React.ReactNode;
|
|
20
|
+
/** @default <Logo /> */
|
|
19
21
|
logo?: React.ReactNode;
|
|
22
|
+
/** @default false */
|
|
20
23
|
done?: boolean;
|
|
21
24
|
/** Called when the close button is clicked. If not provided the close button won't show */
|
|
22
25
|
onClose?: () => void;
|
package/src/header/Header.tsx
CHANGED
|
@@ -29,13 +29,17 @@ export interface HeaderProps extends CommonProps {
|
|
|
29
29
|
* If this condition is not met, a warning will be logged to the console.
|
|
30
30
|
*
|
|
31
31
|
* - Other valid values include standard heading tags (`h1` to `h6`) or `header`.
|
|
32
|
+
* @default 'h5'
|
|
32
33
|
*/
|
|
33
34
|
as?: Heading | 'legend' | 'header';
|
|
34
35
|
|
|
35
36
|
/** Required prop to set the title of the Header. */
|
|
36
37
|
title: ReactNode;
|
|
37
38
|
|
|
38
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Optional prop to specify the level of the Header
|
|
41
|
+
* @default 'group'
|
|
42
|
+
*/
|
|
39
43
|
level?: 'section' | 'group';
|
|
40
44
|
|
|
41
45
|
className?: string;
|
|
@@ -4,8 +4,11 @@ import Circle from '../common/circle';
|
|
|
4
4
|
import { clsx } from 'clsx';
|
|
5
5
|
|
|
6
6
|
export type Props = {
|
|
7
|
+
/** @default 48 */
|
|
7
8
|
size?: 16 | 24 | 32 | 40 | 48 | 56 | 72;
|
|
9
|
+
/** @default 'primary' */
|
|
8
10
|
priority?: 'primary' | 'secondary' | 'tertiary' | 'minimal';
|
|
11
|
+
/** @default 'default' */
|
|
9
12
|
type?: 'default' | 'negative';
|
|
10
13
|
'data-testid'?: string;
|
|
11
14
|
} & Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'onClick'> &
|
|
@@ -14,7 +14,7 @@ export type LegacyListItemProps = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* @deprecated
|
|
17
|
+
* @deprecated Use `<ListItem />` instead.
|
|
18
18
|
* @deprecatedSince 46.104.0
|
|
19
19
|
* @see [Source](../listItem/ListItem.tsx)
|
|
20
20
|
* @see [Storybook](https://storybook.wise.design/?path=/docs/content-listitem--docs)
|
package/src/list/List.tsx
CHANGED
|
@@ -6,10 +6,12 @@ import { ListItemContext } from '../ListItemContext';
|
|
|
6
6
|
|
|
7
7
|
export type ListItemIconButtonProps = Pick<
|
|
8
8
|
IconButtonProps,
|
|
9
|
-
'
|
|
9
|
+
'type' | 'onClick' | 'href' | 'target' | 'aria-label'
|
|
10
10
|
> & {
|
|
11
11
|
children: ReactNode;
|
|
12
12
|
partiallyInteractive?: boolean;
|
|
13
|
+
/** @default 'minimal' */
|
|
14
|
+
priority?: IconButtonProps['priority'];
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -6,10 +6,12 @@ import { ListItemMediaSize } from '../ListItemContext';
|
|
|
6
6
|
export type ListItemImageProps = Omit<ImageProps, 'stretch' | 'shrink' | 'id' | 'alt' | 'role'> & {
|
|
7
7
|
/**
|
|
8
8
|
* The size of square container for the image, matching available avatar sizes.
|
|
9
|
+
* @default 48
|
|
9
10
|
*/
|
|
10
11
|
size?: ListItemMediaSize;
|
|
11
12
|
/**
|
|
12
13
|
* When unset, it will force `role="presentation"` on the image. Otherwise, the image will use its implicit img role.
|
|
14
|
+
* @default ''
|
|
13
15
|
*/
|
|
14
16
|
alt?: string;
|
|
15
17
|
};
|
|
@@ -45,6 +45,7 @@ export type ListItemControlProps =
|
|
|
45
45
|
| ListItemSwitchProps;
|
|
46
46
|
|
|
47
47
|
export type ListItemProps = {
|
|
48
|
+
/** @default 'li' */
|
|
48
49
|
as?: 'li' | 'div';
|
|
49
50
|
/**
|
|
50
51
|
* Swaps vertical hierarchy of title and subtitle and their corresponding right values.
|
|
@@ -88,6 +89,7 @@ export type ListItemProps = {
|
|
|
88
89
|
* `<ListItem.Navigation />`, <br/>
|
|
89
90
|
* `<ListItem.Radio />`, or
|
|
90
91
|
* `<ListItem.Switch />`
|
|
92
|
+
* @default null
|
|
91
93
|
*/
|
|
92
94
|
control?: ReactNode;
|
|
93
95
|
/**
|
package/src/loader/Loader.tsx
CHANGED
|
@@ -4,19 +4,23 @@ import { useEffect, useState } from 'react';
|
|
|
4
4
|
|
|
5
5
|
import { Size, SizeExtraSmall, SizeSmall, SizeMedium, SizeLarge, SizeExtraLarge } from '../common';
|
|
6
6
|
|
|
7
|
-
// TODO: We gracefully
|
|
7
|
+
// TODO: We gracefully deprecated xs, lg and xl -- remove these as part of a future breaking change to this component
|
|
8
8
|
type DeprecatedSize = SizeExtraSmall | SizeLarge | SizeExtraLarge;
|
|
9
9
|
|
|
10
10
|
type SizeType = SizeSmall | SizeMedium;
|
|
11
11
|
|
|
12
12
|
export type LoaderProps = {
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated
|
|
14
|
+
* @deprecated Use `size` instead.
|
|
15
|
+
* @default false
|
|
15
16
|
*/
|
|
16
17
|
small?: boolean;
|
|
18
|
+
/** @default 'md' */
|
|
17
19
|
size?: SizeType | DeprecatedSize;
|
|
20
|
+
/** @default false */
|
|
18
21
|
displayInstantly?: boolean;
|
|
19
22
|
// TODO: refactor in favor of prop from `CommonProps` type
|
|
23
|
+
/** @default {} */
|
|
20
24
|
classNames?: Record<string, string>;
|
|
21
25
|
'data-testid'?: string;
|
|
22
26
|
};
|
package/src/logo/Logo.tsx
CHANGED
|
@@ -35,7 +35,10 @@ export interface LogoProps {
|
|
|
35
35
|
className?: string;
|
|
36
36
|
/** If true, will use dark colours for dark on light theme */
|
|
37
37
|
inverse?: boolean;
|
|
38
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* What type of logo to display
|
|
40
|
+
* @default 'WISE'
|
|
41
|
+
*/
|
|
39
42
|
type?: `${LogoType}`;
|
|
40
43
|
}
|
|
41
44
|
|