@kopexa/extension-controlref 1.0.0 → 2.0.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 (126) hide show
  1. package/dist/chunk-4C72VBLP.mjs +52 -0
  2. package/dist/chunk-A7FWOQDN.mjs +210 -0
  3. package/dist/chunk-AQTNFDGA.mjs +57 -0
  4. package/dist/chunk-D53W4HWR.mjs +245 -0
  5. package/dist/chunk-FTEE5U3H.mjs +37 -0
  6. package/dist/chunk-GYDJVHHG.mjs +250 -0
  7. package/dist/chunk-IMHLTRZJ.mjs +29 -0
  8. package/dist/chunk-JM66CQVD.mjs +10 -0
  9. package/dist/chunk-LMKP3DDN.mjs +189 -0
  10. package/dist/chunk-RTBFRPB3.mjs +186 -0
  11. package/dist/chunk-TEDXYIGO.mjs +38 -0
  12. package/dist/chunk-WIS7ZNTO.mjs +4 -0
  13. package/dist/chunk-X46EFFCE.mjs +148 -0
  14. package/dist/chunk-XHD2KFKQ.mjs +16 -0
  15. package/dist/chunk-ZRKYAFRY.mjs +46 -0
  16. package/dist/chunk-ZUR6XKMG.mjs +21 -0
  17. package/dist/components/control-block-view.d.mts +6 -0
  18. package/dist/components/control-block-view.d.ts +6 -0
  19. package/dist/components/control-block-view.js +789 -0
  20. package/dist/components/control-block-view.mjs +11 -0
  21. package/dist/components/control-implementation-view.d.mts +6 -0
  22. package/dist/components/control-implementation-view.d.ts +6 -0
  23. package/dist/components/control-implementation-view.js +52 -0
  24. package/dist/components/control-implementation-view.mjs +7 -0
  25. package/dist/components/control-picker.d.mts +25 -0
  26. package/dist/components/control-picker.d.ts +25 -0
  27. package/dist/components/control-picker.js +522 -0
  28. package/dist/components/control-picker.mjs +10 -0
  29. package/dist/components/control-view.js +677 -122
  30. package/dist/components/control-view.mjs +5 -5
  31. package/dist/components/use-control.d.mts +20 -0
  32. package/dist/components/use-control.d.ts +20 -0
  33. package/dist/components/use-control.js +127 -0
  34. package/dist/components/use-control.mjs +9 -0
  35. package/dist/control-block.d.mts +35 -0
  36. package/dist/control-block.d.ts +35 -0
  37. package/dist/control-block.js +1012 -0
  38. package/dist/control-block.mjs +17 -0
  39. package/dist/control-implementation.d.mts +7 -0
  40. package/dist/control-implementation.d.ts +7 -0
  41. package/dist/control-implementation.js +92 -0
  42. package/dist/control-implementation.mjs +9 -0
  43. package/dist/control.d.mts +31 -1
  44. package/dist/control.d.ts +31 -1
  45. package/dist/control.js +819 -136
  46. package/dist/control.mjs +7 -6
  47. package/dist/defaults.d.mts +3 -9
  48. package/dist/defaults.d.ts +3 -9
  49. package/dist/defaults.js +3 -20
  50. package/dist/defaults.mjs +3 -6
  51. package/dist/index.d.mts +10 -10
  52. package/dist/index.d.ts +10 -10
  53. package/dist/index.js +1229 -569
  54. package/dist/index.mjs +58 -21
  55. package/dist/messages/index.d.mts +135 -0
  56. package/dist/messages/index.d.ts +135 -0
  57. package/dist/messages/index.js +137 -2
  58. package/dist/messages/index.mjs +1 -2
  59. package/dist/role.d.mts +17 -0
  60. package/dist/role.d.ts +17 -0
  61. package/dist/role.js +5 -0
  62. package/dist/role.mjs +2 -0
  63. package/dist/types.d.mts +23 -16
  64. package/dist/types.d.ts +23 -16
  65. package/dist/utils/create-control-block.d.mts +7 -0
  66. package/dist/utils/create-control-block.d.ts +7 -0
  67. package/dist/utils/create-control-block.js +85 -0
  68. package/dist/utils/create-control-block.mjs +10 -0
  69. package/dist/utils/create-control-implementation.d.mts +8 -0
  70. package/dist/utils/create-control-implementation.d.ts +8 -0
  71. package/dist/utils/create-control-implementation.js +39 -0
  72. package/dist/utils/create-control-implementation.mjs +7 -0
  73. package/dist/utils/getControlNodeTypes.d.mts +5 -0
  74. package/dist/utils/getControlNodeTypes.d.ts +5 -0
  75. package/dist/utils/getControlNodeTypes.js +44 -0
  76. package/dist/utils/getControlNodeTypes.mjs +7 -0
  77. package/dist/utils/index.d.mts +7 -2
  78. package/dist/utils/index.d.ts +7 -2
  79. package/dist/utils/index.js +35 -3
  80. package/dist/utils/index.mjs +7 -4
  81. package/dist/utils/status-indicator.d.mts +18 -0
  82. package/dist/utils/status-indicator.d.ts +18 -0
  83. package/dist/utils/status-indicator.js +80 -0
  84. package/dist/utils/status-indicator.mjs +7 -0
  85. package/package.json +9 -9
  86. package/dist/card-variant.d.mts +0 -12
  87. package/dist/card-variant.d.ts +0 -12
  88. package/dist/card-variant.js +0 -66
  89. package/dist/card-variant.mjs +0 -8
  90. package/dist/chunk-AC4KL3WX.mjs +0 -29
  91. package/dist/chunk-AZ5M5MVC.mjs +0 -36
  92. package/dist/chunk-DTFR234X.mjs +0 -244
  93. package/dist/chunk-EDD7DYLE.mjs +0 -29
  94. package/dist/chunk-GC5EBQ7G.mjs +0 -10
  95. package/dist/chunk-H2ECPGOG.mjs +0 -81
  96. package/dist/chunk-KLX7Q3HL.mjs +0 -109
  97. package/dist/chunk-LKRTUIEV.mjs +0 -46
  98. package/dist/chunk-NAJ6IC4Y.mjs +0 -43
  99. package/dist/chunk-QI3ZPZTR.mjs +0 -26
  100. package/dist/chunk-SNRVOTF5.mjs +0 -8
  101. package/dist/chunk-VP5POY44.mjs +0 -57
  102. package/dist/chunk-WIR5FCIC.mjs +0 -110
  103. package/dist/control-ref-view.d.mts +0 -6
  104. package/dist/control-ref-view.d.ts +0 -6
  105. package/dist/control-ref-view.js +0 -615
  106. package/dist/control-ref-view.mjs +0 -15
  107. package/dist/control-ref.d.mts +0 -28
  108. package/dist/control-ref.d.ts +0 -28
  109. package/dist/control-ref.js +0 -687
  110. package/dist/control-ref.mjs +0 -16
  111. package/dist/i18n.d.mts +0 -4
  112. package/dist/i18n.d.ts +0 -4
  113. package/dist/i18n.js +0 -128
  114. package/dist/i18n.mjs +0 -10
  115. package/dist/lang/de.d.mts +0 -24
  116. package/dist/lang/de.d.ts +0 -24
  117. package/dist/lang/de.js +0 -25
  118. package/dist/lang/de.mjs +0 -8
  119. package/dist/lang/en.d.mts +0 -24
  120. package/dist/lang/en.d.ts +0 -24
  121. package/dist/lang/en.js +0 -25
  122. package/dist/lang/en.mjs +0 -8
  123. package/dist/settings-dialog.d.mts +0 -19
  124. package/dist/settings-dialog.d.ts +0 -19
  125. package/dist/settings-dialog.js +0 -371
  126. package/dist/settings-dialog.mjs +0 -9
package/dist/types.d.ts CHANGED
@@ -1,5 +1,27 @@
1
1
  import { CardVariantProps } from '@kopexa/theme';
2
2
 
3
+ type FallbackOptions = Record<string, unknown>;
4
+ type ControlNodeAttrs<T = FallbackOptions> = {
5
+ id: string | null;
6
+ title: string | null;
7
+ updatedAt: string | null;
8
+ status: string | null;
9
+ options: T | null;
10
+ };
11
+ type ControlBlockVariant = "default" | "muted" | "accent";
12
+ type ControlViewOptions = {
13
+ showStatus?: boolean | null;
14
+ variant?: ControlBlockVariant;
15
+ };
16
+ type ControlResolver = {
17
+ /**
18
+ * A method to retrieve a list of controls, potentially filtered by a search term.
19
+ * @param searchTerm - Optional term to filter controls.
20
+ * @returns A promise that resolves to an array of control objects.
21
+ */
22
+ getControls: (searchTerm?: string) => Promise<Array<ControlSummary>>;
23
+ getControl: (id: string) => Promise<ControlSummary | null>;
24
+ };
3
25
  type ControlSummary = {
4
26
  id: string | null;
5
27
  title: string | null;
@@ -14,24 +36,9 @@ type ControlImplementationRef = {
14
36
  updatedAt?: string | null;
15
37
  status?: string | null;
16
38
  };
17
- type Variant = "chip" | "card";
18
39
  type CardBorder = CardVariantProps["border"];
19
40
  type CardShadow = CardVariantProps["shadow"];
20
41
  type CardRadius = CardVariantProps["radius"];
21
42
  type CardSpacing = CardVariantProps["spacing"];
22
- type ControlRefOptions = {
23
- variant: Variant;
24
- inlineShowStatus: boolean;
25
- cardShowDescription: boolean;
26
- cardShowImplementations: boolean;
27
- cardBorder: CardBorder;
28
- cardShadow: CardShadow;
29
- cardRadius: CardRadius;
30
- cardSpacing: CardSpacing;
31
- };
32
- type Getters = {
33
- search: (q: string) => Promise<ControlSummary[]>;
34
- getById: (id: string) => Promise<ControlSummary | null>;
35
- };
36
43
 
37
- export type { CardBorder, CardRadius, CardShadow, CardSpacing, ControlImplementationRef, ControlRefOptions, ControlSummary, Getters, Variant };
44
+ export type { CardBorder, CardRadius, CardShadow, CardSpacing, ControlBlockVariant, ControlImplementationRef, ControlNodeAttrs, ControlResolver, ControlSummary, ControlViewOptions };
@@ -0,0 +1,7 @@
1
+ import { Schema } from '@tiptap/pm/model';
2
+ import { ControlImplementationRef } from '../types.mjs';
3
+ import '@kopexa/theme';
4
+
5
+ declare function createControlBlock(schema: Schema, implementations?: ControlImplementationRef[]): any;
6
+
7
+ export { createControlBlock };
@@ -0,0 +1,7 @@
1
+ import { Schema } from '@tiptap/pm/model';
2
+ import { ControlImplementationRef } from '../types.js';
3
+ import '@kopexa/theme';
4
+
5
+ declare function createControlBlock(schema: Schema, implementations?: ControlImplementationRef[]): any;
6
+
7
+ export { createControlBlock };
@@ -0,0 +1,85 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/utils/create-control-block.ts
22
+ var create_control_block_exports = {};
23
+ __export(create_control_block_exports, {
24
+ createControlBlock: () => createControlBlock
25
+ });
26
+ module.exports = __toCommonJS(create_control_block_exports);
27
+
28
+ // src/defaults.ts
29
+ var DEFAULT_CONTROL_REF_OPTIONS = {
30
+ showStatus: true
31
+ };
32
+
33
+ // src/utils/create-control-implementation.ts
34
+ function createControlImplementation(nodeType, impl) {
35
+ var _a, _b, _c;
36
+ return nodeType.createAndFill({
37
+ id: impl.id,
38
+ title: (_a = impl.title) != null ? _a : "",
39
+ status: (_b = impl.status) != null ? _b : null,
40
+ updatedAt: (_c = impl.updatedAt) != null ? _c : null
41
+ });
42
+ }
43
+
44
+ // src/utils/getControlNodeTypes.ts
45
+ function getControlNodeTypes(schema) {
46
+ if (schema.cached.controlNodeTypes) {
47
+ return schema.cached.controlNodeTypes;
48
+ }
49
+ const roles = {};
50
+ Object.keys(schema.nodes).forEach((type) => {
51
+ const nodeType = schema.nodes[type];
52
+ if (nodeType.spec.controlRole) {
53
+ roles[nodeType.spec.controlRole] = nodeType;
54
+ }
55
+ });
56
+ schema.cached.controlNodeTypes = roles;
57
+ return roles;
58
+ }
59
+
60
+ // src/utils/create-control-block.ts
61
+ function createControlBlock(schema, implementations) {
62
+ const types = getControlNodeTypes(schema);
63
+ const attrs = {
64
+ id: null,
65
+ title: null,
66
+ status: null,
67
+ updatedAt: null,
68
+ options: DEFAULT_CONTROL_REF_OPTIONS
69
+ };
70
+ const implNodes = [];
71
+ if (implementations == null ? void 0 : implementations.length) {
72
+ for (const impl of implementations) {
73
+ const n = createControlImplementation(types.controlImplementation, impl);
74
+ if (n) implNodes.push(n);
75
+ }
76
+ }
77
+ if (implNodes.length > 0) {
78
+ return types.controlBlock.createCheck(attrs, null);
79
+ }
80
+ return types.controlBlock.createAndFill();
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ createControlBlock
85
+ });
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import {
3
+ createControlBlock
4
+ } from "../chunk-FTEE5U3H.mjs";
5
+ import "../chunk-XHD2KFKQ.mjs";
6
+ import "../chunk-ZUR6XKMG.mjs";
7
+ import "../chunk-JM66CQVD.mjs";
8
+ export {
9
+ createControlBlock
10
+ };
@@ -0,0 +1,8 @@
1
+ import * as _tiptap_pm_model from '@tiptap/pm/model';
2
+ import { NodeType } from '@tiptap/pm/model';
3
+ import { ControlImplementationRef } from '../types.mjs';
4
+ import '@kopexa/theme';
5
+
6
+ declare function createControlImplementation(nodeType: NodeType, impl: ControlImplementationRef): _tiptap_pm_model.Node | null;
7
+
8
+ export { createControlImplementation };
@@ -0,0 +1,8 @@
1
+ import * as _tiptap_pm_model from '@tiptap/pm/model';
2
+ import { NodeType } from '@tiptap/pm/model';
3
+ import { ControlImplementationRef } from '../types.js';
4
+ import '@kopexa/theme';
5
+
6
+ declare function createControlImplementation(nodeType: NodeType, impl: ControlImplementationRef): _tiptap_pm_model.Node | null;
7
+
8
+ export { createControlImplementation };
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/utils/create-control-implementation.ts
22
+ var create_control_implementation_exports = {};
23
+ __export(create_control_implementation_exports, {
24
+ createControlImplementation: () => createControlImplementation
25
+ });
26
+ module.exports = __toCommonJS(create_control_implementation_exports);
27
+ function createControlImplementation(nodeType, impl) {
28
+ var _a, _b, _c;
29
+ return nodeType.createAndFill({
30
+ id: impl.id,
31
+ title: (_a = impl.title) != null ? _a : "",
32
+ status: (_b = impl.status) != null ? _b : null,
33
+ updatedAt: (_c = impl.updatedAt) != null ? _c : null
34
+ });
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ createControlImplementation
39
+ });
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ createControlImplementation
4
+ } from "../chunk-XHD2KFKQ.mjs";
5
+ export {
6
+ createControlImplementation
7
+ };
@@ -0,0 +1,5 @@
1
+ import { Schema } from '@tiptap/pm/model';
2
+
3
+ declare function getControlNodeTypes(schema: Schema): any;
4
+
5
+ export { getControlNodeTypes };
@@ -0,0 +1,5 @@
1
+ import { Schema } from '@tiptap/pm/model';
2
+
3
+ declare function getControlNodeTypes(schema: Schema): any;
4
+
5
+ export { getControlNodeTypes };
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/utils/getControlNodeTypes.ts
22
+ var getControlNodeTypes_exports = {};
23
+ __export(getControlNodeTypes_exports, {
24
+ getControlNodeTypes: () => getControlNodeTypes
25
+ });
26
+ module.exports = __toCommonJS(getControlNodeTypes_exports);
27
+ function getControlNodeTypes(schema) {
28
+ if (schema.cached.controlNodeTypes) {
29
+ return schema.cached.controlNodeTypes;
30
+ }
31
+ const roles = {};
32
+ Object.keys(schema.nodes).forEach((type) => {
33
+ const nodeType = schema.nodes[type];
34
+ if (nodeType.spec.controlRole) {
35
+ roles[nodeType.spec.controlRole] = nodeType;
36
+ }
37
+ });
38
+ schema.cached.controlNodeTypes = roles;
39
+ return roles;
40
+ }
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ getControlNodeTypes
44
+ });
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ getControlNodeTypes
4
+ } from "../chunk-ZUR6XKMG.mjs";
5
+ export {
6
+ getControlNodeTypes
7
+ };
@@ -1,3 +1,8 @@
1
- declare const DEFAULT_CONTROL_GQL_API = "https://api.kopexa.com/query";
1
+ /**
2
+ * Normalizes dataset keys; supports legacy `data-updatedAt`.
3
+ */
4
+ declare function readUpdatedAt(el: HTMLElement): string | null;
5
+ declare function safeJSONStringify(value: unknown): string | null;
6
+ declare function safeJSONParse<T = unknown>(value: string | null | undefined): T | null;
2
7
 
