@ssa-ui-kit/core 2.12.0 → 2.13.0

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.
@@ -0,0 +1,16 @@
1
+ import { PlotParams } from 'react-plotly.js';
2
+ import { WidgetCardProps } from '../../WidgetCard';
3
+ import { CandlestickChartData, CandlestickStyle } from './utils';
4
+ export type CandlestickChartFeatures = 'header' | 'fullscreenMode';
5
+ export interface CandlestickChartProps extends Partial<Omit<PlotParams, 'data' | 'style'>> {
6
+ data: CandlestickChartData;
7
+ style?: CandlestickStyle;
8
+ title?: string;
9
+ features?: CandlestickChartFeatures[];
10
+ widgetCardProps?: WidgetCardProps;
11
+ }
12
+ export declare const CandlestickChartComponent: ({ title, data, features, widgetCardProps, style, ...plotParams }: CandlestickChartProps) => import("@emotion/react/jsx-runtime").JSX.Element;
13
+ export declare const CandlestickChart: {
14
+ (props: CandlestickChartProps): import("@emotion/react/jsx-runtime").JSX.Element;
15
+ displayName: string;
16
+ };
@@ -0,0 +1 @@
1
+ export * from './CandlestickChart';
@@ -0,0 +1,10 @@
1
+ import { PlotParams } from 'react-plotly.js';
2
+ export type CandlestickStyle = 'japanese' | 'hollow';
3
+ export type CandlestickChartData = {
4
+ x: string[];
5
+ close: number[];
6
+ open: number[];
7
+ high: number[];
8
+ low: number[];
9
+ };
10
+ export declare const getCandlestickPlotData: (style: CandlestickStyle, data: CandlestickChartData, increasingColor: string, decreasingColor: string) => PlotParams["data"];
@@ -7,3 +7,4 @@ export * from './hooks';
7
7
  export * from './GaugeChart';
8
8
  export * from './BarGaugeChart';
9
9
  export * from './BigNumberChart';
10
+ export * from './CandlestickChart';
@@ -1,4 +1,4 @@
1
1
  import { DropdownOptionProps } from '../DropdownOptions/types';
2
2
  import { DropdownProps } from './types';
3
- declare const Dropdown: <T extends DropdownOptionProps>({ selectedItem, isDisabled, isOpen: isInitOpen, children, onChange: handleChange, className, }: DropdownProps<T>) => import("@emotion/react/jsx-runtime").JSX.Element;
3
+ declare const Dropdown: <T extends DropdownOptionProps>({ selectedItem, isDisabled, isOpen: isInitOpen, children, onChange: handleChange, className, placeholder, }: DropdownProps<T>) => import("@emotion/react/jsx-runtime").JSX.Element;
4
4
  export default Dropdown;
