6.1.0 • Published 8 months ago

sham-ui-router v6.1.0

Weekly downloads
144
License
-
Repository
-
Last release
8 months ago

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)
6.1.0

8 months ago

6.0.0-alpha.7

1 year ago

6.0.0

1 year ago

6.0.0-alpha.6

1 year ago

6.0.0-alpha.3

2 years ago

6.0.0-alpha.4

2 years ago

6.0.0-alpha.2

2 years ago

6.0.0-alpha.1

2 years ago

5.0.0

2 years ago

5.0.0-alpha.9

3 years ago

5.0.0-alpha.7

3 years ago

5.0.0-alpha.8

3 years ago

5.0.0-alpha.6

3 years ago

5.0.0-alpha.5

3 years ago

5.0.0-alpha.4

3 years ago

5.0.0-alpha.3

3 years ago

5.0.0-alpha.2

3 years ago

5.0.0-alpha.1

3 years ago

4.3.1

4 years ago

4.3.0

4 years ago

4.2.0

4 years ago

4.1.1

5 years ago

4.1.0

5 years ago

4.0.6

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.3

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago