@pfm-platform/tags-feature 0.1.1
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/dist/index.cjs +25 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var tagsDataAccess = require('@pfm-platform/tags-data-access');
|
|
5
|
+
|
|
6
|
+
// src/hooks/useTagFilters.ts
|
|
7
|
+
function useTagFilters(userId) {
|
|
8
|
+
const { data: defaultTagsData } = tagsDataAccess.useDefaultTags();
|
|
9
|
+
const { data: userTagsData } = tagsDataAccess.useUserTags({ userId });
|
|
10
|
+
return react.useMemo(() => {
|
|
11
|
+
const defaults = defaultTagsData?.defaultTags ?? [];
|
|
12
|
+
const userTags = userTagsData?.userTags ?? [];
|
|
13
|
+
const customTags = userTags.filter((tag) => !defaults.includes(tag));
|
|
14
|
+
const allTags = Array.from(/* @__PURE__ */ new Set([...defaults, ...userTags]));
|
|
15
|
+
return {
|
|
16
|
+
allTags,
|
|
17
|
+
defaultTags: defaults,
|
|
18
|
+
customTags
|
|
19
|
+
};
|
|
20
|
+
}, [defaultTagsData, userTagsData]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.useTagFilters = useTagFilters;
|
|
24
|
+
//# sourceMappingURL=index.cjs.map
|
|
25
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useTagFilters.ts"],"names":["useDefaultTags","useUserTags","useMemo"],"mappings":";;;;;;AAoBO,SAAS,cAAc,MAAA,EAA4B;AACxD,EAAA,MAAM,EAAE,IAAA,EAAM,eAAA,EAAgB,GAAIA,6BAAA,EAAe;AACjD,EAAA,MAAM,EAAE,IAAA,EAAM,YAAA,KAAiBC,0BAAA,CAAY,EAAE,QAAQ,CAAA;AAErD,EAAA,OAAOC,cAAQ,MAAM;AACnB,IAAA,MAAM,QAAA,GAAW,eAAA,EAAiB,WAAA,IAAe,EAAC;AAClD,IAAA,MAAM,QAAA,GAAW,YAAA,EAAc,QAAA,IAAY,EAAC;AAG5C,IAAA,MAAM,UAAA,GAAa,SAAS,MAAA,CAAO,CAAC,QAAQ,CAAC,QAAA,CAAS,QAAA,CAAS,GAAG,CAAC,CAAA;AAGnE,IAAA,MAAM,OAAA,GAAU,KAAA,CAAM,IAAA,iBAAK,IAAI,GAAA,CAAI,CAAC,GAAG,QAAA,EAAU,GAAG,QAAQ,CAAC,CAAC,CAAA;AAE9D,IAAA,OAAO;AAAA,MACL,OAAA;AAAA,MACA,WAAA,EAAa,QAAA;AAAA,MACb;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,eAAA,EAAiB,YAAY,CAAC,CAAA;AACpC","file":"index.cjs","sourcesContent":["import { useMemo } from 'react';\nimport { useDefaultTags, useUserTags } from '@pfm-platform/tags-data-access';\n\nexport interface TagFilters {\n allTags: string[];\n defaultTags: string[];\n customTags: string[];\n}\n\n/**\n * Filter tags into default/custom categories\n *\n * Business logic:\n * - allTags: Union of default tags and user tags (deduplicated)\n * - defaultTags: System-provided tags\n * - customTags: User-created tags (tags in userTags but NOT in defaultTags)\n *\n * @param userId - User ID to fetch tags for\n * @returns Object with allTags, defaultTags, and customTags arrays\n */\nexport function useTagFilters(userId: string): TagFilters {\n const { data: defaultTagsData } = useDefaultTags();\n const { data: userTagsData } = useUserTags({ userId });\n\n return useMemo(() => {\n const defaults = defaultTagsData?.defaultTags ?? [];\n const userTags = userTagsData?.userTags ?? [];\n\n // Custom tags are those in userTags but NOT in defaultTags\n const customTags = userTags.filter((tag) => !defaults.includes(tag));\n\n // allTags is the union (deduplicated)\n const allTags = Array.from(new Set([...defaults, ...userTags]));\n\n return {\n allTags,\n defaultTags: defaults,\n customTags,\n };\n }, [defaultTagsData, userTagsData]);\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface TagFilters {
|
|
2
|
+
allTags: string[];
|
|
3
|
+
defaultTags: string[];
|
|
4
|
+
customTags: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Filter tags into default/custom categories
|
|
8
|
+
*
|
|
9
|
+
* Business logic:
|
|
10
|
+
* - allTags: Union of default tags and user tags (deduplicated)
|
|
11
|
+
* - defaultTags: System-provided tags
|
|
12
|
+
* - customTags: User-created tags (tags in userTags but NOT in defaultTags)
|
|
13
|
+
*
|
|
14
|
+
* @param userId - User ID to fetch tags for
|
|
15
|
+
* @returns Object with allTags, defaultTags, and customTags arrays
|
|
16
|
+
*/
|
|
17
|
+
declare function useTagFilters(userId: string): TagFilters;
|
|
18
|
+
|
|
19
|
+
export { type TagFilters, useTagFilters };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface TagFilters {
|
|
2
|
+
allTags: string[];
|
|
3
|
+
defaultTags: string[];
|
|
4
|
+
customTags: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Filter tags into default/custom categories
|
|
8
|
+
*
|
|
9
|
+
* Business logic:
|
|
10
|
+
* - allTags: Union of default tags and user tags (deduplicated)
|
|
11
|
+
* - defaultTags: System-provided tags
|
|
12
|
+
* - customTags: User-created tags (tags in userTags but NOT in defaultTags)
|
|
13
|
+
*
|
|
14
|
+
* @param userId - User ID to fetch tags for
|
|
15
|
+
* @returns Object with allTags, defaultTags, and customTags arrays
|
|
16
|
+
*/
|
|
17
|
+
declare function useTagFilters(userId: string): TagFilters;
|
|
18
|
+
|
|
19
|
+
export { type TagFilters, useTagFilters };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useDefaultTags, useUserTags } from '@pfm-platform/tags-data-access';
|
|
3
|
+
|
|
4
|
+
// src/hooks/useTagFilters.ts
|
|
5
|
+
function useTagFilters(userId) {
|
|
6
|
+
const { data: defaultTagsData } = useDefaultTags();
|
|
7
|
+
const { data: userTagsData } = useUserTags({ userId });
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
const defaults = defaultTagsData?.defaultTags ?? [];
|
|
10
|
+
const userTags = userTagsData?.userTags ?? [];
|
|
11
|
+
const customTags = userTags.filter((tag) => !defaults.includes(tag));
|
|
12
|
+
const allTags = Array.from(/* @__PURE__ */ new Set([...defaults, ...userTags]));
|
|
13
|
+
return {
|
|
14
|
+
allTags,
|
|
15
|
+
defaultTags: defaults,
|
|
16
|
+
customTags
|
|
17
|
+
};
|
|
18
|
+
}, [defaultTagsData, userTagsData]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { useTagFilters };
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useTagFilters.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,cAAc,MAAA,EAA4B;AACxD,EAAA,MAAM,EAAE,IAAA,EAAM,eAAA,EAAgB,GAAI,cAAA,EAAe;AACjD,EAAA,MAAM,EAAE,IAAA,EAAM,YAAA,KAAiB,WAAA,CAAY,EAAE,QAAQ,CAAA;AAErD,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAA,MAAM,QAAA,GAAW,eAAA,EAAiB,WAAA,IAAe,EAAC;AAClD,IAAA,MAAM,QAAA,GAAW,YAAA,EAAc,QAAA,IAAY,EAAC;AAG5C,IAAA,MAAM,UAAA,GAAa,SAAS,MAAA,CAAO,CAAC,QAAQ,CAAC,QAAA,CAAS,QAAA,CAAS,GAAG,CAAC,CAAA;AAGnE,IAAA,MAAM,OAAA,GAAU,KAAA,CAAM,IAAA,iBAAK,IAAI,GAAA,CAAI,CAAC,GAAG,QAAA,EAAU,GAAG,QAAQ,CAAC,CAAC,CAAA;AAE9D,IAAA,OAAO;AAAA,MACL,OAAA;AAAA,MACA,WAAA,EAAa,QAAA;AAAA,MACb;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,eAAA,EAAiB,YAAY,CAAC,CAAA;AACpC","file":"index.js","sourcesContent":["import { useMemo } from 'react';\nimport { useDefaultTags, useUserTags } from '@pfm-platform/tags-data-access';\n\nexport interface TagFilters {\n allTags: string[];\n defaultTags: string[];\n customTags: string[];\n}\n\n/**\n * Filter tags into default/custom categories\n *\n * Business logic:\n * - allTags: Union of default tags and user tags (deduplicated)\n * - defaultTags: System-provided tags\n * - customTags: User-created tags (tags in userTags but NOT in defaultTags)\n *\n * @param userId - User ID to fetch tags for\n * @returns Object with allTags, defaultTags, and customTags arrays\n */\nexport function useTagFilters(userId: string): TagFilters {\n const { data: defaultTagsData } = useDefaultTags();\n const { data: userTagsData } = useUserTags({ userId });\n\n return useMemo(() => {\n const defaults = defaultTagsData?.defaultTags ?? [];\n const userTags = userTagsData?.userTags ?? [];\n\n // Custom tags are those in userTags but NOT in defaultTags\n const customTags = userTags.filter((tag) => !defaults.includes(tag));\n\n // allTags is the union (deduplicated)\n const allTags = Array.from(new Set([...defaults, ...userTags]));\n\n return {\n allTags,\n defaultTags: defaults,\n customTags,\n };\n }, [defaultTagsData, userTagsData]);\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pfm-platform/tags-feature",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"react": "19.2.0",
|
|
8
|
+
"@pfm-platform/shared": "0.0.1",
|
|
9
|
+
"@pfm-platform/tags-data-access": "0.1.1"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@tanstack/react-query": "5.90.9",
|
|
13
|
+
"@testing-library/react": "^16.3.0",
|
|
14
|
+
"@types/react": "^19.2.5",
|
|
15
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
16
|
+
"@vitest/coverage-v8": "^4.0.9",
|
|
17
|
+
"jsdom": "^27.2.0",
|
|
18
|
+
"react-dom": "19.2.0",
|
|
19
|
+
"typescript": "5.9.3",
|
|
20
|
+
"vitest": "4.0.9"
|
|
21
|
+
},
|
|
22
|
+
"module": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"description": "Personal Finance Management - TAGS feature layer",
|
|
36
|
+
"keywords": [
|
|
37
|
+
"pfm",
|
|
38
|
+
"finance",
|
|
39
|
+
"tags",
|
|
40
|
+
"feature",
|
|
41
|
+
"react",
|
|
42
|
+
"typescript"
|
|
43
|
+
],
|
|
44
|
+
"author": "Lenny Miller",
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/lennylmiller/pfm-research",
|
|
49
|
+
"directory": "packages/tags/feature"
|
|
50
|
+
},
|
|
51
|
+
"bugs": "https://github.com/lennylmiller/pfm-research/issues",
|
|
52
|
+
"homepage": "https://github.com/lennylmiller/pfm-research#readme",
|
|
53
|
+
"scripts": {
|
|
54
|
+
"test": "vitest run",
|
|
55
|
+
"test:watch": "vitest",
|
|
56
|
+
"test:ui": "vitest --ui",
|
|
57
|
+
"test:coverage": "vitest run --coverage",
|
|
58
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean"
|
|
59
|
+
}
|
|
60
|
+
}
|