Skip to content

Commit

Permalink
chore: Rename options to follow existing pattern (#44)
Browse files Browse the repository at this point in the history
* Rename options to follow existing pattern

* Add type alias to avoid breaking change
  • Loading branch information
NathanFarmer authored Mar 18, 2024
1 parent e7e3e3f commit ba7cd85
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/antd/InputNumber.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReactElement } from "react"
import { ControlProps, RendererProps } from "@jsonforms/core"
import { InputNumber as AntdInputNumber } from "antd"
import { InputNumberOptions } from "../ui-schema"
import { NumericControlOptions } from "../ui-schema"
import {
coerceToInteger,
coerceToNumber,
Expand Down Expand Up @@ -48,7 +48,7 @@ export const InputNumber = (props: InputNumberProps): InputNumber => {
}
}

const options = props.uischema.options as InputNumberOptions
const options = props.uischema.options as NumericControlOptions
const addonAfter = options?.addonAfter
const addonBefore = options?.addonBefore
const isPercentage =
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/AlertLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { LabelProps, RendererProps } from "@jsonforms/core"
import { Alert } from "antd"
import { AlertLabelOptions } from "../ui-schema"
import { AlertLayoutOptions } from "../ui-schema"

export function AlertLayout({ text, uischema }: LabelProps & RendererProps) {
const options = uischema.options as AlertLabelOptions
const options = uischema.options as AlertLayoutOptions
return (
<Alert
style={{ marginBottom: "24px" }}
Expand Down
10 changes: 7 additions & 3 deletions src/ui-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ export interface LabelElement extends UISchemaElement, Internationalizable {
options?: LabelOptions
}

export type AlertLabelOptions = { type: AlertProps["type"] }
export type AlertLayoutOptions = { type: AlertProps["type"] }
// aliased to avoid breaking change, remove in next major version
export type AlertLaybelOptions = AlertLayoutOptions

// this is intended to be a union, it just has one member rn
export type LabelOptions = AlertLabelOptions
export type LabelOptions = AlertLayoutOptions

export const OneOfControlOptions = [
"button",
Expand Down Expand Up @@ -283,7 +285,9 @@ type AndCondition = ComposableCondition & {
type: "AND"
}

export type InputNumberOptions = {
export type NumericControlOptions = {
addonBefore?: InputNumberProps["addonBefore"]
addonAfter?: InputNumberProps["addonAfter"]
}
// aliased to avoid breaking change, remove in next major version
export type InputNumberOptions = NumericControlOptions

0 comments on commit ba7cd85

Please sign in to comment.