From 7cb11fe1a256d85adc2a110a3b107a7ee810ded4 Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 13:39:17 +0300 Subject: [PATCH 01/14] Bump deps --- CHANGELOG.md | 4 ++ package.json | 16 ++--- yarn.lock | 189 +++++++++++++++++++++++++++------------------------ 3 files changed, 114 insertions(+), 95 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 243089d..d866c94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.0.0 +* **[ BREAKING ]** `bs-platform >=7.2.2`. +* **[ BREAKING ]** `react-intl >=4.0.0`: + # 1.1.0 * Added `createIntlCache`, `intlConfig`, `createIntl`, `RawIntlProvider`. diff --git a/package.json b/package.json index af754ee..3c032a5 100644 --- a/package.json +++ b/package.json @@ -17,19 +17,19 @@ "preversion": "yarn run clean" }, "peerDependencies": { - "bs-platform": ">=5.0.3", - "react-intl": ">=3.0.0", + "bs-platform": ">=7.2.2", + "react-intl": ">=4.0.0", "reason-react": ">=0.7.0" }, "devDependencies": { - "bs-platform": "5.2.1", - "bs-react-intl-extractor-bin": "0.7.0", + "bs-platform": "7.2.2", + "bs-react-intl-extractor-bin": "0.8.0", "bsb-js": "^1.1.7", "parcel-bundler": "1.12.4", - "react": "16.8.6", - "react-dom": "16.8.6", - "react-intl": "3.4.0", - "reason-react": "0.7.0" + "react": "16.13.1", + "react-dom": "16.13.1", + "react-intl": "4.5.2", + "reason-react": "0.8.0-dev.4" }, "repository": { "type": "git", diff --git a/yarn.lock b/yarn.lock index 88197fb..e8f1afc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -732,24 +732,38 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" -"@formatjs/intl-relativetimeformat@^4.2.1": - version "4.4.0" - resolved "https://registry.yarnpkg.com/@formatjs/intl-relativetimeformat/-/intl-relativetimeformat-4.4.0.tgz#8de1d25457cd34531c87f3fa4c7d381606f010ed" - integrity sha512-8lXOWWvoIPJR8Ak1uywE/gajBmHppfIg6a1o/fyd3t6NV7Qe+PVj7SJ5SgyRUcK3xQVA6AXpDJ7LCyjo5iOD8g== +"@formatjs/intl-displaynames@^1.2.9": + version "1.2.9" + resolved "https://registry.yarnpkg.com/@formatjs/intl-displaynames/-/intl-displaynames-1.2.9.tgz#be30523a91b3f5102fcd1754679073be6f8ee545" + integrity sha512-XQF2rHM0DaxShGtr03wt1eWBye0t8WDSvXfpby0ewSPs0n0uUjQOkyouTqFUderNuXV3aY8vpxq+pnHEkW/VNg== dependencies: - "@formatjs/intl-utils" "^1.4.0" + "@formatjs/intl-utils" "^2.2.5" -"@formatjs/intl-unified-numberformat@^2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@formatjs/intl-unified-numberformat/-/intl-unified-numberformat-2.1.0.tgz#0b8ef3bc3ebbafb40a65f09606a3fc414f1a392a" - integrity sha512-0zL5DKRe4KiaupyiwT8ckTmE1aPlb2fsR0deMGN4QVlkdCxsCDMrLykrLyrhBa9fthTDaGR4Qh+bALk/sa4Vcg== +"@formatjs/intl-listformat@^1.4.7": + version "1.4.7" + resolved "https://registry.yarnpkg.com/@formatjs/intl-listformat/-/intl-listformat-1.4.7.tgz#6529663d535ba24c1a33b26bdb4f6e0c1616466e" + integrity sha512-g0oXgMYhe7CFdH8jEUz64K7sLjo2p8tQAuGGXjcibODCsJvBV+YrC69WGmzQpJPCoeK5kxG7PXQRUO1Sr6NEfA== dependencies: - "@formatjs/intl-utils" "^1.4.0" + "@formatjs/intl-utils" "^2.2.5" -"@formatjs/intl-utils@^1.4.0": - version "1.4.0" - resolved "https://registry.yarnpkg.com/@formatjs/intl-utils/-/intl-utils-1.4.0.tgz#b59fdf78bbae9f99c500a298bf73b1945f5991f1" - integrity sha512-z5HyJumGzORM+5SpvkAlp/hu0AHDeZcUNKSmj9NjS7kWxOGZMuAdS3X1K5XiE0j5I8r8s8SIaz0IQOdMA1WFeA== +"@formatjs/intl-relativetimeformat@^4.5.15": + version "4.5.15" + resolved "https://registry.yarnpkg.com/@formatjs/intl-relativetimeformat/-/intl-relativetimeformat-4.5.15.tgz#1e31cdfc334603e380032745398186265ecc6049" + integrity sha512-DVtiHWMpwsuqPBtszOTmhv6m94RuiPN6/ltWCm6tul/lIFKotoJOvo1CkytfzWJ3ypjnfbYsfPRhvCCQTqVarQ== + dependencies: + "@formatjs/intl-utils" "^2.2.5" + +"@formatjs/intl-unified-numberformat@^3.3.6": + version "3.3.6" + resolved "https://registry.yarnpkg.com/@formatjs/intl-unified-numberformat/-/intl-unified-numberformat-3.3.6.tgz#ab69818f7568894023cb31fdb5b5c7eed62c6537" + integrity sha512-VQYswh9Pxf4kN6FQvKprAQwSJrF93eJstCDPM1HIt3c3O6NqPFWNWhZ91PLTppOV11rLYsFK11ZxiGbnLNiPTg== + dependencies: + "@formatjs/intl-utils" "^2.2.5" + +"@formatjs/intl-utils@^2.2.5": + version "2.2.5" + resolved "https://registry.yarnpkg.com/@formatjs/intl-utils/-/intl-utils-2.2.5.tgz#eaafd94df3d102ee13e54e80f992a33868a6b1e8" + integrity sha512-p7gcmazKROteL4IECCp03Qrs790fZ8tbemUAjQu0+K0AaAlK49rI1SIFFq3LzDUAqXIshV95JJhRe/yXxkal5g== "@iarna/toml@^2.2.0": version "2.2.3" @@ -818,10 +832,10 @@ "@types/react" "*" hoist-non-react-statics "^3.3.0" -"@types/invariant@^2.2.30": - version "2.2.30" - resolved "https://registry.yarnpkg.com/@types/invariant/-/invariant-2.2.30.tgz#20efa342807606ada5483731a8137cb1561e5fe9" - integrity sha512-98fB+yo7imSD2F7PF7GIpELNgtLNgo5wjivu0W5V4jx+KVVJxo6p/qN4zdzSTBWy4/sN3pPyXwnhRSD28QX+ag== +"@types/invariant@^2.2.31": + version "2.2.32" + resolved "https://registry.yarnpkg.com/@types/invariant/-/invariant-2.2.32.tgz#cf523a609062564e36e7a7dadb5089ed87da6382" + integrity sha512-WjY4WVFaehHv+TOgm+dS3UI559NvsPGFz/C0nIo7KOOdC+HeC7Y3/yLzdJYQ3+oFQaTXrOVm7cNtIgMataIDVg== "@types/prop-types@*": version "15.7.1" @@ -1240,15 +1254,15 @@ browserslist@^4.6.0, browserslist@^4.7.2: electron-to-chromium "^1.3.295" node-releases "^1.1.38" -bs-platform@5.2.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-5.2.1.tgz#3f76f6d4f4c7255296375a8104c8be332770b691" - integrity sha512-3ISP+RBC/NYILiJnphCY0W3RTYpQ11JGa2dBBLVug5fpFZ0qtSaL3ZplD8MyjNeXX2bC7xgrWfgBSn8Tc9om7Q== +bs-platform@7.2.2: + version "7.2.2" + resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-7.2.2.tgz#76fdc63e4889458ae3d257a0132107a792f2309c" + integrity sha512-PWcFfN+jCTtT/rMaHDhKh+W9RUTpaRunmSF9vbLYcrJbpgCNW6aFKAY33u0P3mLxwuhshN3b4FxqGUBPj6exZQ== -bs-react-intl-extractor-bin@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/bs-react-intl-extractor-bin/-/bs-react-intl-extractor-bin-0.7.0.tgz#501828265c2e6ef350a83637bd7c3f2c929c0a6f" - integrity sha512-GXwl7YoaITDq8I7QmwDEjHiiKbjaUPtpjB/xR8+BWasgJic7uHU75cKGd4LtlZ9SQ2YGKP8fsU4ZrxTF6P6W2w== +bs-react-intl-extractor-bin@0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/bs-react-intl-extractor-bin/-/bs-react-intl-extractor-bin-0.8.0.tgz#9231fea337fa5fbbec7c51adbdbe11808c375c73" + integrity sha512-xPvdrYposjWBBk5YjJA+RK11BV/MwCfgEVfeAhzcCetwKaUA/OMg4IvYrg2hVxWS1G6lhbIFehvzLg+zDm++Tw== bsb-js@^1.1.7: version "1.1.7" @@ -2559,6 +2573,13 @@ hoist-non-react-statics@^3.3.0: dependencies: react-is "^16.7.0" +hoist-non-react-statics@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" + integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== + dependencies: + react-is "^16.7.0" + hsl-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/hsl-regex/-/hsl-regex-1.0.0.tgz#d49330c789ed819e276a4c0d272dffa30b18fe6e" @@ -2702,30 +2723,27 @@ ini@~1.3.0: resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== -intl-format-cache@^4.2.3, intl-format-cache@^4.2.5: - version "4.2.5" - resolved "https://registry.yarnpkg.com/intl-format-cache/-/intl-format-cache-4.2.5.tgz#6319f5707cdc766ab5c196990a6e55b0df9cc70f" - integrity sha512-xvvog/4HTVhJIg5dexcs6Ji/ROlolCgtz3std23bLEmucoGPrUVrYQPTcBWR314NM9khm4JSrdOamv9SEtvCUg== +intl-format-cache@^4.2.27: + version "4.2.27" + resolved "https://registry.yarnpkg.com/intl-format-cache/-/intl-format-cache-4.2.27.tgz#d25fa83639913aec10ca5a8f9e3b6449bb0eacf2" + integrity sha512-blHXX9qBp8H6fGhQc0jHGh7j97HF0megj4rIB878iazMBdFk/tR7b3av0PJxE72TP8MycLFpeXW9vLY5cBmF4A== -intl-locales-supported@^1.6.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/intl-locales-supported/-/intl-locales-supported-1.8.0.tgz#cfec56f5ac8cbb828bd5ce3155c4392555cd5c5c" - integrity sha512-y1K5NaNM/WjwZcRy4TtRZ4kR8TCXfoPlX2MFbFGWqqYBD0jPG8liX/cU8aBzk2j5+bu1W6ztlLtOfCPAEwQc3A== - -intl-messageformat-parser@^3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/intl-messageformat-parser/-/intl-messageformat-parser-3.2.2.tgz#28cacc80a53823a28b5ecaf16b3b35d0a1d5f9d2" - integrity sha512-ax9639ST77YimAddTH/0Q9qhXuYS8ZVsoqOZinqnS90MbXaNuIq+KIdifaIndwI+lMEv3o+qNaGycXYvlh17rw== +intl-messageformat-parser@^5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/intl-messageformat-parser/-/intl-messageformat-parser-5.0.3.tgz#f281a9446b896f24a8f00ab9415019a28d59ca57" + integrity sha512-u2goKAXOJLkiHBy0zB3HTMuHhWDNFYUyPVevvUeSuacGFqe04jvyvYIJIoVgHD3RYhFJ9T+0UgT0dNbu+51TEw== + dependencies: + "@formatjs/intl-unified-numberformat" "^3.3.6" -intl-messageformat@^7.3.3: - version "7.5.0" - resolved "https://registry.yarnpkg.com/intl-messageformat/-/intl-messageformat-7.5.0.tgz#53582b6e911d4f41434e9d897b4789d2a2b2ff8e" - integrity sha512-s08OFUbRVUPTiXS8OOP06OhfehM1K4ughymhOazY4OhQMO+RiY4bnmsqRgYe7XorETg7mZnwJX1M34sJrzKoOA== +intl-messageformat@^8.3.10: + version "8.3.10" + resolved "https://registry.yarnpkg.com/intl-messageformat/-/intl-messageformat-8.3.10.tgz#4346cf6f3a525fb69f4df2f46e804bf855ea796a" + integrity sha512-0CWciO3DniD8WH0FDkxLlFGAHAYrkeGT2T5sRkrmmg1xFJV64MzgmJU0AiBHbdy/2DGyOxZlba8v6xhrHAygNQ== dependencies: - intl-format-cache "^4.2.5" - intl-messageformat-parser "^3.2.2" + intl-format-cache "^4.2.27" + intl-messageformat-parser "^5.0.3" -invariant@^2.1.1, invariant@^2.2.2: +invariant@^2.2.2: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== @@ -4306,47 +4324,47 @@ rc@^1.2.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -react-dom@16.8.6, react-dom@>=16.8.1: - version "16.8.6" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.6.tgz#71d6303f631e8b0097f56165ef608f051ff6e10f" - integrity sha512-1nL7PIq9LTL3fthPqwkvr2zY7phIPjYrT0jp4HjyEQrEROnw4dG41VVwi/wfoCneoleqrNX7iAD+pXebJZwrwA== +react-dom@16.13.1: + version "16.13.1" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.13.1.tgz#c1bd37331a0486c078ee54c4740720993b2e0e7f" + integrity sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.13.6" - -react-intl@3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/react-intl/-/react-intl-3.4.0.tgz#25986ac75b3c0073c0a7bce31ab2cb1b8bbf421c" - integrity sha512-pW+z0ngVtPzICQeBrvoxk/YOotjFjVMvqxf/q0hjfM4CLvzIWJW/7MQcOz8ujD0Agf146mYOUv0//a9JM4H6Tg== - dependencies: - "@formatjs/intl-relativetimeformat" "^4.2.1" - "@formatjs/intl-unified-numberformat" "^2.1.0" + scheduler "^0.19.1" + +react-intl@4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/react-intl/-/react-intl-4.5.2.tgz#896920103d5c0e2d17b02ce4cec0f6ac1a618e5c" + integrity sha512-QNhNDWh24VbtYmFEp81AE3Gt7zBDtnABPJ6zSIZewcoAiobyRgug9QqZFdNfNs7xb4m6H8zptQYiBPd/wDo2sw== + dependencies: + "@formatjs/intl-displaynames" "^1.2.9" + "@formatjs/intl-listformat" "^1.4.7" + "@formatjs/intl-relativetimeformat" "^4.5.15" + "@formatjs/intl-unified-numberformat" "^3.3.6" + "@formatjs/intl-utils" "^2.2.5" "@types/hoist-non-react-statics" "^3.3.1" - "@types/invariant" "^2.2.30" - hoist-non-react-statics "^3.3.0" - intl-format-cache "^4.2.3" - intl-locales-supported "^1.6.0" - intl-messageformat "^7.3.3" - intl-messageformat-parser "^3.2.2" - invariant "^2.1.1" - shallow-equal "^1.1.0" + "@types/invariant" "^2.2.31" + hoist-non-react-statics "^3.3.2" + intl-format-cache "^4.2.27" + intl-messageformat "^8.3.10" + intl-messageformat-parser "^5.0.3" + shallow-equal "^1.2.1" react-is@^16.7.0, react-is@^16.8.1: version "16.8.6" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16" integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA== -react@16.8.6, react@>=16.8.1: - version "16.8.6" - resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe" - integrity sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw== +react@16.13.1: + version "16.13.1" + resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e" + integrity sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.13.6" readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.3, readable-stream@~2.3.6: version "2.3.6" @@ -4379,13 +4397,10 @@ readdirp@^2.2.1: micromatch "^3.1.10" readable-stream "^2.0.2" -reason-react@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/reason-react/-/reason-react-0.7.0.tgz#46a975c321e81cd51310d7b1a02418ca7667b0d6" - integrity sha512-czR/f0lY5iyLCki9gwftOFF5Zs40l7ZSFmpGK/Z6hx2jBVeFDmIiXB8bAQW/cO6IvtuEt97OmsYueiuOYG9XjQ== - dependencies: - react ">=16.8.1" - react-dom ">=16.8.1" +reason-react@0.8.0-dev.4: + version "0.8.0-dev.4" + resolved "https://registry.yarnpkg.com/reason-react/-/reason-react-0.8.0-dev.4.tgz#87a5561b3e4e09c7b9d668ce30725884e9ba06e2" + integrity sha512-3O2sfahNkmFbmD9QvtSNbM2RSvgNColknnoS2bZEbKbiHEL7VV/LsJRylqD2109cDTid9cSnx72oVDh3tTzhpg== regenerate-unicode-properties@^8.1.0: version "8.1.0" @@ -4615,10 +4630,10 @@ saxes@^3.1.9: dependencies: xmlchars "^2.1.1" -scheduler@^0.13.6: - version "0.13.6" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.6.tgz#466a4ec332467b31a91b9bf74e5347072e4cd889" - integrity sha512-IWnObHt413ucAYKsD9J1QShUKkbKLQQHdxRyw73sw4FN26iWr3DY/H34xGPe4nmL1DwXyWmSWmMrA9TfQbE/XQ== +scheduler@^0.19.1: + version "0.19.1" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196" + integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" @@ -4705,10 +4720,10 @@ shallow-copy@~0.0.1: resolved "https://registry.yarnpkg.com/shallow-copy/-/shallow-copy-0.0.1.tgz#415f42702d73d810330292cc5ee86eae1a11a170" integrity sha1-QV9CcC1z2BAzApLMXuhurhoRoXA= -shallow-equal@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shallow-equal/-/shallow-equal-1.2.0.tgz#fd828d2029ff4e19569db7e19e535e94e2d1f5cc" - integrity sha512-Z21pVxR4cXsfwpMKMhCEIO1PCi5sp7KEp+CmOpBQ+E8GpHwKOw2sEzk7sgblM3d/j4z4gakoWEoPcjK0VJQogA== +shallow-equal@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/shallow-equal/-/shallow-equal-1.2.1.tgz#4c16abfa56043aa20d050324efa68940b0da79da" + integrity sha512-S4vJDjHHMBaiZuT9NPb616CSmLf618jawtv3sufLl6ivK8WocjAo58cXwbRV1cgqxH0Qbv+iUt6m05eqEa2IRA== shebang-command@^1.2.0: version "1.2.0" From 2b22a9946406df29818f1ab0eb42c873c064c6bd Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 13:40:48 +0300 Subject: [PATCH 02/14] Remove ReactIntlCompat --- CHANGELOG.md | 1 + src/ReactIntlCompat.re | 749 ----------------------------------------- 2 files changed, 1 insertion(+), 749 deletions(-) delete mode 100644 src/ReactIntlCompat.re diff --git a/CHANGELOG.md b/CHANGELOG.md index d866c94..81bc5a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 2.0.0 * **[ BREAKING ]** `bs-platform >=7.2.2`. * **[ BREAKING ]** `react-intl >=4.0.0`: +* **[ BREAKING ]** Removed `ReactIntlCompat`. # 1.1.0 * Added `createIntlCache`, `intlConfig`, `createIntl`, `RawIntlProvider`. diff --git a/src/ReactIntlCompat.re b/src/ReactIntlCompat.re deleted file mode 100644 index a9eb094..0000000 --- a/src/ReactIntlCompat.re +++ /dev/null @@ -1,749 +0,0 @@ -/* Common */ -type message = { - . - "id": string, - "defaultMessage": string, -}; - -type jsonMessage = { - . - "id": string, - "defaultMessage": string, - "message": Js.nullable(string), -}; - -type jsonMessages = array(jsonMessage); - -/* addLocaleData */ -type localeData('t) = {.. "locale": string} as 't; - -[@bs.module "react-intl"] -external addLocaleData: localeData('t) => unit = "addLocaleData"; - -/* defineMessages */ -type defineMessages('m) = (. 'm) => 'm; - -[@bs.module "react-intl"] -external defineMessages: defineMessages(Js.t({..})) = "defineMessages"; - -/* Formatters */ -type localeMatcher = - | BestFitLocaleMatcher - | LookupLocaleMatcher; - -let mapReasonLocaleMatcherToJs = localeMatcher => - Js.Option.map( - (. localeMatcher) => - switch (localeMatcher) { - | BestFitLocaleMatcher => "best fit" - | LookupLocaleMatcher => "lookup" - }, - localeMatcher, - ) - |> Js.Nullable.fromOption; - -type formatMatcher = - | BestFitFormatMatcher - | BasicFormatMatcher; - -let mapReasonFormatMatcherToJs = formatMatcher => - Js.Option.map( - (. formatMatcher) => - switch (formatMatcher) { - | BestFitFormatMatcher => "best fit" - | BasicFormatMatcher => "basic" - }, - formatMatcher, - ) - |> Js.Nullable.fromOption; - -type numeralFormat = - | NumericNumeralFormat - | TwoDigitNumeralFormat; - -let mapReasonNumeralFormatToJs = numeralFormat => - Js.Option.map( - (. numeralFormat) => - switch (numeralFormat) { - | NumericNumeralFormat => "numeric" - | TwoDigitNumeralFormat => "2-digit" - }, - numeralFormat, - ) - |> Js.Nullable.fromOption; - -type textualFormat = - | NarrowTextualFormat - | ShortTextualFormat - | LongTextualFormat; - -let mapReasonTextualFormatToJs = textualFormat => - Js.Option.map( - (. textualFormat) => - switch (textualFormat) { - | NarrowTextualFormat => "narrow" - | ShortTextualFormat => "short" - | LongTextualFormat => "long" - }, - textualFormat, - ) - |> Js.Nullable.fromOption; - -type mixedFormat = - | NumericMixedFormat - | TwoDigitMixedFormat - | NarrowMixedFormat - | ShortMixedFormat - | LongMixedFormat; - -let mapReasonMixedFormatToJs = mixedFormat => - Js.Option.map( - (. mixedFormat) => - switch (mixedFormat) { - | NarrowMixedFormat => "narrow" - | ShortMixedFormat => "short" - | LongMixedFormat => "long" - | NumericMixedFormat => "numeric" - | TwoDigitMixedFormat => "2-digit" - }, - mixedFormat, - ) - |> Js.Nullable.fromOption; - -type timeZoneName = - | ShortTimeZoneName - | LongTimeZoneName; - -let mapReasonTimeZoneNameToJs = timeZoneName => - Js.Option.map( - (. timeZoneName) => - switch (timeZoneName) { - | ShortTimeZoneName => "short" - | LongTimeZoneName => "long" - }, - timeZoneName, - ) - |> Js.Nullable.fromOption; - -type dateTimeFormatOptionsRe = { - . - "localeMatcher": option(localeMatcher), - "formatMatcher": option(formatMatcher), - "timeZone": option(string), - "hour12": option(bool), - "weekday": option(textualFormat), - "era": option(textualFormat), - "year": option(numeralFormat), - "month": option(mixedFormat), - "day": option(numeralFormat), - "hour": option(numeralFormat), - "minute": option(numeralFormat), - "second": option(numeralFormat), - "timeZoneName": option(timeZoneName), - "format": option(string), -}; - -type dateTimeFormatOptionsJs = { - . - "localeMatcher": Js.nullable(string), - "formatMatcher": Js.nullable(string), - "timeZone": Js.nullable(string), - "hour12": Js.nullable(bool), - "weekday": Js.nullable(string), - "era": Js.nullable(string), - "year": Js.nullable(string), - "month": Js.nullable(string), - "day": Js.nullable(string), - "hour": Js.nullable(string), - "minute": Js.nullable(string), - "second": Js.nullable(string), - "timeZoneName": Js.nullable(string), - "format": Js.nullable(string), -}; - -let mapReasonDateTimeFormatOptionsToJs = - (options: dateTimeFormatOptionsRe): dateTimeFormatOptionsJs => { - "localeMatcher": options##localeMatcher |> mapReasonLocaleMatcherToJs, - "formatMatcher": options##formatMatcher |> mapReasonFormatMatcherToJs, - "timeZone": options##timeZone |> Js.Nullable.fromOption, - "hour12": options##hour12 |> Js.Nullable.fromOption, - "weekday": options##weekday |> mapReasonTextualFormatToJs, - "era": options##era |> mapReasonTextualFormatToJs, - "year": options##year |> mapReasonNumeralFormatToJs, - "month": options##month |> mapReasonMixedFormatToJs, - "day": options##day |> mapReasonNumeralFormatToJs, - "hour": options##hour |> mapReasonNumeralFormatToJs, - "minute": options##minute |> mapReasonNumeralFormatToJs, - "second": options##second |> mapReasonNumeralFormatToJs, - "timeZoneName": options##timeZoneName |> mapReasonTimeZoneNameToJs, - "format": options##format |> Js.Nullable.fromOption, -}; - -type relativeStyle = - | BestFitRelativeStyle - | NumericRelativeStyle; - -let mapReasonRelativeStyleToJs = relativeStyle => - Js.Option.map( - (. relativeStyle) => - switch (relativeStyle) { - | BestFitRelativeStyle => "best fit" - | NumericRelativeStyle => "numeric" - }, - relativeStyle, - ) - |> Js.Nullable.fromOption; - -type units = - | Second - | Minute - | Hour - | Day - | Month - | Year; - -let mapReasonUnitsToJs = units => - Js.Option.map( - (. units) => - switch (units) { - | Second => "second" - | Minute => "minute" - | Hour => "hour" - | Day => "day" - | Month => "month" - | Year => "year" - }, - units, - ) - |> Js.Nullable.fromOption; - -type relativeFormatOptionsRe = { - . - "style": option(relativeStyle), - "units": option(units), - "format": option(string), - "now": option(int), -}; - -type relativeFormatOptionsJs = { - . - "style": Js.nullable(string), - "units": Js.nullable(string), - "format": Js.nullable(string), - "now": Js.nullable(int), -}; - -let mapReasonRelativeFormatOptionsToJs = - (options: relativeFormatOptionsRe): relativeFormatOptionsJs => { - "style": options##style |> mapReasonRelativeStyleToJs, - "units": options##units |> mapReasonUnitsToJs, - "format": options##format |> Js.Nullable.fromOption, - "now": options##now |> Js.Nullable.fromOption, -}; - -type numberStyle = - | DecimalNumberStyle - | CurrencyNumberStyle - | PercentNumberStyle; - -let mapReasonNumberStyleToJs = numberStyle => - Js.Option.map( - (. numberStyle) => - switch (numberStyle) { - | DecimalNumberStyle => "decimal" - | CurrencyNumberStyle => "currency" - | PercentNumberStyle => "percent" - }, - numberStyle, - ) - |> Js.Nullable.fromOption; - -type currencyDisplay = - | SymbolCurrencyDisplay - | CodeCurrencyDisplay - | NameCurrencyDisplay; - -let mapReasonCurrencyDisplayToJs = currencyDisplay => - Js.Option.map( - (. currencyDisplay) => - switch (currencyDisplay) { - | SymbolCurrencyDisplay => "symbol" - | CodeCurrencyDisplay => "code" - | NameCurrencyDisplay => "name" - }, - currencyDisplay, - ) - |> Js.Nullable.fromOption; - -type numberFormatOptionsRe = { - . - "localeMatcher": option(localeMatcher), - "style": option(numberStyle), - "currency": option(string), - "currencyDisplay": option(currencyDisplay), - "useGrouping": option(bool), - "minimumIntegerDigits": option(int), - "minimumFractionDigits": option(int), - "maximumFractionDigits": option(int), - "minimumSignificantDigits": option(int), - "maximumSignificantDigits": option(int), -}; - -type numberFormatOptionsJs = { - . - "localeMatcher": Js.nullable(string), - "style": Js.nullable(string), - "currency": Js.nullable(string), - "currencyDisplay": Js.nullable(string), - "useGrouping": Js.nullable(bool), - "minimumIntegerDigits": Js.nullable(int), - "minimumFractionDigits": Js.nullable(int), - "maximumFractionDigits": Js.nullable(int), - "minimumSignificantDigits": Js.nullable(int), - "maximumSignificantDigits": Js.nullable(int), -}; - -let mapReasonNumberFormatOptionsToJs = options => { - "localeMatcher": options##localeMatcher |> mapReasonLocaleMatcherToJs, - "style": options##style |> mapReasonNumberStyleToJs, - "currency": options##currency |> Js.Nullable.fromOption, - "currencyDisplay": options##currencyDisplay |> mapReasonCurrencyDisplayToJs, - "useGrouping": options##useGrouping |> Js.Nullable.fromOption, - "minimumIntegerDigits": - options##minimumIntegerDigits |> Js.Nullable.fromOption, - "minimumFractionDigits": - options##minimumFractionDigits |> Js.Nullable.fromOption, - "maximumFractionDigits": - options##maximumFractionDigits |> Js.Nullable.fromOption, - "minimumSignificantDigits": - options##minimumSignificantDigits |> Js.Nullable.fromOption, - "maximumSignificantDigits": - options##maximumSignificantDigits |> Js.Nullable.fromOption, -}; - -type pluralStyle = - | CardinalPluralStyle - | OrdinalPluralStyle; - -let mapReasonPluralStyleToJs = pluralStyle => - Js.Option.map( - (. pluralStyle) => - switch (pluralStyle) { - | CardinalPluralStyle => "cardinal" - | OrdinalPluralStyle => "ordinal" - }, - pluralStyle, - ) - |> Js.Nullable.fromOption; - -type pluralFormatOptionsRe = {. "style": option(pluralStyle)}; - -type pluralFormatOptionsJs = {. "style": Js.nullable(string)}; - -let mapReasonPluralFormatOptionsToJs = options => { - "style": options##style |> mapReasonPluralStyleToJs, -}; - -/* Components */ -type domTag = - | Span - | Div - | H1 - | H2 - | H3 - | H4 - | H5 - | H6 - | P - | Strong - | B - | I - | Em - | Mark - | Small - | Del - | Ins - | Sub - | Sup; - -type textComponent = - | DomTag(domTag) - | ReactComponent(ReasonReact.reactClass); - -let mapDomTagToString = tag => - switch (tag) { - | Span => "span" - | Div => "div" - | P => "p" - | H1 => "h1" - | H2 => "h2" - | H3 => "h3" - | H4 => "h4" - | H5 => "h5" - | H6 => "h6" - | Strong => "strong" - | B => "b" - | I => "i" - | Em => "em" - | Mark => "mark" - | Small => "small" - | Del => "del" - | Ins => "ins" - | Sub => "sub" - | Sup => "sup" - }; - -let mapOptDomTagToString = tag => - switch (tag) { - | Some(tag) => Some(tag |> mapDomTagToString) - | None => None - }; - -let mapTextComponentToJs = textComponent => - switch (textComponent) { - | DomTag(domTag) => mapDomTagToString(domTag)->Obj.magic - | ReactComponent(reactComponent) => reactComponent->Obj.magic - }; - -let mapOptTextComponentToJs = textComponent => - textComponent->Belt.Option.map(mapTextComponentToJs); - -type errorHandler = string => unit; - -module IntlProvider = { - [@bs.module "react-intl"] - external reactClass: ReasonReact.reactClass = "IntlProvider"; - let make = - ( - ~locale: option(string)=?, - ~formats: option(Js.t({..}))=?, /* TODO */ - ~messages: option(Js.Dict.t(string))=?, - ~defaultLocale: option(string)=?, - ~defaultFormats: option(Js.t({..}))=?, /* TODO */ - ~textComponent: option(textComponent)=?, - ~initialNow: option(int)=?, - ~onError: option(errorHandler)=?, - children, - ) => - ReasonReact.wrapJsForReason( - ~reactClass, - ~props={ - "locale": locale |> Js.Nullable.fromOption, - "formats": formats |> Js.Nullable.fromOption, - "messages": messages |> Js.Nullable.fromOption, - "defaultLocale": defaultLocale |> Js.Nullable.fromOption, - "defaultFormats": defaultFormats |> Js.Nullable.fromOption, - "textComponent": - textComponent |> mapOptTextComponentToJs |> Js.Nullable.fromOption, - "initialNow": initialNow |> Js.Nullable.fromOption, - "onError": onError |> Js.Nullable.fromOption, - }, - children, - ); -}; - -type intlJs('t) = - { - . - "locale": string, - "formats": Js.t({..}), /* TODO */ - "messages": Js.Dict.t(string), - "defaultLocale": string, - "defaultFormats": Js.t({..}), /* TODO */ - "formatDate": - [@bs.meth] ( - (Js.Date.t, Js.nullable(dateTimeFormatOptionsJs)) => string - ), - "formatTime": - [@bs.meth] ( - (Js.Date.t, Js.nullable(dateTimeFormatOptionsJs)) => string - ), - "formatRelative": - [@bs.meth] ( - (Js.Date.t, Js.nullable(relativeFormatOptionsJs)) => string - ), - "formatNumber": - [@bs.meth] ((float, Js.nullable(numberFormatOptionsJs)) => string), - "formatPlural": - [@bs.meth] ((int, Js.nullable(pluralFormatOptionsJs)) => string), - "formatMessage": - [@bs.meth] ((message, Js.nullable(Js.t({..}))) => string), - "formatHTMLMessage": - [@bs.meth] ((message, Js.nullable(Js.t({..}))) => string), - "now": [@bs.meth] (unit => int), - } as 't; - -type intl('t) = { - locale: string, - formats: Js.t({..} as 't), /* TODO */ - messages: Js.Dict.t(string), - defaultLocale: string, - defaultFormats: Js.t({..} as 't), /* TODO */ - formatDate: Js.Date.t => string, - formatDateWithOptions: (dateTimeFormatOptionsRe, Js.Date.t) => string, - formatTime: Js.Date.t => string, - formatTimeWithOptions: (dateTimeFormatOptionsRe, Js.Date.t) => string, - formatRelative: Js.Date.t => string, - formatRelativeWithOptions: (relativeFormatOptionsRe, Js.Date.t) => string, - formatInt: int => string, - formatIntWithOptions: (numberFormatOptionsRe, int) => string, - formatFloat: float => string, - formatFloatWithOptions: (numberFormatOptionsRe, float) => string, - formatPlural: int => string, - formatPluralWithOptions: (pluralFormatOptionsRe, int) => string, - formatMessage: message => string, - formatMessageWithValues: (Js.t({..} as 't), message) => string, - formatHTMLMessage: message => string, - formatHTMLMessageWithValues: (Js.t({..} as 't), message) => string, - now: unit => int, -}; - -let mapIntlJsToReason = (intlJs: intlJs('t)): intl('a) => { - locale: intlJs##locale, - formats: intlJs##formats, - messages: intlJs##messages, - defaultLocale: intlJs##defaultLocale, - defaultFormats: intlJs##defaultFormats, - formatDate: value => - intlJs##formatDate(value, None |> Js.Nullable.fromOption), - formatDateWithOptions: (options, value) => - intlJs##formatDate( - value, - Some(options |> mapReasonDateTimeFormatOptionsToJs) - |> Js.Nullable.fromOption, - ), - formatTime: value => - intlJs##formatTime(value, None |> Js.Nullable.fromOption), - formatTimeWithOptions: (options, value) => - intlJs##formatTime( - value, - Some(options |> mapReasonDateTimeFormatOptionsToJs) - |> Js.Nullable.fromOption, - ), - formatRelative: value => - intlJs##formatRelative(value, None |> Js.Nullable.fromOption), - formatRelativeWithOptions: (options, value) => - intlJs##formatRelative( - value, - Some(options |> mapReasonRelativeFormatOptionsToJs) - |> Js.Nullable.fromOption, - ), - formatInt: value => - intlJs##formatNumber( - value |> float_of_int, - None |> Js.Nullable.fromOption, - ), - formatIntWithOptions: (options, value) => - intlJs##formatNumber( - value |> float_of_int, - Some(options |> mapReasonNumberFormatOptionsToJs) - |> Js.Nullable.fromOption, - ), - formatFloat: value => - intlJs##formatNumber(value, None |> Js.Nullable.fromOption), - formatFloatWithOptions: (options, value) => - intlJs##formatNumber( - value, - Some(options |> mapReasonNumberFormatOptionsToJs) - |> Js.Nullable.fromOption, - ), - formatPlural: value => - intlJs##formatPlural(value, None |> Js.Nullable.fromOption), - formatPluralWithOptions: (options, value) => - intlJs##formatPlural( - value, - Some(options |> mapReasonPluralFormatOptionsToJs) - |> Js.Nullable.fromOption, - ), - formatMessage: message => - intlJs##formatMessage(message, None |> Js.Nullable.fromOption), - formatMessageWithValues: (values, message) => - intlJs##formatMessage(message, Some(values) |> Js.Nullable.fromOption), - formatHTMLMessage: message => - intlJs##formatHTMLMessage(message, None |> Js.Nullable.fromOption), - formatHTMLMessageWithValues: (values, message) => - intlJs##formatHTMLMessage( - message, - Some(values) |> Js.Nullable.fromOption, - ), - now: () => intlJs##now(), -}; - -module IntlInjector = { - let reactClass: ReasonReact.reactClass = [%bs.raw - {| - require("react-intl").injectIntl(function(_ref) { - var intl = _ref.intl, children = _ref.children; - return children(intl); - }) - |} - ]; - let make = children => - ReasonReact.wrapJsForReason( - ~reactClass, ~props=Js.Obj.empty(), (intlJs: intlJs('t)) => - children(mapIntlJsToReason(intlJs)) - ); -}; - -module FormattedMessage = { - [@bs.module "react-intl"] - external reactClass: ReasonReact.reactClass = "FormattedMessage"; - let make = - ( - ~id: string, - ~defaultMessage: string, - ~values: option(Js.t({..}))=?, - ~tagName: option(domTag)=?, - _, - ) => - ReasonReact.wrapJsForReason( - ~reactClass, - ~props={ - "id": id, - "defaultMessage": defaultMessage, - "values": values |> Js.Nullable.fromOption, - "tagName": tagName |> mapOptDomTagToString |> Js.Nullable.fromOption, - }, - [||], - ); -}; - -/* DefinedMessage is another wrapper for FormattedMessage. - It takes the id and defaultMessage props from a passed message object. */ -module DefinedMessage = { - [@bs.module "react-intl"] - external reactClass: ReasonReact.reactClass = "FormattedMessage"; - let make = - ( - ~message: message, - ~values: option(Js.t({..}))=?, - ~tagName: option(domTag)=?, - _, - ) => - ReasonReact.wrapJsForReason( - ~reactClass, - ~props={ - "id": message##id, - "defaultMessage": message##defaultMessage, - "values": values |> Js.Nullable.fromOption, - "tagName": tagName |> mapOptDomTagToString |> Js.Nullable.fromOption, - }, - [||], - ); -}; - -module FormattedDate = { - [@bs.module "react-intl"] - external reactClass: ReasonReact.reactClass = "FormattedDate"; - let make = - ( - ~value: Js.Date.t, - ~format: option(string)=?, - ~localeMatcher: option(localeMatcher)=?, - ~formatMatcher: option(formatMatcher)=?, - ~timeZone: option(string)=?, - ~hour12: option(bool)=?, - ~weekday: option(textualFormat)=?, - ~era: option(textualFormat)=?, - ~year: option(numeralFormat)=?, - ~month: option(mixedFormat)=?, - ~day: option(numeralFormat)=?, - ~hour: option(numeralFormat)=?, - ~minute: option(numeralFormat)=?, - ~second: option(numeralFormat)=?, - ~timeZoneName: option(timeZoneName)=?, - _, - ) => - ReasonReact.wrapJsForReason( - ~reactClass, - ~props={ - "value": value, - "format": format |> Js.Nullable.fromOption, - "localeMatcher": localeMatcher |> mapReasonLocaleMatcherToJs, - "formatMatcher": formatMatcher |> mapReasonFormatMatcherToJs, - "timeZone": timeZone |> Js.Nullable.fromOption, - "hour12": hour12 |> Js.Nullable.fromOption, - "weekday": weekday |> mapReasonTextualFormatToJs, - "era": era |> mapReasonTextualFormatToJs, - "year": year |> mapReasonNumeralFormatToJs, - "month": month |> mapReasonMixedFormatToJs, - "day": day |> mapReasonNumeralFormatToJs, - "hour": hour |> mapReasonNumeralFormatToJs, - "minute": minute |> mapReasonNumeralFormatToJs, - "second": second |> mapReasonNumeralFormatToJs, - "timeZoneName": timeZoneName |> mapReasonTimeZoneNameToJs, - }, - [||], - ); -}; - -module FormattedTime = { - [@bs.module "react-intl"] - external reactClass: ReasonReact.reactClass = "FormattedTime"; - let make = - ( - ~value: Js.Date.t, - ~format: option(string)=?, - ~localeMatcher: option(localeMatcher)=?, - ~formatMatcher: option(formatMatcher)=?, - ~timeZone: option(string)=?, - ~hour12: option(bool)=?, - ~weekday: option(textualFormat)=?, - ~era: option(textualFormat)=?, - ~year: option(numeralFormat)=?, - ~month: option(mixedFormat)=?, - ~day: option(numeralFormat)=?, - ~hour: option(numeralFormat)=?, - ~minute: option(numeralFormat)=?, - ~second: option(numeralFormat)=?, - ~timeZoneName: option(timeZoneName)=?, - _, - ) => - ReasonReact.wrapJsForReason( - ~reactClass, - ~props={ - "value": value, - "format": format |> Js.Nullable.fromOption, - "localeMatcher": localeMatcher |> mapReasonLocaleMatcherToJs, - "formatMatcher": formatMatcher |> mapReasonFormatMatcherToJs, - "timeZone": timeZone |> Js.Nullable.fromOption, - "hour12": hour12 |> Js.Nullable.fromOption, - "weekday": weekday |> mapReasonTextualFormatToJs, - "era": era |> mapReasonTextualFormatToJs, - "year": year |> mapReasonNumeralFormatToJs, - "month": month |> mapReasonMixedFormatToJs, - "day": day |> mapReasonNumeralFormatToJs, - "hour": hour |> mapReasonNumeralFormatToJs, - "minute": minute |> mapReasonNumeralFormatToJs, - "second": second |> mapReasonNumeralFormatToJs, - "timeZoneName": timeZoneName |> mapReasonTimeZoneNameToJs, - }, - [||], - ); -}; - -/* Utils */ -let wrapUnicodeString = (input: string) => {j|$input|j}; - -let wrapOptUnicodeString = (input: Js.nullable(string)) => - switch (input |> Js.Nullable.toOption) { - | Some(input) => input |> wrapUnicodeString - | None => "" - }; - -let messagesArrayToDict = (translation: jsonMessages) => - translation - |> Array.fold_left( - (dict, message) => { - let unicodeMessage = message##message |> wrapOptUnicodeString; - let unicodeDefaultMessage = - message##defaultMessage |> wrapUnicodeString; - Js.Dict.set( - dict, - message##id, - unicodeMessage !== "" ? unicodeMessage : unicodeDefaultMessage, - ); - dict; - }, - Js.Dict.empty(), - ); From 8d36175dd191b957815f40676b5f870553abd683 Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 13:43:43 +0300 Subject: [PATCH 03/14] Remove FormattedHTMLMessage, Intl.formatHtmlMessage & Intl.formatHtmlMessageWithValues --- CHANGELOG.md | 1 + src/ReactIntl.re | 19 ------------------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81bc5a9..84421a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 2.0.0 * **[ BREAKING ]** `bs-platform >=7.2.2`. * **[ BREAKING ]** `react-intl >=4.0.0`: + - Removed `FormattedHTMLMessage`, `Intl.formatHTMLMessage` & `Intl.formatHtmlMessageWithValues` * **[ BREAKING ]** Removed `ReactIntlCompat`. # 1.1.0 diff --git a/src/ReactIntl.re b/src/ReactIntl.re index 38c8ec9..e845dcf 100644 --- a/src/ReactIntl.re +++ b/src/ReactIntl.re @@ -121,11 +121,6 @@ module Intl = { [@bs.send] external formatMessageWithValues: (t, message, Js.t({..})) => string = "formatMessage"; - [@bs.send] - external formatHtmlMessage: (t, message) => string = "formatHtmlMessage"; - [@bs.send] - external formatHtmlMessageWithValues: (t, message, Js.t({..})) => string = - "formatHtmlMessage"; [@bs.send] external now: (t, unit) => int = "now"; }; @@ -204,20 +199,6 @@ module FormattedMessage = { "FormattedMessage"; }; -module FormattedHTMLMessage = { - [@react.component] [@bs.module "react-intl"] - external make: - ( - ~id: string, - ~defaultMessage: string, - ~values: Js.t({..})=?, - ~tagName: string=?, - ~children: (~formattedMessage: React.element) => React.element=? - ) => - React.element = - "FormattedHTMLMessage"; -}; - module FormattedDate = { [@react.component] [@bs.module "react-intl"] external make: From af785dfef3c02b1590b9bfafbdfe8e77961e3c2e Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 13:47:22 +0300 Subject: [PATCH 04/14] Update FormattedRelativeTime & Intl.formatRelativeTime --- CHANGELOG.md | 2 ++ src/ReactIntl.re | 86 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84421a2..2f7fe31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ * **[ BREAKING ]** `bs-platform >=7.2.2`. * **[ BREAKING ]** `react-intl >=4.0.0`: - Removed `FormattedHTMLMessage`, `Intl.formatHTMLMessage` & `Intl.formatHtmlMessageWithValues` + - `FormattedRelative` has been renamed to `FormattedRelativeTime` and its API has been changed as well + - `Intl.formatRelative` has been renamed to `Intl.formatRelativeTime` and its API has been changed as well * **[ BREAKING ]** Removed `ReactIntlCompat`. # 1.1.0 diff --git a/src/ReactIntl.re b/src/ReactIntl.re index e845dcf..4ea7413 100644 --- a/src/ReactIntl.re +++ b/src/ReactIntl.re @@ -29,20 +29,17 @@ external dateTimeFormatOptions: dateTimeFormatOptions = ""; -type relativeFormatOptions; +type relativeTimeFormatOptions; [@bs.obj] -external relativeFormatOptions: +external relativeTimeFormatOptions: ( - ~style: [@bs.string] [ | [@bs.as "best fit"] `bestFit | `numeric]=?, - ~units: [@bs.string] [ | `second | `minute | `hour | `day | `month | `year] - =?, + ~numeric: [@bs.string] [ | `always | `auto]=?, + ~style: [@bs.string] [ | `long | `short | `narrow]=?, ~format: string=?, - ~now: int=?, unit ) => - relativeFormatOptions = - ""; + relativeTimeFormatOptions; type numberFormatOptions; @@ -104,11 +101,44 @@ module Intl = { (t, Js.Date.t, dateTimeFormatOptions) => string = "formatTime"; [@bs.send] - external formatRelative: (t, Js.Date.t) => string = "formatRelative"; + external formatRelativeTime: (t, float) => string = "formatRelativeTime"; + [@bs.send] + external formatRelativeTimeWithUnit: + ( + t, + float, + [@bs.string] [ + | `second + | `minute + | `hour + | `day + | `week + | `month + | `quarter + | `year + ] + ) => + string = + "formatRelativeTime"; [@bs.send] - external formatRelativeWithOptions: - (t, Js.Date.t, relativeFormatOptions) => string = - "formatRelative"; + external formatRelativeTimeWithUnitAndOptions: + ( + t, + float, + [@bs.string] [ + | `second + | `minute + | `hour + | `day + | `week + | `month + | `quarter + | `year + ], + relativeTimeFormatOptions + ) => + string = + "formatRelativeTime"; [@bs.send] external formatNumber: (t, float) => string = "formatNumber"; [@bs.send] external formatNumberWithOptions: (t, float, numberFormatOptions) => string = @@ -265,28 +295,30 @@ module FormattedTime = { "FormattedTime"; }; -module FormattedRelative = { +module FormattedRelativeTime = { [@react.component] [@bs.module "react-intl"] external make: ( - ~value: Js.Date.t, - ~style: [@bs.string] [ | [@bs.as "best fit"] `bestFit | `numeric]=?, - ~units: [@bs.string] [ - | `second - | `minute - | `hour - | `day - | `month - | `year - ] - =?, + ~value: float, + ~unit: [@bs.string] [ + | `second + | `minute + | `hour + | `day + | `week + | `month + | `quarter + | `year + ] + =?, + ~numeric: [@bs.string] [ | `always | `auto]=?, + ~style: [@bs.string] [ | `long | `short | `narrow]=?, ~format: string=?, - ~updateInterval: float=?, - ~initialNow: int=?, + ~updateIntervalInSeconds: float=?, ~children: (~formattedDate: string) => React.element=? ) => React.element = - "FormattedRelative"; + "FormattedRelativeTime"; }; module FormattedNumber = { From bb4cf4f752e80eda5a308d7036bf367f5068ca34 Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 13:47:46 +0300 Subject: [PATCH 05/14] Refmt --- src/ReactIntl.re | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ReactIntl.re b/src/ReactIntl.re index 4ea7413..e964a11 100644 --- a/src/ReactIntl.re +++ b/src/ReactIntl.re @@ -26,8 +26,7 @@ external dateTimeFormatOptions: ~format: string=?, unit ) => - dateTimeFormatOptions = - ""; + dateTimeFormatOptions; type relativeTimeFormatOptions; @@ -58,16 +57,14 @@ external numberFormatOptions: ~maximumSignificantDigits: int=?, unit ) => - numberFormatOptions = - ""; + numberFormatOptions; type pluralFormatOptions; [@bs.obj] external pluralFormatOptions: (~style: [@bs.string] [ | `cardinal | `ordinal]=?, unit) => - pluralFormatOptions = - ""; + pluralFormatOptions; type message = { . @@ -185,8 +182,7 @@ external intlConfig: ~onError: string => unit=?, unit ) => - intlConfig = - ""; + intlConfig; [@bs.module "react-intl"] external createIntl: (intlConfig, intlCache) => Intl.t = "createIntl"; From 3fe372ce177f1ba767dbaf86fc6100b401179f12 Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 14:00:42 +0300 Subject: [PATCH 06/14] Add FormattedList, Intl.formatList & Intl.formatListWithOptions --- CHANGELOG.md | 1 + src/ReactIntl.re | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f7fe31..95416df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 2.0.0 * **[ BREAKING ]** `bs-platform >=7.2.2`. * **[ BREAKING ]** `react-intl >=4.0.0`: + - Added `FormattedList`, `Intl.formatList` & `Intl.formatListWithOptions` - Removed `FormattedHTMLMessage`, `Intl.formatHTMLMessage` & `Intl.formatHtmlMessageWithValues` - `FormattedRelative` has been renamed to `FormattedRelativeTime` and its API has been changed as well - `Intl.formatRelative` has been renamed to `Intl.formatRelativeTime` and its API has been changed as well diff --git a/src/ReactIntl.re b/src/ReactIntl.re index e964a11..25eb56e 100644 --- a/src/ReactIntl.re +++ b/src/ReactIntl.re @@ -66,6 +66,17 @@ external pluralFormatOptions: (~style: [@bs.string] [ | `cardinal | `ordinal]=?, unit) => pluralFormatOptions; +type listFormatOptions; + +[@bs.obj] +external listFormatOptions: + ( + ~style: [@bs.string] [ | `long | `short | `narrow]=?, + ~_type: [@bs.string] [ | `disjunction | `conjunction | `unit]=?, + unit + ) => + listFormatOptions; + type message = { . "id": string, @@ -148,6 +159,11 @@ module Intl = { [@bs.send] external formatMessageWithValues: (t, message, Js.t({..})) => string = "formatMessage"; + [@bs.send] external formatList: (t, array(string)) => string = "formatList"; + [@bs.send] + external formatListWithOptions: + (t, array(string), listFormatOptions) => string = + "formatList"; [@bs.send] external now: (t, unit) => int = "now"; }; @@ -357,3 +373,16 @@ module FormattedPlural = { React.element = "FormattedPlural"; }; + +module FormattedList = { + [@react.component] [@bs.module "react-intl"] + external make: + ( + ~value: array(string), + ~style: [@bs.string] [ | `long | `short | `narrow]=?, + ~_type: [@bs.string] [ | `disjunction | `conjunction | `unit]=?, + ~children: (~formattedList: string) => React.element=? + ) => + React.element = + "FormattedList"; +}; From 1e95334e419df9db0f430108bb1f21a2c182981f Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 14:15:59 +0300 Subject: [PATCH 07/14] Add Intl.timeZone --- CHANGELOG.md | 1 + src/ReactIntl.re | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95416df..d579114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 2.0.0 * **[ BREAKING ]** `bs-platform >=7.2.2`. * **[ BREAKING ]** `react-intl >=4.0.0`: + - Added `Intl.timeZone` - Added `FormattedList`, `Intl.formatList` & `Intl.formatListWithOptions` - Removed `FormattedHTMLMessage`, `Intl.formatHTMLMessage` & `Intl.formatHtmlMessageWithValues` - `FormattedRelative` has been renamed to `FormattedRelativeTime` and its API has been changed as well diff --git a/src/ReactIntl.re b/src/ReactIntl.re index 25eb56e..d2172b2 100644 --- a/src/ReactIntl.re +++ b/src/ReactIntl.re @@ -94,6 +94,8 @@ module Intl = { type t; [@bs.get] external locale: t => string = "locale"; + [@bs.get] [@bs.return nullable] + external timeZone: t => option(string) = "timeZone"; [@bs.get] external formats: t => Js.t({..}) = "formats"; [@bs.get] external messages: t => Js.Dict.t(string) = "messages"; [@bs.get] external defaultLocale: t => string = "defaultLocale"; From baa1f75c769df49aa058816768fb4543e972913d Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 14:17:00 +0300 Subject: [PATCH 08/14] Remove Intl.now --- CHANGELOG.md | 1 + src/ReactIntl.re | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d579114..5bc0c72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Added `Intl.timeZone` - Added `FormattedList`, `Intl.formatList` & `Intl.formatListWithOptions` - Removed `FormattedHTMLMessage`, `Intl.formatHTMLMessage` & `Intl.formatHtmlMessageWithValues` + - Removed `Intl.now` - `FormattedRelative` has been renamed to `FormattedRelativeTime` and its API has been changed as well - `Intl.formatRelative` has been renamed to `Intl.formatRelativeTime` and its API has been changed as well * **[ BREAKING ]** Removed `ReactIntlCompat`. diff --git a/src/ReactIntl.re b/src/ReactIntl.re index d2172b2..83026c6 100644 --- a/src/ReactIntl.re +++ b/src/ReactIntl.re @@ -166,7 +166,6 @@ module Intl = { external formatListWithOptions: (t, array(string), listFormatOptions) => string = "formatList"; - [@bs.send] external now: (t, unit) => int = "now"; }; [@bs.val] [@bs.module "react-intl"] From 12949c0a1cd48a0d60943e27e3f4d83c8a60fb7d Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 14:44:08 +0300 Subject: [PATCH 09/14] Add FormattedDisplayName, Intl.formatDisplayName & Intl.formatDisplayNameWithOptions --- CHANGELOG.md | 1 + src/ReactIntl.re | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bc0c72..3e5787a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * **[ BREAKING ]** `react-intl >=4.0.0`: - Added `Intl.timeZone` - Added `FormattedList`, `Intl.formatList` & `Intl.formatListWithOptions` + - Added `FormattedDisplayName`, `Intl.formatDisplayName` & `Intl.formatDisplayNameWithOptions` - Removed `FormattedHTMLMessage`, `Intl.formatHTMLMessage` & `Intl.formatHtmlMessageWithValues` - Removed `Intl.now` - `FormattedRelative` has been renamed to `FormattedRelativeTime` and its API has been changed as well diff --git a/src/ReactIntl.re b/src/ReactIntl.re index 83026c6..6d44783 100644 --- a/src/ReactIntl.re +++ b/src/ReactIntl.re @@ -77,6 +77,18 @@ external listFormatOptions: ) => listFormatOptions; +type displayNameFormatOptions; + +[@bs.obj] +external displayNameFormatOptions: + ( + ~style: [@bs.string] [ | `long | `short | `narrow]=?, + ~_type: [@bs.string] [ | `language | `region | `script | `currency]=?, + ~fallback: [@bs.string] [ | `code | `none]=?, + unit + ) => + displayNameFormatOptions; + type message = { . "id": string, @@ -166,6 +178,12 @@ module Intl = { external formatListWithOptions: (t, array(string), listFormatOptions) => string = "formatList"; + [@bs.send] + external formatDisplayName: (t, string) => string = "formatDisplayName"; + [@bs.send] + external formatDisplayNameWithOptions: + (t, string, displayNameFormatOptions) => string = + "formatDisplayName"; }; [@bs.val] [@bs.module "react-intl"] @@ -387,3 +405,16 @@ module FormattedList = { React.element = "FormattedList"; }; + +module FormattedDisplayName = { + [@react.component] [@bs.module "react-intl"] + external make: + ( + ~value: string, + ~style: [@bs.string] [ | `long | `short | `narrow]=?, + ~_type: [@bs.string] [ | `language | `region | `script | `currency]=?, + ~fallback: [@bs.string] [ | `code | `none]=? + ) => + React.element = + "FormattedDisplayName"; +}; From 07164ab4eb760373f0a5e22d046267459c205f40 Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 15:37:02 +0300 Subject: [PATCH 10/14] Add Parts API components and functions --- CHANGELOG.md | 3 ++ src/ReactIntl.re | 119 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 121 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e5787a..fe21e05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Added `Intl.timeZone` - Added `FormattedList`, `Intl.formatList` & `Intl.formatListWithOptions` - Added `FormattedDisplayName`, `Intl.formatDisplayName` & `Intl.formatDisplayNameWithOptions` + - Added `FormattedDateParts`, `Intl.formatDateToParts` & `Intl.formatDateToPartsWithOptions` + - Added `FormattedTimeParts`, `Intl.formatTimeToParts` & `Intl.formatTimeToPartsWithOptions` + - Added `FormattedNumberParts`, `Intl.formatNumberToParts` & `Intl.formatNumberToPartsWithOptions` - Removed `FormattedHTMLMessage`, `Intl.formatHTMLMessage` & `Intl.formatHtmlMessageWithValues` - Removed `Intl.now` - `FormattedRelative` has been renamed to `FormattedRelativeTime` and its API has been changed as well diff --git a/src/ReactIntl.re b/src/ReactIntl.re index 6d44783..4faa2de 100644 --- a/src/ReactIntl.re +++ b/src/ReactIntl.re @@ -102,6 +102,13 @@ type translation = { "message": Js.nullable(string), }; +module Part = { + type t; + + [@bs.get] external type_: t => string = "type"; + [@bs.get] external value: t => string = "value"; +}; + module Intl = { type t; @@ -114,15 +121,29 @@ module Intl = { [@bs.get] external defaultFormats: t => Js.t({..}) = "defaultFormats"; [@bs.send] external formatDate: (t, Js.Date.t) => string = "formatDate"; [@bs.send] + external formatDateToParts: (t, Js.Date.t) => array(Part.t) = + "formatDateToParts"; + [@bs.send] external formatDateWithOptions: (t, Js.Date.t, dateTimeFormatOptions) => string = "formatDate"; + [@bs.send] + external formatDateWithOptionsToParts: + (t, Js.Date.t, dateTimeFormatOptions) => array(Part.t) = + "formatDateToParts"; [@bs.send] external formatTime: (t, Js.Date.t) => string = "formatTime"; [@bs.send] + external formatTimeToParts: (t, Js.Date.t) => array(Part.t) = + "formatTimeToParts"; + [@bs.send] external formatTimeWithOptions: (t, Js.Date.t, dateTimeFormatOptions) => string = "formatTime"; [@bs.send] + external formatTimeWithOptionsToParts: + (t, Js.Date.t, dateTimeFormatOptions) => array(Part.t) = + "formatTimeToParts"; + [@bs.send] external formatRelativeTime: (t, float) => string = "formatRelativeTime"; [@bs.send] external formatRelativeTimeWithUnit: @@ -163,8 +184,15 @@ module Intl = { "formatRelativeTime"; [@bs.send] external formatNumber: (t, float) => string = "formatNumber"; [@bs.send] + external formatNumberToParts: (t, float) => array(Part.t) = + "formatNumberToParts"; + [@bs.send] external formatNumberWithOptions: (t, float, numberFormatOptions) => string = "formatNumber"; + [@bs.send] + external formatNumberWithOptionsToParts: + (t, float, numberFormatOptions) => array(Part.t) = + "formatNumberToParts"; [@bs.send] external formatPlural: (t, int) => string = "formatPlural"; [@bs.send] external formatPluralWithOptions: (t, int, pluralFormatOptions) => string = @@ -293,6 +321,39 @@ module FormattedDate = { "FormattedDate"; }; +module FormattedDateParts = { + [@react.component] [@bs.module "react-intl"] + external make: + ( + ~value: Js.Date.t, + ~localeMatcher: [@bs.string] [ | [@bs.as "best fit"] `bestFit | `lookup] + =?, + ~formatMatcher: [@bs.string] [ | [@bs.as "best fit"] `bestFit | `basic]=?, + ~timeZone: string=?, + ~hour12: bool=?, + ~weekday: [@bs.string] [ | `narrow | `short | `long]=?, + ~era: [@bs.string] [ | `narrow | `short | `long]=?, + ~year: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, + ~month: [@bs.string] [ + | `numeric + | [@bs.as "2-digit"] `twoDigit + | `narrow + | `short + | `long + ] + =?, + ~day: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, + ~hour: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, + ~minute: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, + ~second: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, + ~timeZoneName: [@bs.string] [ | `short | `long]=?, + ~format: string=?, + ~children: (~formattedDateParts: array(Part.t)) => React.element + ) => + React.element = + "FormattedDateParts"; +}; + module FormattedTime = { [@react.component] [@bs.module "react-intl"] external make: @@ -320,12 +381,45 @@ module FormattedTime = { ~second: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, ~timeZoneName: [@bs.string] [ | `short | `long]=?, ~format: string=?, - ~children: (~formattedDate: string) => React.element=? + ~children: (~formattedTime: string) => React.element=? ) => React.element = "FormattedTime"; }; +module FormattedTimeParts = { + [@react.component] [@bs.module "react-intl"] + external make: + ( + ~value: Js.Date.t, + ~localeMatcher: [@bs.string] [ | [@bs.as "best fit"] `bestFit | `lookup] + =?, + ~formatMatcher: [@bs.string] [ | [@bs.as "best fit"] `bestFit | `basic]=?, + ~timeZone: string=?, + ~hour12: bool=?, + ~weekday: [@bs.string] [ | `narrow | `short | `long]=?, + ~era: [@bs.string] [ | `narrow | `short | `long]=?, + ~year: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, + ~month: [@bs.string] [ + | `numeric + | [@bs.as "2-digit"] `twoDigit + | `narrow + | `short + | `long + ] + =?, + ~day: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, + ~hour: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, + ~minute: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, + ~second: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, + ~timeZoneName: [@bs.string] [ | `short | `long]=?, + ~format: string=?, + ~children: (~formattedTimeParts: array(Part.t)) => React.element + ) => + React.element = + "FormattedTimeParts"; +}; + module FormattedRelativeTime = { [@react.component] [@bs.module "react-intl"] external make: @@ -375,6 +469,29 @@ module FormattedNumber = { "FormattedNumber"; }; +module FormattedNumberParts = { + [@react.component] [@bs.module "react-intl"] + external make: + ( + ~value: float, + ~localeMatcher: [@bs.string] [ | [@bs.as "best fit"] `bestFit | `lookup] + =?, + ~style: [@bs.string] [ | `decimal | `currency | `percent]=?, + ~currency: string=?, + ~currencyDisplay: [@bs.string] [ | `symbol | `code | `name]=?, + ~useGrouping: bool=?, + ~minimumIntegerDigits: int=?, + ~minimumFractionDigits: int=?, + ~maximumFractionDigits: int=?, + ~minimumSignificantDigits: int=?, + ~maximumSignificantDigits: int=?, + ~format: string=?, + ~children: (~formattedNumberParts: array(Part.t)) => React.element + ) => + React.element = + "FormattedNumberParts"; +}; + module FormattedPlural = { [@react.component] [@bs.module "react-intl"] external make: From 1b2174e2e9ebb4060242d45ea22fe50018b28dac Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 15:37:20 +0300 Subject: [PATCH 11/14] Add HTML example --- examples/Page.re | 12 ++++++++++++ examples/translations/en.json | 5 +++++ examples/translations/ru.json | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/examples/Page.re b/examples/Page.re index 6c1302f..c4cd5ff 100644 --- a/examples/Page.re +++ b/examples/Page.re @@ -33,5 +33,17 @@ let make = (~locale, ~setLocale) => { " (FormattedDate)"->React.string +
+ text , + "italic": text => text , + "combined": (italicBold, text) => + italicBold text , + } + /> +
; }; diff --git a/examples/translations/en.json b/examples/translations/en.json index b1ab32d..a579059 100644 --- a/examples/translations/en.json +++ b/examples/translations/en.json @@ -4,6 +4,11 @@ "defaultMessage": "Hello", "message": "" }, + { + "id": "page.html", + "defaultMessage": "HTML example: bold text, italic bold text", + "message": "" + }, { "id": "page.today", "defaultMessage": "Today is", diff --git a/examples/translations/ru.json b/examples/translations/ru.json index e8cf66c..9ef13e9 100644 --- a/examples/translations/ru.json +++ b/examples/translations/ru.json @@ -4,6 +4,11 @@ "defaultMessage": "Hello", "message": "Привет" }, + { + "id": "page.html", + "defaultMessage": "HTML example: bold text, italic bold text", + "message": "Пример HTML: полужирный текст, полужирный курсивный текст" + }, { "id": "page.today", "defaultMessage": "Today is", From 9f1a16b8952ce142cd4bb0fece75046a45d1081b Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Tue, 5 May 2020 15:46:23 +0300 Subject: [PATCH 12/14] v2.0.0-beta.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3c032a5..6c5249e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bs-react-intl", - "version": "1.1.0", + "version": "2.0.0-beta.1", "description": "BuckleScript bindings to react-intl", "author": "Alex Fedoseev ", "license": "MIT", From e699b90fae146909746d39ef45bdba9f2fb7624c Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Sun, 10 May 2020 11:58:49 +0300 Subject: [PATCH 13/14] Update `part` type --- src/ReactIntl.re | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/ReactIntl.re b/src/ReactIntl.re index 4faa2de..bb9bc2d 100644 --- a/src/ReactIntl.re +++ b/src/ReactIntl.re @@ -102,11 +102,10 @@ type translation = { "message": Js.nullable(string), }; -module Part = { - type t; - - [@bs.get] external type_: t => string = "type"; - [@bs.get] external value: t => string = "value"; +type part = { + [@bs.as "type"] + type_: string, + value: string, }; module Intl = { @@ -121,7 +120,7 @@ module Intl = { [@bs.get] external defaultFormats: t => Js.t({..}) = "defaultFormats"; [@bs.send] external formatDate: (t, Js.Date.t) => string = "formatDate"; [@bs.send] - external formatDateToParts: (t, Js.Date.t) => array(Part.t) = + external formatDateToParts: (t, Js.Date.t) => array(part) = "formatDateToParts"; [@bs.send] external formatDateWithOptions: @@ -129,11 +128,11 @@ module Intl = { "formatDate"; [@bs.send] external formatDateWithOptionsToParts: - (t, Js.Date.t, dateTimeFormatOptions) => array(Part.t) = + (t, Js.Date.t, dateTimeFormatOptions) => array(part) = "formatDateToParts"; [@bs.send] external formatTime: (t, Js.Date.t) => string = "formatTime"; [@bs.send] - external formatTimeToParts: (t, Js.Date.t) => array(Part.t) = + external formatTimeToParts: (t, Js.Date.t) => array(part) = "formatTimeToParts"; [@bs.send] external formatTimeWithOptions: @@ -141,7 +140,7 @@ module Intl = { "formatTime"; [@bs.send] external formatTimeWithOptionsToParts: - (t, Js.Date.t, dateTimeFormatOptions) => array(Part.t) = + (t, Js.Date.t, dateTimeFormatOptions) => array(part) = "formatTimeToParts"; [@bs.send] external formatRelativeTime: (t, float) => string = "formatRelativeTime"; @@ -184,14 +183,14 @@ module Intl = { "formatRelativeTime"; [@bs.send] external formatNumber: (t, float) => string = "formatNumber"; [@bs.send] - external formatNumberToParts: (t, float) => array(Part.t) = + external formatNumberToParts: (t, float) => array(part) = "formatNumberToParts"; [@bs.send] external formatNumberWithOptions: (t, float, numberFormatOptions) => string = "formatNumber"; [@bs.send] external formatNumberWithOptionsToParts: - (t, float, numberFormatOptions) => array(Part.t) = + (t, float, numberFormatOptions) => array(part) = "formatNumberToParts"; [@bs.send] external formatPlural: (t, int) => string = "formatPlural"; [@bs.send] @@ -348,7 +347,7 @@ module FormattedDateParts = { ~second: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, ~timeZoneName: [@bs.string] [ | `short | `long]=?, ~format: string=?, - ~children: (~formattedDateParts: array(Part.t)) => React.element + ~children: (~formattedDateParts: array(part)) => React.element ) => React.element = "FormattedDateParts"; @@ -414,7 +413,7 @@ module FormattedTimeParts = { ~second: [@bs.string] [ | `numeric | [@bs.as "2-digit"] `twoDigit]=?, ~timeZoneName: [@bs.string] [ | `short | `long]=?, ~format: string=?, - ~children: (~formattedTimeParts: array(Part.t)) => React.element + ~children: (~formattedTimeParts: array(part)) => React.element ) => React.element = "FormattedTimeParts"; @@ -486,7 +485,7 @@ module FormattedNumberParts = { ~minimumSignificantDigits: int=?, ~maximumSignificantDigits: int=?, ~format: string=?, - ~children: (~formattedNumberParts: array(Part.t)) => React.element + ~children: (~formattedNumberParts: array(part)) => React.element ) => React.element = "FormattedNumberParts"; From 50d865dd4d26d19a03b0d71a11f99da419fe7924 Mon Sep 17 00:00:00 2001 From: Alex Fedoseev Date: Sun, 10 May 2020 12:03:36 +0300 Subject: [PATCH 14/14] Bump deps --- package.json | 6 +++--- yarn.lock | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 6c5249e..cd01de2 100644 --- a/package.json +++ b/package.json @@ -22,14 +22,14 @@ "reason-react": ">=0.7.0" }, "devDependencies": { - "bs-platform": "7.2.2", + "bs-platform": "7.3.2", "bs-react-intl-extractor-bin": "0.8.0", "bsb-js": "^1.1.7", "parcel-bundler": "1.12.4", "react": "16.13.1", "react-dom": "16.13.1", - "react-intl": "4.5.2", - "reason-react": "0.8.0-dev.4" + "react-intl": "4.5.3", + "reason-react": "0.8.0" }, "repository": { "type": "git", diff --git a/yarn.lock b/yarn.lock index e8f1afc..e84ec6c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1254,10 +1254,10 @@ browserslist@^4.6.0, browserslist@^4.7.2: electron-to-chromium "^1.3.295" node-releases "^1.1.38" -bs-platform@7.2.2: - version "7.2.2" - resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-7.2.2.tgz#76fdc63e4889458ae3d257a0132107a792f2309c" - integrity sha512-PWcFfN+jCTtT/rMaHDhKh+W9RUTpaRunmSF9vbLYcrJbpgCNW6aFKAY33u0P3mLxwuhshN3b4FxqGUBPj6exZQ== +bs-platform@7.3.2: + version "7.3.2" + resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-7.3.2.tgz#301f5c9b4e8cf5713cb60ca22e145e56e793affe" + integrity sha512-seJL5g4anK9la4erv+B2o2sMHQCxDF6OCRl9en3hbaUos/S3JsusQ0sPp4ORsbx5eXfHLYBwPljwKXlgpXtsgQ== bs-react-intl-extractor-bin@0.8.0: version "0.8.0" @@ -4334,10 +4334,10 @@ react-dom@16.13.1: prop-types "^15.6.2" scheduler "^0.19.1" -react-intl@4.5.2: - version "4.5.2" - resolved "https://registry.yarnpkg.com/react-intl/-/react-intl-4.5.2.tgz#896920103d5c0e2d17b02ce4cec0f6ac1a618e5c" - integrity sha512-QNhNDWh24VbtYmFEp81AE3Gt7zBDtnABPJ6zSIZewcoAiobyRgug9QqZFdNfNs7xb4m6H8zptQYiBPd/wDo2sw== +react-intl@4.5.3: + version "4.5.3" + resolved "https://registry.yarnpkg.com/react-intl/-/react-intl-4.5.3.tgz#d24774fa20aeb1049c5d8cb04f1c8d9da0efb6a8" + integrity sha512-qx7R7bRdmmoBbHBaQCTWIui5KcMOpUWZwe7oF83x1oLf5KJ5zm4Qt9XCGF7Ki4JbYTNuUiz7QUc4IPy0HFoMGg== dependencies: "@formatjs/intl-displaynames" "^1.2.9" "@formatjs/intl-listformat" "^1.4.7" @@ -4397,10 +4397,10 @@ readdirp@^2.2.1: micromatch "^3.1.10" readable-stream "^2.0.2" -reason-react@0.8.0-dev.4: - version "0.8.0-dev.4" - resolved "https://registry.yarnpkg.com/reason-react/-/reason-react-0.8.0-dev.4.tgz#87a5561b3e4e09c7b9d668ce30725884e9ba06e2" - integrity sha512-3O2sfahNkmFbmD9QvtSNbM2RSvgNColknnoS2bZEbKbiHEL7VV/LsJRylqD2109cDTid9cSnx72oVDh3tTzhpg== +reason-react@0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/reason-react/-/reason-react-0.8.0.tgz#a55143f95a872596c92b54595e7904c03ee7c9db" + integrity sha512-97AfK3eCF6vfP8rnbq3k6GgXsZt//OiPMINTUk5luJ8W0Wt/JaYsDG6eWKP8Zx3gPpxSU1EPjB1pUm6o6fBnFA== regenerate-unicode-properties@^8.1.0: version "8.1.0"