sham-ui-router

6.1.0 • Public • Published

sham-ui-router

Build Status npm version MIT Licence

Router for sham-ui

Install

# npm
npm install sham-ui-router
# yarn
yarn add sham-ui-router

API

Table of Contents

LinkToOptions

Options for LinkTo

Type: Object

Properties

  • path string Name of page for link. Default ''
  • params Object Params of page for link. Default {}
  • text string Text for link. Default ''
  • useActiveClass boolean Use activeClass options for active page link. Default false
  • activeClass string Class name for active link. Default 'active'

LinkTo

Component for link to page

Properties

ActivePageContainer

Component-container for page

Examples

{% import ActivePageContainer from 'sham-ui-router/active-page-container' %}
...
<ActivePageContainer/>
...

ParamsBuilder

Helper for build params for href-to directive

Type: Object

Examples

{% import path from 'sham-ui-router/params' %}
...
<a :hrefto={{path("foo").param("id", 2)}} class="custom-class-1 custom-class-2">
 Foo
</a>
...

param

Add param for page

Parameters
  • name string Param name
  • value any Param value

Returns ParamsBuilder

_params

Set params

Parameters

Returns ParamsBuilder

_useActiveClass

Use active class

Returns ParamsBuilder

_activeClass

Set active class

Parameters

Returns ParamsBuilder

path

Create new ParamsBuilder

Parameters

  • path string Name of destination page

Returns ParamsBuilder

HrefTo

Directive for links

Parameters

  • component

Examples

...
  <a :hrefto={{ {"path": "foo",  "params": params} }} class="custom-class-1 custom-class-2">
    Foo
  </a>
....

lazyPage

Hook for process lazy page after loader finish. Can override with DI.bind( 'router:lazy-page' )

Parameters

  • pageComponent Class<Component>

Returns Class<Component>

Router

Router service

Parameters

  • DI Object App DI container
  • root (string | null) Root URL (optional, default null)
  • useHash boolean Use hash symbol as delimiter (optional, default false)
  • hash string Hash symbol (use useHash=true) (optional, default '#')

Examples

import FooPage from '../components/FooPage.sht';
import BarPage from '../components/BarPage.sht';
import Router from 'sham-ui-router';

const router = new Router();
router
    .bindPage(
        '/foo', // URL
        'foo', // Name
        FooPage, // Component class
        { componentOption: 1 } // Component options
    )
    .bindLazyPage( '/bar/:some_param/detail', 'bar', () => import( '../src/components/BarPage' ), {} )
    .resolve();

bindPage

Bind page component & url

Parameters
  • url string Url for page
  • name string Page name*
  • pageComponent Class<Component> Component for page
  • componentOptions Object Options for component

Returns Router

bindLazyPage

Bind lazy loaded page component & url

Parameters
  • url string Url for page
  • name string Page name
  • loader Function Loader for page component
  • componentOptions Object Options for component

Returns Router

navigateToRoute

Go to route by name

Parameters

resolve

Resolve current url & run router

notFound

Not found handler

navigate

Changing the page

Parameters

hooks

Hooks

Parameters
  • hooks Object Object with hooks

generate

Generate url for page

Parameters
Examples
router
    .bindPage( '/trip/:tripId/edit', 'trip.edit', PageComponent, {} )
    .bindPage( '/trip/save', 'trip.save', PageComponent, {} )
    .bindPage( '/trip/:action/:tripId', 'trip.action', PageComponent, {} );
console.log(router.generate('trip.edit', { tripId: 42 })); // --> /trip/42/edit
console.log(router.generate('trip.action', { tripId: 42, action: 'save' })); // --> /trip/save/42
console.log(router.generate('trip.save')); // --> /trip/save

routerStorage

Type: RouterStorage

RouterStorage

Data storage for router service

Type: Object

Properties

  • url string Current page url
  • name string Current page name
  • params Object Current page params
  • query string Current page query
  • activePageComponent Class<Component> Current page component class
  • activePageOptions Object Options for current page component
  • pageLoaded boolean Current page component loaded (@see Router.bindLazyPage)

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
6.1.02latest

Version History

VersionDownloads (Last 7 Days)Published
6.1.02
6.0.00
6.0.0-alpha.70
6.0.0-alpha.60
6.0.0-alpha.40
6.0.0-alpha.30
6.0.0-alpha.20
6.0.0-alpha.10
5.0.00
5.0.0-alpha.90
5.0.0-alpha.80
5.0.0-alpha.70
5.0.0-alpha.60
5.0.0-alpha.50
5.0.0-alpha.40
5.0.0-alpha.30
5.0.0-alpha.20
5.0.0-alpha.10
4.3.10
4.3.01
4.2.00
4.1.10
4.1.00
4.0.60
4.0.50
4.0.40
4.0.30
4.0.20
4.0.10
4.0.00
3.0.10
3.0.00
2.1.40
2.1.30
2.1.20
2.1.10
2.1.00
2.0.10
2.0.00
0.0.100
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i sham-ui-router

Weekly Downloads

3

Version

6.1.0

License

none

Unpacked Size

43.5 kB

Total Files

15

Last publish

Collaborators

  • shamcode