@transferwise/components 0.0.0-experimental-b2eafa7 → 0.0.0-experimental-b7402e7
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/index.esm.js +50 -178
- package/build/index.esm.js.map +1 -1
- package/build/index.js +50 -179
- package/build/index.js.map +1 -1
- package/build/main.css +0 -101
- package/build/styles/main.css +0 -101
- package/build/types/checkboxOption/CheckboxOption.d.ts +2 -2
- package/build/types/checkboxOption/CheckboxOption.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/snackbar/Snackbar.d.ts +30 -22
- package/build/types/snackbar/Snackbar.d.ts.map +1 -1
- package/build/types/snackbar/SnackbarContext.d.ts +7 -2
- package/build/types/snackbar/SnackbarContext.d.ts.map +1 -1
- package/build/types/snackbar/SnackbarProvider.d.ts +7 -12
- package/build/types/snackbar/SnackbarProvider.d.ts.map +1 -1
- package/build/types/snackbar/index.d.ts +2 -0
- package/build/types/snackbar/index.d.ts.map +1 -0
- package/build/types/snackbar/useSnackbar.d.ts +1 -1
- package/build/types/snackbar/useSnackbar.d.ts.map +1 -1
- package/build/types/withNextPortal/withNextPortal.d.ts +1 -1
- package/build/types/withNextPortal/withNextPortal.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/checkboxOption/CheckboxOption.tsx +2 -2
- package/src/index.ts +2 -2
- package/src/main.css +0 -101
- package/src/main.less +0 -1
- package/src/snackbar/{Snackbar.story.js → Snackbar.story.tsx} +2 -1
- package/src/snackbar/{Snackbar.js → Snackbar.tsx} +31 -32
- package/src/snackbar/SnackbarContext.ts +11 -0
- package/src/snackbar/SnackbarProvider.tsx +39 -0
- package/src/ssr.spec.js +0 -17
- package/src/withNextPortal/withNextPortal.tsx +1 -1
- package/build/styles/segmentedControl/SegmentedControl.css +0 -101
- package/build/types/segmentedControl/SegmentedControl.d.ts +0 -31
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +0 -1
- package/build/types/segmentedControl/index.d.ts +0 -3
- package/build/types/segmentedControl/index.d.ts.map +0 -1
- package/src/segmentedControl/SegmentedControl.css +0 -101
- package/src/segmentedControl/SegmentedControl.less +0 -101
- package/src/segmentedControl/SegmentedControl.spec.tsx +0 -106
- package/src/segmentedControl/SegmentedControl.story.tsx +0 -55
- package/src/segmentedControl/SegmentedControl.tsx +0 -175
- package/src/segmentedControl/index.ts +0 -2
- package/src/snackbar/SnackbarContext.js +0 -4
- package/src/snackbar/SnackbarProvider.js +0 -51
- /package/src/snackbar/{index.js → index.ts} +0 -0
- /package/src/snackbar/{useSnackbar.js → useSnackbar.ts} +0 -0
package/build/index.js
CHANGED
|
@@ -2612,7 +2612,7 @@ const CheckboxOption = /*#__PURE__*/React.forwardRef(({
|
|
|
2612
2612
|
button: /*#__PURE__*/jsxRuntime.jsx(CheckboxButton$1, {
|
|
2613
2613
|
checked: checked,
|
|
2614
2614
|
disabled: disabled,
|
|
2615
|
-
onChange: () => onChange(!checked)
|
|
2615
|
+
onChange: () => onChange?.(!checked)
|
|
2616
2616
|
})
|
|
2617
2617
|
});
|
|
2618
2618
|
});
|
|
@@ -9913,7 +9913,6 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
|
|
|
9913
9913
|
setChecked(!checked); // Update local state for checkbox
|
|
9914
9914
|
}
|
|
9915
9915
|
};
|
|
9916
|
-
|
|
9917
9916
|
const componentId = `${id || generateRandomId()}`;
|
|
9918
9917
|
// Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
|
|
9919
9918
|
// `'download'` if `download` is truthy. If neither condition is true, set
|
|
@@ -11077,123 +11076,21 @@ Select.defaultProps = {
|
|
|
11077
11076
|
dropdownProps: {}
|
|
11078
11077
|
};
|
|
11079
11078
|
|
|
11080
|
-
const SegmentedControl = ({
|
|
11081
|
-
name,
|
|
11082
|
-
defaultValue,
|
|
11083
|
-
mode = 'input',
|
|
11084
|
-
segments,
|
|
11085
|
-
onChange
|
|
11086
|
-
}) => {
|
|
11087
|
-
const [selectedValue, setSelectedValue] = React.useState(defaultValue || segments[0].value);
|
|
11088
|
-
const [animate, setAnimate] = React.useState(false);
|
|
11089
|
-
const segmentsRef = React.useRef(null);
|
|
11090
|
-
if (segments.length > 3) {
|
|
11091
|
-
throw new Error('SegmentedControl only supports up to 3 segments. Please refer to: https://wise.design/components/segmented-control');
|
|
11092
|
-
}
|
|
11093
|
-
const segmentsWithRefs = segments.map(segment => ({
|
|
11094
|
-
...segment,
|
|
11095
|
-
ref: /*#__PURE__*/React.createRef()
|
|
11096
|
-
}));
|
|
11097
|
-
const updateSegmentPosition = () => {
|
|
11098
|
-
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value === selectedValue)?.ref;
|
|
11099
|
-
// We grab the active segments style object from the ref
|
|
11100
|
-
// and set the css variables to the selected segments width and x position.
|
|
11101
|
-
// This is so we can animate the highlight to the selected segment
|
|
11102
|
-
if (selectedSegmentRef?.current && segmentsRef.current) {
|
|
11103
|
-
const {
|
|
11104
|
-
style
|
|
11105
|
-
} = segmentsRef.current;
|
|
11106
|
-
style.setProperty('--segment-highlight-width', `${selectedSegmentRef.current.offsetWidth}px`);
|
|
11107
|
-
style.setProperty('--segment-highlight-x', `${selectedSegmentRef.current.offsetLeft}px`);
|
|
11108
|
-
}
|
|
11109
|
-
};
|
|
11110
|
-
React.useEffect(() => {
|
|
11111
|
-
updateSegmentPosition();
|
|
11112
|
-
const handleWindowSizeChange = () => {
|
|
11113
|
-
setAnimate(false);
|
|
11114
|
-
updateSegmentPosition();
|
|
11115
|
-
};
|
|
11116
|
-
window.addEventListener('resize', handleWindowSizeChange);
|
|
11117
|
-
return () => {
|
|
11118
|
-
window.removeEventListener('resize', handleWindowSizeChange);
|
|
11119
|
-
};
|
|
11120
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11121
|
-
}, [segmentsWithRefs, selectedValue]);
|
|
11122
|
-
React.useEffect(() => {
|
|
11123
|
-
onChange(selectedValue);
|
|
11124
|
-
}, [onChange, selectedValue]);
|
|
11125
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
11126
|
-
ref: segmentsRef,
|
|
11127
|
-
"data-testid": "segmented-control",
|
|
11128
|
-
className: classNames__default.default('segmented-control', {
|
|
11129
|
-
'segmented-control--input': mode === 'input'
|
|
11130
|
-
}),
|
|
11131
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
11132
|
-
className: classNames__default.default('segmented-control__segments', {
|
|
11133
|
-
'segmented-control__segments--no-animate': !animate
|
|
11134
|
-
}),
|
|
11135
|
-
children: segmentsWithRefs.map(segment => mode === 'input' ? /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
11136
|
-
ref: segment.ref,
|
|
11137
|
-
htmlFor: segment.id,
|
|
11138
|
-
className: classNames__default.default('segmented-control__segment', {
|
|
11139
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
11140
|
-
}),
|
|
11141
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("input", {
|
|
11142
|
-
type: "radio",
|
|
11143
|
-
className: "segmented-control__radio-input",
|
|
11144
|
-
id: segment.id,
|
|
11145
|
-
name: name,
|
|
11146
|
-
value: segment.value,
|
|
11147
|
-
checked: selectedValue === segment.value,
|
|
11148
|
-
onChange: () => {
|
|
11149
|
-
setAnimate(true);
|
|
11150
|
-
setSelectedValue(segment.value);
|
|
11151
|
-
}
|
|
11152
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
11153
|
-
className: "segmented-control__text",
|
|
11154
|
-
as: "span",
|
|
11155
|
-
type: selectedValue === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
|
|
11156
|
-
children: segment.label
|
|
11157
|
-
})]
|
|
11158
|
-
}, segment.id) : /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
11159
|
-
ref: segment.ref,
|
|
11160
|
-
type: "button",
|
|
11161
|
-
role: "tab",
|
|
11162
|
-
id: segment.id,
|
|
11163
|
-
"aria-controls": segment.controls,
|
|
11164
|
-
"aria-selected": selectedValue === segment.value,
|
|
11165
|
-
className: classNames__default.default('segmented-control__segment', 'segmented-control__button', {
|
|
11166
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
11167
|
-
}),
|
|
11168
|
-
onClick: () => {
|
|
11169
|
-
setAnimate(true);
|
|
11170
|
-
setSelectedValue(segment.value);
|
|
11171
|
-
},
|
|
11172
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
11173
|
-
as: "span",
|
|
11174
|
-
className: "segmented-control__text",
|
|
11175
|
-
type: selectedValue === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
|
|
11176
|
-
children: segment.label
|
|
11177
|
-
})
|
|
11178
|
-
}, segment.id))
|
|
11179
|
-
})
|
|
11180
|
-
});
|
|
11181
|
-
};
|
|
11182
|
-
|
|
11183
11079
|
const CSS_TRANSITION_DURATION = 400;
|
|
11184
11080
|
class Snackbar extends React.Component {
|
|
11185
|
-
/** @type {RefObject<HTMLSpanElement>} */
|
|
11186
11081
|
bodyRef = /*#__PURE__*/React.createRef();
|
|
11187
|
-
|
|
11188
|
-
|
|
11082
|
+
timeout = 0;
|
|
11083
|
+
transitionTimeout = 0;
|
|
11084
|
+
constructor(props) {
|
|
11085
|
+
super(props);
|
|
11189
11086
|
this.state = {
|
|
11190
11087
|
visible: false,
|
|
11191
11088
|
text: ''
|
|
11192
11089
|
};
|
|
11193
11090
|
}
|
|
11194
11091
|
componentWillUnmount() {
|
|
11195
|
-
clearTimeout(this.timeout);
|
|
11196
|
-
clearTimeout(this.transitionTimeout);
|
|
11092
|
+
window.clearTimeout(this.timeout);
|
|
11093
|
+
window.clearTimeout(this.transitionTimeout);
|
|
11197
11094
|
}
|
|
11198
11095
|
shouldComponentUpdate(nextProps, nextState) {
|
|
11199
11096
|
if (!nextProps.text) {
|
|
@@ -11208,7 +11105,7 @@ class Snackbar extends React.Component {
|
|
|
11208
11105
|
const {
|
|
11209
11106
|
timeout
|
|
11210
11107
|
} = this.props;
|
|
11211
|
-
this.timeout = setTimeout(() => {
|
|
11108
|
+
this.timeout = window.setTimeout(() => {
|
|
11212
11109
|
this.setState({
|
|
11213
11110
|
visible: false
|
|
11214
11111
|
});
|
|
@@ -11231,12 +11128,12 @@ class Snackbar extends React.Component {
|
|
|
11231
11128
|
this.setLeaveTimeout();
|
|
11232
11129
|
});
|
|
11233
11130
|
} else if (previousProps.timestamp !== timestamp) {
|
|
11234
|
-
clearTimeout(this.timeout);
|
|
11131
|
+
window.clearTimeout(this.timeout);
|
|
11235
11132
|
if (this.state.visible) {
|
|
11236
11133
|
this.setState({
|
|
11237
11134
|
visible: false
|
|
11238
11135
|
}, () => {
|
|
11239
|
-
this.transitionTimeout = setTimeout(() => {
|
|
11136
|
+
this.transitionTimeout = window.setTimeout(() => {
|
|
11240
11137
|
this.setState({
|
|
11241
11138
|
visible: true,
|
|
11242
11139
|
action,
|
|
@@ -11261,7 +11158,7 @@ class Snackbar extends React.Component {
|
|
|
11261
11158
|
const {
|
|
11262
11159
|
action,
|
|
11263
11160
|
text,
|
|
11264
|
-
theme,
|
|
11161
|
+
theme = exports.Theme.LIGHT,
|
|
11265
11162
|
visible
|
|
11266
11163
|
} = this.state;
|
|
11267
11164
|
const {
|
|
@@ -11295,74 +11192,51 @@ class Snackbar extends React.Component {
|
|
|
11295
11192
|
}
|
|
11296
11193
|
}
|
|
11297
11194
|
Snackbar.contextType = DirectionContext;
|
|
11298
|
-
Snackbar.propTypes = {
|
|
11299
|
-
action: PropTypes__default.default.shape({
|
|
11300
|
-
label: PropTypes__default.default.string.isRequired,
|
|
11301
|
-
onClick: PropTypes__default.default.func
|
|
11302
|
-
}),
|
|
11303
|
-
text: PropTypes__default.default.node.isRequired,
|
|
11304
|
-
theme: PropTypes__default.default.oneOf(['light', 'dark']),
|
|
11305
|
-
timeout: PropTypes__default.default.number.isRequired,
|
|
11306
|
-
timestamp: PropTypes__default.default.number.isRequired
|
|
11307
|
-
};
|
|
11308
|
-
Snackbar.defaultProps = {
|
|
11309
|
-
action: null,
|
|
11310
|
-
theme: exports.Theme.LIGHT
|
|
11311
|
-
};
|
|
11312
11195
|
var SnackbarPortal = withNextPortalWrapper(Snackbar);
|
|
11313
11196
|
|
|
11314
|
-
const SnackbarContext = /*#__PURE__*/React.createContext(
|
|
11197
|
+
const SnackbarContext = /*#__PURE__*/React.createContext({
|
|
11198
|
+
createSnackbar: () => {}
|
|
11199
|
+
});
|
|
11315
11200
|
const SnackbarConsumer = SnackbarContext.Consumer;
|
|
11316
11201
|
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
}
|
|
11325
|
-
|
|
11202
|
+
function SnackbarProvider({
|
|
11203
|
+
timeout = 4500,
|
|
11204
|
+
children
|
|
11205
|
+
}) {
|
|
11206
|
+
const [state, setState] = React.useState({
|
|
11207
|
+
text: '',
|
|
11208
|
+
timestamp: 0
|
|
11209
|
+
});
|
|
11210
|
+
const {
|
|
11326
11211
|
action,
|
|
11327
11212
|
text,
|
|
11328
|
-
theme
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
}), this.props.children]
|
|
11355
|
-
});
|
|
11356
|
-
}
|
|
11213
|
+
theme,
|
|
11214
|
+
timestamp
|
|
11215
|
+
} = state;
|
|
11216
|
+
return /*#__PURE__*/jsxRuntime.jsxs(SnackbarContext.Provider, {
|
|
11217
|
+
value: React.useMemo(() => ({
|
|
11218
|
+
createSnackbar: ({
|
|
11219
|
+
action,
|
|
11220
|
+
text,
|
|
11221
|
+
theme
|
|
11222
|
+
}) => {
|
|
11223
|
+
setState({
|
|
11224
|
+
action,
|
|
11225
|
+
text,
|
|
11226
|
+
theme,
|
|
11227
|
+
timestamp: Date.now()
|
|
11228
|
+
});
|
|
11229
|
+
}
|
|
11230
|
+
}), []),
|
|
11231
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(SnackbarPortal, {
|
|
11232
|
+
action: action,
|
|
11233
|
+
text: text,
|
|
11234
|
+
timestamp: timestamp,
|
|
11235
|
+
timeout: timeout,
|
|
11236
|
+
theme: theme
|
|
11237
|
+
}), children]
|
|
11238
|
+
});
|
|
11357
11239
|
}
|
|
11358
|
-
SnackbarProvider.propTypes = {
|
|
11359
|
-
children: PropTypes__default.default.node.isRequired,
|
|
11360
|
-
timeout: PropTypes__default.default.number
|
|
11361
|
-
};
|
|
11362
|
-
SnackbarProvider.defaultProps = {
|
|
11363
|
-
timeout: 4500
|
|
11364
|
-
};
|
|
11365
|
-
var SnackbarProvider$1 = SnackbarProvider;
|
|
11366
11240
|
|
|
11367
11241
|
const Sticky = ({
|
|
11368
11242
|
open,
|
|
@@ -13964,7 +13838,6 @@ const UploadButton = ({
|
|
|
13964
13838
|
if (areAllFilesAllowed) {
|
|
13965
13839
|
return null; //file input by default allows all files
|
|
13966
13840
|
}
|
|
13967
|
-
|
|
13968
13841
|
if (Array.isArray(fileTypes)) {
|
|
13969
13842
|
return {
|
|
13970
13843
|
accept: fileTypes.join(',')
|
|
@@ -14162,7 +14035,6 @@ const UploadItem = ({
|
|
|
14162
14035
|
children: processIndicator
|
|
14163
14036
|
}); // Scale down ProcessIndicator to be 20px*20px to match `icons`
|
|
14164
14037
|
};
|
|
14165
|
-
|
|
14166
14038
|
const getErrorMessage = () => typeof error === 'object' && error.message || error || formatMessage(MESSAGES.uploadingFailed);
|
|
14167
14039
|
const getDescription = () => {
|
|
14168
14040
|
if (error || status === exports.Status.FAILED) {
|
|
@@ -15649,7 +15521,6 @@ exports.RadioOption = RadioOption$1;
|
|
|
15649
15521
|
exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
|
|
15650
15522
|
exports.SearchInput = SearchInput;
|
|
15651
15523
|
exports.Section = Section;
|
|
15652
|
-
exports.SegmentedControl = SegmentedControl;
|
|
15653
15524
|
exports.Select = Select;
|
|
15654
15525
|
exports.SelectInput = SelectInput;
|
|
15655
15526
|
exports.SelectInputOptionContent = SelectInputOptionContent;
|
|
@@ -15658,7 +15529,7 @@ exports.SlidingPanel = SlidingPanel$1;
|
|
|
15658
15529
|
exports.SnackbarConsumer = SnackbarConsumer;
|
|
15659
15530
|
exports.SnackbarContext = SnackbarContext;
|
|
15660
15531
|
exports.SnackbarPortal = SnackbarPortal;
|
|
15661
|
-
exports.SnackbarProvider = SnackbarProvider
|
|
15532
|
+
exports.SnackbarProvider = SnackbarProvider;
|
|
15662
15533
|
exports.StatusIcon = StatusIcon;
|
|
15663
15534
|
exports.Stepper = Stepper;
|
|
15664
15535
|
exports.Sticky = Sticky$1;
|