@hypericon/mico 0.3.14 → 0.3.15

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.
@@ -31,12 +31,16 @@ export declare const Tree: m.Component<{
31
31
  }) => void) | undefined;
32
32
  /** Optional message to display in defined but empty children lists */
33
33
  emptyChildrenMessage?: string | undefined;
34
- /** Optionally override the default icon for a collapsed folder */
35
- collapsedIcon?: m.Vnode<any, {}> | undefined;
36
- /** Optionally override the default icon for an expanded folder */
37
- expandedIcon?: m.Vnode<any, {}> | undefined;
34
+ /** Optionally override the default icon for a collapsed node */
35
+ collapsedIcon?: m.Vnode<any, any> | undefined;
36
+ /** Optionally override the default icon for an expanded node */
37
+ expandedIcon?: m.Vnode<any, any> | undefined;
38
+ /** Optionally override the default toggle icon for a node that cannot toggle */
39
+ noToggleIcon?: m.Vnode<any, any> | undefined;
38
40
  /** Optionally enable toggling of expansion nodes by clicking their labels */
39
41
  toggleExpansionWithLabel?: boolean | undefined;
42
+ /** Optionally override the default nesting width */
43
+ nestingWidth?: string | undefined;
40
44
  /** Optional CSS classes to apply to the root div */
41
45
  class?: string | undefined;
42
46
  /** Optional CSS styles to apply to the root div */
@@ -80,12 +84,16 @@ export declare function createTree<TNodeData extends object = {}>(): m.Component
80
84
  }) => void) | undefined;
81
85
  /** Optional message to display in defined but empty children lists */
82
86
  emptyChildrenMessage?: string | undefined;
83
- /** Optionally override the default icon for a collapsed folder */
84
- collapsedIcon?: m.Vnode<any, {}> | undefined;
85
- /** Optionally override the default icon for an expanded folder */
86
- expandedIcon?: m.Vnode<any, {}> | undefined;
87
+ /** Optionally override the default icon for a collapsed node */
88
+ collapsedIcon?: m.Vnode<any, any> | undefined;
89
+ /** Optionally override the default icon for an expanded node */
90
+ expandedIcon?: m.Vnode<any, any> | undefined;
91
+ /** Optionally override the default toggle icon for a node that cannot toggle */
92
+ noToggleIcon?: m.Vnode<any, any> | undefined;
87
93
  /** Optionally enable toggling of expansion nodes by clicking their labels */
88
94
  toggleExpansionWithLabel?: boolean | undefined;
95
+ /** Optionally override the default nesting width */
96
+ nestingWidth?: string | undefined;
89
97
  /** Optional CSS classes to apply to the root div */
90
98
  class?: string | undefined;
91
99
  /** Optional CSS styles to apply to the root div */
@@ -8,6 +8,7 @@ const utils_1 = require("@hypericon/utils");
8
8
  const mithril_1 = __importDefault(require("mithril"));
9
9
  const icon_1 = require("../icon");
10
10
  const DATA_TRANSFER_TYPE = "application/tree-data";
11
+ const DEFAULT_NESTING_WIDTH = "1.5rem";
11
12
  /**
12
13
  * An untyped tree component (see `createTree<T>()`)
13
14
  */
@@ -47,7 +48,9 @@ function createTree() {
47
48
  emptyChildrenMessage: attrs.emptyChildrenMessage,
48
49
  collapsedIcon: attrs.collapsedIcon,
49
50
  expandedIcon: attrs.expandedIcon,
51
+ noToggleIcon: attrs.noToggleIcon,
50
52
  toggleExpansionWithLabel: attrs.toggleExpansionWithLabel,
53
+ nestingWidth: attrs.nestingWidth || DEFAULT_NESTING_WIDTH,
51
54
  });
52
55
  })),
53
56
  ]);
@@ -132,7 +135,7 @@ function createTree() {
132
135
  style: `display: flex; align-items: stretch; max-width: 100%; overflow-x: hidden; ${(attrs.toggleExpansionWithLabel && enableToggling) ? `cursor: pointer;` : ``}`,
133
136
  }, [
134
137
  expanded ? (0, mithril_1.default)("button.mico-tree-toggle", {
135
- style: `width: 1.5rem; flex: none;`,
138
+ style: `width: ${attrs.nestingWidth}; flex: none;`,
136
139
  // class: enableToggling ? `hover:text-primary` : `text-view-icon`,
137
140
  disabled: !enableToggling,
138
141
  onclick: (ev) => {
@@ -144,7 +147,7 @@ function createTree() {
144
147
  },
145
148
  }, attrs.expandedIcon || (0, mithril_1.default)(icon_1.Icon, { fas: "chevron-down" })) : undefined,
146
149
  collapsed ? (0, mithril_1.default)("button.mico-tree-toggle", {
147
- style: `width: 1.5rem; flex: none;`,
150
+ style: `width: ${attrs.nestingWidth}; flex: none;`,
148
151
  // class: enableToggling ? `hover:text-primary` : `text-view-icon`,
149
152
  disabled: !enableToggling,
150
153
  onclick: (ev) => {
@@ -155,6 +158,9 @@ function createTree() {
155
158
  (_a = attrs.ontoggle) === null || _a === void 0 ? void 0 : _a.call(attrs, { node, expanded: true, recursive: ev.altKey });
156
159
  },
157
160
  }, attrs.collapsedIcon || (0, mithril_1.default)(icon_1.Icon, { fas: "chevron-right" })) : undefined,
161
+ (!canHaveChildren) ? (0, mithril_1.default)(".mico-tree-toggle", {
162
+ style: `width: ${attrs.nestingWidth}; flex: none;`,
163
+ }, attrs.noToggleIcon || (0, mithril_1.default)(icon_1.Icon, { fas: "caret-right" })) : [],
158
164
  (0, mithril_1.default)(".mico-tree-label", {
159
165
  class: `${targettingDragClass}`,
160
166
  style: "position: relative; flex: 1 1 0%; overflow-x: hidden;",
@@ -181,7 +187,9 @@ function createTree() {
181
187
  ]),
182
188
  ]),
183
189
  // Any nested children within the item
184
- (expanded) ? (0, mithril_1.default)("ul", [
190
+ (expanded) ? (0, mithril_1.default)("ul", {
191
+ style: `margin-left: ${attrs.nestingWidth};`,
192
+ }, [
185
193
  ...(node.children || []).map((child, i) => {
186
194
  return (0, mithril_1.default)(TreeNode, {
187
195
  // key: child.key,
@@ -197,7 +205,9 @@ function createTree() {
197
205
  emptyChildrenMessage: attrs.emptyChildrenMessage,
198
206
  collapsedIcon: attrs.collapsedIcon,
199
207
  expandedIcon: attrs.expandedIcon,
208
+ noToggleIcon: attrs.noToggleIcon,
200
209
  toggleExpansionWithLabel: attrs.toggleExpansionWithLabel,
210
+ nestingWidth: attrs.nestingWidth,
201
211
  });
202
212
  }),
203
213
  (canHaveChildren && !hasChildren && emptyChildrenMessage !== undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypericon/mico",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "description": "UI components and utilities with Mithril",
5
5
  "author": "Ed Johnson, Hypericon Ltd",
6
6
  "license": "MIT",