Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Identity file changes #91

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/ButtonGroupIp.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
external strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity"
open SelectBox
@react.component
let make = (
Expand All @@ -9,7 +8,7 @@ let make = (
~isSeparate=false,
~buttonSize=?,
) => {
let onChange = str => input.onChange(str->strToFormEvent)
let onChange = str => input.onChange(str->Identity.stringToFormReactEvent)
let buttonState = {isDisabled ? Button.Disabled : Button.Normal}

let buttons =
Expand Down
6 changes: 0 additions & 6 deletions src/components/CsvFileUpload.res
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
type t

type formData
external formDataToStr: t => string = "%identity"

external toString: 't => string = "%identity"
external toRef: 'a => 't = "%identity"
@new external formData: unit => t = "FormData"

@send external append: (t, string, 'a) => unit = "append"
@send external delete: (t, string) => unit = "delete"
@send external get: (t, string) => 'k = "get"
Expand Down
4 changes: 1 addition & 3 deletions src/components/CustomCharts/HighchartBarChart.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
external objToJson: {..} => Js.Json.t = "%identity"

module RawBarChart = {
@react.component
let make = (~options: Js.Json.t) => {
Expand Down Expand Up @@ -59,7 +57,7 @@ module HighBarChart1D = {
},
"series": barSeries,
"legend": {"enabled": false},
}->objToJson
}->Identity.genericObjectOrRecordToJson
barOption
}, (barSeries, gridLineColor))
if barSeries->Js.Array2.length > 0 {
Expand Down
14 changes: 7 additions & 7 deletions src/components/CustomCharts/LineChartUtils.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
external legendItemAsBool: Highcharts.legendItem => Highcharts.element = "%identity"
external objToJson: {..} => Js.Json.t = "%identity"

open LogicUtils
open Highcharts
open Identity
let defaultColor = "#7cb5ec"
let legendColor = [
defaultColor,
Expand Down Expand Up @@ -804,7 +804,7 @@ let legendItemStyle = (theme: ThemeProvider.theme, legendFontFamilyClass, legend
"fontWeight": "500",
"fontFamily": legendFontFamilyClass,
"fontStyle": "normal",
}->objToJson
}->genericObjectOrRecordToJson
| Light =>
{
"color": "rgba(53, 64, 82, 0.8)",
Expand All @@ -813,7 +813,7 @@ let legendItemStyle = (theme: ThemeProvider.theme, legendFontFamilyClass, legend
"fontWeight": "500",
"fontFamily": legendFontFamilyClass,
"fontStyle": "normal",
}->objToJson
}->genericObjectOrRecordToJson
}
}

Expand All @@ -831,7 +831,7 @@ let legendHiddenStyle = (
"fontWeight": "500",
"fontFamily": legendFontFamilyClass,
"fontStyle": "normal",
}->objToJson
}->genericObjectOrRecordToJson
| Light =>
{
"color": "rgba(53, 64, 82, 0.2)",
Expand All @@ -840,7 +840,7 @@ let legendHiddenStyle = (
"fontWeight": "500",
"fontFamily": legendFontFamilyClass,
"fontStyle": "normal",
}->objToJson
}->genericObjectOrRecordToJson
}
}

Expand All @@ -853,15 +853,15 @@ let chartTitleStyle = (theme: ThemeProvider.theme) => {
"fontWeight": "500",
"fontFamily": "IBM Plex Sans",
"fontStyle": "normal",
}->objToJson
}->genericObjectOrRecordToJson
| Light =>
{
"color": "#354052",
"fontSize": "13px",
"fontWeight": "500",
"fontFamily": "IBM Plex Sans",
"fontStyle": "normal",
}->objToJson
}->genericObjectOrRecordToJson
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/components/DatePicker.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
external jsonToForm: Js.Json.t => ReactEvent.Form.t = "%identity"

