omi

Web Components Framework - Web组件框架

OTHER License

Downloads
8.7K
Stars
13K
Committers
15

Bot releases are hidden (Show)

omi - v6.15.0

Published by dntzhang about 5 years ago

  • Multi-store injection supported
  • static use has been removed, please use use
omi - v6.14.2

Published by dntzhang about 5 years ago

  • Fix usingSelf error
omi - v6.14.0

Published by dntzhang about 5 years ago

  • Remove observe, tick and nextTick from omi
  • Remove this.data from instance of component
omi - v6.12.0

Published by dntzhang about 5 years ago

Add useSelf to store system, update self only, exclude children components, for example:

define('my-app', class extends WeElement {
  useSelf() {
    return ['msg']
  }

  render() {
    return (
      <div>
        <span onClick={this.store.random}>{this.store.data.msg}</span>
        <my-counter />
      </div>
    )
  }
})

render(
  <my-app />,
  'body',
  new class Store {
    data = {
      msg: 'aaa',
      count: 0
    }
    sub = () => {
      this.data.count--
    }
    add = () => {
      this.data.count++
    }
    random = () => {
      this.data.msg = Math.random()
    }
  }()
)
omi - v6.11.3

Published by dntzhang about 5 years ago

  • Add updateSelf method to the instance of component
omi - v6.11.2

Published by dntzhang about 5 years ago

  • Fix JSONProxy error of omi.d.ts
omi - v6.11.0

Published by dntzhang about 5 years ago

  • Fix receiveProps when define with functional api
  • Export JSONProxy
  • Support use, propTypes and defaultProps options with functional api
omi - v6.10.2

Published by dntzhang about 5 years ago

  • Fix error using define the functional way with 2 args
omi - v6.10.1

Published by dntzhang about 5 years ago

Add the fourth parameter to define method, can configure CSS and lifecycle functions.

import { render, define } from 'omi'

class Store {
  data = {
    count: 1
  }
  sub = () => {
    this.data.count--
  }
  add = () => {
    this.data.count++
  }
}

define('my-counter', ['count'], _ => (
  <div>
    <button onClick={_.store.sub}>-</button>
    <span>{_.store.data.count}</span>
    <button onClick={_.store.add}>+</button>
  </div>
), {
    css: `span { color: red; }`,
    installed() {
      console.log('installed')
    }
  })

render(<my-counter />, 'body', new Store)
omi - v6.10.0

Published by dntzhang about 5 years ago

New functional styel API:

import { define, render } from 'omi'

class Store {
  data = {
    count: 1
  }
  sub = () => {
    this.data.count--
  }
  add = () => {
    this.data.count++
  }
}

define('my-counter', ['count'], _ => (
  <div>
    <button onClick={_.store.sub}>-</button>
    <span>{_.store.data.count}</span>
    <button onClick={_.store.add}>+</button>
  </div>
))

render(<my-counter />, 'body', new Store)

The second parameter of define is optional.

omi - v6.9.2

Published by dntzhang about 5 years ago

  • Optimizing the extend performance
omi - v6.9.1

Published by dntzhang about 5 years ago

  • Add bind and unbind methods
  • Fix extend error after component update
omi - v6.9.0

Published by dntzhang about 5 years ago

Add

  • Support extend, get and set methods

Demos

omi - v6.8.2

Published by dntzhang about 5 years ago

  • Made fire method of element case sensitive
omi - v6.8.1

Published by dntzhang about 5 years ago

  • Fix prevProps value lost property
omi - v6.8.0

Published by dntzhang about 5 years ago

New syntax, prop supports reading prop from data center - Omi.$

Example

Define element:

import { define, WeElement } from 'omi'

define('my-ele', class extends WeElement {
  static propTypes = {
    user: Object
  }

  render(props) {
    return (
      <div>name: {props.user.name}, age: {props.user.age}</div>
    )
  }
})

Using Element in others framework or pure js:

<script>
  Omi.$.user = { name: 'dntzhang', age: 18 }
</script>
<my-ele user=":user" ></my-ele>

Also supports path:

<other-ele age=":user.age" ></other-ele>
omi - v6.7.1

Published by dntzhang about 5 years ago

  • Remove dead code
omi - v6.7.0

Published by dntzhang about 5 years ago

  • Modify initUse to use
  • Modify use to using
omi - v6.6.9

Published by dntzhang over 5 years ago

  • Fix input value error
omi - v6.6.8

Published by dntzhang over 5 years ago

  • Change this._host to this.rootNode, you can access the root node of the shadow dom based on this property.
Package Rankings
Top 1.45% on Npmjs.org
Top 3.63% on Proxy.golang.org