@bigbinary/neeto-folders-frontend 2.0.6 → 2.0.8

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/cjs/hooks.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var useFolderActions = require('../useFolderActions-D8xGNhk0.js');
3
+ var useFolderActions = require('../useFolderActions-ibifd0ZD.js');
4
4
  require('@babel/runtime/helpers/defineProperty');
5
5
  require('i18next');
6
6
  require('@bigbinary/neeto-cist');
7
- require('../internal-CS6_tPWL.js');
7
+ require('../internal-CXN78HoA.js');
8
8
  require('ramda');
9
9
  require('react-router-dom');
10
10
  require('zustand/shallow');
package/dist/cjs/utils.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  require('ramda');
4
- var utils = require('../index-BFO1zYNo.js');
4
+ var utils = require('../index-hg5oms4a.js');
5
5
  require('@babel/runtime/helpers/defineProperty');
6
6
  require('@bigbinary/neeto-cist');
7
- require('../internal-CS6_tPWL.js');
7
+ require('../internal-CXN78HoA.js');
8
8
  require('react-router-dom');
9
9
 
10
10
 
@@ -7,10 +7,10 @@ import { buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
7
7
  import Alert from '@bigbinary/neetoui/Alert';
8
8
  import { useTranslation as useTranslation$1, Trans } from 'react-i18next';
9
9
  import { useHistory, Link, NavLink } from 'react-router-dom';
10
- import { c as useFolderStore, d as useDestroyFolder, a as useFolders, e as useFetchFolders, f as useCreateFolder, g as useUpdateFolder, h as useReorderFolders, D as DEFAULT_CONFIG, u as useFolder, b as useFolderActions } from './useFolderActions-BLpmmlOf.js';
10
+ import { c as useFolderStore, d as useDestroyFolder, a as useFolders, e as useFetchFolders, f as useCreateFolder, g as useUpdateFolder, h as useReorderFolders, D as DEFAULT_CONFIG, u as useFolder, b as useFolderActions } from './useFolderActions-Cckopfet.js';
11
11
  import { QUERY_KEYS } from './constants.js';
12
- import { p as pathToFolder, t as treeToMap, m as measureDepth, a as mapToTree, b as mapToSortedTree } from './index-Cq1DyvVr.js';
13
- import { a as isActiveFolder, g as getActiveFolderId, i as isArray } from './internal-G6z0jIQe.js';
12
+ import { p as pathToFolder, t as treeToMap, m as measureDepth, a as mapToTree, b as mapToSortedTree } from './index-CO0LgS5v.js';
13
+ import { a as isActiveFolder, m as mapObj, g as getActiveFolderId, i as isArray } from './internal-B2c8gwOa.js';
14
14
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
15
15
  import Pane from '@bigbinary/neetoui/Pane';
16
16
  import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
@@ -31,7 +31,6 @@ import classNames from 'classnames';
31
31
  import { useField } from 'formik';
32
32
  import Down from '@bigbinary/neeto-icons/Down';
33
33
  import Label from '@bigbinary/neetoui/Label';
34
- import { values, isEmpty, assoc } from 'ramda';
35
34
  import useHotkeys from '@bigbinary/neeto-hotkeys';
36
35
  import Button from '@bigbinary/neetoui/Button';
37
36
  import { noop, isNotPresent } from '@bigbinary/neeto-cist';
@@ -39,6 +38,7 @@ import Radio from '@bigbinary/neetoui/Radio';
39
38
  import { useDraggable, useDroppable, DndContext, DragOverlay, useSensors, useSensor, PointerSensor } from '@dnd-kit/core';
40
39
  import Reorder from '@bigbinary/neeto-icons/Reorder';
41
40
  import Toastr from '@bigbinary/neetoui/Toastr';
41
+ import { isEmpty, assoc } from 'ramda';
42
42
  import { createPortal } from 'react-dom';
43
43
  import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
44
44
  import Checkbox from '@bigbinary/neetoui/Checkbox';
@@ -266,7 +266,7 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
266
266
  return setTouched(true);
267
267
  },
268
268
  onChange: function onChange(value) {
269
- return setValue(value);
269
+ return setValue(value !== null && value !== void 0 ? value : null);
270
270
  }
271
271
  }, _objectSpread$b({
272
272
  disabled: disabled,
@@ -293,8 +293,8 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_ref, ref) {
293
293
  });
294
294
  TreeSelect.displayName = "TreeSelect";
295
295
 
