fds-vue-core 1.0.2 → 1.2.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.
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # FDS Vue Core
2
2
 
3
- A Vue 3 component library with FDS Core integration, built with TypeScript for excellent developer experience.
4
-
5
3
  ## Installation
6
4
 
7
5
  ```bash
@@ -16,177 +14,18 @@ Make sure you have the required peer dependencies installed:
16
14
  npm install vue@^3.5.0 fds-core@^3.8.0
17
15
  ```
18
16
 
19
- ## Styling
20
-
21
- This library is **style-free** and designed to work with your existing CSS framework. The components use standard HTML classes that you can style with:
22
-
23
- - **Tailwind CSS** (recommended)
24
- - **CSS Modules**
25
- - **Styled Components**
26
- - **Any CSS framework**
27
-
28
- The components will inherit your project's styling automatically.
29
-
30
- ## Usage
17
+ ## Consume
31
18
 
32
- ### Global Registration
33
-
34
- ```typescript
35
- import { createApp } from 'vue'
19
+ ```js
36
20
  import FdsVueCore from 'fds-vue-core'
37
-
38
- const app = createApp(App)
39
- app.use(FdsVueCore)
40
- app.mount('#app')
41
- ```
42
-
43
- ### Individual Component Import
44
-
45
- ```typescript
46
- import { FdsTreeView } from 'fds-vue-core'
47
- import 'fds-vue-core/style.css'
48
- ```
49
-
50
- ## Components
51
-
52
- ### FdsTreeView
53
-
54
- A hierarchical tree view component with full TypeScript support.
55
-
56
- #### Basic Usage
57
-
58
- ```vue
59
- <template>
60
- <FdsTreeView
61
- :nodes="treeData"
62
- :nodeId="'root'"
63
- :nodeExpandIcon="'arrowDown'"
64
- :nodeCollapseIcon="'arrowUp'"
65
- :indentation="20"
66
- :showNodeDescription="true"
67
- :showChildrenCount="true"
68
- :showIndeterminate="true"
69
- />
70
- </template>
71
-
72
- <script setup lang="ts">
73
- import { FdsTreeView, type TreeNode } from 'fds-vue-core'
74
-
75
- const treeData: TreeNode[] = [
76
- {
77
- nodeId: 'root-1',
78
- title: 'Documents',
79
- children: [
80
- {
81
- nodeId: 'doc-1',
82
- title: 'Work',
83
- children: [
84
- {
85
- nodeId: 'work-1',
86
- title: 'Projects',
87
- data: { type: 'folder', count: 5 }
88
- }
89
- ]
90
- }
91
- ]
92
- }
93
- ]
94
- </script>
95
- ```
96
-
97
- #### TypeScript Support
98
-
99
- The library provides full TypeScript support with comprehensive type definitions:
100
-
101
- ```typescript
102
- import type {
103
- TreeNode,
104
- TreeNodeArray,
105
- TreeNodeItem,
106
- TreeViewProps,
107
- NodeId,
108
- TreeViewEvents,
109
- ComponentSize,
110
- ComponentVariant
111
- } from 'fds-vue-core'
112
-
113
- // Typed tree data
114
- interface ProjectData {
115
- type: 'project'
116
- status: 'active' | 'completed' | 'planning'
117
- priority: number
118
- }
119
-
120
- const typedTreeData: TreeNode<ProjectData>[] = [
121
- {
122
- nodeId: 'proj-1',
123
- title: 'My Project',
124
- data: {
125
- type: 'project',
126
- status: 'active',
127
- priority: 1
128
- }
129
- }
130
- ]
131
21
  ```
132
22
 
133
- #### Props
134
-
135
- | Prop | Type | Default | Description |
136
- |------|------|---------|-------------|
137
- | `nodes` | `TreeNode[]` | `[]` | Array of tree nodes |
138
- | `nodeId` | `string` | - | Unique identifier for the current node |
139
- | `nodeExpandIcon` | `string` | - | Icon name for expanded state |
140
- | `nodeCollapseIcon` | `string` | - | Icon name for collapsed state |
141
- | `indentation` | `number` | - | Indentation level in pixels |
142
- | `showNodeDescription` | `boolean` | `false` | Show node descriptions |
143
- | `showChildrenCount` | `boolean` | `false` | Show children count |
144
- | `showIndeterminate` | `boolean` | `false` | Show indeterminate state for partial selections |
145
-
146
- #### Events
147
-
148
- | Event | Payload | Description |
149
- |-------|---------|-------------|
150
- | `node-select` | `TreeNode` | Fired when a node is selected |
151
- | `node-expand` | `TreeNode` | Fired when a node is expanded |
152
- | `node-collapse` | `TreeNode` | Fired when a node is collapsed |
153
- | `selection-change` | `TreeNode[]` | Fired when selection changes |
154
-
155
- ## Development
156
-
157
- ```bash
158
- # Install dependencies
159
- npm install
160
-
161
- # Start development server
162
- npm run dev
163
-
164
- # Build library
165
- npm run build
166
-
167
- # Type checking
168
- npm run type-check
169
-
170
- # Linting
171
- npm run lint
23
+ ```js
24
+ .use(FdsVueCore)
172
25
  ```
