index
int64 0
0
| repo_id
stringlengths 16
181
| file_path
stringlengths 28
270
| content
stringlengths 1
11.6M
| __index_level_0__
int64 0
10k
|
---|---|---|---|---|
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_index.scss | // Config
@import
'config';
// Vendors
@import
'~include-media';
// Functions
@import
'em',
'rem',
'im-to-em',
'logical',
'str-replace',
'easing',
'dash-join';
// Mixins
@import
'vendor-prefix',
'body-before',
'transform-origins',
'responsive-classes';
| 9,500 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_logical.scss | /**
* Give logical string for a "classic" placement
* @param {String} $placement - top/left/right/bottom/vertical/horizontal/t/r/b/l/v/h/x/y
* @return {String} - the logical prop fragment
*/
@function logical($placement) {
@if $placement == 'top' or $placement == 't' {
@return 'block-start';
}
@if $placement == 'bottom' or $placement == 'b' {
@return 'block-end';
}
@if $placement == 'left' or $placement == 'l' {
@return 'inline-start';
}
@if $placement == 'right' or $placement == 'r' {
@return 'inline-end';
}
@if $placement == 'horizontal' or $placement == 'h' or $placement == 'x' {
@return 'inline';
}
@if $placement == 'vertical' or $placement == 'v' or $placement == 'y' {
@return 'block';
}
@return null;
}
| 9,501 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_rem.scss | @use 'sass:math';
/**
* Calculate an rem value from a px value
* @param {Number} $px - A value to be converted in em
* @param {Number} $user-default-font-size - The default font-size of the browser. Should be equivalent to 16px
* @return {Number} - The $px value converted in rem
*/
@function rem($px, $user-default-font-size: $root-default-font-size) {
@return (math.div($px, $user-default-font-size)) * 1rem;
}
| 9,502 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_responsive-classes.scss | @use 'sass:string';
@use 'sass:map';
$queries: (
default: 'all',
sm: '>xsmall',
md: '>small',
lg: '>medium',
xl: '>large',
);
/// Generate a class stack selector form a class list and responsive prefix
/// @param {List} $classnames - List of classes for generation
/// @param {String} $prefix - Prefix from $queries
/// @return {String} Stacked classes with responsive prefixes
@function stack-classenames($classnames, $prefix) {
$classstack: '';
@each $classname in $classnames {
// Remove dot (.) if there is one
$classname: if(string.slice($classname, 1, 1) == '.', string.slice($classname, 2, -1), $classname);
// Stack classe with dot, comma and responsive prefix
$classstack: if($classstack == '', '.' + $prefix + $classname, $classstack + ', .' + $prefix + $classname);
}
@return $classstack;
}
/// Generate responsive classes, duh!
/// @param {String | List | Node} $param - List of classes
/// @content The declaration block of a css rule. Used when $param is a String or a List
/// @returns {String} CSS classes with responsive prefixes
/// @example scss - Basic usage: __String__
/// @include responsive-classes(dummy-class) {
/// property: value;
/// }
/// @example scss - Several classes with the same declaration block: __List__
/// @include responsive-classes((class-1, class-2)) {
/// property: value;
/// }
/// @example scss - When you need to serialize several classes to avoid cascade ordering issues: __Map__
/// @include responsive-classes((
/// class: (
/// property: value,
/// ),
/// (class-1, class-2): (
/// property: value,
/// ),
/// ));
@mixin responsive-classes($param) {
@each $breakpointname, $query in $queries {
@include media($query) {
$prefix: if($breakpointname == 'default', '', $breakpointname + '\\\:');
@if type-of($param) == 'map' {
@each $classnames, $properties in $param {
#{stack-classenames($classnames, $prefix)} {
@each $property, $value in $properties {
// Search in the $value string if we need the breakpoint name, e.g. for custom sizing css variables
$value: if(
string.index(#{$value}, '[BPN]'),
str-replace($value, '[BPN]', if($breakpointname == 'default', '', $breakpointname + '-')),
$value
);
#{$property}: #{$value};
}
}
}
} @else {
#{stack-classenames($param, $prefix)} {
@content;
}
}
}
}
}
| 9,503 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_str-replace.scss | /**
* Replace `$search` with `$replace` in `$string`
* @author Hugo Giraudel
* @param {String} $string - Initial string
* @param {String} $search - Substring to replace
* @param {String} $replace ('') - New value
* @return {String} - Updated string
*/
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace +
str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@return $string;
}
| 9,504 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_transform-origins.scss | /**
* Generate each transform origin possibilities
* @return {String} - CSS classes for each transform origin value
*/
@mixin transform-origins() {
@each $position,
$origin
in (
(top, bottom center),
(top-start, bottom left),
(top-end, bottom right),
(bottom, top center),
(bottom-start, top left),
(bottom-end, top right),
(left, right center),
(left-end, right bottom),
(left-start, right top),
(right, left center),
(right-end, left bottom),
(right-start, left top)
)
{
&--#{$position} {
transform-origin: $origin;
}
}
}
| 9,505 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_vendor-prefix.scss | /**
* Generate vendor prefixes for a given property
* @param {String} $property - The given property from which generate vendor prefixes
* @param {String} $value - The value of the property
* @param {String} $prefixes - Wanted prefix•es
* @return {String} - The property with each prefix
*/
@mixin vendor-prefix($property, $value, $prefixes: (webkit, moz, ms, o)) {
@if $prefixes {
@each $prefix in $prefixes {
#{'-' + $prefix + '-' + $property}: $value;
}
}
#{$property}: $value;
}
| 9,506 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/specifics/_list.scss | @use 'sass:math';
/*
* Items
* For conversations list
*/
.view-column-detail {
.scroll-inner {
@supports (overflow-y: overlay) {
overflow-y: overlay; // Deprecated, but didn't have the choice
}
}
}
.items-column-list {
inline-size: var(--width-conversation-column, calc(100vw * #{math.div($conversations-column-width, 100%)}));
min-inline-size: 360px; // Subjective value
max-inline-size: calc(100vw - 450px - #{$width-sidebar}px - var(--drawer-width, 0rem)); // Subjective value
}
// trick to have proper direction on react virtual lists
.ReactVirtualized__Grid,
.ReactVirtualized__List {
direction: inherit !important;
}
.items-column-list-inner,
.ReactVirtualized__Grid__innerScrollContainer {
border-inline-end: 1px solid var(--border-weak);
min-block-size: 100%;
}
// prevent double border on the right
.main-area--row-mode .items-column-list-inner {
margin-inline-end: -1px;
}
.items-column-list-inner--border-none {
// fix for Contact and ReactVirtualized__Grid
border: 0;
}
.items-column-list--mobile {
inline-size: 100%;
}
.items-column-list,
.items-column-list--mobile,
.view-column-detail {
block-size: 100%;
}
.view-column-detail,
// because it's sticky on top
.message-conversation-summary {
background-color: var(--email-message-view-background-color);
}
$item-container-height: rem(66) !default;
$item-container-padding-block: em(13) !default;
$item-container-padding-inline-start: em(16) !default;
$item-container-padding-inline-end: em(12) !default;
$item-container-padding-inline: $item-container-padding-inline-start $item-container-padding-inline-end;
$item-container-height-compact-mode: rem(56) !default;
$item-container-row-height-compact-mode: rem(36) !default;
$item-container-row-padding-block: em(5) !default; // design wants 48px
.item-container,
.item-container-row {
@extend %appearing-container;
position: relative;
padding-block: $item-container-padding-block; // design wants ~66 height
padding-inline: $item-container-padding-inline;
scroll-margin-block-start: $item-container-height;
// no transition, otherwhise there's a flash on page loading
// because of theme file loading after applying default theme colors
&.read {
background-color: var(--email-item-read-background-color);
color: var(--email-item-read-text-color);
.item-icon,
.item-icon-compact:hover {
background-color: var(--email-item-read-icon-background-color);
color: var(--email-item-read-icon-text-color);
}
}
&.unread {
background-color: var(--email-item-unread-background-color);
color: var(--email-item-unread-text-color);
.item-senders,
.item-senddate-col,
.item-senddate-row,
.item-weight,
.item-subject {
font-weight: var(--font-weight-bold);
}
.item-icon,
.item-icon-compact:hover {
background-color: var(--email-item-unread-icon-background-color);
color: var(--email-item-unread-icon-text-color);
}
}
&:hover {
z-index: 2;
box-shadow: var(--shadow-norm);
}
&::after {
content: '';
position: absolute;
inset-block: -1px;
inset-inline: 0;
border: 1px solid transparent;
border-radius: inherit;
pointer-events: none;
}
&:focus {
outline: none;
}
@supports not selector(:focus-visible) {
&:focus::after {
z-index: 1;
border-color: var(--focus-outline);
box-shadow: 0 0 0 #{$focus-ring-size} var(--focus-ring);
}
}
@supports selector(:focus-visible) {
&:focus-visible::after {
z-index: 1;
border-color: var(--focus-outline);
box-shadow: 0 0 0 #{$focus-ring-size} var(--focus-ring);
}
}
&.item-is-selected {
background-color: var(--email-item-selected-background-color);
color: var(--email-item-selected-text-color);
.item-icon,
.item-icon-compact:hover {
background-color: var(--email-item-selected-icon-background-color);
color: var(--email-item-selected-icon-text-color);
}
}
.item-unread-dot {
display: flex;
align-items: center;
flex-shrink: 0;
}
// Styling for contact items inside contact dropdown
&.item-contact {
background-color: var(--email-item-unread-background-color);
color: var(--email-item-unread-text-color);
.item-icon,
.item-icon-compact:hover {
background-color: var(--email-item-unread-icon-background-color);
color: var(--email-item-unread-icon-text-color);
}
}
// Encrypted search shows a preview of the body in the item,
// which therefore has to be bigger
&.es-three-rows {
block-size: auto;
}
.item-titlesender {
min-block-size: rem(36);
}
}
.item-container {
margin-inline: em(8);
border-radius: var(--border-radius-lg);
@include media('<=small') {
margin-inline: em(2);
}
}
.item-container-row {
padding-block: $item-container-row-padding-block;
// fix pseudo element for row layout
.item-checkbox {
&::after {
inset-block: -#{$item-container-padding-block};
}
}
.item-weight {
min-inline-size: 5em;
@include media('<=#{em(1200, 16)}') {
display: none;
}
}
.item-senders {
inline-size: rem(200);
color: var(--text-norm);
@include media('<=large') {
inline-size: rem(128);
}
}
// override for row mode
.item-checkbox-label {
&::before {
inset-block: -#{$item-container-row-padding-block};
}
.item-checkbox {
&::after {
inset-block: -#{$item-container-row-padding-block};
}
}
}
}
.item-checkbox-label {
.item-checkbox {
// this is a crazy fix for Firefox - for having ::after stuff working on it for mail conversations
// to have increased area around checkbox for clicking
/* autoprefixer: ignore next */
/* stylelint-disable-next-line */
-moz-appearance: initial;
&::after {
content: '';
inset-inline: -#{$item-container-padding-inline-start} 0;
inset-block: -#{$item-container-padding-block};
z-index: 1;
position: absolute;
}
}
/* attempt of increase click surface on label, but does not work in Firefox when shift clicking
&::before {
content: '';
position: absolute;
inset-inline: -#{$item-container-padding-inline-start} 0;
inset-block: -#{$item-container-padding-block};
z-index: 1;
background: #f00A;
} */
// fix for Firefox multi-selection issue
& > .item-checkbox {
inline-size: 100%;
block-size: 100%;
z-index: 1;
}
}
.item-firstline,
.item-secondline {
block-size: em(20);
line-height: calc(20 * 1.5 / 21);
}
.item-firstline {
&-infos {
transform: translateY(-0.5ex); // Requested by design -_-"
}
}
.item-secondline:empty::before {
content: ' ';
}
.item-hover-action-buttons {
display: none;
// prevent layout jump in row mode
.main-area--row-mode & {
margin-block: em(-2);
}
}
@include media('mouse', '>small') {
.item-hover-action-buttons {
margin-inline-end: rem(-6); // Magic number to get perfect alignment with star on hover :D
}
.item-container:hover,
.item-container-row:hover {
.item-hover-action-buttons {
display: inline-flex; // We don't want any transition, so we can use `display`.
}
}
.item-container:hover .item-meta-infos,
.item-container:hover .item-firstline-infos,
.item-container-row:hover .item-senddate-row {
display: none;
}
}
// Used to keep the buttons visible when a dropdown is open regardless of hover state
.item-hover-action-buttons--dropdown-open {
display: inline-flex;
}
/* Comfortable view */
.is-comfortable {
.auto-delete-banner-enabled.auto-delete-banner-enabled--column:not(.auto-delete-banner-enabled--compact) {
@include media('>small') {
margin-block-end: em(-12);
}
}
.item-container {
&:not(.item-container-row) {
margin-block-end: var(--space-1);
}
// just a 12 margin only for first element, not on mobile
&-wrapper:first-child .item-container {
margin-block-start: var(--space-2);
@include media('>small') {
margin-block-start: var(--space-3);
}
}
&-row {
padding-inline-start: em(21);
}
}
.item-container-column .item-unread-dot {
display: block;
position: absolute;
inset-block-start: em(19);
inset-inline-start: em(2);
z-index: 1;
}
.item-container-row .item-unread-dot {
position: absolute;
inset-block-start: em(15);
inset-inline-start: em(5);
z-index: 1;
}
}
/* Compact view */
.item-icon-compact {
inline-size: rem($conversation-icon-size);
block-size: rem($conversation-icon-size);
border-radius: 50%;
font-size: rem(12);
transition: background-color 0.25s ease-out;
margin-block-start: em(-5); // to align with first line
// for allowing hovering larger than fake circle
&::after {
content: '';
position: absolute;
inset-block: rem(-2);
inset-inline: rem(-6);
}
&::before {
content: '';
position: absolute;
inset-block: em(-6);
inset-inline: em(-6) em(-12);
z-index: 1;
}
.checkbox-fakecheck {
margin: auto;
background: var(--background-norm);
}
}
.list-compact {
.item-container,
.item-container-row {
// block-size: $item-container-height-compact-mode;
// scroll-margin-block-start: $item-container-height-compact-mode;
padding-block: em(8);
padding-inline: em(6) em(12);
margin-inline: 0;
border-radius: 0;
@include media('<=small') {
padding-inline-start: em(12);
}
.item-container-inner {
padding-block: em(0);
padding-inline: em(12);
}
}
.item-container-row {
block-size: $item-container-row-height-compact-mode;
scroll-margin-block-start: $item-container-row-height-compact-mode;
padding-block: 0;
.item-icon-compact {
// margin-block-start: 0;
margin-block: auto;
/* attempt of increase click surface on label, but does not work in Firefox when shift clicking
&::before {
inset-block: em(-2);
inset-inline: em(-6) em(-12);
}
*/
}
.item-checkbox::after {
inset-block: em(-2) !important;
inset-inline: em(-6) em(-12) !important;
}
}
.item-firstline,
.item-secondline {
margin: 0;
}
.item-firstline-infos {
transform: none;
}
}
// fixes for ES results in compact mode list-compact class is not applied in ES context
.is-compact {
.es-row-results,
.es-three-rows {
padding-inline-start: em(6);
}
.es-three-rows {
margin-inline-start: 0;
}
}
.item-is-loading {
background-color: var(--background-norm);
pointer-events: none;
.item-checkbox-label::before,
.item-icon-compact::before,
.item-senders::before,
.item-senddate-col::before,
.item-senddate-row::before,
.item-weight::before,
.item-star,
.item-subject::before {
@extend %placeholder-loading;
}
.item-checkbox-label,
.item-icon-compact {
position: relative;
margin-block: auto;
&::before {
content: '';
position: absolute;
inset: 0;
z-index: 1;
border-radius: var(--border-radius-md);
background-color: currentcolor;
opacity: 0;
}
.item-icon,
.checkbox-fakecheck {
opacity: 0;
}
}
.item-checkbox-label {
margin-block-start: 0;
}
.item-senders,
.item-senddate-col,
.item-senddate-row,
.item-weight,
.item-subject {
&::before {
@extend %item-loading-pseudo;
}
}
.item-senders {
&::before {
inline-size: 35%;
}
}
.item-senddate-col {
min-inline-size: 6em;
&::before {
inline-size: 100%;
}
}
.item-senddate-row {
&::before {
inline-size: 70%;
}
}
.item-weight {
min-inline-size: 4em;
&::before {
inline-size: 100%;
}
}
.item-subject {
&::before {
inline-size: 60%;
}
}
}
.item-checkbox {
& + .item-icon {
border: 0;
}
// hidden fake check by default
& + .item-icon > .item-icon-fakecheck {
display: none;
}
@supports not selector(:focus-visible) {
&:focus + .item-icon {
box-shadow: 0 0 0 #{$focus-ring-size} var(--focus-ring);
}
}
@supports selector(:focus-visible) {
&:focus-visible + .item-icon {
box-shadow: 0 0 0 #{$focus-ring-size} var(--focus-ring);
}
}
// hover state of checkbox
&:hover + .item-icon,
& + .item-icon:hover {
& > .item-abbr {
display: none;
}
& > .item-icon-fakecheck {
display: flex;
transform: scale(1);
}
}
// checked state
&:checked + .item-icon {
background-color: var(--interaction-norm);
& > .item-abbr {
display: none;
}
& > .item-icon-fakecheck {
display: flex;
animation: anime-conversation-icon-in easing(ease-out-quint) 0.15s;
}
@keyframes anime-conversation-icon-in {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
.item-icon-fakecheck-icon {
fill: var(--interaction-norm-contrast);
}
}
}
| 9,507 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/specifics/_placeholder-loading.scss | /*
* Shared for placeholder loading
*/
@keyframes anime-loading-item {
from {
opacity: 0.05;
}
to {
opacity: 0.15;
}
}
%item-loading-pseudo {
content: '\00a0';
display: inline-block;
border-radius: var(--border-radius-sm);
background-color: currentcolor;
line-height: 1.2;
opacity: 0;
}
%appearing-container {
animation: anime-item-fade-in 0.5s easing(ease-out-quint);
}
%placeholder-loading {
animation: anime-loading-item 0.5s calc(var(--index, 0) * 20ms) easing(ease-out-sine) infinite alternate both;
}
@keyframes anime-item-fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
| 9,508 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/specifics/_settings.scss | .settings-loading-page-title,
.settings-loading-section-title,
.settings-loading-paragraph-line {
&::before {
@extend %item-loading-pseudo;
@extend %placeholder-loading;
}
}
.settings-loading-page-title {
&::before {
inline-size: 30%;
}
}
.settings-loading-section-title {
&::before {
inline-size: 50%;
}
}
.settings-loading-paragraph-line {
&:nth-child(1) {
&::before {
inline-size: 90%;
}
}
&:nth-child(2) {
&::before {
inline-size: 100%;
}
}
&:nth-child(3) {
&::before {
inline-size: 40%;
}
}
}
| 9,509 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/specifics/android-dark-mode.scss | /*
* Vars override
*/
:root {
--background-norm: #262a33;
--text-norm: white;
}
| 9,510 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/specifics/android-reset.scss | /*
* Specific reset for Android
*/
/* stylelint-disable-next-line value-keyword-case */
$font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue',
sans-serif;
article,
aside,
datalist,
details,
dialog,
figure,
footer,
header,
main,
menu,
nav,
section {
display: block;
}
audio,
canvas,
progress,
video {
display: inline-block;
}
abbr,
mark,
meter,
time,
output {
display: inline;
}
html,
body,
blockquote,
ul,
ol,
form,
button,
figure {
margin: 0;
padding: 0;
}
button,
progress {
border: 0;
}
p,
ul,
ol,
dl,
blockquote,
pre,
menu,
td,
th {
font-size: 1em;
line-height: 1.5;
margin-block: 1.5em;
margin-inline: 0;
}
input,
select,
textarea,
optgroup,
button {
font: inherit;
}
/* fix display img/iframe */
img,
iframe {
vertical-align: middle;
}
ul,
ol,
menu {
padding-inline-start: 2em;
}
dd {
margin-inline-start: 2em;
}
b,
strong {
font-weight: bold;
}
/* harmonization between Chrome/Firefox */
pre,
code,
kbd,
samp {
/* stylelint-disable-next-line */
font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace, monospace;
font-size: 1em;
}
pre {
white-space: pre-wrap;
word-wrap: break-word;
}
mark {
background-color: yellow;
color: black;
font-weight: bold;
}
small {
font-size: 80%;
}
/* avoid border on images in links + fix border image IE */
a:link img,
a:visited img,
img {
border-style: none;
}
/* tiny control */
audio:not([controls]) {
display: none;
block-size: 0;
}
/* important, abbr are good */
/* only those with a title are shown */
abbr[title] {
border-block-end: dotted 1px;
cursor: help;
text-decoration: none;
/* color inherited from text */
}
code,
pre,
samp {
white-space: pre-wrap;
}
code {
line-height: 1;
}
dfn {
font-style: italic;
}
/*
* Deal with typo
*/
$use-other-typo-helpers: false;
$use-other-line-height-helpers: false;
$base-font-size: 16;
$title-sizes: (
h1: 32,
h2: 24,
h3: 19,
h4: 16,
h5: 13,
h6: 12,
);
/* stylelint-disable-next-line no-invalid-position-at-import-rule */
@import '../config/';
/* stylelint-disable-next-line no-invalid-position-at-import-rule */
@import '../base/typo';
/*
* Vars
*/
:root {
--background-norm: white;
--text-norm: #262a33;
}
/*
* Base styles
*/
body {
font-size: 100%;
inline-size: 100%;
font-family: $font-family;
padding: 1rem;
line-height: $base-line-height;
background-color: var(--background-norm);
color: var(--text-norm);
}
// Specific to Android/iOS
q {
quotes: none;
&::after,
&::before {
content: none;
}
}
a {
&:focus {
outline: dotted thin;
}
&:active,
&:hover {
outline: 0;
}
}
img {
border: 0;
max-inline-size: 100%;
}
table img {
max-inline-size: none;
}
/* styling quotes for messages */
blockquote {
padding-block: 0.2em !important;
padding-inline: 1.2em !important;
/* margin: 1em 0 2em 0 !important; */
margin: 0 !important; // actually on web
border: 3px solid var(--primary) !important;
border-width: 0 0 0 3px !important;
}
// limit - same as mail web
blockquote blockquote blockquote blockquote blockquote blockquote {
padding: 0 !important;
border: none !important;
}
/*
* Helpers
*/
[hidden] {
display: none;
}
| 9,511 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_border.scss | .border {
border: 1px solid var(--border-norm);
}
@each $placement in (top, right, bottom, left) {
.border-#{$placement} {
#{dash-join('border', logical($placement))}: 1px solid var(--border-norm);
}
}
@each $color in (primary, norm, weak, danger, warning, success, info) {
// Initialize namespace
$prefix: '';
@if $color == 'norm' or $color == 'weak' {
$prefix: 'border';
}
@if $color == 'danger' or $color == 'warning' or $color == 'success' or $color == 'info' {
$prefix: 'signal';
}
.border-#{$color} {
border-color: var(--#{dash-join($prefix, $color)});
}
}
.border-currentcolor {
border-color: currentcolor;
}
.border-dashed {
border-style: dashed;
}
.border-dotted {
border-style: dotted;
}
.border-collapse {
border-collapse: collapse;
}
.border-none {
border: none;
}
.border-2 {
border-width: 2px;
}
| 9,512 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_colors.scss | @each $color in (primary, danger, warning, success, info) {
$prefix: if($color != 'primary', 'signal', '');
.bg-#{$color} {
background-color: var(--#{dash-join($prefix, $color)});
color: var(--#{dash-join($prefix, $color, 'contrast')});
a,
.link,
.button-link,
[class*='button-ghost'],
[class*='button-underline'],
[class*='button-outline'] {
color: inherit;
}
[class*='button-outline'] {
--button-default-border-color: currentcolor;
--button-hover-border-color: currentcolor;
--button-active-border-color: currentcolor;
// Force same backgrounds as solid shape of same color
--button-default-background-color: var(--#{dash-join($prefix, $color)});
--button-hover-background-color: var(--#{dash-join($prefix, $color, 'major-1')});
--button-active-background-color: var(--#{dash-join($prefix, $color, 'major-2')});
}
}
.color-#{$color} {
color: var(--#{dash-join($prefix, $color)});
}
.fill-#{$color} {
fill: var(--#{dash-join($prefix, $color)});
}
}
@each $color in (norm, weak, strong) {
.bg-#{$color} {
background-color: var(--background-#{$color});
}
.bg-#{$color}-odd > *:nth-child(odd) {
background-color: var(--background-#{$color});
}
.bg-#{$color}-even > *:nth-child(even) {
background-color: var(--background-#{$color});
}
}
@each $color in (norm, weak, hint, disabled, invert) {
.color-#{$color} {
color: var(--text-#{$color});
}
}
.color-inherit {
color: inherit;
&:is(a, .link, .button-link, [class*='button-ghost'], [class*='button-underline'], [class*='button-outline']) {
&:hover,
&:focus,
&:active {
color: inherit;
}
}
}
.on-hover-color-norm {
&:hover,
&:focus,
&:active {
color: var(--text-norm);
}
}
.fill-currentcolor {
fill: currentcolor;
}
| 9,513 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_cursors.scss | @each $cursor in (default, help, wait, grab, row-resize, col-resize, pointer, move, text, inherit) {
.cursor-#{$cursor} {
cursor: #{$cursor};
}
}
| 9,514 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_display.scss | @include responsive-classes(
(
block: (
display: block,
),
inline: (
display: inline,
),
inline-block: (
display: inline-block,
),
flex: (
display: flex,
flex-wrap: wrap,
),
inline-flex: (
display: inline-flex,
flex-wrap: wrap,
),
hidden: (
display: none,
),
table-cell: (
display: table-cell,
),
)
);
.flex,
.sm\:flex,
.md\:flex,
.lg\:flex,
.xl\:flex {
& > * {
min-block-size: 0;
min-inline-size: 0;
}
}
/* table-design in CSS */
.row {
display: table;
table-layout: fixed;
}
.inline-row {
display: inline-table;
table-layout: fixed;
}
.line {
display: table-row;
}
.col {
display: table-cell;
vertical-align: top;
}
.col-no-align {
display: table-cell;
}
[hidden],
.hidden-empty:empty {
display: none;
}
// deprecated: hide-on-hover
.group-hover\:hidden {
.group-hover-hide-container:focus-within &,
.group-hover-hide-container:hover & {
display: none;
}
}
| 9,515 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_divide.scss | .divide-x > * ~ * {
border-inline-start: 1px solid var(--border-norm);
}
.divide-y > * ~ * {
border-block-start: 1px solid var(--border-norm);
}
.divide-weak > * ~ * {
border-color: var(--border-weak);
}
| 9,516 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_flex.scss | @use 'sass:map';
.inline-flex-vcenter {
display: inline-flex;
flex-wrap: wrap;
}
.flex-flex-children,
.flex-no-min-children {
display: flex;
flex-wrap: wrap;
}
.flex-flex-children > * {
display: flex;
}
// ----------------------------------------------------------------------------
// Create an empty map to make it reachable outside of loops
$dummy-map: ();
// Add `flex-direction` utilities to the map
@each $direction in (row, row-reverse, column, column-reverse) {
$dummy-map: map.merge(
$dummy-map,
(
flex-#{$direction}:
(
flex-direction: $direction,
)
)
);
}
// Add `flex-justify` utilities to the map
@each $justify in (start, center, end, space-between, space-around, space-evenly) {
// Remove prefix when 'start' and 'end' will be recognized by browsers
$prefix: if($justify == start or $justify == end, 'flex', '');
$dummy-map: map.merge(
$dummy-map,
(
flex-justify-#{$justify}:
(
justify-content: #{dash-join($prefix, $justify)},
)
)
);
}
// Add `flex-wrap` utilities to the map
@each $wrap in (wrap, wrap-reverse, nowrap) {
$dummy-map: map.merge(
$dummy-map,
(
flex-#{$wrap}:
(
flex-wrap: #{$wrap},
)
)
);
}
// Add `order` utilities to the map
// Use a for in case we need more
@for $i from 0 through 1 {
$dummy-map: map.merge(
$dummy-map,
(
order-#{$i}:
(
order: #{$i},
)
)
);
}
// Serialize the responsive utilities creation with the map to avoid any cascade ordering issues
@include responsive-classes($dummy-map);
// ----------------------------------------------------------------------------
@each $align in (start, center, end, baseline, stretch, inherit) {
// Remove prefix when 'start' and 'end' will be recognized by browsers
$prefix: if($align == start or $align == end, 'flex', '');
.flex-align-items-#{$align} {
align-items: #{dash-join($prefix, $align)};
}
.flex-align-self-#{$align} {
align-self: #{dash-join($prefix, $align)};
}
}
.flex-flex-align-items-center > * {
align-items: center;
}
.inline-flex-vcenter > *,
.flex-item-centered-vert {
margin-block: auto;
align-self: center;
}
@include responsive-classes(flex-item-fluid) {
flex: 1 1 0px;
}
@include responsive-classes(flex-item-fluid-auto) {
flex: 1 1 auto;
}
@include responsive-classes(flex-item-shrink) {
flex-shrink: 1;
}
.flex-item-noshrink {
flex-shrink: 0;
}
.flex-item-shrink {
flex-shrink: 1;
}
.flex-item-nogrow {
flex-grow: 0;
}
.flex-item-grow {
flex-grow: 1;
}
.flex-item-grow-2 {
flex-grow: 2;
}
.flex-item-grow-custom {
flex-grow: var(--grow-custom);
}
.flex-item-noflex {
flex: 0;
}
| 9,517 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_grid.scss | .grid-auto-fill {
display: grid;
inline-size: 100%;
grid-template-columns: repeat(auto-fill, minmax(var(--min-grid-template-column-size, #{rem(100)}), 1fr));
}
.grid-align-icon {
display: grid;
grid-template-columns: auto 1fr;
}
.grid-align-icon-center {
@extend .grid-align-icon;
align-items: center;
}
.grid-align-icon > *:not(svg, .keep-left) {
grid-column-start: 2;
}
| 9,518 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_icons.scss | @use 'sass:math';
%icon {
display: inline-block;
vertical-align: middle;
fill: currentcolor;
}
@each $width in (6, 8, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 42, 48, 56, 60, 70, 100, 110) {
.icon-#{$width}p {
@extend %icon; // 🤔
inline-size: rem($width);
block-size: rem($width);
}
}
@each $width in (50) {
.icon-#{$width} {
@extend %icon; // 🤔
inline-size: math.percentage(math.div($width, 100));
block-size: math.percentage(math.div($width, 100));
}
}
.path2x {
stroke-width: 1px;
}
| 9,519 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_index.scss | /* stylelint-disable */
@import
'misc',
'icons',
'typo',
'colors',
'layout',
'display',
'position',
'sizing',
'spacing',
'flex',
'cursors',
'border',
'divide',
'outline',
'opacity',
'shadow',
'table',
'rounded',
'responsive',
'print',
'grid';
| 9,520 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_layout.scss | .mod,
.scroll-if-needed,
.overflow-auto {
overflow: auto;
}
.overflow-overlay {
overflow: auto; // fallback
overflow: overlay;
}
.scroll-horizontal-if-needed,
.overflow-x-auto {
overflow-x: auto;
}
.mod--hidden,
.no-scroll,
.overflow-hidden {
overflow: hidden;
}
.resize-none {
resize: none;
}
.float-left {
float: inline-start;
}
.float-right {
float: inline-end;
}
/* clear floats */
.clear {
clear: both;
}
@if $use-clearleft-right==true {
.clear-left {
clear: inline-start;
}
.clear-right {
clear: inline-end;
}
}
@if $use-clearhidden==true {
.clear-hidden {
clear: both;
margin: 0;
padding: 0;
visibility: hidden;
}
}
@if $use-clearfix==true {
.clear-fix::after {
content: '.';
display: block;
block-size: 0;
clear: both;
visibility: hidden;
}
}
/*
* ratio container (for responsive iframes/videos/etc.)
*/
[class*='ratio-container-'] {
inline-size: 100%;
block-size: 0;
@extend .relative;
}
.ratio-container-square {
padding-block-start: 100%;
}
.ratio-container-16-9 {
padding-block-start: 56.25%;
}
.ratio-container-5-1 {
padding-block-start: 20%;
}
.inner-ratio-container {
position: absolute;
inset: 0;
}
| 9,521 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_misc.scss | .row--orderable {
z-index: $layer-modals;
/* In case the modal is open */
background: var(--background-norm);
color: var(--text-norm);
}
/*
* Welcome boxes in a 2 column design
* Make breakpoint overable
*/
$breakpoint-2-columns: 1180 !default;
@include media('<=#{em($breakpoint-2-columns, 16)}') {
.boxes-placeholder-container {
flex-direction: column;
& > * {
margin-block-end: 1em;
inline-size: 100%;
flex-basis: auto;
}
}
.boxes-placeholder-button {
margin-block-start: 0;
}
}
.qr-code {
border: 1px solid white;
}
.unstyled {
padding-inline-start: 0;
list-style-type: none;
}
.list-columns {
column-count: 1;
column-gap: 0;
& > *,
&-no-break {
-webkit-column-break-inside: avoid; // Chrome, Safari, Opera
page-break-inside: avoid; // Firefox
break-inside: avoid; // IE 10+
break-inside: avoid-column; // W3C
}
}
@include responsive-classes(
(
column-1: (
column-count: 1,
),
column-2: (
column-count: 2,
),
)
);
/* hardware-acceleration activation */
.hardware-accelerated {
@include vendor-prefix(transform, translateZ(0));
}
/* to hide text with accessibility… a11y */
.invisible,
.sr-only {
border: 0;
clip: rect(0 0 0 0);
block-size: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
inline-size: 1px;
inset-block-start: 0; // needed for Safari dumb and 💩 behaviour
}
.visibility-hidden {
visibility: hidden;
}
.filter-blur {
filter: blur(4px);
}
/* RTL/others */
.mirror,
[dir='rtl'] .on-rtl-mirror {
transform: rotateY(180deg);
}
.rotateX-180 {
transform: rotateX(180deg);
}
.rotateZ-90 {
transform: rotateZ(90deg);
}
.rotateZ-270 {
transform: rotateZ(270deg);
}
/* increase surface click/tap */
.increase-click-surface::before {
content: '';
position: absolute;
inset: 0;
}
.no-pointer-events,
.no-pointer-events-children * {
pointer-events: none;
}
| 9,522 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_opacity.scss | // When adding new opacity classes, add the values also in Storybook
// applications/storybook/src/stories/cssUtilities/Opacity.stories.tsx
.opacity-70 {
opacity: 0.7;
}
.opacity-65 {
opacity: 0.65;
}
.opacity-50 {
opacity: 0.5;
}
.opacity-40 {
opacity: 0.4;
}
.opacity-30 {
opacity: 0.3;
}
.opacity-0 {
opacity: 0;
pointer-events: none;
}
.focus\:opacity-100 {
&:focus,
&:focus-within {
opacity: 1;
pointer-events: all;
}
}
// Make hover-only interaction focusable with keyboard
// deprecated: opacity-on-hover
$container-name: 'group-hover-opacity-container';
.group-hover\:opacity-100 {
&:not([aria-expanded='true'], .is-active) {
opacity: 0; // Do not use visibility to keep it focusable even when invisible
}
// Need a container to manage with focus-within
@at-root {
.#{$container-name}:focus-within &,
.#{$container-name}:focus-within .mouse\:group-hover\:opacity-100 {
opacity: 1;
}
}
@include media('mouse') {
.#{$container-name}:not(:hover, :focus, :focus-within) &-no-width:not([aria-expanded='true'], .is-active) {
position: absolute;
transition: none;
pointer-events: none;
}
@at-root {
.#{$container-name}:hover &,
.#{$container-name}:hover .mouse\:group-hover\:opacity-100 {
opacity: 1;
}
}
@at-root {
&,
.mouse\:group-hover\:opacity-100 {
opacity: 0;
will-change: opacity;
}
}
}
}
| 9,523 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_outline.scss | .outline-none {
// we remove outline for all cases, and add it back for focus-visible cases
&,
&--at-all {
&,
&:focus {
outline: 0;
}
}
&:focus-visible:not([tabindex='-1']) {
outline: 2px auto;
}
&--at-all {
&:focus-visible {
outline: 0;
}
}
}
| 9,524 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_position.scss | @include responsive-classes(
(
static: (
position: static,
),
relative: (
position: relative,
),
absolute: (
position: absolute,
z-index: 1,
),
fixed: (
position: fixed,
),
)
);
.absolute-center {
position: absolute;
inset-block-start: 50%;
inset-inline-start: 50%;
transform: translate(-50%, -50%);
[dir='rtl'] & {
transform: translate(50%, -50%);
}
}
.absolute-center-x {
inset-inline-start: 50%;
transform: translate(-50%, 0%);
[dir='rtl'] & {
transform: translate(50%, 0%);
}
}
.absolute-center-y {
inset-block-start: 50%;
transform: translateY(-50%);
}
.absolute-cover {
position: absolute;
inset: 0;
}
.sticky {
&-top,
&-bottom {
position: sticky;
z-index: 1;
}
&-top {
inset-block-start: 0;
}
&-bottom {
inset-block-end: 0;
}
}
.upper-layer {
z-index: $layer-upper;
}
/*
* Placements
*/
.top,
.top-0 {
inset-block-start: 0;
}
.right,
.right-0 {
inset-inline-end: 0;
}
.bottom,
.bottom-0 {
inset-block-end: 0;
}
.left,
.left-0 {
inset-inline-start: 0;
}
.inset,
.inset-0 {
inset: 0;
}
/*
* set up to use inline style with custom props
* to avoid having logical props in JS, postCSS can't process them
* Specificity issue with composer and others -_-v
*/
.top-custom {
&#{&} {
inset-block-start: var(--top-custom);
}
}
.right-custom {
&#{&} {
inset-inline-end: var(--right-custom);
}
}
.bottom-custom {
&#{&} {
inset-block-end: var(--bottom-custom);
}
}
.left-custom {
&#{&} {
inset-inline-start: var(--left-custom);
}
}
| 9,525 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_print.scss | @include media('print') {
/**
* add in this all elements which need to be hardly reseted for print
*/
body,
html,
.page,
.reset4print {
background-color: white;
background-image: none;
border: 0;
box-shadow: none;
color: black;
float: none;
block-size: auto;
margin: 0;
max-inline-size: 100%;
min-block-size: 0;
padding: 0;
position: static;
inline-size: auto;
opacity: 1;
visibility: visible;
max-block-size: none;
display: block;
font-size: 10pt;
}
body {
padding: 0.5em;
overflow: auto;
}
/* hide unnecessary elements */
.no-print {
display: none;
}
.is-printed-version {
.modal-container,
.modal,
.modal-content-inner,
.modal-two-content,
.modal-two,
.modal-two-dialog,
.modal-two-dialog-container {
@extend .reset4print;
}
.modal-content-inner::before,
.modal-content-inner::after {
content: none;
}
.app-root,
.modal-overlay,
.modal-two-backdrop,
.modal-two-header,
.modal-two-footer,
.item-icon,
.scroll-start-shadow,
.scroll-end-shadow {
@extend .no-print;
}
}
/* display specific elements for print */
.on-print {
display: block;
}
/* avoid problematic page break */
ul,
ol {
page-break-inside: avoid;
}
h1,
h2,
h3,
caption {
page-break-after: avoid;
}
.keep-color {
/* stylelint-disable-next-line */
print-color-adjust: exact;
}
.main {
border: 0;
}
}
.only-print {
@include media('screen') {
display: none;
}
}
| 9,526 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_responsive.scss | // For global structure adaptation in JS (page / skip links / header / main content / footer)
@include body-before('large-desktop', true);
.no-desktop {
display: none;
}
@include media('<=xlarge') {
@include body-before('medium-desktop');
}
@include media('<=large') {
@include body-before('small-desktop');
}
/**
* medium/tablet breakpoint
*/
@include media('<=medium') {
// For global structure adaptation in JS (page / skip links / header / main content / footer)
@include body-before('tablet');
.no-desktop {
display: block;
}
.no-tablet {
display: none;
}
.auto-tablet {
float: none;
display: block;
inline-size: auto;
}
.on-tablet {
&-flex-column {
flex-direction: column;
& > * {
inline-size: 100%;
flex-basis: auto;
}
}
&-flex-shrink {
flex-shrink: 1;
}
&-flex-justify-start {
justify-content: start;
}
&-flex-justify-end {
justify-content: end;
}
&-flex-justify-center {
justify-content: center;
}
&-order-1 {
order: 1;
}
@for $i from 2 through 3 {
&-hide-td#{$i} td:nth-child(#{$i}) {
display: none;
}
}
}
}
/**
* small/mobile breakpoint
*/
@include media('<=small') {
// For global structure adaptation in JS (page / skip links / header / main content / footer)
@include body-before('mobile');
.no-tablet {
display: block;
}
.no-mobile {
display: none;
}
/* linearization of floating content/table-layout */
// 🚗
.auto-mobile {
float: none;
display: block;
inline-size: auto;
}
.on-mobile {
&-flex {
display: flex;
}
&-inline-flex {
display: inline-flex;
}
&-flex-column {
flex-direction: column;
& > * {
inline-size: 100%;
flex-basis: auto;
}
}
&-flex-column-no-stretch {
flex-direction: column;
& > * {
align-self: center;
}
}
&-flex-item-fluid {
flex: 1 1 0px;
}
&-flex-item-fluid-auto {
flex: 1 1 auto;
}
&-no-flex {
flex: 0 0 auto;
}
&-flex-shrink {
flex-shrink: 1;
}
&-flex-align-self-start {
align-self: start;
}
&-flex-align-self-center {
align-self: center;
}
&-flex-justify-start {
justify-content: start;
}
&-flex-justify-end {
justify-content: start;
}
&-flex-justify-center {
justify-content: center;
}
&-flex-wrap {
flex-wrap: wrap;
}
&-order-1 {
order: 1;
}
&-border-none {
border: 0;
}
@for $i from 2 through 5 {
&-hide-td#{$i} td:nth-child(#{$i}) {
display: none;
}
}
}
}
/**
* tiny/small mobile breakpoint
*/
@include media('<=xsmall') {
// For global structure adaptation in JS (page / skip links / header / main content / footer)
@include body-before('tinymobile');
.no-tiny-mobile {
display: none;
}
/* linearization of floating content/table-layout */
.auto-tiny-mobile {
float: none;
display: block;
inline-size: auto;
}
.on-tiny-mobile {
&-flex-align-self-start {
align-self: flex-start;
}
&-flex-column {
flex-direction: column;
& > * {
inline-size: 100%;
flex-basis: auto;
}
}
&-flex-column-no-stretch {
flex-direction: column;
& > * {
align-self: center;
}
}
&-flex-column-reverse {
flex-direction: column-reverse;
}
&-flex-item-grow-1-5 {
flex-grow: 1.5;
}
&-flex-item-grow-3 {
flex-grow: 3;
}
&-flex-item-grow-custom {
flex-grow: var(--xs-grow-custom);
}
&-hide-td3 td:nth-child(3) {
display: none;
}
}
}
| 9,527 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_rounded.scss | .rounded-sm {
border-radius: var(--border-radius-sm);
}
.rounded {
border-radius: var(--border-radius-md);
}
.rounded-lg {
border-radius: var(--border-radius-lg);
}
.rounded-xl {
border-radius: var(--border-radius-xl);
}
.rounded-full {
border-radius: var(--border-radius-full);
}
.rounded-50 {
border-radius: 50%;
}
.rounded-none {
border-radius: 0;
}
| 9,528 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_shadow.scss | // .shadow-norm .shadow-lifted for purgecss
@each $type in (norm, lifted) {
:root {
--shadow-#{$type}: var(--shadow-#{$type}-offset)
rgb(var(--shadow-color, var(--shadow-default-color)) / var(--shadow-#{$type}-opacity));
}
}
@include responsive-classes(
(
shadow-norm: (
box-shadow: var(--shadow-norm-offset)
rgb(var(--shadow-color, var(--shadow-default-color)) / var(--shadow-norm-opacity)),
),
shadow-lifted: (
box-shadow: var(--shadow-lifted-offset)
rgb(var(--shadow-color, var(--shadow-default-color)) / var(--shadow-lifted-opacity)),
),
shadow-none: (
box-shadow: none,
),
)
);
.shadow-color-norm {
--shadow-color: var(--shadow-default-color);
}
.shadow-color-primary {
--shadow-color: var(--shadow-primary-color);
}
| 9,529 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_sizing.scss | @use 'sass:math';
@use 'sass:map';
@function pixel-to-rem($value) {
@return if(type-of($value) == 'number' and unitless($value), rem($value), $value);
}
$dummy-map: ();
/// These sizings were defined in collaboration with the Design team.
/// Please contact the UXE team if you need any additional one.
/// If you can't find what you need, please consider using custom sizing utilities:
/// https://design-system.protontech.ch/?path=/docs/css-utilities-sizing--fractions#custom
@each $direction, $property in (w: inline, h: block) {
@each $boundary in (min, '', max) {
// Common property name
$propname: dash-join($boundary, $property, 'size');
// Framework
@each $sizingname, $size in ('0': 0, 'px': '1px', '2': 8, '4': 16, 'full': 100%, 'auto': 'auto', 'none': 'none') {
@if not(($sizingname == 'auto' and $boundary != '') or ($sizingname == 'none' and $boundary == '')) {
$classname: dash-join($boundary, $direction, $sizingname);
$value: pixel-to-rem($size);
$dummy-map: map.merge($dummy-map, (#{$classname}: (#{$propname}: #{$value})));
}
}
// Fractions
@if $direction == 'w' {
// Do not add any new value here without asking UXE team!
@each $i in (2, 3, 4, 5, 6, 10) {
@for $j from 1 through $i - 1 {
$classname: dash-join($boundary, $direction, $j + '\\\/' + $i);
$value: math.div($j, $i) * 100%;
$dummy-map: map.merge($dummy-map, (#{$classname}: (#{$propname}: #{$value})));
}
}
}
// Customs
$classname: dash-join($boundary, $direction, 'custom');
$value: var(--#{'[BPN]' + $classname});
$dummy-map: map.merge($dummy-map, (#{$classname}: (#{$propname}: #{$value})));
}
}
// We need to serialize the classes to avoid any cascade ordering issues
@include responsive-classes($dummy-map);
| 9,530 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_spacing.scss | @use 'sass:map';
// when updating margin sizes, please update them in Storybook accordingly
// applications/storybook/src/stories/cssUtilities/Margin.stories.tsx
@function pixel-to-rem($value) {
@return if(type-of($value) == 'number' and unitless($value), rem($value), $value);
}
$spacings: (
'0': 0,
'0\\\.5': 2,
'1': 4,
'2': 8,
'3': 12,
'4': 16,
'5': 20,
'6': 24,
'7': 28,
'8': 32,
'10': 40,
'11': 44,
'12': 48,
'14': 56,
'16': 64,
'auto': 'auto',
);
// generate css custom props
:root {
@each $spacingname, $size in $spacings {
$spacingname: str-replace($spacingname, '\\\.', '-');
--space-#{$spacingname}: #{pixel-to-rem($size)};
}
}
$dummy-map: ();
// generate `margin` and `padding` classes
$properties: (
m: 'margin',
p: 'padding',
);
$placements: (
default: '',
y: 'block',
t: 'block-start',
b: 'block-end',
x: 'inline',
l: 'inline-start',
r: 'inline-end',
);
@each $propertyname, $property in $properties {
@each $placementname, $placement in $placements {
$cssproperty: if($placementname == 'default', $property, dash-join($property, $placement));
@each $spacingname, $size in $spacings {
@if not($property == 'padding' and $spacingname == 'auto') {
$classname: dash-join($propertyname + if($placementname == 'default', '', $placementname), $spacingname);
$value: pixel-to-rem($size);
$dummy-map: map.merge(
$dummy-map,
(
$classname: (
#{$cssproperty}: #{$value},
),
)
);
}
}
$classname: dash-join($propertyname + if($placementname == 'default', '', $placementname), 'custom');
$value: var(--#{'[BPN]' + $classname});
$dummy-map: map.merge(
$dummy-map,
(
$classname: (
#{$cssproperty}: #{$value},
),
)
);
}
}
// generate `gap` classes
$placements: (
default: '',
x: 'column',
y: 'row',
);
@each $placementname, $placement in $placements {
$cssproperty: if($placementname == 'default', 'gap', dash-join($placement, 'gap'));
@each $spacingname, $size in $spacings {
@if not($spacingname == 'auto') {
$classname: dash-join('gap', if($placementname == 'default', '', $placementname), $spacingname);
$value: pixel-to-rem($size);
$dummy-map: map.merge(
$dummy-map,
(
$classname: (
#{$cssproperty}: #{$value},
),
)
);
}
}
$classname: dash-join('gap', if($placementname == 'default', '', $placementname), 'custom');
$value: var(--#{'[BPN]' + $classname});
$dummy-map: map.merge(
$dummy-map,
(
$classname: (
#{$cssproperty}: #{$value},
),
)
);
}
// We serialize here to factorize media queries
@include responsive-classes($dummy-map);
| 9,531 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_table.scss | .table-auto {
table-layout: auto;
}
.table-fixed {
table-layout: fixed;
}
| 9,532 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_typo.scss | @use 'sass:map';
.text-monospace {
font-family: $font-family-monospace;
}
.text-tabular-nums {
font-variant: tabular-nums;
}
@if $use-other-typo-helpers==true {
$dummy-map: ();
@each $name, $size in (2xs: 9, xs: 10, sm: 12, rg: $base-font-size, lg: 16, xl: 18, 2xl: 20, 3xl: 22, 4xl: 24) {
$dummy-map: map.merge(
$dummy-map,
(
text-#{$name}:
(
font-size: #{em($size)},
)
)
);
}
// Serialize the responsive utilities creation with the map to avoid any cascade ordering issues
@include responsive-classes($dummy-map);
}
@if $use-other-line-height-helpers==true {
.lh100 {
line-height: 1;
}
.lh120 {
line-height: 1.2;
}
.lh130 {
line-height: 1.3;
}
.lh-rg {
line-height: $base-line-height;
}
}
/* Hyphenation: Thou shalt not pass (Moïse or Gandalf, don’t remember) */
@if $hyphenation==false {
.text-cut {
word-break: break-word;
}
@supports (-webkit-hyphens: auto) or (hyphens: auto) {
.text-cut {
word-break: normal;
@include vendor-prefix(hyphens, auto, webkit);
}
}
}
.link {
@extend a;
}
.link-focus {
outline: 1px solid transparent;
outline-offset: em(1);
border-radius: var(--border-radius-sm);
transition: outline 0.15s easing(ease-out-quad);
&:focus-visible {
outline-color: var(--focus-outline);
}
}
/* remove hyphenation if needed */
.text-no-cut {
word-wrap: normal;
}
@supports (-webkit-hyphens: auto) or (hyphens: auto) {
.text-no-cut {
@include vendor-prefix(hyphens, none, webkit);
}
}
.text-break {
word-break: break-word;
}
.text-break-all {
word-break: break-all;
}
.text-hyphens {
@include vendor-prefix(hyphens, auto, webkit);
}
@include responsive-classes(
(
text-left: (
text-align: start,
),
text-center: (
text-align: center,
),
text-right: (
text-align: end,
),
)
);
@each $align in (baseline, sub, super, text-top, text-bottom, middle, top, bottom) {
.align-#{$align} {
vertical-align: $align;
}
}
.text-ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.text-ellipsis-two-lines,
.text-ellipsis-four-lines {
/* stylelint-disable-next-line */
display: -webkit-box;
/* stylelint-disable-next-line */
-webkit-box-orient: vertical;
overflow: hidden;
}
.text-ellipsis-two-lines {
-webkit-line-clamp: 2;
}
.text-ellipsis-four-lines {
-webkit-line-clamp: 4;
}
.text-uppercase {
text-transform: uppercase;
}
.text-capitalize {
text-transform: capitalize;
}
.text-capitalize-block {
text-transform: lowercase;
&::first-letter {
text-transform: uppercase;
}
}
.text-strong,
.text-bold {
font-weight: var(--font-weight-bold);
}
.text-normal,
.text-no-bold {
font-weight: var(--font-weight-normal);
}
.text-semibold {
font-weight: var(--font-weight-semibold);
}
.text-italic {
font-style: italic;
}
.text-no-italic {
font-style: normal;
}
.text-strike {
text-decoration: line-through;
}
.text-pre {
white-space: pre;
}
.text-pre-wrap {
white-space: pre-wrap;
}
.text-no-wrap,
.text-nowrap {
white-space: nowrap;
}
.text-no-decoration {
text-decoration: none;
}
.text-underline {
text-decoration: underline;
}
.hover\:text-underline {
&:hover,
&:focus {
text-decoration: underline;
}
}
// if this is empty, we add an non-breakable-space
.text-keep-space:empty::before {
content: '\00a0';
}
.user-select {
user-select: all;
}
.user-select-none {
user-select: none;
}
| 9,533 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles | petrpan-code/ProtonMail/WebClients/packages/styles/tasks/lint-svg.sh | #!/usr/bin/env bash
set -eo pipefail
for file in $(find . -type f -name "*.svg" -not -path "./node_modules/*"); do
echo "[LINT]: $file";
npx svgo "$file" -q 2>&1 -o /dev/null;
done;
| 9,534 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/testing/.eslintrc.js | module.exports = {
extends: ['@proton/eslint-config-proton'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
ignorePatterns: ['.eslintrc.js'],
};
| 9,535 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/testing/README.md | # Testing
The testing package contains common mocks and test data to use across the monorepo.
## Builders
Builders are using [test-data-bot](https://github.com/jackfranklin/test-data-bot) to generate data structures according to our types. It is reasonably flexible, allowing to create variations by using `traits` and using overrides, have some random and/or fixed fields and use builders within builders.
## Handlers
Handlers are for [Mock Service Worker](https://mswjs.io) to use in mock API responses. It can be used both in tests as well as client side when needed. `handlers.ts` responses are loaded by default, but you can override via `server.use` and injecting a `rest.get` to override an existing handler.
## Mocks
The mocks are all blank apart from the API and getRandomValues. The simple API mock is necessary to allow the use of `MSW`.
| 9,536 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/testing/index.ts | export { rest } from 'msw';
export * from './lib/api';
export * from './lib/builders';
export * from './lib/cache';
export * from './lib/context';
export * from './lib/event-manager';
export * from './lib/flush-promises';
export * from './lib/mockApiWithServer';
export * from './lib/mockModals';
export * from './lib/mockNotifications';
export * from './lib/mockRandomValues';
export * from './lib/mockSpotlight';
export * from './lib/mockUseActiveBreakpoint';
export * from './lib/mockUseAddresses';
export * from './lib/mockUseApi';
export * from './lib/mockUseConfig';
export * from './lib/mockUseContactEmailsCache';
export * from './lib/mockUseEventManager';
export * from './lib/mockUseFeature';
export * from './lib/mockUseFlag';
export * from './lib/mockUseFolders';
export * from './lib/mockUseHistory';
export * from './lib/mockUseLabels';
export * from './lib/mockUseLocation';
export * from './lib/mockUseMailSettings';
export * from './lib/mockUseNotifications';
export * from './lib/mockUseSelector';
export * from './lib/mockUseSpotlightOnFeature';
export * from './lib/mockUseUser';
export * from './lib/mockUseWelcomeFlags';
export * from './lib/payments';
export * from './lib/server';
| 9,537 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/testing/package.json | {
"name": "@proton/testing",
"description": "",
"license": "GPL-3.0",
"main": "index.ts",
"scripts": {
"check-types": "tsc",
"lint": "eslint index.ts lib --ext .js,.ts,.tsx --quiet --cache",
"pretty": "prettier --write $(find . -path ./node_modules -prune -o -type f -name '*.js' -o -name '*.ts' -o -name '*.tsx')"
},
"dependencies": {
"@proton/shared": "workspace:packages/shared"
},
"devDependencies": {
"@jackfranklin/test-data-bot": "^2.1.0",
"cross-fetch": "^4.0.0",
"msw": "^1.3.2"
}
}
| 9,538 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/testing/tsconfig.json | {
"extends": "../../tsconfig.base.json"
}
| 9,539 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/builders/address.ts | import { Address, AddressKey } from '@proton/shared/lib/interfaces';
export const buildAddress = (value?: Partial<Address>): Address => {
return {
CatchAll: false,
ID: 'YC-yr6jeFLCSwO5DuGBxGYMSHesNSgl3FcIZ-ITJtvTu2w6gBAmGnufX8Hnl0TK4P5p2VOPJ3kVcjHBSj9hQKw==',
DomainID: 'l8vWAXHBQmv0u7OVtPbcqMa4iwQaBqowINSQjPrxAr-Da8fVPKUkUcqAq30_BCxj1X0nW70HQRmAa-rIvzmKUA==',
Email: '[email protected]',
Status: 0,
Type: 2,
Receive: 0,
Send: 0,
DisplayName: 'Jovan',
Signature: '<div>pred><posle</div>',
Order: 37,
Priority: 37,
HasKeys: 1,
Keys: [
{
ID: 'Rw8hqmbcdWaSfNy2lxbJ54xDlwFvUtYbyTK4YPva6Gw_WWQ6yMOvOsRF_a-v5ddOP2fsTv-vX-ZM0R_JdKSUGg==',
Primary: 1,
Flags: 3,
Fingerprint: '6afee2a00d36edbf42f7f28c332d35bb9d2fce91',
Fingerprints: ['6afee2a00d36edbf42f7f28c332d35bb9d2fce91', 'a28a3964196a4fe0a0dcb7f10ffa6f0097158327'],
PublicKey:
'-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: ProtonMail\n\nxsBNBFrPQ8MBCACI3P2NU+79ShFa9pmdXHHvjR9pMa7p/PzGBqb8psH5ZTbA\ntPUECvBNsdGvH6/WwhijwphZuNufe6h3t1fPfnE01oM9i3DLZaOgIC9/Iose\nOkhA0OkHGScpuI4YqtFu6hYyVqxV5X5DruJhrC2dkp2M8eEhn/ZuWFa5VxaZ\nA3XJYbM8NLqr5fR1nlFnAug3FGfqQweTDvVvOKDUSkvi6pbRGdaB5LlaB5gX\npBdCVaGdoHEE/c3pnXgJLKtOClufEpyzTIc4CwoKizwXjHUxD9DM2S9Tt5Ce\nBcyZ9zqnmuey6d2sE2/Dh+KtF0HQkHHVGWiuya3dmeD2GXBftG3c07UfABEB\nAAHNM2p2bnRzdDEyMEBwcm90b25tYWlsLmNvbSA8anZudHN0MTIwQHByb3Rv\nbm1haWwuY29tPsLAjQQQAQgAIAUCYTDKywYLCQcIAwIEFQgKAgQWAgEAAhkB\nAhsDAh4BACEJEDMtNbudL86RFiEEav7ioA027b9C9/KMMy01u50vzpFHXwf/\nYOq9dDaTAhJSIafSIENqHKtUsq2ZnT8t48835GEo36Wpyt42j9z9iC4BuIG8\nt1FWrZmS5DqqZ6/Ksq6pUjd1JlrOE/ROcjF08fdmaLO5n3VJrAmLMi+rXWpS\nNK2K7WE004Ky5aa1R556A9wpcbrazMd/Uc64GqsSofEjoL4xI3HEoi/6QwGJ\n69jIUYc2oUTjEhwv56QnaDz8hGHIcLJe6l8dmELtsr6xDV5iyjwvpyMqDjVS\nOGIriksA3F97tLaF4jqLenUPiPB82V5Bt0MgBkDLEWZRx8SLw87ze0/ZyB10\ncPQQJlw9Sood09r/yRdVykOmVBJvsZziQJGKquXKi87ATQRaz0PDAQgAu7lm\npkaXp2jEZLodI/XyZPaOq52PnR6ww6tBDukGZR+59EYzZ3cDtK+Y4cmlbqBg\nHmuVVAwxWNrrvvy2/19Vm9mIJW76qggJNEf+GMwzPuc6KA2DveioDUIy4p0Y\nSETyjmRcploBEfe1TtDRCH+29Dva7XNeX24i7OVMetXqMiB55T7HplfernqE\nPjd1rYVG1/dWWaQi0NlZUaUZUvVqETlusTG5wLprEhDhpn3cyaKavJazaciZ\nkoetjzYvpkLtmak/dN68PPLcZ0ubircV1X+DVgLtQGMf3v3eLGY2Jkdna5VJ\nncEOa4/O+mpLedKlFkHg2GixYRWNf4PYLwpIaQARAQABwsB2BBgBCAAJBQJh\nMMrLAhsMACEJEDMtNbudL86RFiEEav7ioA027b9C9/KMMy01u50vzpElNAf+\nMcUpuiSnz6REc5WOEow3Ti9OF1kBgN5wvGGlZmOj+XkDnQZqpPdLn+wMyhU7\n0hXHE0z9qkPSWRNqzJdIMeQ+kX/ML5dw368SXX1v/udviqPEvu9nhoMsQw7S\naSt/vPjPjwVMIn8s4BTzYYtBzDnzqFF5xgzPIKZQtheLxcQqS8BA2oUkviNy\nsoSHnW63fIgV48GDGP7XMBi3MtSSngLRQUjVmbhAP3mbyrGxMyWwrxaOj1wg\nCJu2HCNVKwIy7EgKdT2D+jBfa0scDVPTkQAxAVw2JnMYeoqWAebqJXSKDAZ5\nU+5l/+i8l586tFJmg6sfC8pJYoSQsvQ4JManm5YjgA==\n=Gxhi\n-----END PGP PUBLIC KEY BLOCK-----\n',
Active: 1,
Version: 3,
PrivateKey:
'-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: ProtonMail\n\n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\n=w8zS\n-----END PGP PRIVATE KEY BLOCK-----\n',
Token: '-----BEGIN PGP MESSAGE-----\nVersion: ProtonMail\n\nwcBMA+d3/RmquWBYAQf/U9ovKmpXSnD8hMVlKe/NHPteUMY+Kb+D2P6lXh/K\ny7mWAQJzr49gX6Gp9JfNA3y34VD8E+vgab/7FYVX1Z2E/iRa+bzmmE0W6lPX\nPgm5COKkRmfovDtgOoUffvBi9aEG6BgxtkXY1r1H2Jf2mmqKBPNJirzVdvJ5\neEO1TdgnHLu8caXeofBQgoBa5ObfolpSIMFLsBWVD8kPr4jBPKifbF+3SjZ9\n15lhyQa+AE/Z0+7HL/xdQ5V81cGZiUvmpv0thZE80x8j2dMrovWyPc5bD/gW\n0xDZlZAy++fAd66aYSPjFaSlJ+/TFmWoeyMPe0cxYvY5c7o9dZPzWUJ/UeQe\n99J4AcvL3ORCg/TowGVcvWDvE9ib4D3ZjcP+sPhhidmqjAjw9yTbaCHLyx6n\nfA5hwdPFO9vCGnBVwarx7Dqyjr02ICxzpIHicPqeBimrT52XKTPo9TP+a767\nyVrRZf0C08jWkR128bfSivn2axlgj/B6Pj8NW27WlEC8\n=odVa\n-----END PGP MESSAGE-----\n',
Signature:
'-----BEGIN PGP SIGNATURE-----\nVersion: ProtonMail\n\nwsBzBAEBCAAGBQJhl45HACEJEMO1ZjhE3f0jFiEEmo5cq93ZoSWYGoi3w7Vm\nOETd/SMGMwgAhM/J/ZniEw+eXk9zOPYSuk7muhG/OOVj42RqXNM151Dhe3qA\ncUg4KX1RahoMWEIasegw062xtancNwpE9xm0yO4/UaccVe6x3sucIGRcIlUR\nxEMsu843sl5G00m6ajras3QNCaKm7AcPatiQqL1aVTbIuVR/lF/TSo29BsA6\nMfC7LObXLP8zU89/88u879gW+Vsfnt9m/lRSPEU2bgEVCGWvSP3huoExH938\nHgWRtTd+ySe+CaGCPFL0YjYdBL6nQi4oQRcQTXWJkG+DFbISR6AaRBLyxxMt\nDlCl8izyvBov0jYeoblyeEFDsTU2Fy8OnYGgYP/LITK71t0KkimPcw==\n=U6I7\n-----END PGP SIGNATURE-----\n',
} as AddressKey,
],
SignedKeyList: null,
ProtonMX: true,
ConfirmationState: 1,
...value,
};
};
| 9,540 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/builders/index.ts | export * from './user';
| 9,541 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/builders/user.ts | import { Key, UserModel } from '@proton/shared/lib/interfaces';
import { privateKeyA } from '../data';
export const buildUser = (value?: Partial<UserModel>): UserModel => {
return {
ID: 'rSUCW_Qlh8dCCsxWKPXvkUsoDNL5eW9FJUM7WX8jTPrDE3ftOMIfWt-BSuKaw5PZ7EQ6Zsp8HL9Y9qMv4Y5XJQ==',
Name: 'alice',
Currency: 'EUR',
Credit: 0,
Type: 1,
CreateTime: 1589313678,
MaxSpace: 7516192768,
MaxUpload: 26214400,
UsedSpace: 99993,
Subscribed: 1,
Services: 1,
MnemonicStatus: 4,
Role: 2,
Private: 1,
Delinquent: 0,
DriveEarlyAccess: 0,
Idle: 0,
Keys: [
{
ID: '4Xi8TArBe1WYfrFoJF5_wIDF0shMe5ACAqOArU6hjpUNoC0O0c_Zu5Afz11gGU1eeDu5Aanp_EUkpd44kjQ2lg==',
Version: 3,
Primary: 1,
RecoverySecret: null,
RecoverySecretSignature: null,
PrivateKey: privateKeyA,
Fingerprint: '5372de721b9971518273581e04cd9dc25fbae509',
Active: 1,
} as Key,
],
ToMigrate: 0,
Email: '[email protected]',
DisplayName: 'alice',
Flags: {
protected: false,
'drive-early-access': false,
'onboard-checklist-storage-granted': false,
'has-temporary-password': false,
'test-account': false,
'no-login': false,
'recovery-attempt': false,
sso: false,
},
isAdmin: true,
isMember: false,
isFree: false,
isPaid: true,
isPrivate: true,
isSubUser: false,
isDelinquent: false,
hasNonDelinquentScope: true,
hasPaidMail: true,
hasPaidVpn: false,
hasPaidDrive: false,
canPay: true,
AccountRecovery: null,
...value,
};
};
| 9,542 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/data/index.ts | export * from './keys';
export * from './payments';
| 9,543 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/data/keys.ts | export const privateKeyA =
'-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: ProtonMail\n\nxcMGBF67AJkBCACdxh2Ix0gDdRQpnYbwiYgRMjv+D8dG8m2OpzNwC/N66XAV\naemfAJqKckkRIwq/+c/tbFbM8URQBJP7i+01LesCVC1BiH0DTQBVnrRN4B2B\nvkwziu6AHFHP/PkQICTA0hhpWr5f7XOcQ3QGumqc15fuK10QKqh+YBAF/QPH\nMBI2l/RPFSLKwRBF5vF1n+7URfSBnunKg3alTrd4c5U0XQ9rvIG9lcqNl7MF\nHP/pZZ9nTKWafZx9CKpA01OsKquJNtOzLBr3TrBPoWCmcRPQHs8+pR3bmsy/\nWRdP/qa8N8rS1lIojHKRsSeMtrFsz5+7JKsgdUEKCt9O6DLJdX4KpJCrABEB\nAAH+CQMIRYZqop93ToFgaQswNNWxNRND/rOVXHOetQTtnw23cvOkuK88BPem\nq9W4pPKxxEPya70CFI/1thhZP1cVwvESZ6NB8XBhDPX78o+0vGN2MHh4zrOn\n18Qo9P56B8pZauReKOU8h2uJyQ22gogGrew1G5GwZQXdW12vTJ4KAeOsrE18\nIUT6fn5wFK9tqUpZrF46i6AA8fQvGT+NsRwCBzifjZPmu5QZ8ZV6GU/KjDh2\nyGkPAZKn48x9Ylb/NBzDdkjWJmeXL8pBDLiyYwXLUlP/lfL0T91Ys/v5mqJu\nTge4EqD2bj0kPzuMEcbvkqavTpvqmy8Gfq5SSY6IGLQNNjgM8nJkQutSmGej\nAT7X1j+fMuc3Uat7hLd3rsMjqTo9LMau0+XREus2w2E7b0SIjZFYqb62Tm81\ng0e3X+z/HVmXYZnPAyitJy3hNWdyryDBgzuD8UjRIPhD7Axvm8eBWZaRUx8V\nUvhokwrRQk+SrFJnyiJhWUjTlL/mecUS8tKH+3/KHr3o+8S5bK19LJ2SC0Ec\nU8eYgEcAWuUXjEf6jnP3Gvm0XD57/qkT4qNWiJcw7+e4Kevfwf74tVnIqg5i\norFduEyfz7SV9w1kSe9HT6BY+jZQwvexeLrofTi4H+ueNSYaN2L11VGxbh85\nGDD+VPqIAA88vut7EEDzm01WrVyyL3BCDRd1t2nPQ27Hi7eB2kNVv9nsSpjY\nFv/niWx7Kp3LYLUnMwpf8We7pXgEnBWe8PPIZH3iYIrXKJEVZjo7NoquSXA2\nuu7aVFmkyLrjAXlT2XxGJLzL0KeNUOviGcBdAvFcjA2n3FLFgJLV8GLI5wy8\n4S+qI2p0TipL6M5o9jTL+QnMojjuJyDKZyoZ1OgEmuv/RKRG6f57unZCBGn1\nvJ2YVxj7MMaLmabuHHSBdUku6pEc5bfJzSdwcm9AcHJvdG9ubWFpbC5kZXYg\nPHByb0Bwcm90b25tYWlsLmRldj7CwHYEEAEIACAFAl67AJkGCwkHCAMCBBUI\nCgIEFgIBAAIZAQIbAwIeAQAKCRAEzZ3CX7rlCTFcB/0U6DqZmVKqv0lFBwnT\nLgxobs0LOW5CK15Y3wYF5V4HK30+2viFThMlyLPmUxDRoe8NQ9oUCkROQKE2\ngovixKlBofHxFDE/BZAF9OyVxwkk1+X/CDbn1TMCmkNC4lVZ+mbbyzzwGqgg\nmoZXGG816Fvc3YLR7q6s6iBvYomPhOv8essIgjbxClziHVcuCuTToM71b+3W\nznbd+WW89gt9r0sHpxyM6fnPYP2APYGe0xoWe1wgRNLn9vELGi5XprAzCKN5\n7G0f93hCq4VRQYxqWvnOLU9eOvYWa6oaXHmLnI4pml6ng0/HFNTFRFAJ4G+T\nP+0fHLxaV2dm2Sg54E22thmdx8MGBF67AJkBCADZFBeLn19hB73BEg8vMKBE\nkbNNmfP1iO/csPhWPftHdXCcEhkdB6NwjwtrLbAhgK1V0kWawOVH1LPYmSDt\nxnM83hF22TU6YfVC4KulK5Ty5WffE5KQkNdBPRN/87rEQRbHvT+xfpHG5ekN\nU5buXZH5bsgsl83XHaOA/omRcLEIuWmZLv3fopBgL8uZaq0/FaabdkJ0FZ3x\nN+ufWqV0zR9eqbP/stheK8eqy7b7HaZc/JkckTfshucofEA0/DNlqokphaE0\ncn0vZPwdHjwEJTeP0tAycuwqYSTNOmWxado3WqelwZCatSQ3QGssjcUfDycb\nVSRit0GAWqIFoASH214NABEBAAH+CQMIGut/fHj7mgNgygFrDciKcqUIUmkg\nerJQF2EtwrH90qVSLHJHQ9X3DitEVbO2HR6wKhiyIju3Lm22LPpstOoTjIED\nD7UBtGMY0EbHkJvw+jjhxAXE8M54sbcfzsUsCwaZlo3JJnG771GFbreoxaW5\nryRXPtljZHLIX9J8gBlr47E7p8qbAmdbcjL0XSpCSy1+DpEmV0kFUOlpZUea\nQK7795G6rZQodF14KCgBHgFEOa0CwpAM7Mi5e1o5bG63U4cL6k8RGhXG6kDc\nviJ8q6tGSrmEUZC261wH3JkdleRlLL7s8RnOEvraL2ymHg7g3rT40rFQIxBH\nv8wZBuT/DZdC9vPPTW9pVQMK6cxmahb/rgvEriQNk9MXk4unGYoK5Twji6d+\nkUJ0SNPPXzz9FYQ4wpivAn4TYa2R0trl0GIAwWlLCrTFMhgYpz99Ct2u+aWw\ni0DkrTcZ01HX9FnjegkpG54hEn5VOdCzUeiaRxKLFGRDERgpxRlEZLNwZYjN\nbqRJzRnoWFFYZI/5nEfuG7ELO3fOVQtxK3cPsuvENe+NJ1LYHwFpk9E8RCjp\nkQtAsltJ82jSniVchCq7411vM+Ud3qbUYjNo2ofzUMvXjhbhu8171BI0wtmA\nQYPQCb1sNiUI2vuO5Lbu0hnJ5xStW4VqUbP9AhLEkqpaeI6JsXdYpauqwCxq\nZn1YfBlj9Zw9aF9fEcTxutXE/gdq4eTbpm/Rqc02Vs0Quug6eiMu15nM9lI2\nz+QvjV59V+cIY0c+Zg9Dz6tcMFMue8u/uh0ypjGFXMoJDZ7xligZnomLYY5Z\nlqXQm5T9OHeZ3FmWtaBcntB/nne59DYPHq9SwFJxgU237KE9TKtljrEl3cLH\nn94Efh7TybwYM4+43F6907c6kGCqz+mV1VrmRkmyGvh3lwxsjUAqo9+GwsBf\nBBgBCAAJBQJeuwCZAhsMAAoJEATNncJfuuUJDTkH/Ru1uOI9ZW0ddV+R24dH\n6tbSmS0QLqaq1C645qu3eMGKUILdef5Dx/S3d9gpn+q5SRMvh/KBh/y3r78/\n3VvFdVyBh2kFVVEnGVG5+D4/5wj0UqX3bfd4aVR0XBIOTiR+tfnQINH6rfai\nwptTKB+fAlKhxcVwVi2eSoIcwlRlZinWRCgrvUnXQ59bJW98cErKWgPEyKOK\nWa7U19laMFmCycH68lXWUAzaxsRtjrvGyJJhUwqWVMloNCxlM4sI3AA5xuQK\nBHtimB9D8meqS/a52IAi5kwzOLLpYpLP286bDCqY6P/zWF3mxmSlXUKN3d5K\nydJHDOOvI+zz/2tadhbwT6A=\n=GaA/\n-----END PGP PRIVATE KEY BLOCK-----\n';
| 9,544 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/data | petrpan-code/ProtonMail/WebClients/packages/testing/data/payments/data-plans.ts | import { ADDON_NAMES, PLANS } from '@proton/shared/lib/constants';
import { PlansMap } from '@proton/shared/lib/interfaces';
export const PLANS_MAP: PlansMap = {
[PLANS.MAIL_PRO]: {
ID: 'BKiAUbkGnUPiy2c3b0sBCK557OBnWD7ACqqX3VPoZqOOyeMdupoWcjrPDBHy3ANfFKHnJs6qdQrdvHj7zjon_g==',
Type: 1,
Name: PLANS.MAIL_PRO,
Title: 'Mail Essentials',
MaxDomains: 3,
MaxAddresses: 10,
MaxCalendars: 25,
MaxSpace: 16106127360,
MaxMembers: 1,
MaxVPN: 0,
MaxTier: 0,
Services: 1,
Features: 1,
State: 1,
Pricing: {
'1': 799,
'12': 8388,
'24': 15576,
},
DefaultPricing: {
'1': 799,
'12': 8388,
'24': 15576,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 799,
},
[ADDON_NAMES.MEMBER_MAIL_PRO]: {
ID: 'FK4MKKIVJqOC9Pg_sAxCjNWf8PM9yGzrXO3eXq8sk5RJB6HtaRBNUEcnvJBrQVPAtrDSoTNq4Du3FpqIxyMhHQ==',
Type: 0,
Name: ADDON_NAMES.MEMBER_MAIL_PRO,
Title: '+1 User',
MaxDomains: 0,
MaxAddresses: 10,
MaxCalendars: 25,
MaxSpace: 16106127360,
MaxMembers: 1,
MaxVPN: 0,
MaxTier: 0,
Services: 1,
Features: 0,
State: 1,
Pricing: {
'1': 799,
'12': 8388,
'24': 15576,
},
DefaultPricing: {
'1': 799,
'12': 8388,
'24': 15576,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 799,
},
[PLANS.BUNDLE_PRO]: {
ID: 'q6fRrEIn0nyJBE_-YSIiVf80M2VZhOuUHW5In4heCyOdV_nGibV38tK76fPKm7lTHQLcDiZtEblk0t55wbuw4w==',
Type: 1,
Name: PLANS.BUNDLE_PRO,
Title: 'Business',
MaxDomains: 10,
MaxAddresses: 15,
MaxCalendars: 25,
MaxSpace: 536870912000,
MaxMembers: 1,
MaxVPN: 10,
MaxTier: 2,
Services: 15,
Features: 1,
State: 1,
Pricing: {
'1': 1299,
'12': 13188,
'24': 23976,
},
DefaultPricing: {
'1': 1299,
'12': 13188,
'24': 23976,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 1299,
},
[ADDON_NAMES.DOMAIN_BUNDLE_PRO]: {
ID: '39hry1jlHiPzhXRXrWjfS6t3fqA14QbYfrbF30l2PYYWOhVpyJ33nhujM4z4SHtfuQqTx6e7oSQokrqhLMD8LQ==',
Type: 0,
Name: ADDON_NAMES.DOMAIN_BUNDLE_PRO,
Title: '+1 Domain for Business',
MaxDomains: 1,
MaxAddresses: 0,
MaxCalendars: 0,
MaxSpace: 0,
MaxMembers: 0,
MaxVPN: 0,
MaxTier: 0,
Services: 15,
Features: 0,
State: 1,
Pricing: {
'1': 150,
'12': 1680,
'24': 3120,
},
DefaultPricing: {
'1': 150,
'12': 1680,
'24': 3120,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 150,
},
[ADDON_NAMES.MEMBER_BUNDLE_PRO]: {
ID: '0WjWEbOmKh7F2a1Snx2FJKA7a3Fm05p-nIZ0TqiHjDDUa6oHnsyWeeVXgSuzumCmFE8_asJsom9ZzGbx-eDecw==',
Type: 0,
Name: ADDON_NAMES.MEMBER_BUNDLE_PRO,
Title: '+1 User for Business',
MaxDomains: 0,
MaxAddresses: 15,
MaxCalendars: 25,
MaxSpace: 536870912000,
MaxMembers: 1,
MaxVPN: 10,
MaxTier: 0,
Services: 15,
Features: 0,
State: 1,
Pricing: {
'1': 1299,
'12': 13188,
'24': 23976,
},
DefaultPricing: {
'1': 1299,
'12': 13188,
'24': 23976,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 1299,
},
[PLANS.FAMILY]: {
ID: 'UOZXnOXW6gC7xjRiJC14rn0UazL4M7wuHDdMILF1H6xnTW41x2ka_MY4XikenQOyBAk4r6ra5jfPzs2FybDKTg==',
Type: 1,
Name: PLANS.FAMILY,
Title: 'Proton Family',
MaxDomains: 3,
MaxAddresses: 90,
MaxCalendars: 150,
MaxSpace: 3298534883328,
MaxMembers: 6,
MaxVPN: 60,
MaxTier: 2,
Services: 15,
Features: 1,
State: 1,
Pricing: {
'1': 2999,
'12': 28788,
'24': 47976,
},
DefaultPricing: {
'1': 2999,
'12': 28788,
'24': 47976,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 2999,
},
[PLANS.VPN_PRO]: {
ID: 'AzampIHTO3xrN5LwsFXdd4fNyasQ4pojbycVaupg7I2pKhr5pzwQGxuFUgTF_fvUZiNZ_tVjjeCs8_DnOfADYQ==',
Type: 1,
Name: PLANS.VPN_PRO,
Title: 'VPN Essentials',
MaxDomains: 0,
MaxAddresses: 2,
MaxCalendars: 0,
MaxSpace: 0,
MaxMembers: 2,
MaxVPN: 20,
MaxTier: 2,
Services: 4,
Features: 0,
State: 1,
Pricing: {
'1': 1798,
'12': 16776,
'24': 28752,
},
DefaultPricing: {
'1': 1798,
'12': 16776,
'24': 28752,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 1798,
},
[ADDON_NAMES.MEMBER_VPN_PRO]: {
ID: 'XPnq2M_XbuLj7ct30C-hy0AwvPSjV_uMmbzrNeNRLQ63L8lOU7oSO1fRbjZhn0x4GFfypOHwInBKGFkS90AUKQ==',
Type: 0,
Name: ADDON_NAMES.MEMBER_VPN_PRO,
Title: '+1 User',
MaxDomains: 0,
MaxAddresses: 1,
MaxCalendars: 0,
MaxSpace: 0,
MaxMembers: 1,
MaxVPN: 10,
MaxTier: 2,
Services: 4,
Features: 0,
State: 1,
Pricing: {
'1': 898,
'12': 8388,
'24': 14376,
},
DefaultPricing: {
'1': 898,
'12': 8388,
'24': 14376,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 898,
},
[PLANS.VPN_BUSINESS]: {
ID: 'Br7AescivJNN22BCAqgq1aDCH0gvGXseztEeC2wurDH43gNMNfu77T3Y-kVZdp9wQH8r5nmycmQXLhBlh_gv9g==',
Type: 1,
Name: PLANS.VPN_BUSINESS,
Title: 'VPN Business',
MaxDomains: 0,
MaxAddresses: 2,
MaxCalendars: 0,
MaxSpace: 0,
MaxMembers: 2,
MaxVPN: 20,
MaxTier: 2,
Services: 4,
Features: 0,
State: 1,
Pricing: {
'1': 7397,
'12': 71964,
'24': 129528,
},
DefaultPricing: {
'1': 7397,
'12': 71964,
'24': 129528,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 7397,
},
[ADDON_NAMES.MEMBER_VPN_BUSINESS]: {
ID: '2XuG4XQN__aa3uie3ijJ1xVPs9vJP_9TJdY34ky3hJHsMajkQshefL7AXOfW1Z5_wV-GQ3fCg9lCskuJ92wHKg==',
Type: 0,
Name: ADDON_NAMES.MEMBER_VPN_BUSINESS,
Title: '+1 User',
MaxDomains: 0,
MaxAddresses: 1,
MaxCalendars: 0,
MaxSpace: 0,
MaxMembers: 1,
MaxVPN: 10,
MaxTier: 2,
Services: 4,
Features: 0,
State: 1,
Pricing: {
'1': 1199,
'12': 11988,
'24': 21576,
},
DefaultPricing: {
'1': 1199,
'12': 11988,
'24': 21576,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 1199,
},
[ADDON_NAMES.IP_VPN_BUSINESS]: {
ID: '3pf-EZUUjPtbBvBREF0TOxA4Cq6lYozP7fyUhCa0NnU3Im_QCoihoHN1vJKFWd7_hOx1lR35tAG3C8NjPr70RQ==',
Type: 0,
Name: ADDON_NAMES.IP_VPN_BUSINESS,
Title: '+1 Ip',
MaxDomains: 0,
MaxAddresses: 0,
MaxCalendars: 0,
MaxSpace: 0,
MaxMembers: 0,
MaxVPN: 0,
MaxTier: 2,
Services: 4,
Features: 0,
State: 1,
Pricing: {
'1': 4999,
'12': 47988,
'24': 86376,
},
DefaultPricing: {
'1': 4999,
'12': 47988,
'24': 86376,
},
Currency: 'CHF',
Quantity: 1,
Offers: [],
Cycle: 1,
Amount: 4999,
},
};
| 9,545 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/data | petrpan-code/ProtonMail/WebClients/packages/testing/data/payments/data-subscription.ts | import { CYCLE, PLANS, PLAN_TYPES } from '@proton/shared/lib/constants';
import { External, Renew, Subscription, SubscriptionModel } from '@proton/shared/lib/interfaces';
export const subscriptionMock: SubscriptionModel = {
ID: 'subscriptionId123',
InvoiceID: 'invoiceId123',
Cycle: CYCLE.YEARLY,
PeriodStart: 1685966060,
PeriodEnd: 1717588460,
CreateTime: 1685966060,
CouponCode: null,
Currency: 'EUR',
Amount: 11988,
Discount: 0,
RenewAmount: 11988,
Renew: Renew.Enabled,
External: External.Default,
Plans: [
{
ID: 'planId123',
Name: PLANS.BUNDLE,
Type: PLAN_TYPES.PLAN,
Title: 'Proton Unlimited',
MaxDomains: 3,
MaxAddresses: 15,
MaxCalendars: 25,
MaxSpace: 536870912000,
MaxMembers: 1,
MaxVPN: 10,
MaxTier: 2,
Services: 15,
Features: 1,
State: 1,
Cycle: 12,
Currency: 'EUR',
Amount: 11988,
Quantity: 1,
Pricing: {
'1': 1299,
'12': 11988,
'24': 19176,
},
Offers: [],
},
],
isManagedByMozilla: false,
};
export const upcomingSubscriptionMock: Subscription = {
ID: 'subscriptionId124',
InvoiceID: 'invoiceId124',
Cycle: CYCLE.TWO_YEARS,
PeriodStart: 1717588460,
PeriodEnd: 1780660460,
CreateTime: 1685966060,
CouponCode: null,
Currency: 'EUR',
Amount: 19176,
Discount: 0,
RenewAmount: 19176,
Renew: Renew.Enabled,
External: External.Default,
Plans: [
{
ID: 'planId123',
Name: PLANS.BUNDLE,
Type: PLAN_TYPES.PLAN,
Title: 'Proton Unlimited',
MaxDomains: 3,
MaxAddresses: 15,
MaxCalendars: 25,
MaxSpace: 536870912000,
MaxMembers: 1,
MaxVPN: 10,
MaxTier: 2,
Services: 15,
Features: 1,
State: 1,
Cycle: 12,
Currency: 'EUR',
Amount: 11988,
Quantity: 1,
Pricing: {
'1': 1299,
'12': 11988,
'24': 19176,
},
Offers: [],
},
],
};
| 9,546 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/data | petrpan-code/ProtonMail/WebClients/packages/testing/data/payments/index.ts | export * from './data-plans';
export * from './data-subscription';
| 9,547 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/api.ts | import noop from '@proton/utils/noop';
type HttpMethod = 'get' | 'post' | 'put' | 'delete';
type ApiMockHandler = (...arg: any[]) => any;
type ApiMockEntry = {
method?: HttpMethod;
handler: (...arg: any[]) => any;
};
type ApiMock = { [url: string]: ApiMockEntry[] | undefined };
export const apiMocksMap: ApiMock = {};
let logging = false;
export const enableMockApiLogging = () => (logging = true);
export const disableMockApiLogging = () => (logging = false);
export const apiMock = jest.fn<Promise<any>, any>(async (args: any) => {
const entryKey = Object.keys(apiMocksMap).find((path) => {
return args.url === path;
});
const entry = apiMocksMap[entryKey || '']?.find(
(entry) => entry.method === undefined || entry.method === args.method
);
if (entry) {
if (logging) {
console.log('apiMock', args);
console.log('apiMock entry', entry);
}
const result = entry.handler({ ...args });
if (logging) {
console.log('apiMock result', result);
}
return result;
}
return {};
});
export const addApiMock = (url: string, handler: ApiMockHandler, method?: HttpMethod) => {
const newEntry = { method, handler };
if (!apiMocksMap[url]) {
apiMocksMap[url] = [newEntry];
} else {
apiMocksMap[url] = apiMocksMap[url]?.filter((entry) => entry.method !== newEntry.method).concat([newEntry]);
}
};
export const addApiResolver = (url: string, method?: HttpMethod) => {
let resolveLastPromise: (result: any) => void = noop;
let rejectLastPromise: (result: any) => void = noop;
const resolve = (value: any) => resolveLastPromise(value);
const reject = (value: any) => rejectLastPromise(value);
const promise = new Promise((resolve, reject) => {
resolveLastPromise = resolve;
rejectLastPromise = reject;
});
addApiMock(url, () => promise, method);
return { resolve, reject };
};
export const clearApiMocks = () => {
Object.keys(apiMocksMap).forEach((key) => delete apiMocksMap[key]);
};
| 9,548 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/builders.ts | import { build } from '@jackfranklin/test-data-bot';
import { CALENDAR_DISPLAY, CALENDAR_FLAGS, CALENDAR_TYPE } from '@proton/shared/lib/calendar/constants';
import { MEMBER_PERMISSIONS } from '@proton/shared/lib/calendar/permissions';
import { ADDRESS_TYPE } from '@proton/shared/lib/constants';
import { Address, AddressKey } from '@proton/shared/lib/interfaces';
import {
CALENDAR_SUBSCRIPTION_STATUS,
CalendarEvent,
VcalVeventComponent,
VisualCalendar,
} from '@proton/shared/lib/interfaces/calendar';
import { Message } from '@proton/shared/lib/interfaces/mail/Message';
export const messageBuilder = build<Pick<Message, 'ID' | 'ParsedHeaders'>>('Message', {
fields: {
ID: 'FbqL-2iaaLZnVB8oF3PI5hUQW6nbggQ_tg7n0xZlhAw59jy7WXaZbMh51ESNQY16Tq0OKxHu4PvKlux2sXAU8w==',
ParsedHeaders: {
To: '[email protected]',
From: 'ProtonCalendar <[email protected]>',
Date: 'Thu, 25 Nov 2021 16:16:15 +0000',
Subject: 'Reminder: event starting at 6:00 PM (GMT+1) on Thursday, November 25',
'X-Auto-Response-Suppress': 'OOF',
Precedence: 'bulk',
'Auto-Submitted': 'auto-generated',
References:
'<jWX4uC1V6Nib4EHf19aHN3bC7K5HRChaFBzBZSOrCkE7Dlx0LX0tQqw89Stl45PZXvpJ5hH_BUcpB_Ms3UUIeQ==@calendar.proton.me>',
'X-Pm-Calendar-Eventid':
'jWX4uC1V6Nib4EHf19aHN3bC7K5HRChaFBzBZSOrCkE7Dlx0LX0tQqw89Stl45PZXvpJ5hH_BUcpB_Ms3UUIeQ==',
'X-Pm-Calendar-Calendarid':
'8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
'X-Pm-Calendar-Occurrence': '1637859600',
'X-Pm-Calendar-Sequence': '0',
'X-Pm-Calendar-Eventuid': '[email protected]',
'X-Pm-Calendar-Eventisrecurring': '0',
'Message-Id': '<[email protected]>',
'X-Pm-Origin': 'internal',
'X-Pm-Content-Encryption': 'end-to-end',
'X-Pm-Spamscore': '0',
Received: 'from mailmx.proton.black by mailmx.proton.black; Thu, 25 Nov 2021 16:16:36 +0000',
'X-Original-To': '[email protected]',
'Return-Path': '<[email protected]>',
'Delivered-To': '[email protected]',
'Mime-Version': '1.0',
'Content-Type': 'text/html',
'X-Attached': 'protoncalendar.png',
},
},
});
const testEmail = '[email protected]';
const testAdddressId = 'Lw5suur9q0eTrcp-ufF41Ar7WNj5FQQFz_iKVcCD8khv0eVLJ8MPyx9oiI1XfZJ3JVuTmpG2dgOIY2zCCrIVIw==';
const testCalendarId = '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==';
export const calendarBuilder = build<VisualCalendar>('Calendar', {
fields: {
ID: testCalendarId,
Name: 'My calendar',
Description: '',
Type: 0,
Flags: CALENDAR_FLAGS.ACTIVE,
Email: testEmail,
Color: '#F00',
Display: 1,
Permissions: 127,
Owner: { Email: testEmail },
Priority: 1,
Members: [
{
ID: 'otkpEZzG--8dMXvwyLXLQWB72hhBhNGzINjH14rUDfywvOyeN01cDxDrS3Koifxf6asA7Xcwtldm0r_MCmWiAQ==',
Email: testEmail,
Permissions: 127,
AddressID: testAdddressId,
Flags: CALENDAR_FLAGS.ACTIVE,
Color: '#F00',
Display: 1,
CalendarID: testCalendarId,
Name: 'My calendar',
Description: '',
Priority: 1,
},
],
},
traits: {
resetNeeded: {
overrides: {
Members: [
{
ID: 'otkpEZzG--8dMXvwyLXLQWB72hhBhNGzINjH14rUDfywvOyeN01cDxDrS3Koifxf6asA7Xcwtldm0r_MCmWiAQ==',
Email: testEmail,
Permissions: 127,
AddressID: testAdddressId,
Flags: CALENDAR_FLAGS.RESET_NEEDED,
Color: '#F00',
Display: 1,
CalendarID: testCalendarId,
Name: 'My calendar',
Description: '',
Priority: 1,
},
],
},
},
updatePassphrase: {
overrides: {
Members: [
{
ID: 'otkpEZzG--8dMXvwyLXLQWB72hhBhNGzINjH14rUDfywvOyeN01cDxDrS3Koifxf6asA7Xcwtldm0r_MCmWiAQ==',
Email: testEmail,
Permissions: 127,
AddressID: testAdddressId,
Flags: CALENDAR_FLAGS.UPDATE_PASSPHRASE,
Color: '#F00',
Display: 1,
CalendarID: testCalendarId,
Name: 'My calendar',
Description: '',
Priority: 1,
},
],
},
},
},
});
export const addressKeyBuilder = build<AddressKey>('AddressKey', {
fields: {
ID: 'oAwF7m8z5CksIPpX9fzAGp6hvyy0zPV0XnDWkdq-OcPyBmVygc7cyK-JFgr_HVkOc4B48BM-RSNILvPDZyfOGA==',
Flags: 3,
Primary: 1,
Fingerprint: 'dbae8b8bb94db1b8cce9d7d2d683831eeedb3e32',
Fingerprints: ['1be0b1b19ca7cc803eba2234725c5400df3b966b', 'dbae8b8bb94db1b8cce9d7d2d683831eeedb3e32'],
PublicKey:
'-----BEGIN PGP PUBLIC KEY BLOCK-----\\nVersion: ProtonMail\\n\\nxjMEYZYvQxYJKwYBBAHaRw8BAQdA7QXbKv40LALRWxAhKs5qdXCugnfV+ltz\\ndRMIzvLza/XNKXN0ZXN0MUBwcm90b24uYmxhY2sgPHN0ZXN0MUBwcm90b24u\\nYmxhY2s+wo8EEBYKACAFAmGWL0MGCwkHCAMCBBUICgIEFgIBAAIZAQIbAwIe\\nAQAhCRDWg4Me7ts+MhYhBNuui4u5TbG4zOnX0taDgx7u2z4yPJYA/ihS6mAn\\ndgU9SWuT2eQdpHzjS2aFM++3ORBqbmlUMJ2TAP9BK/ShGaU1xQT7oW4r1IwJ\\nwh6GPVoI9l/dDluwAsgbDM44BGGWL0MSCisGAQQBl1UBBQEBB0BHSIm4e1GL\\ndcT1fSo1xyPDskA8DQ3xzgECfLiGB0G/ZwMBCAfCeAQYFggACQUCYZYvQwIb\\nDAAhCRDWg4Me7ts+MhYhBNuui4u5TbG4zOnX0taDgx7u2z4yvkEBAMUxhmbz\\n/iKUMCB1dZWWYgXxXubgRXVE6KUB14tbQS+IAP98S0YWeQgOXG5tRzOgxpZL\\n9hyxyxotRbZCxiMfLIJeBw==\\n=LacE\\n-----END PGP PUBLIC KEY BLOCK-----\\n',
PrivateKey:
'-----BEGIN PGP PRIVATE KEY BLOCK-----\\nVersion: ProtonMail\\n\\nxYYEYZYvQxYJKwYBBAHaRw8BAQdA7QXbKv40LALRWxAhKs5qdXCugnfV+ltz\\ndRMIzvLza/X+CQMI91KskzNcMxhgYjWul/wQozuyfoGySCt3I81VyUgQn2qd\\nwRtolOfoecu6KeOm+62vHBxwUDqeU0RQ3d40gEdf/iqQqSB8PCLSRoU8i4zP\\nhM0pc3Rlc3QxQHByb3Rvbi5ibGFjayA8c3Rlc3QxQHByb3Rvbi5ibGFjaz7C\\njwQQFgoAIAUCYZYvQwYLCQcIAwIEFQgKAgQWAgEAAhkBAhsDAh4BACEJENaD\\ngx7u2z4yFiEE266Li7lNsbjM6dfS1oODHu7bPjI8lgD+KFLqYCd2BT1Ja5PZ\\n5B2kfONLZoUz77c5EGpuaVQwnZMA/0Er9KEZpTXFBPuhbivUjAnCHoY9Wgj2\\nX90OW7ACyBsMx4sEYZYvQxIKKwYBBAGXVQEFAQEHQEdIibh7UYt1xPV9KjXH\\nI8OyQDwNDfHOAQJ8uIYHQb9nAwEIB/4JAwgS0zzsR9GuWWApVtJXYfWFaVy+\\nWv8RtclDDWvYCXm7U6t9Z4X74cYVJdCxxieoOqOs9xiZuWbGUVaj10z2o5WP\\nqp5tfpPMwxgBNNbX7CASwngEGBYIAAkFAmGWL0MCGwwAIQkQ1oODHu7bPjIW\\nIQTbrouLuU2xuMzp19LWg4Me7ts+Mr5BAQDFMYZm8/4ilDAgdXWVlmIF8V7m\\n4EV1ROilAdeLW0EviAD/fEtGFnkIDlxubUczoMaWS/YcscsaLUW2QsYjHyyC\\nXgc=\\n=wxep\\n-----END PGP PRIVATE KEY BLOCK-----\\n',
Signature:
'-----BEGIN PGP SIGNATURE-----\\nVersion: ProtonMail\\n\\nwnUEARYKAAYFAmGWL38AIQkQmMokddP43uoWIQSeQbXypkkMBCLPiL+YyiR1\\n0/je6t0xAPsE4JQeK2gIug3FLP/FGERdmwcscuZNgaoCpUqQupp5eAD/QtOs\\nBF243mQGEbji7T8cq/E5AP7a/nNa4uWvNPAI/gk=\\n=Icvl\\n-----END PGP SIGNATURE-----\\n',
Token: '-----BEGIN PGP MESSAGE-----\\nVersion: ProtonMail\\n\\nwV4Dq7i1ziRJQLUSAQdAe+uk39M57AL4pw8jNszfIQ9iOIrYD0qROCVBsttu\\naR8wZ2NmkCujcl4ruaPEDp4cOEE/CAh1aU49zsXVkG/mv5+fd+Y7RWUqoNjI\\n/Y+mUyhM0ngBHu51pNAOaOVphTTZXlCkJmhM2wdggQaIbR6yR4KcFyvycgHj\\nFqdgJKhEwocDW9AtLxcbcPWYXQucB5Gfa4omMS966uKigF5EfeDimK+sQ7mF\\nL3/XKOvRy7axwptQDdGN1/MeloLEQIUdeo+n8FF5IOCZ+7N/YMg=\\n=0UNR\\n-----END PGP MESSAGE-----\\n',
RecoverySecret: null,
RecoverySecretSignature: null,
Active: 1,
Version: 3,
AddressForwardingID: null,
},
});
export const addressBuilder = build<Address>('Address', {
fields: {
CatchAll: false,
ID: testAdddressId,
DomainID: 'l8vWAXHBQmv0u7OVtPbcqMa4iwQaBqowINSQjPrxAr-Da8fVPKUkUcqAq30_BCxj1X0nW70HQRmAa-rIvzmKUA==',
DisplayName: testEmail,
Email: testEmail,
Keys: [],
HasKeys: 1,
SignedKeyList: {
MinEpochID: null,
MaxEpochID: null,
Data: '[{"Primary":1,"Flags":3,"Fingerprint":"dbae8b8bb94db1b8cce9d7d2d683831eeedb3e32","SHA256Fingerprints":["41964058156a2d90c1f0e65a38f5752fb2921b9666ea3b17f781787b6ef55f8f","d82271d5deec94e65862ca759f3c24a263512f00bf67864cac71c8b14f0dc744"]}]',
Signature:
'-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGWL38AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+MmKdAQDGpH8FevWQE32waPgqx+1EqjGmEdywZdZkilUEwb0VswEAgdrS\r\noustAwFTu4E5PubZz7H7tN0SqM9p5GiKSYJSCQg=\r\n=gK8A\r\n-----END PGP SIGNATURE-----\r\n',
},
Order: 1,
Priority: 1,
Receive: 1,
Send: 1,
Signature: '',
Status: 1,
Type: ADDRESS_TYPE.TYPE_ORIGINAL,
ProtonMX: true,
ConfirmationState: 1,
},
postBuild: (address) => {
address.Keys = [addressKeyBuilder()];
return address;
},
});
export const calendarEventBuilder = build<CalendarEvent>('Event', {
fields: {
IsProtonProtonInvite: 0,
// LastEditTime: 1637857503,
// LastEditTime: 1637857503,
Author: '[email protected]',
Permissions: 1,
SharedKeyPacket:
'wV4Dg2X1eF86wkcSAQdADLyc34k1EjC67CQo4M2OuhmX+YwNKQhbk6bz2ow31kgw2oiUfClVOBP5sYPcIJ+aD1B9JrTrDP5gY/BUiXKMPpEbaZpp+5DKBKIpdLheM5cJ',
SharedEvents: [
{
Type: 2,
Data: 'BEGIN:VCALENDAR\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nUID:[email protected]\r\nDTSTAMP:20211125T162445Z\r\nDTSTART;TZID=Europe/Zurich:20211125T180000\r\nDTEND;TZID=Europe/Zurich:20211125T193000\r\nORGANIZER;[email protected]:mailto:[email protected]\r\nSEQUENCE:0\r\nEND:VEVENT\r\nEND:VCALENDAR',
Signature:
'-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGfuN0AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+MpTvAP41Z15ymzb+mGakFzAMui23FzRSF0gNHEqRgPGYDNTsXQD9Hrh+\r\nNC4mIQG3mhgx5gKzDSR7yRv7shr9TPVZUe/GuAA=\r\n=yrvm\r\n-----END PGP SIGNATURE-----\r\n',
Author: '[email protected]',
},
{
Type: 3,
Data: '0sBOAVp6l7BAqo8QhcuhlZIrWPYtPYWub5bFf+FTQc6sqz0EtozOUpO4+Ki/3S5YID5xhCkj/TyjA3CP+1TIs5giO2yvRD6GZ/TLPa9XXKmVWBYA+Y+otvAbT0sOudh7T3e2jdhQFcdUHYWoskF5nltoX54AdZuqijT/CBlmfwkIlu9Nv8S/ovW3Wna9BqhYE+XFV9F4ILEz+WicixqbUtsQR8IO1y0wwD9LC7fy07Nd96ym5XB7lEc5d1NfhXiB+dJQ1TXSHcMbgHkt4upOESFGHpXzOKjKDYji75IqzTWErcAgvCHz8aRrYSmaQ2Iz0PtOh83zfNoWwRzj0+OpFLF1EOywrloQdrqmAQ1V2sYo',
Signature:
'-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGfuN0AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+Mt7nAQCGtqatUfwfDhYOCFVu3DEYtEtJBsPG1kSGibzBit3++wD/Vgz8\r\n+Oh4n5pCt1lKVXArEWcGP5LESUAfvtoV4zdevgA=\r\n=4wfE\r\n-----END PGP SIGNATURE-----\r\n',
Author: '[email protected]',
},
],
CalendarKeyPacket: null,
AddressKeyPacket: null,
AddressID: null,
CalendarEvents: [
{
Type: 2,
Data: 'BEGIN:VCALENDAR\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nUID:[email protected]\r\nDTSTAMP:20211125T162445Z\r\nSTATUS:CONFIRMED\r\nEND:VEVENT\r\nEND:VCALENDAR',
Signature:
'-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGfuN0AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+Mi8UAQC4VMeBVVzERqdjviLIQHoqQFrRK569/uqokDCBXuZmYwEA6oNl\r\nX3laSh9+ZYhjWZ+KMydEBDQzsuT9+l7bDqJi4AA=\r\n=4H4p\r\n-----END PGP SIGNATURE-----\r\n',
Author: '[email protected]',
},
],
ID: 'jWX4uC1V6Nib4EHf19aHN3bC7K5HRChaFBzBZSOrCkE7Dlx0LX0tQqw89Stl45PZXvpJ5hH_BUcpB_Ms3UUIeQ==',
CalendarID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
SharedEventID:
'3YnKxnpRu1eDKP2_WkwZF54MlQSYHvl1FZKFgeiHrjaa4ff60s0yTYlXBMaUUApx1wxaRStoe-c-07JmOp8giBLZe_byc8u_dCWjQGf1zxw=',
StartTime: 1637859600,
StartTimezone: 'Europe/Zurich',
EndTime: 1637865000,
EndTimezone: 'Europe/Zurich',
FullDay: 0,
UID: '[email protected]',
RecurrenceID: null,
Exdates: [],
RRule: null,
CreateTime: 1637855813,
ModifyTime: 1637857503,
IsOrganizer: 1,
Notifications: null,
AttendeesEvents: [
{
Type: 3,
Data: '0sEYAYJHqp1jBcWK88Dyn7KmmqYv87UfmOj0bFafht64OeqBKwHWbhNbjo8lRWg5st3hDXEiamCe2d2BfoNhU/EF9UEEb+8jfsvbNAgtYgZYwR29jK2viqw1VY6lZPBVERhXl8enicmMfEOUkOwwZjyOSEHeLMJd9paeba5VoHHRD2d4HApQnWx40FG1E91jbJXm/oCZRaObmb7UC8lXET4J2n/+Gk9NQz5azEWZ8AImVkLmrOKtOeWRVYaV+YFoVMn5hEAhYMSJ8rSjU3cOTk0ve9ALr0hWTnUhbs5yAvnvmWI270y3ipXbO56BGD/oKNogErgPEcCwY97Z1+zKKXEvNCK49Bvo3ltm+cszJAfUJNisdGZTkWT/Jl2BfvXm/bYFs+9p+WTFIGwMNk3K6YV5/65qz7VCElx940nsLfpyPBUT/GONRuYFdxyjpyKxNk65QH4dMfjBK2+y9F6mJ7Cn4iRVGLWBMMMC+yKdJA5fGaFAmoJprtWRjA8hwnjneBsZ98ZZqVClOw/8o2HOjdBjgf/0XmUnxGRc1eIkpo3tWiKdNzXGW7d3C7W4Rs/ludBb2BFnzzoMbY4saPJ2GobKXR1fSRvdtlX3dGgDHcsy5YQ2jroFD9lsIw==',
Signature:
'-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGfuN0AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+MrCDAP9WYG5b/GBu0mxUuOUViDU3YadrEBpi8Zu+jO9wlMTvbwD/W/68\r\n4Tod7E68Q9DIHInPb8bBJXDizBeo6Lbp8dVXfgM=\r\n=frBC\r\n-----END PGP SIGNATURE-----\r\n',
Author: '[email protected]',
},
],
Attendees: [
{
ID: 'Proye_ciptkeikxsRdv3sVlYdqVXqRAJOfIjn_Bcug_9PaEDxga9-gHHa0Bkds25K3GBt50C4gJNsNexeirkrg==',
Token: '3c5c89a60b8e36ff0b4b1399152b0551c73e373f',
Status: 0,
UpdateTime: null,
},
{
ID: '_rJk4ub7qapyIkWd-d3EwIbJ7svqscEuq_HfWM_E6oBHEQAIKFFpx-89fW27J8waIU39_hcJQ34yM4p9GlYChQ==',
Token: '5578255a302f0938e7f5628487a06ed0fd0f5c8c',
Status: 0,
UpdateTime: null,
},
],
},
traits: {
canceled: {
overrides: {
CalendarEvents: [
{
Type: 2,
Data: 'BEGIN:VCALENDAR\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nUID:[email protected]\r\nDTSTAMP:20211125T162445Z\r\nSTATUS:CANCELLED\r\nEND:VEVENT\r\nEND:VCALENDAR',
Signature:
'-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGfuN0AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+Mi8UAQC4VMeBVVzERqdjviLIQHoqQFrRK569/uqokDCBXuZmYwEA6oNl\r\nX3laSh9+ZYhjWZ+KMydEBDQzsuT9+l7bDqJi4AA=\r\n=4H4p\r\n-----END PGP SIGNATURE-----\r\n',
Author: '[email protected]',
},
],
},
},
},
});
export const veventBuilder = build<VcalVeventComponent>('vevent', {
fields: {
component: 'vevent',
uid: {
value: '[email protected]',
},
dtstamp: {
value: {
year: 2021,
month: 11,
day: 25,
hours: 16,
minutes: 24,
seconds: 45,
isUTC: true,
},
},
dtstart: {
value: {
year: 2021,
month: 11,
day: 25,
hours: 18,
minutes: 0,
seconds: 0,
isUTC: false,
},
parameters: {
tzid: 'Europe/Zurich',
},
},
dtend: {
value: {
year: 2021,
month: 11,
day: 25,
hours: 19,
minutes: 30,
seconds: 0,
isUTC: false,
},
parameters: {
tzid: 'Europe/Zurich',
},
},
organizer: {
value: 'mailto:[email protected]',
parameters: {
cn: '[email protected]',
},
},
sequence: {
value: 0,
},
description: {
value: 'Test description',
},
summary: {
value: 'Test event',
},
location: {
value: 'Test location',
},
status: {
value: 'CONFIRMED',
},
attendee: [
{
value: 'mailto:[email protected]',
parameters: {
cn: '[email protected]',
role: 'REQ-PARTICIPANT',
rsvp: 'TRUE',
'x-pm-token': '3c5c89a60b8e36ff0b4b1399152b0551c73e373f',
partstat: 'NEEDS-ACTION',
},
},
{
value: 'mailto:[email protected]',
parameters: {
cn: '[email protected]',
role: 'REQ-PARTICIPANT',
rsvp: 'TRUE',
'x-pm-token': '5578255a302f0938e7f5628487a06ed0fd0f5c8c',
partstat: 'NEEDS-ACTION',
},
},
],
},
});
export const userBuilder = build('User', {
fields: {
ID: 'XTMQTRBEv-QushjfD5ST-YBFsGCWD-XwuRWoyqgWvPVQj5KcKQRy207GIwLK-DvBrRL-PAiIpp4XKoznVXq-HA==',
Subscribed: 0, // 5 is visionary
Name: 'stest1',
UsedSpace: 729514,
Currency: 'EUR',
Credit: 0,
MaxSpace: 21474836480,
MaxUpload: 26214400,
Services: 5,
DriveEarlyAccess: 1,
MnemonicStatus: 1,
Role: 2,
Private: 1,
Delinquent: 0,
Keys: [
{
ID: 'G069KcZLuBEqitlJvsNsldLWx4kR4HAMwkjLp8w7-VcjWpI0pKExAm0QwalWsoUGKoHrOp5lQSqDYi8nYzKZZA==',
Version: 3,
Primary: 1,
RecoverySecret: null,
RecoverySecretSignature: null,
PrivateKey:
'-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: ProtonMail\n\nxYYEYZYvQxYJKwYBBAHaRw8BAQdAOAQ0qa66bef6/Q1ENhnWb30cdu9cQoeE\n2Jz4W0pg+ZH+CQMIaWXFbP4Z79Jgqd49X0YbF48Qb8Lz02/tTi2uhyssMmUx\n+SiMf57ROgKif7MVHtSDDhggzPVzvIiO6bZFNBKzPSsxAnfwyBrEdakBZ2jf\n5807bm90X2Zvcl9lbWFpbF91c2VAZG9tYWluLnRsZCA8bm90X2Zvcl9lbWFp\nbF91c2VAZG9tYWluLnRsZD7CjwQQFgoAIAUCYZYvQwYLCQcIAwIEFQgKAgQW\nAgEAAhkBAhsDAh4BACEJEJjKJHXT+N7qFiEEnkG18qZJDAQiz4i/mMokddP4\n3urgQgD+LI33CnxtImG5itTEdXHAS3E+oQkTv0eRv0GKvUTff1wA/isu2UKO\n0oagG/4ZaydLEKnh65sC03KSKy/WDnEpPEAMx4sEYZYvQxIKKwYBBAGXVQEF\nAQEHQGdDIKW1oEv2p4wvBEfkibOD1Ey03uecLDFWZ2Nb5g4zAwEIB/4JAwg2\nupFO+VHAx2CGNlWxM7g+KRr0zb1bFDZnGdVNE/AxJvzZUOuRA5rjGJxM6vac\nFOpH6fL4zNm+BJsu54OiVvxNfVAjyPSmrCk5JbDOGif4wngEGBYIAAkFAmGW\nL0MCGwwAIQkQmMokddP43uoWIQSeQbXypkkMBCLPiL+YyiR10/je6tSoAQDx\ndRTZmvcbkKe6k+F+EOa/Tmp/lARzEYMmWpnQcmI9cQD6AhgeFjDh+r+XY+q1\nZ2fGhDHqYiLQd0s+LmRzq8Tnfwo=\n=y2fV\n-----END PGP PRIVATE KEY BLOCK-----\n',
Fingerprint: '9e41b5f2a6490c0422cf88bf98ca2475d3f8deea',
Active: 1,
},
],
ToMigrate: 0,
Email: '[email protected]',
DisplayName: 'Bad Boy',
},
});
interface GenerateSimpleCalendarCustomParams {
id?: string;
name?: string;
calendarEmail?: string;
ownerEmail?: string;
permissions?: number;
type?: CALENDAR_TYPE;
flags?: CALENDAR_FLAGS;
display?: CALENDAR_DISPLAY;
color?: string;
}
export const generateSimpleCalendar = (
i: number,
{
id = `id-${i}`,
name = `name-${i}`,
calendarEmail = 'calendarEmail',
ownerEmail = 'calendarEmail',
permissions = MEMBER_PERMISSIONS.OWNS,
type = CALENDAR_TYPE.PERSONAL,
flags = CALENDAR_FLAGS.ACTIVE,
display = CALENDAR_DISPLAY.VISIBLE,
color = '#F00',
}: GenerateSimpleCalendarCustomParams
): VisualCalendar => ({
ID: id,
Name: name,
Description: `description-${i}`,
Type: type,
Flags: flags,
Email: calendarEmail,
Color: color,
Display: display,
Permissions: permissions,
Priority: 1,
Owner: { Email: ownerEmail },
Members: [
{
ID: `member-${i}`,
Email: calendarEmail,
Permissions: permissions,
AddressID: `address-id-${i}`,
Flags: flags,
Color: color,
Display: display,
CalendarID: `id-${i}`,
Name: `name-${i}`,
Description: `description-${i}`,
Priority: 1,
},
],
});
export const generateTestAddress = (compelled?: Partial<Address>): Address => {
return {
ID: 'fHR97Meg0sNme5k8IFa2umNtk5FjTUA7FbImbZj7RIO3U5hMmGk8_NF6a7qgSZ2QviSQmEg7Qib9xfLEdjCdXA==',
DomainID: 'l8vWAXHBQmv0u7OVtPbcqMa4iwQaBqowINSQjPrxAr-Da8fVPKUkUcqAq30_BCxj1X0nW70HQRmAa-rIvzmKUA==',
Email: '[email protected]',
Status: 1,
Receive: 1,
Send: 1,
DisplayName: 'unlimited',
SignedKeyList: {
ExpectedMinEpochID: 1,
Data: '[{"Primary":1,"Flags":3,"Fingerprint":"c2b4f440b000d4f326a65d70a827bb8b6fa093d9","SHA256Fingerprints":["efaba78a9004f1c01cce6b45f4ccfe1e37651c9067d188b665d8d29186c693b2","439fa8debeff000609b2cf8e316f3637a3fb7479da144b10bb95fe24f64f926d"]}]',
Signature: '-----BEGIN PGP SIGNATURE-----...',
MinEpochID: 0,
MaxEpochID: 0,
},
Keys: [],
HasKeys: 0,
CatchAll: false,
Order: 1,
Priority: 1,
Signature: '-----BEGIN PGP SIGNATURE-----...',
Type: ADDRESS_TYPE.TYPE_ORIGINAL,
ProtonMX: true,
ConfirmationState: 1,
...compelled,
};
};
export const generateSharedCalendar = (i: number, params: GenerateSimpleCalendarCustomParams) => {
const calendar = generateSimpleCalendar(i, params);
if (params.calendarEmail && params.ownerEmail && params.calendarEmail === params.ownerEmail) {
throw new Error('Owner matches calendar email, not a shared calendar!');
}
if (calendar.Email === calendar.Owner.Email) {
calendar.Owner.Email = calendar.Owner.Email === 'calendarEmail' ? 'ownerEmail' : `${calendar.Email}-owner`;
}
return calendar;
};
interface GenerateSubscribedCalendarCustomParams extends GenerateSimpleCalendarCustomParams {
status?: CALENDAR_SUBSCRIPTION_STATUS;
url?: string;
}
export const generateSubscribedCalendar = (
i: number,
{ status = CALENDAR_SUBSCRIPTION_STATUS.OK, url = '#', ...rest }: GenerateSubscribedCalendarCustomParams
) => {
const simpleCalendar = generateSimpleCalendar(i, rest);
const SubscriptionParameters = {
CalendarID: simpleCalendar.ID,
CreateTime: 0,
LastUpdateTime: Math.floor(+Date.now() / 1000),
Status: status,
URL: url,
};
return {
...simpleCalendar,
Type: CALENDAR_TYPE.SUBSCRIPTION,
SubscriptionParameters,
};
};
export const generateHolidaysCalendar = (i: number, params: GenerateSimpleCalendarCustomParams) => {
const simpleCalendar = generateSimpleCalendar(i, params);
return {
...simpleCalendar,
Type: CALENDAR_TYPE.HOLIDAYS,
};
};
export const generateOwnedPersonalCalendars = (n: number, customParams?: GenerateSimpleCalendarCustomParams[]) => {
if (n <= 0) {
return [];
}
return Array(n)
.fill(1)
.map((val, i) => generateSimpleCalendar(i, customParams?.[i] || {}));
};
export const generateSharedCalendars = (n: number, customParams?: GenerateSimpleCalendarCustomParams[]) => {
if (n <= 0) {
return [];
}
return Array(n)
.fill(1)
.map((val, i) => generateSharedCalendar(i, customParams?.[i] || {}));
};
export const generateSubscribedCalendars = (n: number, customParams?: GenerateSubscribedCalendarCustomParams[]) => {
if (n <= 0) {
return [];
}
return Array(n)
.fill(1)
.map((val, i) => generateSubscribedCalendar(i, customParams?.[i] || {}));
};
export const generateHolidaysCalendars = (n: number, customParams?: GenerateSimpleCalendarCustomParams[]) => {
if (n <= 0) {
return [];
}
return Array(n)
.fill(1)
.map((val, i) => generateHolidaysCalendar(i, customParams?.[i] || {}));
};
| 9,549 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/cache.ts | import createCache from '@proton/shared/lib/helpers/cache';
import { STATUS } from '@proton/shared/lib/models/cache';
export interface ResolvedRequest<T> {
status: STATUS;
value: T;
}
export const resolvedRequest = <T>(value: T): ResolvedRequest<T> => ({ status: STATUS.RESOLVED, value });
export const mockCache = createCache();
export const addToCache = (key: string, value: any) => {
mockCache.set(key, resolvedRequest(value));
};
export const clearCache = () => mockCache.clear();
| 9,550 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/event-manager.ts | import { EventManager } from '@proton/shared/lib/eventManager/eventManager';
export const mockEventManager: EventManager = {
call: jest.fn().mockReturnValue(Promise.resolve()),
setEventID: jest.fn(),
getEventID: jest.fn(),
start: jest.fn(),
stop: jest.fn(),
reset: jest.fn(),
subscribe: jest.fn(),
};
| 9,551 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/flush-promises.ts | const scheduler = typeof setImmediate === 'function' ? setImmediate : setTimeout;
export function flushPromises() {
return new Promise(function (resolve) {
scheduler(resolve);
});
}
| 9,552 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/handlers.ts | import { rest } from 'msw';
import { DEFAULT_MAILSETTINGS } from '@proton/shared/lib/mail/mailSettings';
import { addressBuilder, calendarBuilder, calendarEventBuilder, userBuilder } from './builders';
export const handlers = [
rest.get('/addresses', (req, res, ctx) => {
return res(
ctx.json({
Addresses: [addressBuilder()],
Total: 1,
})
);
}),
rest.get(`/calendar/v1/:calendarId/events/:eventId`, (req, res, ctx) => {
return res(
ctx.json({
Event: calendarEventBuilder(),
})
);
}),
rest.get(`/calendar/v1`, (req, res, ctx) => {
return res(
ctx.json({
Calendars: [calendarBuilder()],
})
);
}),
rest.get(`/calendar/v1/events`, (req, res, ctx) => {
return res(
ctx.json({
Events: [],
})
);
}),
rest.get(`/users`, (req, res, ctx) => {
return res(
ctx.json({
User: userBuilder(),
})
);
}),
rest.get(`/settings/calendar`, (req, res, ctx) => {
return res(
ctx.json({
CalendarUserSettings: {
WeekStart: 1,
WeekLength: 0,
DisplayWeekNumber: 1,
DateFormat: 0,
TimeFormat: 0,
AutoDetectPrimaryTimezone: 1,
PrimaryTimezone: 'Europe/Zurich',
DisplaySecondaryTimezone: 0,
SecondaryTimezone: null,
ViewPreference: 1,
DefaultCalendarID:
'8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
ShowCancelled: 1,
ShowDeclined: 1,
AutoImportInvite: 0,
},
})
);
}),
rest.get(`/contacts/v4/contacts/emails`, (req, res, ctx) => {
return res(
ctx.json({
ContactEmails: [],
})
);
}),
rest.get(`/calendar/v1/:calendarId/bootstrap`, (req, res, ctx) => {
return res(
ctx.json({
Keys: [
{
ID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
PrivateKey:
'-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: ProtonMail\n\nxYYEYZYvsxYJKwYBBAHaRw8BAQdA5OCfLNgBD9N1o+rbYZ+T0cebDmXdqID9\nztWaA1Ks6g/+CQMIW87X8JxZQJZgbrTx1CiT3KHTzu6OPHyodLoBFTHsxuUk\nSH/QffB34h5ZcqBwjKXMXAxSUvSYoq3hA3SDpHWiYvpzVrXQGQPn6Z7nCvyu\njM0MQ2FsZW5kYXIga2V5wo8EEBYKACAFAmGWL7MGCwkHCAMCBBUICgIEFgIB\nAAIZAQIbAwIeAQAhCRA5ciVSKZC25RYhBKVX9ChVLEMtyLclAzlyJVIpkLbl\nVB0A/3EAxSlLsbwwcB1FdygYmNpUNcIA1F2a3jq0HFEY1M0dAP0eoUy/wI7G\n9dPWOdfIhsLpS8LZsnnlxXQCevonOi7xAceLBGGWL7MSCisGAQQBl1UBBQEB\nB0AYjNLjQgjzxU8rqfjXfiv/hIDBztnCHIHNC8bhHSMsWwMBCAf+CQMIccKl\n/DITNo5gvvFNaFhF6sKRd5KeOs7BPd/J1FZfmaEK5RF/o524eofdq7I3xp3F\nRTDmQ9XGKe237ixzBuX/Dlmb0BDAIXifTe9F23HQO8J4BBgWCAAJBQJhli+z\nAhsMACEJEDlyJVIpkLblFiEEpVf0KFUsQy3ItyUDOXIlUimQtuX8gQEA4xUQ\n4wbiOtsy+wimRQAzG3W5XWbpxcOdAhNWgen1EFIBANqbYe0rHPzfs6Jya6II\nXLLT5roLSphpuYwODd+GQ3kL\n=YRWm\n-----END PGP PRIVATE KEY BLOCK-----\n',
PassphraseID:
'8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
Flags: 3,
CalendarID:
'8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
},
],
Passphrase: {
Flags: 1,
ID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
MemberPassphrases: [
{
MemberID:
'8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
Passphrase:
'-----BEGIN PGP MESSAGE-----\nVersion: ProtonMail\n\nwV4DclxUAN87lmsSAQdAo9FgKmAgiR5vwuLn1O5Ms1RFNPR9Z3H5UMtk0A7q\nrFUwIIX6blb/51oAAi2T7Arp++gx/S+EUr0T1keB2wYMansZsYclQbXfix6s\nnWrxoejL0mQBV6qx9TtuDAvOFIEy0EXEsY2QKg8QjAsz01siPoYLXOV3xJm6\nwD8U72xxxxvoMtIsx5OmmQYDzqpFTasZCgGJxsCo/y/tI+089KPjjC1YRHKG\ng6uJr+BnQrv7vsi65+AjRgmW\n=znTY\n-----END PGP MESSAGE-----\n',
Signature:
'-----BEGIN PGP SIGNATURE-----\nVersion: ProtonMail\n\nwnUEARYKAAYFAmGWL+8AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\n7ts+MialAQCWwcs4GNahH4ZwGLxoQ5zpFCcieySg9sg1fYoSJXdYLAEApOc2\nxmZLBSMdpd4QrfWp2IhIyro6bO4s6NFRhElLmAw=\n=n64B\n-----END PGP SIGNATURE-----\n',
},
],
CalendarID:
'8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
},
Members: [
{
ID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
Permissions: 127,
Email: '[email protected]',
AddressID:
'Lw5suur9q0eTrcp-ufF41Ar7WNj5FQQFz_iKVcCD8khv0eVLJ8MPyx9oiI1XfZJ3JVuTmpG2dgOIY2zCCrIVIw==',
CalendarID:
'8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
Color: '#5EC7B7',
Display: 1,
},
],
CalendarSettings: {
ID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
CalendarID:
'8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
DefaultEventDuration: 30,
DefaultPartDayNotifications: [
{
Type: 1,
Trigger: '-PT15M',
},
],
DefaultFullDayNotifications: [
{
Type: 1,
Trigger: '-PT15H',
},
],
},
})
);
}),
rest.get(`/mail/v4/settings`, (req, res, ctx) => {
return res(
ctx.json({
MailSettings: DEFAULT_MAILSETTINGS,
})
);
}),
];
| 9,553 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockApiWithServer.ts | import { jest } from '@jest/globals';
import fetch from 'cross-fetch';
function handleResponse(response: Response) {
return response.text().then((text) => {
const data = text && JSON.parse(text);
if (!response.ok) {
const error = (data && data.message) || response.statusText;
return Promise.reject(error);
}
return data;
});
}
export const mockApiWithServer = jest.fn((config: any) => {
const url = new URL(`http://localhost/${config.url}`);
if (config.params) {
url.search = new URLSearchParams(config.params).toString();
}
return fetch(url.toString(), {
method: config.method,
}).then(handleResponse);
});
| 9,554 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockMatchMedia.ts | Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});
| 9,555 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockModals.ts | import { jest } from '@jest/globals';
import useModals from '@proton/components/hooks/useModals';
export const mockModals: ReturnType<typeof useModals> = {
createModal: jest.fn<any>(),
removeModal: jest.fn(),
hideModal: jest.fn(),
getModal: jest.fn<any>(),
modals: [],
};
| 9,556 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockNotifications.ts | import { jest } from '@jest/globals';
import useNotifications from '@proton/components/hooks/useNotifications';
export const mockNotifications: ReturnType<typeof useNotifications> = {
createNotification: jest.fn<any>(),
removeNotification: jest.fn(),
removeDuplicate: jest.fn(),
hideNotification: jest.fn(),
clearNotifications: jest.fn(),
setOffset: jest.fn(),
};
| 9,557 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockRandomValues.ts | type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array;
let original: undefined | typeof crypto.getRandomValues;
/**
* Mock crypto.getRandomValues using the mocked implementation (if given). Otherwise,
* a deterministic function will fill the buffer with consecutive values from 0 up to 254.
*/
export const initRandomMock = <T extends TypedArray>(mockedImplementation?: (buf: T) => T) => {
if (!original) {
original = crypto.getRandomValues;
}
if (mockedImplementation) {
// @ts-ignore DataView not supported
crypto.getRandomValues = mockedImplementation;
} else {
const staticMockRandomValues = (buf: TypedArray) => {
for (let i = 0; i < Math.min(buf.length, 255); ++i) {
// values wrap around automatically based on the provided typed array
buf[i] = i;
}
return buf;
};
// @ts-ignore DataView not supported
crypto.getRandomValues = staticMockRandomValues;
}
};
export const disableRandomMock = () => {
if (!original) {
throw new Error('mock was not initialized');
}
crypto.getRandomValues = original;
original = undefined;
};
| 9,558 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockSpotlight.tsx | import { Children, MouseEventHandler, PropsWithChildren, ReactElement, useEffect } from 'react';
import { SpotlightProps } from '@proton/components/components';
/**
* Raw spotlight used as a mock for testing
*/
export const SpotlightMock = ({ children, show, content, onClose, onDisplayed }: PropsWithChildren<SpotlightProps>) => {
const child = Children.only(children) as ReactElement;
const handleClose: MouseEventHandler = (event) => {
onClose?.(event);
};
useEffect(() => {
if (show) {
onDisplayed?.();
}
}, [show]);
return (
<>
{child}
<div className="spotlight">
<div>{content}</div>
<button title={'Close'} className="spotlight-close" onClick={handleClose}>
{'Close'}
</button>
</div>
</>
);
};
| 9,559 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUnleash.ts | jest.mock('@protontech/proxy-client-react', () => ({
__esModule: true,
useFlag: jest.fn(),
useFlags: () => {},
useFlagsStatus: () => {},
}));
| 9,560 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseActiveBreakpoint.ts | import * as useActiveBreakpointModule from '@proton/components/hooks/useActiveBreakpoint';
export const mockUseActiveBreakpoint = (value?: Partial<ReturnType<typeof useActiveBreakpointModule.default>>) => {
const mockedUseActiveBreakpoint = jest.spyOn(useActiveBreakpointModule, 'default');
const values = {
breakpoint: 'desktop',
isLargeDesktop: true,
isMediumDesktop: false,
isSmallDesktop: false,
isTablet: false,
isMobile: false,
isTinyMobile: false,
...value,
};
mockedUseActiveBreakpoint.mockReturnValue({
...values,
isNarrow: value?.isNarrow ?? (values.isMobile || values.isTinyMobile),
isDesktop: value?.isNarrow ?? (values.isLargeDesktop || values.isMediumDesktop || values.isSmallDesktop),
});
return mockedUseActiveBreakpoint;
};
| 9,561 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseAddresses.ts | import * as useAddressesModule from '@proton/components/hooks/useAddresses';
import { Address } from '@proton/shared/lib/interfaces';
import { buildAddress } from '../builders/address';
export const mockUseAddresses = (value: [Address[]?, boolean?, any?] = []) => {
const [addresses, cached, miss = jest.fn()] = value;
const mockedUseAddress = jest.spyOn(useAddressesModule, 'default');
mockedUseAddress.mockReturnValue([addresses ?? [buildAddress()], Boolean(cached), miss]);
return mockedUseAddress;
};
| 9,562 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseApi.ts | import * as useApiModule from '@proton/components/hooks/useApi';
export const mockUseApi = (value?: ReturnType<typeof useApiModule.default>) => {
const mockedUseApi = jest.spyOn(useApiModule, 'default');
mockedUseApi.mockReturnValue(value ?? jest.fn());
return mockedUseApi;
};
| 9,563 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseConfig.ts | import * as useConfigModule from '@proton/components/hooks/useConfig';
import { APPS, CLIENT_TYPES } from '@proton/shared/lib/constants';
export const mockUseConfig = (value?: Partial<ReturnType<typeof useConfigModule.default>>) => {
const mockedUseConfig = jest.spyOn(useConfigModule, 'default');
mockedUseConfig.mockReturnValue({
CLIENT_TYPE: CLIENT_TYPES.MAIL,
CLIENT_SECRET: '',
APP_VERSION: '0.0.1',
APP_NAME: APPS.PROTONMAIL,
API_URL: 'string',
LOCALES: {},
DATE_VERSION: '',
COMMIT: '',
BRANCH: 'main',
SENTRY_DSN: '',
VERSION_PATH: '',
...value,
});
return mockedUseConfig;
};
| 9,564 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseContactEmailsCache.ts | import * as useContactEmailsCacheModule from '@proton/components/containers/contacts/ContactEmailsProvider';
export const mockUseContactEmailsCache = (
value?: Partial<ReturnType<typeof useContactEmailsCacheModule.useContactEmailsCache>>
) => {
const mockedUseContactEmailsCache = jest.spyOn(useContactEmailsCacheModule, 'useContactEmailsCache');
mockedUseContactEmailsCache.mockReturnValue({
contactEmails: [],
contactGroups: [],
contactEmailsMap: {},
contactEmailsMapWithDuplicates: {},
groupsWithContactsMap: {},
...value,
});
return mockedUseContactEmailsCache;
};
| 9,565 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseEventManager.ts | import * as useEventManagerModule from '@proton/components/hooks/useEventManager';
export const mockUseEventManager = (value?: Partial<ReturnType<typeof useEventManagerModule.default>>) => {
const mockedUseEventManager = jest.spyOn(useEventManagerModule, 'default');
mockedUseEventManager.mockReturnValue({
setEventID: jest.fn(),
getEventID: jest.fn(),
start: jest.fn(),
stop: jest.fn(),
call: jest.fn(),
reset: jest.fn(),
subscribe: jest.fn(),
...value,
});
return mockedUseEventManager;
};
| 9,566 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseFeature.ts | import * as useFeatureModule from '@proton/components/hooks/useFeature';
import { DeepPartial } from '@proton/shared/lib/interfaces';
type HookReturnType = ReturnType<typeof useFeatureModule.default>;
/**
* Basic and raw useFeature mock
*
* Example:
* ```
* const mockedUseFeature = mockUseFeature({ feature: { Value: true } });
* expect(mockedUseFeature.code).toBe('FeatureCode');
* ```
*
* More advanced mocks will be needed in case of components with multiple calls to useFeature
*/
export const mockUseFeature = (value?: DeepPartial<ReturnType<typeof useFeatureModule.default>>) => {
const mockedUseFeature = jest.spyOn(useFeatureModule, 'default');
mockedUseFeature.mockImplementation(
(code) =>
({
feature: {
Type: 'boolean',
DefaultValue: false,
Value: false,
Minimum: 0,
Maximum: 1,
Global: false,
Writable: false,
ExpirationTime: -1,
UpdateTime: -1,
Options: [],
...value?.feature,
Code: code,
},
loading: false,
get: jest.fn(),
update: jest.fn(),
...value,
code,
} as HookReturnType)
);
return mockedUseFeature;
};
| 9,567 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseFlag.ts | import * as useFlagModule from '@protontech/proxy-client-react';
export const mockUseFlag = (value: boolean = false) => {
const mockedUseFlag = jest.spyOn(useFlagModule, 'useFlag');
mockedUseFlag.mockReturnValue(value);
return mockedUseFlag;
};
| 9,568 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseFolders.ts | import * as useFoldersModule from '@proton/components/hooks/useCategories';
import { Folder } from '@proton/shared/lib/interfaces/Folder';
export const mockUseFolders = (params?: [Folder[]?, boolean?]) => {
const [value = [], loading = false] = params ?? [];
const mockedUseFolders = jest.spyOn(useFoldersModule, 'useFolders');
mockedUseFolders.mockReturnValue([value, loading]);
return mockedUseFolders;
};
| 9,569 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseHistory.ts | import * as reactRouterDomModule from 'react-router-dom';
// A simple workaround for jest issue not solved yet
// https://stackoverflow.com/questions/67872622/jest-spyon-not-working-on-index-file-cannot-redefine-property
jest.mock('react-router-dom', () => {
return {
__esModule: true,
...jest.requireActual('react-router-dom'),
};
});
export const mockUseHistory = (value?: Partial<ReturnType<typeof reactRouterDomModule.useHistory>>) => {
const mockedUseHistory = jest.spyOn(reactRouterDomModule, 'useHistory');
mockedUseHistory.mockReturnValue({
length: 0,
action: 'PUSH',
location: {
pathname: '/',
search: '',
state: {},
hash: '',
},
push: jest.fn(),
replace: jest.fn(),
go: jest.fn(),
goBack: jest.fn(),
goForward: jest.fn(),
block: jest.fn(),
listen: jest.fn(),
createHref: jest.fn(),
...value,
});
return mockedUseHistory;
};
| 9,570 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseLabels.ts | import * as useLabelsModule from '@proton/components/hooks/useCategories';
import { Label } from '@proton/shared/lib/interfaces/Label';
export const mockUseLabels = (params?: [Label[]?, boolean?]) => {
const [value = [], loading = false] = params ?? [];
const mockedUseLabels = jest.spyOn(useLabelsModule, 'useLabels');
mockedUseLabels.mockReturnValue([value, loading]);
return mockedUseLabels;
};
| 9,571 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseLocation.ts | import * as reactRouterDomModule from 'react-router-dom';
// A simple workaround for jest issue not solved yet
// https://stackoverflow.com/questions/67872622/jest-spyon-not-working-on-index-file-cannot-redefine-property
jest.mock('react-router-dom', () => {
return {
__esModule: true,
...jest.requireActual('react-router-dom'),
};
});
export const mockUseLocation = (value?: Partial<ReturnType<typeof reactRouterDomModule.useLocation>>) => {
const mockedUseLocation = jest.spyOn(reactRouterDomModule, 'useLocation');
mockedUseLocation.mockReturnValue({
pathname: '/',
search: '',
state: {},
hash: '',
...value,
});
return mockedUseLocation;
};
| 9,572 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseMailSettings.ts | import * as useMailSettingsModule from '@proton/components/hooks/useMailSettings';
import { MIME_TYPES } from '@proton/shared/lib/constants';
import { MailSettings } from '@proton/shared/lib/interfaces';
import { DEFAULT_MAILSETTINGS } from '@proton/shared/lib/mail/mailSettings';
const defaultMailSettings: MailSettings = {
...DEFAULT_MAILSETTINGS,
FontSize: null,
FontFace: null,
ViewLayout: 0,
SwipeLeft: 0,
SwipeRight: 1,
PMSignature: 1,
HideSenderImages: 0,
DraftMIMEType: MIME_TYPES.PLAINTEXT,
AutoDeleteSpamAndTrashDays: 0,
};
export const mockUseMailSettings = (params?: [Partial<MailSettings>?, boolean?, (() => void)?]) => {
const [value, isMissed = false, miss = jest.fn()] = params ?? [];
const mockedUseMailSettings = jest.spyOn(useMailSettingsModule, 'useMailSettings');
mockedUseMailSettings.mockReturnValue([
{
...defaultMailSettings,
...value,
},
isMissed,
miss,
]);
return mockedUseMailSettings;
};
| 9,573 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseNotifications.ts | import * as useNotificationsModule from '@proton/components/hooks/useNotifications';
export const mockUseNotifications = (value?: Partial<ReturnType<typeof useNotificationsModule.default>>) => {
const mockedUseNotifications = jest.spyOn(useNotificationsModule, 'default');
mockedUseNotifications.mockReturnValue({
setOffset: jest.fn(),
removeDuplicate: jest.fn(),
createNotification: jest.fn(),
removeNotification: jest.fn(),
hideNotification: jest.fn(),
clearNotifications: jest.fn(),
...value,
});
return mockedUseNotifications;
};
| 9,574 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseSelector.ts | import * as useSelectorModule from 'react-redux';
// A simple workaround for jest issue not solved yet
// https://stackoverflow.com/questions/67872622/jest-spyon-not-working-on-index-file-cannot-redefine-property
jest.mock('react-redux', () => {
return {
__esModule: true,
...jest.requireActual('react-redux'),
};
});
export const mockUseSelector = (value?: Partial<ReturnType<typeof useSelectorModule.useSelector>>) => {
const mockedUseSelector = jest.spyOn(useSelectorModule, 'useSelector');
mockedUseSelector.mockReturnValue(value);
return mockedUseSelector;
};
| 9,575 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseSpotlightOnFeature.ts | import * as useSpotlightOnFeatureModule from '@proton/components/hooks/useSpotlightOnFeature';
type HookReturnType = ReturnType<typeof useSpotlightOnFeatureModule.default>;
export const mockUseSpotlightOnFeature = (values: Partial<HookReturnType>) => {
const mockedUseSpotlightOnFeature = jest.spyOn(useSpotlightOnFeatureModule, 'default');
mockedUseSpotlightOnFeature.mockReturnValue({
onDisplayed: () => {},
onClose: () => {},
show: false,
...values,
});
return mockedUseSpotlightOnFeature;
};
| 9,576 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseUser.ts | import * as useUserModule from '@proton/components/hooks/useUser';
import { UserModel } from '@proton/shared/lib/interfaces';
import { buildUser } from '../builders';
export const mockUseUser = (value: [Partial<UserModel>?, boolean?, any?] = []) => {
const [user, cached, miss = jest.fn()] = value;
const mockedUseUser = jest.spyOn(useUserModule, 'default');
mockedUseUser.mockReturnValue([buildUser(user), Boolean(cached), miss]);
return mockedUseUser;
};
| 9,577 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseWelcomeFlags.ts | import * as useWelcomeFlagsModule from '@proton/components/hooks/useWelcomeFlags';
export const mockUseWelcomeFlags = ([state, setDone]: [
Partial<useWelcomeFlagsModule.WelcomeFlagsState>?,
(() => void)?
] = []) => {
const mockedUseWelcomeFlags = jest.spyOn(useWelcomeFlagsModule, 'default');
mockedUseWelcomeFlags.mockReturnValue([
{ hasGenericWelcomeStep: true, isDone: false, isWelcomeFlow: false, ...state },
setDone ?? jest.fn,
]);
return mockedUseWelcomeFlags;
};
| 9,578 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/server.ts | import { setupServer } from 'msw/node';
import { handlers } from './handlers';
export const server = setupServer(...handlers);
| 9,579 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/context/hocs.ts | import React, { ComponentType } from 'react';
import { WrapperComponent } from '@testing-library/react-hooks';
interface HOC<T> {
(Component: ComponentType<T>): ComponentType<T>;
}
const reduceHOCs = <T>(hocs: HOC<T>[]): HOC<T> => hocs.reduce((reduced, next) => (c) => next(reduced(c)));
/**
* A helper function to apply multiple higher order components to a component.
* It's useful to mock context providers.
*/
export const applyHOCs = <T extends JSX.IntrinsicAttributes>(...hocs: HOC<T>[]) => {
const reversedHocs = [...hocs].reverse();
const reducedHoc = reduceHOCs(reversedHocs);
return (Component: ComponentType<T>) => {
const WrappedComponent = reducedHoc(Component);
return (props: T & JSX.IntrinsicAttributes) => {
return React.createElement<T>(WrappedComponent, props);
};
};
};
export const hookWrapper = <T extends JSX.IntrinsicAttributes>(...hocs: HOC<T>[]): WrapperComponent<T> => {
return reduceHOCs(hocs)(({ children }) => React.createElement('', { children }));
};
export const componentWrapper = <T extends JSX.IntrinsicAttributes>(
...hocs: HOC<T>[]
): React.JSXElementConstructor<{ children: React.ReactElement }> => {
return reduceHOCs(hocs)((props) => props.children as any) as any;
};
| 9,580 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/context/index.ts | export * from './hocs';
export * from './providers';
| 9,581 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/context/providers.tsx | import { ComponentType } from 'react';
import ApiContext from '@proton/components/containers/api/apiContext';
import AuthenticationProvider, {
Props as AuthenticationProviderProps,
} from '@proton/components/containers/authentication/Provider';
import { CacheProvider } from '@proton/components/containers/cache';
import { ConfigProvider } from '@proton/components/containers/config';
import EventManagerContext from '@proton/components/containers/eventManager/context';
import FeaturesProvider from '@proton/components/containers/features/FeaturesProvider';
import ModalsContext from '@proton/components/containers/modals/modalsContext';
import NotificationsProvider from '@proton/components/containers/notifications/Provider';
import { CLIENT_TYPES } from '@proton/shared/lib/constants';
import { ProtonConfig } from '@proton/shared/lib/interfaces';
import { apiMock } from '../api';
import { mockCache } from '../cache';
import { mockEventManager } from '../event-manager';
import { mockModals } from '../mockModals';
export const withNotifications =
() =>
<T extends {}>(Component: ComponentType<T>) =>
(props: T & JSX.IntrinsicAttributes) => {
return (
<NotificationsProvider>
<Component {...props} />
</NotificationsProvider>
);
};
export const withDeprecatedModals =
(value = mockModals) =>
<T extends {}>(Component: ComponentType<T>) =>
(props: T & JSX.IntrinsicAttributes) => {
return (
<ModalsContext.Provider value={value}>
<Component {...props} />
</ModalsContext.Provider>
);
};
export const withCache =
(cache = mockCache) =>
<T extends {}>(Component: ComponentType<T>) =>
(props: T & JSX.IntrinsicAttributes) => {
return (
<CacheProvider cache={cache}>
<Component {...props} />
</CacheProvider>
);
};
export const withApi =
(api = apiMock) =>
<T extends {}>(Component: ComponentType<T>) =>
(props: T & JSX.IntrinsicAttributes) => {
return (
<ApiContext.Provider value={api}>
<Component {...props} />
</ApiContext.Provider>
);
};
export const withEventManager =
(eventManager = mockEventManager) =>
<T extends {}>(Component: ComponentType<T>) =>
(props: T & JSX.IntrinsicAttributes) => {
return (
<EventManagerContext.Provider value={eventManager}>
<Component {...props} />
</EventManagerContext.Provider>
);
};
/**
* >>> It depends on {@link withApi}! <<<
* Make sure to include the API provider first.
*/
export const withFeatures =
() =>
<T extends {}>(Component: ComponentType<T>) =>
(props: T & JSX.IntrinsicAttributes) => {
return (
<FeaturesProvider>
<Component {...props} />
</FeaturesProvider>
);
};
export const defaultProtonConfig: ProtonConfig = {
CLIENT_TYPE: CLIENT_TYPES.MAIL,
CLIENT_SECRET: 'secret',
APP_VERSION: '1.0.0',
APP_NAME: 'proton-account',
API_URL: 'https://proton.me/api',
LOCALES: {},
DATE_VERSION: '2020-01-01',
COMMIT: 'b8a9c0d1e2f3a4b5c6d4e8f9a0b2c2d3e4f5a6b7',
BRANCH: 'main',
SENTRY_DSN: '',
VERSION_PATH: '/version.json',
};
export const withConfig =
(config: ProtonConfig = defaultProtonConfig) =>
<T extends {}>(Component: ComponentType<T>) =>
(props: T & JSX.IntrinsicAttributes) => {
return (
<ConfigProvider config={config}>
<Component {...props} />
</ConfigProvider>
);
};
export const withAuthentication =
(store: AuthenticationProviderProps['store'] = { UID: 'uid-123' } as any) =>
<T extends {}>(Component: ComponentType<T>) =>
(props: T & JSX.IntrinsicAttributes) => {
return (
<AuthenticationProvider store={store}>
<Component {...props} />
</AuthenticationProvider>
);
};
| 9,582 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/payments/api-endpoints.ts | import {
Autopay,
PAYMENT_METHOD_TYPES,
PAYMENT_TOKEN_STATUS,
PayPalDetails,
PaymentMethodStatus,
SavedCardDetails,
SavedPaymentMethod,
} from '@proton/components/payments/core';
import { createToken, queryPaymentMethodStatus, queryPaymentMethods } from '@proton/shared/lib/api/payments';
import lastItem from '@proton/utils/lastItem';
import { addApiMock, addApiResolver } from '../api';
const tokensUrl = createToken({} as any).url;
export const MOCK_TOKEN_RESPONSE = {
Token: 'token123',
Code: 1000,
Status: PAYMENT_TOKEN_STATUS.STATUS_CHARGEABLE,
};
export function addTokensResponse(response = MOCK_TOKEN_RESPONSE) {
addApiMock(tokensUrl, () => response);
const addons = {
pending: () => {
addApiMock(tokensUrl, () => ({
...response,
Status: PAYMENT_TOKEN_STATUS.STATUS_PENDING,
ApprovalURL: 'https://verify.proton.me',
ReturnHost: 'https://account.proton.me',
}));
return addons;
},
throw: () => {
addApiMock(tokensUrl, () => {
throw new Error();
});
return addons;
},
};
return addons;
}
export function addTokensResolver() {
return addApiResolver(tokensUrl);
}
export const MOCK_PAYMENT_STATUS: PaymentMethodStatus = {
Card: true,
Paypal: true,
Apple: true,
Cash: true,
Bitcoin: true,
};
export function mockPaymentStatus(status = MOCK_PAYMENT_STATUS) {
addApiMock(queryPaymentMethodStatus().url, () => status);
}
export const PAYMENT_METHODS_MOCK: {
PaymentMethods: SavedPaymentMethod[];
} = {
PaymentMethods: [],
};
export function mockPaymentMethods(methods = PAYMENT_METHODS_MOCK) {
const innerMethods = {
...methods,
PaymentMethods: [...methods.PaymentMethods],
};
const applyMock = () => {
addApiMock(queryPaymentMethods().url, () => innerMethods);
};
applyMock();
const getNextId = (id?: string) => {
const last = lastItem(innerMethods.PaymentMethods);
const prevID = last?.ID ?? '0';
const nextID = id ?? '' + (+prevID + 1);
return nextID;
};
const getNextOrder = (order?: number) => {
const last = lastItem(innerMethods.PaymentMethods);
const prevOrder = last?.Order ?? 499;
const nextOrder = order ?? prevOrder + 1;
return nextOrder;
};
type CommonProps = {
ID?: string;
Order?: number;
autopayStatus?: Autopay;
};
const addons = {
withCard: (card: SavedCardDetails, { ID, Order, autopayStatus }: CommonProps = {}) => {
innerMethods.PaymentMethods.push({
ID: getNextId(ID),
Type: PAYMENT_METHOD_TYPES.CARD,
Order: getNextOrder(Order),
Autopay: autopayStatus ?? Autopay.ENABLE,
Details: card,
});
return addons;
},
withPaypal: (paypal: PayPalDetails, { ID, Order }: CommonProps = {}) => {
innerMethods.PaymentMethods.push({
ID: getNextId(ID),
Type: PAYMENT_METHOD_TYPES.PAYPAL,
Order: getNextOrder(Order),
Details: paypal,
});
return addons;
},
noSaved: () => {
innerMethods.PaymentMethods = [];
return addons;
},
reset: () => {
innerMethods.PaymentMethods = [...methods.PaymentMethods];
return addons;
},
};
return addons;
}
| 9,583 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/payments/index.ts | export * from './mockVerifyPayment';
export * from './api-endpoints';
| 9,584 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/payments/mockVerifyPayment.ts | import { PAYMENT_METHOD_TYPES, TokenPaymentMethod } from '@proton/components/payments/core';
export function mockVerifyPayment() {
const verifyPayment = jest.fn();
(verifyPayment as any).mockVerification = (
value: TokenPaymentMethod = {
Payment: {
Type: PAYMENT_METHOD_TYPES.TOKEN,
Details: {
Token: 'token123',
},
},
}
) => verifyPayment.mockResolvedValue(value);
return verifyPayment as jest.Mock & {
mockVerification: (value?: TokenPaymentMethod) => jest.Mock;
};
}
| 9,585 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/.eslintrc.js | module.exports = {
extends: ['@proton/eslint-config-proton'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
ignorePatterns: ['.eslintrc.js'],
};
| 9,586 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/README.md | # Util
Generic business-agnostic utils. Inspired by parallels such as lodash or ramda.
1 concern (usually 1 function) per file. Necessarily pure.
| 9,587 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/addItem.test.ts | import addItem from './addItem';
describe('addItem()', () => {
it('adds item to empty array', () => {
const item = 'item to add';
const result = addItem([], item);
expect(result).toStrictEqual([item]);
});
it('appends item to ends of array', () => {
const array = ['item 1', 'item 2', 'item 3'];
const item = 'item to add';
const result = addItem(array, item);
expect(result).toStrictEqual([...array, item]);
});
});
| 9,588 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/addItem.ts | /**
* Adds an item to an array
*/
export default function addItem<T>(array: T[], item: T) {
return array.concat(item);
}
| 9,589 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/arraysContainSameElements.test.ts | import arraysContainSameElements from './arraysContainSameElements';
describe('arraysContainSameElements()', () => {
it('returns true for empty arrays', () => {
const result = arraysContainSameElements([], []);
expect(result).toBeTruthy();
});
it('returns false if arrays are of different length', () => {
const array1 = ['item 1', 'item 2', 'item 3'];
const array2 = ['item 1', 'item 2'];
const result = arraysContainSameElements(array1, array2);
expect(result).toBeFalsy();
});
it('returns true if items are the same and are in the same order', () => {
const array1 = ['item 1', 'item 2', 'item 3'];
const array2 = ['item 1', 'item 2', 'item 3'];
const result = arraysContainSameElements(array1, array2);
expect(result).toBeTruthy();
});
it('returns true if items are the same but out of order', () => {
const array1 = ['item 1', 'item 2', 'item 3'];
const array2 = ['item 1', 'item 3', 'item 2'];
const result = arraysContainSameElements(array1, array2);
expect(result).toBeTruthy();
});
});
| 9,590 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/arraysContainSameElements.ts | export default function arraysContainSameElements<T>(array1: T[], array2: T[]) {
if (array1.length !== array2.length) {
return false;
}
return array1.every((element) => array2.includes(element));
}
| 9,591 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/capitalize.test.ts | import capitalize from './capitalize';
describe('capitalize()', () => {
it('returns undefined when called with undefined', () => {
expect(capitalize(undefined)).toBe(undefined);
});
it('returns an empty string when an empty string is provided', () => {
expect(capitalize('')).toBe('');
});
it('capitalizes a single letter', () => {
expect(capitalize('a')).toBe('A');
});
it('capitalizes only the first letter', () => {
expect(capitalize('abc')).toBe('Abc');
});
it('capitalizes the first letter even if it is already a capital', () => {
expect(capitalize('Abc')).toBe('Abc');
});
it(`doesn't affect other capital letters`, () => {
expect(capitalize('ABc')).toBe('ABc');
});
});
| 9,592 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/capitalize.ts | /**
* Capitalize the first letter in a string.
*/
export default function capitalize(str: string | undefined) {
if (str === undefined) {
return;
}
if (str === '') {
return str;
}
return str[0].toUpperCase() + str.slice(1);
}
| 9,593 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/chunk.test.ts | import chunk from './chunk';
describe('chunk()', () => {
it('creates an array of chunks of a given other array of fixed size', () => {
const output = chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], 3);
const expected = [
['a', 'b', 'c'],
['d', 'e', 'f'],
['g', 'h', 'i'],
];
expect(output).toEqual(expected);
});
it('defaults to a chunk size of 1 ', () => {
const output = chunk(['a', 'b', 'c']);
const expected = [['a'], ['b'], ['c']];
expect(output).toEqual(expected);
});
it('creates the last chunk equal to the size of remaining elements if not exactly divisible by the chunk size', () => {
const output = chunk(['a', 'b', 'c', 'd', 'e'], 2);
const expected = [['a', 'b'], ['c', 'd'], ['e']];
expect(output).toEqual(expected);
});
it("doesn't mutate the input array", () => {
const input = ['a', 'b', 'c'];
chunk(input);
expect(input).toEqual(['a', 'b', 'c']);
});
it('returns an empty array given no input', () => {
const output = chunk();
expect(output).toEqual([]);
});
});
| 9,594 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/chunk.ts | /**
* Divide an array into sub-arrays of a fixed chunk size
*/
const chunk = <T>(list: T[] = [], size = 1) => {
return list.reduce<T[][]>((res, item, index) => {
if (index % size === 0) {
res.push([]);
}
res[res.length - 1].push(item);
return res;
}, []);
};
export default chunk;
| 9,595 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/clamp.test.ts | import clamp from './clamp';
describe('clamp()', () => {
it('returns the exact value passed in if it already lies between min & max', () => {
expect(clamp(7, 0, 10)).toBe(7);
});
it('returns the min if the value passed in is lower than min', () => {
expect(clamp(-2, 0, 10)).toBe(0);
});
it('returns the max if the value passed in is higher than max', () => {
expect(clamp(12, 0, 10)).toBe(10);
});
});
| 9,596 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/clamp.ts | /**
* Makes sure a value can't leave the bounds of defined
* min & max values. If n is larger than max or smaller
* than min, returns min or max respectively.
*/
const clamp = (value: number, min: number, max: number) => Math.min(Math.max(min, value), max);
export default clamp;
| 9,597 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/clsx.test.ts | import clsx from './clsx';
describe('clsx()', () => {
it('handles array arguments', () => {
const result = clsx(['a', 'b']);
expect(result).toBe('a b');
});
it('returns empty string when empty array is passed', () => {
const result = clsx([]);
expect(result).toBe('');
});
it('returns empty string when empty string is passed', () => {
const result = clsx('');
expect(result).toBe('');
});
it('joins strings correctly', () => {
const result = clsx('a', 'b');
expect(result).toBe('a b');
});
it('trims empty space', () => {
const result = clsx('foo bar', ' ', 'foobar');
expect(result).toBe('foo bar foobar');
});
it('keeps only non-blank strings', () => {
const result = clsx(null, '', false, undefined, 'foobar', ' ', true);
expect(result).toBe('foobar');
});
});
| 9,598 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/clsx.ts | type V = string | boolean | null | undefined;
function clsx(args: V[]): string;
function clsx(...args: V[]): string;
function clsx(...args: any): any {
return args
.flat()
.filter((a: any) => typeof a === 'string')
.map((a: string) => a.trim())
.filter((a: string) => a !== '')
.join(' ');
}
export default clsx;
| 9,599 |
Subsets and Splits