snice 3.4.0 → 3.5.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 (177) hide show
  1. package/bin/templates/base/package.json +2 -2
  2. package/bin/templates/social/package.json +2 -2
  3. package/bin/templates/social/src/styles/global.css +56 -47
  4. package/dist/components/avatar/snice-avatar.d.ts +2 -2
  5. package/dist/components/avatar/snice-avatar.js +20 -21
  6. package/dist/components/avatar/snice-avatar.js.map +1 -1
  7. package/dist/components/calendar/snice-calendar.d.ts +8 -2
  8. package/dist/components/calendar/snice-calendar.js +160 -82
  9. package/dist/components/calendar/snice-calendar.js.map +1 -1
  10. package/dist/components/chart/snice-chart.js +50 -18
  11. package/dist/components/chart/snice-chart.js.map +1 -1
  12. package/dist/components/checkbox/snice-checkbox.d.ts +4 -1
  13. package/dist/components/checkbox/snice-checkbox.js +46 -17
  14. package/dist/components/checkbox/snice-checkbox.js.map +1 -1
  15. package/dist/components/code-block/highlighter.d.ts +5 -0
  16. package/dist/components/code-block/highlighter.js +137 -0
  17. package/dist/components/code-block/highlighter.js.map +1 -0
  18. package/dist/components/code-block/highlighters/highlight.d.ts +64 -0
  19. package/dist/components/code-block/highlighters/highlight.js +108 -0
  20. package/dist/components/code-block/highlighters/highlight.js.map +1 -0
  21. package/dist/components/code-block/highlighters/prism.d.ts +41 -0
  22. package/dist/components/code-block/highlighters/prism.js +73 -0
  23. package/dist/components/code-block/highlighters/prism.js.map +1 -0
  24. package/dist/components/code-block/snice-code-block.d.ts +19 -1
  25. package/dist/components/code-block/snice-code-block.js +128 -29
  26. package/dist/components/code-block/snice-code-block.js.map +1 -1
  27. package/dist/components/code-block/snice-code-block.types.d.ts +15 -1
  28. package/dist/components/color-picker/snice-color-picker.d.ts +1 -0
  29. package/dist/components/color-picker/snice-color-picker.js +17 -6
  30. package/dist/components/color-picker/snice-color-picker.js.map +1 -1
  31. package/dist/components/date-picker/snice-date-picker.d.ts +1 -0
  32. package/dist/components/date-picker/snice-date-picker.js +16 -5
  33. package/dist/components/date-picker/snice-date-picker.js.map +1 -1
  34. package/dist/components/doc/snice-doc.d.ts +27 -73
  35. package/dist/components/doc/snice-doc.js +385 -534
  36. package/dist/components/doc/snice-doc.js.map +1 -1
  37. package/dist/components/draw/snice-draw.d.ts +4 -0
  38. package/dist/components/draw/snice-draw.js +134 -14
  39. package/dist/components/draw/snice-draw.js.map +1 -1
  40. package/dist/components/draw/snice-draw.types.d.ts +5 -0
  41. package/dist/components/file-upload/snice-file-upload.js +1 -1
  42. package/dist/components/input/snice-input.d.ts +2 -0
  43. package/dist/components/input/snice-input.js +34 -9
  44. package/dist/components/input/snice-input.js.map +1 -1
  45. package/dist/components/kanban/snice-kanban.d.ts +13 -1
  46. package/dist/components/kanban/snice-kanban.js +191 -36
  47. package/dist/components/kanban/snice-kanban.js.map +1 -1
  48. package/dist/components/kanban/snice-kanban.types.d.ts +11 -1
  49. package/dist/components/kpi/snice-kpi.js +5 -1
  50. package/dist/components/kpi/snice-kpi.js.map +1 -1
  51. package/dist/components/layout/snice-layout-sidebar.js +1 -1
  52. package/dist/components/layout/snice-layout-sidebar.js.map +1 -1
  53. package/dist/components/layout/snice-layout.js +1 -1
  54. package/dist/components/layout/snice-layout.js.map +1 -1
  55. package/dist/components/location/snice-location.js +1 -1
  56. package/dist/components/location/snice-location.js.map +1 -1
  57. package/dist/components/radio/snice-radio.d.ts +1 -0
  58. package/dist/components/radio/snice-radio.js +17 -6
  59. package/dist/components/radio/snice-radio.js.map +1 -1
  60. package/dist/components/select/snice-select.d.ts +2 -0
  61. package/dist/components/select/snice-select.js +48 -19
  62. package/dist/components/select/snice-select.js.map +1 -1
  63. package/dist/components/slider/snice-slider.d.ts +2 -0
  64. package/dist/components/slider/snice-slider.js +34 -14
  65. package/dist/components/slider/snice-slider.js.map +1 -1
  66. package/dist/components/snice-cell-HZ2iIBIC.js +4 -0
  67. package/dist/components/snice-cell-HZ2iIBIC.js.map +1 -0
  68. package/dist/components/split-pane/snice-split-pane.js +1 -1
  69. package/dist/components/split-pane/snice-split-pane.js.map +1 -1
  70. package/dist/components/switch/snice-switch.d.ts +1 -0
  71. package/dist/components/switch/snice-switch.js +16 -6
  72. package/dist/components/switch/snice-switch.js.map +1 -1
  73. package/dist/components/table/snice-cell-actions.js +1 -1
  74. package/dist/components/table/snice-cell-actions.js.map +1 -1
  75. package/dist/components/table/snice-cell-boolean.js +1 -1
  76. package/dist/components/table/snice-cell-color.js +1 -1
  77. package/dist/components/table/snice-cell-color.js.map +1 -1
  78. package/dist/components/table/snice-cell-currency.js +1 -1
  79. package/dist/components/table/snice-cell-date.js +1 -1
  80. package/dist/components/table/snice-cell-duration.js +1 -1
  81. package/dist/components/table/snice-cell-email.js +1 -1
  82. package/dist/components/table/snice-cell-email.js.map +1 -1
  83. package/dist/components/table/snice-cell-filesize.js +1 -1
  84. package/dist/components/table/snice-cell-image.js +1 -1
  85. package/dist/components/table/snice-cell-image.js.map +1 -1
  86. package/dist/components/table/snice-cell-json.js +1 -1
  87. package/dist/components/table/snice-cell-json.js.map +1 -1
  88. package/dist/components/table/snice-cell-link.js +1 -1
  89. package/dist/components/table/snice-cell-link.js.map +1 -1
  90. package/dist/components/table/snice-cell-location.js +1 -1
  91. package/dist/components/table/snice-cell-location.js.map +1 -1
  92. package/dist/components/table/snice-cell-number.js +1 -1
  93. package/dist/components/table/snice-cell-percentage.js +1 -1
  94. package/dist/components/table/snice-cell-percentage.js.map +1 -1
  95. package/dist/components/table/snice-cell-phone.js +1 -1
  96. package/dist/components/table/snice-cell-phone.js.map +1 -1
  97. package/dist/components/table/snice-cell-progress.js +3 -3
  98. package/dist/components/table/snice-cell-progress.js.map +1 -1
  99. package/dist/components/table/snice-cell-rating.js +2 -2
  100. package/dist/components/table/snice-cell-rating.js.map +1 -1
  101. package/dist/components/table/snice-cell-sparkline.js +2 -2
  102. package/dist/components/table/snice-cell-sparkline.js.map +1 -1
  103. package/dist/components/table/snice-cell-status.js +1 -1
  104. package/dist/components/table/snice-cell-status.js.map +1 -1
  105. package/dist/components/table/snice-cell-tag.js +1 -1
  106. package/dist/components/table/snice-cell-tag.js.map +1 -1
  107. package/dist/components/table/snice-cell-text.js +1 -1
  108. package/dist/components/table/snice-cell.js +15 -10
  109. package/dist/components/table/snice-cell.js.map +1 -1
  110. package/dist/components/table/snice-header.js +1 -1
  111. package/dist/components/table/snice-header.js.map +1 -1
  112. package/dist/components/table/snice-row.js +2 -2
  113. package/dist/components/table/snice-row.js.map +1 -1
  114. package/dist/components/table/snice-table.d.ts +1 -0
  115. package/dist/components/table/snice-table.js +24 -4
  116. package/dist/components/table/snice-table.js.map +1 -1
  117. package/dist/components/terminal/snice-terminal.d.ts +40 -0
  118. package/dist/components/terminal/snice-terminal.js +371 -0
  119. package/dist/components/terminal/snice-terminal.js.map +1 -0
  120. package/dist/components/terminal/snice-terminal.types.d.ts +20 -24
  121. package/dist/components/textarea/snice-textarea.d.ts +2 -0
  122. package/dist/components/textarea/snice-textarea.js +25 -6
  123. package/dist/components/textarea/snice-textarea.js.map +1 -1
  124. package/dist/components/theme/theme.css +16 -0
  125. package/dist/components/tree/snice-tree-item.d.ts +18 -4
  126. package/dist/components/tree/snice-tree-item.js +271 -88
  127. package/dist/components/tree/snice-tree-item.js.map +1 -1
  128. package/dist/components/tree/snice-tree-item.types.d.ts +3 -0
  129. package/dist/components/tree/snice-tree.d.ts +18 -2
  130. package/dist/components/tree/snice-tree.js +422 -56
  131. package/dist/components/tree/snice-tree.js.map +1 -1
  132. package/dist/components/tree/snice-tree.types.d.ts +1 -0
  133. package/dist/components/virtual-scroller/snice-virtual-scroller.js +4 -2
  134. package/dist/components/virtual-scroller/snice-virtual-scroller.js.map +1 -1
  135. package/dist/index.cjs +42 -23
  136. package/dist/index.cjs.map +1 -1
  137. package/dist/index.esm.js +42 -23
  138. package/dist/index.esm.js.map +1 -1
  139. package/dist/index.iife.js +42 -23
  140. package/dist/index.iife.js.map +1 -1
  141. package/dist/render-tracker.d.ts +1 -0
  142. package/dist/symbols.cjs +13 -14
  143. package/dist/symbols.cjs.map +1 -1
  144. package/dist/symbols.esm.js +13 -14
  145. package/dist/symbols.esm.js.map +1 -1
  146. package/dist/template.d.ts +1 -0
  147. package/dist/transitions.cjs +1 -1
  148. package/dist/transitions.esm.js +1 -1
  149. package/docs/ai/api.md +37 -4
  150. package/docs/ai/components/doc.md +41 -106
  151. package/docs/ai/components/kanban.md +31 -9
  152. package/docs/ai/components/kpi.md +15 -0
  153. package/docs/components/doc.md +96 -212
  154. package/docs/components/kanban.md +119 -4
  155. package/docs/components/kpi.md +27 -0
  156. package/package.json +4 -1
  157. package/dist/components/actions/snice-actions.d.ts +0 -28
  158. package/dist/components/actions/snice-actions.js +0 -220
  159. package/dist/components/actions/snice-actions.js.map +0 -1
  160. package/dist/components/actions/snice-actions.types.d.ts +0 -27
  161. package/dist/components/doc/snice-doc.types.d.ts +0 -118
  162. package/dist/components/gantt/snice-gantt.d.ts +0 -29
  163. package/dist/components/gantt/snice-gantt.js +0 -268
  164. package/dist/components/gantt/snice-gantt.js.map +0 -1
  165. package/dist/components/gantt/snice-gantt.types.d.ts +0 -23
  166. package/dist/components/snice-cell-C0slgOpe.js +0 -4
  167. package/dist/components/snice-cell-C0slgOpe.js.map +0 -1
  168. package/dist/components/stat/snice-stat.d.ts +0 -14
  169. package/dist/components/stat/snice-stat.js +0 -140
  170. package/dist/components/stat/snice-stat.js.map +0 -1
  171. package/dist/components/stat/snice-stat.types.d.ts +0 -12
  172. package/docs/ai/components/actions.md +0 -81
  173. package/docs/ai/components/gantt.md +0 -95
  174. package/docs/ai/components/stat.md +0 -29
  175. package/docs/components/actions.md +0 -317
  176. package/docs/components/gantt.md +0 -347
  177. package/docs/components/stat.md +0 -45
