@burdenoff/microfe-cosmicintersection 2026.1101.1 → 2026.1101.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/dist/cosmicintersection/api/tagsApi.d.ts +100 -0
- package/dist/cosmicintersection/api/tagsApi.d.ts.map +1 -0
- package/dist/cosmicintersection/api/tagsApi.js +110 -0
- package/dist/cosmicintersection/api/tagsApi.js.map +1 -0
- package/dist/cosmicintersection/components/EntityTagsField.d.ts +5 -5
- package/dist/cosmicintersection/components/EntityTagsField.js.map +1 -1
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.d.ts +27 -0
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.d.ts.map +1 -0
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.js +141 -0
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.js.map +1 -0
- package/dist/cosmicintersection/components/index.d.ts +1 -0
- package/dist/cosmicintersection/components/index.d.ts.map +1 -1
- package/dist/cosmicintersection/components/index.js +6 -5
- package/dist/cosmicintersection/hooks/useEntityTagSync.d.ts +49 -0
- package/dist/cosmicintersection/hooks/useEntityTagSync.d.ts.map +1 -0
- package/dist/cosmicintersection/hooks/useEntityTagSync.js +86 -0
- package/dist/cosmicintersection/hooks/useEntityTagSync.js.map +1 -0
- package/dist/cosmicintersection/pages/collections/CollectionFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/collections/CollectionFormPage.js +75 -74
- package/dist/cosmicintersection/pages/collections/CollectionFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.js +115 -106
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.js.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetFormPage.js +103 -101
- package/dist/cosmicintersection/pages/datasets/DatasetFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebookFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebookFormPage.js +141 -139
- package/dist/cosmicintersection/pages/notebooks/NotebookFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.js +213 -211
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/sources/SourceFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/sources/SourceFormPage.js +110 -107
- package/dist/cosmicintersection/pages/sources/SourceFormPage.js.map +1 -1
- package/dist/stories/WorkspaceTagsPicker.stories.d.ts +12 -0
- package/dist/stories/WorkspaceTagsPicker.stories.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client/react';
|
|
2
|
+
/** Entity types the CosmicIntersection subgraph registers with wspace-tags-svc. */
|
|
3
|
+
export type CosTagEntityType = 'COSMICINTERSECTION_DATASET' | 'COSMICINTERSECTION_SOURCE' | 'COSMICINTERSECTION_NOTEBOOK' | 'COSMICINTERSECTION_COLLECTION' | 'COSMICINTERSECTION_PIPELINE' | 'COSMICINTERSECTION_RELEASE';
|
|
4
|
+
/** An assignable workspace tag (`CosAvailableTag`). */
|
|
5
|
+
export interface CosWorkspaceTag {
|
|
6
|
+
id: string;
|
|
7
|
+
key: string;
|
|
8
|
+
label: string;
|
|
9
|
+
color?: string | null;
|
|
10
|
+
}
|
|
11
|
+
/** Upper bound on the workspace tags the picker loads for suggestions. */
|
|
12
|
+
export declare const WORKSPACE_TAG_LIMIT = 200;
|
|
13
|
+
export declare const AVAILABLE_COS_TAGS: import('graphql').DocumentNode;
|
|
14
|
+
export declare const CREATE_COS_TAG: import('graphql').DocumentNode;
|
|
15
|
+
export declare const REPLACE_COS_ENTITY_TAGS: import('graphql').DocumentNode;
|
|
16
|
+
export declare const SEARCH_COS_TAGS: import('graphql').DocumentNode;
|
|
17
|
+
export declare const COS_ENTITY_TAGS: import('graphql').DocumentNode;
|
|
18
|
+
export interface AvailableCosTagsData {
|
|
19
|
+
availableCosTags: CosWorkspaceTag[];
|
|
20
|
+
}
|
|
21
|
+
export interface CreateCosTagData {
|
|
22
|
+
createCosTag: CosWorkspaceTag;
|
|
23
|
+
}
|
|
24
|
+
export interface SearchCosTagsData {
|
|
25
|
+
searchCosTags: CosWorkspaceTag[];
|
|
26
|
+
}
|
|
27
|
+
export interface CosEntityTagsData {
|
|
28
|
+
cosEntityTags: Array<CosEntityTagAssignment & {
|
|
29
|
+
id: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
export interface ReplaceCosEntityTagsData {
|
|
33
|
+
replaceCosEntityTags: Array<{
|
|
34
|
+
id: string;
|
|
35
|
+
tagId: string;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Workspace tags for the picker's suggestions. `cache-and-network` so a tag
|
|
40
|
+
* created from another form shows up the next time a picker mounts, while the
|
|
41
|
+
* cached list renders instantly. A failure (tags-svc down, no permission) is
|
|
42
|
+
* reported through `error` and the picker falls back to free-text entry.
|
|
43
|
+
*/
|
|
44
|
+
export declare function useWorkspaceTags(skip?: boolean): useQuery.Result<AvailableCosTagsData, {
|
|
45
|
+
limit: number;
|
|
46
|
+
}, "empty" | "complete" | "streaming", {
|
|
47
|
+
limit: number;
|
|
48
|
+
}, undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Longest label the picker input accepts; a cheap guard against oversized new
|
|
51
|
+
* values. It is enforced on the input only: labels loaded from an entity keep
|
|
52
|
+
* their full text, since the earlier free-text field accepted any length.
|
|
53
|
+
*/
|
|
54
|
+
export declare const MAX_TAG_LABEL_LENGTH = 64;
|
|
55
|
+
/** Display form of a label: trimmed, inner whitespace collapsed. */
|
|
56
|
+
export declare function cleanTagLabel(label: string): string;
|
|
57
|
+
/** Case- and whitespace-insensitive identity for a tag label. */
|
|
58
|
+
export declare function normalizeTagLabel(label: string): string;
|
|
59
|
+
/** Unique, cleaned labels in first-seen order (duplicates by {@link normalizeTagLabel} collapse). */
|
|
60
|
+
export declare function uniqueTagLabels(labels: readonly string[]): string[];
|
|
61
|
+
export interface EntityTagLabelDiff {
|
|
62
|
+
/** Labels the user added since the entity was loaded. */
|
|
63
|
+
added: string[];
|
|
64
|
+
/** Labels the user removed since the entity was loaded. */
|
|
65
|
+
removed: string[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* What changed between the labels an entity was loaded with and the labels the
|
|
69
|
+
* form now holds. Only these labels touch the entity's workspace assignments,
|
|
70
|
+
* so a tag assigned from another surface (the shell `/tags` route, the API)
|
|
71
|
+
* survives every save that does not explicitly remove it.
|
|
72
|
+
*/
|
|
73
|
+
export declare function diffEntityTagLabels(previous: readonly string[], next: readonly string[]): EntityTagLabelDiff;
|
|
74
|
+
/** First workspace tag whose label matches `label` (case/whitespace-insensitive). */
|
|
75
|
+
export declare function findTagByLabel(workspaceTags: readonly CosWorkspaceTag[], label: string): CosWorkspaceTag | undefined;
|
|
76
|
+
/** A current assignment as read back from `cosEntityTags`. */
|
|
77
|
+
export interface CosEntityTagAssignment {
|
|
78
|
+
tagId: string;
|
|
79
|
+
tagInfo?: {
|
|
80
|
+
label?: string | null;
|
|
81
|
+
} | null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Labels the form holds that the entity has no assignment for yet. An
|
|
85
|
+
* assignment's label comes from its `tagInfo`, or from the workspace taxonomy
|
|
86
|
+
* when the projection is missing.
|
|
87
|
+
*/
|
|
88
|
+
export declare function labelsMissingFromAssignments(labels: readonly string[], current: readonly CosEntityTagAssignment[], workspaceTags: readonly CosWorkspaceTag[]): string[];
|
|
89
|
+
/**
|
|
90
|
+
* The full tag-id set to write after a save: the entity's current assignments,
|
|
91
|
+
* minus the ids whose label the user removed, plus the resolved ids of the
|
|
92
|
+
* labels the user added. Order is stable and ids are unique.
|
|
93
|
+
*/
|
|
94
|
+
export declare function nextEntityTagIds(current: readonly CosEntityTagAssignment[], removedLabels: readonly string[], removedTagIds: readonly string[], addedTagIds: readonly string[]): string[];
|
|
95
|
+
/**
|
|
96
|
+
* Picker suggestions: workspace tags not already selected whose label contains
|
|
97
|
+
* the typed text, alphabetically, capped at `limit`.
|
|
98
|
+
*/
|
|
99
|
+
export declare function suggestWorkspaceTags(workspaceTags: readonly CosWorkspaceTag[], selected: readonly string[], query: string, limit?: number): CosWorkspaceTag[];
|
|
100
|
+
//# sourceMappingURL=tagsApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagsApi.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/api/tagsApi.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,mFAAmF;AACnF,MAAM,MAAM,gBAAgB,GACxB,4BAA4B,GAC5B,2BAA2B,GAC3B,6BAA6B,GAC7B,+BAA+B,GAC/B,6BAA6B,GAC7B,4BAA4B,CAAC;AAEjC,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,0EAA0E;AAC1E,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,eAAO,MAAM,kBAAkB,gCAS9B,CAAC;AAEF,eAAO,MAAM,cAAc,gCAS1B,CAAC;AAEF,eAAO,MAAM,uBAAuB,gCAOnC,CAAC;AAEF,eAAO,MAAM,eAAe,gCAS3B,CAAC;AAEF,eAAO,MAAM,eAAe,gCAW3B,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,eAAe,EAAE,CAAC;CACrC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,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CAC5C;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,EAAE,SAAS,sBAAsB,EAAE,EAC1C,aAAa,EAAE,SAAS,eAAe,EAAE,GACxC,MAAM,EAAE,CAQV;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,sBAAsB,EAAE,EAC1C,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,MAAM,EAAE,CAeV;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,SAAS,eAAe,EAAE,EACzC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,KAAK,EAAE,MAAM,EACb,KAAK,SAAI,GACR,eAAe,EAAE,CAanB"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { gql as e } from "@apollo/client";
|
|
2
|
+
import { useQuery as t } from "@apollo/client/react";
|
|
3
|
+
var n = e`
|
|
4
|
+
query AvailableCosTags($limit: Int) {
|
|
5
|
+
availableCosTags(limit: $limit) {
|
|
6
|
+
id
|
|
7
|
+
key
|
|
8
|
+
label
|
|
9
|
+
color
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`, r = e`
|
|
13
|
+
mutation CreateCosTag($input: CreateCosTagInput!) {
|
|
14
|
+
createCosTag(input: $input) {
|
|
15
|
+
id
|
|
16
|
+
key
|
|
17
|
+
label
|
|
18
|
+
color
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`, i = e`
|
|
22
|
+
mutation ReplaceCosEntityTags($input: ReplaceCosEntityTagsInput!) {
|
|
23
|
+
replaceCosEntityTags(input: $input) {
|
|
24
|
+
id
|
|
25
|
+
tagId
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`, a = e`
|
|
29
|
+
query SearchCosTags($query: String!, $limit: Int) {
|
|
30
|
+
searchCosTags(query: $query, limit: $limit) {
|
|
31
|
+
id
|
|
32
|
+
key
|
|
33
|
+
label
|
|
34
|
+
color
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`, o = e`
|
|
38
|
+
query CosEntityTags($input: GetCosEntityTagsInput!) {
|
|
39
|
+
cosEntityTags(input: $input) {
|
|
40
|
+
id
|
|
41
|
+
tagId
|
|
42
|
+
tagInfo {
|
|
43
|
+
id
|
|
44
|
+
label
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
function s(e = !1) {
|
|
50
|
+
return t(n, {
|
|
51
|
+
variables: { limit: 200 },
|
|
52
|
+
fetchPolicy: "cache-and-network",
|
|
53
|
+
errorPolicy: "all",
|
|
54
|
+
skip: e
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function c(e) {
|
|
58
|
+
return e.trim().replace(/\s+/g, " ");
|
|
59
|
+
}
|
|
60
|
+
function l(e) {
|
|
61
|
+
return c(e).toLowerCase();
|
|
62
|
+
}
|
|
63
|
+
function u(e) {
|
|
64
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
65
|
+
for (let r of e) {
|
|
66
|
+
let e = l(r);
|
|
67
|
+
!e || t.has(e) || (t.add(e), n.push(c(r)));
|
|
68
|
+
}
|
|
69
|
+
return n;
|
|
70
|
+
}
|
|
71
|
+
function d(e, t) {
|
|
72
|
+
let n = u(e), r = u(t), i = new Set(n.map(l)), a = new Set(r.map(l));
|
|
73
|
+
return {
|
|
74
|
+
added: r.filter((e) => !i.has(l(e))),
|
|
75
|
+
removed: n.filter((e) => !a.has(l(e)))
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function f(e, t) {
|
|
79
|
+
let n = l(t);
|
|
80
|
+
if (n) return e.find((e) => l(e.label) === n);
|
|
81
|
+
}
|
|
82
|
+
function p(e, t, n) {
|
|
83
|
+
let r = /* @__PURE__ */ new Set();
|
|
84
|
+
for (let e of t) {
|
|
85
|
+
let t = e.tagInfo?.label ?? n.find((t) => t.id === e.tagId)?.label;
|
|
86
|
+
t && r.add(l(t));
|
|
87
|
+
}
|
|
88
|
+
return u(e).filter((e) => !r.has(l(e)));
|
|
89
|
+
}
|
|
90
|
+
function m(e, t, n, r) {
|
|
91
|
+
let i = new Set(t.map(l)), a = new Set(n), o = [], s = (e) => {
|
|
92
|
+
e && !o.includes(e) && o.push(e);
|
|
93
|
+
};
|
|
94
|
+
for (let t of e) {
|
|
95
|
+
let e = t.tagInfo?.label;
|
|
96
|
+
e && i.has(l(e)) || a.has(t.tagId) || s(t.tagId);
|
|
97
|
+
}
|
|
98
|
+
return r.forEach(s), o;
|
|
99
|
+
}
|
|
100
|
+
function h(e, t, n, r = 8) {
|
|
101
|
+
let i = new Set(t.map(l)), a = l(n), o = /* @__PURE__ */ new Set();
|
|
102
|
+
return e.filter((e) => {
|
|
103
|
+
let t = l(e.label);
|
|
104
|
+
return !t || i.has(t) || o.has(t) ? !1 : (o.add(t), a === "" || t.includes(a));
|
|
105
|
+
}).sort((e, t) => e.label.localeCompare(t.label)).slice(0, r);
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { n as AVAILABLE_COS_TAGS, o as COS_ENTITY_TAGS, r as CREATE_COS_TAG, i as REPLACE_COS_ENTITY_TAGS, a as SEARCH_COS_TAGS, c as cleanTagLabel, d as diffEntityTagLabels, f as findTagByLabel, p as labelsMissingFromAssignments, m as nextEntityTagIds, l as normalizeTagLabel, h as suggestWorkspaceTags, u as uniqueTagLabels, s as useWorkspaceTags };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=tagsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagsApi.js","names":[],"sources":["../../../src/cosmicintersection/api/tagsApi.ts"],"sourcesContent":["/**\n * tagsApi — workspace tag operations for CosmicIntersection entities.\n *\n * Every document here targets the `Cos`-prefixed tag surface that\n * wspace-cosmicintersection-svc publishes from the shared\n * `@burdenoff/be-sdk/tags` builder (`availableCosTags`, `searchCosTags`,\n * `createCosTag`, `cosEntityTags`, `replaceCosEntityTags`). The service\n * forwards each call to wspace-tags-svc, so tags live in the workspace\n * taxonomy and are shared with every other product surface.\n *\n * The entity's inline `tags: [String!]` array is still written by the entity's\n * own create/update mutation (labels of the selected tags) so list filters and\n * search keep working; `useEntityTagSync` applies the labels the user added or\n * removed to the structured assignments ({@link diffEntityTagLabels}).\n */\nimport { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\n\n/** Entity types the CosmicIntersection subgraph registers with wspace-tags-svc. */\nexport type CosTagEntityType =\n | 'COSMICINTERSECTION_DATASET'\n | 'COSMICINTERSECTION_SOURCE'\n | 'COSMICINTERSECTION_NOTEBOOK'\n | 'COSMICINTERSECTION_COLLECTION'\n | 'COSMICINTERSECTION_PIPELINE'\n | 'COSMICINTERSECTION_RELEASE';\n\n/** An assignable workspace tag (`CosAvailableTag`). */\nexport interface CosWorkspaceTag {\n id: string;\n key: string;\n label: string;\n color?: string | null;\n}\n\n/** Upper bound on the workspace tags the picker loads for suggestions. */\nexport const WORKSPACE_TAG_LIMIT = 200;\n\nexport const AVAILABLE_COS_TAGS = gql`\n query AvailableCosTags($limit: Int) {\n availableCosTags(limit: $limit) {\n id\n key\n label\n color\n }\n }\n`;\n\nexport const CREATE_COS_TAG = gql`\n mutation CreateCosTag($input: CreateCosTagInput!) {\n createCosTag(input: $input) {\n id\n key\n label\n color\n }\n }\n`;\n\nexport const REPLACE_COS_ENTITY_TAGS = gql`\n mutation ReplaceCosEntityTags($input: ReplaceCosEntityTagsInput!) {\n replaceCosEntityTags(input: $input) {\n id\n tagId\n }\n }\n`;\n\nexport const SEARCH_COS_TAGS = gql`\n query SearchCosTags($query: String!, $limit: Int) {\n searchCosTags(query: $query, limit: $limit) {\n id\n key\n label\n color\n }\n }\n`;\n\nexport const COS_ENTITY_TAGS = gql`\n query CosEntityTags($input: GetCosEntityTagsInput!) {\n cosEntityTags(input: $input) {\n id\n tagId\n tagInfo {\n id\n label\n }\n }\n }\n`;\n\nexport interface AvailableCosTagsData {\n availableCosTags: CosWorkspaceTag[];\n}\n\nexport interface CreateCosTagData {\n createCosTag: CosWorkspaceTag;\n}\n\nexport interface SearchCosTagsData {\n searchCosTags: CosWorkspaceTag[];\n}\n\nexport interface CosEntityTagsData {\n cosEntityTags: Array<CosEntityTagAssignment & { id: string }>;\n}\n\nexport interface ReplaceCosEntityTagsData {\n replaceCosEntityTags: Array<{ id: string; tagId: string }>;\n}\n\n/**\n * Workspace tags for the picker's suggestions. `cache-and-network` so a tag\n * created from another form shows up the next time a picker mounts, while the\n * cached list renders instantly. A failure (tags-svc down, no permission) is\n * reported through `error` and the picker falls back to free-text entry.\n */\nexport function useWorkspaceTags(skip = false) {\n return useQuery<AvailableCosTagsData, { limit: number }>(AVAILABLE_COS_TAGS, {\n variables: { limit: WORKSPACE_TAG_LIMIT },\n fetchPolicy: 'cache-and-network',\n errorPolicy: 'all',\n skip,\n });\n}\n\n/**\n * Longest label the picker input accepts; a cheap guard against oversized new\n * values. It is enforced on the input only: labels loaded from an entity keep\n * their full text, since the earlier free-text field accepted any length.\n */\nexport const MAX_TAG_LABEL_LENGTH = 64;\n\n/** Display form of a label: trimmed, inner whitespace collapsed. */\nexport function cleanTagLabel(label: string): string {\n return label.trim().replace(/\\s+/g, ' ');\n}\n\n/** Case- and whitespace-insensitive identity for a tag label. */\nexport function normalizeTagLabel(label: string): string {\n return cleanTagLabel(label).toLowerCase();\n}\n\n/** Unique, cleaned labels in first-seen order (duplicates by {@link normalizeTagLabel} collapse). */\nexport function uniqueTagLabels(labels: readonly string[]): string[] {\n const seen = new Set<string>();\n const out: string[] = [];\n for (const label of labels) {\n const key = normalizeTagLabel(label);\n if (!key || seen.has(key)) continue;\n seen.add(key);\n out.push(cleanTagLabel(label));\n }\n return out;\n}\n\nexport interface EntityTagLabelDiff {\n /** Labels the user added since the entity was loaded. */\n added: string[];\n /** Labels the user removed since the entity was loaded. */\n removed: string[];\n}\n\n/**\n * What changed between the labels an entity was loaded with and the labels the\n * form now holds. Only these labels touch the entity's workspace assignments,\n * so a tag assigned from another surface (the shell `/tags` route, the API)\n * survives every save that does not explicitly remove it.\n */\nexport function diffEntityTagLabels(\n previous: readonly string[],\n next: readonly string[]\n): EntityTagLabelDiff {\n const before = uniqueTagLabels(previous);\n const after = uniqueTagLabels(next);\n const beforeKeys = new Set(before.map(normalizeTagLabel));\n const afterKeys = new Set(after.map(normalizeTagLabel));\n return {\n added: after.filter((label) => !beforeKeys.has(normalizeTagLabel(label))),\n removed: before.filter((label) => !afterKeys.has(normalizeTagLabel(label))),\n };\n}\n\n/** First workspace tag whose label matches `label` (case/whitespace-insensitive). */\nexport function findTagByLabel(\n workspaceTags: readonly CosWorkspaceTag[],\n label: string\n): CosWorkspaceTag | undefined {\n const key = normalizeTagLabel(label);\n if (!key) return undefined;\n return workspaceTags.find((tag) => normalizeTagLabel(tag.label) === key);\n}\n\n/** A current assignment as read back from `cosEntityTags`. */\nexport interface CosEntityTagAssignment {\n tagId: string;\n tagInfo?: { label?: string | null } | null;\n}\n\n/**\n * Labels the form holds that the entity has no assignment for yet. An\n * assignment's label comes from its `tagInfo`, or from the workspace taxonomy\n * when the projection is missing.\n */\nexport function labelsMissingFromAssignments(\n labels: readonly string[],\n current: readonly CosEntityTagAssignment[],\n workspaceTags: readonly CosWorkspaceTag[]\n): string[] {\n const assigned = new Set<string>();\n for (const assignment of current) {\n const label =\n assignment.tagInfo?.label ?? workspaceTags.find((tag) => tag.id === assignment.tagId)?.label;\n if (label) assigned.add(normalizeTagLabel(label));\n }\n return uniqueTagLabels(labels).filter((label) => !assigned.has(normalizeTagLabel(label)));\n}\n\n/**\n * The full tag-id set to write after a save: the entity's current assignments,\n * minus the ids whose label the user removed, plus the resolved ids of the\n * labels the user added. Order is stable and ids are unique.\n */\nexport function nextEntityTagIds(\n current: readonly CosEntityTagAssignment[],\n removedLabels: readonly string[],\n removedTagIds: readonly string[],\n addedTagIds: readonly string[]\n): string[] {\n const removedKeys = new Set(removedLabels.map(normalizeTagLabel));\n const removedIds = new Set(removedTagIds);\n const ids: string[] = [];\n const push = (id: string) => {\n if (id && !ids.includes(id)) ids.push(id);\n };\n for (const assignment of current) {\n const label = assignment.tagInfo?.label;\n const removedByLabel = label ? removedKeys.has(normalizeTagLabel(label)) : false;\n if (removedByLabel || removedIds.has(assignment.tagId)) continue;\n push(assignment.tagId);\n }\n addedTagIds.forEach(push);\n return ids;\n}\n\n/**\n * Picker suggestions: workspace tags not already selected whose label contains\n * the typed text, alphabetically, capped at `limit`.\n */\nexport function suggestWorkspaceTags(\n workspaceTags: readonly CosWorkspaceTag[],\n selected: readonly string[],\n query: string,\n limit = 8\n): CosWorkspaceTag[] {\n const taken = new Set(selected.map(normalizeTagLabel));\n const needle = normalizeTagLabel(query);\n const seen = new Set<string>();\n return workspaceTags\n .filter((tag) => {\n const key = normalizeTagLabel(tag.label);\n if (!key || taken.has(key) || seen.has(key)) return false;\n seen.add(key);\n return needle === '' || key.includes(needle);\n })\n .sort((a, b) => a.label.localeCompare(b.label))\n .slice(0, limit);\n}\n"],"mappings":";;AAsCA,IAAa,IAAqB,CAAG;;;;;;;;;GAWxB,IAAiB,CAAG;;;;;;;;;GAWpB,IAA0B,CAAG;;;;;;;GAS7B,IAAkB,CAAG;;;;;;;;;GAWrB,IAAkB,CAAG;;;;;;;;;;;;AAuClC,SAAgB,EAAiB,IAAO,IAAO;CAC7C,OAAO,EAAkD,GAAoB;EAC3E,WAAW,EAAE,OAAA,IAA2B;EACxC,aAAa;EACb,aAAa;EACb;CACF,CAAC;AACH;AAUA,SAAgB,EAAc,GAAuB;CACnD,OAAO,EAAM,KAAK,CAAC,CAAC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ACA,GACU;CACV,IAAM,IAAc,IAAI,IAAI,EAAc,IAAI,CAAiB,CAAC,GAC1D,IAAa,IAAI,IAAI,CAAa,GAClC,IAAgB,CAAC,GACjB,KAAQ,MAAe;EAC3B,AAAI,KAAM,CAAC,EAAI,SAAS,CAAE,KAAG,EAAI,KAAK,CAAE;CAC1C;CACA,KAAK,IAAM,KAAc,GAAS;EAChC,IAAM,IAAQ,EAAW,SAAS;EAElC,AADuB,KAAQ,EAAY,IAAI,EAAkB,CAAK,CAAC,KACjD,EAAW,IAAI,EAAW,KAAK,KACrD,EAAK,EAAW,KAAK;CACvB;CAEA,OADA,EAAY,QAAQ,CAAI,GACjB;AACT;AAMA,SAAgB,EACd,GACA,GACA,GACA,IAAQ,GACW;CACnB,IAAM,IAAQ,IAAI,IAAI,EAAS,IAAI,CAAiB,CAAC,GAC/C,IAAS,EAAkB,CAAK,GAChC,oBAAO,IAAI,IAAY;CAC7B,OAAO,EACJ,QAAQ,MAAQ;EACf,IAAM,IAAM,EAAkB,EAAI,KAAK;EAGvC,OAFI,CAAC,KAAO,EAAM,IAAI,CAAG,KAAK,EAAK,IAAI,CAAG,IAAU,MACpD,EAAK,IAAI,CAAG,GACL,MAAW,MAAM,EAAI,SAAS,CAAM;CAC7C,CAAC,CAAC,CACD,MAAM,GAAG,MAAM,EAAE,MAAM,cAAc,EAAE,KAAK,CAAC,CAAC,CAC9C,MAAM,GAAG,CAAK;AACnB"}
|
|
@@ -9,11 +9,11 @@ export interface EntityTagsFieldProps {
|
|
|
9
9
|
className?: string;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Controlled
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* Controlled free-text chips input for plain string arrays (grant scopes,
|
|
13
|
+
* release authors). Entity *tags* use `WorkspaceTagsPicker` instead, which
|
|
14
|
+
* suggests from and writes to the workspace taxonomy; this field never talks to
|
|
15
|
+
* a tag service. The parent form owns the array and passes it straight into the
|
|
16
|
+
* entity's create/update input.
|
|
17
17
|
*/
|
|
18
18
|
export declare function EntityTagsField({ value, onChange, label, placeholder, disabled, className, }: EntityTagsFieldProps): import('react').JSX.Element;
|
|
19
19
|
export default EntityTagsField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityTagsField.js","names":[],"sources":["../../../src/cosmicintersection/components/EntityTagsField.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Plus, Tag as TagIcon, X } from 'lucide-react';\nimport { Badge, Button, Input } from '@burdenoff/fe-libs/ui';\n\nexport interface EntityTagsFieldProps {\n /** Current tags (the `tags: [String!]` inline array on the Cos entity). */\n value: string[];\n /** Called with the next tag array whenever a chip is added or removed. */\n onChange: (tags: string[]) => void;\n label?: string;\n placeholder?: string;\n disabled?: boolean;\n className?: string;\n}\n\n/**\n * Controlled
|
|
1
|
+
{"version":3,"file":"EntityTagsField.js","names":[],"sources":["../../../src/cosmicintersection/components/EntityTagsField.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Plus, Tag as TagIcon, X } from 'lucide-react';\nimport { Badge, Button, Input } from '@burdenoff/fe-libs/ui';\n\nexport interface EntityTagsFieldProps {\n /** Current tags (the `tags: [String!]` inline array on the Cos entity). */\n value: string[];\n /** Called with the next tag array whenever a chip is added or removed. */\n onChange: (tags: string[]) => void;\n label?: string;\n placeholder?: string;\n disabled?: boolean;\n className?: string;\n}\n\n/**\n * Controlled free-text chips input for plain string arrays (grant scopes,\n * release authors). Entity *tags* use `WorkspaceTagsPicker` instead, which\n * suggests from and writes to the workspace taxonomy; this field never talks to\n * a tag service. The parent form owns the array and passes it straight into the\n * entity's create/update input.\n */\nexport function EntityTagsField({\n value,\n onChange,\n label = 'Tags',\n placeholder = 'Add a tag and press Enter',\n disabled = false,\n className,\n}: EntityTagsFieldProps) {\n const [draft, setDraft] = useState('');\n\n const addTag = () => {\n const trimmed = draft.trim();\n if (!trimmed) {\n return;\n }\n // De-duplicate case-insensitively while preserving the user's casing.\n const exists = value.some((tag) => tag.toLowerCase() === trimmed.toLowerCase());\n if (!exists) {\n onChange([...value, trimmed]);\n }\n setDraft('');\n };\n\n const removeTag = (tag: string) => {\n onChange(value.filter((existing) => existing !== tag));\n };\n\n return (\n <div className={`space-y-2 ${className ?? ''}`}>\n <div className=\"flex items-center gap-2 text-sm font-medium text-text-primary\">\n <TagIcon className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span>{label}</span>\n </div>\n\n <div className=\"flex flex-wrap gap-2\" role=\"list\" aria-label={label}>\n {value.length === 0 ? (\n <span className=\"text-sm text-text-secondary\">No tags yet.</span>\n ) : (\n value.map((tag) => (\n <Badge key={tag} variant=\"secondary\" className=\"gap-1.5\" role=\"listitem\">\n <span className=\"min-w-0 truncate\">{tag}</span>\n <button\n type=\"button\"\n onClick={() => removeTag(tag)}\n disabled={disabled}\n aria-label={`Remove ${tag}`}\n className=\"rounded-full text-text-secondary transition-colors hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border-focus disabled:opacity-50\"\n >\n <X className=\"size-3\" aria-hidden=\"true\" />\n </button>\n </Badge>\n ))\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n <Input\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n placeholder={placeholder}\n aria-label={`${label} input`}\n disabled={disabled}\n className=\"w-full max-w-xs\"\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n addTag();\n }\n }}\n />\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={addTag}\n disabled={disabled || !draft.trim()}\n >\n <Plus className=\"size-4\" />\n Add\n </Button>\n </div>\n </div>\n );\n}\n\nexport default EntityTagsField;\n"],"mappings":";;;;;AAsBA,SAAgB,EAAgB,EAC9B,UACA,aACA,WAAQ,QACR,iBAAc,6BACd,cAAW,IACX,gBACuB;CACvB,IAAM,CAAC,GAAO,KAAY,EAAS,EAAE,GAE/B,UAAe;EACnB,IA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kBAAC,GAAD,EAAM,WAAU,SAAU,CAAA,GAAC,KAErB;MACL;;EACF;;AAET"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface WorkspaceTagsPickerProps {
|
|
2
|
+
/** Selected tag labels (mirrors the entity's inline `tags: [String!]` array). */
|
|
3
|
+
value: string[];
|
|
4
|
+
/** Called with the next label array whenever a tag is added or removed. */
|
|
5
|
+
onChange: (tags: string[]) => void;
|
|
6
|
+
label?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Max suggestions shown under the input. */
|
|
11
|
+
suggestionLimit?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Workspace-aware tag picker for CosmicIntersection entity forms.
|
|
15
|
+
*
|
|
16
|
+
* Suggests existing tags from the workspace taxonomy (wspace-tags-svc, via the
|
|
17
|
+
* `availableCosTags` field of this product's subgraph) and lets the user add a
|
|
18
|
+
* brand-new tag when nothing matches. New labels are created in the taxonomy
|
|
19
|
+
* when the form saves (`useEntityTagSync`), so cancelling a form never leaves
|
|
20
|
+
* orphan tags behind. When the taxonomy cannot be loaded the picker still
|
|
21
|
+
* works as a plain chips input.
|
|
22
|
+
*
|
|
23
|
+
* Self-contained by design: MFEs never import each other, so this lives here
|
|
24
|
+
* rather than in microfe-tags (which owns the full `/tags` management UI).
|
|
25
|
+
*/
|
|
26
|
+
export declare function WorkspaceTagsPicker({ value, onChange, label, placeholder, disabled, className, suggestionLimit, }: WorkspaceTagsPickerProps): import('react').JSX.Element;
|
|
27
|
+
//# sourceMappingURL=WorkspaceTagsPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkspaceTagsPicker.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/components/WorkspaceTagsPicker.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,wBAAwB;IACvC,iFAAiF;IACjF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,QAAQ,EACR,KAAc,EACd,WAAsD,EACtD,QAAgB,EAChB,SAAS,EACT,eAAmB,GACpB,EAAE,wBAAwB,+BAqJ1B"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { cleanTagLabel as e, findTagByLabel as t, normalizeTagLabel as n, suggestWorkspaceTags as r, useWorkspaceTags as i } from "../api/tagsApi.js";
|
|
2
|
+
import { useId as a, useMemo as o, useState as s } from "react";
|
|
3
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
4
|
+
import { Plus as u, Tag as d, X as f } from "lucide-react";
|
|
5
|
+
import { Badge as p, Button as m, Input as h } from "@burdenoff/fe-libs/ui";
|
|
6
|
+
//#region src/cosmicintersection/components/WorkspaceTagsPicker.tsx
|
|
7
|
+
function g({ value: g, onChange: _, label: v = "Tags", placeholder: y = "Search workspace tags or add a new one", disabled: b = !1, className: x, suggestionLimit: S = 8 }) {
|
|
8
|
+
let [C, w] = s(""), T = a(), { data: E, loading: D, error: O } = i(b), k = o(() => E?.availableCosTags ?? [], [E]), A = o(() => r(k, g, C, S), [
|
|
9
|
+
k,
|
|
10
|
+
g,
|
|
11
|
+
C,
|
|
12
|
+
S
|
|
13
|
+
]), j = e(C), M = n(j), N = g.some((e) => n(e) === M), P = t(k, j), F = j !== "" && !N && !P, I = (t) => {
|
|
14
|
+
let r = e(t);
|
|
15
|
+
r && (g.some((e) => n(e) === n(r)) || _([...g, r]), w(""));
|
|
16
|
+
}, L = () => {
|
|
17
|
+
j && I(P?.label ?? j);
|
|
18
|
+
}, R = (e) => {
|
|
19
|
+
let t = n(e);
|
|
20
|
+
_(g.filter((e) => n(e) !== t));
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ l("div", {
|
|
23
|
+
className: `space-y-2 ${x ?? ""}`,
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ l("div", {
|
|
26
|
+
className: "flex items-center gap-2 text-sm font-medium text-text-primary",
|
|
27
|
+
children: [/* @__PURE__ */ c(d, {
|
|
28
|
+
className: "size-4 text-text-secondary",
|
|
29
|
+
"aria-hidden": "true"
|
|
30
|
+
}), /* @__PURE__ */ c("span", { children: v })]
|
|
31
|
+
}),
|
|
32
|
+
/* @__PURE__ */ c("div", {
|
|
33
|
+
className: "flex flex-wrap gap-2",
|
|
34
|
+
role: "list",
|
|
35
|
+
"aria-label": v,
|
|
36
|
+
children: g.length === 0 ? /* @__PURE__ */ c("span", {
|
|
37
|
+
className: "text-sm text-text-secondary",
|
|
38
|
+
children: "No tags yet."
|
|
39
|
+
}) : g.map((e) => /* @__PURE__ */ l(p, {
|
|
40
|
+
variant: "secondary",
|
|
41
|
+
className: "gap-1.5",
|
|
42
|
+
role: "listitem",
|
|
43
|
+
children: [/* @__PURE__ */ c("span", {
|
|
44
|
+
className: "min-w-0 truncate",
|
|
45
|
+
children: e
|
|
46
|
+
}), /* @__PURE__ */ c("button", {
|
|
47
|
+
type: "button",
|
|
48
|
+
onClick: () => R(e),
|
|
49
|
+
disabled: b,
|
|
50
|
+
"aria-label": `Remove ${e}`,
|
|
51
|
+
className: "rounded-full text-text-secondary transition-colors hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border-focus disabled:opacity-50",
|
|
52
|
+
children: /* @__PURE__ */ c(f, {
|
|
53
|
+
className: "size-3",
|
|
54
|
+
"aria-hidden": "true"
|
|
55
|
+
})
|
|
56
|
+
})]
|
|
57
|
+
}, e))
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ l("div", {
|
|
60
|
+
className: "flex items-center gap-2",
|
|
61
|
+
children: [/* @__PURE__ */ c(h, {
|
|
62
|
+
value: C,
|
|
63
|
+
onChange: (e) => w(e.target.value),
|
|
64
|
+
placeholder: y,
|
|
65
|
+
"aria-label": `${v} input`,
|
|
66
|
+
"aria-controls": T,
|
|
67
|
+
maxLength: 64,
|
|
68
|
+
disabled: b,
|
|
69
|
+
className: "w-full max-w-xs",
|
|
70
|
+
onKeyDown: (e) => {
|
|
71
|
+
e.key === "Enter" && (e.preventDefault(), L());
|
|
72
|
+
}
|
|
73
|
+
}), /* @__PURE__ */ l(m, {
|
|
74
|
+
type: "button",
|
|
75
|
+
variant: "outline",
|
|
76
|
+
size: "sm",
|
|
77
|
+
onClick: L,
|
|
78
|
+
disabled: b || !j,
|
|
79
|
+
children: [/* @__PURE__ */ c(u, { className: "size-4" }), "Add"]
|
|
80
|
+
})]
|
|
81
|
+
}),
|
|
82
|
+
b ? null : /* @__PURE__ */ l("div", {
|
|
83
|
+
id: T,
|
|
84
|
+
className: "flex flex-wrap items-center gap-2",
|
|
85
|
+
"aria-label": `${v} suggestions`,
|
|
86
|
+
role: "group",
|
|
87
|
+
children: [
|
|
88
|
+
A.length > 0 ? /* @__PURE__ */ c("span", {
|
|
89
|
+
className: "text-xs text-text-secondary",
|
|
90
|
+
children: j ? "Matching tags:" : "Workspace tags:"
|
|
91
|
+
}) : null,
|
|
92
|
+
A.map((e) => /* @__PURE__ */ l(m, {
|
|
93
|
+
type: "button",
|
|
94
|
+
variant: "ghost",
|
|
95
|
+
size: "sm",
|
|
96
|
+
className: "h-7 px-2 text-xs",
|
|
97
|
+
onClick: () => I(e.label),
|
|
98
|
+
"aria-label": `Add workspace tag ${e.label}`,
|
|
99
|
+
children: [/* @__PURE__ */ c(d, {
|
|
100
|
+
className: "size-3",
|
|
101
|
+
"aria-hidden": "true"
|
|
102
|
+
}), e.label]
|
|
103
|
+
}, e.id)),
|
|
104
|
+
F ? /* @__PURE__ */ l(m, {
|
|
105
|
+
type: "button",
|
|
106
|
+
variant: "ghost",
|
|
107
|
+
size: "sm",
|
|
108
|
+
className: "h-7 px-2 text-xs",
|
|
109
|
+
onClick: () => I(j),
|
|
110
|
+
"aria-label": `Create tag ${j}`,
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ c(u, {
|
|
113
|
+
className: "size-3",
|
|
114
|
+
"aria-hidden": "true"
|
|
115
|
+
}),
|
|
116
|
+
"Create “",
|
|
117
|
+
j,
|
|
118
|
+
"”"
|
|
119
|
+
]
|
|
120
|
+
}) : null,
|
|
121
|
+
D && k.length === 0 ? /* @__PURE__ */ c("span", {
|
|
122
|
+
className: "text-xs text-text-secondary",
|
|
123
|
+
children: "Loading workspace tags…"
|
|
124
|
+
}) : null,
|
|
125
|
+
O && k.length === 0 ? /* @__PURE__ */ c("span", {
|
|
126
|
+
className: "text-xs text-text-secondary",
|
|
127
|
+
children: "Workspace tags are unavailable right now; new tags are still saved."
|
|
128
|
+
}) : null,
|
|
129
|
+
!D && !O && k.length === 0 && !F ? /* @__PURE__ */ c("span", {
|
|
130
|
+
className: "text-xs text-text-secondary",
|
|
131
|
+
children: "No workspace tags yet. Type a name to create the first one."
|
|
132
|
+
}) : null
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
export { g as WorkspaceTagsPicker };
|
|
140
|
+
|
|
141
|
+
//# sourceMappingURL=WorkspaceTagsPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkspaceTagsPicker.js","names":[],"sources":["../../../src/cosmicintersection/components/WorkspaceTagsPicker.tsx"],"sourcesContent":["import { useId, useMemo, useState } from 'react';\nimport { Plus, Tag as TagIcon, X } from 'lucide-react';\nimport { Badge, Button, Input } from '@burdenoff/fe-libs/ui';\n\nimport {\n MAX_TAG_LABEL_LENGTH,\n cleanTagLabel,\n findTagByLabel,\n normalizeTagLabel,\n suggestWorkspaceTags,\n useWorkspaceTags,\n} from '../api/tagsApi';\n\nexport interface WorkspaceTagsPickerProps {\n /** Selected tag labels (mirrors the entity's inline `tags: [String!]` array). */\n value: string[];\n /** Called with the next label array whenever a tag is added or removed. */\n onChange: (tags: string[]) => void;\n label?: string;\n placeholder?: string;\n disabled?: boolean;\n className?: string;\n /** Max suggestions shown under the input. */\n suggestionLimit?: number;\n}\n\n/**\n * Workspace-aware tag picker for CosmicIntersection entity forms.\n *\n * Suggests existing tags from the workspace taxonomy (wspace-tags-svc, via the\n * `availableCosTags` field of this product's subgraph) and lets the user add a\n * brand-new tag when nothing matches. New labels are created in the taxonomy\n * when the form saves (`useEntityTagSync`), so cancelling a form never leaves\n * orphan tags behind. When the taxonomy cannot be loaded the picker still\n * works as a plain chips input.\n *\n * Self-contained by design: MFEs never import each other, so this lives here\n * rather than in microfe-tags (which owns the full `/tags` management UI).\n */\nexport function WorkspaceTagsPicker({\n value,\n onChange,\n label = 'Tags',\n placeholder = 'Search workspace tags or add a new one',\n disabled = false,\n className,\n suggestionLimit = 8,\n}: WorkspaceTagsPickerProps) {\n const [draft, setDraft] = useState('');\n const listId = useId();\n const { data, loading, error } = useWorkspaceTags(disabled);\n\n const workspaceTags = useMemo(() => data?.availableCosTags ?? [], [data]);\n const suggestions = useMemo(\n () => suggestWorkspaceTags(workspaceTags, value, draft, suggestionLimit),\n [workspaceTags, value, draft, suggestionLimit]\n );\n const trimmed = cleanTagLabel(draft);\n const normalized = normalizeTagLabel(trimmed);\n const alreadySelected = value.some((tag) => normalizeTagLabel(tag) === normalized);\n const existing = findTagByLabel(workspaceTags, trimmed);\n const canCreate = trimmed !== '' && !alreadySelected && !existing;\n\n const addTag = (next: string) => {\n const clean = cleanTagLabel(next);\n if (!clean) return;\n if (!value.some((tag) => normalizeTagLabel(tag) === normalizeTagLabel(clean))) {\n onChange([...value, clean]);\n }\n setDraft('');\n };\n\n /** Enter picks the matching workspace tag (keeping its canonical label), else adds the typed text. */\n const commitDraft = () => {\n if (!trimmed) return;\n addTag(existing?.label ?? trimmed);\n };\n\n const removeTag = (tag: string) => {\n const key = normalizeTagLabel(tag);\n onChange(value.filter((existingTag) => normalizeTagLabel(existingTag) !== key));\n };\n\n return (\n <div className={`space-y-2 ${className ?? ''}`}>\n <div className=\"flex items-center gap-2 text-sm font-medium text-text-primary\">\n <TagIcon className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span>{label}</span>\n </div>\n\n <div className=\"flex flex-wrap gap-2\" role=\"list\" aria-label={label}>\n {value.length === 0 ? (\n <span className=\"text-sm text-text-secondary\">No tags yet.</span>\n ) : (\n value.map((tag) => (\n <Badge key={tag} variant=\"secondary\" className=\"gap-1.5\" role=\"listitem\">\n <span className=\"min-w-0 truncate\">{tag}</span>\n <button\n type=\"button\"\n onClick={() => removeTag(tag)}\n disabled={disabled}\n aria-label={`Remove ${tag}`}\n className=\"rounded-full text-text-secondary transition-colors hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border-focus disabled:opacity-50\"\n >\n <X className=\"size-3\" aria-hidden=\"true\" />\n </button>\n </Badge>\n ))\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n <Input\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n placeholder={placeholder}\n aria-label={`${label} input`}\n aria-controls={listId}\n maxLength={MAX_TAG_LABEL_LENGTH}\n disabled={disabled}\n className=\"w-full max-w-xs\"\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n commitDraft();\n }\n }}\n />\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={commitDraft}\n disabled={disabled || !trimmed}\n >\n <Plus className=\"size-4\" />\n Add\n </Button>\n </div>\n\n {disabled ? null : (\n <div\n id={listId}\n className=\"flex flex-wrap items-center gap-2\"\n aria-label={`${label} suggestions`}\n role=\"group\"\n >\n {suggestions.length > 0 ? (\n <span className=\"text-xs text-text-secondary\">\n {trimmed ? 'Matching tags:' : 'Workspace tags:'}\n </span>\n ) : null}\n {suggestions.map((tag) => (\n <Button\n key={tag.id}\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-7 px-2 text-xs\"\n onClick={() => addTag(tag.label)}\n aria-label={`Add workspace tag ${tag.label}`}\n >\n <TagIcon className=\"size-3\" aria-hidden=\"true\" />\n {tag.label}\n </Button>\n ))}\n {canCreate ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-7 px-2 text-xs\"\n onClick={() => addTag(trimmed)}\n aria-label={`Create tag ${trimmed}`}\n >\n <Plus className=\"size-3\" aria-hidden=\"true\" />\n Create “{trimmed}”\n </Button>\n ) : null}\n {loading && workspaceTags.length === 0 ? (\n <span className=\"text-xs text-text-secondary\">Loading workspace tags…</span>\n ) : null}\n {error && workspaceTags.length === 0 ? (\n <span className=\"text-xs text-text-secondary\">\n Workspace tags are unavailable right now; new tags are still saved.\n </span>\n ) : null}\n {!loading && !error && workspaceTags.length === 0 && !canCreate ? (\n <span className=\"text-xs text-text-secondary\">\n No workspace tags yet. Type a name to create the first one.\n </span>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAuCA,SAAgB,EAAoB,EAClC,UACA,aACA,WAAQ,QACR,iBAAc,0CACd,cAAW,IACX,cACA,qBAAkB,KACS;CAC3B,IAAM,CAAC,GAAO,KAAY,EAAS,EAAE,GAC/B,IAAS,EAAM,GACf,EAAE,SAAM,YAAS,aAAU,EAAiB,CAAQ,GAEpD,IAAgB,QAAc,GAAM,oBAAoB,CAAC,GAAG,CAAC,CAAI,CAAC,GAClE,IAAc,QACZ,EAAqB,GAAe,GAAO,GAAO,CAAe,GACvE;EAAC;EAAe;EAAO;EAAO;CAAe,CAC/C,GACM,IAAU,EAAc,CAAK,GAC7B,IAAa,EAAkB,CAA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AA,IACJ;IACD;;EAEJ;;AAET"}
|
|
@@ -8,6 +8,7 @@ export { DiscussionPanel, type DiscussionPanelProps } from './DiscussionPanel';
|
|
|
8
8
|
export { EmptyState, type EmptyStateProps } from './EmptyState';
|
|
9
9
|
export { EntityFormShell, type EntityFormShellProps } from './EntityFormShell';
|
|
10
10
|
export { EntityTagsField, type EntityTagsFieldProps } from './EntityTagsField';
|
|
11
|
+
export { WorkspaceTagsPicker, type WorkspaceTagsPickerProps } from './WorkspaceTagsPicker';
|
|
11
12
|
export { ErrorState, type ErrorStateProps } from './ErrorState';
|
|
12
13
|
export { FileUploadField, GET_FILE_DOWNLOAD_URL, useFileDownloadUrl, type FileUploadFieldProps, } from './FileUploadField';
|
|
13
14
|
export { LoadingState, type LoadingStateProps } from './LoadingState';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/components/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,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MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EACL,WAAW,EACX,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,eAAe,CAAC"}
|
|
@@ -7,8 +7,9 @@ import { SafeLink as a } from "./SafeLink.js";
|
|
|
7
7
|
import { DiscussionPanel as o } from "./DiscussionPanel.js";
|
|
8
8
|
import { EntityFormShell as s } from "./EntityFormShell.js";
|
|
9
9
|
import { EntityTagsField as c } from "./EntityTagsField.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
10
|
+
import { WorkspaceTagsPicker as l } from "./WorkspaceTagsPicker.js";
|
|
11
|
+
import { FileUploadField as u, useFileDownloadUrl as d } from "./FileUploadField.js";
|
|
12
|
+
import { PageLayout as f } from "./PageLayout.js";
|
|
13
|
+
import { Pagination as p, usePagination as m } from "./Pagination.js";
|
|
14
|
+
import { StatusBadge as h, formatEnumLabel as g } from "./StatusBadge.js";
|
|
15
|
+
export { e as ActionMenu, i as ActivityFeedPanel, o as DiscussionPanel, t as EmptyState, s as EntityFormShell, c as EntityTagsField, n as ErrorState, u as FileUploadField, r as LoadingState, f as PageLayout, p as Pagination, a as SafeLink, h as StatusBadge, l as WorkspaceTagsPicker, g as formatEnumLabel, d as useFileDownloadUrl, m as usePagination };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CosTagEntityType } from '../api/tagsApi';
|
|
2
|
+
/** What a user can do after a failed sync; changes are not replayed automatically. */
|
|
3
|
+
export declare const RETRY_HINT = "The labels were saved. Workspace tag assignments were not changed; manage them from the Tags page.";
|
|
4
|
+
/**
|
|
5
|
+
* Apply the tag labels a form added or removed to an entity's workspace tag
|
|
6
|
+
* assignments.
|
|
7
|
+
*
|
|
8
|
+
* Call the returned `syncTags(entityId, labels, previousLabels)` right after
|
|
9
|
+
* the entity's own create/update mutation succeeds (the entity and its inline
|
|
10
|
+
* `tags` array are already saved by then). Pass the labels the entity was
|
|
11
|
+
* loaded with, captured before the mutation (an empty array on create).
|
|
12
|
+
*
|
|
13
|
+
* - Unchanged labels do nothing: there is no network call and assignments made
|
|
14
|
+
* from another surface are never touched.
|
|
15
|
+
* - When the labels changed, every label the form holds that is not assigned
|
|
16
|
+
* yet is resolved against the workspace taxonomy. Labels missing from
|
|
17
|
+
* the capped suggestion page are looked up with `searchCosTags` before
|
|
18
|
+
* anything is created, so a large workspace never gets a duplicate tag.
|
|
19
|
+
* Labels with no match are created (create-on-select).
|
|
20
|
+
* - Removed labels drop only their own assignment, resolved by the label of
|
|
21
|
+
* the assignment or, when that projection is missing, by looking the label
|
|
22
|
+
* up in the taxonomy. Every other current assignment is kept.
|
|
23
|
+
*
|
|
24
|
+
* Best-effort by design: the entity is already persisted, so a tags-svc
|
|
25
|
+
* failure must never block the form. When some new tags were created before
|
|
26
|
+
* a later one failed, the ones that succeeded are still assigned. A failure
|
|
27
|
+
* surfaces one warning and resolves `false`, so the page can skip its success
|
|
28
|
+
* toast.
|
|
29
|
+
*
|
|
30
|
+
* The entity's inline `tags` array stays the source of truth for the labels;
|
|
31
|
+
* assignments are never reconciled to exactly that set, because that would
|
|
32
|
+
* drop tags assigned from other surfaces. So a change whose sync failed is not
|
|
33
|
+
* replayed later. Adding a label again re-applies it on the next tag edit
|
|
34
|
+
* (missing labels are backfilled), while a failed removal has to be repeated
|
|
35
|
+
* from the workspace Tags page. The warning says so instead of promising an
|
|
36
|
+
* automatic retry.
|
|
37
|
+
*/
|
|
38
|
+
export interface EntityTagSync {
|
|
39
|
+
/** Apply the form's label changes to the entity's workspace tag assignments. */
|
|
40
|
+
syncTags: (entityId: string, labels: readonly string[], previousLabels?: readonly string[]) => Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* True while a sync is in flight. Forms add it to their saving state so the
|
|
43
|
+
* submit button stays disabled between the entity mutation and navigation,
|
|
44
|
+
* which prevents a second submit from creating a duplicate entity.
|
|
45
|
+
*/
|
|
46
|
+
syncing: boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare function useEntityTagSync(entityType: CosTagEntityType): EntityTagSync;
|
|
49
|
+
//# sourceMappingURL=useEntityTagSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEntityTagSync.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/hooks/useEntityTagSync.ts"],"names":[],"mappings":"AAGA,OAAO,EAcL,KAAK,gBAAgB,EAKtB,MAAM,gBAAgB,CAAC;AAGxB,sFAAsF;AACtF,eAAO,MAAM,UAAU,uGAC+E,CAAC;AAKvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,WAAW,aAAa;IAC5B,gFAAgF;IAChF,QAAQ,EAAE,CACR,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,KAC/B,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,GAAG,aAAa,CAwI5E"}
|