ywana-core8 0.0.283 → 0.0.286

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/dist/index.umd.js CHANGED
@@ -4172,7 +4172,7 @@
4172
4172
  * Create Content Dialog
4173
4173
  */
4174
4174
 
4175
- var CreateContentDialog$1 = function CreateContentDialog(_ref) {
4175
+ var CreateContentDialog = function CreateContentDialog(_ref) {
4176
4176
  var label = _ref.label,
4177
4177
  type = _ref.type,
4178
4178
  _ref$value = _ref.value,
@@ -4346,101 +4346,6 @@
4346
4346
  }));
4347
4347
  };
4348
4348
 
4349
- /**
4350
- * Create Content Dialog
4351
- */
4352
-
4353
- var CreateContentDialog = function CreateContentDialog(_ref) {
4354
- var label = _ref.label,
4355
- type = _ref.type,
4356
- validator = _ref.validator,
4357
- onOK = _ref.onOK,
4358
- _ref$onActionClose = _ref.onActionClose,
4359
- onActionClose = _ref$onActionClose === void 0 ? true : _ref$onActionClose;
4360
- var site = React.useContext(SiteContext);
4361
-
4362
- var _useState = React.useState({}),
4363
- form = _useState[0],
4364
- setForm = _useState[1];
4365
-
4366
- var _useState2 = React.useState(false),
4367
- isValid = _useState2[0],
4368
- setValid = _useState2[1];
4369
-
4370
- var _useState3 = React.useState([]),
4371
- errors = _useState3[0],
4372
- setErrors = _useState3[1];
4373
-
4374
- function change(form, validForm) {
4375
- setForm(form);
4376
-
4377
- if (validator) {
4378
- var _validator = validator(form),
4379
- validation = _validator.validation,
4380
- _validator$errors = _validator.errors,
4381
- _errors = _validator$errors === void 0 ? [] : _validator$errors;
4382
-
4383
- setValid(validForm && validation);
4384
- setErrors(_errors);
4385
- } else {
4386
- setValid(validForm);
4387
- }
4388
- }
4389
-
4390
- function onAction(action) {
4391
- if (action === 'OK' && onOK) onOK(form);
4392
- if (action === 'CLOSE' || onActionClose === true) site.closeDialog();
4393
- }
4394
-
4395
- function isRequired(field) {
4396
- var _field$required = field.required,
4397
- required = _field$required === void 0 ? false : _field$required;
4398
- return required;
4399
- }
4400
-
4401
- function isOptional(field) {
4402
- var _field$creation = field.creation,
4403
- creation = _field$creation === void 0 ? false : _field$creation;
4404
- return creation;
4405
- }
4406
-
4407
- var actions = /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, /*#__PURE__*/React__default["default"].createElement(Button, {
4408
- label: "CLOSE",
4409
- action: function action() {
4410
- return onAction("CLOSE");
4411
- }
4412
- }), /*#__PURE__*/React__default["default"].createElement(Button, {
4413
- label: "OK",
4414
- action: function action() {
4415
- return onAction("OK");
4416
- },
4417
- disabled: !isValid,
4418
- raised: true
4419
- }));
4420
- var title = /*#__PURE__*/React__default["default"].createElement(Text, {
4421
- use: "headline6"
4422
- }, label);
4423
- var content = new Content(type, form);
4424
- return /*#__PURE__*/React__default["default"].createElement(Dialog, {
4425
- title: title,
4426
- open: true,
4427
- onAction: onAction,
4428
- actions: actions
4429
- }, /*#__PURE__*/React__default["default"].createElement(ContentForm, {
4430
- content: content,
4431
- filter: function filter(field) {
4432
- return isRequired(field) || isOptional(field);
4433
- },
4434
- onChange: change
4435
- }), errors.map(function (error) {
4436
- return /*#__PURE__*/React__default["default"].createElement(Text, {
4437
- use: "overline",
4438
- tag: "div",
4439
- className: "error"
4440
- }, error);
4441
- }));
4442
- };
4443
-
4444
4349
  /**
4445
4350
  * Collection Page
4446
4351
  */
@@ -4483,6 +4388,7 @@
4483
4388
  name = _props$name === void 0 ? "Collection 1" : _props$name,
4484
4389
  schema = props.schema,
4485
4390
  url = props.url,
4391
+ host = props.host,
4486
4392
  groupBy = props.groupBy,
4487
4393
  editor = props.editor,
4488
4394
  field = props.field,
@@ -4498,7 +4404,7 @@
4498
4404
  pageContext = _useContext[0],
4499
4405
  setPageContext = _useContext[1];
4500
4406
 
4501
- var context = CollectionContext(url, field);
4407
+ var context = CollectionContext(url, field, host);
4502
4408
  React.useEffect(function () {
4503
4409
  try {
4504
4410
  return Promise.resolve(context.load()).then(function () {
@@ -4822,7 +4728,7 @@
4822
4728
 
4823
4729
 
4824
4730
  var CollectionContext = function CollectionContext(url, field, host) {
4825
- var API = CollectionAPI(url);
4731
+ var API = CollectionAPI(url, host);
4826
4732
  return {
4827
4733
  all: [],
4828
4734
  selected: null,
@@ -4943,7 +4849,7 @@
4943
4849
  * Collection API
4944
4850
  */
4945
4851
 
4946
- var CollectionAPI = function CollectionAPI(url) {
4852
+ var CollectionAPI = function CollectionAPI(url, host) {
4947
4853
  var http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
4948
4854
  return {
4949
4855
  all: function all(filters) {
@@ -5235,7 +5141,7 @@
5235
5141
  }
5236
5142
  };
5237
5143
 
5238
- site.openDialog( /*#__PURE__*/React__default["default"].createElement(CreateContentDialog$1, {
5144
+ site.openDialog( /*#__PURE__*/React__default["default"].createElement(CreateContentDialog, {
5239
5145
  label: "Crear " + name,
5240
5146
  type: schema,
5241
5147
  onOK: onOK,
@@ -5884,7 +5790,7 @@
5884
5790
  exports.Content = Content;
5885
5791
  exports.ContentEditor = ContentEditor;
5886
5792
  exports.ContentForm = ContentForm;
5887
- exports.CreateContentDialog = CreateContentDialog$1;
5793
+ exports.CreateContentDialog = CreateContentDialog;
5888
5794
  exports.DataTable = DataTable;
5889
5795
  exports.Dialog = Dialog;
5890
5796
  exports.DropDown = DropDown;