@@ -1,9 +1,10 @@
1
- import { __esDecorate, __runInitializers } from 'tslib';
2
- import { element, property, queryAll, ready, watch, dispatch, render, styles, html, css } from 'snice';
1
+ import { __runInitializers, __esDecorate } from 'tslib';
2
+ import { element, property, queryAll, ready, watch, on, dispatch } from 'snice';
3
3
  import './snice-tree-item.js';
4
4
  import '../checkbox/snice-checkbox.js';
5
+ import '../spinner/snice-spinner.js';
5
6
 
6
- var cssContent = ":host{display:block}.tree{font-family:var(--font-family, system-ui, -apple-system, sans-serif);font-size:var(--font-size-base, 1rem);color:var(--color-text,#1f2937);background-color:var(--color-background,#fff);border:1px solid var(--color-neutral-200,#e5e7eb);border-radius:var(--border-radius-md,.375rem);overflow:auto;max-height:var(--tree-max-height,100%)}.tree__content{padding:var(--spacing-xs,.5rem)}.tree--no-border{border:none}.tree__empty{padding:var(--spacing-lg,1.5rem);text-align:center;color:var(--color-text-muted,#6b7280);font-style:italic}";
7
+ var cssContent = ":host{display:block}.tree{font-family:var(--snice-font-family, system-ui, -apple-system, sans-serif);font-size:var(--snice-font-size-base, 1rem);color:var(--snice-color-text,rgb(23 23 23));background-color:var(--snice-color-background,rgb(255 255 255));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.375rem);overflow:auto;max-height:var(--tree-max-height,100%)}.tree__content{padding:var(--snice-spacing-xs,.5rem)}.tree--no-border{border:none}.tree__empty{padding:var(--snice-spacing-lg,1.5rem);text-align:center;color:var(--snice-color-text-muted,rgb(115 115 115));font-style:italic}";
7
8
 
