ywana-core8 0.0.195 → 0.0.199

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.
@@ -1018,6 +1018,234 @@ var DropDown = function DropDown(props) {
1018
1018
  }) : null, renderOptions());
1019
1019
  };
1020
1020
 
1021
+ /**
1022
+ * TYPES
1023
+ */
1024
+ var TYPES = {
1025
+ STRING: 'String',
1026
+ NUMBER: 'Number',
1027
+ BOOLEAN: 'Boolean',
1028
+ ARRAY: 'Array',
1029
+ ENTITY: 'Object',
1030
+ FUNCTION: 'Function'
1031
+ };
1032
+ /**
1033
+ * FORMATS
1034
+ */
1035
+
1036
+ var FORMATS = {
1037
+ NONE: '',
1038
+ DATE: 'date',
1039
+ EMAIL: 'email',
1040
+ HTML: 'HTML',
1041
+ URL: 'URL'
1042
+ };
1043
+ /**
1044
+ * CHECK
1045
+ */
1046
+
1047
+ var CHECK = Object.values(TYPES).reduce(function (obj, name) {
1048
+ obj['is' + name] = function (x) {
1049
+ return toString.call(x) == '[object ' + name + ']';
1050
+ };
1051
+
1052
+ return obj;
1053
+ }, {});
1054
+ /**
1055
+ * Content Type
1056
+ */
1057
+
1058
+ var ContentType = /*#__PURE__*/function () {
1059
+ function ContentType(schema) {
1060
+ this._schema = schema;
1061
+ }
1062
+
1063
+ var _proto = ContentType.prototype;
1064
+
1065
+ _proto.checkType = function checkType(_ref, data) {
1066
+ var type = _ref.type,
1067
+ item = _ref.item;
1068
+ var valid = true;
1069
+ var validChildren = true;
1070
+
1071
+ if (item) {
1072
+ var child = new ContentType(item);
1073
+
1074
+ switch (type) {
1075
+ case TYPES.ARRAY:
1076
+ valid = CHECK['is' + type](data);
1077
+ validChildren = data.every(function (element) {
1078
+ return child.validate(element);
1079
+ });
1080
+ break;
1081
+
1082
+ case TYPES.ENTITY:
1083
+ valid = CHECK['is' + type](data);
1084
+ validChildren = child.validate(data);
1085
+ break;
1086
+
1087
+ case TYPES.NUMBER:
1088
+ valid = CHECK['is' + type](data.value);
1089
+ validChildren = true;
1090
+ break;
1091
+
1092
+ default:
1093
+ valid = true;
1094
+ validChildren = true;
1095
+ }
1096
+ }
1097
+
1098
+ return valid && validChildren;
1099
+ }
1100
+ /**
1101
+ * Validate entity data
1102
+ * - Inspect required attributes only
1103
+ * - Check attributes type
1104
+ */
1105
+ ;
1106
+
1107
+ _proto.validate = function validate(data) {
1108
+ var _this = this;
1109
+
1110
+ var attributes = Object.entries(this._schema);
1111
+ return attributes.filter(function (_ref2) {
1112
+ var attr = _ref2[1];
1113
+ return attr.required === true;
1114
+ }).every(function (_ref3) {
1115
+ var name = _ref3[0],
1116
+ attr = _ref3[1];
1117
+ return data[name] !== undefined ? _this.checkType(attr, data[name]) : false;
1118
+ });
1119
+ }
1120
+ /**
1121
+ * Content Type Form
1122
+ */
1123
+ ;
1124
+
1125
+ _proto.form = function form(data) {
1126
+ var entries = Object.entries(this._schema);
1127
+ var form = entries.reduce(function (form, _ref4) {
1128
+ var id = _ref4[0],
1129
+ field = _ref4[1];
1130
+ form[id] = Object.assign({}, field, {
1131
+ value: data[id]
1132
+ });
1133
+ return form;
1134
+ }, {});
1135
+ return form;
1136
+ }
1137
+ /**
1138
+ * Content Type Sections
1139
+ */
1140
+ ;
1141
+
1142
+ _proto.sections = function sections(data) {
1143
+ var form = this.form(data);
1144
+ var fields = Object.values(form);
1145
+ var sections = fields.reduce(function (sections, field) {
1146
+ var section = field.section;
1147
+ var title = section ? section : '';
1148
+ if (!sections.hasOwnProperty(title)) sections[title] = {
1149
+ title: title,
1150
+ fields: []
1151
+ };
1152
+ sections[title].fields.push(field);
1153
+ return sections;
1154
+ }, {});
1155
+ return Object.values(sections);
1156
+ }
1157
+ /**
1158
+ * value
1159
+ */
1160
+ ;
1161
+
1162
+ _proto.value = function value(data) {
1163
+ var fields = Object.entries(this._schema);
1164
+ var next = fields.reduce(function (next, _ref5) {
1165
+ var name = _ref5[0],
1166
+ field = _ref5[1];
1167
+ var type = field.type,
1168
+ item = field.item;
1169
+ var entryData = data ? data[name] : null;
1170
+
1171
+ switch (type) {
1172
+ case TYPES.STRING:
1173
+ next[name] = entryData || field["default"];
1174
+ break;
1175
+
1176
+ case TYPES.NUMBER:
1177
+ next[name] = entryData || field["default"];
1178
+ break;
1179
+
1180
+ case TYPES.BOOLEAN:
1181
+ next[name] = entryData || field["default"];
1182
+ break;
1183
+
1184
+ case TYPES.ENTITY:
1185
+ var child1 = new ContentType(item);
1186
+ next[name] = child1.value(entryData);
1187
+ break;
1188
+
1189
+ case TYPES.ARRAY:
1190
+ if (item === TYPES.STRING) {
1191
+ next[name] = entryData ? entryData : [];
1192
+ } else {
1193
+ var child2 = new ContentType(item);
1194
+ next[name] = entryData ? entryData.map(function (data2) {
1195
+ return child2.value(data2);
1196
+ }) : [];
1197
+ }
1198
+
1199
+ break;
1200
+
1201
+ default:
1202
+ next[name] = field;
1203
+ break;
1204
+ }
1205
+
1206
+ return next;
1207
+ }, {});
1208
+ return next;
1209
+ };
1210
+
1211
+ return ContentType;
1212
+ }();
1213
+ /**
1214
+ * Content
1215
+ */
1216
+
1217
+ var Content = /*#__PURE__*/function () {
1218
+ function Content(type, value) {
1219
+ this.type = type;
1220
+ this._type = new ContentType(type);
1221
+ this._value = value;
1222
+ }
1223
+
1224
+ var _proto2 = Content.prototype;
1225
+
1226
+ _proto2.isValid = function isValid() {
1227
+ return this._type.validate(this._value);
1228
+ };
1229
+
1230
+ _proto2.value = function value() {
1231
+ return this._type.value(this._value);
1232
+ };
1233
+
1234
+ _proto2.form = function form() {
1235
+ return this._type.form(this._value);
1236
+ };
1237
+
1238
+ _proto2.sections = function sections() {
1239
+ return this._type.sections(this._value);
1240
+ };
1241
+
1242
+ _proto2.update = function update(value) {
1243
+ this._value = value;
1244
+ };
1245
+
1246
+ return Content;
1247
+ }();
1248
+
1021
1249
  var isFunction$1 = function isFunction(value) {
1022
1250
  return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
1023
1251
  };
