ywana-core8 0.0.407 → 0.0.410

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.407",
3
+ "version": "0.0.410",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -0,0 +1,35 @@
1
+ // preview.config.js
2
+
3
+ /** @type {import("@previewjs/config").PreviewConfig} */
4
+ module.exports = {
5
+ /**
6
+ * Configure custom aliases (auto-detected if you use TypeScript).
7
+ */
8
+ alias: {
9
+ foo: "src/foo"
10
+ },
11
+
12
+ /**
13
+ * Configure a public assets directory.
14
+ */
15
+ publicDir: "public",
16
+
17
+ /**
18
+ * Set up a custom component to wrap around previewed components.
19
+ *
20
+ * Useful to set up context providers and global CSS.
21
+ */
22
+ wrapper: {
23
+ path: "__previewjs__/Wrapper.tsx",
24
+ componentName: "Wrapper"
25
+ },
26
+
27
+ /**
28
+ * Specify a custom Vite configuration.
29
+ *
30
+ * See https://vitejs.dev/config.
31
+ */
32
+ vite: {
33
+
34
+ }
35
+ };
@@ -0,0 +1,11 @@
1
+ import React, { Fragment, useContext, useEffect, useState } from 'react'
2
+ import { Desktop } from './desktop'
3
+ import { Window } from './window'
4
+
5
+ const DesktopTest = (prop) => {
6
+ return (
7
+ <Desktop>
8
+ <Window id="w1" icon="folder" title="Window 1" />
9
+ </Desktop>
10
+ )
11
+ }
@@ -0,0 +1,6 @@
1
+ .desktop {
2
+ height: 100vh;
3
+ width: 100vw;
4
+ background-color: rgb(113, 102, 226);
5
+ position: relative;
6
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react'
2
+ import './desktop.css'
3
+
4
+ export const Desktop = (props) => {
5
+
6
+ const { children } = props
7
+
8
+ return (
9
+ <div className='desktop'>
10
+ { children }
11
+ </div>
12
+ )
13
+ }
@@ -0,0 +1,58 @@
1
+ .window {
2
+ position: absolute;
3
+ top: 1rem;
4
+ left: 1rem;
5
+ min-width: 20rem;
6
+ min-height: 15rem;
7
+ resize: both;
8
+ background-color: rgb(227, 227, 227);
9
+ display: grid;
10
+ overflow: hidden;
11
+ resize: both;
12
+ }
13
+
14
+ .window.normal {
15
+ grid-template-areas:
16
+ "header header header"
17
+ "nav nav nav"
18
+ "menu main aside"
19
+ "footer footer footer";
20
+ grid-template-columns: auto 1fr auto;
21
+ grid-template-rows: 2rem auto 1fr auto;
22
+ }
23
+
24
+ .window>header {
25
+ grid-area: header;
26
+ padding: .3rem .3rem 0 0;
27
+ display: flex;
28
+ align-items: center;
29
+ overflow: hidden;
30
+ }
31
+
32
+ .window>header>label {
33
+ flex: 1;
34
+ }
35
+
36
+ .window>nav {
37
+ grid-area: nav;
38
+ }
39
+
40
+ .window>menu {
41
+ grid-area: menu;
42
+ padding: 0;
43
+ }
44
+
45
+ .window>main {
46
+ grid-area: main;
47
+ padding: .5rem;
48
+ overflow: hidden;
49
+ border: solid 1px var(--divider-color);
50
+ }
51
+
52
+ .window>aside {
53
+ grid-area: aside;
54
+ }
55
+
56
+ .window>footer {
57
+ grid-area: footer;
58
+ }
@@ -0,0 +1,27 @@
1
+ import React from 'react'
2
+ import { Button, Icon } from '../html'
3
+ import './window.css'
4
+
5
+ export const Window = (props) => {
6
+
7
+ const { id, icon, title, children } = props
8
+
9
+ return (
10
+ <div className="window normal" draggable>
11
+ <header>
12
+ <Icon icon={icon} size="small" />
13
+ <label>{title}</label>
14
+ <Icon icon="close" clickable size="small" />
15
+ </header>
16
+ <nav>
17
+
18
+ </nav>
19
+ <menu></menu>
20
+ <main>
21
+ {children}x
22
+ </main>
23
+ <aside></aside>
24
+ <footer>x</footer>
25
+ </div>
26
+ )
27
+ }
@@ -249,7 +249,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
249
249
  case FORMATS.COLOR: return <ColorField id={id} onChange={change} value={value}/>
250
250
  case FORMATS.HTML: return <Editor id={id} value={value} onChange={change} content={content} />
251
251
  case FORMATS.DATE: return <TextField outlined={outlined} id={id} type="date" label={label} value={value} onChange={change} readOnly={!editable} />
252
- case FORMATS.TOKENS: return <TokenField id={id} label={label} onChange={change} readOnly={!editable} options={options} />
252
+ case FORMATS.TOKENS: return <TokenField id={id} label={label} onChange={change} readOnly={!editable} options={buildOptions()} />
253
253
  default:
254
254
  return options ? (
255
255
  <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} predictive={predictive} />
@@ -3,15 +3,19 @@ import { ContentEditor } from './ContentEditor'
3
3
  import { Content, FORMATS, TYPES } from './ContentType'
4
4
  import './ContentEditor.test.css'
5
5
 
6
+ function buildTokenOptions() {
7
+ return [
8
+ {label: "One", value: 1 },
9
+ {label: "Two", value: 2 },
10
+ {label: "Thressse", value: 3 },
11
+ ]
12
+ }
13
+
6
14
  const schema = {
7
15
  name : { id: "name" , type: TYPES.STRING, format: FORMATS.NONE, required: true, label: "Name" },
8
16
  field1: { id: "field1", type: TYPES.STRING, format: FORMATS.NONE, required: true, label: "field1", multivalue: true },
9
17
  field2: { id: "field2", type: TYPES.STRING, format: FORMATS.NONE, required: true, label: "field2" },
10
- field3: { id: "field3", type: TYPES.STRING, format: FORMATS.TOKENS, required: true, label: "field3", options: [
11
- {label: "One", value: 1 },
12
- {label: "Two", value: 2 },
13
- {label: "Three", value: 3 },
14
- ] },
18
+ field3: { id: "field3", type: TYPES.STRING, format: FORMATS.TOKENS, required: true, label: "field3", options: buildTokenOptions },
15
19
  field4: { id: "field4", type: TYPES.STRING, format: FORMATS.COLOR, required: true, label: "Color" },
16
20
  }
17
21
 
@@ -272,7 +272,7 @@ const TableFilters = (props) => {
272
272
  }
273
273
  }
