ywana-core8 0.0.623 → 0.0.626

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.623",
3
+ "version": "0.0.626",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -175,7 +175,7 @@ const CollectionList = (props) => {
175
175
  function search() {
176
176
  const items = filter ? all.filter(item => {
177
177
  const result = searchBy.some(fieldName => {
178
- const value = item[fieldName]
178
+ const value = item[fieldName] ? item[fieldName].toUpperCase() : ""
179
179
  return value ? value.indexOf(filter.toUpperCase()) >= 0 : false
180
180
  })
181
181
  return result
@@ -270,7 +270,7 @@ const EntityEditor = ({ field, value = {}, onChange }) => {
270
270
  * String Editor
271
271
  */
272
272
  export const StringEditor = ({ field, value = '', onChange, content, outlined }) => {
273
- const { id, format, options, required=false, editable = true, predictive = false, multivalue = false, Editor } = field
273
+ const { id, format, options, required=false, editable = true, predictive = false, multivalue = false, freeValue = false, Editor } = field
274
274
 
275
275
  function change(id, value) {
276
276
  if (onChange) onChange(id, value)
@@ -301,7 +301,7 @@ export const StringEditor = ({ field, value = '', onChange, content, outlined })
301
301
  return <TokenField id={id} label={label} onChange={change} options={buildOptions()} tokens={value} />
302
302
  default:
303
303
  return options ? (
304
- <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} predictive={predictive} />
304
+ <DropDown outlined={outlined} id={id} label={label} value={value} onChange={change} options={buildOptions()} readOnly={!editable} predictive={predictive} editable={freeValue} />
305
305
  ) : multivalue ? (
306
306
  <TokenField id={id} label={label} onChange={change} readOnly={!editable} />
307
307
  ) : (
package/src/html/icon.js CHANGED
@@ -4,7 +4,7 @@ import './icon.css'
4
4
  /**
5
5
  * Icon
6
6
  */
7
- export const Icon = ({ icon, size = "normal", clickable = false, disabled = false, action, eventPropagation = false }) => {
7
+ export const Icon = ({ icon, size = "normal", clickable = false, disabled = false, action, eventPropagation = false, className }) => {
8
8
 
9
9
  function click (event) {
10
10
  if (!eventPropagation) {
@@ -16,7 +16,7 @@ export const Icon = ({ icon, size = "normal", clickable = false, disabled = fals
16
16
 
17
17
  const style = disabled ? "disabled" : clickable ? "clickable" : ""
18
18
  return (
19
- <i className={`icon ${size} ${style} material-icons`} onClick={click}>
19
+ <i className={`icon ${size} ${style} ${className} material-icons`} onClick={click}>
20
20
  {icon}
21
21
  </i>
22
22
  )
@@ -60,6 +60,14 @@
60
60
  -webkit-transition: 0.2s ease all;
61
61
  }
62
62
 
63
+ .textfield > label .row .icon {
64
+ width: 1.2rem;
65
+ height: 1.2rem;
66
+ font-size: 1rem;
67
+ margin-left: .3rem;
68
+ color: var(--text-color-lighter);
69
+ }
70
+
63
71
  input:read-only {
64
72
  background-color: rgba(200,200,200,.1);
65
73
  border: 0px !important;
@@ -122,6 +130,13 @@ input:read-only ~ label,
122
130
  right: .2rem;
123
131
  }
124
132
 
133
+ .dropdown>.decorator {
134
+ position: absolute;
135
+ top: 1.5rem;
136
+ right: 1.7rem !important;
137
+ color: rgba(150,150,150,1);
138
+ }
139
+
125
140
  .dropdown>.textfield>.icon,
126
141
  .dropdown>.textfield-outlined>.icon {
127
142
  position: absolute;
@@ -119,26 +119,34 @@ export const TextArea = (props) => {
119
119
  export const DropDown = (props) => {
120
120
 
121
121
  const site = useContext(SiteContext)
122
- const { id, options = [], value, onChange, predictive = false, readOnly = false, verbose = true, onBlur } = props
122
+ const { id, options = [], value, onChange, predictive = false, readOnly = false, verbose = true, editable = false, onBlur } = props
123
123
  const [open, setOpen] = useState(false)
124
124
  const [label, setLabel] = useState()
125
125
 
126
126
  useEffect(() => {
127
+
127
128
  if (Array.isArray(options)) {
128
129
  const option = options.find(option => option.value === value)
129
130
  const label = option ? option.label : ""
130
- setLabel(label)
131
+ if (editable && label === "") setLabel(value)
132
+ if (!editable) setLabel(label)
131
133
  }
132
- }, [value])
133
134
 
135
+ }, [value])
136
+
134
137
  function change(id, value) {
135
138
  if (predictive) {
136
139
  setLabel(value)
137
140
  } else {
141
+ console.log('change',id, value)
138
142
  if (onChange) onChange(id, value)
139
143
  }
140
144
  }
141
145
 
146
+ function onFocus() {
147
+ if (!editable) toggle()
148
+ }
149
+
142
150
  function toggle() {
143
151
  if (site && site.changeFocus) {
144
152
  site.changeFocus({
@@ -175,9 +183,10 @@ export const DropDown = (props) => {
175
183
  }
176
184
  }
177
185
 
186
+ const title = editable ? <div className='row'>{props.label}<Icon className="decorator" icon="edit" size="small" /></div> : props.label}
178
187
  return (
179
188
  <div className="dropdown">
180
- <TextField {...props} onClick={toggle} value={label} onChange={change} onBlur={blur} readOnly={!predictive} />
189
+ <TextField {...props} label={title} onClick={onFocus} value={label} onChange={change} onBlur={blur} readOnly={!predictive && !editable} />
181
190
  {!readOnly ? <Icon icon="expand_more" clickable size="small" action={toggle} /> : null}
182
191
  {renderOptions()}
183
192
  </div>
@@ -8,6 +8,7 @@ const TextFieldTest = (prop) => {
8
8
  const [form, setForm] = useState({})
9
9
 
10
10
  function change(id, value) {
11
+ console.log('2', id, value)
11
12
  const next = Object.assign({}, form, { [id]: value })
12
13
  setForm(next)
13
14
  }
@@ -29,11 +30,12 @@ const TextFieldTest = (prop) => {
29
30
  return (
30
31
  <>
31
32
  <DropDown id="b1" label="Boolean1" onChange={change} options={options2} value={form.b1} />
33
+ <DropDown id="gender1" label="Dropdown 1" value={form.gender1} onChange={change} options={options} predictive={false}/>
34
+ <DropDown id="gender2" label="Dropdown 2" value={form.gender2} onChange={change} options={options} predictive={true}/>
35
+ <DropDown id="gender3" label="Dropdown 3" value={form.gender3} onChange={change} options={options} predictive={false} editable={true}/>
32
36
  <TokenField id="token1" label="Tokens" onChange={change} />
33
37
  <TokenField id="token2" label="Tokens DropDown" onChange={change} options={options} tokens={form.token2}/>
34
38
  <TextField id="name" label="Name" value={form.name} onChange={change} />
35
- <DropDown id="gender1" label="Dropdown 1" value={form.gender1} onChange={change} options={options} predictive={false}/>
36
- <DropDown id="gender2" label="Dropdown 2" value={form.gender2} onChange={change} options={options} predictive={true}/>
37
39
  <TextArea id="text1" label="Text 1" value={form.text1} onChange={change} />
38
40
  <TextField id="date1" type="DATE" label="Date" value={form.date1} onChange={change} />
39
41
  <DateRange id="range1" value={form.range1} onChange={change}/>