-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## **Description** Bump snaps packages to latest and handle breaking changes. Summary of changes in the snaps deps: - Add `Checkbox` component - Add `Tooltip` component - Add `FileInput` component - Add `alignment` prop to `Text` - Support additional components inside forms - Support conditional children in most JSX components - Support parameters in `setTimeout` and `setInterval` Closes #25385 Closes MetaMask/snaps#2500 Closes MetaMask/MetaMask-planning#2416 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25505?quickstart=1) --------- Co-authored-by: Guillaume Roux <[email protected]> Co-authored-by: Maarten Zuidhoorn <[email protected]>
- Loading branch information
1 parent
e0fb582
commit 721673e
Showing
27 changed files
with
607 additions
and
70 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,7 +221,7 @@ | |
"[email protected]": "^7.5.4", | ||
"@trezor/schema-utils@npm:1.0.2": "patch:@trezor/schema-utils@npm%3A1.0.2#~/.yarn/patches/@trezor-schema-utils-npm-1.0.2-7dd48689b2.patch", | ||
"lavamoat-core@npm:^15.1.1": "patch:lavamoat-core@npm%3A15.1.1#~/.yarn/patches/lavamoat-core-npm-15.1.1-51fbe39988.patch", | ||
"@metamask/snaps-sdk": "^5.0.0", | ||
"@metamask/snaps-sdk": "^6.0.0", | ||
"@metamask/transaction-controller": "^32.0.0", | ||
"@babel/runtime@npm:^7.7.6": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch", | ||
"@babel/runtime@npm:^7.9.2": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch", | ||
|
@@ -335,11 +335,11 @@ | |
"@metamask/selected-network-controller": "^15.0.2", | ||
"@metamask/signature-controller": "^16.0.0", | ||
"@metamask/smart-transactions-controller": "^10.1.2", | ||
"@metamask/snaps-controllers": "^9.0.0", | ||
"@metamask/snaps-execution-environments": "^6.4.0", | ||
"@metamask/snaps-rpc-methods": "^9.1.3", | ||
"@metamask/snaps-sdk": "^5.0.0", | ||
"@metamask/snaps-utils": "^7.6.0", | ||
"@metamask/snaps-controllers": "^9.2.0", | ||
"@metamask/snaps-execution-environments": "^6.5.0", | ||
"@metamask/snaps-rpc-methods": "^9.1.4", | ||
"@metamask/snaps-sdk": "^6.0.0", | ||
"@metamask/snaps-utils": "^7.7.0", | ||
"@metamask/transaction-controller": "^32.0.0", | ||
"@metamask/user-operation-controller": "^10.0.0", | ||
"@metamask/utils": "^8.2.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
TEST_SNAPS_WEBSITE_URL: 'https://metamask.github.io/snaps/test-snaps/2.9.0/', | ||
TEST_SNAPS_WEBSITE_URL: 'https://metamask.github.io/snaps/test-snaps/2.11.0/', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './snap-ui-checkbox'; |
81 changes: 81 additions & 0 deletions
81
ui/components/app/snaps/snap-ui-checkbox/snap-ui-checkbox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React, { FunctionComponent, useEffect, useState } from 'react'; | ||
import { useSnapInterfaceContext } from '../../../../contexts/snaps'; | ||
import { | ||
Display, | ||
FlexDirection, | ||
} from '../../../../helpers/constants/design-system'; | ||
import { | ||
Box, | ||
Label, | ||
HelpText, | ||
HelpTextSeverity, | ||
Checkbox, | ||
} from '../../../component-library'; | ||
import ToggleButton from '../../../ui/toggle-button'; | ||
|
||
export type SnapUICheckboxProps = { | ||
name: string; | ||
fieldLabel?: string; | ||
variant?: 'default' | 'toggle'; | ||
label?: string; | ||
error?: string; | ||
form?: string; | ||
}; | ||
|
||
export const SnapUICheckbox: FunctionComponent<SnapUICheckboxProps> = ({ | ||
name, | ||
variant, | ||
fieldLabel, | ||
label, | ||
error, | ||
form, | ||
...props | ||
}) => { | ||
const { handleInputChange, getValue } = useSnapInterfaceContext(); | ||
|
||
const initialValue = getValue<boolean>(name, form); | ||
|
||
const [value, setValue] = useState(initialValue ?? false); | ||
|
||
useEffect(() => { | ||
if (initialValue !== undefined && initialValue !== null) { | ||
setValue(initialValue); | ||
} | ||
}, [initialValue]); | ||
|
||
const handleChange = () => { | ||
setValue(!value); | ||
handleInputChange(name, !value, form); | ||
}; | ||
|
||
return ( | ||
<Box | ||
className="snap-ui-renderer__checkbox" | ||
display={Display.Flex} | ||
flexDirection={FlexDirection.Column} | ||
> | ||
{fieldLabel && <Label htmlFor={name}>{fieldLabel}</Label>} | ||
{variant === 'toggle' ? ( | ||
<ToggleButton | ||
onToggle={handleChange} | ||
value={value} | ||
onLabel={label} | ||
offLabel={label} | ||
{...props} | ||
/> | ||
) : ( | ||
<Checkbox | ||
onChange={handleChange} | ||
isChecked={value} | ||
label={label} | ||
{...props} | ||
/> | ||
)} | ||
{error && ( | ||
<HelpText severity={HelpTextSeverity.Danger} marginTop={1}> | ||
{error} | ||
</HelpText> | ||
)} | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.snap-ui-renderer { | ||
&__file-input { | ||
&__drop-zone { | ||
background-color: var(--color-background-alternative); | ||
|
||
.mm-icon, | ||
.mm-text { | ||
color: var(--color-icon-alternative); | ||
} | ||
|
||
&:hover .mm-icon, | ||
&:hover .mm-text { | ||
color: var(--color-info-default); | ||
} | ||
|
||
&:hover { | ||
background-color: var(--color-background-alternative-hover); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './snap-ui-file-input'; |
Oops, something went wrong.