ywana-core8 0.0.16 → 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.
@@ -3131,13 +3131,13 @@ var CollectionAdder = function CollectionAdder(_ref11) {
3131
3131
  var CreateContentDialog = function CreateContentDialog(_ref) {
3132
3132
  var label = _ref.label,
3133
3133
  type = _ref.type,
3134
+ _ref$value = _ref.value,
3135
+ value = _ref$value === void 0 ? {} : _ref$value,
3134
3136
  validator = _ref.validator,
3135
- onOK = _ref.onOK,
3136
- _ref$onActionClose = _ref.onActionClose,
3137
- onActionClose = _ref$onActionClose === void 0 ? true : _ref$onActionClose;
3137
+ onOK = _ref.onOK;
3138
3138
  var site = useContext(SiteContext);
3139
3139
 
3140
- var _useState = useState({}),
3140
+ var _useState = useState(value),
3141
3141
  form = _useState[0],
3142
3142
  setForm = _useState[1];
3143
3143
 
@@ -3149,7 +3149,7 @@ var CreateContentDialog = function CreateContentDialog(_ref) {
3149
3149
  errors = _useState3[0],
3150
3150
  setErrors = _useState3[1];
3151
3151
 
3152
- function change(form, validForm) {
3152
+ function change(form) {
3153
3153
  setForm(form);
3154
3154
 
3155
3155
  if (validator) {
@@ -3158,28 +3158,20 @@ var CreateContentDialog = function CreateContentDialog(_ref) {
3158
3158
  _validator$errors = _validator.errors,
3159
3159
  _errors = _validator$errors === void 0 ? [] : _validator$errors;
3160
3160
 
3161
- setValid(validForm && validation);
3161
+ setValid(validation);
3162
3162
  setErrors(_errors);
3163
3163
  } else {
3164
- setValid(validForm);
3164
+ setValid(true);
3165
3165
  }
3166
3166
  }
3167
3167
 
3168
3168
  function onAction(action) {
3169
- if (action === 'OK' && onOK) onOK(form);
3170
- if (action === 'CLOSE' || onActionClose === true) site.closeDialog();
3171
- }
3172
-
3173
- function isRequired(field) {
3174
- var _field$required = field.required,
3175
- required = _field$required === void 0 ? false : _field$required;
3176
- return required;
3169
+ if (action === 'OK' && onOK) onOK(Object.assign({}, value, form));
3170
+ site.closeDialog();
3177
3171
  }
3178
3172
 
3179
- function isOptional(field) {
3180
- var _field$creation = field.creation,
3181
- creation = _field$creation === void 0 ? false : _field$creation;
3182
- return creation;
3173
+ function createFilter(field, content) {
3174
+ return field.required === true || field.optional === true; // TODO: execute props.filter
3183
3175
  }
3184
3176
 
3185
3177
  var actions = /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Button, {
@@ -3187,6 +3179,8 @@ var CreateContentDialog = function CreateContentDialog(_ref) {
3187
3179
  action: function action() {
3188
3180
  return onAction("CLOSE");
3189
3181
  }
3182
+ }), /*#__PURE__*/React.createElement("div", {
3183
+ className: "expand"
3190
3184
  }), /*#__PURE__*/React.createElement(Button, {
3191
3185
  label: "OK",
3192
3186
  action: function action() {
@@ -3204,12 +3198,10 @@ var CreateContentDialog = function CreateContentDialog(_ref) {
3204
3198
  open: true,
3205
3199
  onAction: onAction,
3206
3200
  actions: actions
3207
- }, /*#__PURE__*/React.createElement(ContentForm, {
3201
+ }, /*#__PURE__*/React.createElement(ContentEditor, {
3208
3202
  content: content,
3209
- filter: function filter(field) {
3210
- return isRequired(field) || isOptional(field);
3211
- },
3212
- onChange: change
3203
+ onChange: change,
3204
+ filter: createFilter
3213
3205
  }), errors.map(function (error) {
3214
3206
  return /*#__PURE__*/React.createElement(Text, {
3215
3207
  use: "overline",