import { DemoModalServiceStaticComponent } from './demos/service-template/service-template'; import { DemoModalServiceFromComponent } from './demos/service-component/service-component'; import { DemoModalServiceNestedComponent } from './demos/service-nested/service-nested'; import { DemoModalServiceEventsComponent } from './demos/service-events/service-events'; import { DemoModalServiceDisableAnimationComponent } from './demos/service-options/disable-animation/disable-animation'; import { DemoModalServiceCustomCSSClassComponent } from './demos/service-options/custom-css-class/custom-css-class'; import { DemoModalServiceDisableEscClosingComponent } from './demos/service-options/disable-esc-closing/disable-esc-closing'; import { DemoModalServiceDisableBackdropComponent } from './demos/service-options/disable-backdrop/disable-backdrop'; import { DemoModalServiceConfirmWindowComponent } from './demos/service-confirm-window/service-confirm-window'; import { DemoModalServiceChangeClassComponent } from './demos/service-options/change-class/change-class'; import { DemoModalStaticComponent } from './demos/static/static'; import { DemoModalSizesComponent } from './demos/sizes/sizes'; import { DemoModalChildComponent } from './demos/child/child'; import { DemoModalNestedComponent } from './demos/nested/nested'; import { DemoModalEventsComponent } from './demos/events/events'; import { DemoAutoShownModalComponent } from './demos/auto-shown/auto-shown'; import { DemoAccessibilityComponent } from './demos/accessibility/accessibility'; import { DemoModalWithPopupsComponent } from './demos/modal-with-popups/modal-with-popups'; import { ContentSection } from '@ngx-bootstrap-doc/docs'; import { ExamplesComponent } from '@ngx-bootstrap-doc/docs'; import { ApiSectionsComponent } from '@ngx-bootstrap-doc/docs'; import { NgApiDocComponent, NgApiDocClassComponent, NgApiDocConfigComponent } from '@ngx-bootstrap-doc/docs'; import { DemoModalScrollingLongContentComponent } from './demos/scrolling-long-content/scrolling-long-content'; import { DemoModalRefEventsComponent } from './demos/modal-ref-events/modal-ref-events'; import { DemoModalServiceWithInterceptorComponent } from './demos/service-interceptor/service-interceptor'; export const demoComponentContent: ContentSection[] = [ { name: 'Overview', anchor: 'overview', tabName: 'overview', outlet: ExamplesComponent, content: [ { title: 'Service examples', anchor: 'service-section', description: `

Open a modal from service.

To be able to open modals from service, inject BsModalService to your constructor.
Then, call .show() method of modal service. Pass a TemplateRef or a component as a first argument and config as a second (optionally).
.show() method returns an instance of BsModalRef class with .hide() method and content property where you'll find a component which you've passed to service.

` }, { title: 'Template', anchor: 'service-template', component: require('!!raw-loader!./demos/service-template/service-template.ts'), html: require('!!raw-loader!./demos/service-template/service-template.html'), outlet: DemoModalServiceStaticComponent }, { title: 'Component', anchor: 'service-component', component: require('!!raw-loader!./demos/service-component/service-component.ts'), html: require('!!raw-loader!./demos/service-component/service-component.html'), description: `

Creating a modal with component just as easy as it is with template. Just pass your component in .show() method as in example, and don't forget to include your component to entryComponents of your NgModule
If you passed a component to .show() you can get access to opened modal by injecting BsModalRef. Also you can pass data in your modal by adding initialState field in config. See example for more info

`, outlet: DemoModalServiceFromComponent }, { title: 'Nested', anchor: 'service-nested', component: require('!!raw-loader!./demos/service-nested/service-nested.ts'), html: require('!!raw-loader!./demos/service-nested/service-nested.html'), description: `

Nested modals are supported

`, outlet: DemoModalServiceNestedComponent }, { title: 'Scrolling long content', anchor: 'scrolling-long-content', component: require('!!raw-loader!./demos/scrolling-long-content/scrolling-long-content.ts'), html: require('!!raw-loader!./demos/scrolling-long-content/scrolling-long-content.html'), outlet: DemoModalScrollingLongContentComponent }, { title: 'Events', anchor: 'service-events', component: require('!!raw-loader!./demos/service-events/service-events.ts'), html: require('!!raw-loader!./demos/service-events/service-events.html'), description: `

Modal service events. Modal service exposes 4 events: onShow, onShown, onHide, onHidden. See usage example below.

onHide and onHidden events emit dismiss reason. Possible values are backdrop-click, esc or {id: number | string} if modal was closed by direct call of hide() method

`, outlet: DemoModalServiceEventsComponent }, { title: 'ModalRef Events', anchor: 'modal-ref-events', component: require('!!raw-loader!./demos/modal-ref-events/modal-ref-events.ts'), html: require('!!raw-loader!./demos/modal-ref-events/modal-ref-events.html'), description: `

Modal ref events. ModalRef exposes 2 events: onHide and onHidden. Note, onShow and onShown are not options because they have already fired by the time the ModalRef is created. See usage example below.

onHide and onHidden events emit dismiss reason. Possible values are backdrop-click, esc or {id: number | string} if modal was closed by direct call of hide() method

`, outlet: DemoModalRefEventsComponent }, { title: 'Confirm Window', anchor: 'confirm-window', component: require('!!raw-loader!./demos/service-confirm-window/service-confirm-window.ts'), html: require('!!raw-loader!./demos/service-confirm-window/service-confirm-window.html'), description: `

Modal with opportunity to confirm or decline.

`, outlet: DemoModalServiceConfirmWindowComponent }, { title: 'Сustom css class', anchor: 'service-custom-css-class', component: require('!!raw-loader!./demos/service-options/custom-css-class/custom-css-class.ts'), html: require('!!raw-loader!./demos/service-options/custom-css-class/custom-css-class.html'), description: `

There is possibility to add custom css class to a modal. See the demo below to learn how to use it

`, outlet: DemoModalServiceCustomCSSClassComponent }, { title: 'Animation option', anchor: 'service-disable-animation', component: require('!!raw-loader!./demos/service-options/disable-animation/disable-animation.ts'), html: require('!!raw-loader!./demos/service-options/disable-animation/disable-animation.html'), description: `

There is animation option that you can configure.

`, outlet: DemoModalServiceDisableAnimationComponent }, { title: 'Esc closing option', anchor: 'service-disable-esc-closing', component: require('!!raw-loader!./demos/service-options/disable-esc-closing/disable-esc-closing.ts'), html: require('!!raw-loader!./demos/service-options/disable-esc-closing/disable-esc-closing.html'), description: `

There is closing by Esc button option that you can configure.

`, outlet: DemoModalServiceDisableEscClosingComponent }, { title: 'Modal window with tooltip and popover', anchor: 'modal-with-popups', component: require('!!raw-loader!./demos/modal-with-popups/modal-with-popups.ts'), html: require('!!raw-loader!./demos/modal-with-popups/modal-with-popups.html'), description: `

Tooltips and popovers can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed.

`, outlet: DemoModalWithPopupsComponent }, { title: 'Backdrop options', anchor: 'service-disable-backdrop', component: require('!!raw-loader!./demos/service-options/disable-backdrop/disable-backdrop.ts'), html: require('!!raw-loader!./demos/service-options/disable-backdrop/disable-backdrop.html'), description: `

There is backdrop options that you can configure.

`, outlet: DemoModalServiceDisableBackdropComponent }, { title: 'Change class', anchor: 'change-class', component: require('!!raw-loader!./demos/service-options/change-class/change-class.ts'), html: require('!!raw-loader!./demos/service-options/change-class/change-class.html'), description: `

Calling setClass method to change modal's window class

`, outlet: DemoModalServiceChangeClassComponent }, { title: 'Close interceptor', anchor: 'service-with-interceptor', component: require('!!raw-loader!./demos/service-interceptor/service-interceptor.ts'), html: require('!!raw-loader!./demos/service-interceptor/service-interceptor.html'), description: `

When opening a modal with a component, you can provide an interceptor which will be triggered whenever the modal try to close, allowing you to block the disappearance of a modal.

`, outlet: DemoModalServiceWithInterceptorComponent }, { title: 'Directive examples', anchor: 'directive-section', description: `

Also you can use directive instead of service. See the demos below

` }, { title: 'Static modal', anchor: 'directive-static', component: require('!!raw-loader!./demos/static/static.ts'), html: require('!!raw-loader!./demos/static/static.html'), outlet: DemoModalStaticComponent }, { title: 'Optional sizes', anchor: 'directive-sizes', component: require('!!raw-loader!./demos/sizes/sizes.ts'), html: require('!!raw-loader!./demos/sizes/sizes.html'), outlet: DemoModalSizesComponent }, { title: 'Child modal', anchor: 'directive-child', component: require('!!raw-loader!./demos/child/child.ts'), html: require('!!raw-loader!./demos/child/child.html'), description: `

Control modal from parent component

`, outlet: DemoModalChildComponent }, { title: 'Nested modals', anchor: 'directive-nested', component: require('!!raw-loader!./demos/nested/nested.ts'), html: require('!!raw-loader!./demos/nested/nested.html'), description: `

Open a modal from another modal

`, outlet: DemoModalNestedComponent }, { title: 'Modal events', anchor: 'directive-events', component: require('!!raw-loader!./demos/events/events.ts'), html: require('!!raw-loader!./demos/events/events.html'), description: `

ModalDirective exposes 4 events: onShow, onShown, onHide, onHidden. See usage example below.
$event is an instance of ModalDirective. There you may find some useful properties like isShown, dismissReason, etc.
For example, you may want to know which one of user's actions caused closing of a modal. Just get the value of dismissReason,
possible values are backdrop-click, esc or null if modal was closed by direct call of hide() method

`, outlet: DemoModalEventsComponent }, { title: 'Auto shown modal', anchor: 'directive-auto-shown', component: require('!!raw-loader!./demos/auto-shown/auto-shown.ts'), html: require('!!raw-loader!./demos/auto-shown/auto-shown.html'), description: `

Show modal right after it has been initialized. This allows you to keep DOM clean by only appending visible modals to the DOM using *ngIf directive.

It can also be useful if you want your modal component to perform some initialization operations, but want to defer that until user actually sees modal content. I.e. for a "Select e-mail recipient" modal you might want to defer recipient list loading until the modal is shown.

`, outlet: DemoAutoShownModalComponent }, { title: 'Accessibility', anchor: 'accessibility', component: require('!!raw-loader!./demos/accessibility/accessibility.ts'), html: require('!!raw-loader!./demos/accessibility/accessibility.html'), description: `

Be sure to add id="" attribute to your title and description in the template to make your modal works according to accessibility. The aria-labelledby attribute establishes relationships between the modal and its title (only if the title has id attribute). The element containing the modal's description is referenced by aria-describedby attribute. The dialog does not need aria-describedby since there is no static text that describes it.

Use modal options to set aria-labelledby and aria-describedby attributes.

`, outlet: DemoAccessibilityComponent } ] }, { name: 'Installation', anchor: 'api-reference', tabName: 'api', outlet: ApiSectionsComponent, usage: require('!!raw-loader!./docs/usage.md'), importInfo: 'ng add ngx-bootstrap --component modals', content: [ { title: 'ModalDirective', anchor: 'modal-directive', outlet: NgApiDocComponent }, { title: 'ModalBackdropComponent', anchor: 'modal-backdrop-component', outlet: NgApiDocComponent }, { title: 'BsModalService', anchor: 'bs-modal-service', outlet: NgApiDocClassComponent }, { title: 'BsModalRef', anchor: 'bs-modal-ref', outlet: NgApiDocClassComponent }, { title: 'ModalOptions', anchor: 'modal-options', outlet: NgApiDocConfigComponent } ] }, { name: 'Examples', anchor: 'examples', tabName: 'examples', outlet: ExamplesComponent, content: [ { title: 'Template', anchor: 'service-template-ex', outlet: DemoModalServiceStaticComponent }, { title: 'Component', anchor: 'service-component-ex', outlet: DemoModalServiceFromComponent }, { title: 'Nested', anchor: 'service-nested-ex', outlet: DemoModalServiceNestedComponent }, { title: 'Scrolling long content', anchor: 'scrolling-long-content-ex', outlet: DemoModalScrollingLongContentComponent }, { title: 'Events', anchor: 'service-events-ex', outlet: DemoModalServiceEventsComponent }, { title: 'ModalRef Events', anchor: 'modal-ref-events-ex', outlet: DemoModalRefEventsComponent }, { title: 'Confirm Window', anchor: 'confirm-window-ex', outlet: DemoModalServiceConfirmWindowComponent }, { title: 'Сustom css class', anchor: 'service-custom-css-class-ex', outlet: DemoModalServiceCustomCSSClassComponent }, { title: 'Animation option', anchor: 'service-disable-animation-ex', outlet: DemoModalServiceDisableAnimationComponent }, { title: 'Esc closing option', anchor: 'service-disable-esc-closing-ex', outlet: DemoModalServiceDisableEscClosingComponent }, { title: 'Modal window with tooltip and popover', anchor: 'modal-with-popups-ex', outlet: DemoModalWithPopupsComponent }, { title: 'Backdrop options', anchor: 'service-disable-backdrop-ex', outlet: DemoModalServiceDisableBackdropComponent }, { title: 'Change class', anchor: 'change-class-ex', outlet: DemoModalServiceChangeClassComponent }, { title: 'Close interceptor', anchor: 'service-with-interceptor-ex', outlet: DemoModalServiceWithInterceptorComponent }, { title: 'Static modal', anchor: 'directive-static-ex', outlet: DemoModalStaticComponent }, { title: 'Optional sizes', anchor: 'directive-sizes-ex', outlet: DemoModalSizesComponent }, { title: 'Child modal', anchor: 'directive-child-ex', outlet: DemoModalChildComponent }, { title: 'Nested modals', anchor: 'directive-nested-ex', outlet: DemoModalNestedComponent }, { title: 'Modal events', anchor: 'directive-events-ex', outlet: DemoModalEventsComponent }, { title: 'Auto shown modal', anchor: 'directive-auto-shown-ex', outlet: DemoAutoShownModalComponent } ] } ];