@oanda/labs-currency-cross-table 1.0.23 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +204 -0
- package/dist/main/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js +26 -27
- package/dist/main/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/Main.js +10 -10
- package/dist/main/CurrencyCrossTableWidget/Main.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/ValidationWrapper.js +6 -6
- package/dist/main/CurrencyCrossTableWidget/ValidationWrapper.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/Cell.js +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/Cell.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/CellWithData.js +7 -7
- package/dist/main/CurrencyCrossTableWidget/components/CellWithData.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/TextCell.js +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/TextCell.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/types.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/constant.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/index.js +8 -8
- package/dist/main/CurrencyCrossTableWidget/index.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/render.js +6 -6
- package/dist/main/CurrencyCrossTableWidget/render.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/types.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/utils.js.map +1 -1
- package/dist/main/gql/types/fragment-masking.js.map +1 -1
- package/dist/main/gql/types/gql.js +1 -1
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +73 -73
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/main/gql/types/index.js.map +1 -1
- package/dist/main/gql/validateInstruments.js +4 -1
- package/dist/main/gql/validateInstruments.js.map +1 -1
- package/dist/main/translations/index.js +1 -1
- package/dist/main/translations/index.js.map +1 -1
- package/dist/main/translations/translations.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js +27 -27
- package/dist/module/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/Main.js +10 -10
- package/dist/module/CurrencyCrossTableWidget/Main.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/ValidationWrapper.js +6 -6
- package/dist/module/CurrencyCrossTableWidget/ValidationWrapper.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/Cell.js +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/Cell.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/CellWithData.js +7 -7
- package/dist/module/CurrencyCrossTableWidget/components/CellWithData.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/TextCell.js +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/TextCell.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/types.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/constant.js +1 -1
- package/dist/module/CurrencyCrossTableWidget/constant.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/index.js +1 -1
- package/dist/module/CurrencyCrossTableWidget/index.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/render.js +6 -6
- package/dist/module/CurrencyCrossTableWidget/render.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/types.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/utils.js +1 -1
- package/dist/module/CurrencyCrossTableWidget/utils.js.map +1 -1
- package/dist/module/gql/types/fragment-masking.js.map +1 -1
- package/dist/module/gql/types/gql.js +1 -1
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +73 -73
- package/dist/module/gql/types/graphql.js.map +1 -1
- package/dist/module/gql/types/index.js +2 -2
- package/dist/module/gql/types/index.js.map +1 -1
- package/dist/module/gql/validateInstruments.js +4 -1
- package/dist/module/gql/validateInstruments.js.map +1 -1
- package/dist/module/translations/index.js +1 -1
- package/dist/module/translations/index.js.map +1 -1
- package/dist/module/translations/translations.js.map +1 -1
- package/dist/types/CurrencyCrossTableWidget/CurrencyCrossTableWidget.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/Main.d.ts +2 -2
- package/dist/types/CurrencyCrossTableWidget/ValidationWrapper.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/components/Cell.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/components/CellWithData.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/components/TextCell.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/components/types.d.ts +2 -2
- package/dist/types/CurrencyCrossTableWidget/constant.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/index.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/types.d.ts +2 -2
- package/dist/types/CurrencyCrossTableWidget/utils.d.ts +3 -3
- package/dist/types/gql/types/gql.d.ts +2 -2
- package/dist/types/gql/types/index.d.ts +2 -2
- package/dist/types/translations/index.d.ts +2 -2
- package/package.json +3 -3
- package/src/CurrencyCrossTableWidget/CurrencyCrossTableWidget.tsx +28 -31
- package/src/CurrencyCrossTableWidget/Main.tsx +21 -28
- package/src/CurrencyCrossTableWidget/ValidationWrapper.tsx +28 -21
- package/src/CurrencyCrossTableWidget/components/Cell.tsx +11 -8
- package/src/CurrencyCrossTableWidget/components/CellWithData.tsx +24 -15
- package/src/CurrencyCrossTableWidget/components/TextCell.tsx +14 -9
- package/src/CurrencyCrossTableWidget/components/types.ts +3 -2
- package/src/CurrencyCrossTableWidget/constant.ts +13 -4
- package/src/CurrencyCrossTableWidget/index.ts +1 -1
- package/src/CurrencyCrossTableWidget/render.tsx +44 -30
- package/src/CurrencyCrossTableWidget/types.tsx +3 -2
- package/src/CurrencyCrossTableWidget/utils.ts +10 -7
- package/src/gql/types/fragment-masking.ts +41 -21
- package/src/gql/types/gql.ts +7 -3
- package/src/gql/types/graphql.ts +129 -47
- package/src/gql/types/index.ts +2 -2
- package/src/gql/validateInstruments.ts +4 -1
- package/src/translations/index.ts +4 -4
- package/src/translations/translations.ts +2 -1
- package/test/Main.test.tsx +25 -11
- package/test/mocks.ts +23 -14
- package/test/utils.test.ts +119 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyCrossTableWidget.js","names":["
|
|
1
|
+
{"version":3,"file":"CurrencyCrossTableWidget.js","names":["ApolloClient","InMemoryCache","WidgetProvider","WidgetWrapper","React","Division","translations","ValidationWrapper","CurrencyCrossTableWidget","_ref","graphqlUrl","liveRatesUrl","currencies","division","locale","theme","isParamError","removePadding","logoLink","client","uri","cache","divisionCode","Opt","Ogm","dataSource","createElement","withSuspense","liveRates","url","options","styling","linkArea"],"sources":["../../../src/CurrencyCrossTableWidget/CurrencyCrossTableWidget.tsx"],"sourcesContent":["import { ApolloClient, InMemoryCache } from '@apollo/client';\nimport { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport { Division } from '../gql/types/graphql';\nimport { translations } from '../translations';\nimport type { CurrencyCrossTableConfig } from './types';\nimport { ValidationWrapper } from './ValidationWrapper';\n\nconst CurrencyCrossTableWidget = ({\n graphqlUrl,\n liveRatesUrl,\n currencies,\n division,\n locale,\n theme,\n isParamError,\n removePadding,\n logoLink,\n}: CurrencyCrossTableConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n const divisionCode = division === Division.Opt ? Division.Ogm : division;\n const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';\n\n return (\n <WidgetProvider\n withSuspense\n client={client}\n liveRates={{\n url: liveRatesUrl,\n options: { divisionCode, dataSource },\n }}\n locale={locale}\n styling={{\n removePadding,\n }}\n theme={theme}\n translations={translations}\n >\n <WidgetWrapper linkArea=\"full\" logoLink={logoLink}>\n <ValidationWrapper\n currencies={currencies}\n division={division}\n isParamError={isParamError}\n />\n </WidgetWrapper>\n </WidgetProvider>\n );\n};\n\nexport { CurrencyCrossTableWidget };\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,aAAa,QAAQ,gBAAgB;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,2BAA2B;AACzE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,QAAQ,QAAQ,sBAAsB;AAC/C,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,SAASC,iBAAiB,QAAQ,qBAAqB;AAEvD,MAAMC,wBAAwB,GAAGC,IAAA,IAUD;EAAA,IAVE;IAChCC,UAAU;IACVC,YAAY;IACZC,UAAU;IACVC,QAAQ;IACRC,MAAM;IACNC,KAAK;IACLC,YAAY;IACZC,aAAa;IACbC;EACwB,CAAC,GAAAT,IAAA;EACzB,MAAMU,MAAM,GAAG,IAAInB,YAAY,CAAC;IAC9BoB,GAAG,EAAEV,UAAU;IACfW,KAAK,EAAE,IAAIpB,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMqB,YAAY,GAAGT,QAAQ,KAAKR,QAAQ,CAACkB,GAAG,GAAGlB,QAAQ,CAACmB,GAAG,GAAGX,QAAQ;EACxE,MAAMY,UAAU,GAAGH,YAAY,KAAKjB,QAAQ,CAACmB,GAAG,GAAG,KAAK,GAAG,KAAK;EAEhE,OACEpB,KAAA,CAAAsB,aAAA,CAACxB,cAAc;IACbyB,YAAY;IACZR,MAAM,EAAEA,MAAO;IACfS,SAAS,EAAE;MACTC,GAAG,EAAElB,YAAY;MACjBmB,OAAO,EAAE;QAAER,YAAY;QAAEG;MAAW;IACtC,CAAE;IACFX,MAAM,EAAEA,MAAO;IACfiB,OAAO,EAAE;MACPd;IACF,CAAE;IACFF,KAAK,EAAEA,KAAM;IACbT,YAAY,EAAEA;EAAa,GAE3BF,KAAA,CAAAsB,aAAA,CAACvB,aAAa;IAAC6B,QAAQ,EAAC,MAAM;IAACd,QAAQ,EAAEA;EAAS,GAChDd,KAAA,CAAAsB,aAAA,CAACnB,iBAAiB;IAChBK,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAEA,QAAS;IACnBG,YAAY,EAAEA;EAAa,CAC5B,CACY,CACD,CAAC;AAErB,CAAC;AAED,SAASR,wBAAwB","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { Fragment, useEffect, useState } from 'react';
|
|
2
1
|
import { useLiveRatesQuery } from '@oanda/labs-widget-common';
|
|
2
|
+
import React, { Fragment, useEffect, useState } from 'react';
|
|
3
3
|
import { CellWithData, TextCell } from './components';
|
|
4
4
|
import { divisionMapper } from './utils';
|
|
5
5
|
const Main = _ref => {
|
|
@@ -20,33 +20,33 @@ const Main = _ref => {
|
|
|
20
20
|
});
|
|
21
21
|
}, validInstruments);
|
|
22
22
|
return React.createElement("div", {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
className: "lw-w-full lw-overflow-x-auto lw-overflow-y-hidden lw-border lw-border-b-0 lw-border-solid lw-border-border-primary",
|
|
24
|
+
"data-testid": "currency-cross-table-wrapper"
|
|
25
25
|
}, React.createElement("div", {
|
|
26
26
|
className: "lw-flex lw-w-max lw-min-w-full"
|
|
27
27
|
}, React.createElement(TextCell, {
|
|
28
28
|
sticky: true
|
|
29
29
|
}), currencies.map(pair => React.createElement(TextCell, {
|
|
30
30
|
key: pair,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
hovered: pair === selectedPair,
|
|
32
|
+
label: pair
|
|
33
33
|
}))), currencies.map((currency, index, arr) => React.createElement("div", {
|
|
34
34
|
key: currency,
|
|
35
35
|
className: "lw-flex lw-w-max lw-min-w-full"
|
|
36
36
|
}, React.createElement(TextCell, {
|
|
37
|
-
|
|
37
|
+
sticky: true,
|
|
38
38
|
hovered: currency === selectedCurrency,
|
|
39
|
-
|
|
39
|
+
label: currency
|
|
40
40
|
}), arr.map(pair => React.createElement(Fragment, {
|
|
41
41
|
key: `${currency}_${pair}`
|
|
42
42
|
}, currency !== pair ? React.createElement(CellWithData, {
|
|
43
43
|
currency: currency,
|
|
44
|
-
|
|
44
|
+
division: division,
|
|
45
45
|
isValid: validInstruments.includes(`${currency}${divisionMapper(division)}${pair}`),
|
|
46
|
-
|
|
46
|
+
pair: pair,
|
|
47
47
|
setSelectedCurrency: setSelectedCurrency,
|
|
48
48
|
setSelectedPair: setSelectedPair,
|
|
49
|
-
|
|
49
|
+
target: target
|
|
50
50
|
}) : React.createElement(TextCell, {
|
|
51
51
|
emptyIndicator: true
|
|
52
52
|
}))))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["React","Fragment","useEffect","useState","
|
|
1
|
+
{"version":3,"file":"Main.js","names":["useLiveRatesQuery","React","Fragment","useEffect","useState","CellWithData","TextCell","divisionMapper","Main","_ref","currencies","validInstruments","division","selectedCurrency","setSelectedCurrency","selectedPair","setSelectedPair","target","setQuery","instruments","createElement","className","sticky","map","pair","key","hovered","label","currency","index","arr","isValid","includes","emptyIndicator"],"sources":["../../../src/CurrencyCrossTableWidget/Main.tsx"],"sourcesContent":["import { useLiveRatesQuery } from '@oanda/labs-widget-common';\nimport React, { Fragment, useEffect, useState } from 'react';\n\nimport { CellWithData, TextCell } from './components';\nimport type { MainProps } from './types';\nimport { divisionMapper } from './utils';\n\nconst Main = ({ currencies, validInstruments, division }: MainProps) => {\n const [selectedCurrency, setSelectedCurrency] = useState('');\n const [selectedPair, setSelectedPair] = useState('');\n const { target, setQuery } = useLiveRatesQuery();\n\n useEffect(() => {\n setQuery({ instruments: validInstruments });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, validInstruments);\n\n return (\n <div\n className=\"lw-w-full lw-overflow-x-auto lw-overflow-y-hidden lw-border lw-border-b-0 lw-border-solid lw-border-border-primary\"\n data-testid=\"currency-cross-table-wrapper\"\n >\n <div className=\"lw-flex lw-w-max lw-min-w-full\">\n <TextCell sticky />\n {currencies.map((pair) => (\n <TextCell key={pair} hovered={pair === selectedPair} label={pair} />\n ))}\n </div>\n {currencies.map((currency, index, arr) => (\n <div key={currency} className=\"lw-flex lw-w-max lw-min-w-full\">\n <TextCell\n sticky\n hovered={currency === selectedCurrency}\n label={currency}\n />\n {arr.map((pair) => (\n <Fragment key={`${currency}_${pair}`}>\n {currency !== pair ? (\n <CellWithData\n currency={currency}\n division={division}\n isValid={validInstruments.includes(\n `${currency}${divisionMapper(division)}${pair}`\n )}\n pair={pair}\n setSelectedCurrency={setSelectedCurrency}\n setSelectedPair={setSelectedPair}\n target={target}\n />\n ) : (\n <TextCell emptyIndicator />\n )}\n </Fragment>\n ))}\n </div>\n ))}\n </div>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,2BAA2B;AAC7D,OAAOC,KAAK,IAAIC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE5D,SAASC,YAAY,EAAEC,QAAQ,QAAQ,cAAc;AAErD,SAASC,cAAc,QAAQ,SAAS;AAExC,MAAMC,IAAI,GAAGC,IAAA,IAA2D;EAAA,IAA1D;IAAEC,UAAU;IAAEC,gBAAgB;IAAEC;EAAoB,CAAC,GAAAH,IAAA;EACjE,MAAM,CAACI,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGV,QAAQ,CAAC,EAAE,CAAC;EAC5D,MAAM,CAACW,YAAY,EAAEC,eAAe,CAAC,GAAGZ,QAAQ,CAAC,EAAE,CAAC;EACpD,MAAM;IAAEa,MAAM;IAAEC;EAAS,CAAC,GAAGlB,iBAAiB,CAAC,CAAC;EAEhDG,SAAS,CAAC,MAAM;IACde,QAAQ,CAAC;MAAEC,WAAW,EAAER;IAAiB,CAAC,CAAC;EAE7C,CAAC,EAAEA,gBAAgB,CAAC;EAEpB,OACEV,KAAA,CAAAmB,aAAA;IACEC,SAAS,EAAC,oHAAoH;IAC9H,eAAY;EAA8B,GAE1CpB,KAAA,CAAAmB,aAAA;IAAKC,SAAS,EAAC;EAAgC,GAC7CpB,KAAA,CAAAmB,aAAA,CAACd,QAAQ;IAACgB,MAAM;EAAA,CAAE,CAAC,EAClBZ,UAAU,CAACa,GAAG,CAAEC,IAAI,IACnBvB,KAAA,CAAAmB,aAAA,CAACd,QAAQ;IAACmB,GAAG,EAAED,IAAK;IAACE,OAAO,EAAEF,IAAI,KAAKT,YAAa;IAACY,KAAK,EAAEH;EAAK,CAAE,CACpE,CACE,CAAC,EACLd,UAAU,CAACa,GAAG,CAAC,CAACK,QAAQ,EAAEC,KAAK,EAAEC,GAAG,KACnC7B,KAAA,CAAAmB,aAAA;IAAKK,GAAG,EAAEG,QAAS;IAACP,SAAS,EAAC;EAAgC,GAC5DpB,KAAA,CAAAmB,aAAA,CAACd,QAAQ;IACPgB,MAAM;IACNI,OAAO,EAAEE,QAAQ,KAAKf,gBAAiB;IACvCc,KAAK,EAAEC;EAAS,CACjB,CAAC,EACDE,GAAG,CAACP,GAAG,CAAEC,IAAI,IACZvB,KAAA,CAAAmB,aAAA,CAAClB,QAAQ;IAACuB,GAAG,EAAE,GAAGG,QAAQ,IAAIJ,IAAI;EAAG,GAClCI,QAAQ,KAAKJ,IAAI,GAChBvB,KAAA,CAAAmB,aAAA,CAACf,YAAY;IACXuB,QAAQ,EAAEA,QAAS;IACnBhB,QAAQ,EAAEA,QAAS;IACnBmB,OAAO,EAAEpB,gBAAgB,CAACqB,QAAQ,CAChC,GAAGJ,QAAQ,GAAGrB,cAAc,CAACK,QAAQ,CAAC,GAAGY,IAAI,EAC/C,CAAE;IACFA,IAAI,EAAEA,IAAK;IACXV,mBAAmB,EAAEA,mBAAoB;IACzCE,eAAe,EAAEA,eAAgB;IACjCC,MAAM,EAAEA;EAAO,CAChB,CAAC,GAEFhB,KAAA,CAAAmB,aAAA,CAACd,QAAQ;IAAC2B,cAAc;EAAA,CAAE,CAEpB,CACX,CACE,CACN,CACE,CAAC;AAEV,CAAC;AAED,SAASzB,IAAI","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
|
-
import { ChartError } from '@oanda/labs-widget-common';
|
|
4
1
|
import { useSuspenseQuery } from '@apollo/client';
|
|
2
|
+
import { ChartError } from '@oanda/labs-widget-common';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import React from 'react';
|
|
5
5
|
import { validateInstruments } from '../gql/validateInstruments';
|
|
6
|
-
import { currenciesToInstruments, validCurrencies } from './utils';
|
|
7
6
|
import { Main } from './Main';
|
|
7
|
+
import { currenciesToInstruments, validCurrencies } from './utils';
|
|
8
8
|
const ValidationWrapper = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
currencies,
|
|
@@ -28,9 +28,9 @@ const ValidationWrapper = _ref => {
|
|
|
28
28
|
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
29
29
|
className: "lw-flex lw-w-full lw-text-sm lw-tracking-normal lw-text-text-primary"
|
|
30
30
|
}, !showError && React.createElement(Main, {
|
|
31
|
-
validInstruments: validInstruments,
|
|
32
31
|
currencies: currencies,
|
|
33
|
-
division: division
|
|
32
|
+
division: division,
|
|
33
|
+
validInstruments: validInstruments
|
|
34
34
|
}), showError && React.createElement("div", {
|
|
35
35
|
className: classnames('lw-flex lw-h-[250px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary')
|
|
36
36
|
}, React.createElement(ChartError, null))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationWrapper.js","names":["
|
|
1
|
+
{"version":3,"file":"ValidationWrapper.js","names":["useSuspenseQuery","ChartError","classnames","React","validateInstruments","Main","currenciesToInstruments","validCurrencies","ValidationWrapper","_ref","currencies","division","isParamError","instruments","data","error","variables","fetchPolicy","errorPolicy","validInstruments","resolveInstrumentsByDivision","map","instrument","name","showError","length","createElement","Fragment","className"],"sources":["../../../src/CurrencyCrossTableWidget/ValidationWrapper.tsx"],"sourcesContent":["import { useSuspenseQuery } from '@apollo/client';\nimport { ChartError } from '@oanda/labs-widget-common';\nimport classnames from 'classnames';\nimport React from 'react';\n\nimport type {\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables,\n} from '../gql/types/graphql';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { Main } from './Main';\nimport type { ValidationWrapperProps } from './types';\nimport { currenciesToInstruments, validCurrencies } from './utils';\n\nconst ValidationWrapper = ({\n currencies,\n division,\n isParamError,\n}: ValidationWrapperProps) => {\n const instruments = currenciesToInstruments(currencies, division);\n\n const { data, error } = useSuspenseQuery<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables\n >(validateInstruments, {\n variables: {\n instruments,\n division,\n },\n fetchPolicy: 'network-only',\n errorPolicy: 'all',\n });\n\n const validInstruments = data?.resolveInstrumentsByDivision?.map(\n (instrument) => instrument.name\n );\n const showError =\n !validCurrencies(currencies) ||\n isParamError ||\n error ||\n !validInstruments ||\n validInstruments.length === 0;\n\n return (\n <>\n <div className=\"lw-flex lw-w-full lw-text-sm lw-tracking-normal lw-text-text-primary\">\n {!showError && (\n <Main\n currencies={currencies}\n division={division}\n validInstruments={validInstruments}\n />\n )}\n {showError && (\n <div\n className={classnames(\n 'lw-flex lw-h-[250px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary'\n )}\n >\n <ChartError />\n </div>\n )}\n </div>\n </>\n );\n};\n\nexport { ValidationWrapper };\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,gBAAgB;AACjD,SAASC,UAAU,QAAQ,2BAA2B;AACtD,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,OAAO;AAMzB,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,IAAI,QAAQ,QAAQ;AAE7B,SAASC,uBAAuB,EAAEC,eAAe,QAAQ,SAAS;AAElE,MAAMC,iBAAiB,GAAGC,IAAA,IAII;EAAA,IAJH;IACzBC,UAAU;IACVC,QAAQ;IACRC;EACsB,CAAC,GAAAH,IAAA;EACvB,MAAMI,WAAW,GAAGP,uBAAuB,CAACI,UAAU,EAAEC,QAAQ,CAAC;EAEjE,MAAM;IAAEG,IAAI;IAAEC;EAAM,CAAC,GAAGf,gBAAgB,CAGtCI,mBAAmB,EAAE;IACrBY,SAAS,EAAE;MACTH,WAAW;MACXF;IACF,CAAC;IACDM,WAAW,EAAE,cAAc;IAC3BC,WAAW,EAAE;EACf,CAAC,CAAC;EAEF,MAAMC,gBAAgB,GAAGL,IAAI,EAAEM,4BAA4B,EAAEC,GAAG,CAC7DC,UAAU,IAAKA,UAAU,CAACC,IAC7B,CAAC;EACD,MAAMC,SAAS,GACb,CAACjB,eAAe,CAACG,UAAU,CAAC,IAC5BE,YAAY,IACZG,KAAK,IACL,CAACI,gBAAgB,IACjBA,gBAAgB,CAACM,MAAM,KAAK,CAAC;EAE/B,OACEtB,KAAA,CAAAuB,aAAA,CAAAvB,KAAA,CAAAwB,QAAA,QACExB,KAAA,CAAAuB,aAAA;IAAKE,SAAS,EAAC;EAAsE,GAClF,CAACJ,SAAS,IACTrB,KAAA,CAAAuB,aAAA,CAACrB,IAAI;IACHK,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAEA,QAAS;IACnBQ,gBAAgB,EAAEA;EAAiB,CACpC,CACF,EACAK,SAAS,IACRrB,KAAA,CAAAuB,aAAA;IACEE,SAAS,EAAE1B,UAAU,CACnB,mGACF;EAAE,GAEFC,KAAA,CAAAuB,aAAA,CAACzB,UAAU,MAAE,CACV,CAEJ,CACL,CAAC;AAEP,CAAC;AAED,SAASO,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cell.js","names":["
|
|
1
|
+
{"version":3,"file":"Cell.js","names":["classnames","React","CELL_EMPTY_VALUE","CELL_LOADING_VALUE","Cell","_ref","children","isError","isLoading","hovered","mouseEnterHandler","mouseLeaveHandler","createElement","className","onMouseEnter","onMouseLeave"],"sources":["../../../../src/CurrencyCrossTableWidget/components/Cell.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport React from 'react';\n\nimport { CELL_EMPTY_VALUE, CELL_LOADING_VALUE } from '../constant';\nimport type { CellProps } from './types';\n\nconst Cell = ({\n children,\n isError,\n isLoading,\n hovered,\n mouseEnterHandler,\n mouseLeaveHandler,\n}: CellProps) => (\n <div\n className={classnames(\n 'lw-flex lw-h-11 lw-min-w-[70px] lw-flex-1 lw-items-center lw-justify-center lw-border-b lw-border-r lw-border-solid lw-border-border-primary last:lw-border-r-[0px]',\n {\n 'lw-bg-border-primary lw-font-semibold lw-shadow-innerBorderBgColor':\n hovered,\n }\n )}\n onMouseEnter={mouseEnterHandler}\n onMouseLeave={mouseLeaveHandler}\n >\n {isLoading && <div className=\"lw-px-3 lw-py-3.5\">{CELL_LOADING_VALUE}</div>}\n {!isLoading && !isError && children}\n {!isLoading && isError && <span>{CELL_EMPTY_VALUE}</span>}\n </div>\n);\n\nexport { Cell };\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,aAAa;AAGlE,MAAMC,IAAI,GAAGC,IAAA;EAAA,IAAC;IACZC,QAAQ;IACRC,OAAO;IACPC,SAAS;IACTC,OAAO;IACPC,iBAAiB;IACjBC;EACS,CAAC,GAAAN,IAAA;EAAA,OACVJ,KAAA,CAAAW,aAAA;IACEC,SAAS,EAAEb,UAAU,CACnB,qKAAqK,EACrK;MACE,oEAAoE,EAClES;IACJ,CACF,CAAE;IACFK,YAAY,EAAEJ,iBAAkB;IAChCK,YAAY,EAAEJ;EAAkB,GAE/BH,SAAS,IAAIP,KAAA,CAAAW,aAAA;IAAKC,SAAS,EAAC;EAAmB,GAAEV,kBAAwB,CAAC,EAC1E,CAACK,SAAS,IAAI,CAACD,OAAO,IAAID,QAAQ,EAClC,CAACE,SAAS,IAAID,OAAO,IAAIN,KAAA,CAAAW,aAAA,eAAOV,gBAAuB,CACrD,CAAC;AAAA,CACP;AAED,SAASE,IAAI","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
1
|
import { Price, useLiveRatesMessage } from '@oanda/labs-widget-common';
|
|
3
|
-
import {
|
|
2
|
+
import React, { useState } from 'react';
|
|
4
3
|
import { divisionMapper, getBuyPrice, getPriceMovement } from '../utils';
|
|
4
|
+
import { Cell } from './Cell';
|
|
5
5
|
const CellWithData = _ref => {
|
|
6
6
|
let {
|
|
7
7
|
currency,
|
|
@@ -26,7 +26,7 @@ const CellWithData = _ref => {
|
|
|
26
26
|
buyPriceMovement: update?.askPriceMovement,
|
|
27
27
|
displayPrecision: currency === 'JPY' && !isValid ? 6 : update?.displayPrecision
|
|
28
28
|
};
|
|
29
|
-
const checkLoading =
|
|
29
|
+
const checkLoading = () => !liveRatesError && updatedRecord.buy === undefined;
|
|
30
30
|
const handleMouseEnter = () => {
|
|
31
31
|
setHovered(true);
|
|
32
32
|
setSelectedCurrency(currency);
|
|
@@ -38,14 +38,14 @@ const CellWithData = _ref => {
|
|
|
38
38
|
setSelectedPair('');
|
|
39
39
|
};
|
|
40
40
|
return React.createElement(Cell, {
|
|
41
|
-
isLoading: checkLoading('buy'),
|
|
42
|
-
isError: !!liveRatesError,
|
|
43
41
|
hovered: hovered,
|
|
42
|
+
isError: !!liveRatesError,
|
|
43
|
+
isLoading: checkLoading(),
|
|
44
44
|
mouseEnterHandler: handleMouseEnter,
|
|
45
45
|
mouseLeaveHandler: handleMouseLeave
|
|
46
46
|
}, React.createElement(Price, {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
movementIndicator: "background",
|
|
48
|
+
priceMovement: getPriceMovement(updatedRecord.buyPriceMovement, !isValid)
|
|
49
49
|
}, React.createElement("span", null, getBuyPrice(updatedRecord.buy, !isValid).toFixed(updatedRecord.displayPrecision))));
|
|
50
50
|
};
|
|
51
51
|
export { CellWithData };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellWithData.js","names":["
|
|
1
|
+
{"version":3,"file":"CellWithData.js","names":["Price","useLiveRatesMessage","React","useState","divisionMapper","getBuyPrice","getPriceMovement","Cell","CellWithData","_ref","currency","pair","isValid","target","division","setSelectedCurrency","setSelectedPair","hovered","setHovered","instrument","instrumentForUpdates","update","error","liveRatesError","updatedRecord","displayName","buy","ask","buyPriceMovement","askPriceMovement","displayPrecision","checkLoading","undefined","handleMouseEnter","handleMouseLeave","createElement","isError","isLoading","mouseEnterHandler","mouseLeaveHandler","movementIndicator","priceMovement","toFixed"],"sources":["../../../../src/CurrencyCrossTableWidget/components/CellWithData.tsx"],"sourcesContent":["import { Price, useLiveRatesMessage } from '@oanda/labs-widget-common';\nimport React, { useState } from 'react';\n\nimport { divisionMapper, getBuyPrice, getPriceMovement } from '../utils';\nimport { Cell } from './Cell';\nimport type { CellWithDataProps } from './types';\n\nconst CellWithData = ({\n currency,\n pair,\n isValid,\n target,\n division,\n setSelectedCurrency,\n setSelectedPair,\n}: CellWithDataProps) => {\n const [hovered, setHovered] = useState(false);\n\n const instrument = `${currency}${divisionMapper(division)}${pair}`;\n const instrumentForUpdates = isValid\n ? instrument\n : `${pair}${divisionMapper(division)}${currency}`;\n\n const { update, error: liveRatesError } = useLiveRatesMessage(\n instrumentForUpdates,\n target\n );\n\n const updatedRecord = {\n displayName: `${currency}/${pair}`,\n instrument,\n buy: update?.ask,\n buyPriceMovement: update?.askPriceMovement,\n displayPrecision:\n currency === 'JPY' && !isValid ? 6 : update?.displayPrecision,\n };\n\n const checkLoading = () => !liveRatesError && updatedRecord.buy === undefined;\n\n const handleMouseEnter = () => {\n setHovered(true);\n setSelectedCurrency(currency);\n setSelectedPair(pair);\n };\n\n const handleMouseLeave = () => {\n setHovered(false);\n setSelectedCurrency('');\n setSelectedPair('');\n };\n\n return (\n <Cell\n hovered={hovered}\n isError={!!liveRatesError}\n isLoading={checkLoading()}\n mouseEnterHandler={handleMouseEnter}\n mouseLeaveHandler={handleMouseLeave}\n >\n <Price\n movementIndicator=\"background\"\n priceMovement={getPriceMovement(\n updatedRecord.buyPriceMovement,\n !isValid\n )}\n >\n <span>\n {getBuyPrice(updatedRecord.buy, !isValid).toFixed(\n updatedRecord.displayPrecision\n )}\n </span>\n </Price>\n </Cell>\n );\n};\n\nexport { CellWithData };\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,mBAAmB,QAAQ,2BAA2B;AACtE,OAAOC,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AAEvC,SAASC,cAAc,EAAEC,WAAW,EAAEC,gBAAgB,QAAQ,UAAU;AACxE,SAASC,IAAI,QAAQ,QAAQ;AAG7B,MAAMC,YAAY,GAAGC,IAAA,IAQI;EAAA,IARH;IACpBC,QAAQ;IACRC,IAAI;IACJC,OAAO;IACPC,MAAM;IACNC,QAAQ;IACRC,mBAAmB;IACnBC;EACiB,CAAC,GAAAP,IAAA;EAClB,MAAM,CAACQ,OAAO,EAAEC,UAAU,CAAC,GAAGf,QAAQ,CAAC,KAAK,CAAC;EAE7C,MAAMgB,UAAU,GAAG,GAAGT,QAAQ,GAAGN,cAAc,CAACU,QAAQ,CAAC,GAAGH,IAAI,EAAE;EAClE,MAAMS,oBAAoB,GAAGR,OAAO,GAChCO,UAAU,GACV,GAAGR,IAAI,GAAGP,cAAc,CAACU,QAAQ,CAAC,GAAGJ,QAAQ,EAAE;EAEnD,MAAM;IAAEW,MAAM;IAAEC,KAAK,EAAEC;EAAe,CAAC,GAAGtB,mBAAmB,CAC3DmB,oBAAoB,EACpBP,MACF,CAAC;EAED,MAAMW,aAAa,GAAG;IACpBC,WAAW,EAAE,GAAGf,QAAQ,IAAIC,IAAI,EAAE;IAClCQ,UAAU;IACVO,GAAG,EAAEL,MAAM,EAAEM,GAAG;IAChBC,gBAAgB,EAAEP,MAAM,EAAEQ,gBAAgB;IAC1CC,gBAAgB,EACdpB,QAAQ,KAAK,KAAK,IAAI,CAACE,OAAO,GAAG,CAAC,GAAGS,MAAM,EAAES;EACjD,CAAC;EAED,MAAMC,YAAY,GAAGA,CAAA,KAAM,CAACR,cAAc,IAAIC,aAAa,CAACE,GAAG,KAAKM,SAAS;EAE7E,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;IAC7Bf,UAAU,CAAC,IAAI,CAAC;IAChBH,mBAAmB,CAACL,QAAQ,CAAC;IAC7BM,eAAe,CAACL,IAAI,CAAC;EACvB,CAAC;EAED,MAAMuB,gBAAgB,GAAGA,CAAA,KAAM;IAC7BhB,UAAU,CAAC,KAAK,CAAC;IACjBH,mBAAmB,CAAC,EAAE,CAAC;IACvBC,eAAe,CAAC,EAAE,CAAC;EACrB,CAAC;EAED,OACEd,KAAA,CAAAiC,aAAA,CAAC5B,IAAI;IACHU,OAAO,EAAEA,OAAQ;IACjBmB,OAAO,EAAE,CAAC,CAACb,cAAe;IAC1Bc,SAAS,EAAEN,YAAY,CAAC,CAAE;IAC1BO,iBAAiB,EAAEL,gBAAiB;IACpCM,iBAAiB,EAAEL;EAAiB,GAEpChC,KAAA,CAAAiC,aAAA,CAACnC,KAAK;IACJwC,iBAAiB,EAAC,YAAY;IAC9BC,aAAa,EAAEnC,gBAAgB,CAC7BkB,aAAa,CAACI,gBAAgB,EAC9B,CAAChB,OACH;EAAE,GAEFV,KAAA,CAAAiC,aAAA,eACG9B,WAAW,CAACmB,aAAa,CAACE,GAAG,EAAE,CAACd,OAAO,CAAC,CAAC8B,OAAO,CAC/ClB,aAAa,CAACM,gBAChB,CACI,CACD,CACH,CAAC;AAEX,CAAC;AAED,SAAStB,YAAY","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextCell.js","names":["
|
|
1
|
+
{"version":3,"file":"TextCell.js","names":["classnames","React","TextCell","_ref","label","emptyIndicator","hovered","sticky","createElement","className"],"sources":["../../../../src/CurrencyCrossTableWidget/components/TextCell.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport React from 'react';\n\nimport type { TextCellProps } from './types';\n\nconst TextCell = ({\n label,\n emptyIndicator,\n hovered,\n sticky,\n}: TextCellProps) => (\n <span\n className={classnames(\n 'lw-h-11 lw-min-w-[70px] lw-flex-1 lw-border-b lw-border-r lw-border-solid lw-border-border-primary lw-py-3.5 lw-text-center last:lw-border-r-[0px]',\n {\n 'lw-bg-border-primary': emptyIndicator,\n 'lw-shadow-innerBorderBgColor': emptyIndicator && hovered,\n 'lw-bg-border-primary lw-font-semibold': hovered,\n 'lw-sticky lw-left-0 lw-z-10': sticky,\n 'lw-bg-bg-primary': sticky && !hovered,\n }\n )}\n >\n {label}\n </span>\n);\n\nexport { TextCell };\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,OAAO;AAIzB,MAAMC,QAAQ,GAAGC,IAAA;EAAA,IAAC;IAChBC,KAAK;IACLC,cAAc;IACdC,OAAO;IACPC;EACa,CAAC,GAAAJ,IAAA;EAAA,OACdF,KAAA,CAAAO,aAAA;IACEC,SAAS,EAAET,UAAU,CACnB,oJAAoJ,EACpJ;MACE,sBAAsB,EAAEK,cAAc;MACtC,8BAA8B,EAAEA,cAAc,IAAIC,OAAO;MACzD,uCAAuC,EAAEA,OAAO;MAChD,6BAA6B,EAAEC,MAAM;MACrC,kBAAkB,EAAEA,MAAM,IAAI,CAACD;IACjC,CACF;EAAE,GAEDF,KACG,CAAC;AAAA,CACR;AAED,SAASF,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/CurrencyCrossTableWidget/components/types.ts"],"sourcesContent":["import { LoaderSize } from '@oanda/labs-widget-common';\nimport { Division } from '../../gql/types/graphql';\n\nexport interface CellWithDataProps {\n currency: string;\n pair: string;\n isValid: boolean;\n target: EventTarget | null;\n division: Division;\n setSelectedCurrency: React.Dispatch<React.SetStateAction<string>>;\n setSelectedPair: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport interface CellProps {\n children: React.ReactNode;\n isLoading?: boolean;\n isError?: boolean;\n loaderSize?: LoaderSize;\n hovered: boolean;\n mouseEnterHandler: () => void;\n mouseLeaveHandler: () => void;\n}\n\nexport interface TextCellProps {\n label?: string;\n emptyIndicator?: boolean;\n hovered?: boolean;\n sticky?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/CurrencyCrossTableWidget/components/types.ts"],"sourcesContent":["import type { LoaderSize } from '@oanda/labs-widget-common';\n\nimport type { Division } from '../../gql/types/graphql';\n\nexport interface CellWithDataProps {\n currency: string;\n pair: string;\n isValid: boolean;\n target: EventTarget | null;\n division: Division;\n setSelectedCurrency: React.Dispatch<React.SetStateAction<string>>;\n setSelectedPair: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport interface CellProps {\n children: React.ReactNode;\n isLoading?: boolean;\n isError?: boolean;\n loaderSize?: LoaderSize;\n hovered: boolean;\n mouseEnterHandler: () => void;\n mouseLeaveHandler: () => void;\n}\n\nexport interface TextCellProps {\n label?: string;\n emptyIndicator?: boolean;\n hovered?: boolean;\n sticky?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -2,5 +2,5 @@ const MAJOR_CURRENCIES = ['EUR', 'USD', 'JPY', 'GBP', 'CHF', 'AUD', 'CAD', 'NZD'
|
|
|
2
2
|
const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';
|
|
3
3
|
const CELL_LOADING_VALUE = '...';
|
|
4
4
|
const CELL_EMPTY_VALUE = '\u2014';
|
|
5
|
-
export {
|
|
5
|
+
export { CELL_EMPTY_VALUE, CELL_LOADING_VALUE, INSTRUMENT_TOOLTIP_ID, MAJOR_CURRENCIES };
|
|
6
6
|
//# sourceMappingURL=constant.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","names":["MAJOR_CURRENCIES","INSTRUMENT_TOOLTIP_ID","CELL_LOADING_VALUE","CELL_EMPTY_VALUE"],"sources":["../../../src/CurrencyCrossTableWidget/constant.ts"],"sourcesContent":["const MAJOR_CURRENCIES = ['EUR'
|
|
1
|
+
{"version":3,"file":"constant.js","names":["MAJOR_CURRENCIES","INSTRUMENT_TOOLTIP_ID","CELL_LOADING_VALUE","CELL_EMPTY_VALUE"],"sources":["../../../src/CurrencyCrossTableWidget/constant.ts"],"sourcesContent":["const MAJOR_CURRENCIES = [\n 'EUR',\n 'USD',\n 'JPY',\n 'GBP',\n 'CHF',\n 'AUD',\n 'CAD',\n 'NZD',\n];\n\nconst INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';\n\nconst CELL_LOADING_VALUE = '...';\n\nconst CELL_EMPTY_VALUE = '\\u2014';\n\nexport {\n CELL_EMPTY_VALUE,\n CELL_LOADING_VALUE,\n INSTRUMENT_TOOLTIP_ID,\n MAJOR_CURRENCIES,\n};\n"],"mappings":"AAAA,MAAMA,gBAAgB,GAAG,CACvB,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,CACN;AAED,MAAMC,qBAAqB,GAAG,uBAAuB;AAErD,MAAMC,kBAAkB,GAAG,KAAK;AAEhC,MAAMC,gBAAgB,GAAG,QAAQ;AAEjC,SACEA,gBAAgB,EAChBD,kBAAkB,EAClBD,qBAAqB,EACrBD,gBAAgB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/CurrencyCrossTableWidget/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/CurrencyCrossTableWidget/index.ts"],"sourcesContent":["export * from './CurrencyCrossTableWidget';\nexport * from './types';\n"],"mappings":"AAAA,cAAc,4BAA4B;AAC1C,cAAc,SAAS","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { validateLocale, validateToolParams } from '@oanda/labs-widget-common';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import { validateLocale, validateToolParams } from '@oanda/labs-widget-common';
|
|
4
|
-
import { CurrencyCrossTableWidget } from './CurrencyCrossTableWidget';
|
|
5
4
|
import { Division } from '../gql/types/graphql';
|
|
5
|
+
import { CurrencyCrossTableWidget } from './CurrencyCrossTableWidget';
|
|
6
6
|
const {
|
|
7
7
|
graphqlUrl,
|
|
8
8
|
liveRatesUrl
|
|
@@ -38,13 +38,13 @@ currencyCrossTableElements.forEach(element => {
|
|
|
38
38
|
name: 'liveRatesUrl'
|
|
39
39
|
}]);
|
|
40
40
|
root.render(React.createElement(CurrencyCrossTableWidget, {
|
|
41
|
+
currencies: currencies,
|
|
42
|
+
division: division,
|
|
41
43
|
graphqlUrl: graphqlUrl,
|
|
44
|
+
isParamError: isParamError,
|
|
42
45
|
liveRatesUrl: liveRatesUrl,
|
|
43
|
-
division: division,
|
|
44
|
-
currencies: currencies,
|
|
45
46
|
locale: locale,
|
|
46
|
-
theme: mode
|
|
47
|
-
isParamError: isParamError
|
|
47
|
+
theme: mode
|
|
48
48
|
}));
|
|
49
49
|
});
|
|
50
50
|
//# sourceMappingURL=render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["
|
|
1
|
+
{"version":3,"file":"render.js","names":["validateLocale","validateToolParams","React","createRoot","Division","CurrencyCrossTableWidget","graphqlUrl","liveRatesUrl","window","widgetsConfig","currencyCrossTableElements","document","querySelectorAll","forEach","element","root","params","getAttribute","mode","currencies","division","locale","JSON","parse","isParamError","name","valueCheck","value","Object","values","includes","length","render","createElement","theme"],"sources":["../../../src/CurrencyCrossTableWidget/render.tsx"],"sourcesContent":["import type { Theme } from '@oanda/labs-widget-common';\nimport { validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { Division } from '../gql/types/graphql';\nimport { CurrencyCrossTableWidget } from './CurrencyCrossTableWidget';\n\nconst { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};\n\nconst currencyCrossTableElements = document.querySelectorAll(\n 'div[data-currency-cross-table-params]'\n);\n\ncurrencyCrossTableElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-currency-cross-table-params');\n const mode = element.getAttribute('data-mode');\n const { currencies, division, locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams(\n {\n division,\n locale,\n currencies,\n graphqlUrl,\n liveRatesUrl,\n },\n [\n {\n name: 'locale',\n valueCheck: (value: string | undefined) => validateLocale(value),\n },\n {\n name: 'division',\n valueCheck: (value: Division) =>\n Object.values(Division).includes(value),\n },\n {\n name: 'currencies',\n valueCheck: (value) =>\n (value as string[]).length > 0 && (value as string[]).length <= 8,\n },\n {\n name: 'graphqlUrl',\n },\n {\n name: 'liveRatesUrl',\n },\n ]\n );\n\n root.render(\n <CurrencyCrossTableWidget\n currencies={currencies}\n division={division}\n graphqlUrl={graphqlUrl}\n isParamError={isParamError}\n liveRatesUrl={liveRatesUrl}\n locale={locale}\n theme={mode as Theme}\n />\n );\n});\n"],"mappings":"AACA,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,2BAA2B;AAC9E,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,SAASC,QAAQ,QAAQ,sBAAsB;AAC/C,SAASC,wBAAwB,QAAQ,4BAA4B;AAErE,MAAM;EAAEC,UAAU;EAAEC;AAAa,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE/D,MAAMC,0BAA0B,GAAGC,QAAQ,CAACC,gBAAgB,CAC1D,uCACF,CAAC;AAEDF,0BAA0B,CAACG,OAAO,CAAEC,OAAO,IAAK;EAC9C,MAAMC,IAAI,GAAGZ,UAAU,CAACW,OAAO,CAAC;EAChC,MAAME,MAAM,GAAGF,OAAO,CAACG,YAAY,CAAC,kCAAkC,CAAC;EACvE,MAAMC,IAAI,GAAGJ,OAAO,CAACG,YAAY,CAAC,WAAW,CAAC;EAC9C,MAAM;IAAEE,UAAU;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACP,MAAgB,CAAC;EAErE,MAAMQ,YAAY,GAAGvB,kBAAkB,CACrC;IACEmB,QAAQ;IACRC,MAAM;IACNF,UAAU;IACVb,UAAU;IACVC;EACF,CAAC,EACD,CACE;IACEkB,IAAI,EAAE,QAAQ;IACdC,UAAU,EAAGC,KAAyB,IAAK3B,cAAc,CAAC2B,KAAK;EACjE,CAAC,EACD;IACEF,IAAI,EAAE,UAAU;IAChBC,UAAU,EAAGC,KAAe,IAC1BC,MAAM,CAACC,MAAM,CAACzB,QAAQ,CAAC,CAAC0B,QAAQ,CAACH,KAAK;EAC1C,CAAC,EACD;IACEF,IAAI,EAAE,YAAY;IAClBC,UAAU,EAAGC,KAAK,IACfA,KAAK,CAAcI,MAAM,GAAG,CAAC,IAAKJ,KAAK,CAAcI,MAAM,IAAI;EACpE,CAAC,EACD;IACEN,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE;EACR,CAAC,CAEL,CAAC;EAEDV,IAAI,CAACiB,MAAM,CACT9B,KAAA,CAAA+B,aAAA,CAAC5B,wBAAwB;IACvBc,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAEA,QAAS;IACnBd,UAAU,EAAEA,UAAW;IACvBkB,YAAY,EAAEA,YAAa;IAC3BjB,YAAY,EAAEA,YAAa;IAC3Bc,MAAM,EAAEA,MAAO;IACfa,KAAK,EAAEhB;EAAc,CACtB,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["Locale"],"sources":["../../../src/CurrencyCrossTableWidget/types.tsx"],"sourcesContent":["import { WidgetConfig } from '@oanda/labs-widget-common';\nimport { Division } from '../gql/types/graphql';\n\nexport { Locale } from '@oanda/mono-i18n';\n\nexport interface CurrencyCrossTableConfig extends WidgetConfig {\n division: Division;\n liveRatesUrl: string;\n currencies: string[];\n removePadding?: boolean;\n}\n\nexport interface ValidationWrapperProps {\n currencies: string[];\n division: Division;\n isParamError?: boolean;\n}\nexport interface MainProps {\n currencies: string[];\n validInstruments: string[];\n division: Division;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","names":["Locale"],"sources":["../../../src/CurrencyCrossTableWidget/types.tsx"],"sourcesContent":["import type { WidgetConfig } from '@oanda/labs-widget-common';\n\nimport type { Division } from '../gql/types/graphql';\n\nexport { Locale } from '@oanda/mono-i18n';\n\nexport interface CurrencyCrossTableConfig extends WidgetConfig {\n division: Division;\n liveRatesUrl: string;\n currencies: string[];\n removePadding?: boolean;\n}\n\nexport interface ValidationWrapperProps {\n currencies: string[];\n division: Division;\n isParamError?: boolean;\n}\nexport interface MainProps {\n currencies: string[];\n validInstruments: string[];\n division: Division;\n}\n"],"mappings":"AAIA,SAASA,MAAM,QAAQ,kBAAkB","ignoreList":[]}
|
|
@@ -16,5 +16,5 @@ const getBuyPrice = (price, isReversed) => {
|
|
|
16
16
|
if (price === undefined) return 0;
|
|
17
17
|
return isReversed ? 1 / price : price;
|
|
18
18
|
};
|
|
19
|
-
export {
|
|
19
|
+
export { currenciesToInstruments, divisionMapper, getBuyPrice, getPriceMovement, validCurrencies };
|
|
20
20
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["MAJOR_CURRENCIES","validCurrencies","currencies","every","currency","includes","divisionMapper","division","currenciesToInstruments","pairs","reduce","acc","cV","index","array","unique","filter","_item","idx","map","el","getPriceMovement","priceMovement","isReversed","undefined","getBuyPrice","price"],"sources":["../../../src/CurrencyCrossTableWidget/utils.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"utils.js","names":["MAJOR_CURRENCIES","validCurrencies","currencies","every","currency","includes","divisionMapper","division","currenciesToInstruments","pairs","reduce","acc","cV","index","array","unique","filter","_item","idx","map","el","getPriceMovement","priceMovement","isReversed","undefined","getBuyPrice","price"],"sources":["../../../src/CurrencyCrossTableWidget/utils.ts"],"sourcesContent":["import type { Division } from '../gql/types/graphql';\nimport { MAJOR_CURRENCIES } from './constant';\n\nconst validCurrencies = (currencies: string[]) =>\n currencies.every((currency) => MAJOR_CURRENCIES.includes(currency));\n\nconst divisionMapper = (division: Division) => (division === 'OGM' ? '' : '_');\n\nconst currenciesToInstruments = (currencies: string[], division: Division) => {\n const pairs = currencies.reduce((acc, cV, index, array) => {\n const unique = array.filter((_item, idx) => index !== idx);\n\n return [\n ...acc,\n ...unique.map((el) => `${cV}${divisionMapper(division)}${el}`),\n ];\n }, [] as string[]);\n\n return pairs;\n};\n\nconst getPriceMovement = (\n priceMovement: number | undefined,\n isReversed: boolean\n) => {\n if (priceMovement === undefined) return 0;\n\n return isReversed ? priceMovement * -1 : priceMovement;\n};\n\nconst getBuyPrice = (price: number | undefined, isReversed: boolean) => {\n if (price === undefined) return 0;\n\n return isReversed ? 1 / price : price;\n};\n\nexport {\n currenciesToInstruments,\n divisionMapper,\n getBuyPrice,\n getPriceMovement,\n validCurrencies,\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,YAAY;AAE7C,MAAMC,eAAe,GAAIC,UAAoB,IAC3CA,UAAU,CAACC,KAAK,CAAEC,QAAQ,IAAKJ,gBAAgB,CAACK,QAAQ,CAACD,QAAQ,CAAC,CAAC;AAErE,MAAME,cAAc,GAAIC,QAAkB,IAAMA,QAAQ,KAAK,KAAK,GAAG,EAAE,GAAG,GAAI;AAE9E,MAAMC,uBAAuB,GAAGA,CAACN,UAAoB,EAAEK,QAAkB,KAAK;EAC5E,MAAME,KAAK,GAAGP,UAAU,CAACQ,MAAM,CAAC,CAACC,GAAG,EAAEC,EAAE,EAAEC,KAAK,EAAEC,KAAK,KAAK;IACzD,MAAMC,MAAM,GAAGD,KAAK,CAACE,MAAM,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAKL,KAAK,KAAKK,GAAG,CAAC;IAE1D,OAAO,CACL,GAAGP,GAAG,EACN,GAAGI,MAAM,CAACI,GAAG,CAAEC,EAAE,IAAK,GAAGR,EAAE,GAAGN,cAAc,CAACC,QAAQ,CAAC,GAAGa,EAAE,EAAE,CAAC,CAC/D;EACH,CAAC,EAAE,EAAc,CAAC;EAElB,OAAOX,KAAK;AACd,CAAC;AAED,MAAMY,gBAAgB,GAAGA,CACvBC,aAAiC,EACjCC,UAAmB,KAChB;EACH,IAAID,aAAa,KAAKE,SAAS,EAAE,OAAO,CAAC;EAEzC,OAAOD,UAAU,GAAGD,aAAa,GAAG,CAAC,CAAC,GAAGA,aAAa;AACxD,CAAC;AAED,MAAMG,WAAW,GAAGA,CAACC,KAAyB,EAAEH,UAAmB,KAAK;EACtE,IAAIG,KAAK,KAAKF,SAAS,EAAE,OAAO,CAAC;EAEjC,OAAOD,UAAU,GAAG,CAAC,GAAGG,KAAK,GAAGA,KAAK;AACvC,CAAC;AAED,SACElB,uBAAuB,EACvBF,cAAc,EACdmB,WAAW,EACXJ,gBAAgB,EAChBpB,eAAe","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fragment-masking.js","names":["useFragment","_documentNode","fragmentType","makeFragmentData","data","_fragment","isFragmentReady","queryNode","fragmentNode","deferredFields","__meta__","fragDef","definitions","fragName","name","value","fields","length","every","field"],"sources":["../../../../src/gql/types/fragment-masking.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"fragment-masking.js","names":["useFragment","_documentNode","fragmentType","makeFragmentData","data","_fragment","isFragmentReady","queryNode","fragmentNode","deferredFields","__meta__","fragDef","definitions","fragName","name","value","fields","length","every","field"],"sources":["../../../../src/gql/types/fragment-masking.ts"],"sourcesContent":["import {\n ResultOf,\n DocumentTypeDecoration,\n TypedDocumentNode,\n} from '@graphql-typed-document-node/core';\nimport { FragmentDefinitionNode } from 'graphql';\nimport { Incremental } from './graphql';\n\nexport type FragmentType<\n TDocumentType extends DocumentTypeDecoration<any, any>,\n> =\n TDocumentType extends DocumentTypeDecoration<infer TType, any>\n ? [TType] extends [{ ' $fragmentName'?: infer TKey }]\n ? TKey extends string\n ? { ' $fragmentRefs'?: { [key in TKey]: TType } }\n : never\n : never\n : never;\n\n// return non-nullable if `fragmentType` is non-nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>\n): TType;\n// return nullable if `fragmentType` is nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType:\n | FragmentType<DocumentTypeDecoration<TType, any>>\n | null\n | undefined\n): TType | null | undefined;\n// return array of non-nullable if `fragmentType` is array of non-nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>\n): ReadonlyArray<TType>;\n// return array of nullable if `fragmentType` is array of nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType:\n | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>\n | null\n | undefined\n): ReadonlyArray<TType> | null | undefined;\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType:\n | FragmentType<DocumentTypeDecoration<TType, any>>\n | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>\n | null\n | undefined\n): TType | ReadonlyArray<TType> | null | undefined {\n return fragmentType as any;\n}\n\nexport function makeFragmentData<\n F extends DocumentTypeDecoration<any, any>,\n FT extends ResultOf<F>,\n>(data: FT, _fragment: F): FragmentType<F> {\n return data as FragmentType<F>;\n}\nexport function isFragmentReady<TQuery, TFrag>(\n queryNode: DocumentTypeDecoration<TQuery, any>,\n fragmentNode: TypedDocumentNode<TFrag>,\n data:\n | FragmentType<TypedDocumentNode<Incremental<TFrag>, any>>\n | null\n | undefined\n): data is FragmentType<typeof fragmentNode> {\n const deferredFields = (\n queryNode as {\n __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> };\n }\n ).__meta__?.deferredFields;\n\n if (!deferredFields) return true;\n\n const fragDef = fragmentNode.definitions[0] as\n | FragmentDefinitionNode\n | undefined;\n const fragName = fragDef?.name?.value;\n\n const fields = (fragName && deferredFields[fragName]) || [];\n return fields.length > 0 && fields.every((field) => data && field in data);\n}\n"],"mappings":"AA6CA,OAAO,SAASA,WAAWA,CACzBC,aAAiD,EACjDC,YAIa,EACoC;EACjD,OAAOA,YAAY;AACrB;AAEA,OAAO,SAASC,gBAAgBA,CAG9BC,IAAQ,EAAEC,SAAY,EAAmB;EACzC,OAAOD,IAAI;AACb;AACA,OAAO,SAASE,eAAeA,CAC7BC,SAA8C,EAC9CC,YAAsC,EACtCJ,IAGa,EAC8B;EAC3C,MAAMK,cAAc,GAClBF,SAAS,CAGTG,QAAQ,EAAED,cAAc;EAE1B,IAAI,CAACA,cAAc,EAAE,OAAO,IAAI;EAEhC,MAAME,OAAO,GAAGH,YAAY,CAACI,WAAW,CAAC,CAAC,CAE7B;EACb,MAAMC,QAAQ,GAAGF,OAAO,EAAEG,IAAI,EAAEC,KAAK;EAErC,MAAMC,MAAM,GAAIH,QAAQ,IAAIJ,cAAc,CAACI,QAAQ,CAAC,IAAK,EAAE;EAC3D,OAAOG,MAAM,CAACC,MAAM,GAAG,CAAC,IAAID,MAAM,CAACE,KAAK,CAAEC,KAAK,IAAKf,IAAI,IAAIe,KAAK,IAAIf,IAAI,CAAC;AAC5E","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as types from './graphql';
|
|
2
2
|
const documents = {
|
|
3
|
-
|
|
3
|
+
'\n query validateInstruments($instruments: [String]!, $division: Division!) {\n resolveInstrumentsByDivision(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n': types.ValidateInstrumentsDocument
|
|
4
4
|
};
|
|
5
5
|
export function graphql(source) {
|
|
6
6
|
return documents[source] ?? {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gql.js","names":["types","documents","ValidateInstrumentsDocument","graphql","source"],"sources":["../../../../src/gql/types/gql.ts"],"sourcesContent":["/* eslint-disable */\nimport * as types from './graphql';\nimport { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';\n\n/**\n * Map of all GraphQL operations in the project.\n *\n * This map has several performance disadvantages:\n * 1. It is not tree-shakeable, so it will include all operations in the project.\n * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.\n * 3. It does not support dead code elimination, so it will add unused operations.\n *\n * Therefore it is highly recommended to use the babel or swc plugin for production.\n */\nconst documents = {\n
|
|
1
|
+
{"version":3,"file":"gql.js","names":["types","documents","ValidateInstrumentsDocument","graphql","source"],"sources":["../../../../src/gql/types/gql.ts"],"sourcesContent":["/* eslint-disable */\nimport * as types from './graphql';\nimport { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';\n\n/**\n * Map of all GraphQL operations in the project.\n *\n * This map has several performance disadvantages:\n * 1. It is not tree-shakeable, so it will include all operations in the project.\n * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.\n * 3. It does not support dead code elimination, so it will add unused operations.\n *\n * Therefore it is highly recommended to use the babel or swc plugin for production.\n */\nconst documents = {\n '\\n query validateInstruments($instruments: [String]!, $division: Division!) {\\n resolveInstrumentsByDivision(instruments: $instruments, division: $division) {\\n name\\n displayName\\n }\\n }\\n':\n types.ValidateInstrumentsDocument,\n};\n\n/**\n * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n *\n *\n * @example\n * ```ts\n * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);\n * ```\n *\n * The query argument is unknown!\n * Please regenerate the types.\n */\nexport function graphql(source: string): unknown;\n\n/**\n * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n */\nexport function graphql(\n source: '\\n query validateInstruments($instruments: [String]!, $division: Division!) {\\n resolveInstrumentsByDivision(instruments: $instruments, division: $division) {\\n name\\n displayName\\n }\\n }\\n'\n): (typeof documents)['\\n query validateInstruments($instruments: [String]!, $division: Division!) {\\n resolveInstrumentsByDivision(instruments: $instruments, division: $division) {\\n name\\n displayName\\n }\\n }\\n'];\n\nexport function graphql(source: string) {\n return (documents as any)[source] ?? {};\n}\n\nexport type DocumentType<TDocumentNode extends DocumentNode<any, any>> =\n TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;\n"],"mappings":"AACA,OAAO,KAAKA,KAAK,MAAM,WAAW;AAalC,MAAMC,SAAS,GAAG;EAChB,iNAAiN,EAC/MD,KAAK,CAACE;AACV,CAAC;AAuBD,OAAO,SAASC,OAAOA,CAACC,MAAc,EAAE;EACtC,OAAQH,SAAS,CAASG,MAAM,CAAC,IAAI,CAAC,CAAC;AACzC","ignoreList":[]}
|