3
- export { DEFAULT_CONTROL_GQL_API };
8
+ export { readUpdatedAt, safeJSONParse, safeJSONStringify };
@@ -1,3 +1,8 @@
1
- declare const DEFAULT_CONTROL_GQL_API = "https://api.kopexa.com/query";
1
+ /**
2
+ * Normalizes dataset keys; supports legacy `data-updatedAt`.
3
+ */
4
+ declare function readUpdatedAt(el: HTMLElement): string | null;
5
+ declare function safeJSONStringify(value: unknown): string | null;
6
+ declare function safeJSONParse<T = unknown>(value: string | null | undefined): T | null;
2
7
 
3
- export { DEFAULT_CONTROL_GQL_API };
8
+ export { readUpdatedAt, safeJSONParse, safeJSONStringify };
@@ -21,11 +21,43 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/utils/index.ts
22
22
  var utils_exports = {};
23
23
  __export(utils_exports, {
24
- DEFAULT_CONTROL_GQL_API: () => DEFAULT_CONTROL_GQL_API
24
+ readUpdatedAt: () => readUpdatedAt,
25
+ safeJSONParse: () => safeJSONParse,
26
+ safeJSONStringify: () => safeJSONStringify
25
27
  });
26
28
  module.exports = __toCommonJS(utils_exports);
