mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 11:17:19 +08:00
feat(segment-view): support disabled
This commit is contained in:
8
core/src/components.d.ts
vendored
8
core/src/components.d.ts
vendored
@ -2719,6 +2719,10 @@ export namespace Components {
|
|||||||
interface IonSegmentContent {
|
interface IonSegmentContent {
|
||||||
}
|
}
|
||||||
interface IonSegmentView {
|
interface IonSegmentView {
|
||||||
|
/**
|
||||||
|
* If `true`, the segment view cannot be interacted with.
|
||||||
|
*/
|
||||||
|
"disabled": boolean;
|
||||||
"setContent": (id: string) => Promise<void>;
|
"setContent": (id: string) => Promise<void>;
|
||||||
}
|
}
|
||||||
interface IonSelect {
|
interface IonSelect {
|
||||||
@ -7498,6 +7502,10 @@ declare namespace LocalJSX {
|
|||||||
interface IonSegmentContent {
|
interface IonSegmentContent {
|
||||||
}
|
}
|
||||||
interface IonSegmentView {
|
interface IonSegmentView {
|
||||||
|
/**
|
||||||
|
* If `true`, the segment view cannot be interacted with.
|
||||||
|
*/
|
||||||
|
"disabled"?: boolean;
|
||||||
}
|
}
|
||||||
interface IonSelect {
|
interface IonSelect {
|
||||||
/**
|
/**
|
||||||
|
@ -20,3 +20,12 @@
|
|||||||
:host::-webkit-scrollbar {
|
:host::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host(.segment-view-disabled) {
|
||||||
|
scroll-snap-type: none;
|
||||||
|
|
||||||
|
touch-action: none;
|
||||||
|
overflow-x: hidden;
|
||||||
|
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { ComponentInterface } from '@stencil/core';
|
import type { ComponentInterface } from '@stencil/core';
|
||||||
import { Component, Element, Host, Listen, Method, h } from '@stencil/core';
|
import { Component, Element, Host, Listen, Method, Prop, h } from '@stencil/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-segment-view',
|
tag: 'ion-segment-view',
|
||||||
@ -9,6 +9,11 @@ import { Component, Element, Host, Listen, Method, h } from '@stencil/core';
|
|||||||
export class SegmentView implements ComponentInterface {
|
export class SegmentView implements ComponentInterface {
|
||||||
@Element() el!: HTMLElement;
|
@Element() el!: HTMLElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If `true`, the segment view cannot be interacted with.
|
||||||
|
*/
|
||||||
|
@Prop() disabled = false;
|
||||||
|
|
||||||
@Listen('scroll')
|
@Listen('scroll')
|
||||||
handleScroll(ev: any) {
|
handleScroll(ev: any) {
|
||||||
const { scrollLeft, offsetWidth } = ev.target;
|
const { scrollLeft, offsetWidth } = ev.target;
|
||||||
@ -59,8 +64,14 @@ export class SegmentView implements ComponentInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { disabled } = this;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Host>
|
<Host
|
||||||
|
class={{
|
||||||
|
'segment-view-disabled': disabled,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</Host>
|
</Host>
|
||||||
);
|
);
|
||||||
|
@ -55,6 +55,25 @@
|
|||||||
<ion-segment-content id="free">Free</ion-segment-content>
|
<ion-segment-content id="free">Free</ion-segment-content>
|
||||||
<ion-segment-content id="top">Top</ion-segment-content>
|
<ion-segment-content id="top">Top</ion-segment-content>
|
||||||
</ion-segment-view>
|
</ion-segment-view>
|
||||||
|
|
||||||
|
<ion-toolbar>
|
||||||
|
<ion-segment disabled color="danger">
|
||||||
|
<ion-segment-button content-id="bookmarks" value="Bookmarks">
|
||||||
|
<ion-label>Bookmarks</ion-label>
|
||||||
|
</ion-segment-button>
|
||||||
|
<ion-segment-button content-id="reading-list" value="Reading List">
|
||||||
|
<ion-label>Reading List</ion-label>
|
||||||
|
</ion-segment-button>
|
||||||
|
<ion-segment-button content-id="shared-links" value="Shared Links">
|
||||||
|
<ion-label>Shared Links</ion-label>
|
||||||
|
</ion-segment-button>
|
||||||
|
</ion-segment>
|
||||||
|
</ion-toolbar>
|
||||||
|
<ion-segment-view disabled>
|
||||||
|
<ion-segment-content id="bookmarks">Bookmarks</ion-segment-content>
|
||||||
|
<ion-segment-content id="reading-list">Reading List</ion-segment-content>
|
||||||
|
<ion-segment-content id="shared-links">Shared Links</ion-segment-content>
|
||||||
|
</ion-segment-view>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
||||||
<ion-footer>
|
<ion-footer>
|
||||||
|
@ -2027,6 +2027,7 @@ export declare interface IonSegmentContent extends Components.IonSegmentContent
|
|||||||
|
|
||||||
|
|
||||||
@ProxyCmp({
|
@ProxyCmp({
|
||||||
|
inputs: ['disabled'],
|
||||||
methods: ['setContent']
|
methods: ['setContent']
|
||||||
})
|
})
|
||||||
@Component({
|
@Component({
|
||||||
@ -2034,7 +2035,7 @@ export declare interface IonSegmentContent extends Components.IonSegmentContent
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
template: '<ng-content></ng-content>',
|
template: '<ng-content></ng-content>',
|
||||||
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
|
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
|
||||||
inputs: [],
|
inputs: ['disabled'],
|
||||||
})
|
})
|
||||||
export class IonSegmentView {
|
export class IonSegmentView {
|
||||||
protected el: HTMLElement;
|
protected el: HTMLElement;
|
||||||
|
@ -1865,6 +1865,7 @@ export declare interface IonSegmentContent extends Components.IonSegmentContent
|
|||||||
|
|
||||||
@ProxyCmp({
|
@ProxyCmp({
|
||||||
defineCustomElementFn: defineIonSegmentView,
|
defineCustomElementFn: defineIonSegmentView,
|
||||||
|
inputs: ['disabled'],
|
||||||
methods: ['setContent']
|
methods: ['setContent']
|
||||||
})
|
})
|
||||||
@Component({
|
@Component({
|
||||||
@ -1872,7 +1873,7 @@ export declare interface IonSegmentContent extends Components.IonSegmentContent
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
template: '<ng-content></ng-content>',
|
template: '<ng-content></ng-content>',
|
||||||
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
|
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
|
||||||
inputs: [],
|
inputs: ['disabled'],
|
||||||
standalone: true
|
standalone: true
|
||||||
})
|
})
|
||||||
export class IonSegmentView {
|
export class IonSegmentView {
|
||||||
|
@ -758,7 +758,9 @@ export const IonSegmentButton = /*@__PURE__*/ defineContainer<JSX.IonSegmentButt
|
|||||||
export const IonSegmentContent = /*@__PURE__*/ defineContainer<JSX.IonSegmentContent>('ion-segment-content', defineIonSegmentContent);
|
export const IonSegmentContent = /*@__PURE__*/ defineContainer<JSX.IonSegmentContent>('ion-segment-content', defineIonSegmentContent);
|
||||||
|
|
||||||
|
|
||||||
export const IonSegmentView = /*@__PURE__*/ defineContainer<JSX.IonSegmentView>('ion-segment-view', defineIonSegmentView);
|
export const IonSegmentView = /*@__PURE__*/ defineContainer<JSX.IonSegmentView>('ion-segment-view', defineIonSegmentView, [
|
||||||
|
'disabled'
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
export const IonSelect = /*@__PURE__*/ defineContainer<JSX.IonSelect, JSX.IonSelect["value"]>('ion-select', defineIonSelect, [
|
export const IonSelect = /*@__PURE__*/ defineContainer<JSX.IonSelect, JSX.IonSelect["value"]>('ion-select', defineIonSelect, [
|
||||||
|
Reference in New Issue
Block a user