ywana-core8 0.1.44 → 0.1.46

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.
@@ -481,65 +481,34 @@ var ActionButton = function ActionButton(props) {
481
481
  var CheckBox = function CheckBox(props) {
482
482
  var id = props.id,
483
483
  label = props.label,
484
- placeholder = props.placeholder,
485
- value = props.value,
484
+ _props$value = props.value,
485
+ value = _props$value === void 0 ? false : _props$value,
486
486
  _props$readOnly = props.readOnly,
487
487
  readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
488
488
  onChange = props.onChange;
489
+ var _React$useState = React.useState(value),
490
+ checked = _React$useState[0],
491
+ setChecked = _React$useState[1];
492
+ useEffect(function () {
493
+ setChecked(value);
494
+ }, [value]);
489
495
  function change(event) {
490
496
  event.stopPropagation();
491
- event.preventDefault();
492
- var value = event.target.checked;
493
- if (onChange) onChange(id, value);
494
- }
495
- var labelTxt = /*#__PURE__*/React.createElement(Text, null, label);
496
- var placeholderTxt = /*#__PURE__*/React.createElement(Text, null, placeholder);
497
- if (readOnly === true) {
498
- return value === true ? /*#__PURE__*/React.createElement("div", {
499
- className: "checkbox",
500
- key: id + "1"
501
- }, /*#__PURE__*/React.createElement(Icon, {
502
- id: id,
503
- icon: "check",
504
- size: "small"
505
- }), /*#__PURE__*/React.createElement("span", {
506
- className: "checkmark"
507
- }), /*#__PURE__*/React.createElement("label", {
508
- htmlFor: id
509
- }, labelTxt)) : /*#__PURE__*/React.createElement("div", {
510
- className: "checkbox",
511
- key: id + "0"
512
- }, /*#__PURE__*/React.createElement("span", {
513
- className: "checkmark"
514
- }), /*#__PURE__*/React.createElement("label", {
515
- htmlFor: id
516
- }, labelTxt));
497
+ var nextValue = event.target.checked;
498
+ setChecked(nextValue);
499
+ if (onChange) onChange(id, nextValue);
517
500
  }
518
- return value === true ? /*#__PURE__*/React.createElement("div", {
519
- className: "checkbox",
501
+ var labelTxt = label && /*#__PURE__*/React.createElement(Text, null, label);
502
+ return /*#__PURE__*/React.createElement("div", {
503
+ className: "checkbox " + (readOnly ? "readonly" : ""),
520
504
  key: id + "1"
521
505
  }, /*#__PURE__*/React.createElement("input", {
522
506
  id: id,
507
+ key: id + "_" + checked,
523
508
  type: "checkbox",
524
- placeholder: placeholderTxt,
525
- checked: true,
526
- value: value,
509
+ checked: checked,
527
510
  onChange: change,
528
- readOnly: true
529
- }), /*#__PURE__*/React.createElement("span", {
530
- className: "checkmark"
531
- }), /*#__PURE__*/React.createElement("label", {
532
- htmlFor: id
533
- }, labelTxt)) : /*#__PURE__*/React.createElement("div", {
534
- className: "checkbox",
535
- key: id + "0"
536
- }, /*#__PURE__*/React.createElement("input", {
537
- id: id,
538
- type: "checkbox",
539
- placeholder: placeholderTxt,
540
- value: value,
541
- onChange: change,
542
- readOnly: true
511
+ disabled: readOnly
543
512
  }), /*#__PURE__*/React.createElement("span", {
544
513
  className: "checkmark"
545
514
  }), /*#__PURE__*/React.createElement("label", {
@@ -4151,8 +4120,11 @@ var EventCard = function EventCard(props) {
4151
4120
  * Upload Area
4152
4121
  */
4153
4122
  var UploadArea = function UploadArea(props) {
4154
- var _props$label = props.label,
4155
- label = _props$label === void 0 ? 'Add file or drop file here...' : _props$label;
4123
+ var icon = props.icon,
4124
+ _props$label = props.label,
4125
+ label = _props$label === void 0 ? 'Add file or drop file here...' : _props$label,
4126
+ _props$disabled = props.disabled,
4127
+ disabled = _props$disabled === void 0 ? false : _props$disabled;
4156
4128
  var areaElement = useRef();
4157
4129
  var _useState = useState(false),
4158
4130
  drag = _useState[0],
@@ -4164,19 +4136,24 @@ var UploadArea = function UploadArea(props) {
4164
4136
  }
4165
4137
  }, []);
4166
4138
  var onDragOver = function onDragOver() {
4139
+ if (disabled) return;
4167
4140
  setDrag(true);
4168
4141
  };
4169
4142
  var onDragLeave = function onDragLeave() {
4143
+ if (disabled) return;
4170
4144
  setDrag(false);
4171
4145
  };
4172
4146
  var dragging = drag === true ? 'drag-over' : '';
4147
+ var disabledStyle = disabled === true ? 'disabled' : '';
4173
4148
  return /*#__PURE__*/React.createElement("div", {
4174
- className: "upload-area6 " + dragging,
4149
+ className: "upload-area6 " + dragging + " " + disabledStyle,
4175
4150
  onDragOver: onDragOver,
4176
4151
  onDragLeave: onDragLeave,
4177
4152
  ref: areaElement
4178
4153
  }, /*#__PURE__*/React.createElement(UploadIcon, {
4179
- resumable: resumable
4154
+ icon: icon,
4155
+ resumable: resumable,
4156
+ disabled: disabled
4180
4157
  }), /*#__PURE__*/React.createElement("label", null, label));
4181
4158
  };
4182
4159
 
@@ -4186,7 +4163,9 @@ var UploadArea = function UploadArea(props) {
4186
4163
  var UploadIcon = function UploadIcon(_ref) {
4187
4164
  var _ref$icon = _ref.icon,
4188
4165
  icon = _ref$icon === void 0 ? "folder_open" : _ref$icon,
4189
- resumable = _ref.resumable;
4166
+ resumable = _ref.resumable,
4167
+ _ref$disabled = _ref.disabled,
4168
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
4190
4169
  var iconElement = useRef();
4191
4170
  useEffect(function () {
4192
4171
  if (resumable && iconElement.current) {
@@ -4198,7 +4177,8 @@ var UploadIcon = function UploadIcon(_ref) {
4198
4177
  ref: iconElement
4199
4178
  }, /*#__PURE__*/React.createElement(Icon, {
4200
4179
  icon: icon,
4201
- clickable: true
4180
+ clickable: true,
4181
+ disabled: disabled
4202
4182
  }));
4203
4183
  };
4204
4184
 
@@ -4272,7 +4252,9 @@ var Uploader = function Uploader(_ref) {
4272
4252
  onProgress = _ref.onProgress,
4273
4253
  onSuccess = _ref.onSuccess,
4274
4254
  onError = _ref.onError,
4275
- onComplete = _ref.onComplete;
4255
+ onComplete = _ref.onComplete,
4256
+ _ref$disabled = _ref.disabled,
4257
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
4276
4258
  var resumable = useMemo(function () {
4277
4259
  var config = {
4278
4260
  target: target,
@@ -4329,18 +4311,21 @@ var Uploader = function Uploader(_ref) {
4329
4311
  return /*#__PURE__*/React.createElement(UploadArea, {
4330
4312
  resumable: resumable,
4331
4313
  icon: icon,
4332
- label: label
4314
+ label: label,
4315
+ disabled: disabled
4333
4316
  });
4334
4317
  case "icon":
4335
4318
  return /*#__PURE__*/React.createElement(UploadIcon, {
4336
4319
  resumable: resumable,
4337
- icon: icon
4320
+ icon: icon,
4321
+ disabled: disabled
4338
4322
  });
4339
4323
  default:
4340
4324
  return /*#__PURE__*/React.createElement(UploadArea, {
4341
4325
  resumable: resumable,
4342
4326
  icon: icon,
4343
- label: label
4327
+ label: label,
4328
+ disabled: disabled
4344
4329
  });
4345
4330
  }
4346
4331
  }
@@ -4363,7 +4348,8 @@ var UploadDialog = function UploadDialog(_ref) {
4363
4348
  onClose = _ref.onClose,
4364
4349
  children = _ref.children,
4365
4350
  className = _ref.className,
4366
- disabled = _ref.disabled,
4351
+ _ref$disabled = _ref.disabled,
4352
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
4367
4353
  onCanClose = _ref.onCanClose,
4368
4354
  _ref$overlayCanClose = _ref.overlayCanClose,
4369
4355
  overlayCanClose = _ref$overlayCanClose === void 0 ? true : _ref$overlayCanClose;
@@ -4400,12 +4386,13 @@ var UploadDialog = function UploadDialog(_ref) {
4400
4386
  actions: actions,
4401
4387
  className: className,
4402
4388
  overlayCanClose: overlayCanClose
4403
- }, disabled ? "" : /*#__PURE__*/React.createElement(Uploader, {
4389
+ }, /*#__PURE__*/React.createElement(Uploader, {
4404
4390
  label: label,
4405
4391
  accept: accept,
4406
4392
  target: target,
4407
4393
  onSuccess: success,
4408
- onComplete: complete
4394
+ onComplete: complete,
4395
+ disabled: disabled
4409
4396
  }), children);
4410
4397
  };
4411
4398