@@ -1181,6 +1409,7 @@ var DataTableCell = function DataTableCell(_ref2) {
1181
1409
  min = column.min,
1182
1410
  max = column.max,
1183
1411
  _onChange = column.onChange,
1412
+ format = column.format,
1184
1413
  options = column.options;
1185
1414
 
1186
1415
  if (id === "checked") {
@@ -1300,6 +1529,7 @@ var DataTableCell = function DataTableCell(_ref2) {
1300
1529
  return /*#__PURE__*/React.createElement(StringCellViewer, {
1301
1530
  id: id,
1302
1531
  value: cell,
1532
+ format: format,
1303
1533
  options: options
1304
1534
  });
1305
1535
 
@@ -1334,11 +1564,19 @@ var BooleanCellViewer = function BooleanCellViewer(_ref3) {
1334
1564
 
1335
1565
  var StringCellViewer = function StringCellViewer(_ref4) {
1336
1566
  var value = _ref4.value,
1567
+ format = _ref4.format,
1337
1568
  options = _ref4.options;
1338
1569
  var option = options ? options.find(function (o) {
1339
1570
  return o.value === value;
1340
1571
  }) : null;
1341
1572
  var text = option ? option.label : value;
1573
+
1574
+ switch (format) {
1575
+ case FORMATS.DATE:
1576
+ text = new Date(text).toLocaleString();
1577
+ break;
1578
+ }
1579
+
1342
1580
  return /*#__PURE__*/React.createElement("div", {
1343
1581
  className: "field-editor string-viewer"
1344
1582
  }, text);
@@ -2263,234 +2501,6 @@ var Dialog = function Dialog(props) {
2263
2501
  }) : null, /*#__PURE__*/React.createElement(Text, null, title)), /*#__PURE__*/React.createElement("main", null, children), /*#__PURE__*/React.createElement("footer", null, actions))));
