ywana-core8 0.0.551 → 0.0.554

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.551",
3
+ "version": "0.0.554",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
package/src/site/view.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react'
1
+ import React, { useState, useEffect } from 'react'
2
2
  import { Icon, MenuIcon, Tabs, Tab, Stack } from '../html'
3
3
  import './view.css'
4
4
 
@@ -36,11 +36,15 @@ export const View = (props) => {
36
36
 
37
37
  export const TabbedView = (props) => {
38
38
 
39
- const { title, className } = props
39
+ const { title, className, selected } = props
40
40
  const [tab, setTab] = useState(0)
41
41
  const children = React.Children.toArray(props.children);
42
42
  const tabs = children.map(child => <Tab key={child.props.label} label={child.props.label}></Tab>)
43
43
 
44
+ useEffect(() => {
45
+ if (selected && selected !== tab) setTab(selected)
46
+ }, [selected])
47
+
44
48
  const toolbar = (
45
49
  <Tabs selected={tab} onChange={tab => setTab(tab)}>
46
50
  {tabs}
@@ -10,7 +10,7 @@ const moment = extendMoment(Moment)
10
10
 
11
11
  export const Calendar = (props) => {
12
12
 
13
- const { events = [], children} = props
13
+ const { events = [], children, onChange } = props
14
14
  const [position, setPosition] = useState()
15
15
 
16
16
  useEffect(() => {
@@ -18,6 +18,17 @@ export const Calendar = (props) => {
18
18
  setPosition(today)
19
19
  }, [])
20
20
 
21
+ useEffect(() => {
22
+ if (position && onChange) {
23
+ const firstDayOfMonth = position.clone().startOf('month');
24
+ const firstDayOfRange = firstDayOfMonth.clone().startOf('isoweek');
25
+ const lastDayOfMonth = position.clone().endOf('month');
26
+ const lastDayOfRange = lastDayOfMonth.clone().endOf('isoweek');
27
+ const range = moment.range(firstDayOfRange, lastDayOfRange)
28
+ onChange(position, range)
29
+ }
30
+ }, [position])
31
+
21
32
  function next() {
22
33
  const next = position.clone().add(1, 'month')
23
34
  setPosition(next)