ywana-core8 0.0.249 → 0.0.253

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.249",
3
+ "version": "0.0.253",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
package/src/html/text.js CHANGED
@@ -23,7 +23,7 @@ export const Text = ({ format, children }) => {
23
23
  const { lang, dictionary = {} } = site
24
24
  const term = dictionary[children]
25
25
  const text = term ? term[lang] : children
26
- if (text) value=text
26
+ if (text) value = text
27
27
  }
28
28
 
29
29
  const formatter = Intl.NumberFormat()
@@ -1,11 +1,12 @@
1
1
  import React, { useState } from 'react'
2
- import { Text, FORMATS } from './text'
2
+ import { Text, TEXTFORMATS } from './text'
3
3
 
4
4
  const TextTest = (prop) => {
5
5
 
6
6
  return (
7
7
  <>
8
- <Text format={FORMATS.NUMERIC}>345356345.345</Text>
8
+ <Text format={TEXTFORMATS.NUMERIC}>846964.4199142859</Text>
9
+ <Text format={TEXTFORMATS.NUMERIC}>{"345356345.345"}</Text>
9
10
  </>
10
11
  )
11
12
  }
@@ -167,8 +167,6 @@ export const DropDown = (props) => {
167
167
  }
168
168
  }
169
169
 
170
- console.log('dropdown',id, 'predictive', predictive)
171
-
172
170
  return (
173
171
  <div className="dropdown">
174
172
  <TextField {...props} onClick={toggle} value={label} onChange={change} />
@@ -3,7 +3,10 @@
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  overflow: hidden;
6
- border: solid 1px var(--divider-color);
6
+ border: solid 10px var(--divider-color);
7
+ }
8
+
9
+ .planner-box> header {
7
10
  }
8
11
 
