Skip to content

Commit

Permalink
refactor(types): remove overlay attribute interfaces (#26181)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

`ActionSheetAttributes`, `AlertAttributes`, `AlertTextareaAttributes`, `AlertInputAttributes`, `LoadingAttributes`, `ModalAttributes`, `PickerAttributes`, `PopoverAttributes`, and `ToastAttributes` have been removed. Developers should use `{ [key: string]: any }` instead.
  • Loading branch information
liamdebeasi committed Oct 28, 2022
1 parent 34ca337 commit 322a1db
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 94 deletions.
8 changes: 8 additions & 0 deletions BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ This is a comprehensive list of the breaking changes introduced in the major ver
- [Textarea](#version-7x-textarea)
- [Toggle](#version-7x-toggle)
- [Virtual Scroll](#version-7x-virtual-scroll)
- [Types](#version-7x-types)
- [Overlay Attribute Interfaces](#version-7x-overlay-attribute-interfaces)
- [JavaScript Frameworks](#version-7x-javascript-frameworks)
- [React](#version-7x-react)
- [Vue](#version-7x-vue)
Expand Down Expand Up @@ -182,6 +184,12 @@ Developers using the component will need to migrate to a virtual scroll solution

Any references to the virtual scroll types from `@ionic/core` have been removed. Please remove or replace these types: `Cell`, `VirtualNode`, `CellType`, `NodeChange`, `HeaderFn`, `ItemHeightFn`, `FooterHeightFn`, `ItemRenderFn` and `DomRenderFn`.

<h2 id="version-7x-types">Types</h2>

<h4 id="version-7x-overlay-attribute-interfaces">Overlay Attribute Interfaces</h4>

`ActionSheetAttributes`, `AlertAttributes`, `AlertTextareaAttributes`, `AlertInputAttributes`, `LoadingAttributes`, `ModalAttributes`, `PickerAttributes`, `PopoverAttributes`, and `ToastAttributes` have been removed. Developers should use `{ [key: string]: any }` instead.

<h2 id="version-7x-javascript-frameworks">JavaScript Frameworks</h2>

<h4 id="version-7x-react">React</h4>
Expand Down
2 changes: 0 additions & 2 deletions angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export {
ActionSheetButton,
AlertOptions,
AlertInput,
AlertTextareaAttributes,
AlertInputAttributes,
AlertButton,
BackButtonEvent,
CheckboxCustomEvent,
Expand Down
32 changes: 15 additions & 17 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
* It contains typing information for all components that exist in this project.
*/
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
import { AccordionGroupChangeEventDetail, ActionSheetAttributes, ActionSheetButton, AlertButton, AlertInput, AnimationBuilder, AutocompleteTypes, BreadcrumbCollapsedClickEventDetail, CheckboxChangeEventDetail, Color, ComponentProps, ComponentRef, DatetimeChangeEventDetail, DatetimePresentation, FrameworkDelegate, InputChangeEventDetail, InputInputEventDetail, ItemReorderEventDetail, LoadingAttributes, MenuChangeEventDetail, ModalAttributes, ModalBreakpointChangeEventDetail, ModalHandleBehavior, NavComponent, NavComponentWithProps, NavOptions, OverlayEventDetail, PickerAttributes, PickerButton, PickerColumn, PopoverAttributes, PopoverSize, PositionAlign, PositionReference, PositionSide, RadioGroupChangeEventDetail, RangeChangeEventDetail, RangeKnobMoveEndEventDetail, RangeKnobMoveStartEventDetail, RangeValue, RefresherEventDetail, RouteID, RouterDirection, RouterEventDetail, RouterOutletOptions, RouteWrite, ScrollBaseDetail, ScrollDetail, SearchbarChangeEventDetail, SegmentButtonLayout, SegmentChangeEventDetail, SelectChangeEventDetail, SelectInterface, SelectPopoverOption, Side, SpinnerTypes, StyleEventDetail, SwipeGestureHandler, TabBarChangedEventDetail, TabButtonClickEventDetail, TabButtonLayout, TextareaChangeEventDetail, TextFieldTypes, TitleSelectedDatesFormatter, ToastButton, ToggleChangeEventDetail, TransitionDoneFn, TransitionInstruction, TriggerAction, ViewController } from "./interface";
import { AccordionGroupChangeEventDetail, ActionSheetButton, AlertButton, AlertInput, AnimationBuilder, AutocompleteTypes, BreadcrumbCollapsedClickEventDetail, CheckboxChangeEventDetail, Color, ComponentProps, ComponentRef, DatetimeChangeEventDetail, DatetimePresentation, FrameworkDelegate, InputChangeEventDetail, InputInputEventDetail, ItemReorderEventDetail, MenuChangeEventDetail, ModalBreakpointChangeEventDetail, ModalHandleBehavior, NavComponent, NavComponentWithProps, NavOptions, OverlayEventDetail, PickerButton, PickerColumn, PopoverSize, PositionAlign, PositionReference, PositionSide, RadioGroupChangeEventDetail, RangeChangeEventDetail, RangeKnobMoveEndEventDetail, RangeKnobMoveStartEventDetail, RangeValue, RefresherEventDetail, RouteID, RouterDirection, RouterEventDetail, RouterOutletOptions, RouteWrite, ScrollBaseDetail, ScrollDetail, SearchbarChangeEventDetail, SegmentButtonLayout, SegmentChangeEventDetail, SelectChangeEventDetail, SelectInterface, SelectPopoverOption, Side, SpinnerTypes, StyleEventDetail, SwipeGestureHandler, TabBarChangedEventDetail, TabButtonClickEventDetail, TabButtonLayout, TextareaChangeEventDetail, TextFieldTypes, TitleSelectedDatesFormatter, ToastButton, ToggleChangeEventDetail, TransitionDoneFn, TransitionInstruction, TriggerAction, ViewController } from "./interface";
import { IonicSafeString } from "./utils/sanitization";
import { AlertAttributes } from "./components/alert/alert-interface";
import { CounterFormatter } from "./components/item/item-interface";
import { PickerColumnItem } from "./components/picker-column-internal/picker-column-internal-interfaces";
import { PickerInternalChangeEventDetail } from "./components/picker-internal/picker-internal-interfaces";
import { PinFormatter } from "./components/range/range-interface";
import { NavigationHookCallback } from "./components/route/route-interface";
import { SelectCompareFn } from "./components/select/select-interface";
import { ToastAttributes } from "./components/toast/toast-interface";
export namespace Components {
interface IonAccordion {
/**
Expand Down Expand Up @@ -111,7 +109,7 @@ export namespace Components {
/**
* Additional attributes to pass to the action sheet.
*/
"htmlAttributes"?: ActionSheetAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* If `true`, the keyboard will be automatically dismissed when the overlay is presented.
*/
Expand Down Expand Up @@ -180,7 +178,7 @@ export namespace Components {
/**
* Additional attributes to pass to the alert.
*/
"htmlAttributes"?: AlertAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* Array of input to show in the alert.
*/
Expand Down Expand Up @@ -1404,7 +1402,7 @@ export namespace Components {
/**
* Additional attributes to pass to the loader.
*/
"htmlAttributes"?: LoadingAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* If `true`, the loading indicator will open. If `false`, the loading indicator will close. Use this if you need finer grained control over presentation, otherwise just use the loadingController or the `trigger` property. Note: `isOpen` will not automatically be set back to `false` when the loading indicator dismisses. You will need to do that in your code.
*/
Expand Down Expand Up @@ -1605,7 +1603,7 @@ export namespace Components {
/**
* Additional attributes to pass to the modal.
*/
"htmlAttributes"?: ModalAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* A decimal value between 0 and 1 that indicates the initial point the modal will open at when creating a sheet modal. This value must also be listed in the `breakpoints` array.
*/
Expand Down Expand Up @@ -1853,7 +1851,7 @@ export namespace Components {
/**
* Additional attributes to pass to the picker.
*/
"htmlAttributes"?: PickerAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* If `true`, the keyboard will be automatically dismissed when the overlay is presented.
*/
Expand Down Expand Up @@ -1977,7 +1975,7 @@ export namespace Components {
/**
* Additional attributes to pass to the popover.
*/
"htmlAttributes"?: PopoverAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* If `true`, the popover will open. If `false`, the popover will close. Use this if you need finer grained control over presentation, otherwise just use the popoverController or the `trigger` property. Note: `isOpen` will not automatically be set back to `false` when the popover dismisses. You will need to do that in your code.
*/
Expand Down Expand Up @@ -2862,7 +2860,7 @@ export namespace Components {
/**
* Additional attributes to pass to the toast.
*/
"htmlAttributes"?: ToastAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* The name of the icon to display, or the path to a valid SVG file. See `ion-icon`. https://ionic.io/ionicons
*/
Expand Down Expand Up @@ -3864,7 +3862,7 @@ declare namespace LocalJSX {
/**
* Additional attributes to pass to the action sheet.
*/
"htmlAttributes"?: ActionSheetAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* If `true`, the keyboard will be automatically dismissed when the overlay is presented.
*/
Expand Down Expand Up @@ -3931,7 +3929,7 @@ declare namespace LocalJSX {
/**
* Additional attributes to pass to the alert.
*/
"htmlAttributes"?: AlertAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* Array of input to show in the alert.
*/
Expand Down Expand Up @@ -5206,7 +5204,7 @@ declare namespace LocalJSX {
/**
* Additional attributes to pass to the loader.
*/
"htmlAttributes"?: LoadingAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* If `true`, the loading indicator will open. If `false`, the loading indicator will close. Use this if you need finer grained control over presentation, otherwise just use the loadingController or the `trigger` property. Note: `isOpen` will not automatically be set back to `false` when the loading indicator dismisses. You will need to do that in your code.
*/
Expand Down Expand Up @@ -5413,7 +5411,7 @@ declare namespace LocalJSX {
/**
* Additional attributes to pass to the modal.
*/
"htmlAttributes"?: ModalAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* A decimal value between 0 and 1 that indicates the initial point the modal will open at when creating a sheet modal. This value must also be listed in the `breakpoints` array.
*/
Expand Down Expand Up @@ -5583,7 +5581,7 @@ declare namespace LocalJSX {
/**
* Additional attributes to pass to the picker.
*/
"htmlAttributes"?: PickerAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* If `true`, the keyboard will be automatically dismissed when the overlay is presented.
*/
Expand Down Expand Up @@ -5707,7 +5705,7 @@ declare namespace LocalJSX {
/**
* Additional attributes to pass to the popover.
*/
"htmlAttributes"?: PopoverAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* If `true`, the popover will open. If `false`, the popover will close. Use this if you need finer grained control over presentation, otherwise just use the popoverController or the `trigger` property. Note: `isOpen` will not automatically be set back to `false` when the popover dismisses. You will need to do that in your code.
*/
Expand Down Expand Up @@ -6708,7 +6706,7 @@ declare namespace LocalJSX {
/**
* Additional attributes to pass to the toast.
*/
"htmlAttributes"?: ToastAttributes;
"htmlAttributes"?: { [key: string]: any };
/**
* The name of the icon to display, or the path to a valid SVG file. See `ion-icon`. https://ionic.io/ionicons
*/
Expand Down
7 changes: 1 addition & 6 deletions core/src/components/action-sheet/action-sheet-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@ export interface ActionSheetOptions {
mode?: Mode;
keyboardClose?: boolean;
id?: string;
htmlAttributes?: ActionSheetAttributes;
htmlAttributes?: { [key: string]: any };

enterAnimation?: AnimationBuilder;
leaveAnimation?: AnimationBuilder;
}

/**
* @deprecated - Use { [key: string]: any } directly instead.
*/
export type ActionSheetAttributes = { [key: string]: any };

export interface ActionSheetButton<T = any> {
text?: string;
role?: 'cancel' | 'destructive' | 'selected' | string;
Expand Down
3 changes: 1 addition & 2 deletions core/src/components/action-sheet/action-sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Component, Element, Event, Host, Method, Prop, h, readTask } from '@ste

import { getIonMode } from '../../global/ionic-global';
import type {
ActionSheetAttributes,
ActionSheetButton,
AnimationBuilder,
CssClassMap,
Expand Down Expand Up @@ -100,7 +99,7 @@ export class ActionSheet implements ComponentInterface, OverlayInterface {
/**
* Additional attributes to pass to the action sheet.
*/
@Prop() htmlAttributes?: ActionSheetAttributes;
@Prop() htmlAttributes?: { [key: string]: any };

/**
* Emitted after the alert has presented.
Expand Down
19 changes: 2 additions & 17 deletions core/src/components/alert/alert-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface AlertOptions {
backdropDismiss?: boolean;
translucent?: boolean;
animated?: boolean;
htmlAttributes?: AlertAttributes;
htmlAttributes?: { [key: string]: any };

mode?: Mode;
keyboardClose?: boolean;
Expand All @@ -21,11 +21,6 @@ export interface AlertOptions {
leaveAnimation?: AnimationBuilder;
}

/**
* @deprecated - Use { [key: string]: any } directly instead.
*/
export type AlertAttributes = { [key: string]: any };

export interface AlertInput {
type?: TextFieldTypes | 'checkbox' | 'radio' | 'textarea';
name?: string;
Expand All @@ -39,20 +34,10 @@ export interface AlertInput {
min?: string | number;
max?: string | number;
cssClass?: string | string[];
attributes?: AlertInputAttributes | AlertTextareaAttributes;
attributes?: { [key: string]: any };
tabindex?: number;
}

/**
* @deprecated - Use { [key: string]: any } directly instead.
*/
export type AlertTextareaAttributes = { [key: string]: any };

/**
* @deprecated - Use { [key: string]: any } directly instead.
*/
export type AlertInputAttributes = { [key: string]: any };

type AlertButtonOverlayHandler = boolean | void | { [key: string]: any };

export interface AlertButton {
Expand Down
9 changes: 3 additions & 6 deletions core/src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { getIonMode } from '../../global/ionic-global';
import type {
AlertButton,
AlertInput,
AlertInputAttributes,
AlertTextareaAttributes,
AnimationBuilder,
CssClassMap,
OverlayEventDetail,
Expand All @@ -19,7 +17,6 @@ import type { IonicSafeString } from '../../utils/sanitization';
import { sanitizeDOMString } from '../../utils/sanitization';
import { getClassMap } from '../../utils/theme';

import type { AlertAttributes } from './alert-interface';
import { iosEnterAnimation } from './animations/ios.enter';
import { iosLeaveAnimation } from './animations/ios.leave';
import { mdEnterAnimation } from './animations/md.enter';
Expand Down Expand Up @@ -124,7 +121,7 @@ export class Alert implements ComponentInterface, OverlayInterface {
/**
* Additional attributes to pass to the alert.
*/
@Prop() htmlAttributes?: AlertAttributes;
@Prop() htmlAttributes?: { [key: string]: any };

/**
* Emitted after the alert has presented.
Expand Down Expand Up @@ -499,7 +496,7 @@ export class Alert implements ComponentInterface, OverlayInterface {
value={i.value}
id={i.id}
tabIndex={i.tabindex}
{...(i.attributes as AlertTextareaAttributes)}
{...(i.attributes as { [key: string]: any })}
disabled={i.attributes?.disabled ?? i.disabled}
class={inputClass(i)}
onInput={(e) => {
Expand All @@ -522,7 +519,7 @@ export class Alert implements ComponentInterface, OverlayInterface {
value={i.value}
id={i.id}
tabIndex={i.tabindex}
{...(i.attributes as AlertInputAttributes)}
{...(i.attributes as { [key: string]: any })}
disabled={i.attributes?.disabled ?? i.disabled}
class={inputClass(i)}
onInput={(e) => {
Expand Down
7 changes: 1 addition & 6 deletions core/src/components/loading/loading-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ export interface LoadingOptions {
mode?: Mode;
keyboardClose?: boolean;
id?: string;
htmlAttributes?: LoadingAttributes;
htmlAttributes?: { [key: string]: any };

enterAnimation?: AnimationBuilder;
leaveAnimation?: AnimationBuilder;
}

/**
* @deprecated - Use { [key: string]: any } directly instead.
*/
export type LoadingAttributes = { [key: string]: any };
3 changes: 1 addition & 2 deletions core/src/components/loading/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getIonMode } from '../../global/ionic-global';
import type {
AnimationBuilder,
FrameworkDelegate,
LoadingAttributes,
OverlayEventDetail,
OverlayInterface,
SpinnerTypes,
Expand Down Expand Up @@ -122,7 +121,7 @@ export class Loading implements ComponentInterface, OverlayInterface {
/**
* Additional attributes to pass to the loader.
*/
@Prop() htmlAttributes?: LoadingAttributes;
@Prop() htmlAttributes?: { [key: string]: any };

/**
* If `true`, the loading indicator will open. If `false`, the loading indicator will close.
Expand Down
7 changes: 1 addition & 6 deletions core/src/components/modal/modal-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface ModalOptions<T extends ComponentRef = ComponentRef> {
mode?: Mode;
keyboardClose?: boolean;
id?: string;
htmlAttributes?: ModalAttributes;
htmlAttributes?: { [key: string]: any };

enterAnimation?: AnimationBuilder;
leaveAnimation?: AnimationBuilder;
Expand All @@ -40,11 +40,6 @@ export interface ModalCustomEvent extends CustomEvent {
target: HTMLIonModalElement;
}

/**
* @deprecated - Use { [key: string]: any } directly instead.
*/
export type ModalAttributes = { [key: string]: any };

/**
* The behavior setting for modals when the handle is pressed.
*/
Expand Down
3 changes: 1 addition & 2 deletions core/src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type {
ComponentRef,
FrameworkDelegate,
Gesture,
ModalAttributes,
ModalBreakpointChangeEventDetail,
ModalHandleBehavior,
OverlayEventDetail,
Expand Down Expand Up @@ -202,7 +201,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
/**
* Additional attributes to pass to the modal.
*/
@Prop() htmlAttributes?: ModalAttributes;
@Prop() htmlAttributes?: { [key: string]: any };

/**
* If `true`, the modal will open. If `false`, the modal will close.
Expand Down
7 changes: 1 addition & 6 deletions core/src/components/picker/picker-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@ export interface PickerOptions {
mode?: Mode;
keyboardClose?: boolean;
id?: string;
htmlAttributes?: PickerAttributes;
htmlAttributes?: { [key: string]: any };

enterAnimation?: AnimationBuilder;
leaveAnimation?: AnimationBuilder;
}

/**
* @deprecated - Use { [key: string]: any } directly instead.
*/
export type PickerAttributes = { [key: string]: any };

export interface PickerButton {
text?: string;
role?: string;
Expand Down

0 comments on commit 322a1db

Please sign in to comment.