27
- var DEFAULT_CONTROL_GQL_API = "https://api.kopexa.com/query";
29
+ function firstNonEmpty(...vals) {
30
+ for (const v of vals) {
31
+ if (v != null && String(v).trim() !== "") return String(v);
32
+ }
33
+ return null;
34
+ }
35
+ function readUpdatedAt(el) {
36
+ const v = firstNonEmpty(
37
+ el.getAttribute("data-updated-at"),
38
+ el.getAttribute("data-updatedat")
39
+ );
40
+ return v;
41
+ }
42
+ function safeJSONStringify(value) {
43
+ try {
44
+ if (value == null) return null;
45
+ return JSON.stringify(value);
46
+ } catch {
47
+ return null;
48
+ }
49
+ }
50
+ function safeJSONParse(value) {
51
+ if (!value) return null;
52
+ try {
53
+ return JSON.parse(value);
54
+ } catch {
55
+ return null;
56
+ }
57
+ }
28
58
  // Annotate the CommonJS export names for ESM import in node:
29
59
  0 && (module.exports = {
30
- DEFAULT_CONTROL_GQL_API
60
+ readUpdatedAt,
61
+ safeJSONParse,
62
+ safeJSONStringify
31
63
  });
@@ -1,8 +1,11 @@
1
1
  "use client";
