@deephaven/file-explorer 0.43.0 → 0.44.1-beta.0

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.
Files changed (41) hide show
  1. package/dist/FileExistsError.js +14 -0
  2. package/dist/FileExistsError.js.map +1 -0
  3. package/dist/FileExplorer.css +26 -0
  4. package/dist/FileExplorer.css.map +1 -0
  5. package/dist/FileExplorer.js +153 -0
  6. package/dist/FileExplorer.js.map +1 -0
  7. package/dist/FileExplorerShortcuts.js +20 -0
  8. package/dist/FileExplorerShortcuts.js.map +1 -0
  9. package/dist/FileExplorerToolbar.css +37 -0
  10. package/dist/FileExplorerToolbar.css.map +1 -0
  11. package/dist/FileExplorerToolbar.js +37 -0
  12. package/dist/FileExplorerToolbar.js.map +1 -0
  13. package/dist/FileList.css +93 -0
  14. package/dist/FileList.css.map +1 -0
  15. package/dist/FileList.js +309 -0
  16. package/dist/FileList.js.map +1 -0
  17. package/dist/FileListContainer.js +167 -0
  18. package/dist/FileListContainer.js.map +1 -0
  19. package/dist/FileListItem.js +118 -0
  20. package/dist/FileListItem.js.map +1 -0
  21. package/dist/FileListItemEditor.css +33 -0
  22. package/dist/FileListItemEditor.css.map +1 -0
  23. package/dist/FileListItemEditor.js +92 -0
  24. package/dist/FileListItemEditor.js.map +1 -0
  25. package/dist/FileListUtils.js +34 -0
  26. package/dist/FileListUtils.js.map +1 -0
  27. package/dist/FileNotFoundError.js +11 -0
  28. package/dist/FileNotFoundError.js.map +1 -0
  29. package/dist/FileStorage.js +12 -0
  30. package/dist/FileStorage.js.map +1 -0
  31. package/dist/FileTestUtils.js +103 -0
  32. package/dist/FileTestUtils.js.map +1 -0
  33. package/dist/FileUtils.js +243 -0
  34. package/dist/FileUtils.js.map +1 -0
  35. package/dist/NewItemModal.css +17 -0
  36. package/dist/NewItemModal.css.map +1 -0
  37. package/dist/NewItemModal.js +467 -0
  38. package/dist/NewItemModal.js.map +1 -0
  39. package/dist/index.js +15 -0
  40. package/dist/index.js.map +1 -0
  41. package/package.json +8 -8
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../../../node_modules/@deephaven/components/scss/custom.scss","../src/FileList.scss","../../../node_modules/@deephaven/components/scss/bootstrap_overrides.scss","../../../node_modules/@deephaven/components/scss/new_variables.scss"],"names":[],"mappings":"AAAA;ACcA;EACE;EACA;EACA;EACA;EACA;AA8EA;AA0BA;;AAtGA;EACE,aAnBW;EAoBX;EACA,OApBgB;EAqBhB;EACA;EACA;;AAGF;EACE;;AAGF;EACE;EACA,OCfO;EDgBP,YC2Fa;ED1Fb;EACA;EACA;;AAEA;EACE,kBArC0B;;AAwC5B;EACE,kBAzC0B;;AA4C5B;EAIE,OCzCW;;AD6Cf;EACE;EACA;EACA;;AAGF;EACE,cE/DO;;AFmEP;EACE,kBA7DiB;;AAiEnB;EACE,kBApEkB;EAqElB,OC/DW;EDgEX,mBArE6B;EAsE7B,oBAtE6B;;AA0EjC;EACE;;AAGE;EACE;;AAIJ;AAAA;EAEE,OChFW;;ADsFb;EAEE,kBCzFU;ED0FV,OCzFW;ED0FX;;AAKJ;EAEE;;AAKF;EACE;;AAIF;EACE;;;AAKJ;EACE;EACA;EACA;;AAEA;EACE;EACA,YC7EW;ED8EX,OCzHa;ED0Hb,eCdY","file":"FileList.css","sourcesContent":["/* stylelint-disable scss/at-import-no-partial-leading-underscore */\n// Consumers should be able to resolve bootstrap/ to node_modules/bootstrap\n\n//Make bootstrap functions available for use in overrides\n@import 'bootstrap/scss/_functions.scss';\n@import './bootstrap_overrides.scss';\n\n//_variable imports come after bootstrap default overrides,\n// makes all other variables and mixins from bootstrap available\n/// with just importing customer.scss\n@import 'bootstrap/scss/_variables.scss';\n@import 'bootstrap/scss/_mixins.scss';\n\n//New variables come after imports\n@import './new_variables.scss';\n","@import '@deephaven/components/scss/custom.scss';\n\n$depth-line-color: $gray-600;\n$depth-margin: 5px;\n$depth-indentation: 8px;\n$item-list-color: $text-muted;\n$item-list-selected-nofocus-bg: mix($primary, $gray-700, 12%);\n$item-list-selected-bg: mix($primary, $gray-700, 35%);\n$item-list-selection-border-color: mix($primary, $gray-700, 55%);\n$item-list-focused-bg: rgba($primary, 0.75);\n$item-list-hover-bg: $primary;\n$item-list-selected-color: $white;\n$item-list-drop-target-color: $white;\n\n.file-list {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n\n .file-list-depth-line {\n margin-left: $depth-margin;\n padding-bottom: 2px;\n width: $depth-indentation;\n height: 100%;\n border-left: 1px solid $depth-line-color;\n box-sizing: content-box;\n }\n\n .item-list-scroll-pane {\n border: none;\n }\n\n .item-list-item {\n padding: 0 $input-btn-padding-x;\n color: $item-list-color;\n transition: $btn-transition;\n border: 1px solid transparent; // we need a spacer border so stuff doesn't move on us when we apply a border-color\n -webkit-user-drag: none; // we need to disable webkit-user-drag or else Chrome switches to a Copy icon when dragging on Mac\n cursor: pointer;\n\n &.is-focused {\n background-color: $item-list-selected-nofocus-bg;\n }\n\n &.active {\n background-color: $item-list-selected-nofocus-bg;\n }\n\n &:focus,\n &.active,\n &:hover,\n &.is-focused {\n color: $item-list-selected-color;\n }\n }\n\n .truncation-wrapper {\n overflow-x: hidden;\n text-overflow: ellipsis;\n white-space: pre;\n }\n\n .item-icon {\n margin-right: $spacer-1;\n }\n\n &:focus-within {\n &.item-list-item.is-focused {\n background-color: $item-list-focused-bg;\n }\n\n //for selected items, apply border on left and right\n .item-list-item.active {\n background-color: $item-list-selected-bg;\n color: $item-list-selected-color;\n border-left-color: $item-list-selection-border-color;\n border-right-color: $item-list-selection-border-color;\n }\n }\n\n &.is-dragging {\n cursor: grabbing;\n\n .item-list-item {\n &.active {\n opacity: 0.5;\n }\n }\n\n .is-in-drop-target,\n .is-exact-drop-target {\n color: $item-list-drop-target-color;\n }\n }\n\n /* stylelint-disable no-descending-specificity */\n &:not(.is-dragging) {\n .item-list-item:hover,\n &:focus-within .item-list-item.active:hover {\n background-color: $item-list-hover-bg;\n color: $item-list-selected-color;\n transition: none; //to make things feel more responsive don't transition the hover in\n }\n }\n\n //apply border to top of the first item in the list if its selected, and the first selected after a non-selected item\n &:focus-within .item-list-item:not(.active) + .active,\n &:focus-within .item-list-item.active:first-of-type {\n border-top: 1px solid $item-list-selection-border-color;\n }\n\n //there's no easy way to get the last select item in a grouping, so we apply the end border\n //to the TOP of the first non-selected item, ie. the previous selection group\n &:focus-within .item-list-item.active + .item-list-item:not(.active) {\n border-top: 1px solid $item-list-selection-border-color;\n }\n\n //since there is no item after the last item in teh selection, we apply the border to the bottom of the last selected element\n &:focus-within .item-list-item.active:last-of-type {\n border-bottom: 1px solid $item-list-selection-border-color;\n }\n /* stylelint-enable no-descending-specificity */\n}\n\n.file-list-dnd-placeholder {\n position: absolute;\n top: -100px;\n right: 0;\n\n .dnd-placeholder-content {\n padding: $spacer-1 $spacer-3;\n background: $primary-dark;\n color: $foreground;\n border-radius: $border-radius;\n }\n}\n","// Styling overrides for bootstrap\n\n// Override / set color variables\n$red: #f95d84;\n$orange: #f37e3f;\n$yellow: #fcd65b;\n$green: #9edc6f;\n$blue: #76d9e4;\n$purple: #aa9af4;\n\n//Define some UI colors\n$interfacegray: #2d2a2e;\n$interfaceblue: #4878ea;\n$interfacewhite: #f0f0ee; //same as gray-200\n$interfaceblack: #1a171a;\n\n//Define our Gray scale\n$white: $interfacewhite;\n$gray-100: #fcfcfa;\n$gray-200: $interfacewhite;\n$gray-300: #c0bfbf;\n$gray-400: #929192;\n$gray-500: #5b5a5c;\n$gray-600: #555356;\n$gray-700: #403e41;\n$gray-800: #373438;\n$gray-850: #322f33;\n$gray-900: #211f22;\n$black: $interfaceblack;\n$content-bg: $interfacegray;\n$background: $interfaceblack;\n$foreground: $interfacewhite;\n\n//Load colors into map\n$colors: ();\n$colors: map-merge(\n (\n 'red': $red,\n 'orange': $orange,\n 'yellow': $yellow,\n 'green': $green,\n 'blue': $blue,\n 'purple': $purple,\n 'white': $white,\n 'black': $black,\n ),\n $colors\n);\n\n//Set default colors\n$body-bg: $black;\n$body-color: $interfacewhite;\n\n// Set brand colors\n$primary: $interfaceblue;\n$primary-hover: darken($primary, 8%);\n$primary-dark: mix($primary, $content-bg, 25%);\n$primary-light: scale-color($primary, $lightness: -25%);\n$secondary: $gray-500;\n$secondary-hover: darken($secondary, 8%);\n$success: $green;\n$info: $yellow;\n$warning: $orange;\n$danger: $red;\n$danger-hover: darken($danger, 8%);\n$light: $gray-100;\n$mid: $gray-400; //Added a mid color, useful for input styling\n$dark: $gray-800;\n$green-dark: scale-color($green, $lightness: -45%, $saturation: -10%);\n\n$theme-colors: () !default;\n$theme-colors: map-merge(\n (\n 'primary': $primary,\n 'primary-hover': $primary-hover,\n 'primary-light': $primary-light,\n 'primary-dark': $primary-dark,\n 'secondary': $secondary,\n 'success': $success,\n 'info': $info,\n 'warning': $warning,\n 'danger': $danger,\n 'light': $light,\n 'dark': $dark,\n 'mid': $mid,\n 'content-bg': $interfacegray,\n 'background': $interfaceblack,\n 'foreground': $interfacewhite,\n ),\n $theme-colors\n);\n\n$component-active-bg: $primary;\n$theme-color-interval: 9%;\n$yiq-contrasted-threshold: 180;\n\n// Override fonts\n$font-family-sans-serif: 'Fira Sans', -apple-system, blinkmacsystemfont,\n 'Segoe UI', 'Roboto', 'Helvetica Neue', arial, sans-serif; //fira sans then native system ui fallbacks\n$font-family-monospace: 'Fira Mono', menlo, monaco, consolas, 'Liberation Mono',\n 'Courier New', monospace;\n$font-family-base: $font-family-sans-serif;\n\n$headings-font-weight: 400;\n\n//Text overides\n$text-muted: $gray-400;\n\n//Style Selection highlight color\n//so browsers add alpha to your color by default, ignoring opacity 1\n//by setting rgba with 0.99 it tricks browser into thinking there is alpha applied\n$text-select-color: $primary-hover;\n$text-select-color-editor: lighten(\n $gray-700,\n 15%\n); //we lighten it abit to account for that 0.01 loss, and because it needs some anyways.\n\n//Grid variables, same value as default just making easily accessible\n$grid-gutter-width: 30px;\n\n//Visual Overrides\n$border-radius: 4px;\n$box-shadow: 0 0.1rem 1rem rgba($black, 45%); //because our UI is so dark, we need darker default shadows\n$box-shadow-900: 0 0.1rem 1rem rgba(0, 0, 0, 45%); //darkest shadow for $black popups over $black UI\n\n//Override Btn\n$btn-border-radius: 4rem;\n$btn-padding-x: 1.5rem;\n$btn-transition: color 0.12s ease-in-out, background-color 0.12s ease-in-out,\n border-color 0.12s ease-in-out, box-shadow 0.12s ease-in-out; //default 0.15 is too long\n$btn-border-width: 2px;\n\n//Override Inputs\n$input-bg: $gray-600;\n$input-disabled-bg: $gray-800;\n$input-color: $foreground;\n$input-border-color: $gray-400;\n$input-placeholder-color: $gray-400;\n$input-focus-border-color: rgba($primary, 85%);\n\n$input-btn-focus-width: 0.2rem;\n$input-btn-focus-color: rgba($component-active-bg, 35%);\n$input-btn-focus-box-shadow: 0 0 0 $input-btn-focus-width $input-btn-focus-color;\n\n//checkbox\n$custom-control-indicator-bg: $gray-600;\n$custom-control-indicator-bg-size: 75% 75%;\n$custom-control-indicator-disabled-bg: $gray-800;\n$custom-control-indicator-checked-disabled-bg: $gray-800;\n$custom-control-label-disabled-color: $gray-400;\n\n//Custom Select\n$custom-select-indicator-color: $gray-400;\n$custom-select-bg-size: 16px 16px;\n//dhSort icon encoded\n$custom-select-indicator: str-replace(\n url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='#{$custom-select-indicator-color}' d='M4 7l-.4-.8 4-3.7h.8l4 3.7-.4.8H4zm0 2l-.4.8 4 3.7h.8l4-3.7L12 9H4z'/%3E%3C/svg%3E\"),\n '#',\n '%23'\n);\n$custom-select-focus-box-shadow: $input-btn-focus-box-shadow;\n$custom-select-disabled-color: darken($gray-400, 5%);\n$custom-select-disabled-bg: $gray-800;\n\n//modal\n$modal-content-bg: $gray-200;\n$modal-content-border-width: 0;\n$modal-md: 550px;\n\n// Toast notification\n$toast-bg: $primary-dark;\n$toast-color: $foreground;\n$toast-error-bg: mix($danger, $content-bg, 15%);\n$toast-error-color: $foreground;\n\n//tooltips\n$tooltip-bg: $gray-700;\n$tooltip-color: $foreground;\n$tooltip-box-shadow: 0 0.1rem 1.5rem 0.1rem rgba($black, 80%);\n\n//drowdowns\n$dropdown-bg: $gray-600;\n$dropdown-link-color: $foreground;\n$dropdown-link-hover-color: $foreground;\n$dropdown-link-hover-bg: $primary;\n$dropdown-divider-bg: $gray-700;\n\n//context menus\n$contextmenu-bg: $gray-600;\n$contextmenu-color: $foreground;\n$contextmenu-disabled-color: $text-muted;\n$contextmenu-keyboard-selected-bg: rgba($primary, 50%);\n$contextmenu-selected-bg: $primary;\n$contextmenu-selected-color: $foreground;\n\n//links\n$link-color: $gray-400;\n$link-hover-color: $foreground;\n\n//progress-bar\n$progress-bg: $gray-600;\n$progress-border-radius: 1rem;\n\n// Set global options\n$enable-shadows: false;\n$enable-gradients: false;\n$enable-print-styles: false; //I don't think anyone should expect to \"print\" this app.\n\n// Transition times\n$transition: 0.15s;\n$transition-mid: 0.2s;\n$transition-long: 0.3s;\n$transition-slow: 0.6s;\n\n//form-validation icon, uses vsWarning icon encoded here as svg\n$form-feedback-icon-invalid-color: theme-color('danger');\n$form-feedback-icon-invalid: str-replace(\n url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cg fill='none'%3E%3Cg fill='#{$form-feedback-icon-invalid-color}'%3E%3Cpath d='M7.56 1h.88l6.54 12.26-.44.74H1.44L1 13.26 7.56 1zM8 2.28 2.28 13H13.7L8 2.28zM8.625 12v-1h-1.25v1h1.25zm-1.25-2V6h1.25v4h-1.25z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E \"),\n '#',\n '%23'\n);\n","//Set of spacer variables from the spacer map\n$spacer-0: map-get($spacers, 0); //0\n$spacer-1: map-get($spacers, 1);\n$spacer-2: map-get($spacers, 2);\n$spacer-3: map-get($spacers, 3);\n$spacer-4: map-get($spacers, 4);\n$spacer-5: map-get($spacers, 5);\n\n//Marching Ants for golden layout dropzone and drag and drop\n//top bottom, left right.\n//create 4 background images that are 50% color 1, 50% color 2 using graidents, two veritical, two horizontal\n//size them to ant-size and thickness\n//position those images along the egdes and make top/bottom repeat-x and left/right repeat-y\n//then offest each of those background positions by ant-size in animation to make them march.\n$ant-size: 8px;\n$ant-thickness: 1px;\n\n@mixin ants-base($color-1: black, $color-2: white) {\n background-image: linear-gradient(to right, $color-2 50%, $color-1 50%),\n linear-gradient(to right, $color-2 50%, $color-1 50%),\n linear-gradient(to bottom, $color-2 50%, $color-1 50%),\n linear-gradient(to bottom, $color-2 50%, $color-1 50%);\n background-size: $ant-size $ant-thickness, $ant-size $ant-thickness,\n $ant-thickness $ant-size, $ant-thickness $ant-size;\n background-position: 0 top, 0 bottom, left 0, right 0;\n background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;\n animation: march 0.5s;\n animation-timing-function: linear;\n animation-iteration-count: infinite;\n}\n\n@mixin drag-stack($pseudo-element) {\n &::#{$pseudo-element} {\n content: ' ';\n background: $primary;\n box-shadow: $box-shadow;\n border-radius: $border-radius;\n position: absolute;\n height: 100%;\n width: 100%;\n @content;\n }\n}\n\n$focus-bg-transparency: 0.12;\n$hover-bg-transparency: 0.14;\n$active-bg-transparency: 0.28;\n$exception-transparency: 0.13;\n"]}
@@ -0,0 +1,309 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ import { ItemList } from '@deephaven/components';
7
+ import Log from '@deephaven/log';
8
+ import { RangeUtils } from '@deephaven/utils';
9
+ import classNames from 'classnames';
10
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
11
+ import { isDirectory } from "./FileStorage.js";
12
+ import "./FileList.css";
13
+ import { DEFAULT_ROW_HEIGHT, getMoveOperation } from "./FileListUtils.js";
14
+ import { FileListItem } from "./FileListItem.js";
15
+ var log = Log.module('FileList');
16
+ // How long you need to hover over a directory before it expands
17
+ var DRAG_HOVER_TIMEOUT = 500;
18
+ var ITEM_LIST_CLASS_NAME = 'item-list-scroll-pane';
19
+
20
+ /**
21
+ * Component that displays and allows interaction with the file system in the provided FileStorageTable.
22
+ */
23
+ export function FileList(props) {
24
+ var {
25
+ isMultiSelect = false,
26
+ table,
27
+ onFocusChange = () => undefined,
28
+ onMove,
29
+ onSelect,
30
+ onSelectionChange = () => undefined,
31
+ renderItem = FileListItem,
32
+ rowHeight = DEFAULT_ROW_HEIGHT,
33
+ overscanCount = ItemList.DEFAULT_OVERSCAN
34
+ } = props;
35
+ var [loadedViewport, setLoadedViewport] = useState(() => ({
36
+ items: [],
37
+ offset: 0,
38
+ itemCount: 0
39
+ }));
40
+ var [viewport, setViewport] = useState({
41
+ top: 0,
42
+ bottom: 0
43
+ });
44
+ var [dropTargetItem, setDropTargetItem] = useState();
45
+ var [draggedItems, setDraggedItems] = useState();
46
+ var [dragPlaceholder, setDragPlaceholder] = useState();
47
+ var [selectedRanges, setSelectedRanges] = useState([]);
48
+ var itemList = useRef(null);
49
+ var fileList = useRef(null);
50
+ var getItems = useCallback(ranges => {
51
+ if (ranges.length === 0 || loadedViewport == null) {
52
+ return [];
53
+ }
54
+ var items = [];
55
+ for (var i = 0; i < ranges.length; i += 1) {
56
+ var range = ranges[i];
57
+ for (var j = range[0]; j <= range[1]; j += 1) {
58
+ if (j >= loadedViewport.offset && j < loadedViewport.offset + loadedViewport.items.length) {
59
+ items.push(loadedViewport.items[j - loadedViewport.offset]);
60
+ }
61
+ }
62
+ }
63
+ return items;
64
+ }, [loadedViewport]);
65
+ var getItem = useCallback(itemIndex => {
66
+ var items = getItems([[itemIndex, itemIndex]]);
67
+ if (items.length > 0) {
68
+ return items[0];
69
+ }
70
+ }, [getItems]);
71
+
72
+ /**
73
+ * Get the placeholder text to show when a drag operation is in progress
74
+ */
75
+ var getDragPlaceholderText = useCallback(() => {
76
+ var count = RangeUtils.count(selectedRanges);
77
+ if (count === 0) {
78
+ return null;
79
+ }
80
+ if (count === 1) {
81
+ var index = selectedRanges[0][0];
82
+ var item = getItem(index);
83
+ if (item != null) {
84
+ return item.filename;
85
+ }
86
+ }
87
+ return "".concat(count, " items");
88
+ }, [getItem, selectedRanges]);
89
+
90
+ /**
91
+ * Drop the currently dragged items at the currently set drop target.
92
+ * If an itemIndex is provided, focus that index after the drop.
93
+ */
94
+ var dropItems = useCallback(itemIndex => {
95
+ if (!draggedItems || !dropTargetItem) {
96
+ return;
97
+ }
98
+ log.debug('dropItems', draggedItems, 'to', itemIndex);
99
+ try {
100
+ var {
101
+ files: _files,
102
+ targetPath
103
+ } = getMoveOperation(draggedItems, dropTargetItem);
104
+ onMove === null || onMove === void 0 ? void 0 : onMove(_files, targetPath);
105
+ if (itemIndex != null) {
106
+ var _itemList$current;
107
+ setSelectedRanges([[itemIndex, itemIndex]]);
108
+ (_itemList$current = itemList.current) === null || _itemList$current === void 0 ? void 0 : _itemList$current.focusItem(itemIndex);
109
+ }
110
+ } catch (err) {
111
+ log.error('Unable to complete move', err);
112
+ }
113
+ }, [draggedItems, dropTargetItem, onMove]);
114
+ var handleSelect = useCallback((itemIndex, event) => {
115
+ var item = loadedViewport.items[itemIndex - loadedViewport.offset];
116
+ if (item !== undefined) {
117
+ log.debug('handleItemClick', item);
118
+ onSelect(item, event);
119
+ if (isDirectory(item)) {
120
+ table === null || table === void 0 ? void 0 : table.setExpanded(item.filename, !item.isExpanded);
121
+ }
122
+ }
123
+ }, [loadedViewport, onSelect, table]);
124
+ var handleItemDragStart = useCallback((itemIndex, e) => {
125
+ var _itemList$current2;
126
+ log.debug2('handleItemDragStart', itemIndex, selectedRanges);
127
+ var draggedRanges = selectedRanges;
128
+ if (!RangeUtils.isSelected(selectedRanges, itemIndex)) {
129
+ draggedRanges = [[itemIndex, itemIndex]];
130
+ setSelectedRanges(draggedRanges);
131
+ }
132
+ setDraggedItems(getItems(draggedRanges));
133
+
134
+ // We need to reset reset the mouse state since we steal the drag
135
+ (_itemList$current2 = itemList.current) === null || _itemList$current2 === void 0 ? void 0 : _itemList$current2.resetMouseState();
136
+ var newDragPlaceholder = document.createElement('div');
137
+ newDragPlaceholder.innerHTML = "<div class=\"dnd-placeholder-content\">".concat(getDragPlaceholderText(), "</div>");
138
+ newDragPlaceholder.className = 'file-list-dnd-placeholder';
139
+ document.body.appendChild(newDragPlaceholder);
140
+ e.dataTransfer.setDragImage(newDragPlaceholder, 0, 0);
141
+ e.dataTransfer.effectAllowed = 'move';
142
+ setDragPlaceholder(newDragPlaceholder);
143
+ }, [getDragPlaceholderText, getItems, selectedRanges]);
144
+ var handleItemDragOver = useCallback((itemIndex, e) => {
145
+ e.preventDefault();
146
+ log.debug2('handleItemDragOver', e);
147
+ setDropTargetItem(getItem(itemIndex));
148
+ }, [getItem]);
149
+ var handleItemDragEnd = useCallback((itemIndex, e) => {
150
+ log.debug('handleItemDragEnd', itemIndex);
151
+ dragPlaceholder === null || dragPlaceholder === void 0 ? void 0 : dragPlaceholder.remove();
152
+
153
+ // Drag end is triggered after drop
154
+ // Also drop isn't triggered if drag end is outside of the list
155
+ setDraggedItems(undefined);
156
+ setDropTargetItem(undefined);
157
+ setDragPlaceholder(undefined);
158
+ }, [dragPlaceholder]);
159
+ var handleItemDrop = useCallback((itemIndex, e) => {
160
+ dropItems(itemIndex);
161
+ }, [dropItems]);
162
+ var handleItemDragExit = useCallback(() => {
163
+ log.debug2('handleItemDragExit');
164
+ setDropTargetItem(undefined);
165
+ }, []);
166
+ var handleListDragOver = useCallback(e => {
167
+ if (e.target instanceof Element && e.target.classList.contains(ITEM_LIST_CLASS_NAME)) {
168
+ // Need to prevent default to enable drop
169
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#droptargets
170
+ e.preventDefault();
171
+ log.debug2('handleListDragOver', e);
172
+ setDropTargetItem({
173
+ type: 'directory',
174
+ filename: '/',
175
+ basename: '/',
176
+ id: '/'
177
+ });
178
+ }
179
+ }, []);
180
+ var handleListDrop = useCallback(e => {
181
+ if (e.target instanceof Element && e.target.classList.contains(ITEM_LIST_CLASS_NAME)) {
182
+ log.debug('handleListDrop');
183
+ dropItems();
184
+ }
185
+ }, [dropItems]);
186
+ var handleSelectionChange = useCallback(newSelectedRanges => {
187
+ log.debug2('handleSelectionChange', newSelectedRanges);
188
+ if (newSelectedRanges !== selectedRanges) {
189
+ setSelectedRanges(newSelectedRanges);
190
+ var _selectedItems = getItems(newSelectedRanges);
191
+ onSelectionChange(_selectedItems);
192
+ }
193
+ }, [getItems, onSelectionChange, selectedRanges]);
194
+ var handleFocusChange = useCallback(focusIndex => {
195
+ log.debug2('handleFocusChange', focusIndex);
196
+ if (focusIndex != null) {
197
+ var [_focusedItem] = getItems([[focusIndex, focusIndex]]);
198
+ onFocusChange(_focusedItem);
199
+ } else {
200
+ onFocusChange();
201
+ }
202
+ }, [getItems, onFocusChange]);
203
+ var handleViewportChange = useCallback((top, bottom) => {
204
+ log.debug('handleViewportChange', top, bottom);
205
+ if (top !== viewport.top || bottom !== viewport.bottom) {
206
+ setViewport({
207
+ top,
208
+ bottom
209
+ });
210
+ }
211
+ }, [viewport]);
212
+ var isDropTargetValid = useMemo(() => {
213
+ if (!draggedItems || !dropTargetItem) {
214
+ return false;
215
+ }
216
+ try {
217
+ getMoveOperation(draggedItems, dropTargetItem);
218
+ log.debug('handleValidateDropTarget true');
219
+ return true;
220
+ } catch (e) {
221
+ log.debug('handleValidateDropTarget false');
222
+ return false;
223
+ }
224
+ }, [draggedItems, dropTargetItem]);
225
+ var {
226
+ focusedPath
227
+ } = props;
228
+ useEffect(() => {
229
+ if (focusedPath !== undefined) {
230
+ if (focusedPath === '/') {
231
+ table.collapseAll();
232
+ } else {
233
+ table.setExpanded(focusedPath, false);
234
+ table.setExpanded(focusedPath, true);
235
+ }
236
+ }
237
+ }, [table, focusedPath]);
238
+ useEffect(function updateTableViewport() {
239
+ log.debug('updating table viewport', viewport);
240
+ table === null || table === void 0 ? void 0 : table.setViewport({
241
+ top: Math.max(0, viewport.top - overscanCount),
242
+ bottom: viewport.bottom + overscanCount
243
+ });
244
+ }, [overscanCount, table, viewport]);
245
+
246
+ // Listen for table updates
247
+ useEffect(function setLoadedViewportAndReturnCleanup() {
248
+ var listenerRemover = table.onUpdate(newViewport => {
249
+ setLoadedViewport({
250
+ items: newViewport.items.map(item => _objectSpread(_objectSpread({}, item), {}, {
251
+ itemName: item.basename
252
+ })),
253
+ offset: newViewport.offset,
254
+ itemCount: table.size
255
+ });
256
+ });
257
+ return () => {
258
+ listenerRemover();
259
+ };
260
+ }, [table]);
261
+
262
+ // Expand a folder if hovering over it
263
+ useEffect(function expandFolderOnHover() {
264
+ if (dropTargetItem != null && isDirectory(dropTargetItem) && dropTargetItem.filename !== '/') {
265
+ var timeout = setTimeout(() => {
266
+ if (!dropTargetItem.isExpanded) {
267
+ table === null || table === void 0 ? void 0 : table.setExpanded(dropTargetItem.filename, true);
268
+ }
269
+ }, DRAG_HOVER_TIMEOUT);
270
+ return () => clearTimeout(timeout);
271
+ }
272
+ }, [dropTargetItem, table]);
273
+ var renderWrapper = useCallback(itemProps => renderItem(_objectSpread(_objectSpread({}, itemProps), {}, {
274
+ isDragInProgress: draggedItems != null,
275
+ dropTargetItem,
276
+ draggedItems,
277
+ isDropTargetValid,
278
+ onDragStart: handleItemDragStart,
279
+ onDragEnd: handleItemDragEnd,
280
+ onDragOver: handleItemDragOver,
281
+ onDragExit: handleItemDragExit,
282
+ onDrop: handleItemDrop
283
+ })), [handleItemDragEnd, handleItemDragExit, handleItemDragOver, handleItemDragStart, handleItemDrop, draggedItems, dropTargetItem, isDropTargetValid, renderItem]);
284
+ return /*#__PURE__*/React.createElement("div", {
285
+ ref: fileList,
286
+ className: classNames('file-list', {
287
+ 'is-dragging': draggedItems != null
288
+ }),
289
+ onDragOver: handleListDragOver,
290
+ onDrop: handleListDrop
291
+ }, /*#__PURE__*/React.createElement(ItemList, {
292
+ ref: itemList,
293
+ items: loadedViewport.items,
294
+ itemCount: loadedViewport.itemCount,
295
+ offset: loadedViewport.offset,
296
+ onFocusChange: handleFocusChange,
297
+ onSelect: handleSelect,
298
+ onSelectionChange: handleSelectionChange,
299
+ onViewportChange: handleViewportChange,
300
+ selectedRanges: selectedRanges,
301
+ renderItem: renderWrapper,
302
+ rowHeight: rowHeight,
303
+ isMultiSelect: isMultiSelect,
304
+ isDragSelect: false,
305
+ isDeselectOnClick: false
306
+ }));
307
+ }
308
+ export default FileList;
309
+ //# sourceMappingURL=FileList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileList.js","names":["ItemList","Log","RangeUtils","classNames","React","useCallback","useEffect","useMemo","useRef","useState","isDirectory","DEFAULT_ROW_HEIGHT","getMoveOperation","FileListItem","log","module","DRAG_HOVER_TIMEOUT","ITEM_LIST_CLASS_NAME","FileList","props","isMultiSelect","table","onFocusChange","undefined","onMove","onSelect","onSelectionChange","renderItem","rowHeight","overscanCount","DEFAULT_OVERSCAN","loadedViewport","setLoadedViewport","items","offset","itemCount","viewport","setViewport","top","bottom","dropTargetItem","setDropTargetItem","draggedItems","setDraggedItems","dragPlaceholder","setDragPlaceholder","selectedRanges","setSelectedRanges","itemList","fileList","getItems","ranges","length","i","range","j","push","getItem","itemIndex","getDragPlaceholderText","count","index","item","filename","dropItems","debug","files","targetPath","current","focusItem","err","error","handleSelect","event","setExpanded","isExpanded","handleItemDragStart","e","debug2","draggedRanges","isSelected","resetMouseState","newDragPlaceholder","document","createElement","innerHTML","className","body","appendChild","dataTransfer","setDragImage","effectAllowed","handleItemDragOver","preventDefault","handleItemDragEnd","remove","handleItemDrop","handleItemDragExit","handleListDragOver","target","Element","classList","contains","type","basename","id","handleListDrop","handleSelectionChange","newSelectedRanges","selectedItems","handleFocusChange","focusIndex","focusedItem","handleViewportChange","isDropTargetValid","focusedPath","collapseAll","updateTableViewport","Math","max","setLoadedViewportAndReturnCleanup","listenerRemover","onUpdate","newViewport","map","itemName","size","expandFolderOnHover","timeout","setTimeout","clearTimeout","renderWrapper","itemProps","isDragInProgress","onDragStart","onDragEnd","onDragOver","onDragExit","onDrop"],"sources":["../src/FileList.tsx"],"sourcesContent":["import { ItemList, Range } from '@deephaven/components';\nimport Log from '@deephaven/log';\nimport { RangeUtils } from '@deephaven/utils';\nimport classNames from 'classnames';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { FileStorageItem, FileStorageTable, isDirectory } from './FileStorage';\nimport './FileList.scss';\nimport { DEFAULT_ROW_HEIGHT, getMoveOperation } from './FileListUtils';\nimport { FileListItem, FileListRenderItemProps } from './FileListItem';\n\nconst log = Log.module('FileList');\n\nexport type LoadedViewport = {\n items: FileStorageItem[];\n offset: number;\n itemCount: number;\n};\n\nexport type ListViewport = {\n top: number;\n bottom: number;\n};\n\nexport interface FileListProps {\n table: FileStorageTable;\n\n isMultiSelect?: boolean;\n focusedPath?: string;\n\n onFocusChange?: (focusedItem?: FileStorageItem) => void;\n onMove?: (files: FileStorageItem[], path: string) => void;\n onSelect: (file: FileStorageItem, event: React.SyntheticEvent) => void;\n onSelectionChange?: (selectedItems: FileStorageItem[]) => void;\n\n renderItem?: (props: FileListRenderItemProps) => JSX.Element;\n\n /** Height of each item in the list */\n rowHeight?: number;\n\n overscanCount?: number;\n}\n\n// How long you need to hover over a directory before it expands\nconst DRAG_HOVER_TIMEOUT = 500;\n\nconst ITEM_LIST_CLASS_NAME = 'item-list-scroll-pane';\n\n/**\n * Component that displays and allows interaction with the file system in the provided FileStorageTable.\n */\nexport function FileList(props: FileListProps): JSX.Element {\n const {\n isMultiSelect = false,\n table,\n onFocusChange = () => undefined,\n onMove,\n onSelect,\n onSelectionChange = () => undefined,\n renderItem = FileListItem,\n rowHeight = DEFAULT_ROW_HEIGHT,\n overscanCount = ItemList.DEFAULT_OVERSCAN,\n } = props;\n const [loadedViewport, setLoadedViewport] = useState<LoadedViewport>(() => ({\n items: [],\n offset: 0,\n itemCount: 0,\n }));\n const [viewport, setViewport] = useState<ListViewport>({\n top: 0,\n bottom: 0,\n });\n\n const [dropTargetItem, setDropTargetItem] = useState<FileStorageItem>();\n const [draggedItems, setDraggedItems] = useState<FileStorageItem[]>();\n const [dragPlaceholder, setDragPlaceholder] = useState<HTMLDivElement>();\n const [selectedRanges, setSelectedRanges] = useState([] as Range[]);\n\n const itemList = useRef<ItemList<FileStorageItem>>(null);\n const fileList = useRef<HTMLDivElement>(null);\n\n const getItems = useCallback(\n (ranges: Range[]): FileStorageItem[] => {\n if (ranges.length === 0 || loadedViewport == null) {\n return [];\n }\n\n const items = [] as FileStorageItem[];\n for (let i = 0; i < ranges.length; i += 1) {\n const range = ranges[i];\n for (let j = range[0]; j <= range[1]; j += 1) {\n if (\n j >= loadedViewport.offset &&\n j < loadedViewport.offset + loadedViewport.items.length\n ) {\n items.push(loadedViewport.items[j - loadedViewport.offset]);\n }\n }\n }\n return items;\n },\n [loadedViewport]\n );\n\n const getItem = useCallback(\n (itemIndex: number): FileStorageItem | undefined => {\n const items = getItems([[itemIndex, itemIndex]]);\n if (items.length > 0) {\n return items[0];\n }\n },\n [getItems]\n );\n\n /**\n * Get the placeholder text to show when a drag operation is in progress\n */\n const getDragPlaceholderText = useCallback(() => {\n const count = RangeUtils.count(selectedRanges);\n if (count === 0) {\n return null;\n }\n\n if (count === 1) {\n const index = selectedRanges[0][0];\n const item = getItem(index);\n if (item != null) {\n return item.filename;\n }\n }\n return `${count} items`;\n }, [getItem, selectedRanges]);\n\n /**\n * Drop the currently dragged items at the currently set drop target.\n * If an itemIndex is provided, focus that index after the drop.\n */\n const dropItems = useCallback(\n (itemIndex?: number) => {\n if (!draggedItems || !dropTargetItem) {\n return;\n }\n\n log.debug('dropItems', draggedItems, 'to', itemIndex);\n\n try {\n const { files, targetPath } = getMoveOperation(\n draggedItems,\n dropTargetItem\n );\n onMove?.(files, targetPath);\n if (itemIndex != null) {\n setSelectedRanges([[itemIndex, itemIndex]]);\n itemList.current?.focusItem(itemIndex);\n }\n } catch (err) {\n log.error('Unable to complete move', err);\n }\n },\n [draggedItems, dropTargetItem, onMove]\n );\n\n const handleSelect = useCallback(\n (itemIndex: number, event: React.SyntheticEvent) => {\n const item = loadedViewport.items[itemIndex - loadedViewport.offset];\n if (item !== undefined) {\n log.debug('handleItemClick', item);\n\n onSelect(item, event);\n if (isDirectory(item)) {\n table?.setExpanded(item.filename, !item.isExpanded);\n }\n }\n },\n [loadedViewport, onSelect, table]\n );\n\n const handleItemDragStart = useCallback(\n (itemIndex: number, e: React.DragEvent<HTMLDivElement>) => {\n log.debug2('handleItemDragStart', itemIndex, selectedRanges);\n\n let draggedRanges = selectedRanges;\n if (!RangeUtils.isSelected(selectedRanges, itemIndex)) {\n draggedRanges = [[itemIndex, itemIndex]];\n setSelectedRanges(draggedRanges);\n }\n\n setDraggedItems(getItems(draggedRanges));\n\n // We need to reset reset the mouse state since we steal the drag\n itemList.current?.resetMouseState();\n\n const newDragPlaceholder = document.createElement('div');\n newDragPlaceholder.innerHTML = `<div class=\"dnd-placeholder-content\">${getDragPlaceholderText()}</div>`;\n newDragPlaceholder.className = 'file-list-dnd-placeholder';\n document.body.appendChild(newDragPlaceholder);\n e.dataTransfer.setDragImage(newDragPlaceholder, 0, 0);\n e.dataTransfer.effectAllowed = 'move';\n setDragPlaceholder(newDragPlaceholder);\n },\n [getDragPlaceholderText, getItems, selectedRanges]\n );\n\n const handleItemDragOver = useCallback(\n (itemIndex: number, e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n\n log.debug2('handleItemDragOver', e);\n setDropTargetItem(getItem(itemIndex));\n },\n [getItem]\n );\n\n const handleItemDragEnd = useCallback(\n (itemIndex: number, e: React.DragEvent<HTMLDivElement>) => {\n log.debug('handleItemDragEnd', itemIndex);\n\n dragPlaceholder?.remove();\n\n // Drag end is triggered after drop\n // Also drop isn't triggered if drag end is outside of the list\n setDraggedItems(undefined);\n setDropTargetItem(undefined);\n setDragPlaceholder(undefined);\n },\n [dragPlaceholder]\n );\n\n const handleItemDrop = useCallback(\n (itemIndex: number, e: React.DragEvent<HTMLDivElement>) => {\n dropItems(itemIndex);\n },\n [dropItems]\n );\n\n const handleItemDragExit = useCallback(() => {\n log.debug2('handleItemDragExit');\n setDropTargetItem(undefined);\n }, []);\n\n const handleListDragOver = useCallback(\n (e: React.DragEvent<HTMLDivElement>) => {\n if (\n e.target instanceof Element &&\n e.target.classList.contains(ITEM_LIST_CLASS_NAME)\n ) {\n // Need to prevent default to enable drop\n // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#droptargets\n e.preventDefault();\n\n log.debug2('handleListDragOver', e);\n setDropTargetItem({\n type: 'directory',\n filename: '/',\n basename: '/',\n id: '/',\n });\n }\n },\n []\n );\n\n const handleListDrop = useCallback(\n (e: React.DragEvent<HTMLDivElement>) => {\n if (\n e.target instanceof Element &&\n e.target.classList.contains(ITEM_LIST_CLASS_NAME)\n ) {\n log.debug('handleListDrop');\n dropItems();\n }\n },\n [dropItems]\n );\n\n const handleSelectionChange = useCallback(\n newSelectedRanges => {\n log.debug2('handleSelectionChange', newSelectedRanges);\n if (newSelectedRanges !== selectedRanges) {\n setSelectedRanges(newSelectedRanges);\n const selectedItems = getItems(newSelectedRanges);\n onSelectionChange(selectedItems);\n }\n },\n [getItems, onSelectionChange, selectedRanges]\n );\n\n const handleFocusChange = useCallback(\n focusIndex => {\n log.debug2('handleFocusChange', focusIndex);\n if (focusIndex != null) {\n const [focusedItem] = getItems([[focusIndex, focusIndex]]);\n onFocusChange(focusedItem);\n } else {\n onFocusChange();\n }\n },\n [getItems, onFocusChange]\n );\n\n const handleViewportChange = useCallback(\n (top: number, bottom: number) => {\n log.debug('handleViewportChange', top, bottom);\n if (top !== viewport.top || bottom !== viewport.bottom) {\n setViewport({ top, bottom });\n }\n },\n [viewport]\n );\n\n const isDropTargetValid = useMemo(() => {\n if (!draggedItems || !dropTargetItem) {\n return false;\n }\n\n try {\n getMoveOperation(draggedItems, dropTargetItem);\n log.debug('handleValidateDropTarget true');\n return true;\n } catch (e) {\n log.debug('handleValidateDropTarget false');\n return false;\n }\n }, [draggedItems, dropTargetItem]);\n\n const { focusedPath } = props;\n useEffect(() => {\n if (focusedPath !== undefined) {\n if (focusedPath === '/') {\n table.collapseAll();\n } else {\n table.setExpanded(focusedPath, false);\n table.setExpanded(focusedPath, true);\n }\n }\n }, [table, focusedPath]);\n\n useEffect(\n function updateTableViewport() {\n log.debug('updating table viewport', viewport);\n table?.setViewport({\n top: Math.max(0, viewport.top - overscanCount),\n bottom: viewport.bottom + overscanCount,\n });\n },\n [overscanCount, table, viewport]\n );\n\n // Listen for table updates\n useEffect(\n function setLoadedViewportAndReturnCleanup() {\n const listenerRemover = table.onUpdate(newViewport => {\n setLoadedViewport({\n items: newViewport.items.map(item => ({\n ...item,\n itemName: item.basename,\n })),\n offset: newViewport.offset,\n itemCount: table.size,\n });\n });\n return () => {\n listenerRemover();\n };\n },\n [table]\n );\n\n // Expand a folder if hovering over it\n useEffect(\n function expandFolderOnHover() {\n if (\n dropTargetItem != null &&\n isDirectory(dropTargetItem) &&\n dropTargetItem.filename !== '/'\n ) {\n const timeout = setTimeout(() => {\n if (!dropTargetItem.isExpanded) {\n table?.setExpanded(dropTargetItem.filename, true);\n }\n }, DRAG_HOVER_TIMEOUT);\n return () => clearTimeout(timeout);\n }\n },\n [dropTargetItem, table]\n );\n\n const renderWrapper = useCallback(\n itemProps =>\n renderItem({\n ...itemProps,\n isDragInProgress: draggedItems != null,\n dropTargetItem,\n draggedItems,\n isDropTargetValid,\n onDragStart: handleItemDragStart,\n onDragEnd: handleItemDragEnd,\n onDragOver: handleItemDragOver,\n onDragExit: handleItemDragExit,\n onDrop: handleItemDrop,\n }),\n [\n handleItemDragEnd,\n handleItemDragExit,\n handleItemDragOver,\n handleItemDragStart,\n handleItemDrop,\n draggedItems,\n dropTargetItem,\n isDropTargetValid,\n renderItem,\n ]\n );\n\n return (\n <div\n ref={fileList}\n className={classNames('file-list', {\n 'is-dragging': draggedItems != null,\n })}\n onDragOver={handleListDragOver}\n onDrop={handleListDrop}\n >\n <ItemList\n ref={itemList}\n items={loadedViewport.items}\n itemCount={loadedViewport.itemCount}\n offset={loadedViewport.offset}\n onFocusChange={handleFocusChange}\n onSelect={handleSelect}\n onSelectionChange={handleSelectionChange}\n onViewportChange={handleViewportChange}\n selectedRanges={selectedRanges}\n renderItem={renderWrapper}\n rowHeight={rowHeight}\n isMultiSelect={isMultiSelect}\n isDragSelect={false}\n isDeselectOnClick={false}\n />\n </div>\n );\n}\n\nexport default FileList;\n"],"mappings":";;;;;AAAA,SAASA,QAAQ,QAAe,uBAAuB;AACvD,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,OAAOC,UAAU,MAAM,YAAY;AACnC,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,QAAQ,EAAEtC,YAAa;IACvB,iBAAiB,EAAEmC,qBAAsB;IACzC,gBAAgB,EAAEM,oBAAqB;IACvC,cAAc,EAAEnE,cAAe;IAC/B,UAAU,EAAEqF,aAAc;IAC1B,SAAS,EAAEvG,SAAU;IACrB,aAAa,EAAER,aAAc;IAC7B,YAAY,EAAE,KAAM;IACpB,iBAAiB,EAAE;EAAM,EACzB,CACE;AAEV;AAEA,eAAeF,QAAQ"}
@@ -0,0 +1,167 @@
1
+ import { ContextActions } from '@deephaven/components';
2
+ import { assertNotNull } from '@deephaven/utils';
3
+ import React, { useCallback, useMemo, useState } from 'react';
4
+ import FileList from "./FileList.js";
5
+ import { FileListItem } from "./FileListItem.js";
6
+ import { DEFAULT_ROW_HEIGHT } from "./FileListUtils.js";
7
+ import { isDirectory } from "./FileStorage.js";
8
+ import SHORTCUTS from "./FileExplorerShortcuts.js";
9
+ import "./FileExplorer.css";
10
+ import FileUtils from "./FileUtils.js";
11
+ import FileListItemEditor from "./FileListItemEditor.js";
12
+ /**
13
+ * Component that displays and allows interaction with the file system in the provided FileStorage.
14
+ */
15
+ export function FileListContainer(props) {
16
+ var {
17
+ isMultiSelect = false,
18
+ focusedPath,
19
+ showContextMenu = false,
20
+ onCreateFile,
21
+ onCreateFolder,
22
+ onCopy,
23
+ onDelete,
24
+ onMove,
25
+ onRename,
26
+ onSelect,
27
+ onSelectionChange,
28
+ table,
29
+ rowHeight = DEFAULT_ROW_HEIGHT,
30
+ validateRename = () => Promise.resolve()
31
+ } = props;
32
+ var [renameItem, setRenameItem] = useState();
33
+ var [selectedItems, setSelectedItems] = useState([]);
34
+ var [focusedItem, setFocusedItem] = useState();
35
+ var handleSelectionChange = useCallback(newSelectedItems => {
36
+ setSelectedItems(newSelectedItems);
37
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(newSelectedItems);
38
+ }, [onSelectionChange]);
39
+ var handleFocusChange = useCallback(newFocusedItem => {
40
+ setFocusedItem(newFocusedItem);
41
+ }, []);
42
+ var handleCopyAction = useCallback(() => {
43
+ if (focusedItem) {
44
+ onCopy === null || onCopy === void 0 ? void 0 : onCopy(focusedItem);
45
+ }
46
+ }, [focusedItem, onCopy]);
47
+ var handleDeleteAction = useCallback(() => {
48
+ if (selectedItems.length > 0) {
49
+ onDelete === null || onDelete === void 0 ? void 0 : onDelete(selectedItems);
50
+ }
51
+ }, [onDelete, selectedItems]);
52
+ var handleNewFileAction = useCallback(() => {
53
+ onCreateFile === null || onCreateFile === void 0 ? void 0 : onCreateFile();
54
+ }, [onCreateFile]);
55
+ var handleNewFolderAction = useCallback(() => {
56
+ if (focusedItem) {
57
+ onCreateFolder === null || onCreateFolder === void 0 ? void 0 : onCreateFolder(FileUtils.getPath(focusedItem.filename));
58
+ }
59
+ }, [focusedItem, onCreateFolder]);
60
+ var handleRenameAction = useCallback(() => {
61
+ if (focusedItem) {
62
+ setRenameItem(focusedItem);
63
+ }
64
+ }, [focusedItem]);
65
+ var handleRenameCancel = useCallback(() => {
66
+ setRenameItem(undefined);
67
+ }, []);
68
+ var handleRenameSubmit = useCallback(newName => {
69
+ if (renameItem) {
70
+ onRename === null || onRename === void 0 ? void 0 : onRename(renameItem, newName);
71
+ setRenameItem(undefined);
72
+ }
73
+ }, [onRename, renameItem]);
74
+ var actions = useMemo(() => {
75
+ if (renameItem) {
76
+ // While renaming, we don't want to enable any of the context actions or it may interfere with renaming input
77
+ return [];
78
+ }
79
+ var result = [];
80
+ if (onCreateFile) {
81
+ result.push({
82
+ title: 'New File',
83
+ description: 'Create new file',
84
+ action: handleNewFileAction,
85
+ group: ContextActions.groups.medium
86
+ });
87
+ }
88
+ if (onCreateFolder) {
89
+ result.push({
90
+ title: 'New Folder',
91
+ description: 'Create new folder',
92
+ action: handleNewFolderAction,
93
+ group: ContextActions.groups.medium
94
+ });
95
+ }
96
+ if (onCopy) {
97
+ result.push({
98
+ title: 'Copy',
99
+ description: 'Copy',
100
+ action: handleCopyAction,
101
+ group: ContextActions.groups.low,
102
+ disabled: focusedItem == null || isDirectory(focusedItem)
103
+ });
104
+ }
105
+ if (onDelete && selectedItems.length > 0) {
106
+ result.push({
107
+ title: 'Delete',
108
+ description: 'Delete',
109
+ shortcut: SHORTCUTS.FILE_EXPLORER.DELETE,
110
+ action: handleDeleteAction,
111
+ group: ContextActions.groups.low
112
+ });
113
+ }
114
+ if (onRename) {
115
+ result.push({
116
+ title: 'Rename',
117
+ description: 'Rename',
118
+ shortcut: SHORTCUTS.FILE_EXPLORER.RENAME,
119
+ action: handleRenameAction,
120
+ group: ContextActions.groups.low,
121
+ disabled: focusedItem == null
122
+ });
123
+ }
124
+ return result;
125
+ }, [handleCopyAction, handleDeleteAction, handleNewFileAction, handleNewFolderAction, handleRenameAction, focusedItem, onCopy, onCreateFile, onCreateFolder, onDelete, onRename, selectedItems, renameItem]);
126
+ var validateRenameItem = useCallback(newName => {
127
+ assertNotNull(renameItem);
128
+ return validateRename(renameItem, newName);
129
+ }, [renameItem, validateRename]);
130
+ var renderItem = useCallback(itemProps => {
131
+ var {
132
+ item
133
+ } = itemProps;
134
+ if (renameItem && renameItem.filename === item.filename) {
135
+ return (
136
+ /*#__PURE__*/
137
+ // eslint-disable-next-line react/jsx-props-no-spreading
138
+ React.createElement(FileListItem, itemProps, /*#__PURE__*/React.createElement(FileListItemEditor, {
139
+ item: item,
140
+ validate: validateRenameItem,
141
+ onSubmit: handleRenameSubmit,
142
+ onCancel: handleRenameCancel
143
+ }))
144
+ );
145
+ }
146
+ // eslint-disable-next-line react/jsx-props-no-spreading
147
+ return /*#__PURE__*/React.createElement(FileListItem, itemProps);
148
+ }, [handleRenameCancel, handleRenameSubmit, renameItem, validateRenameItem]);
149
+ return /*#__PURE__*/React.createElement("div", {
150
+ className: "file-list-container"
151
+ }, table != null && /*#__PURE__*/React.createElement(FileList, {
152
+ onMove: onMove,
153
+ onSelect: onSelect,
154
+ onSelectionChange: handleSelectionChange,
155
+ onFocusChange: handleFocusChange,
156
+ renderItem: renderItem,
157
+ rowHeight: rowHeight,
158
+ table: table,
159
+ isMultiSelect: isMultiSelect,
160
+ focusedPath: focusedPath
161
+ }), showContextMenu && /*#__PURE__*/React.createElement(ContextActions, {
162
+ actions: actions
163
+ }));
164
+ }
165
+ FileListContainer.displayName = 'FileListContainer';
166
+ export default FileListContainer;
167
+ //# sourceMappingURL=FileListContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileListContainer.js","names":["ContextActions","assertNotNull","React","useCallback","useMemo","useState","FileList","FileListItem","DEFAULT_ROW_HEIGHT","isDirectory","SHORTCUTS","FileUtils","FileListItemEditor","FileListContainer","props","isMultiSelect","focusedPath","showContextMenu","onCreateFile","onCreateFolder","onCopy","onDelete","onMove","onRename","onSelect","onSelectionChange","table","rowHeight","validateRename","Promise","resolve","renameItem","setRenameItem","selectedItems","setSelectedItems","focusedItem","setFocusedItem","handleSelectionChange","newSelectedItems","handleFocusChange","newFocusedItem","handleCopyAction","handleDeleteAction","length","handleNewFileAction","handleNewFolderAction","getPath","filename","handleRenameAction","handleRenameCancel","undefined","handleRenameSubmit","newName","actions","result","push","title","description","action","group","groups","medium","low","disabled","shortcut","FILE_EXPLORER","DELETE","RENAME","validateRenameItem","renderItem","itemProps","item","displayName"],"sources":["../src/FileListContainer.tsx"],"sourcesContent":["import { ContextAction, ContextActions } from '@deephaven/components';\nimport { assertNotNull } from '@deephaven/utils';\nimport React, { useCallback, useMemo, useState } from 'react';\nimport FileList from './FileList';\nimport { FileListItem, FileListRenderItemProps } from './FileListItem';\nimport { DEFAULT_ROW_HEIGHT } from './FileListUtils';\nimport { FileStorageItem, FileStorageTable, isDirectory } from './FileStorage';\nimport SHORTCUTS from './FileExplorerShortcuts';\nimport './FileExplorer.scss';\nimport FileUtils from './FileUtils';\nimport FileListItemEditor from './FileListItemEditor';\n\nexport interface FileListContainerProps {\n showContextMenu?: boolean;\n table: FileStorageTable;\n\n isMultiSelect?: boolean;\n focusedPath?: string;\n\n onCreateFile?: (path?: string) => void;\n onCreateFolder?: (path?: string) => void;\n onCopy?: (file: FileStorageItem) => void;\n onDelete?: (files: FileStorageItem[]) => void;\n onMove?: (files: FileStorageItem[], path: string) => void;\n onRename?: (file: FileStorageItem, newName: string) => void;\n onSelect: (file: FileStorageItem, event: React.SyntheticEvent) => void;\n validateRename?: (file: FileStorageItem, newName: string) => Promise<void>;\n onSelectionChange?: (selectedItems: FileStorageItem[]) => void;\n\n /** Height of each item in the list */\n rowHeight?: number;\n}\n\n/**\n * Component that displays and allows interaction with the file system in the provided FileStorage.\n */\nexport function FileListContainer(props: FileListContainerProps): JSX.Element {\n const {\n isMultiSelect = false,\n focusedPath,\n showContextMenu = false,\n onCreateFile,\n onCreateFolder,\n onCopy,\n onDelete,\n onMove,\n onRename,\n onSelect,\n onSelectionChange,\n table,\n rowHeight = DEFAULT_ROW_HEIGHT,\n validateRename = () => Promise.resolve(),\n } = props;\n const [renameItem, setRenameItem] = useState<FileStorageItem>();\n const [selectedItems, setSelectedItems] = useState([] as FileStorageItem[]);\n const [focusedItem, setFocusedItem] = useState<FileStorageItem>();\n\n const handleSelectionChange = useCallback(\n newSelectedItems => {\n setSelectedItems(newSelectedItems);\n onSelectionChange?.(newSelectedItems);\n },\n [onSelectionChange]\n );\n\n const handleFocusChange = useCallback(newFocusedItem => {\n setFocusedItem(newFocusedItem);\n }, []);\n\n const handleCopyAction = useCallback(() => {\n if (focusedItem) {\n onCopy?.(focusedItem);\n }\n }, [focusedItem, onCopy]);\n\n const handleDeleteAction = useCallback(() => {\n if (selectedItems.length > 0) {\n onDelete?.(selectedItems);\n }\n }, [onDelete, selectedItems]);\n\n const handleNewFileAction = useCallback(() => {\n onCreateFile?.();\n }, [onCreateFile]);\n\n const handleNewFolderAction = useCallback(() => {\n if (focusedItem) {\n onCreateFolder?.(FileUtils.getPath(focusedItem.filename));\n }\n }, [focusedItem, onCreateFolder]);\n\n const handleRenameAction = useCallback(() => {\n if (focusedItem) {\n setRenameItem(focusedItem);\n }\n }, [focusedItem]);\n\n const handleRenameCancel = useCallback((): void => {\n setRenameItem(undefined);\n }, []);\n\n const handleRenameSubmit = useCallback(\n (newName: string): void => {\n if (renameItem) {\n onRename?.(renameItem, newName);\n setRenameItem(undefined);\n }\n },\n [onRename, renameItem]\n );\n\n const actions = useMemo(() => {\n if (renameItem) {\n // While renaming, we don't want to enable any of the context actions or it may interfere with renaming input\n return [];\n }\n\n const result = [] as ContextAction[];\n if (onCreateFile) {\n result.push({\n title: 'New File',\n description: 'Create new file',\n action: handleNewFileAction,\n group: ContextActions.groups.medium,\n });\n }\n if (onCreateFolder) {\n result.push({\n title: 'New Folder',\n description: 'Create new folder',\n action: handleNewFolderAction,\n group: ContextActions.groups.medium,\n });\n }\n if (onCopy) {\n result.push({\n title: 'Copy',\n description: 'Copy',\n action: handleCopyAction,\n group: ContextActions.groups.low,\n disabled: focusedItem == null || isDirectory(focusedItem),\n });\n }\n if (onDelete && selectedItems.length > 0) {\n result.push({\n title: 'Delete',\n description: 'Delete',\n shortcut: SHORTCUTS.FILE_EXPLORER.DELETE,\n action: handleDeleteAction,\n group: ContextActions.groups.low,\n });\n }\n if (onRename) {\n result.push({\n title: 'Rename',\n description: 'Rename',\n shortcut: SHORTCUTS.FILE_EXPLORER.RENAME,\n action: handleRenameAction,\n group: ContextActions.groups.low,\n disabled: focusedItem == null,\n });\n }\n return result;\n }, [\n handleCopyAction,\n handleDeleteAction,\n handleNewFileAction,\n handleNewFolderAction,\n handleRenameAction,\n focusedItem,\n onCopy,\n onCreateFile,\n onCreateFolder,\n onDelete,\n onRename,\n selectedItems,\n renameItem,\n ]);\n\n const validateRenameItem = useCallback(\n (newName: string): Promise<void> => {\n assertNotNull(renameItem);\n return validateRename(renameItem, newName);\n },\n [renameItem, validateRename]\n );\n\n const renderItem = useCallback(\n (itemProps: FileListRenderItemProps): JSX.Element => {\n const { item } = itemProps;\n if (renameItem && renameItem.filename === item.filename) {\n return (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <FileListItem {...itemProps}>\n <FileListItemEditor\n item={item}\n validate={validateRenameItem}\n onSubmit={handleRenameSubmit}\n onCancel={handleRenameCancel}\n />\n </FileListItem>\n );\n }\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <FileListItem {...itemProps} />;\n },\n [handleRenameCancel, handleRenameSubmit, renameItem, validateRenameItem]\n );\n\n return (\n <div className=\"file-list-container\">\n {table != null && (\n <FileList\n onMove={onMove}\n onSelect={onSelect}\n onSelectionChange={handleSelectionChange}\n onFocusChange={handleFocusChange}\n renderItem={renderItem}\n rowHeight={rowHeight}\n table={table}\n isMultiSelect={isMultiSelect}\n focusedPath={focusedPath}\n />\n )}\n {showContextMenu && <ContextActions actions={actions} />}\n </div>\n );\n}\n\nFileListContainer.displayName = 'FileListContainer';\n\nexport default FileListContainer;\n"],"mappings":"AAAA,SAAwBA,cAAc,QAAQ,uBAAuB;AACrE,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAAC,OACvDC,QAAQ;AAAA,SACNC,YAAY;AAAA,SACZC,kBAAkB;AAAA,SACiBC,WAAW;AAAA,OAChDC,SAAS;AAAA;AAAA,OAETC,SAAS;AAAA,OACTC,kBAAkB;AAuBzB;AACA;AACA;AACA,OAAO,SAASC,iBAAiB,CAACC,KAA6B,EAAe;EAC5E,IAAM;IACJC,aAAa,GAAG,KAAK;IACrBC,WAAW;IACXC,eAAe,GAAG,KAAK;IACvBC,YAAY;IACZC,cAAc;IACdC,MAAM;IACNC,QAAQ;IACRC,MAAM;IACNC,QAAQ;IACRC,QAAQ;IACRC,iBAAiB;IACjBC,KAAK;IACLC,SAAS,GAAGnB,kBAAkB;IAC9BoB,cAAc,GAAG,MAAMC,OAAO,CAACC,OAAO;EACxC,CAAC,GAAGhB,KAAK;EACT,IAAM,CAACiB,UAAU,EAAEC,aAAa,CAAC,GAAG3B,QAAQ,EAAmB;EAC/D,IAAM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