296
- var createFolderOptions = function createFolderOptions(foldersMap, config) {
297
- return values(foldersMap).map(function (folder) {
296
+ var createFolderOptions = function createFolderOptions(foldersMap, activeFolder, config) {
297
+ return mapObj(foldersMap, function (folder) {
298
298
  var _folder$meta$parent;
299
299
  return {
300
300
  id: folder.id,
@@ -303,6 +303,8 @@ var createFolderOptions = function createFolderOptions(foldersMap, config) {
303
303
  pId: (_folder$meta$parent = folder.meta.parent) === null || _folder$meta$parent === void 0 ? void 0 : _folder$meta$parent.id,
304
304
  disabled: folder.meta.depth >= config.maxDepth
305
305
  };
306
+ }, function (folder) {
307
+ return folder.id !== (activeFolder === null || activeFolder === void 0 ? void 0 : activeFolder.id);
306
308
  });
307
309
  };
308
310
  var createInitialValues = function createInitialValues(defaults, extraAttrs) {
@@ -354,19 +356,11 @@ var AddEditPane = function AddEditPane(_ref) {
354
356
  var foldersMap = useMemo(function () {
355
357
  return treeToMap(folders, "sid");
356
358
  }, [folders]);
357
- var folderOptions = useMemo(function () {
358
- return createFolderOptions(foldersMap, config);
359
- }, [foldersMap]);
360
359
  var activeFolderSid = getActiveFolderId(config);
361
360
  var activeFolder = foldersMap[activeFolderSid];
362
361
  var isValidParent = (activeFolder === null || activeFolder === void 0 ? void 0 : activeFolder.meta.depth) < config.maxDepth;
363
362
  var parentId = isValidParent ? activeFolder.id : null;
364
363
  var extraAttributes = config.extraAttributes;
365
- var initialValues = useMemo(function () {
366
- return isEditing ? item : createInitialValues({
367
- parentId: parentId
368
- }, extraAttributes);
369
- }, [isEditing, item, parentId, extraAttributes]);
370
364
  var onSubmitForm = /*#__PURE__*/function () {
371
365
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
372
366
  var payload;
@@ -401,6 +395,14 @@ var AddEditPane = function AddEditPane(_ref) {
401
395
  return _ref2.apply(this, arguments);
402
396
  };
403
397
  }();
398
+ var folderOptions = useMemo(function () {
399
+ return createFolderOptions(foldersMap, item, config);
400
+ }, [foldersMap, item]);
401
+ var initialValues = useMemo(function () {
402
+ return isEditing ? item : createInitialValues({
403
+ parentId: parentId
404
+ }, extraAttributes);
405
+ }, [isEditing, item, parentId, extraAttributes]);
404
406
  return /*#__PURE__*/jsxs(Fragment, {
405
407
  children: [/*#__PURE__*/jsx(Pane.Header, {
406
408
  children: /*#__PURE__*/jsx(Typography, {
@@ -415,40 +417,46 @@ var AddEditPane = function AddEditPane(_ref) {
415
417
  validationSchema: FORM_VALIDATION_SCHEMA,
416
418
  onSubmit: onSubmitForm
417
419
  },
418
- children: /*#__PURE__*/jsxs(Fragment, {
419
- children: [/*#__PURE__*/jsx(Pane.Body, {
420
- className: "pb-6",
421
- children: /*#__PURE__*/jsxs("div", {
422
- className: "w-full space-y-5",
423
- children: [/*#__PURE__*/jsx(Input, {
424
- required: true,
425
- label: t("folders.name"),
426
- name: "name",
427
- ref: setFocusField
428
- }), /*#__PURE__*/jsx(ExtraAttributes, {
429
- attributes: extraAttributes
430
- }), /*#__PURE__*/jsxs("div", {
431
- children: [/*#__PURE__*/jsx(TreeSelect, {
432
- allowClear: true,
433
- showSearch: true,
434
- label: t("createFolder.parentTitle"),
435
- name: "parentId",
436
- treeData: folderOptions
437
- }), /*#__PURE__*/jsx(Typography, {
438
- className: "mt-1",
439
- style: "body3",
440
- children: t("createFolder.parentInfo")
420
+ children: function children(_ref3) {
421
+ var dirty = _ref3.dirty;
422
+ return /*#__PURE__*/jsxs(Fragment, {
423
+ children: [/*#__PURE__*/jsx(Pane.Body, {
424
+ className: "pb-6",
425
+ children: /*#__PURE__*/jsxs("div", {
426
+ className: "w-full space-y-5",
427
+ children: [/*#__PURE__*/jsx(Input, {
428
+ required: true,
429
+ label: t("folders.name"),
430
+ name: "name",
431
+ ref: setFocusField
432
+ }), /*#__PURE__*/jsx(ExtraAttributes, {
433
+ attributes: extraAttributes
434
+ }), /*#__PURE__*/jsxs("div", {
435
+ children: [/*#__PURE__*/jsx(TreeSelect, {
436
+ allowClear: true,
437
+ showSearch: true,
438
+ label: t("createFolder.parentTitle"),
439
+ name: "parentId",
440
+ treeData: folderOptions
441
+ }), /*#__PURE__*/jsx(Typography, {
442
+ className: "mt-1",
443
+ style: "body3",
444
+ children: t("createFolder.parentInfo")
445
+ })]
441
446
  })]
442
- })]
443
- })
444
- }), /*#__PURE__*/jsx(Pane.Footer, {
445
- children: /*#__PURE__*/jsx(ActionBlock, {
446
- cancelButtonProps: {
447
- onClick: onClose
448
- }
449
- })
450
- })]
451
- })
447
+ })
448
+ }), /*#__PURE__*/jsx(Pane.Footer, {
449
+ children: /*#__PURE__*/jsx(ActionBlock, {
450
+ cancelButtonProps: {
451
+ onClick: onClose
452
+ },
453
+ submitButtonProps: {
454
+ disabled: !dirty
455
+ }
456
+ })
457
+ })]
458
+ });
459
+ }
452
460
  })]
453
461
  });
454
462
  };