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

chore: remove redundant code #298

Merged
merged 6 commits into from
Jan 24, 2024
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
5 changes: 0 additions & 5 deletions src/components/AuthWrapperUtils.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
type parent

@val external window: 'a = "window"
@val @scope("window") external parent: parent = "parent"

let getValidToken = oStr => {
if oStr !== Some("__failed") && oStr !== Some("") {
oStr
Expand Down
7 changes: 4 additions & 3 deletions src/components/DynamicTableUtils.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
let tableHeadingClass = "font-bold text-xl text-black text-opacity-75 dark:text-white dark:text-opacity-75"
type view = Table | Card
@val @scope(("window", "location"))
external reload: unit => unit = "reload"

let visibilityColFunc = (
~dateFormatConvertor: string => option<Js.Json.t>,
Expand Down Expand Up @@ -248,7 +246,10 @@ module TableLoadingErrorIndicator = {
{React.string("Oops, Something Went Wrong! Try again Later.")}
</div>
<Button
text="Refresh" leftIcon={FontAwesome("sync-alt")} onClick={_ => reload()} buttonType
text="Refresh"
leftIcon={FontAwesome("sync-alt")}
onClick={_ => Window.Location.reload()}
buttonType
/>
</>}
</div>
Expand Down
7 changes: 1 addition & 6 deletions src/components/RemoteFilter.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
let makeFieldInfo = FormRenderer.makeFieldInfo

@val @scope(("window", "location"))
external reload: unit => unit = "reload"
@val @scope(("window", "location"))
external replace: string => unit = "replace"

module ClearForm = {
@react.component
let make = () => {
Expand Down Expand Up @@ -835,7 +830,7 @@ let make = (
let urlValue = `${path}?${newQueryStr}`
setClearFilterAfterRefresh(_ => true)
setInitialValueJson(_ => Dict.make()->Js.Json.object_)
replace(urlValue)
Window.Location.replace(urlValue)
}

let refreshFilterUi = {
Expand Down
7 changes: 2 additions & 5 deletions src/components/SelectBox.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ external toDict: 'a => Dict.t<'t> = "%identity"
@send external getClientRects: Dom.element => Dom.domRect = "getClientRects"
@send external focus: Dom.element => unit = "focus"

@val @scope("window") external windowInnerHeight: int = "innerHeight"
@val @scope("window") external windowInnerWidth: int = "innerWidth"

external ffInputToSelectInput: ReactFinalForm.fieldRenderPropsInput => ReactFinalForm.fieldRenderPropsCustomInput<
array<string>,
> = "%identity"
Expand Down Expand Up @@ -1624,9 +1621,9 @@ module BaseDropdown = {
->Js.Nullable.toOption
->Option.flatMap(elem => elem->getClientRects->toDict->Dict.get("0"))
->Option.flatMap(firstEl => {
let bottomVacent = windowInnerHeight - firstEl["bottom"]->Belt.Float.toInt > 375
let bottomVacent = Window.innerHeight - firstEl["bottom"]->Belt.Float.toInt > 375
let topVacent = firstEl["top"]->Belt.Float.toInt > 470
let rightVacent = windowInnerWidth - firstEl["left"]->Belt.Float.toInt > 270
let rightVacent = Window.innerWidth - firstEl["left"]->Belt.Float.toInt > 270
let leftVacent = firstEl["right"]->Belt.Float.toInt > 270

if bottomVacent {
Expand Down
139 changes: 114 additions & 25 deletions src/components/SelectBox.resi
Original file line number Diff line number Diff line change
@@ -1,16 +1,54 @@
type retType = CheckBox(array<string>) | Radiobox(string)
external toDict: 'a => Dict.t<'t> = "%identity"
external toDict: 'a => RescriptCore.Dict.t<'t> = "%identity"
@send external getClientRects: Dom.element => Dom.domRect = "getClientRects"
@send external focus: Dom.element => unit = "focus"
@val @scope("window") external windowInnerHeight: int = "innerHeight"
@val @scope("window") external windowInnerWidth: int = "innerWidth"
external ffInputToSelectInput: ReactFinalForm.fieldRenderPropsInput => ReactFinalForm.fieldRenderPropsCustomInput<
array<string>,
> = "%identity"
external ffInputToRadioInput: ReactFinalForm.fieldRenderPropsInput => ReactFinalForm.fieldRenderPropsCustomInput<
string,
> = "%identity"

let regex: (string, string) => Js.Re.t
module ListItem: {
@react.component
let make: (
~isDropDown: bool,
~searchString: string,
~multiSelect: bool,
~optionSize: CheckBoxIcon.size=?,
~isSelectedStateMinus: bool=?,
~isSelected: bool,
~isPrevSelected: bool=?,
~isNextSelected: bool=?,
~onClick: JsxEvent.Mouse.t => unit,
~text: Js.String2.t,
~fill: string=?,
~labelValue: Js.String2.t=?,
~isDisabled: bool=?,
~icon: Button.iconType,
~leftVacennt: bool=?,
~showToggle: bool=?,
~customStyle: string=?,
~serialNumber: option<string>=?,
~isMobileView: bool=?,
~description: option<Js.String2.t>=?,
~customLabelStyle: option<string>=?,
~customMarginStyle: string=?,
~listFlexDirection: string=?,
~customSelectStyle: string=?,
~textOverflowClass: string=?,
~dataId: int,
~showDescriptionAsTool: bool=?,
~optionClass: string=?,
~selectClass: string=?,
~toggleProps: string=?,
~checkboxDimension: string=?,
~iconStroke: string=?,
~showToolTipOptions: bool=?,
~textEllipsisForDropDownOptions: bool=?,
~textColorClass: string=?,
) => React.element
}
type dropdownOptionWithoutOptional = {
label: string,
value: string,
Expand All @@ -31,7 +69,8 @@ type dropdownOption = {
iconStroke?: string,
textColor?: string,
}
let useTransformed: Js.Array2.t<dropdownOption> => Js.Array2.t<dropdownOptionWithoutOptional>
let makeNonOptional: dropdownOption => dropdownOptionWithoutOptional
let useTransformed: array<dropdownOption> => array<dropdownOptionWithoutOptional>
type allSelectType = Icon | Text
type opt = {name_: string}
let makeOptions: array<string> => array<dropdownOption>
Expand All @@ -56,12 +95,12 @@ module BaseSelect: {
~showSerialNumber: bool=?,
~heading: string=?,
~showSelectionAsChips: bool=?,
~maxHeight: Js.String2.t=?,
~maxHeight: string=?,
~searchable: bool=?,
~optionRigthElement: React.element=?,
~searchInputPlaceHolder: string=?,
~showSearchIcon: bool=?,
~customStyle: Js.String2.t=?,
~customStyle: string=?,
~customMargin: string=?,
~disableSelect: bool=?,
~deselectDisable: bool=?,
Expand All @@ -88,10 +127,61 @@ module BaseSelect: {
~dropdownClassName: string=?,
~onItemSelect: (JsxEvent.Mouse.t, Js_string.t) => unit=?,
~wrapBasis: string=?,
~preservedAppliedOptions: Js.Array2.t<Js_string.t>=?,
~preservedAppliedOptions: array<Js_string.t>=?,
) => React.element
}

module BaseSelectButton: {
@react.component
let make: (
~showDropDown: bool=?,
~isDropDown: bool=?,
~isHorizontal: bool=?,
~options: array<dropdownOption>,
~optionSize: CheckBoxIcon.size=?,
~isSelectedStateMinus: bool=?,
~onSelect: string => unit,
~value: Js.Json.t,
~deselectDisable: bool=?,
~onBlur: ReactEvent.Focus.t => unit=?,
~setShowDropDown: ('a => bool) => unit=?,
~onAssignClick: string => unit=?,
~customSearchStyle: string,
~disableSelect: bool=?,
~isMobileView: bool=?,
~hideAssignBtn: bool=?,
~searchInputPlaceHolder: string=?,
~showSearchIcon: bool=?,
~allowButtonTextMinWidth: bool=?,
) => React.element
}
module RenderListItemInBaseRadio: {
@react.component
let make: (
~newOptions: Js.Array2.t<dropdownOptionWithoutOptional>,
~value: Js.Json.t,
~descriptionOnHover: bool,
~isDropDown: bool,
~textIconPresent: bool,
~searchString: string,
~optionSize: CheckBoxIcon.size,
~isSelectedStateMinus: bool,
~onItemClick: (string, bool, JsxEvent.Mouse.t) => unit,
~fill: string,
~customStyle: string,
~isMobileView: bool,
~listFlexDirection: string,
~customSelectStyle: string,
~textOverflowClass: option<string>,
~showToolTipOptions: bool,
~textEllipsisForDropDownOptions: bool,
~isHorizontal: bool,
~customMarginStyleOfListItem: string=?,
) => React.element
}
let getHashMappedOptionValues: array<dropdownOptionWithoutOptional> => RescriptCore.Dict.t<
array<dropdownOptionWithoutOptional>,
>
let getSortedKeys: RescriptCore.Dict.t<'a> => Js.Array2.t<string>
module BaseRadio: {
@react.component
let make: (
Expand All @@ -106,13 +196,13 @@ module BaseRadio: {
~deselectDisable: bool=?,
~onBlur: ReactEvent.Focus.t => unit=?,
~fill: string=?,
~customStyle: Js.String2.t=?,
~customStyle: string=?,
~searchable: bool=?,
~isMobileView: bool=?,
~customSearchStyle: string=?,
~descriptionOnHover: bool=?,
~addDynamicValue: bool=?,
~dropdownCustomWidth: Js.String2.t=?,
~dropdownCustomWidth: string=?,
jainlokesh318 marked this conversation as resolved.
Show resolved Hide resolved
~dropdownRef: React.ref<Js.Nullable.t<Dom.element>>=?,
~showMatchingRecordsText: bool=?,
~fullLength: bool=?,
Expand All @@ -130,12 +220,11 @@ module BaseRadio: {
~textEllipsisForDropDownOptions: bool=?,
) => React.element
}

type direction = BottomLeft | BottomMiddle | BottomRight | TopLeft | TopMiddle | TopRight
module BaseDropdown: {
@react.component
let make: (
~buttonText: Js.String2.t,
~buttonText: string,
~buttonSize: Button.buttonSize=?,
~allowMultiSelect: bool,
~input: ReactFinalForm.fieldRenderPropsInput,
Expand All @@ -155,12 +244,12 @@ module BaseDropdown: {
~defaultLeftIcon: Button.iconType=?,
~autoApply: bool=?,
~fullLength: bool=?,
~customButtonStyle: Js.String2.t=?,
~customButtonStyle: string=?,
~onAssignClick: string => unit=?,
~fixedDropDownDirection: direction=?,
~addButton: bool=?,
~marginTop: string=?,
~customStyle: Js.String2.t=?,
~customStyle: string=?,
~customSearchStyle: string=?,
~showSelectionAsChips: bool=?,
~showToolTip: bool=?,
Expand All @@ -174,16 +263,16 @@ module BaseDropdown: {
~addDynamicValue: bool=?,
~showMatchingRecordsText: bool=?,
~hasApplyButton: bool=?,
~dropdownCustomWidth: Js.String2.t=?,
~dropdownCustomWidth: string=?,
~allowButtonTextMinWidth: bool=?,
~customMarginStyle: string=?,
~customButtonLeftIcon: Button.iconType=?,
~customTextPaddingClass: string=?,
~customButtonPaddingClass: string=?,
~customButtonIconMargin: string=?,
~textStyleClass: Js.String2.t=?,
~textStyleClass: string=?,
~buttonStyleOnDropDownOpened: string=?,
~selectedString: Js.String2.t=?,
~selectedString: string=?,
~setSelectedString: ('a => Js_string.t) => unit=?,
~setExtSearchString: ('b => string) => unit=?,
~listFlexDirection: string=?,
Expand All @@ -193,7 +282,7 @@ module BaseDropdown: {
~showAllSelectedOptions: bool=?,
~buttonClickFn: string => unit=?,
~showSelectCountButton: bool=?,
~maxHeight: Js.String2.t=?,
~maxHeight: string=?,
~customBackColor: string=?,
~showToolTipOptions: bool=?,
~textEllipsisForDropDownOptions: bool=?,
Expand Down Expand Up @@ -231,7 +320,7 @@ module ChipFilterSelectBox: {
@react.component
let make: (
~input: ReactFinalForm.fieldRenderPropsInput,
~buttonText: Js.String2.t=?,
~buttonText: string=?,
~buttonSize: Button.buttonSize=?,
~allowMultiSelect: bool=?,
~isDropDown: bool=?,
Expand All @@ -246,13 +335,13 @@ let make: (
~buttonType: Button.buttonType=?,
~disableSelect: bool=?,
~fullLength: bool=?,
~customButtonStyle: Js.String2.t=?,
~customButtonStyle: string=?,
~textStyle: string=?,
~marginTop: string=?,
~customStyle: Js.String2.t=?,
~customStyle: string=?,
~showSelectionAsChips: bool=?,
~showToggle: bool=?,
~maxHeight: Js.String2.t=?,
~maxHeight: string=?,
~searchable: bool=?,
~fill: string=?,
~optionRigthElement: React.element=?,
Expand All @@ -273,7 +362,7 @@ let make: (
~customButton: React.element=?,
~descriptionOnHover: bool=?,
~fixedDropDownDirection: direction=?,
~dropdownCustomWidth: Js.String2.t=?,
~dropdownCustomWidth: string=?,
~allowButtonTextMinWidth: bool=?,
~baseComponent: React.element=?,
~baseComponentMethod: bool => React.element=?,
Expand All @@ -283,7 +372,7 @@ let make: (
~customTextPaddingClass: string=?,
~customButtonPaddingClass: string=?,
~customButtonIconMargin: string=?,
~textStyleClass: Js.String2.t=?,
~textStyleClass: string=?,
~setExtSearchString: ('a => string) => unit=?,
~buttonStyleOnDropDownOpened: string=?,
~listFlexDirection: string=?,
Expand Down
4 changes: 1 addition & 3 deletions src/components/form/FormValuesSpy.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ module JsonBox = {
}
}

@val @scope(("window", "location")) external hostname: string = "hostname"

@react.component
let make = (~wrapperClass="", ~jsonModifier=?, ~restrictToLocal=true, ~displayProps=true) => {
let subs = ReactFinalForm.useFormSubscription(["values"])

let canRender = if restrictToLocal {
hostname === "localhost"
Window.Location.hostname === "localhost"
} else {
true
}
Expand Down
5 changes: 1 addition & 4 deletions src/context/ThemeProvider.res
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ let useTheme = () => {
theme
}

@val external window: Js.Nullable.t<'a> = "window"
@val @scope("window") external parent: 't = "parent"

@react.component
let make = (~children) => {
let eventTheme = ThemeUtils.useThemeFromEvent()
Expand All @@ -33,7 +30,7 @@ let make = (~children) => {
| Some("Dark") => Dark
| Some(_val) => Light
| None =>
if window !== parent {
if window !== Window.parent {
Light
} else {
themeState
Expand Down
2 changes: 0 additions & 2 deletions src/entities/analytics/EulerAnalyticsLogUtils.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@val @scope("window")
external location: {..} = "location"
external toJson: exn => Js.Json.t = "%identity"
external toExn: string => exn = "%identity"

Expand Down
2 changes: 0 additions & 2 deletions src/genericUtils/DOMUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ type window
@val external window: window = "window"
@send external click: (Dom.element, unit) => unit = "click"
@send external reset: (Dom.element, unit) => unit = "reset"
@val @scope("window") external parent: window = "parent"
type event
@new
external event: string => event = "Event"
@send external dispatchEvent: ('a, event) => unit = "dispatchEvent"
@send external postMessage: (window, Js.Json.t, string) => unit = "postMessage"
@val @scope(("window", "location")) external windowOrigin: string = "origin"
@get external keyCode: 'a => int = "keyCode"
@send external querySelectorAll: (document, string) => array<Dom.element> = "querySelectorAll"
@send external setAttribute: (Dom.element, string, string) => unit = "setAttribute"
Expand Down
Loading
Loading