8
9
  let SniceTree = (() => {
9
10
  let _classDecorators = [element('snice-tree')];
@@ -12,6 +13,9 @@ let SniceTree = (() => {
12
13
  let _classThis;
13
14
  let _classSuper = HTMLElement;
14
15
  let _instanceExtraInitializers = [];
16
+ let _selectable_decorators;
17
+ let _selectable_initializers = [];
18
+ let _selectable_extraInitializers = [];
15
19
  let _selectionMode_decorators;
16
20
  let _selectionMode_initializers = [];
17
21
  let _selectionMode_extraInitializers = [];
@@ -40,17 +44,38 @@ let SniceTree = (() => {
40
44
  let _handleNodesChange_decorators;
41
45
  let _handleSelectedNodesChange_decorators;
42
46
  let _handleCheckedNodesChange_decorators;
47
+ let _handleItemToggle_decorators;
48
+ let _handleItemSelect_decorators;
49
+ let _handleItemCheck_decorators;
50
+ let _handleLazyLoad_decorators;
43
51
  let _dispatchExpandEvent_decorators;
44
52
  let _dispatchCollapseEvent_decorators;
45
53
  let _dispatchSelectEvent_decorators;
46
54
  let _dispatchCheckEvent_decorators;
47
55
  let _dispatchLazyLoadEvent_decorators;
48
- let _render_decorators;
49
- let _styles_decorators;
56
+ let _handleKeyDown_decorators;
57
+ let _handleFocusIn_decorators;
58
+ let _handleFocusOut_decorators;
50
59
  (class extends _classSuper {
51
60
  static { _classThis = this; }
61
+ constructor() {
62
+ super(...arguments);
63
+ this.selectable = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _selectable_initializers, true));
64
+ this.selectionMode = (__runInitializers(this, _selectable_extraInitializers), __runInitializers(this, _selectionMode_initializers, 'single'));
65
+ this.showCheckboxes = (__runInitializers(this, _selectionMode_extraInitializers), __runInitializers(this, _showCheckboxes_initializers, false));
66
+ this.showIcons = (__runInitializers(this, _showCheckboxes_extraInitializers), __runInitializers(this, _showIcons_initializers, true));
67
+ this.expandOnClick = (__runInitializers(this, _showIcons_extraInitializers), __runInitializers(this, _expandOnClick_initializers, false));
68
+ this.nodes = (__runInitializers(this, _expandOnClick_extraInitializers), __runInitializers(this, _nodes_initializers, []));
69
+ this.selectedNodes = (__runInitializers(this, _nodes_extraInitializers), __runInitializers(this, _selectedNodes_initializers, []));
70
+ this.checkedNodes = (__runInitializers(this, _selectedNodes_extraInitializers), __runInitializers(this, _checkedNodes_initializers, []));
71
+ this.nodeMap = (__runInitializers(this, _checkedNodes_extraInitializers), new Map());
72
+ this.treeItems = __runInitializers(this, _treeItems_initializers, void 0);
73
+ this.lastFocusedItem = (__runInitializers(this, _treeItems_extraInitializers), null);
74
+ this.loadingNodeIds = new Set();
75
+ }
52
76
  static {
53
77
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
78
+ _selectable_decorators = [property({ type: Boolean })];
54
79
  _selectionMode_decorators = [property({})];
55
80
  _showCheckboxes_decorators = [property({ type: Boolean, attribute: 'show-checkboxes' })];
56
81
  _showIcons_decorators = [property({ type: Boolean, attribute: 'show-icons' })];
@@ -63,24 +88,35 @@ let SniceTree = (() => {
63
88
  _handleNodesChange_decorators = [watch('nodes')];
64
89
  _handleSelectedNodesChange_decorators = [watch('selectedNodes')];
65
90
  _handleCheckedNodesChange_decorators = [watch('checkedNodes')];
91
+ _handleItemToggle_decorators = [on('tree-item-toggle')];
92
+ _handleItemSelect_decorators = [on('tree-item-select')];
93
+ _handleItemCheck_decorators = [on('tree-item-check')];
94
+ _handleLazyLoad_decorators = [on('tree-item-lazy-load')];
66
95
  _dispatchExpandEvent_decorators = [dispatch('@snice/tree-node-expand', { bubbles: true, composed: true })];
67
96
  _dispatchCollapseEvent_decorators = [dispatch('@snice/tree-node-collapse', { bubbles: true, composed: true })];
68
97
  _dispatchSelectEvent_decorators = [dispatch('@snice/tree-node-select', { bubbles: true, composed: true })];
69
98
  _dispatchCheckEvent_decorators = [dispatch('@snice/tree-node-check', { bubbles: true, composed: true })];
70
99
  _dispatchLazyLoadEvent_decorators = [dispatch('@snice/tree-node-lazy-load', { bubbles: true, composed: true })];
71
- _render_decorators = [render()];
72
- _styles_decorators = [styles()];
100
+ _handleKeyDown_decorators = [on('keydown')];
101
+ _handleFocusIn_decorators = [on('focusin')];
102
+ _handleFocusOut_decorators = [on('focusout')];
73
103
  __esDecorate(this, null, _init_decorators, { kind: "method", name: "init", static: false, private: false, access: { has: obj => "init" in obj, get: obj => obj.init }, metadata: _metadata }, null, _instanceExtraInitializers);
74
104
  __esDecorate(this, null, _handleNodesChange_decorators, { kind: "method", name: "handleNodesChange", static: false, private: false, access: { has: obj => "handleNodesChange" in obj, get: obj => obj.handleNodesChange }, metadata: _metadata }, null, _instanceExtraInitializers);
75
105
  __esDecorate(this, null, _handleSelectedNodesChange_decorators, { kind: "method", name: "handleSelectedNodesChange", static: false, private: false, access: { has: obj => "handleSelectedNodesChange" in obj, get: obj => obj.handleSelectedNodesChange }, metadata: _metadata }, null, _instanceExtraInitializers);
76
106
  __esDecorate(this, null, _handleCheckedNodesChange_decorators, { kind: "method", name: "handleCheckedNodesChange", static: false, private: false, access: { has: obj => "handleCheckedNodesChange" in obj, get: obj => obj.handleCheckedNodesChange }, metadata: _metadata }, null, _instanceExtraInitializers);
107
+ __esDecorate(this, null, _handleItemToggle_decorators, { kind: "method", name: "handleItemToggle", static: false, private: false, access: { has: obj => "handleItemToggle" in obj, get: obj => obj.handleItemToggle }, metadata: _metadata }, null, _instanceExtraInitializers);
108
+ __esDecorate(this, null, _handleItemSelect_decorators, { kind: "method", name: "handleItemSelect", static: false, private: false, access: { has: obj => "handleItemSelect" in obj, get: obj => obj.handleItemSelect }, metadata: _metadata }, null, _instanceExtraInitializers);
109
+ __esDecorate(this, null, _handleItemCheck_decorators, { kind: "method", name: "handleItemCheck", static: false, private: false, access: { has: obj => "handleItemCheck" in obj, get: obj => obj.handleItemCheck }, metadata: _metadata }, null, _instanceExtraInitializers);
110
+ __esDecorate(this, null, _handleLazyLoad_decorators, { kind: "method", name: "handleLazyLoad", static: false, private: false, access: { has: obj => "handleLazyLoad" in obj, get: obj => obj.handleLazyLoad }, metadata: _metadata }, null, _instanceExtraInitializers);
77
111
  __esDecorate(this, null, _dispatchExpandEvent_decorators, { kind: "method", name: "dispatchExpandEvent", static: false, private: false, access: { has: obj => "dispatchExpandEvent" in obj, get: obj => obj.dispatchExpandEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
78
112
  __esDecorate(this, null, _dispatchCollapseEvent_decorators, { kind: "method", name: "dispatchCollapseEvent", static: false, private: false, access: { has: obj => "dispatchCollapseEvent" in obj, get: obj => obj.dispatchCollapseEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
79
113
  __esDecorate(this, null, _dispatchSelectEvent_decorators, { kind: "method", name: "dispatchSelectEvent", static: false, private: false, access: { has: obj => "dispatchSelectEvent" in obj, get: obj => obj.dispatchSelectEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
80
114
  __esDecorate(this, null, _dispatchCheckEvent_decorators, { kind: "method", name: "dispatchCheckEvent", static: false, private: false, access: { has: obj => "dispatchCheckEvent" in obj, get: obj => obj.dispatchCheckEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
81
115
  __esDecorate(this, null, _dispatchLazyLoadEvent_decorators, { kind: "method", name: "dispatchLazyLoadEvent", static: false, private: false, access: { has: obj => "dispatchLazyLoadEvent" in obj, get: obj => obj.dispatchLazyLoadEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
82
- __esDecorate(this, null, _render_decorators, { kind: "method", name: "render", static: false, private: false, access: { has: obj => "render" in obj, get: obj => obj.render }, metadata: _metadata }, null, _instanceExtraInitializers);
83
- __esDecorate(this, null, _styles_decorators, { kind: "method", name: "styles", static: false, private: false, access: { has: obj => "styles" in obj, get: obj => obj.styles }, metadata: _metadata }, null, _instanceExtraInitializers);
116
+ __esDecorate(this, null, _handleKeyDown_decorators, { kind: "method", name: "handleKeyDown", static: false, private: false, access: { has: obj => "handleKeyDown" in obj, get: obj => obj.handleKeyDown }, metadata: _metadata }, null, _instanceExtraInitializers);
117
+ __esDecorate(this, null, _handleFocusIn_decorators, { kind: "method", name: "handleFocusIn", static: false, private: false, access: { has: obj => "handleFocusIn" in obj, get: obj => obj.handleFocusIn }, metadata: _metadata }, null, _instanceExtraInitializers);
118
+ __esDecorate(this, null, _handleFocusOut_decorators, { kind: "method", name: "handleFocusOut", static: false, private: false, access: { has: obj => "handleFocusOut" in obj, get: obj => obj.handleFocusOut }, metadata: _metadata }, null, _instanceExtraInitializers);
119
+ __esDecorate(null, null, _selectable_decorators, { kind: "field", name: "selectable", static: false, private: false, access: { has: obj => "selectable" in obj, get: obj => obj.selectable, set: (obj, value) => { obj.selectable = value; } }, metadata: _metadata }, _selectable_initializers, _selectable_extraInitializers);
84
120
  __esDecorate(null, null, _selectionMode_decorators, { kind: "field", name: "selectionMode", static: false, private: false, access: { has: obj => "selectionMode" in obj, get: obj => obj.selectionMode, set: (obj, value) => { obj.selectionMode = value; } }, metadata: _metadata }, _selectionMode_initializers, _selectionMode_extraInitializers);
85
121
  __esDecorate(null, null, _showCheckboxes_decorators, { kind: "field", name: "showCheckboxes", static: false, private: false, access: { has: obj => "showCheckboxes" in obj, get: obj => obj.showCheckboxes, set: (obj, value) => { obj.showCheckboxes = value; } }, metadata: _metadata }, _showCheckboxes_initializers, _showCheckboxes_extraInitializers);
86
122
  __esDecorate(null, null, _showIcons_decorators, { kind: "field", name: "showIcons", static: false, private: false, access: { has: obj => "showIcons" in obj, get: obj => obj.showIcons, set: (obj, value) => { obj.showIcons = value; } }, metadata: _metadata }, _showIcons_initializers, _showIcons_extraInitializers);
@@ -94,20 +130,98 @@ let SniceTree = (() => {
94
130
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
95
131
  __runInitializers(_classThis, _classExtraInitializers);
96
132
  }
133
+ // NOTE: We don't use @render() here because it causes full re-renders
134
+ // which destroys the tree structure when properties change. Instead, we
135
+ // manually create the initial DOM and update it as needed.
97
136
  init() {
98
137
  this.buildNodeMap();
99
138
  this.syncNodeStates();
100
- // Listen for tree item events
101
- this.addEventListener('tree-item-toggle', this.handleItemToggle.bind(this));
102
- this.addEventListener('tree-item-select', this.handleItemSelect.bind(this));
103
- this.addEventListener('tree-item-check', this.handleItemCheck.bind(this));
104
- this.addEventListener('tree-item-lazy-load', this.handleLazyLoad.bind(this));
139
+ // Create initial DOM structure
140
+ this.renderTemplate();
141
+ // Set ARIA attributes
142
+ this.setAttribute('role', 'tree');
143
+ this.setAttribute('tabindex', '0');
144
+ if (this.selectionMode === 'multiple') {
145
+ this.setAttribute('aria-multiselectable', 'true');
146
+ }
105
147
  // Set node data on tree items
106
148
  this.updateTreeItems();
107
149
  }
150
+ renderTemplate() {
151
+ if (!this.shadowRoot) {
152
+ this.attachShadow({ mode: 'open' });
153
+ }
154
+ this.shadowRoot.innerHTML = `
155
+ <style>${cssContent}</style>
156
+ <div class="tree" part="container" role="tree">
157
+ <div class="tree__content" part="content"></div>
158
+ </div>
159
+ `;
160
+ }
108
161
  handleNodesChange() {
109
162
  this.buildNodeMap();
110
163
  this.syncNodeStates();
164
+ // Track which nodes are currently loading before clearing DOM
165
+ this.trackLoadingNodes();
166
+ this.updateTreeItemsDOM();
167
+ // Restore loading state and finish any completed loads
168
+ requestAnimationFrame(() => {
169
+ this.restoreLoadingState();
170
+ requestAnimationFrame(() => {
171
+ this.finishLoadingNodes();
172
+ });
173
+ });
174
+ }
175
+ trackLoadingNodes() {
176
+ const checkItem = (item) => {
177
+ if (!item || !item.node)
178
+ return;
179
+ if (item.loading) {
180
+ this.loadingNodeIds.add(item.node.id);
181
+ }
182
+ if (item.shadowRoot) {
183
+ const childItems = item.shadowRoot.querySelectorAll('.tree-item__children > snice-tree-item');
184
+ childItems.forEach((child) => checkItem(child));
185
+ }
186
+ };
187
+ const rootItems = this.shadowRoot?.querySelectorAll('.tree__content > snice-tree-item');
188
+ rootItems?.forEach((item) => checkItem(item));
189
+ }
190
+ restoreLoadingState() {
191
+ const restoreItem = (item) => {
192
+ if (!item || !item.node)
193
+ return;
194
+ // Restore loading state if this node was loading
195
+ if (this.loadingNodeIds.has(item.node.id)) {
196
+ item.loading = true;
197
+ }
198
+ // Recursively restore children
199
+ if (item.shadowRoot) {
200
+ const childItems = item.shadowRoot.querySelectorAll('.tree-item__children > snice-tree-item');
201
+ childItems.forEach((child) => restoreItem(child));
202
+ }
203
+ };
204
+ const rootItems = this.shadowRoot?.querySelectorAll('.tree__content > snice-tree-item');
205
+ rootItems?.forEach((item) => restoreItem(item));
206
+ }
207
+ updateTreeItemsDOM() {
208
+ if (!this.shadowRoot)
209
+ return;
210
+ const content = this.shadowRoot.querySelector('.tree__content');
211
+ if (!content)
212
+ return;
213
+ // Clear existing items
214
+ content.innerHTML = '';
215
+ // Create tree items for root nodes
216
+ this.nodes.forEach(node => {
217
+ const item = document.createElement('snice-tree-item');
218
+ if (this.showCheckboxes)
219
+ item.setAttribute('show-checkbox', '');
220
+ if (this.showIcons)
221
+ item.setAttribute('show-icon', '');
222
+ content.appendChild(item);
223
+ });
224
+ // Update items with node data
111
225
  this.updateTreeItems();
112
226
  }
113
227
  updateTreeItems() {
@@ -135,9 +249,17 @@ let SniceTree = (() => {
135
249
  }
136
250
  handleSelectedNodesChange() {
137
251
  this.syncNodeStates();
252
+ // Update tree item selected states
253
+ requestAnimationFrame(() => {
254
+ this.updateSelectedStatesOnly();
255
+ });
138
256
  }
139
257
  handleCheckedNodesChange() {
140
258
  this.syncNodeStates();
259
+ // Update tree item checkbox states
260
+ requestAnimationFrame(() => {
261
+ this.updateCheckboxStatesOnly();
262
+ });
141
263
  }
142
264
  buildNodeMap() {
143
265
  this.nodeMap.clear();
@@ -178,41 +300,201 @@ let SniceTree = (() => {
178
300
  const node = this.nodeMap.get(nodeId);
179
301
  if (!node)
180
302
  return;
181
- if (this.selectionMode === 'none')
303
+ // Check if selection is disabled
304
+ if (!this.selectable || this.selectionMode === 'none')
182
305
  return;
183
306
  if (this.selectionMode === 'single') {
184
- // Deselect all other nodes
185
- this.selectedNodes = selected ? [nodeId] : [];
307
+ // Deselect all nodes first
308
+ this.deselectAllNodes();
309
+ // Select only the clicked node if selecting
310
+ if (selected) {
311
+ node.selected = true;
312
+ this.selectedNodes = [nodeId];
313
+ }
314
+ else {
315
+ node.selected = false;
316
+ this.selectedNodes = [];
317
+ }
318
+ // Update DOM to reflect changes
319
+ this.updateSelectedStatesOnly();
186
320
  }
187
321
  else {
188
322
  // Multiple selection
189
323
  if (selected) {
324
+ node.selected = true;
190
325
  if (!this.selectedNodes.includes(nodeId)) {
191
326
  this.selectedNodes = [...this.selectedNodes, nodeId];
192
327
  }
193
328
  }
194
329
  else {
330
+ node.selected = false;
195
331
  this.selectedNodes = this.selectedNodes.filter(id => id !== nodeId);
196
332
  }
333
+ // Update DOM
334
+ this.updateSelectedStatesOnly();
197
335
  }
198
336
  this.dispatchSelectEvent(nodeId, node);
199
337
  }
338
+ deselectAllNodes() {
339
+ // Recursively deselect all nodes
340
+ const deselect = (nodes) => {
341
+ for (const node of nodes) {
342
+ node.selected = false;
343
+ if (node.children) {
344
+ deselect(node.children);
345
+ }
346
+ }
347
+ };
348
+ deselect(this.nodes);
349
+ }
200
350
  handleItemCheck(e) {
201
351
  const event = e;
202
352
  const { nodeId, checked } = event.detail;
203
353
  const node = this.nodeMap.get(nodeId);
204
354
  if (!node)
205
355
  return;
206
- if (checked) {
207
- if (!this.checkedNodes.includes(nodeId)) {
208
- this.checkedNodes = [...this.checkedNodes, nodeId];
209
- }
210
- }
211
- else {
212
- this.checkedNodes = this.checkedNodes.filter(id => id !== nodeId);
213
- }
356
+ // Update checked state with cascading
357
+ this.syncCheckboxes(node, checked);
214
358
  this.dispatchCheckEvent(nodeId, node, checked);
215
359
  }
360
+ syncCheckboxes(changedNode, checked) {
361
+ // Update descendants
362
+ const updateDescendants = (node, isChecked) => {
363
+ node.checked = isChecked;
364
+ if (isChecked && !this.checkedNodes.includes(node.id)) {
365
+ this.checkedNodes = [...this.checkedNodes, node.id];
366
+ }
367
+ else if (!isChecked) {
368
+ this.checkedNodes = this.checkedNodes.filter(id => id !== node.id);
369
+ }
370
+ if (node.children) {
371
+ for (const child of node.children) {
372
+ if (!child.disabled) {
373
+ updateDescendants(child, isChecked);
374
+ }
375
+ }
376
+ }
377
+ };
378
+ // Update ancestors with indeterminate state
379
+ const updateAncestors = (node) => {
380
+ const parent = this.findParentNode(node.id);
381
+ if (!parent)
382
+ return;
383
+ const children = parent.children || [];
384
+ const checkedChildren = children.filter(c => c.checked && !c.disabled);
385
+ const uncheckedChildren = children.filter(c => !c.checked && !c.disabled && !c.indeterminate);
386
+ const allChecked = checkedChildren.length === children.filter(c => !c.disabled).length;
387
+ const allUnchecked = uncheckedChildren.length === children.filter(c => !c.disabled).length;
388
+ parent.checked = allChecked;
389
+ parent.indeterminate = !allChecked && !allUnchecked;
390
+ if (parent.checked && !this.checkedNodes.includes(parent.id)) {
391
+ this.checkedNodes = [...this.checkedNodes, parent.id];
392
+ }
393
+ else if (!parent.checked && !parent.indeterminate) {
394
+ this.checkedNodes = this.checkedNodes.filter(id => id !== parent.id);
395
+ }
396
+ updateAncestors(parent);
397
+ };
398
+ updateDescendants(changedNode, checked);
399
+ updateAncestors(changedNode);
400
+ // Update checkbox states without re-rendering
401
+ this.updateCheckboxStatesOnly();
402
+ }
403
+ updateCheckboxStatesOnly() {
404
+ // Recursively update all tree-item checkbox states without re-rendering
405
+ const updateItemCheckboxes = (item) => {
406
+ if (!item || !item.node)
407
+ return;
408
+ const node = this.nodeMap.get(item.node.id);
409
+ if (!node)
410
+ return;
411
+ // Update the item's properties directly
412
+ if (item.checked !== node.checked) {
413
+ item.checked = node.checked;
414
+ }
415
+ if (item.indeterminate !== node.indeterminate) {
416
+ item.indeterminate = node.indeterminate;
417
+ }
418
+ // Recursively update children
419
+ if (item.shadowRoot) {
420
+ const childItems = item.shadowRoot.querySelectorAll('.tree-item__children > snice-tree-item');
421
+ childItems.forEach((child) => updateItemCheckboxes(child));
422
+ }
423
+ };
424
+ // Start with root items
425
+ const rootItems = this.shadowRoot?.querySelectorAll('.tree__content > snice-tree-item');
426
+ rootItems?.forEach((item) => updateItemCheckboxes(item));
427
+ }
428
+ updateSelectedStatesOnly() {
429
+ // Recursively update all tree-item selected states without re-rendering
430
+ const updateItemSelection = (item) => {
431
+ if (!item || !item.node)
432
+ return;
433
+ const node = this.nodeMap.get(item.node.id);
434
+ if (!node)
435
+ return;
436
+ // Always update the item's selected property and DOM
437
+ item.selected = node.selected;
438
+ // Force update the DOM class
439
+ if (item.shadowRoot) {
440
+ const content = item.shadowRoot.querySelector('.tree-item__content');
441
+ if (content) {
442
+ if (node.selected) {
443
+ content.classList.add('tree-item__content--selected');
444
+ }
445
+ else {
446
+ content.classList.remove('tree-item__content--selected');
447
+ }
448
+ content.setAttribute('aria-selected', (node.selected ?? false).toString());
449
+ }
450
+ }
451
+ // Recursively update children
452
+ if (item.shadowRoot) {
453
+ const childItems = item.shadowRoot.querySelectorAll('.tree-item__children > snice-tree-item');
454
+ childItems.forEach((child) => updateItemSelection(child));
455
+ }
456
+ };
457
+ // Start with root items
458
+ const rootItems = this.shadowRoot?.querySelectorAll('.tree__content > snice-tree-item');
459
+ rootItems?.forEach((item) => updateItemSelection(item));
460
+ }
461
+ finishLoadingNodes() {
462
+ // Find any tree items with loading state and finish loading if they now have children
463
+ const finishItem = (item) => {
464
+ if (!item || !item.node)
465
+ return;
466
+ // If this item is loading and now has children, finish loading
467
+ if (item.loading && item.node.children && item.node.children.length > 0) {
468
+ item.finishLoading();
469
+ // Remove from loading set
470
+ this.loadingNodeIds.delete(item.node.id);
471
+ }
472
+ // Check children
473
+ if (item.shadowRoot) {
474
+ const childItems = item.shadowRoot.querySelectorAll('.tree-item__children > snice-tree-item');
475
+ childItems.forEach((child) => finishItem(child));
476
+ }
477
+ };
478
+ // Start with root items
479
+ const rootItems = this.shadowRoot?.querySelectorAll('.tree__content > snice-tree-item');
480
+ rootItems?.forEach((item) => finishItem(item));
481
+ }
482
+ findParentNode(nodeId) {
483
+ const findParent = (nodes, targetId) => {
484
+ for (const node of nodes) {
485
+ if (node.children) {
486
+ if (node.children.some(child => child.id === targetId)) {
487
+ return node;
488
+ }
489
+ const found = findParent(node.children, targetId);
490
+ if (found)
491
+ return found;
492
+ }
493
+ }
494
+ return null;
495
+ };
496
+ return findParent(this.nodes, nodeId);
497
+ }
216
498
  handleLazyLoad(e) {
217
499
  const event = e;
218
500
  const { nodeId, node } = event.detail;
@@ -233,25 +515,100 @@ let SniceTree = (() => {
233
515
  dispatchLazyLoadEvent(nodeId, node) {
234
516
  return { nodeId, node, tree: this };
235
517
  }
236
- render() {
237
- const treeClasses = [
238
- 'tree'
239
- ].filter(Boolean).join(' ');
240
- return html /*html*/ `
241
- <div class="${treeClasses}" part="container" role="tree">
242
- <div class="tree__content" part="content">
243
- ${this.nodes.map(node => html `
244
- <snice-tree-item
245
- ?show-checkbox=${this.showCheckboxes}
246
- ?show-icon=${this.showIcons}>
247
- </snice-tree-item>
248
- `)}
249
- </div>
250
- </div>
251
- `;
518
+ // Keyboard navigation
519
+ handleKeyDown(event) {
520
+ if (!['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft', 'Home', 'End', 'Enter', ' '].includes(event.key)) {
521
+ return;
522
+ }
523
+ // Ignore when focus is in a text field
524
+ const target = event.target;
525
+ if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
526
+ return;
527
+ }
528
+ const items = this.getFocusableItems();
529
+ if (items.length === 0)
530
+ return;
531
+ event.preventDefault();
532
+ const activeIndex = items.findIndex(item => item.matches(':focus'));
533
+ const activeItem = items[activeIndex];
534
+ const focusItemAt = (index) => {
535
+ const clampedIndex = Math.max(0, Math.min(index, items.length - 1));
536
+ items[clampedIndex]?.focus();
537
+ };
538
+ if (event.key === 'ArrowDown') {
539
+ focusItemAt(activeIndex + 1);
540
+ }
541
+ else if (event.key === 'ArrowUp') {
542
+ focusItemAt(activeIndex - 1);
543
+ }
544
+ else if (event.key === 'ArrowRight') {
545
+ if (activeItem && activeItem.expand) {
546
+ activeItem.expand();
547
+ }
548
+ }
549
+ else if (event.key === 'ArrowLeft') {
550
+ if (activeItem && activeItem.collapse) {
551
+ activeItem.collapse();
552
+ }
553
+ }
554
+ else if (event.key === 'Home') {
555
+ focusItemAt(0);
556
+ }
557
+ else if (event.key === 'End') {
558
+ focusItemAt(items.length - 1);
559
+ }
560
+ else if (event.key === 'Enter' || event.key === ' ') {
561
+ if (activeItem && activeItem.select) {
562
+ activeItem.select();
563
+ }
564
+ }
252
565
  }
253
- styles() {
254
- return css /*css*/ `${cssContent}`;
566
+ handleFocusIn(event) {
567
+ const target = event.target;
568
+ // If tree gets focus, move to last focused item or first item
569
+ if (target === this) {
570
+ const items = this.getFocusableItems();
571
+ const itemToFocus = this.lastFocusedItem || items[0];
572
+ itemToFocus?.focus();
573
+ return;
574
+ }
575
+ // Update roving tabindex
576
+ if (target.tagName === 'SNICE-TREE-ITEM') {
577
+ if (this.lastFocusedItem) {
578
+ this.lastFocusedItem.setAttribute('tabindex', '-1');
579
+ }
580
+ this.lastFocusedItem = target;
581
+ this.setAttribute('tabindex', '-1');
582
+ target.setAttribute('tabindex', '0');
583
+ }
584
+ }
585
+ handleFocusOut(event) {
586
+ const relatedTarget = event.relatedTarget;
587
+ if (!relatedTarget || !this.contains(relatedTarget)) {
588
+ this.setAttribute('tabindex', '0');
589
+ }
590
+ }
591
+ getFocusableItems() {
592
+ const allItems = Array.from(this.shadowRoot?.querySelectorAll('snice-tree-item') || []);
593
+ const collapsedItems = new Set();
594
+ return allItems.filter(item => {
595
+ const disabled = item.node?.disabled;
596
+ if (disabled)
597
+ return false;
598
+ // Check if parent is collapsed
599
+ let parent = item.parentElement;
600
+ while (parent && parent !== this) {
601
+ if (parent.tagName === 'SNICE-TREE-ITEM') {
602
+ const parentExpanded = parent.expanded;
603
+ if (!parentExpanded) {
604
+ collapsedItems.add(item);
605
+ return false;
606
+ }
607
+ }
608
+ parent = parent.parentElement;
609
+ }
610
+ return !collapsedItems.has(item);
611
+ });
255
612
  }
256
613
  // Public API
257
614
  expandNode(id) {
@@ -306,7 +663,7 @@ let SniceTree = (() => {
306
663
  this.nodes = [...this.nodes];
307
664
  }
308
665
  selectNode(id) {
309
- if (this.selectionMode === 'none')
666
+ if (!this.selectable || this.selectionMode === 'none')
310
667
  return;
311
668
  const node = this.nodeMap.get(id);
312
669
  if (!node)
@@ -369,18 +726,27 @@ let SniceTree = (() => {
369
726
  getCheckedNodes() {
370
727
  return this.checkedNodes.map(id => this.nodeMap.get(id)).filter(Boolean);
371
728
  }
372
- constructor() {
373
- super(...arguments);
374
- this.selectionMode = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _selectionMode_initializers, 'single'));
375
- this.showCheckboxes = (__runInitializers(this, _selectionMode_extraInitializers), __runInitializers(this, _showCheckboxes_initializers, false));
376
- this.showIcons = (__runInitializers(this, _showCheckboxes_extraInitializers), __runInitializers(this, _showIcons_initializers, true));
377
- this.expandOnClick = (__runInitializers(this, _showIcons_extraInitializers), __runInitializers(this, _expandOnClick_initializers, false));
378
- this.nodes = (__runInitializers(this, _expandOnClick_extraInitializers), __runInitializers(this, _nodes_initializers, []));
379
- this.selectedNodes = (__runInitializers(this, _nodes_extraInitializers), __runInitializers(this, _selectedNodes_initializers, []));
380
- this.checkedNodes = (__runInitializers(this, _selectedNodes_extraInitializers), __runInitializers(this, _checkedNodes_initializers, []));
381
- this.nodeMap = (__runInitializers(this, _checkedNodes_extraInitializers), new Map());
382
- this.treeItems = __runInitializers(this, _treeItems_initializers, void 0);
383
- __runInitializers(this, _treeItems_extraInitializers);
729
+ updateNode(id, updates) {
730
+ // Create a new nodes array with the updated node
731
+ const updateInTree = (nodes) => {
732
+ return nodes.map(node => {
733
+ if (node.id === id) {
734
+ // Found the node - create a new node with updates
735
+ return { ...node, ...updates };
736
+ }
737
+ if (node.children) {
738
+ // Recursively update children
739
+ const newChildren = updateInTree(node.children);
740
+ if (newChildren !== node.children) {
741
+ // Children were updated, create new node
742
+ return { ...node, children: newChildren };
743
+ }
744
+ }
745
+ return node;
746
+ });
747
+ };
748
+ // Update and trigger re-render
749
+ this.nodes = updateInTree(this.nodes);
384
750
  }
385
751
  });
386
752
  return _classThis;