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.cjs CHANGED
@@ -4177,7 +4177,7 @@ var CollectionAdder = function CollectionAdder(_ref11) {
4177
4177
  * Create Content Dialog
4178
4178
  */
4179
4179
 
4180
- var CreateContentDialog$1 = function CreateContentDialog(_ref) {
4180
+ var CreateContentDialog = function CreateContentDialog(_ref) {
4181
4181
  var label = _ref.label,
4182
4182
  type = _ref.type,
4183
4183
  _ref$value = _ref.value,
@@ -4351,101 +4351,6 @@ var EditContentDialog = function EditContentDialog(_ref) {
4351
4351
  }));
4352
4352
  };
4353
4353
 
4354
- /**
4355
- * Create Content Dialog
4356
- */
4357
-
4358
- var CreateContentDialog = function CreateContentDialog(_ref) {
4359
- var label = _ref.label,
4360
- type = _ref.type,
4361
- validator = _ref.validator,
4362
- onOK = _ref.onOK,
4363
- _ref$onActionClose = _ref.onActionClose,
4364
- onActionClose = _ref$onActionClose === void 0 ? true : _ref$onActionClose;
4365
- var site = React.useContext(SiteContext);
4366
-
4367
- var _useState = React.useState({}),
4368
- form = _useState[0],
4369
- setForm = _useState[1];
4370
-
4371
- var _useState2 = React.useState(false),
4372
- isValid = _useState2[0],
4373
- setValid = _useState2[1];
4374
-
4375
- var _useState3 = React.useState([]),
4376
- errors = _useState3[0],
4377
- setErrors = _useState3[1];
4378
-
4379
- function change(form, validForm) {
4380
- setForm(form);
4381
-
4382
- if (validator) {
4383
- var _validator = validator(form),
4384
- validation = _validator.validation,
4385
- _validator$errors = _validator.errors,
4386
- _errors = _validator$errors === void 0 ? [] : _validator$errors;
4387
-
4388
- setValid(validForm && validation);
4389
- setErrors(_errors);
4390
- } else {
4391
- setValid(validForm);
4392
- }
4393
- }
4394
-
4395
- function onAction(action) {
4396
- if (action === 'OK' && onOK) onOK(form);
4397
- if (action === 'CLOSE' || onActionClose === true) site.closeDialog();
4398
- }
4399
-
4400
- function isRequired(field) {
4401
- var _field$required = field.required,
4402
- required = _field$required === void 0 ? false : _field$required;
4403
- return required;
4404
- }
4405
-
4406
- function isOptional(field) {
4407
- var _field$creation = field.creation,
4408
- creation = _field$creation === void 0 ? false : _field$creation;
4409
- return creation;
4410
- }
4411
-
4412
- var actions = /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, /*#__PURE__*/React__default["default"].createElement(Button, {
4413
- label: "CLOSE",
4414
- action: function action() {
4415
- return onAction("CLOSE");
4416
- }
4417
- }), /*#__PURE__*/React__default["default"].createElement(Button, {
4418
- label: "OK",
4419
- action: function action() {
4420
- return onAction("OK");
4421
- },
4422
- disabled: !isValid,
4423
- raised: true
4424
- }));
4425
- var title = /*#__PURE__*/React__default["default"].createElement(Text, {
4426
- use: "headline6"
4427
- }, label);
4428
- var content = new Content(type, form);
4429
- return /*#__PURE__*/React__default["default"].createElement(Dialog, {
4430
- title: title,
4431
- open: true,
4432
- onAction: onAction,
4433
- actions: actions
4434
- }, /*#__PURE__*/React__default["default"].createElement(ContentForm, {
4435
- content: content,
4436
- filter: function filter(field) {
4437
- return isRequired(field) || isOptional(field);
4438
- },
4439
- onChange: change
4440
- }), errors.map(function (error) {
4441
- return /*#__PURE__*/React__default["default"].createElement(Text, {
4442
- use: "overline",
4443
- tag: "div",
4444
- className: "error"
4445
- }, error);
4446
- }));
4447
- };
4448
-
4449
4354
  /**
4450
4355
  * Collection Page
4451
4356
  */
@@ -4488,6 +4393,7 @@ var CollectionPage = function CollectionPage(props) {
4488
4393
  name = _props$name === void 0 ? "Collection 1" : _props$name,
4489
4394
  schema = props.schema,
4490
4395
  url = props.url,
4396
+ host = props.host,
4491
4397
  groupBy = props.groupBy,
4492
4398
  editor = props.editor,
4493
4399
  field = props.field,
@@ -4503,7 +4409,7 @@ var CollectionPage = function CollectionPage(props) {
4503
4409
  pageContext = _useContext[0],
4504
4410
  setPageContext = _useContext[1];
4505
4411
 
4506
- var context = CollectionContext(url, field);
4412
+ var context = CollectionContext(url, field, host);
4507
4413
  React.useEffect(function () {
4508
4414
  try {
4509
4415
  return Promise.resolve(context.load()).then(function () {
@@ -4827,7 +4733,7 @@ var CollectionEditor = function CollectionEditor(props) {
4827
4733
 
4828
4734
 
4829
4735
  var CollectionContext = function CollectionContext(url, field, host) {
4830
- var API = CollectionAPI(url);
4736
+ var API = CollectionAPI(url, host);
4831
4737
  return {
4832
4738
  all: [],
4833
4739
  selected: null,
@@ -4948,7 +4854,7 @@ var CollectionContext = function CollectionContext(url, field, host) {
4948
4854
  * Collection API
4949
4855
  */
4950
4856
 
4951
- var CollectionAPI = function CollectionAPI(url) {
4857
+ var CollectionAPI = function CollectionAPI(url, host) {
4952
4858
  var http = HTTPClient(host || window.API || process.env.REACT_APP_API, Session);
4953
4859
  return {
4954
4860
  all: function all(filters) {
@@ -5240,7 +5146,7 @@ var TablePage = function TablePage(props) {
5240
5146
  }
5241
5147
  };
5242
5148
 
5243
- site.openDialog( /*#__PURE__*/React__default["default"].createElement(CreateContentDialog$1, {
5149
+ site.openDialog( /*#__PURE__*/React__default["default"].createElement(CreateContentDialog, {
5244
5150
  label: "Crear " + name,
5245
5151
  type: schema,
5246
5152
  onOK: onOK,
@@ -5889,7 +5795,7 @@ exports.CollectionPage = CollectionPage;
5889
5795
  exports.Content = Content;
5890
5796
  exports.ContentEditor = ContentEditor;
5891
5797
  exports.ContentForm = ContentForm;
5892
- exports.CreateContentDialog = CreateContentDialog$1;
5798
+ exports.CreateContentDialog = CreateContentDialog;
5893
5799
  exports.DataTable = DataTable;
5894
5800
  exports.Dialog = Dialog;
5895
5801
  exports.DropDown = DropDown;