2264
2502
  };
2265
2503
 
2266
- /**
2267
- * TYPES
2268
- */
2269
- var TYPES = {
2270
- STRING: 'String',
2271
- NUMBER: 'Number',
2272
- BOOLEAN: 'Boolean',
2273
- ARRAY: 'Array',
2274
- ENTITY: 'Object',
2275
- FUNCTION: 'Function'
2276
- };
2277
- /**
2278
- * FORMATS
2279
- */
2280
-
2281
- var FORMATS = {
2282
- NONE: '',
2283
- DATE: 'date',
2284
- EMAIL: 'email',
2285
- HTML: 'HTML',
2286
- URL: 'URL'
2287
- };
2288
- /**
2289
- * CHECK
2290
- */
2291
-
2292
- var CHECK = Object.values(TYPES).reduce(function (obj, name) {
2293
- obj['is' + name] = function (x) {
2294
- return toString.call(x) == '[object ' + name + ']';
2295
- };
2296
-
2297
- return obj;
2298
- }, {});
2299
- /**
2300
- * Content Type
2301
- */
2302
-
2303
- var ContentType = /*#__PURE__*/function () {
2304
- function ContentType(schema) {
2305
- this._schema = schema;
2306
- }
2307
-
2308
- var _proto = ContentType.prototype;
2309
-
2310
- _proto.checkType = function checkType(_ref, data) {
2311
- var type = _ref.type,
2312
- item = _ref.item;
2313
- var valid = true;
2314
- var validChildren = true;
2315
-
2316
- if (item) {
2317
- var child = new ContentType(item);
2318
-
2319
- switch (type) {
2320
- case TYPES.ARRAY:
2321
- valid = CHECK['is' + type](data);
2322
- validChildren = data.every(function (element) {
2323
- return child.validate(element);
2324
- });
2325
- break;
2326
-
2327
- case TYPES.ENTITY:
2328
- valid = CHECK['is' + type](data);
2329
- validChildren = child.validate(data);
2330
- break;
2331
-
2332
- case TYPES.NUMBER:
2333
- valid = CHECK['is' + type](data.value);
2334
- validChildren = true;
2335
- break;
2336
-
2337
- default:
2338
- valid = true;
2339
- validChildren = true;
2340
- }
2341
- }
2342
-
2343
- return valid && validChildren;
2344
- }
2345
- /**
2346
- * Validate entity data
2347
- * - Inspect required attributes only
2348
- * - Check attributes type
2349
- */
2350
- ;
2351
-
2352
- _proto.validate = function validate(data) {
2353
- var _this = this;
2354
-
2355
- var attributes = Object.entries(this._schema);
2356
- return attributes.filter(function (_ref2) {
2357
- var attr = _ref2[1];
2358
- return attr.required === true;
2359
- }).every(function (_ref3) {
2360
- var name = _ref3[0],
2361
- attr = _ref3[1];
2362
- return data[name] !== undefined ? _this.checkType(attr, data[name]) : false;
2363
- });
2364
- }
2365
- /**
2366
- * Content Type Form
2367
- */
2368
- ;
2369
-
2370
- _proto.form = function form(data) {
2371
- var entries = Object.entries(this._schema);
2372
- var form = entries.reduce(function (form, _ref4) {
2373
- var id = _ref4[0],
2374
- field = _ref4[1];
2375
- form[id] = Object.assign({}, field, {
2376
- value: data[id]
2377
- });
2378
- return form;
2379
- }, {});
2380
- return form;
2381
- }
2382
- /**
2383
- * Content Type Sections
2384
- */
2385
- ;
2386
-
2387
- _proto.sections = function sections(data) {
2388
- var form = this.form(data);
2389
- var fields = Object.values(form);
2390
- var sections = fields.reduce(function (sections, field) {
2391
- var section = field.section;
2392
- var title = section ? section : '';
2393
- if (!sections.hasOwnProperty(title)) sections[title] = {
2394
- title: title,
2395
- fields: []
2396
- };
2397
- sections[title].fields.push(field);
2398
- return sections;
2399
- }, {});
2400
- return Object.values(sections);
2401
- }
2402
- /**
2403
- * value
2404
- */
2405
- ;
2406
-
2407
- _proto.value = function value(data) {
2408
- var fields = Object.entries(this._schema);
2409
- var next = fields.reduce(function (next, _ref5) {
2410
- var name = _ref5[0],
2411
- field = _ref5[1];
2412
- var type = field.type,
2413
- item = field.item;
2414
- var entryData = data ? data[name] : null;
2415
-
2416
- switch (type) {
2417
- case TYPES.STRING:
2418
- next[name] = entryData || field["default"];
2419
- break;
2420
-
2421
- case TYPES.NUMBER:
2422
- next[name] = entryData || field["default"];
2423
- break;
2424
-
2425
- case TYPES.BOOLEAN:
2426
- next[name] = entryData || field["default"];
2427
- break;
2428
-
2429
- case TYPES.ENTITY:
2430
- var child1 = new ContentType(item);
2431
- next[name] = child1.value(entryData);
2432
- break;
2433
-
2434
- case TYPES.ARRAY:
2435
- if (item === TYPES.STRING) {
2436
- next[name] = entryData ? entryData : [];
2437
- } else {
2438
- var child2 = new ContentType(item);
2439
- next[name] = entryData ? entryData.map(function (data2) {
2440
- return child2.value(data2);
2441
- }) : [];
2442
- }
2443
-
2444
- break;
2445
-
2446
- default:
2447
- next[name] = field;
2448
- break;
2449
- }
2450
-
2451
- return next;
2452
- }, {});
2453
- return next;
2454
- };
2455
-
2456
- return ContentType;
2457
- }();
2458
- /**
2459
- * Content
2460
- */
2461
-
2462
- var Content$1 = /*#__PURE__*/function () {
2463
- function Content(type, value) {
2464
- this.type = type;
2465
- this._type = new ContentType(type);
2466
- this._value = value;
2467
- }
2468
-
2469
- var _proto2 = Content.prototype;
2470
-
2471
- _proto2.isValid = function isValid() {
2472
- return this._type.validate(this._value);
2473
- };
2474
-
2475
- _proto2.value = function value() {
2476
- return this._type.value(this._value);
2477
- };
2478
-
2479
- _proto2.form = function form() {
2480
- return this._type.form(this._value);
2481
- };
2482
-
2483
- _proto2.sections = function sections() {
2484
- return this._type.sections(this._value);
2485
- };
2486
-
2487
- _proto2.update = function update(value) {
2488
- this._value = value;
2489
- };
2490
-
2491
- return Content;
2492
- }();
2493
-
2494
2504
  /**
2495
2505
  * Content Form
2496
2506
  */