2
2
  import {
3
- DEFAULT_CONTROL_GQL_API
4
- } from "../chunk-SNRVOTF5.mjs";
5
- import "../chunk-GC5EBQ7G.mjs";
3
+ readUpdatedAt,
4
+ safeJSONParse,
5
+ safeJSONStringify
6
+ } from "../chunk-TEDXYIGO.mjs";
6
7
  export {
7
- DEFAULT_CONTROL_GQL_API
8
+ readUpdatedAt,
9
+ safeJSONParse,
10
+ safeJSONStringify
8
11
  };
@@ -0,0 +1,18 @@
1
+ type IndicatorColor = "default" | "primary" | "secondary" | "success" | "warning" | "destructive" | "info";
2
+ type IndicatorProps = {
3
+ indicator: boolean;
4
+ indicatorColor: IndicatorColor;
5
+ indicatorVariant?: "pulse";
6
+ };
7
+ /**
8
+ * Returns the props to feed into <Chip>.
9
+ * - If `mapped === false` (unmapped), we surface a destructive pulse to draw attention.
10
+ * - If `enable === false`, indicator is disabled.
11
+ * - Otherwise, color is derived from status; pulse is used for “in flight”/attention states.
12
+ */
13
+ declare function getIndicatorProps(status?: string | null, opts?: {
14
+ mapped?: boolean;
15
+ enable?: boolean;
16
+ }): IndicatorProps;
17
+
18
+ export { type IndicatorColor, type IndicatorProps, getIndicatorProps };
@@ -0,0 +1,18 @@
1
+ type IndicatorColor = "default" | "primary" | "secondary" | "success" | "warning" | "destructive" | "info";
2
+ type IndicatorProps = {
3
+ indicator: boolean;
4
+ indicatorColor: IndicatorColor;
5
+ indicatorVariant?: "pulse";
6
+ };
7
+ /**
8
+ * Returns the props to feed into <Chip>.
9
+ * - If `mapped === false` (unmapped), we surface a destructive pulse to draw attention.
10
+ * - If `enable === false`, indicator is disabled.
11
+ * - Otherwise, color is derived from status; pulse is used for “in flight”/attention states.
12
+ */
13
+ declare function getIndicatorProps(status?: string | null, opts?: {
14
+ mapped?: boolean;
15
+ enable?: boolean;
16
+ }): IndicatorProps;
17
+
18
+ export { type IndicatorColor, type IndicatorProps, getIndicatorProps };
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/utils/status-indicator.ts
22
+ var status_indicator_exports = {};
23
+ __export(status_indicator_exports, {
24
+ getIndicatorProps: () => getIndicatorProps
25
+ });
26
+ module.exports = __toCommonJS(status_indicator_exports);
27
+ function norm(status) {
28
+ return (status != null ? status : "").trim().replace(/[\s-]+/g, "_").toUpperCase();
29
+ }
30
+ function colorForStatusKey(key) {
31
+ switch (key == null ? void 0 : key.toUpperCase()) {
32
+ case "FULFILLED_MANUAL":
33
+ case "FULFILLED_AUTO":
34
+ case "IMPLEMENTED":
35
+ case "APPROVED":
36
+ case "PASSED":
37
+ return "success";
38
+ case "IN_PROGRESS":
39
+ case "NEEDS_APPROVAL":
40
+ case "CHANGES_REQUESTED":
41
+ case "PENDING":
42
+ case "PARTIAL":
43
+ return "warning";
44
+ case "FAILED":
45
+ case "REJECTED":
46
+ return "destructive";
47
+ case "OUT_OF_SCOPE":
48
+ case "PREPARING":
49
+ return "secondary";
50
+ default:
51
+ return "default";
52
+ }
53
+ }
54
+ function getIndicatorProps(status, opts) {
55
+ var _a, _b;
56
+ const mapped = (_a = opts == null ? void 0 : opts.mapped) != null ? _a : true;
57
+ const enable = (_b = opts == null ? void 0 : opts.enable) != null ? _b : true;
58
+ if (!enable) {
59
+ return { indicator: false, indicatorColor: "default" };
60
+ }
61
+ if (!mapped) {
62
+ return {
63
+ indicator: true,
64
+ indicatorColor: "destructive",
65
+ indicatorVariant: "pulse"
66
+ };
67
+ }
68
+ const key = norm(status);
69
+ const indicatorColor = colorForStatusKey(key);
70
+ const shouldPulse = key === "IN_PROGRESS" || key === "NEEDS_APPROVAL" || key === "CHANGES_REQUESTED" || key === "PENDING";
71
+ return {
72
+ indicator: true,
73
+ indicatorColor,
74
+ ...shouldPulse ? { indicatorVariant: "pulse" } : {}
75
+ };
76
+ }
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ getIndicatorProps
80
+ });
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ getIndicatorProps
4
+ } from "../chunk-AQTNFDGA.mjs";
5
+ export {
6
+ getIndicatorProps
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopexa/extension-controlref",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "A extension to show controls within our editor",
5
5
  "keywords": [
6
6
  "extension-controlref"
@@ -28,15 +28,15 @@
28
28
  "motion": ">=12.23.6",
29
29
  "react": ">=19.0.0-rc.0",
30
30
  "react-dom": ">=19.0.0-rc.0",
31
- "@kopexa/i18n": "1.0.0",
32
- "@kopexa/icons": "11.0.0",
33
- "@kopexa/sight": "9.0.0",
34
- "@kopexa/theme": "2.0.0"
31
+ "@kopexa/i18n": "2.0.0",
32
+ "@kopexa/icons": "12.0.0",
33
+ "@kopexa/sight": "10.0.0",
34
+ "@kopexa/theme": "2.1.0"
35
35
  },
36
36
  "dependencies": {
37
- "@tiptap/core": "^3.5.1",
38
- "@tiptap/pm": "^3.5.1",
39
- "@tiptap/react": "^3.5.1",
37
+ "@tiptap/core": "^3.6.1",
38
+ "@tiptap/pm": "3.6.1",
39
+ "@tiptap/react": "^3.6.1",
40
40
  "react-intl": "^7.1.11",
41
41
  "@kopexa/react-utils": "3.0.0",
42
42
  "@kopexa/shared-utils": "2.0.0"
@@ -58,6 +58,6 @@
58
58
  "dev": "pnpm build:fast --watch",
59
59
  "clean": "rimraf dist .turbo",
60
60
  "typecheck": "tsc --noEmit",
61
- "i18n:extract": "formatjs extract 'src/**/*.{ts,tsx}' --out-file src/i18n/en.json --id-interpolation-pattern '[sha512:contenthash:base64:6]' --format simple"
61
+ "i18n:extract": "formatjs extract \"src/**/*.{ts,tsx}\" --ignore \"**/*.test.*\" \"**/*.stories.*\" --format simple --out-file ../../core/i18n/tmp/$npm_package_name.en.json"
62
62
  }
63
63
  }
