From 5bde5ba3ad6d06cd44bd431bf468c7812d3f01d5 Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Thu, 14 Mar 2019 21:15:56 -0300 Subject: [PATCH 01/11] Upgrade mdcw drawer version to 1.0.1 --- package-lock.json | 302 +++++++++++++++++------------------ package.json | 4 +- packages/drawer/package.json | 2 +- 3 files changed, 154 insertions(+), 154 deletions(-) diff --git a/package-lock.json b/package-lock.json index 58f8905dd..c9c0b6486 100644 --- a/package-lock.json +++ b/package-lock.json @@ -628,38 +628,115 @@ "dev": true }, "@material/drawer": { - "version": "0.41.0", - "resolved": "https://registry.npmjs.org/@material/drawer/-/drawer-0.41.0.tgz", - "integrity": "sha512-XMKrr9Ci7z69xwYsT1P/JH/BRccwB+HL9UiYzym8SAfZG/4XtP0b5qw+vYMrIZ/NeF0nOEaE8pNHq2XrUz0csA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@material/drawer/-/drawer-1.0.1.tgz", + "integrity": "sha512-xgpWg2MZVFWU0MX+H4MmWA0XQO0cxF1XFA0KdyV+7W0bdzpI1x8itM8Xh0suyzqyqDc+GMHG/OxP8KYUv40jeg==", "dev": true, "requires": { - "@material/animation": "^0.41.0", - "@material/base": "^0.41.0", - "@material/elevation": "^0.41.0", - "@material/list": "^0.41.0", - "@material/ripple": "^0.41.0", - "@material/rtl": "^0.40.1", - "@material/shape": "^0.41.0", - "@material/theme": "^0.41.0", - "@material/typography": "^0.41.0", - "focus-trap": "^3.0.0" + "@material/animation": "^1.0.0", + "@material/base": "^1.0.0", + "@material/elevation": "^1.0.0", + "@material/list": "^1.0.1", + "@material/ripple": "^1.0.1", + "@material/rtl": "^0.42.0", + "@material/shape": "^1.0.0", + "@material/theme": "^1.0.0", + "@material/typography": "^1.0.0", + "focus-trap": "^4.0.2", + "tslib": "^1.9.3" }, "dependencies": { - "@material/base": { - "version": "0.41.0", - "resolved": "https://registry.npmjs.org/@material/base/-/base-0.41.0.tgz", - "integrity": "sha512-tEyzwBRu3d1H120SfKsDVYZHcqT5lKohh/7cWKR93aAaPDkSvjpKJIjyu2yuSkjpDduVZGzVocYbOvhUKhhzXQ==", - "dev": true + "@material/animation": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@material/animation/-/animation-1.0.0.tgz", + "integrity": "sha512-Ed5/vggn6ZhSJ87yn3ZS1d826VJNFz73jHF2bSsgRtHDoB8KCuOwQMfdgAgDa4lKDF6CDIPCKBZPKrs2ubehdw==", + "dev": true, + "requires": { + "tslib": "^1.9.3" + } + }, + "@material/dom": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@material/dom/-/dom-1.0.1.tgz", + "integrity": "sha512-7gb9Tk8YBn2fLEa5fJfvDexG0QxvRGDb8c6uZEhvK4bTd2ZHCfHg9KrO+smC6Trbn5jC+FsBvdRZBbMjtS/E4g==", + "dev": true, + "requires": { + "tslib": "^1.9.3" + } + }, + "@material/elevation": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@material/elevation/-/elevation-1.0.0.tgz", + "integrity": "sha512-TqmvEXmZDYLm2X5lEnjKCsZMDkCXpxFFxL22AfCAQB5L4d0gAS7vqDEE797y4Rp+BBKEcOP71mum1l56RI3NBQ==", + "dev": true, + "requires": { + "@material/animation": "^1.0.0", + "@material/feature-targeting": "^0.44.1", + "@material/theme": "^1.0.0" + } + }, + "@material/list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@material/list/-/list-1.0.1.tgz", + "integrity": "sha512-u9Bx+mghPy2qCHcSH2b0+0jbjTtkXNdiWjb8JDQcYmOUTfFoeQ16GqvjTybRPwoKA0UC9Hc/4U8gYvnK+bReRw==", + "dev": true, + "requires": { + "@material/base": "^1.0.0", + "@material/dom": "^1.0.1", + "@material/feature-targeting": "^0.44.1", + "@material/ripple": "^1.0.1", + "@material/rtl": "^0.42.0", + "@material/shape": "^1.0.0", + "@material/theme": "^1.0.0", + "@material/typography": "^1.0.0", + "tslib": "^1.9.3" + } }, "@material/ripple": { - "version": "0.41.0", - "resolved": "https://registry.npmjs.org/@material/ripple/-/ripple-0.41.0.tgz", - "integrity": "sha512-rxEUVWM4AByDlTCH0kkthZQmUuY6eeN0X6cOHBoioFN2vUDk0D0Nfzz/N9FF2AlAf8C2lDDLrTuqnJPVIn+NHA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@material/ripple/-/ripple-1.0.1.tgz", + "integrity": "sha512-aBigRoVMjIU2lLDq7TMocI2H2YFbO1hICs5FTdSRp4Yis/QFTrgaW32q8yuHdZI56j+b2BWIWapqA2xpSmCMXQ==", "dev": true, "requires": { - "@material/animation": "^0.41.0", - "@material/base": "^0.41.0", - "@material/theme": "^0.41.0" + "@material/animation": "^1.0.0", + "@material/base": "^1.0.0", + "@material/dom": "^1.0.1", + "@material/feature-targeting": "^0.44.1", + "@material/theme": "^1.0.0", + "tslib": "^1.9.3" + } + }, + "@material/rtl": { + "version": "0.42.0", + "resolved": "https://registry.npmjs.org/@material/rtl/-/rtl-0.42.0.tgz", + "integrity": "sha512-VrnrKJzhmspsN8WXHuxxBZ69yM5IwhCUqWr1t1eNfw3ZEvEj7i1g3P31HGowKThIN1dc1Wh4LE14rCISWCtv5w==", + "dev": true + }, + "@material/shape": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@material/shape/-/shape-1.0.0.tgz", + "integrity": "sha512-zfXEacPQZmH+ujVtaFyfAsYiF46j1QCcFzJeZVouG4pznrbA7XD6614Ywg0wbyWX5iB6hD52ld/IN+R/6oxKqA==", + "dev": true, + "requires": { + "@material/feature-targeting": "^0.44.1" + } + }, + "@material/theme": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@material/theme/-/theme-1.0.0.tgz", + "integrity": "sha512-Bg/BQLU5MmCwtQ3DHcSs9DodZB8PTvuItv1wXrP54S/wBVwryIB5uMDmERhnItbNnAFbkKhlAuhn1asMmMzfkQ==", + "dev": true, + "requires": { + "@material/feature-targeting": "^0.44.1" + } + }, + "@material/typography": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@material/typography/-/typography-1.0.0.tgz", + "integrity": "sha512-Oeqbjci1cC7jTE8/n3dwnkqKe9ZeWiaE+rgMtRYtRFw1HvAw14SpGA5EEAS/Li2Hu2KZ50FYCe3HYqShfxtChA==", + "dev": true, + "requires": { + "@material/feature-targeting": "^0.44.1" } } } @@ -1775,7 +1852,6 @@ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", "dev": true, - "optional": true, "requires": { "es6-promisify": "^5.0.0" } @@ -3905,8 +3981,7 @@ "version": "0.0.2", "resolved": "https://registry.npmjs.org/buffer-more-ints/-/buffer-more-ints-0.0.2.tgz", "integrity": "sha1-JrOIXRD6E9t/wBquOquHAZngEkw=", - "dev": true, - "optional": true + "dev": true }, "buffer-xor": { "version": "1.0.3", @@ -4240,8 +4315,7 @@ "version": "2.1.1", "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -4265,15 +4339,13 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4290,22 +4362,19 @@ "version": "1.1.0", "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -4436,8 +4505,7 @@ "version": "2.0.3", "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -4451,7 +4519,6 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4468,7 +4535,6 @@ "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4477,15 +4543,13 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "resolved": false, "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -4506,7 +4570,6 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4595,8 +4658,7 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -4610,7 +4672,6 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4706,8 +4767,7 @@ "version": "5.1.1", "resolved": false, "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -4749,7 +4809,6 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4771,7 +4830,6 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4820,15 +4878,13 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "resolved": false, "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true, - "optional": true + "dev": true } } }, @@ -8017,12 +8073,12 @@ "dev": true }, "focus-trap": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-3.0.0.tgz", - "integrity": "sha512-jTFblf0tLWbleGjj2JZsAKbgtZTdL1uC48L8FcmSDl4c2vDoU4NycN1kgV5vJhuq1mxNFkw7uWZ1JAGlINWvyw==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-4.0.2.tgz", + "integrity": "sha512-HtLjfAK7Hp2qbBtLS6wEznID1mPT+48ZnP2nkHzgjpL4kroYHg0CdqJ5cTXk+UO5znAxF5fRUkhdyfgrhh8Lzw==", "dev": true, "requires": { - "tabbable": "^3.1.0", + "tabbable": "^3.1.2", "xtend": "^4.0.1" } }, @@ -9508,7 +9564,6 @@ "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", "dev": true, - "optional": true, "requires": { "agent-base": "4", "debug": "3.1.0" @@ -9519,7 +9574,6 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, - "optional": true, "requires": { "ms": "2.0.0" } @@ -9571,7 +9625,6 @@ "resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.6.1.tgz", "integrity": "sha1-rQFScUOi6Hc8+uapb1hla7UqNLI=", "dev": true, - "optional": true, "requires": { "httpreq": ">=0.4.22", "underscore": "~1.7.0" @@ -9581,8 +9634,7 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/httpreq/-/httpreq-0.4.24.tgz", "integrity": "sha1-QzX/2CzZaWaKOUZckprGHWOTYn8=", - "dev": true, - "optional": true + "dev": true }, "https-browserify": { "version": "1.0.0", @@ -9595,7 +9647,6 @@ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", "dev": true, - "optional": true, "requires": { "agent-base": "^4.1.0", "debug": "^3.1.0" @@ -9606,7 +9657,6 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, - "optional": true, "requires": { "ms": "2.0.0" } @@ -9953,8 +10003,7 @@ "version": "1.1.5", "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", - "dev": true, - "optional": true + "dev": true }, "ipaddr.js": { "version": "1.6.0", @@ -11561,15 +11610,13 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/libbase64/-/libbase64-0.1.0.tgz", "integrity": "sha1-YjUag5VjrF/1vSbxL2Dpgwu3UeY=", - "dev": true, - "optional": true + "dev": true }, "libmime": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/libmime/-/libmime-3.0.0.tgz", "integrity": "sha1-UaGp50SOy9Ms2lRCFnW7IbwJPaY=", "dev": true, - "optional": true, "requires": { "iconv-lite": "0.4.15", "libbase64": "0.1.0", @@ -11580,8 +11627,7 @@ "version": "0.4.15", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es=", - "dev": true, - "optional": true + "dev": true } } }, @@ -11589,8 +11635,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/libqp/-/libqp-1.1.0.tgz", "integrity": "sha1-9ebgatdLeU+1tbZpiL9yjvHe2+g=", - "dev": true, - "optional": true + "dev": true }, "load-json-file": { "version": "1.1.0", @@ -11853,7 +11898,6 @@ "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "dev": true, - "optional": true, "requires": { "hoek": "2.x.x" } @@ -11917,8 +11961,7 @@ "version": "2.16.3", "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "dev": true, - "optional": true + "dev": true }, "http-signature": { "version": "1.1.1", @@ -13022,15 +13065,13 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/nodemailer-fetch/-/nodemailer-fetch-1.6.0.tgz", "integrity": "sha1-ecSQihwPXzdbc/6IjamCj23JY6Q=", - "dev": true, - "optional": true + "dev": true }, "nodemailer-shared": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/nodemailer-shared/-/nodemailer-shared-1.1.0.tgz", "integrity": "sha1-z1mU4v0mjQD1zw+nZ6CBae2wfsA=", "dev": true, - "optional": true, "requires": { "nodemailer-fetch": "1.6.0" } @@ -13063,8 +13104,7 @@ "version": "0.1.10", "resolved": "https://registry.npmjs.org/nodemailer-wellknown/-/nodemailer-wellknown-0.1.10.tgz", "integrity": "sha1-WG24EB2zDLRDjrVGc3pBqtDPE9U=", - "dev": true, - "optional": true + "dev": true }, "nomnom": { "version": "1.6.2", @@ -16096,7 +16136,6 @@ "resolved": "https://registry.npmjs.org/smtp-connection/-/smtp-connection-2.12.0.tgz", "integrity": "sha1-1275EnyyPCJZ7bHoNJwujV4tdME=", "dev": true, - "optional": true, "requires": { "httpntlm": "1.6.1", "nodemailer-shared": "1.1.0" @@ -16837,9 +16876,9 @@ } }, "tabbable": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-3.1.1.tgz", - "integrity": "sha512-583MHIOwictf7+zbxqO/L5fBqMN6Li4SJ1XTKQA9WzHRA7c2BB+D+Ny7Y6kGqU2u+rHK59+oRzrBvMU53aZz+A==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-3.1.2.tgz", + "integrity": "sha512-wjB6puVXTYO0BSFtCmWQubA/KIn7Xvajw0x0l6eJUudMG/EAiJvIUnyNX6xO4NpGrJ16lbD0eUseB9WxW0vlpQ==", "dev": true }, "table": { @@ -17977,8 +18016,7 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=", - "dev": true, - "optional": true + "dev": true }, "union-value": { "version": "1.0.0", @@ -18479,8 +18517,7 @@ "version": "2.1.1", "resolved": "", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -18504,15 +18541,13 @@ "version": "1.0.0", "resolved": "", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "resolved": "", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -18529,22 +18564,19 @@ "version": "1.1.0", "resolved": "", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": "", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "resolved": "", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -18675,8 +18707,7 @@ "version": "2.0.3", "resolved": "", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -18690,7 +18721,6 @@ "resolved": "", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -18707,7 +18737,6 @@ "resolved": "", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -18716,15 +18745,13 @@ "version": "0.0.8", "resolved": "", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "resolved": "", "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -18745,7 +18772,6 @@ "resolved": "", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -18834,8 +18860,7 @@ "version": "1.0.1", "resolved": "", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -18849,7 +18874,6 @@ "resolved": "", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -18945,8 +18969,7 @@ "version": "5.1.1", "resolved": "", "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -18988,7 +19011,6 @@ "resolved": "", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -19010,7 +19032,6 @@ "resolved": "", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -19059,15 +19080,13 @@ "version": "1.0.2", "resolved": "", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "resolved": "", "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true, - "optional": true + "dev": true } } }, @@ -19536,8 +19555,7 @@ "version": "2.1.1", "resolved": "", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -19561,15 +19579,13 @@ "version": "1.0.0", "resolved": "", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "resolved": "", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -19586,22 +19602,19 @@ "version": "1.1.0", "resolved": "", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": "", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "resolved": "", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -19732,8 +19745,7 @@ "version": "2.0.3", "resolved": "", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -19747,7 +19759,6 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -19764,7 +19775,6 @@ "resolved": "", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -19773,15 +19783,13 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "resolved": false, "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -19802,7 +19810,6 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -19891,8 +19898,7 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -19906,7 +19912,6 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -20002,8 +20007,7 @@ "version": "5.1.1", "resolved": false, "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -20045,7 +20049,6 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -20067,7 +20070,6 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -20116,15 +20118,13 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "resolved": false, "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true, - "optional": true + "dev": true } } }, diff --git a/package.json b/package.json index a68f470e4..4c1152d64 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "@material/chips": "^1.0.0", "@material/dialog": "^0.43.0", "@material/dom": "^0.41.0", - "@material/drawer": "^0.41.0", + "@material/drawer": "^1.0.1", "@material/fab": "^0.41.0", "@material/floating-label": "^0.41.0", "@material/icon-button": "^0.41.0", @@ -147,8 +147,8 @@ "react-dom": "^16.4.2", "react-router-dom": "^4.3.1", "remap-istanbul": "^0.12.0", - "rimraf": "^2.6.3", "resemblejs": "^3.0.1", + "rimraf": "^2.6.3", "sass-loader": "^6.0.7", "testdouble": "^3.6.0", "ts-loader": "^3.5.0", diff --git a/packages/drawer/package.json b/packages/drawer/package.json index d54544a52..f00a91207 100644 --- a/packages/drawer/package.json +++ b/packages/drawer/package.json @@ -17,7 +17,7 @@ "url": "https://github.com/material-components/material-components-web-react.git" }, "dependencies": { - "@material/drawer": "^0.41.0", + "@material/drawer": "^1.0.1", "@material/list": "^0.41.0", "classnames": "^2.2.6", "focus-trap": "^3.0.0", From 8f205caf5422a8de63dc5b3120e4da0b4fcc19c7 Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Thu, 14 Mar 2019 21:16:22 -0300 Subject: [PATCH 02/11] Add innerRef prop --- packages/drawer/index.tsx | 26 +++++++++++++++++++++++++- test/unit/drawer/index.test.tsx | 14 ++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/packages/drawer/index.tsx b/packages/drawer/index.tsx index 20b81ae04..d730e4c8e 100644 --- a/packages/drawer/index.tsx +++ b/packages/drawer/index.tsx @@ -39,6 +39,8 @@ import {FocusTrap} from 'focus-trap'; const {cssClasses: listCssClasses} = MDCListFoundation; +type RefCallback = (node: T) => void; + export interface DrawerProps extends React.HTMLProps{ className?: string; open?: boolean; @@ -47,12 +49,17 @@ export interface DrawerProps extends React.HTMLProps{ tag?: string; dismissible?: boolean; modal?: boolean; + innerRef?: RefCallback | React.RefObject; }; interface DrawerState { classList: Set; }; +const isRefObject = function(ref: DrawerProps['innerRef']): ref is React.RefObject { + return typeof ref !== 'function'; +}; + class Drawer extends React.Component { previousFocus: HTMLElement | null = null; foundation: MDCDismissibleDrawerFoundation | MDCModalDrawerFoundation; @@ -193,6 +200,23 @@ class Drawer extends React.Component { this.foundation.handleTransitionEnd(evt); }; + attachRef = (node: HTMLElement) => { + const {innerRef} = this.props; + + // https://github.com/facebook/react/issues/13029#issuecomment-410002316 + // @ts-ignore this is acceptable according to the comment above + this.drawerElement.current = node; + + if (innerRef !== undefined) { + if (isRefObject(innerRef)) { + // @ts-ignore same as above + innerRef.current = node; + } else { + innerRef(node); + } + } + } + render() { const { /* eslint-disable no-unused-vars */ @@ -215,7 +239,7 @@ class Drawer extends React.Component { // @ts-ignore */} { scrim.simulate('click'); td.verify(wrapper.instance().foundation.handleScrimClick(), {times: 1}); }); + +test('handles object refs correctly', () => { + const myRef = React.createRef(); + const wrapper = shallow(); + assert.isNotNull(myRef.current); + assert.isNotNull(wrapper.instance().drawerElement.current); +}); + +test('it handles function refs correctly', () => { + const refFn = coerceForTesting<(node: HTMLElement) => void>(td.func()); + const wrapper = shallow(); + assert.isNotNull(wrapper.instance().drawerElement.current); + td.verify(refFn, {times: 1}); +}); From c5db14c2b435c9efc21e5b613762f4fdbf4283aa Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Thu, 14 Mar 2019 21:29:00 -0300 Subject: [PATCH 03/11] Use mount for tests --- test/unit/drawer/index.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/drawer/index.test.tsx b/test/unit/drawer/index.test.tsx index e4aee11d8..84d62238a 100644 --- a/test/unit/drawer/index.test.tsx +++ b/test/unit/drawer/index.test.tsx @@ -286,14 +286,14 @@ test('click on scrim calls #foundation.handleScrimClick', () => { test('handles object refs correctly', () => { const myRef = React.createRef(); - const wrapper = shallow(); + const wrapper = mount(); assert.isNotNull(myRef.current); assert.isNotNull(wrapper.instance().drawerElement.current); }); test('it handles function refs correctly', () => { const refFn = coerceForTesting<(node: HTMLElement) => void>(td.func()); - const wrapper = shallow(); + const wrapper = mount(); assert.isNotNull(wrapper.instance().drawerElement.current); td.verify(refFn, {times: 1}); }); From 19d65743320f42018fc2265e4857b639766c1511 Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Thu, 14 Mar 2019 21:43:34 -0300 Subject: [PATCH 04/11] Avoid passing innerRef to element --- packages/drawer/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/drawer/index.tsx b/packages/drawer/index.tsx index d730e4c8e..1d7e4dc2f 100644 --- a/packages/drawer/index.tsx +++ b/packages/drawer/index.tsx @@ -227,6 +227,7 @@ class Drawer extends React.Component { dismissible, children, className, + innerRef, /* eslint-enable no-unused-vars */ tag: Tag, modal, From 6bf9e7d31a8f1d6ce196791bd13e790bc629d376 Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Thu, 14 Mar 2019 21:53:04 -0300 Subject: [PATCH 05/11] Fix tests --- package-lock.json | 163 +++++++++++++++++++++++--------- test/unit/drawer/index.test.tsx | 2 +- 2 files changed, 121 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index c9c0b6486..cd8664b6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1852,6 +1852,7 @@ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", "dev": true, + "optional": true, "requires": { "es6-promisify": "^5.0.0" } @@ -3981,7 +3982,8 @@ "version": "0.0.2", "resolved": "https://registry.npmjs.org/buffer-more-ints/-/buffer-more-ints-0.0.2.tgz", "integrity": "sha1-JrOIXRD6E9t/wBquOquHAZngEkw=", - "dev": true + "dev": true, + "optional": true }, "buffer-xor": { "version": "1.0.3", @@ -4315,7 +4317,8 @@ "version": "2.1.1", "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -4339,13 +4342,15 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4362,19 +4367,22 @@ "version": "1.1.0", "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4505,7 +4513,8 @@ "version": "2.0.3", "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4519,6 +4528,7 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4535,6 +4545,7 @@ "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4543,13 +4554,15 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "resolved": false, "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -4570,6 +4583,7 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -4658,7 +4672,8 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -4672,6 +4687,7 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -4767,7 +4783,8 @@ "version": "5.1.1", "resolved": false, "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -4809,6 +4826,7 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4830,6 +4848,7 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4878,13 +4897,15 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "resolved": false, "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true + "dev": true, + "optional": true } } }, @@ -9564,6 +9585,7 @@ "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", "dev": true, + "optional": true, "requires": { "agent-base": "4", "debug": "3.1.0" @@ -9574,6 +9596,7 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, + "optional": true, "requires": { "ms": "2.0.0" } @@ -9625,6 +9648,7 @@ "resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.6.1.tgz", "integrity": "sha1-rQFScUOi6Hc8+uapb1hla7UqNLI=", "dev": true, + "optional": true, "requires": { "httpreq": ">=0.4.22", "underscore": "~1.7.0" @@ -9634,7 +9658,8 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/httpreq/-/httpreq-0.4.24.tgz", "integrity": "sha1-QzX/2CzZaWaKOUZckprGHWOTYn8=", - "dev": true + "dev": true, + "optional": true }, "https-browserify": { "version": "1.0.0", @@ -9647,6 +9672,7 @@ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", "dev": true, + "optional": true, "requires": { "agent-base": "^4.1.0", "debug": "^3.1.0" @@ -9657,6 +9683,7 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, + "optional": true, "requires": { "ms": "2.0.0" } @@ -10003,7 +10030,8 @@ "version": "1.1.5", "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", - "dev": true + "dev": true, + "optional": true }, "ipaddr.js": { "version": "1.6.0", @@ -11610,13 +11638,15 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/libbase64/-/libbase64-0.1.0.tgz", "integrity": "sha1-YjUag5VjrF/1vSbxL2Dpgwu3UeY=", - "dev": true + "dev": true, + "optional": true }, "libmime": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/libmime/-/libmime-3.0.0.tgz", "integrity": "sha1-UaGp50SOy9Ms2lRCFnW7IbwJPaY=", "dev": true, + "optional": true, "requires": { "iconv-lite": "0.4.15", "libbase64": "0.1.0", @@ -11627,7 +11657,8 @@ "version": "0.4.15", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es=", - "dev": true + "dev": true, + "optional": true } } }, @@ -11635,7 +11666,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/libqp/-/libqp-1.1.0.tgz", "integrity": "sha1-9ebgatdLeU+1tbZpiL9yjvHe2+g=", - "dev": true + "dev": true, + "optional": true }, "load-json-file": { "version": "1.1.0", @@ -11898,6 +11930,7 @@ "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "dev": true, + "optional": true, "requires": { "hoek": "2.x.x" } @@ -11961,7 +11994,8 @@ "version": "2.16.3", "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "dev": true + "dev": true, + "optional": true }, "http-signature": { "version": "1.1.1", @@ -13065,13 +13099,15 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/nodemailer-fetch/-/nodemailer-fetch-1.6.0.tgz", "integrity": "sha1-ecSQihwPXzdbc/6IjamCj23JY6Q=", - "dev": true + "dev": true, + "optional": true }, "nodemailer-shared": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/nodemailer-shared/-/nodemailer-shared-1.1.0.tgz", "integrity": "sha1-z1mU4v0mjQD1zw+nZ6CBae2wfsA=", "dev": true, + "optional": true, "requires": { "nodemailer-fetch": "1.6.0" } @@ -13104,7 +13140,8 @@ "version": "0.1.10", "resolved": "https://registry.npmjs.org/nodemailer-wellknown/-/nodemailer-wellknown-0.1.10.tgz", "integrity": "sha1-WG24EB2zDLRDjrVGc3pBqtDPE9U=", - "dev": true + "dev": true, + "optional": true }, "nomnom": { "version": "1.6.2", @@ -16136,6 +16173,7 @@ "resolved": "https://registry.npmjs.org/smtp-connection/-/smtp-connection-2.12.0.tgz", "integrity": "sha1-1275EnyyPCJZ7bHoNJwujV4tdME=", "dev": true, + "optional": true, "requires": { "httpntlm": "1.6.1", "nodemailer-shared": "1.1.0" @@ -18016,7 +18054,8 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=", - "dev": true + "dev": true, + "optional": true }, "union-value": { "version": "1.0.0", @@ -18517,7 +18556,8 @@ "version": "2.1.1", "resolved": "", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -18541,13 +18581,15 @@ "version": "1.0.0", "resolved": "", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -18564,19 +18606,22 @@ "version": "1.1.0", "resolved": "", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -18707,7 +18752,8 @@ "version": "2.0.3", "resolved": "", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -18721,6 +18767,7 @@ "resolved": "", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -18737,6 +18784,7 @@ "resolved": "", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -18745,13 +18793,15 @@ "version": "0.0.8", "resolved": "", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "resolved": "", "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -18772,6 +18822,7 @@ "resolved": "", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -18860,7 +18911,8 @@ "version": "1.0.1", "resolved": "", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -18874,6 +18926,7 @@ "resolved": "", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -18969,7 +19022,8 @@ "version": "5.1.1", "resolved": "", "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -19011,6 +19065,7 @@ "resolved": "", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -19032,6 +19087,7 @@ "resolved": "", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -19080,13 +19136,15 @@ "version": "1.0.2", "resolved": "", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "resolved": "", "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true + "dev": true, + "optional": true } } }, @@ -19555,7 +19613,8 @@ "version": "2.1.1", "resolved": "", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -19579,13 +19638,15 @@ "version": "1.0.0", "resolved": "", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -19602,19 +19663,22 @@ "version": "1.1.0", "resolved": "", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -19745,7 +19809,8 @@ "version": "2.0.3", "resolved": "", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -19759,6 +19824,7 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -19775,6 +19841,7 @@ "resolved": "", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -19783,13 +19850,15 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "resolved": false, "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -19810,6 +19879,7 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -19898,7 +19968,8 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -19912,6 +19983,7 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -20007,7 +20079,8 @@ "version": "5.1.1", "resolved": false, "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -20049,6 +20122,7 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -20070,6 +20144,7 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -20118,13 +20193,15 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "resolved": false, "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true + "dev": true, + "optional": true } } }, diff --git a/test/unit/drawer/index.test.tsx b/test/unit/drawer/index.test.tsx index 84d62238a..3686f7d95 100644 --- a/test/unit/drawer/index.test.tsx +++ b/test/unit/drawer/index.test.tsx @@ -295,5 +295,5 @@ test('it handles function refs correctly', () => { const refFn = coerceForTesting<(node: HTMLElement) => void>(td.func()); const wrapper = mount(); assert.isNotNull(wrapper.instance().drawerElement.current); - td.verify(refFn, {times: 1}); + td.verify(refFn(wrapper.instance().drawerElement.current!), {times: 1}); }); From a07b6335cdc4073f4544cac4e7807cbbb6314cf6 Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Thu, 14 Mar 2019 22:08:00 -0300 Subject: [PATCH 06/11] Fix typings --- packages/drawer/index.tsx | 41 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/packages/drawer/index.tsx b/packages/drawer/index.tsx index 1d7e4dc2f..26dbc76e9 100644 --- a/packages/drawer/index.tsx +++ b/packages/drawer/index.tsx @@ -26,8 +26,7 @@ import { MDCDismissibleDrawerFoundation, MDCModalDrawerFoundation, util, -// @ts-ignore no .d.ts file -} from '@material/drawer/dist/mdc.drawer'; +} from '@material/drawer'; // @ts-ignore no .d.ts file import {MDCListFoundation} from '@material/list/dist/mdc.list'; import DrawerHeader from './Header'; @@ -62,7 +61,7 @@ const isRefObject = function(ref: DrawerProps['innerRef']): ref is React.RefObje class Drawer extends React.Component { previousFocus: HTMLElement | null = null; - foundation: MDCDismissibleDrawerFoundation | MDCModalDrawerFoundation; + foundation!: MDCDismissibleDrawerFoundation | MDCModalDrawerFoundation; focusTrap?: FocusTrap; drawerElement: React.RefObject = React.createRef(); @@ -124,7 +123,7 @@ class Drawer extends React.Component { } private initializeFocusTrap = () => { - this.focusTrap = util.createFocusTrapInstance(this.drawerElement.current); + this.focusTrap = util.createFocusTrapInstance(this.drawerElement.current!); }; get classes() { @@ -191,13 +190,13 @@ class Drawer extends React.Component { handleKeyDown = (evt: React.KeyboardEvent) => { this.props.onKeyDown!(evt); if (!this.foundation) return; - this.foundation.handleKeydown(evt); + this.foundation.handleKeydown(evt.nativeEvent); }; handleTransitionEnd = (evt: React.TransitionEvent) => { this.props.onTransitionEnd!(evt); if (!this.foundation) return; - this.foundation.handleTransitionEnd(evt); + this.foundation.handleTransitionEnd(evt.nativeEvent); }; attachRef = (node: HTMLElement) => { @@ -217,6 +216,13 @@ class Drawer extends React.Component { } } + isModal = ( + // @ts-ignore unused var + foundation: Drawer['foundation'] + ): foundation is MDCModalDrawerFoundation => { + return !!this.props.modal; + } + render() { const { /* eslint-disable no-unused-vars */ @@ -228,9 +234,9 @@ class Drawer extends React.Component { children, className, innerRef, + modal, /* eslint-enable no-unused-vars */ tag: Tag, - modal, ...otherProps } = this.props; @@ -247,17 +253,24 @@ class Drawer extends React.Component { > {children} - {modal ? this.renderScrim() : null} + {this.renderScrim()} ); } + renderScrim() { - return ( -
this.foundation.handleScrimClick()} - /> - ); + const foundation = this.foundation; + + if (this.isModal(foundation)) { + return ( +
foundation.handleScrimClick()} + /> + ); + } + + return null; } } From 1f1d8045cb3a61c61ee28fbd38e9582ef149508c Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Thu, 14 Mar 2019 23:12:13 -0300 Subject: [PATCH 07/11] Fix some test typings --- test/unit/drawer/index.test.tsx | 71 +++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/test/unit/drawer/index.test.tsx b/test/unit/drawer/index.test.tsx index 3686f7d95..bfc46cbef 100644 --- a/test/unit/drawer/index.test.tsx +++ b/test/unit/drawer/index.test.tsx @@ -2,10 +2,16 @@ import * as React from 'react'; import {assert} from 'chai'; import {shallow, mount} from 'enzyme'; import * as td from 'testdouble'; +import {MDCModalDrawerFoundation, MDCDismissibleDrawerFoundation, MDCDrawerAdapter} from '@material/drawer'; import Drawer from '../../../packages/drawer/index'; import {Options, DeactivateOptions, FocusTrap} from 'focus-trap'; // eslint-disable-line no-unused-vars import {coerceForTesting} from '../helpers/types'; +function getAdapter(foundation: MDCModalDrawerFoundation | MDCDismissibleDrawerFoundation): MDCDrawerAdapter { + // @ts-ignore adapter_ property is marked as protected in mdc-web. We need to override this behaviour for testing + return foundation.adapter_; +} + suite('Drawer'); test('creates foundation if dismissible', () => { @@ -25,28 +31,28 @@ test('doesnot create foundation if standard', () => { test('when props.open updates to true, #foundation.open is called when dismissible', () => { const wrapper = shallow(); - wrapper.instance().foundation.open = td.func(); + wrapper.instance().foundation.open = coerceForTesting<() => void>(td.func()); wrapper.setProps({open: true}); td.verify(wrapper.instance().foundation.open(), {times: 1}); }); test('when props.open updates to false from true, #foundation.close is called when dismissible', () => { const wrapper = shallow(); - wrapper.instance().foundation.close = td.func(); + wrapper.instance().foundation.close = coerceForTesting<() => void>(td.func()); wrapper.setProps({open: false}); td.verify(wrapper.instance().foundation.close(), {times: 1}); }); test('when props.open updates to true, #foundation.open is called when modal', () => { const wrapper = shallow(); - wrapper.instance().foundation.open = td.func(); + wrapper.instance().foundation.open = coerceForTesting<() => void>(td.func()); wrapper.setProps({open: true}); td.verify(wrapper.instance().foundation.open(), {times: 1}); }); test('when props.open updates to false from true, #foundation.close is called when modal', () => { const wrapper = shallow(); - wrapper.instance().foundation.close = td.func(); + wrapper.instance().foundation.close = coerceForTesting<() => void>(td.func()); wrapper.setProps({open: false}); td.verify(wrapper.instance().foundation.close(), {times: 1}); }); @@ -75,16 +81,16 @@ test('when the drawer changes from dismissible to modal the foundation changes ' test('when the drawer changes from dismissible to modal the original foundation calls destroy', () => { const wrapper = shallow(); - const destroy = td.func(); - wrapper.instance().foundation = {destroy}; + const foundation = wrapper.instance().foundation; + foundation.destroy = coerceForTesting<() => void>(td.func()); wrapper.setProps({modal: true}); - td.verify(destroy(), {times: 1}); + td.verify(foundation.destroy(), {times: 1}); }); test('#componentWillUnmount destroys foundation', () => { const wrapper = shallow(); const foundation = wrapper.instance().foundation; - foundation.destroy = td.func(); + foundation.destroy = coerceForTesting<() => void>(td.func()); wrapper.unmount(); td.verify(foundation.destroy(), {times: 1}); }); @@ -106,21 +112,21 @@ test('has mdc drawer class', () => { test('#adapter.addClass should update state with new className', () => { const wrapper = mount(); - wrapper.instance().foundation.adapter_.addClass('test-class'); + getAdapter(wrapper.instance().foundation).addClass('test-class'); assert.isTrue(wrapper.state().classList.has('test-class')); }); test('#adapter.removeClass should update state with new className', () => { const wrapper = mount(); wrapper.setState({classList: new Set(['test-class'])}); - wrapper.instance().foundation.adapter_.removeClass('test-class'); + getAdapter(wrapper.instance().foundation).removeClass('test-class'); assert.isFalse(wrapper.state().classList.has('test-class')); }); test('#adapter.hasClass returns true if class is contained in classes', () => { const wrapper = mount(); wrapper.setState({classList: new Set(['test-class'])}); - assert.isTrue(wrapper.instance().foundation.adapter_.hasClass('test-class')); + assert.isTrue(getAdapter(wrapper.instance().foundation).hasClass('test-class')); }); test('#adapter.elementHasClass should return true when element has class', () => { @@ -142,15 +148,15 @@ test('#adapter.elementHasClass should return false when element does not have cl .childAt(0) .childAt(0) .getDOMNode(); - const hasClass = wrapper - .instance() - .foundation.adapter_.elementHasClass(element, 'test-class'); + const hasClass = getAdapter( + wrapper.instance().foundation + ).elementHasClass(element, 'test-class'); assert.isFalse(hasClass); }); test('#adapter.saveFocus updates previousFocus', () => { const wrapper = shallow(); - wrapper.instance().foundation.adapter_.saveFocus(); + getAdapter(wrapper.instance().foundation).saveFocus(); assert.exists(wrapper.instance().previousFocus); }); test( @@ -174,7 +180,7 @@ test( .childAt(0) .getDOMNode()); drawerButtonElement.focus(); - wrapper.instance().foundation.adapter_.restoreFocus(); + getAdapter(wrapper.instance().foundation).restoreFocus(); assert.equal(focusedElement, document.activeElement); div.remove(); focusedElement.remove(); @@ -195,7 +201,7 @@ test('#adapter.focusActiveNavigationItem focuses on first list item in drawer', , options ); - wrapper.instance().foundation.adapter_.focusActiveNavigationItem(); + getAdapter(wrapper.instance().foundation).focusActiveNavigationItem(); assert.isTrue( document.activeElement!.classList.contains('mdc-list-item--activated') ); @@ -205,14 +211,14 @@ test('#adapter.focusActiveNavigationItem focuses on first list item in drawer', test('#adapter.notifyClose calls props.onClose', () => { const onClose = coerceForTesting<() => void>(td.func()); const wrapper = shallow(); - wrapper.instance().foundation.adapter_.notifyClose(); + getAdapter(wrapper.instance().foundation).notifyClose(); td.verify(onClose(), {times: 1}); }); test('#adapter.notifyOpen calls props.onOpen', () => { const onOpen = coerceForTesting<() => void>(td.func()); const wrapper = shallow(); - wrapper.instance().foundation.adapter_.notifyOpen(); + getAdapter(wrapper.instance().foundation).notifyOpen(); td.verify(onOpen(), {times: 1}); }); @@ -220,7 +226,7 @@ test('#adapter.trapFocus calls focusTrap.activate if modal variant', () => { const wrapper = shallow(); const activate = coerceForTesting<(activateOptions?: Pick) => void>(td.func()); wrapper.instance().focusTrap = coerceForTesting({activate}); - wrapper.instance().foundation.adapter_.trapFocus(); + getAdapter(wrapper.instance().foundation).trapFocus(); td.verify(activate(), {times: 1}); }); @@ -228,7 +234,7 @@ test('#adapter.releaseFocus calls focusTrap.deactivate if modal variant', () => const wrapper = shallow(); const deactivate = coerceForTesting<(deactivateOptions?: DeactivateOptions) => void>(td.func()); wrapper.instance().focusTrap = coerceForTesting({deactivate}); - wrapper.instance().foundation.adapter_.releaseFocus(); + getAdapter(wrapper.instance().foundation).releaseFocus(); td.verify(deactivate(), {times: 1}); }); @@ -242,10 +248,14 @@ test('event keydown triggers props.onKeyDown', () => { test('event keydown triggers foundation.handleKeydown', () => { const wrapper = shallow(); - wrapper.instance().foundation.handleKeydown = td.func(); - const evt = coerceForTesting({}); + const foundation = wrapper.instance().foundation as MDCModalDrawerFoundation; + foundation.handleKeydown = coerceForTesting<(event: KeyboardEvent) => void>( + td.func() + ); + const nativeEvent = coerceForTesting({}); + const evt = coerceForTesting({nativeEvent}); wrapper.childAt(0).simulate('keydown', evt); - td.verify(wrapper.instance().foundation.handleKeydown(evt), {times: 1}); + td.verify(foundation.handleKeydown(nativeEvent), {times: 1}); }); test('event transitionend triggers props.onTransitionEnd', () => { @@ -258,10 +268,12 @@ test('event transitionend triggers props.onTransitionEnd', () => { test('event transitionend triggers foundation.handleTransitionEnd', () => { const wrapper = shallow(); - wrapper.instance().foundation.handleTransitionEnd = td.func(); - const evt = coerceForTesting({}); + const foundation = wrapper.instance().foundation as MDCModalDrawerFoundation; + foundation.handleTransitionEnd = coerceForTesting<() => void>(td.func()); + const nativeEvent = coerceForTesting({}); + const evt = coerceForTesting({nativeEvent}); wrapper.childAt(0).simulate('transitionend', evt); - td.verify(wrapper.instance().foundation.handleTransitionEnd(evt), { + td.verify(foundation.handleTransitionEnd(nativeEvent), { times: 1, }); }); @@ -278,10 +290,11 @@ test('renders scrim when props.modal is true', () => { test('click on scrim calls #foundation.handleScrimClick', () => { const wrapper = shallow(); - wrapper.instance().foundation.handleScrimClick = td.func(); + const foundation = wrapper.instance().foundation as MDCModalDrawerFoundation; + foundation.handleScrimClick = coerceForTesting<() => void>(td.func()); const scrim = wrapper.childAt(1); scrim.simulate('click'); - td.verify(wrapper.instance().foundation.handleScrimClick(), {times: 1}); + td.verify(foundation.handleScrimClick(), {times: 1}); }); test('handles object refs correctly', () => { From cec9a08a4cb7903d899a64c05998b5e2fc60b60c Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Fri, 15 Mar 2019 00:25:21 -0300 Subject: [PATCH 08/11] Fix failing test --- packages/drawer/index.tsx | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/packages/drawer/index.tsx b/packages/drawer/index.tsx index 26dbc76e9..03185c890 100644 --- a/packages/drawer/index.tsx +++ b/packages/drawer/index.tsx @@ -216,13 +216,6 @@ class Drawer extends React.Component { } } - isModal = ( - // @ts-ignore unused var - foundation: Drawer['foundation'] - ): foundation is MDCModalDrawerFoundation => { - return !!this.props.modal; - } - render() { const { /* eslint-disable no-unused-vars */ @@ -253,24 +246,18 @@ class Drawer extends React.Component { > {children} - {this.renderScrim()} + {modal ? this.renderScrim() : null} ); } renderScrim() { - const foundation = this.foundation; - - if (this.isModal(foundation)) { - return ( -
foundation.handleScrimClick()} - /> - ); - } - - return null; + return ( +
(this.foundation as MDCModalDrawerFoundation).handleScrimClick()} + /> + ); } } From 7a802467d016da309d271b1961d3468572f3aaf7 Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Fri, 15 Mar 2019 22:35:30 -0300 Subject: [PATCH 09/11] Make foundation optional --- packages/drawer/index.tsx | 4 +-- test/unit/drawer/index.test.tsx | 46 ++++++++++++++++----------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/drawer/index.tsx b/packages/drawer/index.tsx index 03185c890..ac1f2c0fd 100644 --- a/packages/drawer/index.tsx +++ b/packages/drawer/index.tsx @@ -61,7 +61,7 @@ const isRefObject = function(ref: DrawerProps['innerRef']): ref is React.RefObje class Drawer extends React.Component { previousFocus: HTMLElement | null = null; - foundation!: MDCDismissibleDrawerFoundation | MDCModalDrawerFoundation; + foundation?: MDCDismissibleDrawerFoundation | MDCModalDrawerFoundation; focusTrap?: FocusTrap; drawerElement: React.RefObject = React.createRef(); @@ -112,7 +112,7 @@ class Drawer extends React.Component { if (changedToModal || changedToDismissible) { this.initFoundation(); } - if (open !== prevProps.open) { + if (open !== prevProps.open && this.foundation) { open ? this.foundation.open() : this.foundation.close(); } } diff --git a/test/unit/drawer/index.test.tsx b/test/unit/drawer/index.test.tsx index bfc46cbef..37a19e15c 100644 --- a/test/unit/drawer/index.test.tsx +++ b/test/unit/drawer/index.test.tsx @@ -31,30 +31,30 @@ test('doesnot create foundation if standard', () => { test('when props.open updates to true, #foundation.open is called when dismissible', () => { const wrapper = shallow(); - wrapper.instance().foundation.open = coerceForTesting<() => void>(td.func()); + wrapper.instance().foundation!.open = coerceForTesting<() => void>(td.func()); wrapper.setProps({open: true}); - td.verify(wrapper.instance().foundation.open(), {times: 1}); + td.verify(wrapper.instance().foundation!.open(), {times: 1}); }); test('when props.open updates to false from true, #foundation.close is called when dismissible', () => { const wrapper = shallow(); - wrapper.instance().foundation.close = coerceForTesting<() => void>(td.func()); + wrapper.instance().foundation!.close = coerceForTesting<() => void>(td.func()); wrapper.setProps({open: false}); - td.verify(wrapper.instance().foundation.close(), {times: 1}); + td.verify(wrapper.instance().foundation!.close(), {times: 1}); }); test('when props.open updates to true, #foundation.open is called when modal', () => { const wrapper = shallow(); - wrapper.instance().foundation.open = coerceForTesting<() => void>(td.func()); + wrapper.instance().foundation!.open = coerceForTesting<() => void>(td.func()); wrapper.setProps({open: true}); - td.verify(wrapper.instance().foundation.open(), {times: 1}); + td.verify(wrapper.instance().foundation!.open(), {times: 1}); }); test('when props.open updates to false from true, #foundation.close is called when modal', () => { const wrapper = shallow(); - wrapper.instance().foundation.close = coerceForTesting<() => void>(td.func()); + wrapper.instance().foundation!.close = coerceForTesting<() => void>(td.func()); wrapper.setProps({open: false}); - td.verify(wrapper.instance().foundation.close(), {times: 1}); + td.verify(wrapper.instance().foundation!.close(), {times: 1}); }); test('when changes from permanent to modal drawer with no foundation, creates a foundation', () => { @@ -82,17 +82,17 @@ test('when the drawer changes from dismissible to modal the foundation changes ' test('when the drawer changes from dismissible to modal the original foundation calls destroy', () => { const wrapper = shallow(); const foundation = wrapper.instance().foundation; - foundation.destroy = coerceForTesting<() => void>(td.func()); + foundation!.destroy = coerceForTesting<() => void>(td.func()); wrapper.setProps({modal: true}); - td.verify(foundation.destroy(), {times: 1}); + td.verify(foundation!.destroy(), {times: 1}); }); test('#componentWillUnmount destroys foundation', () => { const wrapper = shallow(); const foundation = wrapper.instance().foundation; - foundation.destroy = coerceForTesting<() => void>(td.func()); + foundation!.destroy = coerceForTesting<() => void>(td.func()); wrapper.unmount(); - td.verify(foundation.destroy(), {times: 1}); + td.verify(foundation!.destroy(), {times: 1}); }); test('has dismissible drawer class when props.dismissible is true', () => { @@ -112,21 +112,21 @@ test('has mdc drawer class', () => { test('#adapter.addClass should update state with new className', () => { const wrapper = mount(); - getAdapter(wrapper.instance().foundation).addClass('test-class'); + getAdapter(wrapper.instance().foundation!).addClass('test-class'); assert.isTrue(wrapper.state().classList.has('test-class')); }); test('#adapter.removeClass should update state with new className', () => { const wrapper = mount(); wrapper.setState({classList: new Set(['test-class'])}); - getAdapter(wrapper.instance().foundation).removeClass('test-class'); + getAdapter(wrapper.instance().foundation!).removeClass('test-class'); assert.isFalse(wrapper.state().classList.has('test-class')); }); test('#adapter.hasClass returns true if class is contained in classes', () => { const wrapper = mount(); wrapper.setState({classList: new Set(['test-class'])}); - assert.isTrue(getAdapter(wrapper.instance().foundation).hasClass('test-class')); + assert.isTrue(getAdapter(wrapper.instance().foundation!).hasClass('test-class')); }); test('#adapter.elementHasClass should return true when element has class', () => { @@ -149,14 +149,14 @@ test('#adapter.elementHasClass should return false when element does not have cl .childAt(0) .getDOMNode(); const hasClass = getAdapter( - wrapper.instance().foundation + wrapper.instance().foundation! ).elementHasClass(element, 'test-class'); assert.isFalse(hasClass); }); test('#adapter.saveFocus updates previousFocus', () => { const wrapper = shallow(); - getAdapter(wrapper.instance().foundation).saveFocus(); + getAdapter(wrapper.instance().foundation!).saveFocus(); assert.exists(wrapper.instance().previousFocus); }); test( @@ -180,7 +180,7 @@ test( .childAt(0) .getDOMNode()); drawerButtonElement.focus(); - getAdapter(wrapper.instance().foundation).restoreFocus(); + getAdapter(wrapper.instance().foundation!).restoreFocus(); assert.equal(focusedElement, document.activeElement); div.remove(); focusedElement.remove(); @@ -201,7 +201,7 @@ test('#adapter.focusActiveNavigationItem focuses on first list item in drawer', , options ); - getAdapter(wrapper.instance().foundation).focusActiveNavigationItem(); + getAdapter(wrapper.instance().foundation!).focusActiveNavigationItem(); assert.isTrue( document.activeElement!.classList.contains('mdc-list-item--activated') ); @@ -211,14 +211,14 @@ test('#adapter.focusActiveNavigationItem focuses on first list item in drawer', test('#adapter.notifyClose calls props.onClose', () => { const onClose = coerceForTesting<() => void>(td.func()); const wrapper = shallow(); - getAdapter(wrapper.instance().foundation).notifyClose(); + getAdapter(wrapper.instance().foundation!).notifyClose(); td.verify(onClose(), {times: 1}); }); test('#adapter.notifyOpen calls props.onOpen', () => { const onOpen = coerceForTesting<() => void>(td.func()); const wrapper = shallow(); - getAdapter(wrapper.instance().foundation).notifyOpen(); + getAdapter(wrapper.instance().foundation!).notifyOpen(); td.verify(onOpen(), {times: 1}); }); @@ -226,7 +226,7 @@ test('#adapter.trapFocus calls focusTrap.activate if modal variant', () => { const wrapper = shallow(); const activate = coerceForTesting<(activateOptions?: Pick) => void>(td.func()); wrapper.instance().focusTrap = coerceForTesting({activate}); - getAdapter(wrapper.instance().foundation).trapFocus(); + getAdapter(wrapper.instance().foundation!).trapFocus(); td.verify(activate(), {times: 1}); }); @@ -234,7 +234,7 @@ test('#adapter.releaseFocus calls focusTrap.deactivate if modal variant', () => const wrapper = shallow(); const deactivate = coerceForTesting<(deactivateOptions?: DeactivateOptions) => void>(td.func()); wrapper.instance().focusTrap = coerceForTesting({deactivate}); - getAdapter(wrapper.instance().foundation).releaseFocus(); + getAdapter(wrapper.instance().foundation!).releaseFocus(); td.verify(deactivate(), {times: 1}); }); From fb77d32a202d0ed9a7b6c6d381db8d2db6c7e172 Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Fri, 15 Mar 2019 22:36:25 -0300 Subject: [PATCH 10/11] Update attachRef function --- packages/drawer/index.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/drawer/index.tsx b/packages/drawer/index.tsx index ac1f2c0fd..6c5cad6c2 100644 --- a/packages/drawer/index.tsx +++ b/packages/drawer/index.tsx @@ -206,13 +206,15 @@ class Drawer extends React.Component { // @ts-ignore this is acceptable according to the comment above this.drawerElement.current = node; - if (innerRef !== undefined) { - if (isRefObject(innerRef)) { - // @ts-ignore same as above - innerRef.current = node; - } else { - innerRef(node); - } + if (!innerRef) { + return; + } + + if (isRefObject(innerRef)) { + // @ts-ignore same as above + innerRef.current = node; + } else { + innerRef(node); } } From aeddb732446b83581ecc0b9c0ff77761dd913969 Mon Sep 17 00:00:00 2001 From: Lucas Cordeiro Date: Mon, 18 Mar 2019 17:12:19 -0300 Subject: [PATCH 11/11] Add innerRef prop to readme --- packages/drawer/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/drawer/README.md b/packages/drawer/README.md index 0bb641e9a..99bdd0bfe 100644 --- a/packages/drawer/README.md +++ b/packages/drawer/README.md @@ -419,6 +419,7 @@ modal | Boolean | Indicates that the drawer is of type modal. dismissible | Boolean | Indicates that the drawer is of type dismissible. tag | String | Customizes the drawer tag type (default to `