ywana-core8 0.0.868 → 0.0.870

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.868",
3
+ "version": "0.0.870",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -1,5 +1,5 @@
1
1
  import React, { Fragment, useState } from 'react';
2
- import { Button, CheckBox, DataTable, DropDown, Icon, Stack, Tab, Tabs, Text, TextField, PasswordField, Tree, TreeNode, TreeItem, TokenField, Header, Accordion } from '../html';
2
+ import { Button, CheckBox, DataTable, DropDown, Icon, Stack, Tab, Tabs, Text, TextField, PasswordField, Tree, TreeNode, TreeItem, TokenField, Header, Accordion, RadioButton } from '../html';
3
3
  import { CHECK, Content, TYPES, FORMATS } from './ContentType';
4
4
  import { DateRange } from '../html/textfield';
5
5
  import { ColorField } from '../html/color';
@@ -369,7 +369,7 @@ export const ListEditor = ({ field, value = [], onChange }) => {
369
369
  */
370
370
  export const MultiSelectionEditor = ({ field, value = [], content, onChange }) => {
371
371
 
372
- const { id, label, options } = field
372
+ const { id, label, options, format = FORMATS.CHECKBOX } = field
373
373
 
374
374
  function change(v) {
375
375
  const index = value.indexOf(v)
@@ -386,12 +386,24 @@ export const MultiSelectionEditor = ({ field, value = [], content, onChange }) =
386
386
  return opts
387
387
  }
388
388
 
389
+ function renderFormat(format, options) {
390
+ switch (format) {
391
+ case FORMATS.CHECKBOX: return <CheckBoxGroup options={options} value={value} onChange={change} />
392
+ case FORMATS.RADIO: return <RadioGroup options={options} value={value} onChange={change} />
393
+ default: return <CheckBoxGroup options={options} value={value} onChange={change} />
394
+ }
395
+ }
396
+
389
397
  return (
390
398
  <div className="multiselection-editor">
391
399
  <label>{label}</label>
392
400
  {buildOptions().map(option => {
393
401
  const checked = value.includes(option.value)
394
- return <CheckBox value={checked} label={option.label} onChange={() => change(option.value)} />
402
+ switch (format) {
403
+ case FORMATS.CHECKBOX: return <CheckBox value={checked} label={option.label} onChange={() => change(option.value)} />
404
+ case FORMATS.RADIO: return <RadioButton value={checked} label={option.label} onChange={() => change(option.value)} />
405
+ default: return <CheckBox value={checked} label={option.label} onChange={() => change(option.value)} />
406
+ }
395
407
  })}
396
408
  </div>
397
409
  )
@@ -26,6 +26,8 @@ export const FORMATS = {
26
26
  COLOR: 'COLOR',
27
27
  TOKENS: 'TOKENS',
28
28
  PASSWORD: 'PASSWORD',
29
+ RADIO: 'RADIO',
30
+ CHECKBOX: 'CHECKBOX',
29
31
  }
30
32
 
31
33