ywana-core8 0.0.286 → 0.0.289

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.286",
3
+ "version": "0.0.289",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -10,6 +10,8 @@ export const CheckBox = (props) => {
10
10
  const { id, label, placeholder, value, onChange } = props
11
11
 
12
12
  function change(event) {
13
+ event.stopPropagation()
14
+ event.preventDefault()
13
15
  const value = event.target.checked
14
16
  if (onChange) onChange(id, value)
15
17
  }
package/src/html/table.js CHANGED
@@ -54,7 +54,9 @@ export const DataTable = (props) => {
54
54
  }
55
55
 
56
56
  function select(row, event) {
57
- if (onRowSelection) onRowSelection(row, event)
57
+ if (event.target.id !== "checked") {
58
+ if (onRowSelection) onRowSelection(row, event)
59
+ }
58
60
  }
59
61
 
60
62
  function sort(dragged, dropped) {
@@ -76,7 +78,7 @@ export const DataTable = (props) => {
76
78
  const sort = sortDir[id] ? sortDir[id] : null
77
79
  const [rowspan, colspan] = type === TYPES.ENTITY ? [1, Object.values(item).filter(v=>v.column===true).length] : [2, 1]
78
80
  return (
79
- <th rowSpan={rowspan} colSpan={colspan}>
81
+ <th key={id} rowSpan={rowspan} colSpan={colspan}>
80
82
  {id === "checked" ? <CheckBox onChange={checkAll} /> : <Text key={`th_${id}`}>{label}</Text>}
81
83
  {sortable ? <Icon icon="arrow_up" size="small" clickable /> : null}
82
84
  </th>
@@ -0,0 +1,31 @@
1
+ import React, { useState } from 'react'
2
+ import { DataTable } from './table'
3
+
4
+ const TableTest = (prop) => {
5
+
6
+ function select(row) {
7
+ console.log('select',row)
8
+ }
9
+
10
+ function check(id,checked, c) {
11
+ console.log('check', id, checked, c)
12
+ }
13
+
14
+ const table = {
15
+ columns : [
16
+ { id: "checked", onChange: check },
17
+ { id: "name", label: "Name" },
18
+
19
+ ],
20
+ rows: [
21
+ { checked: true, name: "John Smith"},
22
+ { checked: false, name: "Ann Martin"},
23
+ ]
24
+ }
25
+
26
+ return (
27
+ <>
28
+ <DataTable {...table} onRowSelection={select}/>
29
+ </>
30
+ )
31
+ }
@@ -14,12 +14,21 @@ const DATE_RANGE = [
14
14
  /**
15
15
  * Planner
16
16
  */
17
- export const Planner = ({ title, events = [], lanes = [], navigation = true, onSelectCell }) => {
17
+ export const Planner = ({ title, events = [], lanes = [], navigation = true, onSelectCell, focusEvent }) => {
18
18
 
19
19
  const [dateRange, setDateRange] = useState("month");
20
20
  const [from, setFrom] = useState("2021-02-26");
21
21
  const [to, setTo] = useState("2021-04-01");
22
22
 
23
+ useEffect(() => {
24
+ const element = document.getElementById(focusEvent)
25
+ if (element) element.scrollIntoView({
26
+ behavior: 'smooth',
27
+ block: 'start',
28
+ inline: 'center'
29
+ })
30
+ }, [focusEvent])
31
+
23
32
  useEffect(() => {
24
33
  const today = moment();
25
34
  const from_date = today.startOf(dateRange).format("YYYY-MM-DD");
@@ -1,13 +1,13 @@
1
- import React from 'react'
1
+ import React, {useEffect, useState} from 'react'
2
2
  import { Planner } from './Planner'
3
3
 
4
4
  const EventCard = (props) => {
5
- const { event } = props
6
- const { title, color } = event
5
+ const { event={} } = props
6
+ const { id, title, color } = event
7
7
 
8
8
  let style = { backgroundColor : "red", color: "white" }
9
9
  return (
10
- <div className={`event-card`} style={style}>
10
+ <div id={id} className={`event-card`} style={style}>
11
11
  {title}
12
12
  </div>
13
13
  )
@@ -15,6 +15,12 @@ const EventCard = (props) => {
15
15
 
16
16
  const PlannerTest = (prop) => {
17
17
 
18
+ const [event, setEvent] = useState()
19
+
20
+ useEffect(() => {
21
+ setEvent("3")
22
+ }, [])
23
+
18
24
  const lanes = [
19
25
  { id: "lane1", label: "Lane 1" },
20
26
  { id: "lane2", label: "Lane 2" },
@@ -26,12 +32,15 @@ const PlannerTest = (prop) => {
26
32
  ]
27
33
 
28
34
  const events = [
29
- { lane: "lane1", date: "2022-02-01", color: "red", title : "Event One", Renderer: EventCard }
35
+ { id: "1", lane: "lane1", date: "2022-03-01", color: "red", title : "Event One", Renderer: EventCard },
36
+ { id: "2", lane: "lane1", date: "2022-03-22", color: "red", title : "Event One", Renderer: EventCard },
37
+ { id: "3", lane: "lane1", date: "2022-04-03", color: "red", title : "Event One", Renderer: EventCard },
38
+ { id: "4", lane: "lane1", date: "2022-03-04", color: "red", title : "Event One", Renderer: EventCard },
30
39
  ]
31
40
 
41
+
32
42
  return (
33
-
34
- <Planner title="Planner 1" lanes={lanes} events={events} navigation={true} onSelectCell={console.log}>
43
+ <Planner title="Planner 1" lanes={lanes} events={events} navigation={true} onSelectCell={console.log} focusEvent={event}>
35
44
 
36
45
  </Planner>
37
46