274
274
  }
275
- Object.values(filterSchema).forEach(field => field.section = null)
275
+ //Object.values(filterSchema).forEach(field => field.section = null)
276
276
  delete filterSchema.flows
277
277
  return filterSchema
278
278
  }, [schema])
package/src/html/table.js CHANGED
@@ -15,6 +15,7 @@ export const DataTable = (props) => {
15
15
 
16
16
  const { columns = [], rows = [], onRowSelection, onSort, onCheckAll, editable, outlined, expanded = false } = props
17
17
  const [sortDir, setSortDir] = useState({})
18
+ const [allChecked, setAllChecked] = useState(false)
18
19
 
19
20
  function multiSort(array, sortObject = {}) {
20
21
 
@@ -65,6 +66,7 @@ export const DataTable = (props) => {
65
66
 
66
67
  function checkAll(id, value) {
67
68
  const ids = rows.map(row => row.id)
69
+ setAllChecked(value)
68
70
  if (onCheckAll) onCheckAll(ids, value)
69
71
  }
70
72
 
@@ -79,7 +81,7 @@ export const DataTable = (props) => {
79
81
  const [rowspan, colspan] = type === TYPES.ENTITY ? [1, Object.values(item).filter(v=>v.column===true).length] : [2, 1]
80
82
  return (
81
83
  <th key={id} rowSpan={rowspan} colSpan={colspan}>
82
- {id === "checked" ? <CheckBox onChange={checkAll} /> : <Text key={`th_${id}`}>{label}</Text>}
84
+ {id === "checked" ? <CheckBox onChange={checkAll} value={allChecked} /> : <Text key={`th_${id}`}>{label}</Text>}
83
85
  {sortable ? <Icon icon="arrow_up" size="small" clickable /> : null}
84
86
  </th>
85
87
  )
@@ -3,6 +3,14 @@ import { DataTable } from './table'
3
3
 
4
4
  const TableTest = (prop) => {
5
5
 
6
+
7
+ const [rows, setRows] = useState(
8
+ [
9
+ { id: 1, checked: false, name: "John Smith", thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png"},
10
+ { id: 2, checked: false, name: "Ann Martin" }
11
+ ]
12
+ )
13
+
6
14
  function select(row) {
7
15
  console.log('select',row)
8
16
  }
@@ -11,6 +19,11 @@ const TableTest = (prop) => {
11
19
  console.log('check', id, checked, c)
12
20
  }
13
21
 
22
+ function checkAll(ids, checked) {
23
+ const next = rows.map( row => Object.assign({}, row, { checked }))
24
+ setRows(next)
25
+ }
26
+
14
27
  const table = {
15
28
  columns : [
16
29
  { id: "checked", onChange: check },
@@ -18,15 +31,12 @@ const TableTest = (prop) => {
18
31
  { id: "thumb", label: "Thumb", type: "String", format: "IMG" },
19
32
 
20
33
  ],
21
- rows: [
22
- { checked: true, name: "John Smith", thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png"},
23
- { checked: false, name: "Ann Martin" },
24
- ]
34
+ rows
25
35
  }
26
36
 
27
37
  return (
28
38
  <>
29
- <DataTable {...table} onRowSelection={select}/>
39
+ <DataTable {...table} onRowSelection={select} onCheckAll={checkAll}/>
30
40
  </>
31
41
  )
32
42
  }
@@ -1,5 +1,4 @@
1
1
  .tokenField {
2
- max-height: 3.8rem;
3
2
  min-height: 3.8;
4
3
  position: relative;
5
4
  border-bottom: solid 1px var(--divider-color);
@@ -1,37 +0,0 @@
1
- const reactpreview = require("@reactpreview/config");
2
-
3
- module.exports = reactpreview.config({
4
- /**
5
- * Configure custom aliases (auto-detected if you use TypeScript).
6
- */
7
- alias: {
8
- foo: "src/foo"
9
- },
10
-
11
- /**
12
- * Configure a public assets directory.
13
- */
14
- publicDir: "public",
15
-
16
- /**
17
- * Set up a custom component to wrap around previewed components.
18
- *
19
- * Useful to set up context providers and CSS dependencies.
20
- */
21
- wrapper: {
22
- path: "src/ReactPreviewWrapper.js",
23
- componentName: "Wrapper"
24
- },
25
-
26
- /**
27
- * Customise the exported React component name for SVG files.
28
- */
29
- svgr: {
30
- componentName: "default"
31
- },
32
-
33
- /**
34
- * Specify a custom Vite configuration.
35
- */
36
- vite: vite.UserConfig;
37
- });