173
26
 
174
- ## Building for Production
27
+ ## How to use
175
28
 
176
- ```bash
177
- npm run build
29
+ ```js
30
+ <FdsTreeView />
178
31
  ```
179
-
180
- This will generate:
181
- - `dist/fds-vue-core.es.js` - ES module build
182
- - `dist/fds-vue-core.cjs.js` - CommonJS build
183
- - `dist/index.d.ts` - TypeScript declarations
184
- - `dist/style.css` - Styles
185
-
186
- ## TypeScript
187
-
188
- This library is built with TypeScript and provides comprehensive type definitions. All components, props, events, and utilities are fully typed for excellent developer experience.
189
-
190
- ## License
191
-
192
- MIT
@@ -1 +1 @@
1
- {"version":3,"file":"App.vue.d.ts","sourceRoot":"","sources":["../src/App.vue"],"names":[],"mappings":";AAwSA,wBACG"}
1
+ {"version":3,"file":"App.vue.d.ts","sourceRoot":"","sources":["../src/App.vue"],"names":[],"mappings":";AAiTA,wBACG"}
@@ -1,14 +1,19 @@
1
- import type { TreeNode } from './types';
2
- import type { FdsTreeViewProps } from '../../types';
3
- type Props<T = Record<string, unknown>> = FdsTreeViewProps<T>;
1
+ import type { TreeViewProps } from './types.ts';
2
+ type Props<T = Record<string, unknown>> = TreeViewProps<T>;
4
3
  type __VLS_Props = Props;
5
4
  declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
- nodes: TreeNode<Record<string, unknown>>[];
5
+ nodes: import("./types.ts").TreeNode<Record<string, unknown>>[];
7
6
  depth: number;
8
7
  showNodeDescription: boolean;
9
8
  showChildrenCount: boolean;
10
9
  expandChildrenOnSelect: boolean;
11
10
  showIndeterminate: boolean;
11
+ showIndeterminateOnlyOnChildrenSelection: boolean;
12
+ expandChildrenOnParentCheck: boolean;
13
+ expandAllChildrenOnParentCheck: boolean;
14
+ searchEnabled: boolean;
15
+ searchMatchParams: string[];
16
+ searchExpandNodes: boolean;
12
17
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
18
  export default _default;
14
19
  //# sourceMappingURL=FdsTreeView.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FdsTreeView.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fds-tree-view/FdsTreeView.vue"],"names":[],"mappings":"AA+MA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,SAAS,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,KAAK,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAA;AAE7D,KAAK,WAAW,GAAG,KAAK,CAAC;;;;;;;;;AAiXzB,wBAGG"}
1
+ {"version":3,"file":"FdsTreeView.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fds-tree-view/FdsTreeView.vue"],"names":[],"mappings":"AAqMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,KAAK,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAA;AAE1D,KAAK,WAAW,GAAG,KAAK,CAAC;;;;;;;;;;;;;;;AA8ZzB,wBAGG"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Unique identifier for tree nodes
3
+ */
4
+ export type NodeId = string;
5
+ /**
6
+ * Represents a single node in the tree structure
7
+ * @template T - The type of data associated with the node
8
+ */
9
+ export interface TreeNode<T = Record<string, unknown>> {
10
+ /** Unique identifier for the node */
11
+ nodeId: string;
12
+ /** Display title for the node */
13
+ title?: string;
14
+ /** Child nodes of this node */
15
+ children?: TreeNode<T>[];
16
+ /** Optional data object associated with the node */
17
+ data?: T;
18
+ }
19
+ /**
20
+ * Array of tree nodes
21
+ */
22
+ export type TreeNodeArray = TreeNode<Record<string, unknown>>[];
23
+ /**
24
+ * Single tree node item
25
+ */
26
+ export type TreeNodeItem = TreeNode<Record<string, unknown>>;
27
+ /**
28
+ * Props for the FdsTreeView component
29
+ * @template T - The type of data associated with tree nodes
30
+ */
31
+ export interface TreeViewProps<T = Record<string, unknown>> {
32
+ /** The tree data structure containing nodes and their children */
33
+ nodes: TreeNode<T>[];
34
+ /** The current depth level in the tree (used internally for indentation) */
35
+ depth?: number;
36
+ /** Icon name to display when a node is collapsed */
37
+ nodeExpandIcon: string;
38
+ /** Icon name to display when a node is expanded */
39
+ nodeCollapseIcon: string;
40
+ /** Number of pixels to indent each level of the tree */
41
+ indentation: number;
42
+ /** Unique identifier for the current node */
43
+ nodeId: string;
44
+ /** Optional data object associated with the node */
45
+ data?: T;
46
+ /** Display title for the node */
47
+ title?: string;
48
+ /** Whether to show the node description (nodeId) below the title */
49
+ showNodeDescription?: boolean;
50
+ /** Whether to show the count of children next to the node title */
51
+ showChildrenCount?: boolean;
52
+ /** Whether to expand children when a node is selected */
53
+ expandChildrenOnSelect?: boolean;
54
+ /** Whether to show indeterminate state for partially selected nodes */
55
+ showIndeterminate?: boolean;
56
+ /** Whether to only show indeterminate when parent is not selected but children are */
57
+ showIndeterminateOnlyOnChildrenSelection?: boolean;
58
+ /** Whether to expand children when parent is checked */
59
+ expandChildrenOnParentCheck?: boolean;
60
+ /** Whether to expand all children recursively when parent is checked */
61
+ expandAllChildrenOnParentCheck?: boolean;
62
+ /** Whether to show search functionality */
63
+ searchEnabled?: boolean;
64
+ /** Label for the search input */
65
+ searchLabel?: string;
66
+ /** Parameters to match when searching -
67
+ * Defaults to ['title', 'nodeId']
68
+ * */
69
+ searchMatchParams?: string[];
70
+ /** Whether to expand nodes when searching */
71
+ searchExpandNodes?: boolean;
72
+ }
73
+ //# sourceMappingURL=types.d.ts.map
@@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mEAAmE;IACnE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,yDAAyD;IACzD,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,uEAAuE;IACvE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,sFAAsF;IACtF,wCAAwC,CAAC,EAAE,OAAO,CAAA;IAClD,wDAAwD;IACxD,2BAA2B,CAAC,EAAE,OAAO,CAAA;IACrC,wEAAwE;IACxE,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC,2CAA2C;IAC3C,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;SAEK;IACL,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B"}
@@ -1,18 +1,35 @@
1
- import type { TreeNode, NodeId } from './types';
2
- declare const useTreeState: () => {
1
+ import type { TreeNode, NodeId, TreeNodeArray, TreeNodeItem } from './types';
2
+ interface TreeStateOptions {
3
+ expandChildrenOnParentCheck?: boolean;
4
+ expandAllChildrenOnParentCheck?: boolean;
5
+ showIndeterminateOnlyOnChildrenSelection?: boolean;
6
+ }
7
+ declare const useTreeState: (options?: TreeStateOptions) => {
3
8
  selectedNodes: import("vue").Reactive<Set<string>>;
4
9
  selectedNodeObjects: import("vue").Reactive<TreeNode<Record<string, unknown>>[]>;
5
10
  expandedNodes: import("vue").Reactive<Set<string>>;
6
- clearSelection: () => void;
7
- clearExpanded: () => void;
8
- isSelected: (nodeId: NodeId) => boolean;
9
- isExpanded: (nodeId: NodeId) => boolean;
10
- select: (nodeObject: TreeNode) => void;
11
+ searchTerm: import("vue").Ref<string, string>;
12
+ clearAllSelectedNodes: () => void;
13
+ collapseAllExpandedNodes: () => void;
14
+ isNodeSelected: (nodeId: NodeId) => boolean;
15
+ isNodeExpanded: (nodeId: NodeId) => boolean;
16
+ injectNode: (nodeObject: TreeNode) => void;
11
17
  selectAllChildren: (node: TreeNode) => void;
12
- deselect: (nodeId: NodeId) => void;
18
+ deselectNode: (nodeId: NodeId) => void;
13
19
  deselectAllChildren: (node: TreeNode) => void;
14
- expand: (nodeId: NodeId) => import("vue").Reactive<Set<string>>;
15
- collapse: (nodeId: NodeId) => boolean;
20
+ expandNode: (nodeId: NodeId) => import("vue").Reactive<Set<string>>;
21
+ collapseNode: (nodeId: NodeId) => boolean;
22
+ expandAllChildren: (node: TreeNode) => void;
23
+ findNodeById: (nodes: TreeNodeArray, nodeId: string) => TreeNodeItem | null;
24
+ hasChildrenNodes: (nodes: TreeNodeArray) => boolean;
25
+ isNodeIndeterminate: (nodes: TreeNodeArray, parentNodeId?: string) => boolean;
26
+ toggleSelectNode: (nodes: TreeNodeArray, nodeId: string, title?: string, data?: Record<string, unknown>) => void;
27
+ toggleExpandNode: (nodeId: NodeId, nodes: TreeNodeArray) => void;
28
+ getNodeIcon: (nodeId: NodeId, nodes: TreeNodeArray, expandIcon: string, collapseIcon: string) => string;
29
+ nodeMatchesSearch: (node: TreeNode, term: string, searchParams?: string[]) => boolean;
30
+ filterNodes: (nodes: TreeNodeArray, term: string, searchParams?: string[]) => TreeNodeArray;
31
+ setSearchTerm: (term: string) => void;
32
+ clearSearch: () => void;
16
33
  };
17
34
  export default useTreeState;
18
35
  //# sourceMappingURL=useTreeState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTreeState.d.ts","sourceRoot":"","sources":["../../../src/components/fds-tree-view/useTreeState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAE/C,QAAA,MAAM,YAAY;;;;;;yBAWY,MAAM;yBACN,MAAM;yBAEN,QAAQ;8BAKH,QAAQ;uBAaf,MAAM;gCAQG,QAAQ;qBAUnB,MAAM;uBACJ,MAAM;CAiBjC,CAAA;AAED,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"useTreeState.d.ts","sourceRoot":"","sources":["../../../src/components/fds-tree-view/useTreeState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE5E,UAAU,gBAAgB;IACxB,2BAA2B,CAAC,EAAE,OAAO,CAAA;IACrC,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC,wCAAwC,CAAC,EAAE,OAAO,CAAA;CACnD;AAED,QAAA,MAAM,YAAY,GAAI,UAAS,gBAAqB;;;;;;;6BAkClB,MAAM;6BAKN,MAAM;6BAgBN,QAAQ;8BAkBP,QAAQ;2BAsBX,MAAM;gCAYD,QAAQ;yBA/Df,MAAM;2BAKJ,MAAM;8BAcH,QAAQ;0BAyDZ,aAAa,UAAU,MAAM,KAAG,YAAY,GAAG,IAAI;8BAgB/C,aAAa;iCAKV,aAAa,iBAAiB,MAAM,KAAG,OAAO;8BAuCzE,aAAa,UACZ,MAAM,UACN,MAAM,SACP,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;+BAiCE,MAAM,SAAS,aAAa;0BAapD,MAAM,SACP,aAAa,cACR,MAAM,gBACJ,MAAM;8BAQW,QAAQ,QAAQ,MAAM,iBAAiB,MAAM,EAAE,KAAG,OAAO;yBAwBjF,aAAa,QACd,MAAM,iBACG,MAAM,EAAE,KACtB,aAAa;0BAwBa,MAAM;;CAsCpC,CAAA;AAED,eAAe,YAAY,CAAA"}