package/dist/index.js CHANGED
@@ -77,6 +77,8 @@ __webpack_require__.d(__webpack_exports__, {
77
77
  BigNumberChartComponent: () => (/* reexport */ BigNumberChartComponent),
78
78
  Button: () => (/* reexport */ Button_Button),
79
79
  ButtonGroup: () => (/* reexport */ ButtonGroup),
80
+ CandlestickChart: () => (/* reexport */ CandlestickChart),
81
+ CandlestickChartComponent: () => (/* reexport */ CandlestickChartComponent),
80
82
  Card: () => (/* reexport */ Card_Card),
81
83
  CardBase: () => (/* reexport */ Card_CardBase),
82
84
  CardContent: () => (/* reexport */ CardContent_CardContent),
@@ -4366,11 +4368,11 @@ const Dropdown = ({
4366
4368
  isOpen: isInitOpen,
4367
4369
  children,
4368
4370
  onChange: handleChange,
4369
- className
4371
+ className,
4372
+ placeholder = 'Select something'
4370
4373
  }) => {
4371
4374
  const theme = (0,react_namespaceObject.useTheme)();
4372
4375
  const dropdownRef = (0,external_react_namespaceObject.useRef)(null);
4373
- const placeholder = 'Select something';
4374
4376
  const dropdownId = (0,external_react_namespaceObject.useId)();
4375
4377
  const options = [];
4376
4378
  const [isFocused, setIsFocused] = (0,external_react_namespaceObject.useState)(false);
@@ -16843,6 +16845,242 @@ const BigNumberChartComponent = ({
16843
16845
  const BigNumberChart = WithFullscreenMode(BigNumberChartComponent);
16844
16846
  ;// ./src/components/Charts/BigNumberChart/index.ts
16845
16847
 
16848
+ ;// external "react-dom/server"
16849
+ const server_namespaceObject = require("react-dom/server");
16850
+ ;// ./src/components/Charts/CandlestickChart/utils.ts
16851
+ const getCandlestickPlotData = (style, data, increasingColor, decreasingColor) => {
16852
+ if (style === 'japanese') {
16853
+ return [{
16854
+ type: 'candlestick',
16855
+ x: data.x,
16856
+ open: data.open,
16857
+ high: data.high,
16858
+ low: data.low,
16859
+ close: data.close,
16860
+ increasing: {
16861
+ line: {
16862
+ color: increasingColor
16863
+ },
16864
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16865
+ // @ts-ignore
16866
+ fillcolor: increasingColor
16867
+ },
16868
+ decreasing: {
16869
+ line: {
16870
+ color: decreasingColor
16871
+ },
16872
+ fillcolor: decreasingColor
16873
+ }
16874
+ }];
16875
+ }
16876
+ const makeEmpty = () => ({
16877
+ x: [],
16878
+ open: [],
16879
+ close: [],
16880
+ high: [],
16881
+ low: []
16882
+ });
16883
+ const greenHollow = makeEmpty();
16884
+ const greenSolid = makeEmpty();
16885
+ const redHollow = makeEmpty();
16886
+ const redSolid = makeEmpty();
16887
+ for (let i = 0; i < data.x.length; i++) {
16888
+ const open = data.open[i];
16889
+ const close = data.close[i];
16890
+ const prevClose = i > 0 ? data.close[i - 1] : open;
16891
+ const isUp = close > open;
16892
+ const isHollow = isUp;
16893
+ const isGreen = close > prevClose;
16894
+ const target = isGreen && isHollow ? greenHollow : isGreen && !isHollow ? greenSolid : !isGreen && isHollow ? redHollow : redSolid;
16895
+ target.x.push(data.x[i]);
16896
+ target.open.push(open);
16897
+ target.close.push(close);
16898
+ target.high.push(data.high[i]);
16899
+ target.low.push(data.low[i]);
16900
+ }
16901
+ return [{
16902
+ type: 'candlestick',
16903
+ name: '',
16904
+ ...greenHollow,
16905
+ increasing: {
16906
+ line: {
16907
+ color: increasingColor
16908
+ },
16909
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16910
+ // @ts-ignore
16911
+ fillcolor: 'white'
16912
+ },
16913
+ decreasing: {
16914
+ line: {
16915
+ color: increasingColor
16916
+ },
16917
+ fillcolor: 'white'
16918
+ }
16919
+ }, {
16920
+ type: 'candlestick',
16921
+ name: '',
16922
+ ...greenSolid,
16923
+ increasing: {
16924
+ line: {
16925
+ color: increasingColor
16926
+ },
16927
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16928
+ // @ts-ignore
16929
+ fillcolor: increasingColor
16930
+ },
16931
+ decreasing: {
16932
+ line: {
16933
+ color: increasingColor
16934
+ },
16935
+ fillcolor: increasingColor
16936
+ }
16937
+ }, {
16938
+ type: 'candlestick',
16939
+ name: '',
16940
+ ...redHollow,
16941
+ increasing: {
16942
+ line: {
16943
+ color: decreasingColor
16944
+ },
16945
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16946
+ // @ts-ignore
16947
+ fillcolor: 'white'
16948
+ },
16949
+ decreasing: {
16950
+ line: {
16951
+ color: decreasingColor
16952
+ },
16953
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16954
+ // @ts-ignore
16955
+ fillcolor: 'white'
16956
+ }
16957
+ }, {
16958
+ type: 'candlestick',
16959
+ name: '',
16960
+ ...redSolid,
16961
+ increasing: {
16962
+ line: {
16963
+ color: decreasingColor
16964
+ },
16965
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16966
+ // @ts-ignore
16967
+ fillcolor: decreasingColor
16968
+ },
16969
+ decreasing: {
16970
+ line: {
16971
+ color: decreasingColor
16972
+ },
16973
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16974
+ // @ts-ignore
16975
+ fillcolor: decreasingColor
16976
+ }
16977
+ }];
16978
+ };
16979
+ ;// ./src/components/Charts/CandlestickChart/CandlestickChart.tsx
16980
+ function CandlestickChart_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
16981
+
16982
+
16983
+
16984
+
16985
+
16986
+
16987
+
16988
+
16989
+
16990
+ var CandlestickChart_ref = true ? {
16991
+ name: "w1atjl",
16992
+ styles: "width:100%;height:100%"
16993
+ } : 0;
16994
+ const CandlestickChartComponent = ({
16995
+ title,
16996
+ data,
16997
+ features,
16998
+ widgetCardProps,
16999
+ style = 'hollow',
17000
+ ...plotParams
17001
+ }) => {
17002
+ const plotlyDefaultLayoutConfig = usePlotlyDefaultConfig();
17003
+ const {
17004
+ isFullscreenMode,
17005
+ toggleFullscreenMode
17006
+ } = useFullscreenMode();
17007
+ const theme = (0,react_namespaceObject.useTheme)();
17008
+ const {
17009
+ config,
17010
+ layout,
17011
+ ...restPlotParams
17012
+ } = plotParams;
17013
+ const plotData = getCandlestickPlotData(style, data, theme.colors.green, theme.colors.pink);
17014
+ const extraModeBarButtons = [];
17015
+ if (features?.includes('fullscreenMode')) {
17016
+ extraModeBarButtons.push({
17017
+ name: 'fullscreen',
17018
+ icon: {
17019
+ svg: (0,server_namespaceObject.renderToString)((0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
17020
+ name: "maximize"
17021
+ }))
17022
+ },
17023
+ title: isFullscreenMode ? 'Exit fullscreen mode' : 'Fullscreen mode',
17024
+ click: toggleFullscreenMode,
17025
+ attr: 'fullscreen-mode-icon',
17026
+ gravity: '1'
17027
+ });
17028
+ }
17029
+ return (0,jsx_runtime_namespaceObject.jsx)(WithWidgetCard, {
17030
+ features: features,
17031
+ cardProps: {
17032
+ ...widgetCardProps
17033
+ },
17034
+ children: (0,jsx_runtime_namespaceObject.jsx)((external_react_plotly_js_default()), {
17035
+ layout: {
17036
+ ...plotlyDefaultLayoutConfig.layout,
17037
+ title: {
17038
+ text: title,
17039
+ x: 0,
17040
+ y: 1,
17041
+ pad: {
17042
+ l: 10,
17043
+ t: 5
17044
+ },
17045
+ font: {
17046
+ size: 24,
17047
+ weight: 700,
17048
+ family: 'Manrope, sans-serif'
17049
+ }
17050
+ },
17051
+ dragmode: 'zoom',
17052
+ xaxis: {
17053
+ rangeslider: {
17054
+ visible: false
17055
+ }
17056
+ },
17057
+ yaxis: {
17058
+ side: 'right'
17059
+ },
17060
+ margin: {
17061
+ t: 20,
17062
+ b: 40,
17063
+ l: 20,
17064
+ r: 20
17065
+ },
17066
+ showlegend: false,
17067
+ ...layout
17068
+ },
17069
+ css: CandlestickChart_ref,
17070
+ useResizeHandler: true,
17071
+ data: plotData,
17072
+ config: {
17073
+ ...plotlyDefaultLayoutConfig.config,
17074
+ modeBarButtons: [extraModeBarButtons, ['zoom2d', 'pan2d', 'select2d', 'zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d']],
17075
+ ...config
17076
+ },
17077
+ ...restPlotParams
17078
+ })
17079
+ });
17080
+ };
17081
+ const CandlestickChart = WithFullscreenMode(CandlestickChartComponent);
17082
+ ;// ./src/components/Charts/CandlestickChart/index.ts
17083
+
16846
17084
  ;// ./src/components/Charts/index.ts
16847
17085
 
16848
17086
 
@@ -16853,6 +17091,7 @@ const BigNumberChart = WithFullscreenMode(BigNumberChartComponent);
16853
17091
 
16854
17092
 
16855
17093
 
17094
+
16856
17095
  ;// ./src/components/Popover/hooks/index.ts
16857
17096
 
16858
17097