ywana-core8 0.0.13 → 0.0.17

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
@@ -3137,13 +3137,13 @@ var CollectionAdder = function CollectionAdder(_ref11) {
3137
3137
  var CreateContentDialog = function CreateContentDialog(_ref) {
3138
3138
  var label = _ref.label,
3139
3139
  type = _ref.type,
3140
+ _ref$value = _ref.value,
3141
+ value = _ref$value === void 0 ? {} : _ref$value,
3140
3142
  validator = _ref.validator,
3141
- onOK = _ref.onOK,
3142
- _ref$onActionClose = _ref.onActionClose,
3143
- onActionClose = _ref$onActionClose === void 0 ? true : _ref$onActionClose;
3143
+ onOK = _ref.onOK;
3144
3144
  var site = React.useContext(SiteContext);
3145
3145
 
3146
- var _useState = React.useState({}),
3146
+ var _useState = React.useState(value),
3147
3147
  form = _useState[0],
3148
3148
  setForm = _useState[1];
3149
3149
 
@@ -3155,7 +3155,7 @@ var CreateContentDialog = function CreateContentDialog(_ref) {
3155
3155
  errors = _useState3[0],
3156
3156
  setErrors = _useState3[1];
3157
3157
 
3158
- function change(form, validForm) {
3158
+ function change(form) {
3159
3159
  setForm(form);
3160
3160
 
3161
3161
  if (validator) {
@@ -3164,28 +3164,20 @@ var CreateContentDialog = function CreateContentDialog(_ref) {
3164
3164
  _validator$errors = _validator.errors,
3165
3165
  _errors = _validator$errors === void 0 ? [] : _validator$errors;
3166
3166
 
3167
- setValid(validForm && validation);
3167
+ setValid(validation);
3168
3168
  setErrors(_errors);
3169
3169
  } else {
3170
- setValid(validForm);
3170
+ setValid(true);
3171
3171
  }
3172
3172
  }
3173
3173
 
3174
3174
  function onAction(action) {
3175
- if (action === 'OK' && onOK) onOK(form);
3176
- if (action === 'CLOSE' || onActionClose === true) site.closeDialog();
3177
- }
3178
-
3179
- function isRequired(field) {
3180
- var _field$required = field.required,
3181
- required = _field$required === void 0 ? false : _field$required;
3182
- return required;
3175
+ if (action === 'OK' && onOK) onOK(Object.assign({}, value, form));
3176
+ site.closeDialog();
3183
3177
  }
3184
3178
 
3185
- function isOptional(field) {
3186
- var _field$creation = field.creation,
3187
- creation = _field$creation === void 0 ? false : _field$creation;
3188
- return creation;
3179
+ function createFilter(field, content) {
3180
+ return field.required === true || field.optional === true; // TODO: execute props.filter
3189
3181
  }
3190
3182
 
3191
3183
  var actions = /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, /*#__PURE__*/React__default["default"].createElement(Button, {
@@ -3193,6 +3185,8 @@ var CreateContentDialog = function CreateContentDialog(_ref) {
3193
3185
  action: function action() {
3194
3186
  return onAction("CLOSE");
3195
3187
  }
3188
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
3189
+ className: "expand"
3196
3190
  }), /*#__PURE__*/React__default["default"].createElement(Button, {
3197
3191
  label: "OK",
3198
3192
  action: function action() {
@@ -3210,12 +3204,10 @@ var CreateContentDialog = function CreateContentDialog(_ref) {
3210
3204
  open: true,
3211
3205
  onAction: onAction,
3212
3206
  actions: actions
3213
- }, /*#__PURE__*/React__default["default"].createElement(ContentForm, {
3207
+ }, /*#__PURE__*/React__default["default"].createElement(ContentEditor, {
3214
3208
  content: content,
3215
- filter: function filter(field) {
3216
- return isRequired(field) || isOptional(field);
3217
- },
3218
- onChange: change
3209
+ onChange: change,
3210
+ filter: createFilter
3219
3211
  }), errors.map(function (error) {
3220
3212
  return /*#__PURE__*/React__default["default"].createElement(Text, {
3221
3213
  use: "overline",