@react.component
let make = (
~input: ReactFinalForm.fieldRenderPropsInput,
Expand Down
31 changes: 15 additions & 16 deletions src/components/DistributionDonut/DistributionDonut.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
external objToJson: {..} => Js.Json.t = "%identity"

type dataPoint = {y: int, name: string}

module LegendField = {
Expand Down Expand Up @@ -50,6 +48,7 @@ let make = (
~data: array<Js.Json.t>,
~getGroupBasedData: (array<Js.Json.t>, string) => array<dataPoint>,
) => {
open Identity
let (groupBy, setGroupBy) = React.useState(_ => "")
let (groupBasedData, setGroupBasedData) = React.useState((_): array<dataPoint> => [])
let getDonutOptions = (_): Js.Json.t => {
Expand All @@ -58,37 +57,37 @@ let make = (
"text": Js.Json.null,
"align": "center",
"margin": 0,
}->objToJson,
}->genericObjectOrRecordToJson,
"colors": colors,
"credits": {
"enabled": false,
}->objToJson,
}->genericObjectOrRecordToJson,
"subtitle": {
"useHTML": true,
"text": getSubtilteHtml(groupBasedData),
"floating": true,
"verticalAlign": "middle",
"y": 10,
}->objToJson,
}->genericObjectOrRecordToJson,
"legend": {
"enabled": false,
}->objToJson,
}->genericObjectOrRecordToJson,
"chart": {
"backgroundColor": Js.Json.null,
"className": "h-60",
"height": 260,
"width": 260,
"borderColor": Js.Json.null,
}->objToJson,
}->genericObjectOrRecordToJson,
"tooltip": {
"valueDecimals": 0,
"valueSuffix": "",
}->objToJson,
}->genericObjectOrRecordToJson,
"plotOptions": {
"series": {
"animation": {
"duration": 0,
}->objToJson,
}->genericObjectOrRecordToJson,
"borderWidth": 5,
"colorByPoint": true,
"type": "pie",
Expand All @@ -101,23 +100,23 @@ let make = (
"style": {
"fontWeight": "bold",
"fontSize": "16px",
}->objToJson,
}->genericObjectOrRecordToJson,
"connectorWidth": 0,
}->objToJson,
}->objToJson,
}->objToJson,
}->genericObjectOrRecordToJson,
}->genericObjectOrRecordToJson,
}->genericObjectOrRecordToJson,
"series": [
{
"color": "black",
"type": "pie",
"name": tooltipTitle,
"data": Js.Array.map(
(d: dataPoint): Js.Json.t => {"y": d.y, "name": d.name}->objToJson,
(d: dataPoint): Js.Json.t => {"y": d.y, "name": d.name}->genericObjectOrRecordToJson,
groupBasedData,
),
}->objToJson,
}->genericObjectOrRecordToJson,
],
}->objToJson
}->genericObjectOrRecordToJson
}
React.useEffect1(() => {
setGroupBy(_ =>
Expand Down
3 changes: 1 addition & 2 deletions src/components/ExportTable.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
external convertToStrDict: 't => Js.Json.t = "%identity"
@react.component
let make = (
~title: string,
Expand All @@ -11,7 +10,7 @@ let make = (
let actualDataOrig =
tableData
->Belt.Array.keepMap(item => item->Js.Nullable.toOption)
->Js.Array2.map(convertToStrDict)
->Js.Array2.map(Identity.genericTypeToJson)

let headerNames = visibleColumns->Belt.Array.keepMap(head => {
let item = head->getHeading
Expand Down
24 changes: 14 additions & 10 deletions src/components/HSwitchSingleStatWidget.res
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let make = (
~statThreshold: Js.Dict.t<float>=Js.Dict.empty(),
~isHomePage=false,
) => {
open Identity
let (updateKey, setUpdateKey) = React.useState(_ => false)

let sortedData = React.useMemo1(() => {
Expand Down Expand Up @@ -85,21 +86,21 @@ let make = (
"height": (isHomePage ? "80" : "50")->Some,
"width": isHomePage ? None : Some("105"),
"events": None,
}->LineChartUtils.objToJson,
}->genericObjectOrRecordToJson,
),
title: {
"text": "",
"style": Js.Json.object_(Js.Dict.empty()),
}->LineChartUtils.objToJson,
}->genericObjectOrRecordToJson,
credits: {
"enabled": false,
},
legend: {
"enabled": false,
}->LineChartUtils.objToJson,
}->genericObjectOrRecordToJson,
tooltip: {
"enabled": false,
}->LineChartUtils.objToJson,
}->genericObjectOrRecordToJson,
plotOptions: Some(
{
"area": {
Expand All @@ -114,7 +115,7 @@ let make = (
},
},
"lineWidth": 3,
}->LineChartUtils.objToJson,
}->genericObjectOrRecordToJson,
"boxplot": {
"visible": false,
},
Expand All @@ -129,21 +130,24 @@ let make = (
"legendItemClick": None,
"mouseOver": Some(""),
}),
}->LineChartUtils.objToJson,
}->LineChartUtils.objToJson,
}->genericObjectOrRecordToJson,
}->genericObjectOrRecordToJson,
),
xAxis: {
"type": "datetime",
"zoomEnabled": false,
}->LineChartUtils.objToJson,
}->genericObjectOrRecordToJson,
yAxis: {
"tickPositioner": None,
"plotLines": None,
"visible": false,
"title": {"text": "", "style": Js.Json.object_(Js.Dict.empty())}->LineChartUtils.objToJson,
"title": {
"text": "",
"style": Js.Json.object_(Js.Dict.empty()),
}->genericObjectOrRecordToJson,
"labels": {"formatter": None, "enabled": false, "useHTML": false}->Some,
"zoomEnabled": false,
}->LineChartUtils.objToJson,
}->genericObjectOrRecordToJson,
series: [
{
color: Some(strokeColor),
Expand Down
27 changes: 13 additions & 14 deletions src/components/HighchartFunnelChart.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
open Highcharts
open LogicUtils
external objToJson: {..} => Js.Json.t = "%identity"
type options = {x: int}
type tooltipPoints = {
name: string,
Expand Down Expand Up @@ -50,7 +49,7 @@ let make = (
->Belt.Array.get(0)
->Belt.Option.getWithDefault("")}${opacity}`,
"color": `${chartColors->Belt.Array.get(0)->Belt.Option.getWithDefault("")}`,
}->LineChartUtils.objToJson
}->Identity.genericObjectOrRecordToJson
}),
"area",
)
Expand All @@ -70,15 +69,15 @@ let make = (
{
"name": key,
"y": item->Js.Nullable.return,
}->LineChartUtils.objToJson
}->Identity.genericObjectOrRecordToJson
})
let values = {
"name": key,
"data": updatedValue,
"color": chartColors->Belt.Array.get(chartItemIndex),
"pointPlacement": "on",
"legendIndex": chartItemIndex,
}->LineChartUtils.objToJson
}->Identity.genericObjectOrRecordToJson
if zonesFor1D->Js.Array2.length !== 0 {
Js.Array2.concat(
values->getDictFromJsonObject->Js.Dict.entries,
Expand All @@ -102,12 +101,12 @@ let make = (
"backgroundColor": Js.Nullable.null,
"events": None,
"marginBottom": 50,
}->objToJson,
}->Identity.genericObjectOrRecordToJson,
),
title: {
"text": "",
"style": Js.Json.object_(Js.Dict.empty()),
}->objToJson,
}->Identity.genericObjectOrRecordToJson,
credits: {
"enabled": false,
},
Expand All @@ -129,13 +128,13 @@ let make = (
"style": {
"color": theme === Light ? "rgba(246, 248, 249, 1)" : "rgba(25, 26, 26, 1)",
},
}->objToJson,
}->Identity.genericObjectOrRecordToJson,
plotOptions: Some(
{
"area": {
"inverted": true,
"lineWidth": 2,
}->objToJson,
}->Identity.genericObjectOrRecordToJson,
"boxplot": {
"visible": false,
},
Expand All @@ -153,12 +152,12 @@ let make = (
"legendItemClick": None,
"mouseOver": Some(""),
}),
}->objToJson,
}->objToJson,
}->Identity.genericObjectOrRecordToJson,
}->Identity.genericObjectOrRecordToJson,
),
legend: {
"enabled": false,
}->objToJson,
}->Identity.genericObjectOrRecordToJson,
xAxis: {
"visible": true,
"lineWidth": 0,
Expand All @@ -175,7 +174,7 @@ let make = (
},
},
"categories": categories,
}->objToJson,
}->Identity.genericObjectOrRecordToJson,
yAxis: {
"title": "",
"max": maxValueForTheDataSet,
Expand All @@ -195,8 +194,8 @@ let make = (
"letterSpacing": "1px",
"color": theme === Light ? "#4B5468" : "rgba(246, 248, 249, 0.25)",
},
}->objToJson,
}->objToJson,
}->Identity.genericObjectOrRecordToJson,
}->Identity.genericObjectOrRecordToJson,
series: chartData,
}
}, (dataSet, categories, formatter))
Expand Down
Loading