9
12
  .planner-box > header > label {
@@ -12,13 +15,12 @@
12
15
 
13
16
  .planner {
14
17
  flex: 1;
18
+ overflow: auto;
15
19
  display: flex;
16
- height: 70rem;
17
- overflow-y: auto;
18
- margin: 1rem;
19
-
20
- --row-height: 8rem;
21
- --column-width: 14rem;
20
+
21
+ --row-height: 6rem;
22
+ --column-width: 8rem;
23
+ border: solid 3px red;
22
24
  }
23
25
 
24
26
  .planner > .column0 {
@@ -26,8 +28,15 @@
26
28
  left: 0px;
27
29
  z-index: 11;
28
30
  background-color: var(--paper-color);
29
- width: var(--column-width);
31
+ min-width: var(--column-width);
30
32
  border-right: solid 1px var(--divider-color);
33
+
34
+ flex: 1;
35
+ display: flex;
36
+ flex-direction: column;
37
+
38
+ height: 100%;
39
+ border: solid 3px red;
31
40
  }
32
41
 
33
42
  .column-header {
@@ -69,6 +78,7 @@
69
78
  height: 6rem;
70
79
  border-bottom: solid 1px var(--divider-color);
71
80
  border-right: solid 1px var(--divider-color);
81
+ flex: 1;
72
82
  }
73
83
 
74
84
  .row-header {
@@ -82,6 +92,7 @@
82
92
 
83
93
  .planner > .rows {
84
94
  flex: 1;
95
+ border: solid 3px red;
85
96
  }
86
97
 
87
98
  .planner .row {
@@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from "react";
2
2
  import { DropDown, Header, Icon, Text, TextField } from "../../html";
3
3
  import moment from "moment";
4
4
  import { extendMoment } from "moment-range";
5
- import "./Planner.css";
5
+ import "./Planner2.css";
6
6
 
7
7
  const ranges = extendMoment(moment);
8
8
 
@@ -14,7 +14,7 @@ const DATE_RANGE = [
14
14
  /**
15
15
  * Planner
16
16
  */
17
- export const Planner = ({ title, events = [], lanes = [], selected = false, editable = false, navigation = true, onSelect, onAdd, onDelete, onMove }) => {
17
+ export const Planner = ({ title, events = [], lanes = [], navigation = true, onSelectCell }) => {
18
18
 
19
19
  const [dateRange, setDateRange] = useState("month");
20
20
  const [from, setFrom] = useState("2021-02-26");
@@ -46,20 +46,8 @@ export const Planner = ({ title, events = [], lanes = [], selected = false, edit
46
46
  setTo(to_date);
47
47
  }
48
48
 
49
- function add(set, date) {
50
- if (onAdd) onAdd(date, set);
51
- }
52
-
53
- function remove(id) {
54
- if (onDelete) onDelete(id);
55
- }
56
-
57
- function move(form) {
58
- if (onMove) onMove(form);
59
- }
60
-
61
- function select({ id, plan }) {
62
- if (onSelect) onSelect(plan);
49
+ function selectCell(lane, date) {
50
+ if (onSelectCell) onSelectCell(lane, date);
63
51
  }
64
52
 
65
53
  const period = useMemo(() => {
@@ -132,7 +120,7 @@ export const Planner = ({ title, events = [], lanes = [], selected = false, edit
132
120
  })}
133
121
  </div>
134
122
 
135
- {lanes.map((lane) => <PlannerRow lane={lane} events={events} period={period} />)}
123
+ {lanes.map((lane) => <PlannerRow lane={lane} events={events} period={period} onSelectCell={selectCell} />)}
136
124
 
137
125
  </div>
138
126
  </main>
@@ -145,7 +133,7 @@ export const Planner = ({ title, events = [], lanes = [], selected = false, edit
145
133
  */
146
134
  const PlannerRow = (props) => {
147
135
 
148
- const { lane, events = [], period } = props
136
+ const { lane, events = [], period, onSelectCell } = props
149
137
  const rowEvents = events.filter(event => event.lane === lane.id)
150
138
 
151
139
  return (
@@ -153,13 +141,13 @@ const PlannerRow = (props) => {
153
141
  {period.map((date) => {
154
142
  const slotDate = new Date(date.year, date.month, date.day);
155
143
  slotDate.setHours(0, 0, 0);
156
- const cellEvents = rowEvents.filter( event => {
144
+ const cellEvents = rowEvents.filter(event => {
157
145
  const eventDate = new Date(event.date);
158
146
  eventDate.setHours(0, 0, 0);
159
147
  return eventDate.getTime() === slotDate.getTime();
160
148
  })
161
149
  return (
162
- <PlannerCell date={date} events={cellEvents}/>
150
+ <PlannerCell lane={lane} date={date} events={cellEvents} onSelect={onSelectCell} />
163
151
  );
164
152
  })}
165
153
  </div>
@@ -173,6 +161,10 @@ const PlannerCell = ({ lane, events, date, disabled = false, onAdd, onDelete, on
173
161
 
174
162
  const [dragOver, setDragOver] = useState(false);
175
163
 
164
+ function select() {
165
+ if (onSelect) onSelect(lane, date)
166
+ }
167
+
176
168
  function onDragOver(event) {
177
169
  if (!dragOver) setDragOver(true);
178
170
  event.stopPropagation();
@@ -201,8 +193,23 @@ const PlannerCell = ({ lane, events, date, disabled = false, onAdd, onDelete, on
201
193
  const weekend = isWekend ? "weekend" : "";
202
194
 
203
195
  return (
204
- <div className={`cell ${weekend}`} onDragOver={onDragOver} onDragLeave={onDragLeave} onDrop={drop}>
205
- c
196
+ <div className={`cell ${weekend}`} onDragOver={onDragOver} onDragLeave={onDragLeave} onDrop={drop} onClick={select}>
197
+ {events.map(event => {
198
+ const { title, color, Renderer = EventCard } = event
199
+ return <Renderer event={event} />
200
+ })}
206
201
  </div>
207
202
  );
208
203
  };
204
+
205
+ const EventCard = (props) => {
206
+ const { event } = props
207
+ const { title, color } = event
208
+
209
+ let style = { backgroundColor: color, color: "white" }
210
+ return (
211
+ <div className={`event-card`} style={style}>
212
+ {title}
213
+ </div>
214
+ )
215
+ }
@@ -1,23 +1,37 @@
1
1
  import React from 'react'
2
2
  import { Planner } from './Planner'
3
3
 
4
+ const EventCard = (props) => {
5
+ const { event } = props
6
+ const { title, color } = event
7
+
8
+ let style = { backgroundColor : "red", color: "white" }
9
+ return (
10
+ <div className={`event-card`} style={style}>
11
+ {title}
12
+ </div>
13
+ )
14
+ }
15
+
4
16
  const PlannerTest = (prop) => {
5
17
 
6
18
  const lanes = [
7
19
  { id: "lane1", label: "Lane 1" },
8
20
  { id: "lane2", label: "Lane 2" },
9
21
  { id: "lane3", label: "Lane 3" },
10
- { id: "lane3", label: "Lane 3" },
11
- { id: "lane3", label: "Lane 3" },
12
- { id: "lane3", label: "Lane 3" },
13
- { id: "lane3", label: "Lane 3" },
22
+ { id: "lane4", label: "Lane 4" },
23
+ { id: "lane5", label: "Lane 5" },
24
+ { id: "lane6", label: "Lane 6" },
25
+ { id: "lane7", label: "Lane 7" },
14
26
  ]
15
27
 
16
- const events = []
28
+ const events = [
29
+ { lane: "lane1", date: "2022-02-01", color: "red", title : "Event One", Renderer: EventCard }
30
+ ]
17
31
 
18
32
  return (
19
33
 
20
- <Planner title="Planner 1" lanes={lanes} events={events} navigation={true} >
34
+ <Planner title="Planner 1" lanes={lanes} events={events} navigation={true} onSelectCell={console.log}>
21
35
 
22
36
  </Planner>
23
37
 
@@ -0,0 +1,117 @@
1
+ .planner-box {
2
+ flex: 1;
3
+ display: flex;
4
+ flex-direction: column;
5
+ overflow: hidden;
6
+ }
7
+
8
+ .planner-box > header {
9
+ height: 5rem;
10
+ border: solid 1px var(--divider-color);
11
+ border-bottom: 0px;
12
+ }
13
+
14
+ .planner {
15
+ flex: 1;
16
+ border: solid 1px var(--divider-color);
17
+ display: flex;
18
+ overflow: auto;
19
+
20
+ --row-height: 6rem;
21
+ --column-width: 8rem;
22
+ }
23
+
24
+ .planner > .column0 {
25
+ width: var(--column-width);
26
+ position: sticky;
27
+ left: 0px;
28
+ z-index: 11;
29
+ }
30
+
31
+ .planner > .column0 > .column-header {
32
+ width: var(--column-width);
33
+ height: var(--row-height);
34
+ position: sticky;
35
+ top: 0px;
36
+ background-color: var(--paper-color);
37
+ border-right: solid 1px var(--divider-color);
38
+ border-bottom: solid 1px var(--divider-color);
39
+ }
40
+
41
+ .planner .row-header {
42
+ width: var(--column-width);
43
+ background-color: var(--paper-color);
44
+ height: var(--row-height);
45
+ border-bottom: solid 1px var(--divider-color);
46
+ border-right: solid 1px var(--divider-color);
47
+ display: flex;
48
+ justify-content: center;
49
+ align-items: center;
50
+ }
51
+
52
+ .planner > .rows {
53
+ overflow: visible;
54
+ }
55
+
56
+ .planner > .rows .column-header {
57
+ width: var(--column-width);
58
+ background-color: var(--paper-color);
59
+ height: 2.6rem;
60
+ padding: .5rem;
61
+ }
62
+
63
+ .planner > .rows > .row {
64
+ height: var(--row-height);
65
+ border-bottom: solid 1px var(--divider-color);
66
+ }
67
+
68
+ .planner > .rows > .row0 {
69
+ position: sticky;
70
+ top: 0px;
71
+ z-index: 10;
72
+ height: 3rem;
73
+ background-color: var(--paper-color);
74
+ border-bottom: solid 1px var(--divider-color);
75
+ }
76
+
77
+ .planner > .rows > .row1 {
78
+ position: sticky;
79
+ top: 3rem;
80
+ z-index: 10;
81
+ height: 3rem;
82
+ background-color: var(--paper-color);
83
+ border-bottom: solid 1px var(--divider-color);
84
+ }
85
+
86
+ .planner .cell {
87
+ width: var(--column-width);
88
+ height: 100%;
89
+ padding: 0.5rem;
90
+ display: flex;
91
+ justify-content: center;
92
+ align-items: flex-start;
93
+ border-right: dotted 1px var(--divider-color);
94
+ }
95
+
96
+ .planner .cell:hover {
97
+ background-color: rgba(220,220,220,.3);
98
+ }
99
+
100
+ .planner .cell.weekend {
101
+ background-color: rgba(200,200,200,.2);
102
+ }
103
+
104
+ .event-card {
105
+ width: 100%;
106
+ border: solid 1px var(--divider-color);
107
+ border-radius: 3px;
108
+ padding: .1rem .5rem;
109
+ font-size: .8rem;
110
+ font-weight: 500;
111
+ color: var(--text-color-light);
112
+ }
113
+
114
+ .event-card:hover {
115
+ cursor: pointer;
116
+ border: solid 2px var(--divider-color);
117
+ }