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

fix(abp1-revert-fix): Fix revert abp1 #620

Merged
merged 8 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions src/packages/shared-types/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type RHFSlotProps = {
descriptionClassName?: string;
dependency?: DependencyRule;
rules?: RegisterOptions;
horizontalLayout?: boolean;
} & {
[K in keyof RHFComponentMap]: {
rhf: K;
Expand Down
1 change: 1 addition & 0 deletions src/packages/shared-types/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type DatePickerProps = {
export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {
icon?: string;
iconRight?: boolean;
}

export type RadioProps = React.ComponentPropsWithoutRef<
Expand Down
592 changes: 320 additions & 272 deletions src/services/api/webforms/ABP1/v202402.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/services/ui/src/components/Inputs/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { cn } from "@/utils";
import { Loader2 } from "lucide-react";

const buttonVariants = cva(
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
"inline-flex items-center justify-center rounded-md text-[16px] font-bold ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
Expand Down
10 changes: 6 additions & 4 deletions src/services/ui/src/components/Inputs/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ import { cn } from "@/utils";
import { InputProps } from "shared-types";

const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, icon, ...props }, ref) => {
({ className, icon, iconRight, ...props }, ref) => {
return (
<div className="relative">
<div className="relative w-fit">
{icon && (
<span className="absolute inset-y-0 left-0 flex items-center pl-2 text-gray-500">
<span
className={`absolute inset-y-0 flex items-center text-gray-500 ${iconRight ? "right-0 pr-2" : "left-0 pl-2"}`}
>
{icon}
</span>
)}
<input
className={cn(
"flex h-9 w-full rounded-sm border border-black bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
icon && "pl-6",
icon && (iconRight ? "pr-6" : "pl-6"),
className,
)}
ref={ref}
Expand Down
14 changes: 11 additions & 3 deletions src/services/ui/src/components/RHF/Slot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const RHFSlot = <
descriptionClassName,
labelClassName,
formItemClassName,
horizontalLayout,
...rest
}: RHFSlotProps & { control: any; parentId?: string }): ControllerProps<
TFieldValues,
Expand All @@ -39,9 +40,11 @@ export const RHFSlot = <

return (
<FormItem
className={`flex flex-col gap-1 py-2${
className={`flex gap-1 py-2${
formItemClassName ? ` ${formItemClassName}` : ""
}`}
}
${horizontalLayout ? "" : " flex-col"}
`}
jdinh8124 marked this conversation as resolved.
Show resolved Hide resolved
data-testid={rest.name + "Wrapper"}
>
{(label || styledLabel) && (
Expand All @@ -55,7 +58,12 @@ export const RHFSlot = <
</FormDescription>
)}
<FormControl>
<SlotField {...rest} control={control} field={field} />
<SlotField
{...rest}
horizontalLayout={horizontalLayout}
control={control}
field={field}
/>
</FormControl>
{description && !descriptionAbove && (
<FormDescription className={descriptionClassName}>
Expand Down
5 changes: 3 additions & 2 deletions src/services/ui/src/components/RHF/SlotField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const SlotField = ({
parentId,
fields,
name,
horizontalLayout,
}: SlotFieldProps) => {
switch (rhf) {
case "Input":
Expand Down Expand Up @@ -211,7 +212,7 @@ export const SlotField = ({
<RadioGroup
onValueChange={field.onChange}
defaultValue={field.value}
className="flex flex-col space-y-1"
className={`flex ${horizontalLayout ? "pl-5 gap-5" : "flex-col space-y-1"}`}
>
{(props as RHFComponentMap["Radio"]).options.map((OPT) => {
return (
Expand Down Expand Up @@ -275,7 +276,7 @@ export const OptChildren = ({
control={control}
name={parentId + SLOT.name}
{...(SLOT.rules && { rules: SLOT.rules })}
render={RHFSlot({ ...SLOT, parentId, control })}
render={RHFSlot({ ...SLOT, control, parentId })}
/>
</div>
))}
Expand Down
6 changes: 3 additions & 3 deletions src/services/ui/src/components/RHF/dependencyWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DependencyRule, DependencyWrapperProps } from "shared-types";

const checkTriggeringValue = (
dependentValue: unknown[],
dependency?: DependencyRule
dependency?: DependencyRule,
) => {
return !!dependency?.conditions?.every((d, i) => {
switch (d.type) {
Expand All @@ -27,7 +27,7 @@ const checkTriggeringValue = (
};

export const DependencyWrapper = (
props: PropsWithChildren<DependencyWrapperProps>
props: PropsWithChildren<DependencyWrapperProps>,
) => {
// Check for dependencies which won't exist outside of forms
if (
Expand All @@ -51,7 +51,7 @@ const DependencyWrapperHandler = ({
const { watch, setValue } = useFormContext();
const [wasSetLast, setWasSetLast] = useState(false);
const dependentValues = watch(
dependency?.conditions?.map((c) => c.name) ?? []
dependency?.conditions?.map((c) => c.name) ?? [],
);
const isTriggered =
dependency && checkTriggeringValue(dependentValues, dependency);
Expand Down
2 changes: 1 addition & 1 deletion src/services/ui/src/features/webforms/WebFormBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const ClearDataButton: FC<{ reset: () => void }> = ({ reset }) => {
if (clearDataButton) {
return (
<Button type="button" onClick={reset} variant="outline" className="mx-2">
Clear Data
Clear
</Button>
);
}
Expand Down
Loading