Update props in components pass 2
This commit is contained in:
@@ -14,14 +14,18 @@ const MultiSelectContainer = memo<MultiSelectProps>(
|
|||||||
options,
|
options,
|
||||||
onChipClick,
|
onChipClick,
|
||||||
onAddClick,
|
onAddClick,
|
||||||
showAddButton = true,
|
showAddButton: showAddButtonProp,
|
||||||
|
addButton: addButtonProp,
|
||||||
addButtonText = "Add organization type",
|
addButtonText = "Add organization type",
|
||||||
|
formHeader = true,
|
||||||
onCustomChipConfirm,
|
onCustomChipConfirm,
|
||||||
onCustomChipClose,
|
onCustomChipClose,
|
||||||
className = "",
|
className = "",
|
||||||
}) => {
|
}) => {
|
||||||
const size = normalizeMultiSelectSize(sizeProp);
|
const size = normalizeMultiSelectSize(sizeProp);
|
||||||
const palette = normalizeChipPalette(paletteProp);
|
const palette = normalizeChipPalette(paletteProp);
|
||||||
|
// Backward compatibility: if addButton is provided, use it; otherwise use showAddButton
|
||||||
|
const showAddButton = addButtonProp !== undefined ? addButtonProp : (showAddButtonProp !== undefined ? showAddButtonProp : true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MultiSelectView
|
<MultiSelectView
|
||||||
@@ -34,6 +38,7 @@ const MultiSelectContainer = memo<MultiSelectProps>(
|
|||||||
onAddClick={onAddClick}
|
onAddClick={onAddClick}
|
||||||
showAddButton={showAddButton}
|
showAddButton={showAddButton}
|
||||||
addButtonText={addButtonText}
|
addButtonText={addButtonText}
|
||||||
|
formHeader={formHeader}
|
||||||
onCustomChipConfirm={onCustomChipConfirm}
|
onCustomChipConfirm={onCustomChipConfirm}
|
||||||
onCustomChipClose={onCustomChipClose}
|
onCustomChipClose={onCustomChipClose}
|
||||||
className={className}
|
className={className}
|
||||||
|
|||||||
@@ -40,13 +40,23 @@ export interface MultiSelectProps {
|
|||||||
*/
|
*/
|
||||||
onAddClick?: () => void;
|
onAddClick?: () => void;
|
||||||
/**
|
/**
|
||||||
* Show the add button
|
* Show the add button (backward compatibility - use addButton instead)
|
||||||
*/
|
*/
|
||||||
showAddButton?: boolean;
|
showAddButton?: boolean;
|
||||||
|
/**
|
||||||
|
* Whether to show add button (Figma prop).
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
addButton?: boolean;
|
||||||
/**
|
/**
|
||||||
* Text for the add button
|
* Text for the add button
|
||||||
*/
|
*/
|
||||||
addButtonText?: string;
|
addButtonText?: string;
|
||||||
|
/**
|
||||||
|
* Whether to show form header (label and help icon) above multi-select (Figma prop).
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
formHeader?: boolean;
|
||||||
/**
|
/**
|
||||||
* Callback when a custom chip is confirmed (check button clicked)
|
* Callback when a custom chip is confirmed (check button clicked)
|
||||||
*/
|
*/
|
||||||
@@ -68,6 +78,7 @@ export interface MultiSelectViewProps {
|
|||||||
onAddClick?: () => void;
|
onAddClick?: () => void;
|
||||||
showAddButton: boolean;
|
showAddButton: boolean;
|
||||||
addButtonText: string;
|
addButtonText: string;
|
||||||
|
formHeader: boolean;
|
||||||
onCustomChipConfirm?: (chipId: string, value: string) => void;
|
onCustomChipConfirm?: (chipId: string, value: string) => void;
|
||||||
onCustomChipClose?: (chipId: string) => void;
|
onCustomChipClose?: (chipId: string) => void;
|
||||||
className: string;
|
className: string;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ function MultiSelectView({
|
|||||||
onAddClick,
|
onAddClick,
|
||||||
showAddButton,
|
showAddButton,
|
||||||
addButtonText,
|
addButtonText,
|
||||||
|
formHeader = true,
|
||||||
onCustomChipConfirm,
|
onCustomChipConfirm,
|
||||||
onCustomChipClose,
|
onCustomChipClose,
|
||||||
className,
|
className,
|
||||||
@@ -32,7 +33,7 @@ function MultiSelectView({
|
|||||||
return (
|
return (
|
||||||
<div className={`flex flex-col ${isSmall ? "gap-[var(--measures-spacing-200,8px)]" : "gap-[var(--measures-spacing-300,12px)]"} items-start relative w-full ${className}`}>
|
<div className={`flex flex-col ${isSmall ? "gap-[var(--measures-spacing-200,8px)]" : "gap-[var(--measures-spacing-300,12px)]"} items-start relative w-full ${className}`}>
|
||||||
{/* Label using InputLabel component */}
|
{/* Label using InputLabel component */}
|
||||||
{label && (
|
{formHeader && label && (
|
||||||
<InputLabel
|
<InputLabel
|
||||||
label={label}
|
label={label}
|
||||||
helpIcon={showHelpIcon}
|
helpIcon={showHelpIcon}
|
||||||
|
|||||||
@@ -8,16 +8,23 @@ import { normalizeState } from "../../../../lib/propNormalization";
|
|||||||
const SwitchContainer = memo(
|
const SwitchContainer = memo(
|
||||||
forwardRef<HTMLButtonElement, SwitchProps>((props, ref) => {
|
forwardRef<HTMLButtonElement, SwitchProps>((props, ref) => {
|
||||||
const {
|
const {
|
||||||
checked = false,
|
checked: checkedProp,
|
||||||
|
propSwitch: propSwitchProp,
|
||||||
onChange,
|
onChange,
|
||||||
onFocus,
|
onFocus,
|
||||||
onBlur,
|
onBlur,
|
||||||
state: stateProp = "default",
|
state: stateProp = "default",
|
||||||
label,
|
label: labelProp,
|
||||||
|
text: textProp,
|
||||||
className = "",
|
className = "",
|
||||||
...rest
|
...rest
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
// Backward compatibility: use propSwitch if provided, otherwise use checked
|
||||||
|
const checked = propSwitchProp !== undefined ? propSwitchProp : (checkedProp !== undefined ? checkedProp : false);
|
||||||
|
// Backward compatibility: use text if provided, otherwise use label
|
||||||
|
const label = textProp !== undefined ? textProp : labelProp;
|
||||||
|
|
||||||
// Normalize props to handle both PascalCase (Figma) and lowercase (codebase)
|
// Normalize props to handle both PascalCase (Figma) and lowercase (codebase)
|
||||||
const state = normalizeState(stateProp);
|
const state = normalizeState(stateProp);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,15 @@ export interface SwitchProps extends Omit<
|
|||||||
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||||
"onChange"
|
"onChange"
|
||||||
> {
|
> {
|
||||||
|
/**
|
||||||
|
* Whether the switch is checked (backward compatibility - use propSwitch instead).
|
||||||
|
*/
|
||||||
checked?: boolean;
|
checked?: boolean;
|
||||||
|
/**
|
||||||
|
* Whether the switch is checked (Figma prop).
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
propSwitch?: boolean;
|
||||||
onChange?: (
|
onChange?: (
|
||||||
_e:
|
_e:
|
||||||
| React.MouseEvent<HTMLButtonElement>
|
| React.MouseEvent<HTMLButtonElement>
|
||||||
@@ -17,7 +25,14 @@ export interface SwitchProps extends Omit<
|
|||||||
* Figma uses PascalCase, codebase uses lowercase - both are supported.
|
* Figma uses PascalCase, codebase uses lowercase - both are supported.
|
||||||
*/
|
*/
|
||||||
state?: StateValue;
|
state?: StateValue;
|
||||||
|
/**
|
||||||
|
* Label text (backward compatibility - use text instead).
|
||||||
|
*/
|
||||||
label?: string;
|
label?: string;
|
||||||
|
/**
|
||||||
|
* Label text (Figma prop).
|
||||||
|
*/
|
||||||
|
text?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ const TextAreaContainer = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|||||||
name,
|
name,
|
||||||
className = "",
|
className = "",
|
||||||
rows,
|
rows,
|
||||||
|
textHint = false,
|
||||||
|
formHeader = true,
|
||||||
|
showHelpIcon = false,
|
||||||
...props
|
...props
|
||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
@@ -174,6 +177,9 @@ const TextAreaContainer = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|||||||
handleFocus={handleFocus}
|
handleFocus={handleFocus}
|
||||||
handleBlur={handleBlur}
|
handleBlur={handleBlur}
|
||||||
aria-invalid={error}
|
aria-invalid={error}
|
||||||
|
textHint={textHint}
|
||||||
|
formHeader={formHeader}
|
||||||
|
showHelpIcon={showHelpIcon}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -32,6 +32,21 @@ export interface TextAreaProps extends Omit<
|
|||||||
onBlur?: (_e: React.FocusEvent<HTMLTextAreaElement>) => void;
|
onBlur?: (_e: React.FocusEvent<HTMLTextAreaElement>) => void;
|
||||||
className?: string;
|
className?: string;
|
||||||
rows?: number;
|
rows?: number;
|
||||||
|
/**
|
||||||
|
* Whether to show hint text below textarea (Figma prop).
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
textHint?: boolean;
|
||||||
|
/**
|
||||||
|
* Whether to show form header (label and help icon) above textarea (Figma prop).
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
formHeader?: boolean;
|
||||||
|
/**
|
||||||
|
* Whether to show help icon in label.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
showHelpIcon?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TextAreaViewProps {
|
export interface TextAreaViewProps {
|
||||||
@@ -55,4 +70,7 @@ export interface TextAreaViewProps {
|
|||||||
handleChange: (_e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
handleChange: (_e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
||||||
handleFocus: (_e: React.FocusEvent<HTMLTextAreaElement>) => void;
|
handleFocus: (_e: React.FocusEvent<HTMLTextAreaElement>) => void;
|
||||||
handleBlur: (_e: React.FocusEvent<HTMLTextAreaElement>) => void;
|
handleBlur: (_e: React.FocusEvent<HTMLTextAreaElement>) => void;
|
||||||
|
textHint?: boolean;
|
||||||
|
formHeader?: boolean;
|
||||||
|
showHelpIcon?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { forwardRef } from "react";
|
import { forwardRef } from "react";
|
||||||
|
import { getAssetPath, ASSETS } from "../../../../lib/assetUtils";
|
||||||
import type { TextAreaViewProps } from "./TextArea.types";
|
import type { TextAreaViewProps } from "./TextArea.types";
|
||||||
|
|
||||||
export const TextAreaView = forwardRef<HTMLTextAreaElement, TextAreaViewProps>(
|
export const TextAreaView = forwardRef<HTMLTextAreaElement, TextAreaViewProps>(
|
||||||
@@ -20,20 +21,36 @@ export const TextAreaView = forwardRef<HTMLTextAreaElement, TextAreaViewProps>(
|
|||||||
handleChange,
|
handleChange,
|
||||||
handleFocus,
|
handleFocus,
|
||||||
handleBlur,
|
handleBlur,
|
||||||
|
textHint = false,
|
||||||
|
formHeader = true,
|
||||||
|
showHelpIcon = false,
|
||||||
...props
|
...props
|
||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
) => {
|
) => {
|
||||||
return (
|
return (
|
||||||
<div className={containerClasses}>
|
<div className={containerClasses}>
|
||||||
{label && (
|
{formHeader && label && (
|
||||||
<label
|
<div className="flex flex-wrap gap-[var(--measures-spacing-200,4px_8px)] items-baseline pr-[var(--measures-spacing-100,4px)] relative shrink-0 w-full">
|
||||||
id={labelId}
|
<div className="flex gap-[var(--measures-spacing-050,2px)] items-center relative shrink-0">
|
||||||
htmlFor={textareaId}
|
<label
|
||||||
className={`${labelClasses} font-inter font-medium text-[var(--color-content-default-secondary)]`}
|
id={labelId}
|
||||||
>
|
htmlFor={textareaId}
|
||||||
{label}
|
className={`${labelClasses} font-inter font-medium text-[var(--color-content-default-secondary)]`}
|
||||||
</label>
|
>
|
||||||
|
{label}
|
||||||
|
</label>
|
||||||
|
{showHelpIcon && (
|
||||||
|
<div className="relative shrink-0 size-[12px]">
|
||||||
|
<img
|
||||||
|
src={getAssetPath(ASSETS.ICON_HELP)}
|
||||||
|
alt="Help"
|
||||||
|
className="block max-w-none size-full"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className={disabled ? "opacity-40" : ""}>
|
<div className={disabled ? "opacity-40" : ""}>
|
||||||
<textarea
|
<textarea
|
||||||
@@ -54,6 +71,13 @@ export const TextAreaView = forwardRef<HTMLTextAreaElement, TextAreaViewProps>(
|
|||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
{textHint && (
|
||||||
|
<div className="flex items-start relative shrink-0 w-full">
|
||||||
|
<p className="flex-[1_0_0] font-inter font-normal leading-[16px] min-h-px min-w-px relative text-[color:var(--color-content-default-tertiary,#b4b4b4)] text-[length:var(--sizing-300,12px)]">
|
||||||
|
Hint text here
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,6 +17,36 @@ export interface CreateProps {
|
|||||||
className?: string;
|
className?: string;
|
||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
ariaLabelledBy?: string;
|
ariaLabelledBy?: string;
|
||||||
|
/**
|
||||||
|
* Whether to enable Create block array content type (Figma prop).
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
createBlockArray?: boolean;
|
||||||
|
/**
|
||||||
|
* Whether to enable Text input content type (Figma prop).
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
textInput?: boolean;
|
||||||
|
/**
|
||||||
|
* Whether to enable Text area content type (Figma prop).
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
textArea?: boolean;
|
||||||
|
/**
|
||||||
|
* Whether to enable Multi-select content type (Figma prop).
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
multiSelect?: boolean;
|
||||||
|
/**
|
||||||
|
* Whether to enable Upload content type (Figma prop).
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
upload?: boolean;
|
||||||
|
/**
|
||||||
|
* Whether to enable Proportion content type (Figma prop).
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
proportion?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateViewProps {
|
export interface CreateViewProps {
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ export interface ModalFooterProps {
|
|||||||
nextButtonDisabled?: boolean;
|
nextButtonDisabled?: boolean;
|
||||||
currentStep?: number;
|
currentStep?: number;
|
||||||
totalSteps?: number;
|
totalSteps?: number;
|
||||||
|
/**
|
||||||
|
* Whether to show the stepper component in the footer (Figma prop).
|
||||||
|
* Defaults to true if currentStep and totalSteps are provided.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
stepper?: boolean;
|
||||||
footerContent?: React.ReactNode;
|
footerContent?: React.ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export function ModalFooterView({
|
|||||||
nextButtonDisabled = false,
|
nextButtonDisabled = false,
|
||||||
currentStep,
|
currentStep,
|
||||||
totalSteps,
|
totalSteps,
|
||||||
|
stepper: stepperProp,
|
||||||
footerContent,
|
footerContent,
|
||||||
className = "",
|
className = "",
|
||||||
}: ModalFooterProps) {
|
}: ModalFooterProps) {
|
||||||
@@ -23,6 +24,13 @@ export function ModalFooterView({
|
|||||||
// Use localized defaults if text not provided
|
// Use localized defaults if text not provided
|
||||||
const defaultBackText = backButtonText || t("buttons.back");
|
const defaultBackText = backButtonText || t("buttons.back");
|
||||||
const defaultNextText = nextButtonText || t("buttons.next");
|
const defaultNextText = nextButtonText || t("buttons.next");
|
||||||
|
|
||||||
|
// Determine if stepper should be shown
|
||||||
|
// Defaults to true if currentStep and totalSteps are provided, unless explicitly set to false
|
||||||
|
const shouldShowStepper = stepperProp !== undefined
|
||||||
|
? stepperProp
|
||||||
|
: (currentStep !== undefined && totalSteps !== undefined);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`h-[64px] bg-[var(--color-surface-default-primary)] rounded-bl-[var(--radius-300,12px)] rounded-br-[var(--radius-300,12px)] shrink-0 relative ${className}`}
|
className={`h-[64px] bg-[var(--color-surface-default-primary)] rounded-bl-[var(--radius-300,12px)] rounded-br-[var(--radius-300,12px)] shrink-0 relative ${className}`}
|
||||||
@@ -37,7 +45,7 @@ export function ModalFooterView({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Stepper (Centered) */}
|
{/* Stepper (Centered) */}
|
||||||
{currentStep && totalSteps && (
|
{shouldShowStepper && currentStep && totalSteps && (
|
||||||
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2">
|
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2">
|
||||||
<Stepper active={currentStep} totalSteps={totalSteps} />
|
<Stepper active={currentStep} totalSteps={totalSteps} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user