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(action-sheet, alert, toast): button roles autocomplete with available options #27940

Merged
merged 7 commits into from
Jan 30, 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
4 changes: 2 additions & 2 deletions core/src/components/action-sheet/action-sheet-interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnimationBuilder, Mode } from '../../interface';
import type { AnimationBuilder, LiteralUnion, Mode } from '../../interface';

export interface ActionSheetOptions {
header?: string;
Expand All @@ -19,7 +19,7 @@ export interface ActionSheetOptions {

export interface ActionSheetButton<T = any> {
text?: string;
role?: 'cancel' | 'destructive' | 'selected' | string;
role?: LiteralUnion<'cancel' | 'destructive' | 'selected', string>;
icon?: string;
cssClass?: string | string[];
id?: string;
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/alert/alert-interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnimationBuilder, Mode, TextFieldTypes } from '../../interface';
import type { AnimationBuilder, LiteralUnion, Mode, TextFieldTypes } from '../../interface';
import type { IonicSafeString } from '../../utils/sanitization';

export interface AlertOptions {
Expand Down Expand Up @@ -45,7 +45,7 @@ type AlertButtonOverlayHandler = boolean | void | { [key: string]: any };

export interface AlertButton {
text: string;
role?: 'cancel' | 'destructive' | string;
role?: LiteralUnion<'cancel' | 'destructive', string>;
cssClass?: string | string[];
id?: string;
htmlAttributes?: { [key: string]: any };
Expand Down
5 changes: 2 additions & 3 deletions core/src/components/toast/toast-interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnimationBuilder, Color, Mode } from '../../interface';
import type { AnimationBuilder, Color, LiteralUnion, Mode } from '../../interface';
import type { IonicSafeString } from '../../utils/sanitization';

export interface ToastOptions {
Expand Down Expand Up @@ -33,8 +33,7 @@ export interface ToastButton {
text?: string;
icon?: string;
side?: 'start' | 'end';
role?: 'cancel' | string;

role?: LiteralUnion<'cancel', string>;
/**
* @deprecated Use the toast button's CSS Shadow Parts instead.
*/
Expand Down
2 changes: 1 addition & 1 deletion core/src/interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export type PredefinedColors =
| 'medium'
| 'dark';

type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
export type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);

export type Color = LiteralUnion<PredefinedColors, string>;
export type Mode = 'ios' | 'md';
Expand Down
Loading