@@ -1,12 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ControlSummary, ControlRefOptions } from './types.mjs';
3
- import '@kopexa/theme';
4
-
5
- type CardVariantProps = {
6
- control: ControlSummary;
7
- options: ControlRefOptions;
8
- editable?: boolean;
9
- };
10
- declare const CardVariant: ({ control, options, editable, }: CardVariantProps) => react_jsx_runtime.JSX.Element;
11
-
12
- export { CardVariant };
@@ -1,12 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ControlSummary, ControlRefOptions } from './types.js';
3
- import '@kopexa/theme';
4
-
5
- type CardVariantProps = {
6
- control: ControlSummary;
7
- options: ControlRefOptions;
8
- editable?: boolean;
9
- };
10
- declare const CardVariant: ({ control, options, editable, }: CardVariantProps) => react_jsx_runtime.JSX.Element;
11
-
12
- export { CardVariant };
@@ -1,66 +0,0 @@
1
- "use client";
2
- "use strict";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/card-variant.tsx
22
- var card_variant_exports = {};
23
- __export(card_variant_exports, {
24
- CardVariant: () => CardVariant
25
- });
26
- module.exports = __toCommonJS(card_variant_exports);
27
- var import_sight = require("@kopexa/sight");
28
- var import_react = require("@tiptap/react");
29
- var import_jsx_runtime = require("react/jsx-runtime");
30
- var CardVariant = ({
31
- control,
32
- options,
33
- editable
34
- }) => {
35
- var _a, _b;
36
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
37
- import_sight.Card.Root,
38
- {
39
- shadow: options == null ? void 0 : options.cardShadow,
40
- border: options == null ? void 0 : options.cardBorder,
41
- radius: options == null ? void 0 : options.cardRadius,
42
- fullWidth: true,
43
- spacing: options == null ? void 0 : options.cardSpacing,
44
- isPressable: editable,
45
- className: "focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-primary/50",
46
- children: [
47
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_sight.Card.Header, { className: "flex items-start justify-between gap-2", children: [
48
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Heading, { contentEditable: false, children: (_a = control.title) != null ? _a : "Unmapped Control" }),
49
- control.status && control.status !== "default" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Chip, { size: "sm", variant: "bordered", indicator: true, contentEditable: false, children: control.status })
50
- ] }),
51
- (options == null ? void 0 : options.cardShowDescription) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Card.Body, { className: "bg-muted", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.NodeViewContent, { className: "content is-editable py-4", as: "div" }) }),
52
- (options == null ? void 0 : options.cardShowImplementations) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Card.Footer, { className: "flex flex-col gap-2", children: (control == null ? void 0 : control.implementations) && (control == null ? void 0 : control.implementations.length) === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm opacity-70", children: "No implementations" }) : (_b = control == null ? void 0 : control.implementations) == null ? void 0 : _b.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ImplementationCard, { impl: r }, r.id)) })
53
- ]
54
- }
55
- );
56
- };
57
- function ImplementationCard({ impl }) {
58
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Card.Root, { shadow: "2xs", border: "default", radius: "sm", spacing: "sm", fullWidth: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Card.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-1", children: [
59
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "font-medium", contentEditable: false, children: impl.title }),
60
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm text-foreground/60", contentEditable: false, children: "No description" })
61
- ] }) }) });
62
- }
63
- // Annotate the CommonJS export names for ESM import in node:
64
- 0 && (module.exports = {
65
- CardVariant
66
- });
@@ -1,8 +0,0 @@
1
- "use client";
2
- import {
3
- CardVariant
4
- } from "./chunk-NAJ6IC4Y.mjs";
5
- import "./chunk-GC5EBQ7G.mjs";
6
- export {
7
- CardVariant
8
- };