@keenmate/svelte-treeview 1.1.1 → 1.1.2

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/README.md CHANGED
@@ -68,7 +68,7 @@ For more examples see `src/routes/`
68
68
  | hideDisabledCheckboxes | bool | false | hides checkboxes instead of disabling, see [Selection](#selection) |
69
69
  | loadChildrenAsync | ExpandedCallback | null | function that is called when node is expanded, see [Async loading](#async-loading) |
70
70
  | showContextMenu | bool | false | On right click dispaly context menu defined in `context-menu` slot, see [Context menu](#context-menu) |
71
- | expansionTreshold | number | 0 | Expand all nodes when there is less than number provided |
71
+ | expansionThreshold | number | 0 | Expand all nodes when there is less than number provided |
72
72
  | customClasses | Partial<CustomizableClasses> | {} | changes classes used on same elements, see [Custom classes](#custom-classes) |
73
73
  | filter | (node: Node) => boolean or null | null | function that is used for fitlering. It is called on every node |
74
74
  | dragAndDrop | bool | false | enables drag and drop, see [Drag and drop](#drag-and-drop) |
@@ -105,7 +105,7 @@ function getHighlighMode(node, highlightedNode, insertionType) {
105
105
  >
106
106
  {#if effectiveHighlight == InsertionType.insertAbove}
107
107
  <div class="insert-line-wrapper">
108
- <div class="insert-line {classes.inserLineClass}" />
108
+ <div class="insert-line {classes.insertLineClass}" />
109
109
  </div>
110
110
  {/if}
111
111
 
@@ -204,7 +204,7 @@ function getHighlighMode(node, highlightedNode, insertionType) {
204
204
  <!-- Show line if insering -->
205
205
  {#if effectiveHighlight === InsertionType.insertBelow}
206
206
  <div class="insert-line-wrapper">
207
- <div class="insert-line {classes.inserLineClass}" />
207
+ <div class="insert-line {classes.insertLineClass}" />
208
208
  </div>
209
209
  {/if}
210
210
  </li>
@@ -50,8 +50,8 @@ export let recursiveSelection = false;
50
50
  */
51
51
  export let selectionMode = SelectionModes.none;
52
52
  /**
53
- * By default, in recursive mode, non-leaf checkboxes will select/deselct all its children
54
- * If you set this to true, this begaviour will be disabled and only leaf nodes will be selectable
53
+ * By default, in recursive mode, non-leaf checkboxes will select/deselect all its children
54
+ * If you set this to true, this behavior will be disabled and only leaf nodes will be selectable
55
55
  */
56
56
  export let onlyLeafCheckboxes = false; //bool
57
57
  /**
@@ -59,7 +59,7 @@ export let onlyLeafCheckboxes = false; //bool
59
59
  */
60
60
  export let hideDisabledCheckboxes = false; //bool
61
61
  /**
62
- * Function that will be caled when node is expanded and useCallback is set to true
62
+ * Function that will be caged when node is expanded and useCallback is set to true
63
63
  * It should return array of nodes that will be added to tree
64
64
  * If it throws error, node will be collapsed,
65
65
  * but user will be able to open it again and callback will be called
@@ -72,18 +72,18 @@ export let loadChildrenAsync = null;
72
72
  export let showContextMenu = false;
73
73
  // TODO stopped working in new version
74
74
  /**
75
- * Automaticaly expand nodes to this level,
75
+ * Automatically expand nodes to this level,
76
76
  * any user made expansion will override this.
77
77
  */
78
78
  export let expandTo = 0;
79
79
  /**
80
- * Treshold for automatic expansion. If tree has less or equal nodes than this value,
80
+ * Threshold for automatic expansion. If tree has less or equal nodes than this value,
81
81
  * all nodes will be expanded. Default is 0, which means no automatic expansion
82
82
  */
83
- export let expansionTreshold = 0;
83
+ export let expansionThreshold = 0;
84
84
  /**
85
85
  * Classes used in tree. You can override default classes with this prop.
86
- * It is recommended to use default classes and add aditinal styles in your css
86
+ * It is recommended to use default classes and add additional styles in your css
87
87
  */
88
88
  export let customClasses = {};
89
89
  /**
@@ -100,7 +100,7 @@ export let filter = null;
100
100
  */
101
101
  export let logger = null;
102
102
  /*
103
- * Drag and drop mode allows all nodes, that dont have dragDisabled property set to true
103
+ * Drag and drop mode allows all nodes, that don't have dragDisabled property set to true
104
104
  * to be dragged and dropped. By default you can only insert at same level node you are dropping on,
105
105
  * but you can allow nesting by setting nestAllowed to true on node. If you want to disable insertion,
106
106
  * set dropDisabled to true on node. if both is disabled, you wont be able to drop on node.
@@ -131,7 +131,7 @@ $: selectionProvider = new SelectionProvider(helper, recursiveSelection);
131
131
  $: computedTree = computeTree(helper, selectionProvider, tree, filter, props, expandedIds, value);
132
132
  $: debugLog('computedTree', computedTree);
133
133
  export function changeAllExpansion(changeTo) {
134
- debugLog('chaning expantion of every node to ', changeTo ? 'expanded' : 'collapsed');
134
+ debugLog('changing expansion of every node to ', changeTo ? 'expanded' : 'collapsed');
135
135
  if (changeTo) {
136
136
  expandedIds = computedTree.map((node) => node.id);
137
137
  }
@@ -190,7 +190,7 @@ function computeTree(helper, selectionProvider, userProvidedTree, filter, props,
190
190
  const mappedTree = helper.mapTree(userProvidedTree, { ...defaultPropNames, ...props });
191
191
  const { tree: filteredTree, count: filteredCount } = helper.searchTree(mappedTree, filter);
192
192
  // treshold applies to nodes that match the filter, not all their parents
193
- if (filteredCount <= expansionTreshold) {
193
+ if (filteredCount <= expansionThreshold) {
194
194
  expandedIds = uniq([...expandedIds, ...filteredTree.map((node) => node.id)]);
195
195
  }
196
196
  helper.markExpanded(filteredTree, expandedIds);
@@ -229,7 +229,7 @@ function handleCallback(node) {
229
229
  return;
230
230
  }
231
231
  debugLog('calling callback for node', node);
232
- // TODO mark node as loaded and dont call callback again
232
+ // TODO mark node as loaded and don't call callback again
233
233
  // this is now responsibility of user
234
234
  loadChildrenAsync(node);
235
235
  }
@@ -238,7 +238,7 @@ function onSelectionChanged(detail) {
238
238
  const nodePath = node.path;
239
239
  const changeTo = !selectionProvider.isNodeSelected(node);
240
240
  const newValue = selectionProvider.setSelection(computedTree, nodePath, changeTo, value);
241
- debugLog("changing selection of node '", nodePath, "' to ", changeTo, ' returing value ', newValue);
241
+ debugLog("changing selection of node '", nodePath, "' to ", changeTo, ' returning value ', newValue);
242
242
  dispatch('change', newValue);
243
243
  dispatch('selection', {
244
244
  node: node,
@@ -272,7 +272,7 @@ function onDragEnd({ detail: { node, event, element } }) {
272
272
  highlightedNode = null;
273
273
  }
274
274
  function onDragDrop({ detail: { node, event, element } }) {
275
- // here we asume that highlightType is correctly calculated in handleDragOver
275
+ // here we assume that highlightType is correctly calculated in handleDragOver
276
276
  if (!dragAndDrop || draggedNode === null || insertionType === InsertionType.none) {
277
277
  event.preventDefault();
278
278
  return;
@@ -285,7 +285,7 @@ function onDragDrop({ detail: { node, event, element } }) {
285
285
  insertType: insertionType
286
286
  });
287
287
  }
288
- // handle highlihting
288
+ // handle highlighting
289
289
  function onDragEnter({ detail: { node, event, element } }) {
290
290
  highlightedNode = null;
291
291
  if (!draggedNode || !dragAndDrop) {
@@ -35,14 +35,14 @@ declare const __propDef: {
35
35
  * TODO find better name
36
36
  */ selectionMode?: SelectionModes | undefined;
37
37
  /**
38
- * By default, in recursive mode, non-leaf checkboxes will select/deselct all its children
39
- * If you set this to true, this begaviour will be disabled and only leaf nodes will be selectable
38
+ * By default, in recursive mode, non-leaf checkboxes will select/deselect all its children
39
+ * If you set this to true, this behavior will be disabled and only leaf nodes will be selectable
40
40
  */ onlyLeafCheckboxes?: boolean | undefined;
41
41
  /**
42
42
  * Instead of showing disabled checkboxes, show blank space
43
43
  */ hideDisabledCheckboxes?: boolean | undefined;
44
44
  /**
45
- * Function that will be caled when node is expanded and useCallback is set to true
45
+ * Function that will be caged when node is expanded and useCallback is set to true
46
46
  * It should return array of nodes that will be added to tree
47
47
  * If it throws error, node will be collapsed,
48
48
  * but user will be able to open it again and callback will be called
@@ -52,16 +52,16 @@ declare const __propDef: {
52
52
  * Its defined in slot context-menu
53
53
  */ showContextMenu?: boolean | undefined;
54
54
  /**
55
- * Automaticaly expand nodes to this level,
55
+ * Automatically expand nodes to this level,
56
56
  * any user made expansion will override this.
57
57
  */ expandTo?: number | undefined;
58
58
  /**
59
- * Treshold for automatic expansion. If tree has less or equal nodes than this value,
59
+ * Threshold for automatic expansion. If tree has less or equal nodes than this value,
60
60
  * all nodes will be expanded. Default is 0, which means no automatic expansion
61
- */ expansionTreshold?: number | undefined;
61
+ */ expansionThreshold?: number | undefined;
62
62
  /**
63
63
  * Classes used in tree. You can override default classes with this prop.
64
- * It is recommended to use default classes and add aditinal styles in your css
64
+ * It is recommended to use default classes and add additional styles in your css
65
65
  */ customClasses?: Partial<CustomizableClasses> | undefined;
66
66
  /**
67
67
  * Function used to filter what nodes should be shown.
package/dist/constants.js CHANGED
@@ -16,7 +16,7 @@ export const defaultClasses = {
16
16
  nodeClass: '',
17
17
  expandIcon: 'far fa-fw fa-plus-square',
18
18
  collapseIcon: 'far fa-fw fa-minus-square',
19
- inserLineClass: '',
19
+ insertLineClass: '',
20
20
  nestIcon: 'fas fa-level-down-alt'
21
21
  };
22
22
  export const defaultConfig = {
@@ -3,7 +3,7 @@ import { type Node, InsertionType } from '../types.js';
3
3
  export declare class DragDropProvider {
4
4
  helper: TreeHelper;
5
5
  constructor(treeHelper: TreeHelper);
6
- getInsertionPosition(draggendNode: Node, draggedOverNode: Node, e: DragEvent, element: HTMLElement, nest: boolean): InsertionType;
6
+ getInsertionPosition(draggedNode: Node, draggedOverNode: Node, e: DragEvent, element: HTMLElement, nest: boolean): InsertionType;
7
7
  getRelativePosition(element: Element, e: DragEvent): InsertionType;
8
8
  isDropAllowed(draggedNode: Node, targeNode: Node): boolean;
9
9
  }
@@ -4,7 +4,7 @@ export class DragDropProvider {
4
4
  constructor(treeHelper) {
5
5
  this.helper = treeHelper;
6
6
  }
7
- getInsertionPosition(draggendNode, draggedOverNode, e, element, nest) {
7
+ getInsertionPosition(draggedNode, draggedOverNode, e, element, nest) {
8
8
  if (nest && draggedOverNode.nestAllowed) {
9
9
  return InsertionType.nest;
10
10
  }
@@ -65,7 +65,7 @@ export function calculateNewFocusedNode(helper, tree, targetNode, movementDirect
65
65
  return wrapReturn(targetNode);
66
66
  }
67
67
  const parentNode = helper.findNode(tree, parentNodePath);
68
- // asertion
68
+ // assertion
69
69
  if (!parentNode) {
70
70
  console.warn('Parent node not found, this should never happen');
71
71
  return wrapReturn(targetNode);
@@ -113,7 +113,7 @@ export class SelectionProvider {
113
113
  directChildrenStates.push(result.state);
114
114
  }
115
115
  });
116
- // if no children, all are selected, but dont count it for recursive computationq
116
+ // if it doesn't have any children, mark it as selected but ignore it in upstream calculations
117
117
  const ignore = directChildrenStates.length === 0;
118
118
  return { ignore, state: this.computeVisualState(directChildrenStates) };
119
119
  }
@@ -122,7 +122,7 @@ export class SelectionProvider {
122
122
  tree.forEach((node) => {
123
123
  // match itself and all children
124
124
  if (node.path?.startsWith(parentNodePath ? parentNodePath + this.helper.config.separator : '')) {
125
- //dont change if not selectable
125
+ //don't change if not selectable
126
126
  if (!isSelectable(node, SelectionModes.all)) {
127
127
  return;
128
128
  }
@@ -148,6 +148,6 @@ export function isSelectable(node, showCheckboxes) {
148
148
  if (showCheckboxes === SelectionModes.perNode) {
149
149
  return node.checkbox === true;
150
150
  }
151
- //dont show at all
151
+ //don't show at all
152
152
  return false;
153
153
  }
package/dist/types.d.ts CHANGED
@@ -55,11 +55,11 @@ export type CustomizableClasses = {
55
55
  collapseIcon: string;
56
56
  nestIcon: string;
57
57
  expandClass: string;
58
- inserLineClass: string;
58
+ insertLineClass: string;
59
59
  currentlyDraggedClass: string;
60
60
  };
61
- export type DragEnterCallback = (draggendNode: Node, targetNode: Node) => Promise<boolean>;
62
- export type BeforeMovedCallback = (draggendNode: Node, oldParent: Node, newParent: Node, insertionType: string) => boolean;
61
+ export type DragEnterCallback = (draggedNode: Node, targetNode: Node) => Promise<boolean>;
62
+ export type BeforeMovedCallback = (draggedNode: Node, oldParent: Node, newParent: Node, insertionType: string) => boolean;
63
63
  export type ExpandedCallback = (node: Node) => Promise<void>;
64
64
  export type HelperConfig = {
65
65
  separator: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keenmate/svelte-treeview",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",