@@ -2773,7 +2783,7 @@ var TreededContentEditor = function TreededContentEditor(_ref3) {
2773
2783
  setSelected = _useState2[1];
2774
2784
 
2775
2785
  function select(index, field, node) {
2776
- var item = new Content$1(node.item, field);
2786
+ var item = new Content(node.item, field);
2777
2787
  setSelected({
2778
2788
  index: index,
2779
2789
  item: item,
@@ -2923,7 +2933,7 @@ var EntityEditor = function EntityEditor(_ref5) {
2923
2933
  var id = field.id,
2924
2934
  item = field.item,
2925
2935
  label = field.label;
2926
- var content = new Content$1(item, value);
2936
+ var content = new Content(item, value);
2927
2937
 
2928
2938
  function change(fid, value) {
2929
2939
  var _Object$assign4;
@@ -2938,7 +2948,7 @@ var EntityEditor = function EntityEditor(_ref5) {
2938
2948
  });
2939
2949
  return /*#__PURE__*/React.createElement("div", {
2940
2950
  className: "entity-editor"
2941
- }, /*#__PURE__*/React.createElement("header", null, "\u2202", /*#__PURE__*/React.createElement(Text, {
2951
+ }, /*#__PURE__*/React.createElement("header", null, /*#__PURE__*/React.createElement(Text, {
2942
2952
  use: "caption"
2943
2953
  }, label)), /*#__PURE__*/React.createElement("main", null, fields.map(function (field) {
2944
2954
  return /*#__PURE__*/React.createElement(FieldEditor, {
@@ -3349,7 +3359,7 @@ var CreateContentDialog$1 = function CreateContentDialog(_ref) {
3349
3359
  var title = /*#__PURE__*/React.createElement(Text, {
3350
3360
  use: "headline6"
3351
3361
  }, label);
3352
- var content = new Content$1(type, form);
3362
+ var content = new Content(type, form);
3353
3363
  return /*#__PURE__*/React.createElement(Dialog, {
3354
3364
  title: title,
3355
3365
  open: true,
@@ -3438,7 +3448,7 @@ var EditContentDialog = function EditContentDialog(_ref) {
3438
3448
  var title = /*#__PURE__*/React.createElement(Text, {
3439
3449
  use: "headline6"
3440
3450
  }, label);
3441
- var content = new Content$1(type, form);
3451
+ var content = new Content(type, form);
3442
3452
  return /*#__PURE__*/React.createElement(Dialog, {
3443
3453
  title: title,
3444
3454
  open: true,
@@ -3531,7 +3541,7 @@ var CreateContentDialog = function CreateContentDialog(_ref) {
3531
3541
  var title = /*#__PURE__*/React.createElement(Text, {
3532
3542
  use: "headline6"
3533
3543
  }, label);
3534
- var content = new Content$1(type, form);
3544
+ var content = new Content(type, form);
3535
3545
  return /*#__PURE__*/React.createElement(Dialog, {
3536
3546
  title: title,
3537
3547
  open: true,
@@ -3864,7 +3874,7 @@ var CollectionEditor = function CollectionEditor(props) {
3864
3874
  }
3865
3875
 
3866
3876
  function renderEditor() {
3867
- var content = new Content$1(schema, form);
3877
+ var content = new Content(schema, form);
3868
3878
 
3869
3879
  switch (layout) {
3870
3880
  case 'TABBED':
@@ -4096,6 +4106,7 @@ var ContentViewer = function ContentViewer(props) {
4096
4106
  };
4097
4107
  /**
4098
4108
  * Field Viewer
4109
+ *
4099
4110
  * @param {} props
4100
4111
  * @returns
4101
4112
  */
@@ -4330,7 +4341,7 @@ var TablePage = function TablePage(props) {
4330
4341
  return /*#__PURE__*/React.createElement("aside", {
4331
4342
  className: "table-page"
4332
4343
  }, rowSelected ? /*#__PURE__*/React.createElement(TableRowEditor, {
4333
- content: new Content$1(schema, form),
4344
+ content: new Content(schema, form),
4334
4345
  filter: editorFilter,
4335
4346
  onChange: change,
4336
4347
  onClose: closeAside,
@@ -4528,7 +4539,7 @@ var TableFilters = function TableFilters(props) {
4528
4539
  change({});
4529
4540
  }
4530
4541
 
4531
- var content = new Content$1(filterSchema, form);
4542
+ var content = new Content(filterSchema, form);
4532
4543
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
4533
4544
  className: "table-filters",
4534
4545
  title: /*#__PURE__*/React.createElement(Text, null, "Filters")
@@ -4671,6 +4682,7 @@ var TableEditor = function TableEditor(props) {
4671
4682
  id: field.id,
4672
4683
  label: field.label,
4673
4684
  type: field.type,
4685
+ format: field.format,
4674
4686
  onChange: field.id === "checked" ? checkOne : field.editable ? change : null,
4675
4687
 
4676
4688
  /* checked has it´s own handler */
@@ -5233,5 +5245,5 @@ var isFunction = function isFunction(value) {
5233
5245
  return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
5234
5246
  };
5235
5247
 
5236
- export { Avatar, Button$1 as Button, CheckBox, Chip, Chips, CircularProgress, CollectionContext, CollectionEditor$1 as CollectionEditor, CollectionPage, Content$1 as Content, ContentEditor, ContentForm, CreateContentDialog$1 as CreateContentDialog, DataTable, Dialog, DropDown, EditContentDialog, FORMATS, FieldEditor, Form, HTTPClient, Header, Icon, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, Page, PageContext, PageProvider, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, TYPES, Tab, TabbedContentEditor, TablePage, Tabs, Text, TextField, TokenField, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadButton, UploadDialog, UploadFile, Uploader, Viewer, isFunction };
5248
+ export { Avatar, Button$1 as Button, CheckBox, Chip, Chips, CircularProgress, CollectionContext, CollectionEditor$1 as CollectionEditor, CollectionPage, Content, ContentEditor, ContentForm, CreateContentDialog$1 as CreateContentDialog, DataTable, Dialog, DropDown, EditContentDialog, FORMATS, FieldEditor, Form, HTTPClient, Header, Icon, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, Page, PageContext, PageProvider, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, TYPES, Tab, TabbedContentEditor, TablePage, Tabs, Text, TextField, TokenField, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadButton, UploadDialog, UploadFile, Uploader, Viewer, isFunction };
5237
5249
  //# sourceMappingURL=index.modern.js.map