@tuicomponents/keyvalue 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 ADDED
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ KeyValueComponent: () => KeyValueComponent,
24
+ createKeyValue: () => createKeyValue,
25
+ keyValueInputSchema: () => keyValueInputSchema,
26
+ keyValuePairSchema: () => keyValuePairSchema,
27
+ separatorStyleSchema: () => separatorStyleSchema
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+
31
+ // src/keyvalue.ts
32
+ var import_core = require("@tuicomponents/core");
33
+ var import_zod_to_json_schema = require("zod-to-json-schema");
34
+
35
+ // src/schema.ts
36
+ var import_zod = require("zod");
37
+ var separatorStyleSchema = import_zod.z.enum([
38
+ "colon",
39
+ "equals",
40
+ "arrow",
41
+ "dots",
42
+ "none"
43
+ ]);
44
+ var keyValuePairSchema = import_zod.z.object({
45
+ /** Key/label for this pair */
46
+ key: import_zod.z.string(),
47
+ /** Value for this pair */
48
+ value: import_zod.z.union([import_zod.z.string(), import_zod.z.number(), import_zod.z.boolean()])
49
+ });
50
+ var keyValueInputSchema = import_zod.z.object({
51
+ /** Array of key-value pairs */
52
+ pairs: import_zod.z.array(keyValuePairSchema),
53
+ /** Separator between key and value */
54
+ separator: separatorStyleSchema.optional().default("colon"),
55
+ /** Align keys to the same width */
56
+ alignKeys: import_zod.z.boolean().optional().default(true),
57
+ /** Minimum key width (for alignment) */
58
+ minKeyWidth: import_zod.z.number().int().nonnegative().optional(),
59
+ /** Gap between key+separator and value */
60
+ gap: import_zod.z.number().int().nonnegative().optional().default(1)
61
+ });
62
+
63
+ // src/keyvalue.ts
64
+ function getSeparator(style) {
65
+ switch (style) {
66
+ case "colon":
67
+ return ":";
68
+ case "equals":
69
+ return "=";
70
+ case "arrow":
71
+ return "\u2192";
72
+ case "dots":
73
+ return "...";
74
+ case "none":
75
+ return "";
76
+ }
77
+ }
78
+ function colorKey(text, theme) {
79
+ if (!theme) {
80
+ return text;
81
+ }
82
+ return theme.semantic.header(text);
83
+ }
84
+ function colorSeparator(text, theme) {
85
+ if (!theme) {
86
+ return text;
87
+ }
88
+ return theme.semantic.secondary(text);
89
+ }
90
+ var KeyValueComponent = class extends import_core.BaseTuiComponent {
91
+ metadata = {
92
+ name: "keyvalue",
93
+ description: "Renders key-value pairs in an aligned format",
94
+ version: "0.1.0",
95
+ examples: [
96
+ {
97
+ name: "basic",
98
+ description: "Simple key-value pairs",
99
+ input: {
100
+ pairs: [
101
+ { key: "Name", value: "John Doe" },
102
+ { key: "Email", value: "john@example.com" },
103
+ { key: "Age", value: 30 }
104
+ ]
105
+ }
106
+ },
107
+ {
108
+ name: "equals-separator",
109
+ description: "Using equals sign as separator",
110
+ input: {
111
+ pairs: [
112
+ { key: "HOST", value: "localhost" },
113
+ { key: "PORT", value: 8080 },
114
+ { key: "DEBUG", value: true }
115
+ ],
116
+ separator: "equals"
117
+ }
118
+ },
119
+ {
120
+ name: "arrow-separator",
121
+ description: "Using arrow as separator",
122
+ input: {
123
+ pairs: [
124
+ { key: "Input", value: "data.json" },
125
+ { key: "Output", value: "results.csv" }
126
+ ],
127
+ separator: "arrow"
128
+ }
129
+ },
130
+ {
131
+ name: "dots-separator",
132
+ description: "Using dots as separator (config file style)",
133
+ input: {
134
+ pairs: [
135
+ { key: "Version", value: "1.0.0" },
136
+ { key: "Build", value: 12345 },
137
+ { key: "Status", value: "stable" }
138
+ ],
139
+ separator: "dots"
140
+ }
141
+ },
142
+ {
143
+ name: "no-alignment",
144
+ description: "Without key alignment",
145
+ input: {
146
+ pairs: [
147
+ { key: "Short", value: "value" },
148
+ { key: "A much longer key", value: "another value" }
149
+ ],
150
+ alignKeys: false
151
+ }
152
+ }
153
+ ]
154
+ };
155
+ schema = keyValueInputSchema;
156
+ /**
157
+ * Override getJsonSchema to use direct schema generation.
158
+ */
159
+ getJsonSchema() {
160
+ return (0, import_zod_to_json_schema.zodToJsonSchema)(this.schema, {
161
+ name: this.metadata.name,
162
+ $refStrategy: "none"
163
+ });
164
+ }
165
+ render(input, context) {
166
+ const parsed = this.schema.parse(input);
167
+ const separator = getSeparator(parsed.separator);
168
+ const gap = " ".repeat(parsed.gap);
169
+ const theme = context.theme;
170
+ let maxKeyWidth = parsed.minKeyWidth ?? 0;
171
+ if (parsed.alignKeys) {
172
+ for (const pair of parsed.pairs) {
173
+ const keyWidth = (0, import_core.getStringWidth)(pair.key);
174
+ if (keyWidth > maxKeyWidth) {
175
+ maxKeyWidth = keyWidth;
176
+ }
177
+ }
178
+ }
179
+ const lines = [];
180
+ for (const pair of parsed.pairs) {
181
+ const keyWidth = (0, import_core.getStringWidth)(pair.key);
182
+ const padding = parsed.alignKeys ? " ".repeat(Math.max(0, maxKeyWidth - keyWidth)) : "";
183
+ const valueStr = String(pair.value);
184
+ const coloredKey = colorKey(pair.key, theme);
185
+ if (separator) {
186
+ const coloredSep = colorSeparator(separator, theme);
187
+ lines.push(`${coloredKey}${padding}${coloredSep}${gap}${valueStr}`);
188
+ } else {
189
+ lines.push(`${coloredKey}${padding}${gap}${valueStr}`);
190
+ }
191
+ }
192
+ const output = lines.join("\n");
193
+ const measured = (0, import_core.measureLines)(output);
194
+ return {
195
+ output,
196
+ actualWidth: measured.maxWidth,
197
+ lineCount: measured.lineCount
198
+ };
199
+ }
200
+ };
201
+ function createKeyValue() {
202
+ return new KeyValueComponent();
203
+ }
204
+ import_core.registry.register(createKeyValue);
205
+ // Annotate the CommonJS export names for ESM import in node:
206
+ 0 && (module.exports = {
207
+ KeyValueComponent,
208
+ createKeyValue,
209
+ keyValueInputSchema,
210
+ keyValuePairSchema,
211
+ separatorStyleSchema
212
+ });
213
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/keyvalue.ts","../src/schema.ts"],"sourcesContent":["export { createKeyValue, KeyValueComponent } from \"./keyvalue.js\";\nexport {\n keyValueInputSchema,\n keyValuePairSchema,\n separatorStyleSchema,\n type KeyValueInput,\n type KeyValueInputWithDefaults,\n type KeyValuePair,\n type SeparatorStyle,\n} from \"./schema.js\";\n","import {\n BaseTuiComponent,\n type ComponentMetadata,\n type RenderContext,\n type RenderResult,\n type TuiTheme,\n getStringWidth,\n measureLines,\n registry,\n} from \"@tuicomponents/core\";\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\nimport {\n keyValueInputSchema,\n type KeyValueInput,\n type KeyValueInputWithDefaults,\n type SeparatorStyle,\n} from \"./schema.js\";\n\n/**\n * Get separator string for the given style.\n */\nfunction getSeparator(style: SeparatorStyle): string {\n switch (style) {\n case \"colon\":\n return \":\";\n case \"equals\":\n return \"=\";\n case \"arrow\":\n return \"→\";\n case \"dots\":\n return \"...\";\n case \"none\":\n return \"\";\n }\n}\n\n/**\n * Apply color to keys.\n */\nfunction colorKey(text: string, theme: TuiTheme | undefined): string {\n if (!theme) {\n return text;\n }\n return theme.semantic.header(text);\n}\n\n/**\n * Apply color to separators.\n */\nfunction colorSeparator(text: string, theme: TuiTheme | undefined): string {\n if (!theme) {\n return text;\n }\n return theme.semantic.secondary(text);\n}\n\n/**\n * KeyValue component for rendering labeled data pairs.\n */\nclass KeyValueComponent extends BaseTuiComponent<\n KeyValueInput,\n typeof keyValueInputSchema\n> {\n readonly metadata: ComponentMetadata<KeyValueInput> = {\n name: \"keyvalue\",\n description: \"Renders key-value pairs in an aligned format\",\n version: \"0.1.0\",\n examples: [\n {\n name: \"basic\",\n description: \"Simple key-value pairs\",\n input: {\n pairs: [\n { key: \"Name\", value: \"John Doe\" },\n { key: \"Email\", value: \"john@example.com\" },\n { key: \"Age\", value: 30 },\n ],\n },\n },\n {\n name: \"equals-separator\",\n description: \"Using equals sign as separator\",\n input: {\n pairs: [\n { key: \"HOST\", value: \"localhost\" },\n { key: \"PORT\", value: 8080 },\n { key: \"DEBUG\", value: true },\n ],\n separator: \"equals\",\n },\n },\n {\n name: \"arrow-separator\",\n description: \"Using arrow as separator\",\n input: {\n pairs: [\n { key: \"Input\", value: \"data.json\" },\n { key: \"Output\", value: \"results.csv\" },\n ],\n separator: \"arrow\",\n },\n },\n {\n name: \"dots-separator\",\n description: \"Using dots as separator (config file style)\",\n input: {\n pairs: [\n { key: \"Version\", value: \"1.0.0\" },\n { key: \"Build\", value: 12345 },\n { key: \"Status\", value: \"stable\" },\n ],\n separator: \"dots\",\n },\n },\n {\n name: \"no-alignment\",\n description: \"Without key alignment\",\n input: {\n pairs: [\n { key: \"Short\", value: \"value\" },\n { key: \"A much longer key\", value: \"another value\" },\n ],\n alignKeys: false,\n },\n },\n ],\n };\n\n readonly schema = keyValueInputSchema;\n\n /**\n * Override getJsonSchema to use direct schema generation.\n */\n override getJsonSchema(): object {\n return zodToJsonSchema(this.schema, {\n name: this.metadata.name,\n $refStrategy: \"none\",\n });\n }\n\n render(input: KeyValueInput, context: RenderContext): RenderResult {\n // Parse and apply defaults\n const parsed: KeyValueInputWithDefaults = this.schema.parse(input);\n const separator = getSeparator(parsed.separator);\n const gap = \" \".repeat(parsed.gap);\n const theme = context.theme;\n\n // Calculate max key width for alignment\n let maxKeyWidth = parsed.minKeyWidth ?? 0;\n if (parsed.alignKeys) {\n for (const pair of parsed.pairs) {\n const keyWidth = getStringWidth(pair.key);\n if (keyWidth > maxKeyWidth) {\n maxKeyWidth = keyWidth;\n }\n }\n }\n\n const lines: string[] = [];\n\n for (const pair of parsed.pairs) {\n const keyWidth = getStringWidth(pair.key);\n const padding = parsed.alignKeys\n ? \" \".repeat(Math.max(0, maxKeyWidth - keyWidth))\n : \"\";\n\n // Format value as string\n const valueStr = String(pair.value);\n\n // Build the line with colored key and separator\n const coloredKey = colorKey(pair.key, theme);\n if (separator) {\n const coloredSep = colorSeparator(separator, theme);\n lines.push(`${coloredKey}${padding}${coloredSep}${gap}${valueStr}`);\n } else {\n lines.push(`${coloredKey}${padding}${gap}${valueStr}`);\n }\n }\n\n const output = lines.join(\"\\n\");\n const measured = measureLines(output);\n\n return {\n output,\n actualWidth: measured.maxWidth,\n lineCount: measured.lineCount,\n };\n }\n}\n\n/**\n * Factory function to create a keyvalue component.\n */\nexport function createKeyValue(): KeyValueComponent {\n return new KeyValueComponent();\n}\n\n// Register with global registry\nregistry.register(createKeyValue);\n\nexport { KeyValueComponent };\n","import { z } from \"zod\";\n\n/**\n * Separator style options.\n */\nexport const separatorStyleSchema = z.enum([\n \"colon\",\n \"equals\",\n \"arrow\",\n \"dots\",\n \"none\",\n]);\n\nexport type SeparatorStyle = z.infer<typeof separatorStyleSchema>;\n\n/**\n * Schema for a single key-value pair.\n */\nexport const keyValuePairSchema = z.object({\n /** Key/label for this pair */\n key: z.string(),\n /** Value for this pair */\n value: z.union([z.string(), z.number(), z.boolean()]),\n});\n\nexport type KeyValuePair = z.infer<typeof keyValuePairSchema>;\n\n/**\n * Schema for keyvalue component input.\n */\nexport const keyValueInputSchema = z.object({\n /** Array of key-value pairs */\n pairs: z.array(keyValuePairSchema),\n /** Separator between key and value */\n separator: separatorStyleSchema.optional().default(\"colon\"),\n /** Align keys to the same width */\n alignKeys: z.boolean().optional().default(true),\n /** Minimum key width (for alignment) */\n minKeyWidth: z.number().int().nonnegative().optional(),\n /** Gap between key+separator and value */\n gap: z.number().int().nonnegative().optional().default(1),\n});\n\n/**\n * Input type (before defaults applied).\n */\nexport type KeyValueInput = z.input<typeof keyValueInputSchema>;\n\n/**\n * Input type (after defaults applied).\n */\nexport type KeyValueInputWithDefaults = z.output<typeof keyValueInputSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBASO;AACP,gCAAgC;;;ACVhC,iBAAkB;AAKX,IAAM,uBAAuB,aAAE,KAAK;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAOM,IAAM,qBAAqB,aAAE,OAAO;AAAA;AAAA,EAEzC,KAAK,aAAE,OAAO;AAAA;AAAA,EAEd,OAAO,aAAE,MAAM,CAAC,aAAE,OAAO,GAAG,aAAE,OAAO,GAAG,aAAE,QAAQ,CAAC,CAAC;AACtD,CAAC;AAOM,IAAM,sBAAsB,aAAE,OAAO;AAAA;AAAA,EAE1C,OAAO,aAAE,MAAM,kBAAkB;AAAA;AAAA,EAEjC,WAAW,qBAAqB,SAAS,EAAE,QAAQ,OAAO;AAAA;AAAA,EAE1D,WAAW,aAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,IAAI;AAAA;AAAA,EAE9C,aAAa,aAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS;AAAA;AAAA,EAErD,KAAK,aAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC;AAC1D,CAAC;;;ADpBD,SAAS,aAAa,OAA+B;AACnD,UAAQ,OAAO;AAAA,IACb,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA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AAG,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,GAAG,GAAG,QAAQ,EAAE;AAAA,MACpE,OAAO;AACL,cAAM,KAAK,GAAG,UAAU,GAAG,OAAO,GAAG,GAAG,GAAG,QAAQ,EAAE;AAAA,MACvD;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,KAAK,IAAI;AAC9B,UAAM,eAAW,0BAAa,MAAM;AAEpC,WAAO;AAAA,MACL;AAAA,MACA,aAAa,SAAS;AAAA,MACtB,WAAW,SAAS;AAAA,IACtB;AAAA,EACF;AACF;AAKO,SAAS,iBAAoC;AAClD,SAAO,IAAI,kBAAkB;AAC/B;AAGA,qBAAS,SAAS,cAAc;","names":[]}
@@ -0,0 +1,129 @@
1
+ import * as zod from 'zod';
2
+ import { z } from 'zod';
3
+ import { BaseTuiComponent, ComponentMetadata, RenderContext, RenderResult } from '@tuicomponents/core';
4
+
5
+ /**
6
+ * Separator style options.
7
+ */
8
+ declare const separatorStyleSchema: z.ZodEnum<["colon", "equals", "arrow", "dots", "none"]>;
9
+ type SeparatorStyle = z.infer<typeof separatorStyleSchema>;
10
+ /**
11
+ * Schema for a single key-value pair.
12
+ */
13
+ declare const keyValuePairSchema: z.ZodObject<{
14
+ /** Key/label for this pair */
15
+ key: z.ZodString;
16
+ /** Value for this pair */
17
+ value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ value: string | number | boolean;
20
+ key: string;
21
+ }, {
22
+ value: string | number | boolean;
23
+ key: string;
24
+ }>;
25
+ type KeyValuePair = z.infer<typeof keyValuePairSchema>;
26
+ /**
27
+ * Schema for keyvalue component input.
28
+ */
29
+ declare const keyValueInputSchema: z.ZodObject<{
30
+ /** Array of key-value pairs */
31
+ pairs: z.ZodArray<z.ZodObject<{
32
+ /** Key/label for this pair */
33
+ key: z.ZodString;
34
+ /** Value for this pair */
35
+ value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ value: string | number | boolean;
38
+ key: string;
39
+ }, {
40
+ value: string | number | boolean;
41
+ key: string;
42
+ }>, "many">;
43
+ /** Separator between key and value */
44
+ separator: z.ZodDefault<z.ZodOptional<z.ZodEnum<["colon", "equals", "arrow", "dots", "none"]>>>;
45
+ /** Align keys to the same width */
46
+ alignKeys: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
47
+ /** Minimum key width (for alignment) */
48
+ minKeyWidth: z.ZodOptional<z.ZodNumber>;
49
+ /** Gap between key+separator and value */
50
+ gap: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
51
+ }, "strip", z.ZodTypeAny, {
52
+ pairs: {
53
+ value: string | number | boolean;
54
+ key: string;
55
+ }[];
56
+ separator: "colon" | "equals" | "arrow" | "dots" | "none";
57
+ alignKeys: boolean;
58
+ gap: number;
59
+ minKeyWidth?: number | undefined;
60
+ }, {
61
+ pairs: {
62
+ value: string | number | boolean;
63
+ key: string;
64
+ }[];
65
+ separator?: "colon" | "equals" | "arrow" | "dots" | "none" | undefined;
66
+ alignKeys?: boolean | undefined;
67
+ minKeyWidth?: number | undefined;
68
+ gap?: number | undefined;
69
+ }>;
70
+ /**
71
+ * Input type (before defaults applied).
72
+ */
73
+ type KeyValueInput = z.input<typeof keyValueInputSchema>;
74
+ /**
75
+ * Input type (after defaults applied).
76
+ */
77
+ type KeyValueInputWithDefaults = z.output<typeof keyValueInputSchema>;
78
+
79
+ /**
80
+ * KeyValue component for rendering labeled data pairs.
81
+ */
82
+ declare class KeyValueComponent extends BaseTuiComponent<KeyValueInput, typeof keyValueInputSchema> {
83
+ readonly metadata: ComponentMetadata<KeyValueInput>;
84
+ readonly schema: zod.ZodObject<{
85
+ pairs: zod.ZodArray<zod.ZodObject<{
86
+ key: zod.ZodString;
87
+ value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
88
+ }, "strip", zod.ZodTypeAny, {
89
+ value: string | number | boolean;
90
+ key: string;
91
+ }, {
92
+ value: string | number | boolean;
93
+ key: string;
94
+ }>, "many">;
95
+ separator: zod.ZodDefault<zod.ZodOptional<zod.ZodEnum<["colon", "equals", "arrow", "dots", "none"]>>>;
96
+ alignKeys: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
97
+ minKeyWidth: zod.ZodOptional<zod.ZodNumber>;
98
+ gap: zod.ZodDefault<zod.ZodOptional<zod.ZodNumber>>;
99
+ }, "strip", zod.ZodTypeAny, {
100
+ pairs: {
101
+ value: string | number | boolean;
102
+ key: string;
103
+ }[];
104
+ separator: "colon" | "equals" | "arrow" | "dots" | "none";
105
+ alignKeys: boolean;
106
+ gap: number;
107
+ minKeyWidth?: number | undefined;
108
+ }, {
109
+ pairs: {
110
+ value: string | number | boolean;
111
+ key: string;
112
+ }[];
113
+ separator?: "colon" | "equals" | "arrow" | "dots" | "none" | undefined;
114
+ alignKeys?: boolean | undefined;
115
+ minKeyWidth?: number | undefined;
116
+ gap?: number | undefined;
117
+ }>;
118
+ /**
119
+ * Override getJsonSchema to use direct schema generation.
120
+ */
121
+ getJsonSchema(): object;
122
+ render(input: KeyValueInput, context: RenderContext): RenderResult;
123
+ }
124
+ /**
125
+ * Factory function to create a keyvalue component.
126
+ */
127
+ declare function createKeyValue(): KeyValueComponent;
128
+
129
+ export { KeyValueComponent, type KeyValueInput, type KeyValueInputWithDefaults, type KeyValuePair, type SeparatorStyle, createKeyValue, keyValueInputSchema, keyValuePairSchema, separatorStyleSchema };
@@ -0,0 +1,129 @@
1
+ import * as zod from 'zod';
2
+ import { z } from 'zod';
3
+ import { BaseTuiComponent, ComponentMetadata, RenderContext, RenderResult } from '@tuicomponents/core';
4
+
5
+ /**
6
+ * Separator style options.
7
+ */
8
+ declare const separatorStyleSchema: z.ZodEnum<["colon", "equals", "arrow", "dots", "none"]>;
9
+ type SeparatorStyle = z.infer<typeof separatorStyleSchema>;
10
+ /**
11
+ * Schema for a single key-value pair.
12
+ */
13
+ declare const keyValuePairSchema: z.ZodObject<{
14
+ /** Key/label for this pair */
15
+ key: z.ZodString;
16
+ /** Value for this pair */
17
+ value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ value: string | number | boolean;
20
+ key: string;
21
+ }, {
22
+ value: string | number | boolean;
23
+ key: string;
24
+ }>;
25
+ type KeyValuePair = z.infer<typeof keyValuePairSchema>;
26
+ /**
27
+ * Schema for keyvalue component input.
28
+ */
29
+ declare const keyValueInputSchema: z.ZodObject<{
30
+ /** Array of key-value pairs */
31
+ pairs: z.ZodArray<z.ZodObject<{
32
+ /** Key/label for this pair */
33
+ key: z.ZodString;
34
+ /** Value for this pair */
35
+ value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ value: string | number | boolean;
38
+ key: string;
39
+ }, {
40
+ value: string | number | boolean;
41
+ key: string;
42
+ }>, "many">;
43
+ /** Separator between key and value */
44
+ separator: z.ZodDefault<z.ZodOptional<z.ZodEnum<["colon", "equals", "arrow", "dots", "none"]>>>;
45
+ /** Align keys to the same width */
46
+ alignKeys: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
47
+ /** Minimum key width (for alignment) */
48
+ minKeyWidth: z.ZodOptional<z.ZodNumber>;
49
+ /** Gap between key+separator and value */
50
+ gap: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
51
+ }, "strip", z.ZodTypeAny, {
52
+ pairs: {
53
+ value: string | number | boolean;
54
+ key: string;
55
+ }[];
56
+ separator: "colon" | "equals" | "arrow" | "dots" | "none";
57
+ alignKeys: boolean;
58
+ gap: number;
59
+ minKeyWidth?: number | undefined;
60
+ }, {
61
+ pairs: {
62
+ value: string | number | boolean;
63
+ key: string;
64
+ }[];
65
+ separator?: "colon" | "equals" | "arrow" | "dots" | "none" | undefined;
66
+ alignKeys?: boolean | undefined;
67
+ minKeyWidth?: number | undefined;
68
+ gap?: number | undefined;
69
+ }>;
70
+ /**
71
+ * Input type (before defaults applied).
72
+ */
73
+ type KeyValueInput = z.input<typeof keyValueInputSchema>;
74
+ /**
75
+ * Input type (after defaults applied).
76
+ */
77
+ type KeyValueInputWithDefaults = z.output<typeof keyValueInputSchema>;
78
+
79
+ /**
80
+ * KeyValue component for rendering labeled data pairs.
81
+ */
82
+ declare class KeyValueComponent extends BaseTuiComponent<KeyValueInput, typeof keyValueInputSchema> {
83
+ readonly metadata: ComponentMetadata<KeyValueInput>;
84
+ readonly schema: zod.ZodObject<{
85
+ pairs: zod.ZodArray<zod.ZodObject<{
86
+ key: zod.ZodString;
87
+ value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
88
+ }, "strip", zod.ZodTypeAny, {
89
+ value: string | number | boolean;
90
+ key: string;
91
+ }, {
92
+ value: string | number | boolean;
93
+ key: string;
94
+ }>, "many">;
95
+ separator: zod.ZodDefault<zod.ZodOptional<zod.ZodEnum<["colon", "equals", "arrow", "dots", "none"]>>>;
96
+ alignKeys: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
97
+ minKeyWidth: zod.ZodOptional<zod.ZodNumber>;
98
+ gap: zod.ZodDefault<zod.ZodOptional<zod.ZodNumber>>;
99
+ }, "strip", zod.ZodTypeAny, {
100
+ pairs: {
101
+ value: string | number | boolean;
102
+ key: string;
103
+ }[];
104
+ separator: "colon" | "equals" | "arrow" | "dots" | "none";
105
+ alignKeys: boolean;
106
+ gap: number;
107
+ minKeyWidth?: number | undefined;
108
+ }, {
109
+ pairs: {
110
+ value: string | number | boolean;
111
+ key: string;
112
+ }[];
113
+ separator?: "colon" | "equals" | "arrow" | "dots" | "none" | undefined;
114
+ alignKeys?: boolean | undefined;
115
+ minKeyWidth?: number | undefined;
116
+ gap?: number | undefined;
117
+ }>;
118
+ /**
119
+ * Override getJsonSchema to use direct schema generation.
120
+ */
121
+ getJsonSchema(): object;
122
+ render(input: KeyValueInput, context: RenderContext): RenderResult;
123
+ }
124
+ /**
125
+ * Factory function to create a keyvalue component.
126
+ */
127
+ declare function createKeyValue(): KeyValueComponent;
128
+
129
+ export { KeyValueComponent, type KeyValueInput, type KeyValueInputWithDefaults, type KeyValuePair, type SeparatorStyle, createKeyValue, keyValueInputSchema, keyValuePairSchema, separatorStyleSchema };
package/dist/index.js ADDED
@@ -0,0 +1,187 @@
1
+ // src/keyvalue.ts
2
+ import {
3
+ BaseTuiComponent,
4
+ getStringWidth,
5
+ measureLines,
6
+ registry
7
+ } from "@tuicomponents/core";
8
+ import { zodToJsonSchema } from "zod-to-json-schema";
9
+
10
+ // src/schema.ts
11
+ import { z } from "zod";
12
+ var separatorStyleSchema = z.enum([
13
+ "colon",
14
+ "equals",
15
+ "arrow",
16
+ "dots",
17
+ "none"
18
+ ]);
19
+ var keyValuePairSchema = z.object({
20
+ /** Key/label for this pair */
21
+ key: z.string(),
22
+ /** Value for this pair */
23
+ value: z.union([z.string(), z.number(), z.boolean()])
24
+ });
25
+ var keyValueInputSchema = z.object({
26
+ /** Array of key-value pairs */
27
+ pairs: z.array(keyValuePairSchema),
28
+ /** Separator between key and value */
29
+ separator: separatorStyleSchema.optional().default("colon"),
30
+ /** Align keys to the same width */
31
+ alignKeys: z.boolean().optional().default(true),
32
+ /** Minimum key width (for alignment) */
33
+ minKeyWidth: z.number().int().nonnegative().optional(),
34
+ /** Gap between key+separator and value */
35
+ gap: z.number().int().nonnegative().optional().default(1)
36
+ });
37
+
38
+ // src/keyvalue.ts
39
+ function getSeparator(style) {
40
+ switch (style) {
41
+ case "colon":
42
+ return ":";
43
+ case "equals":
44
+ return "=";
45
+ case "arrow":
46
+ return "\u2192";
47
+ case "dots":
48
+ return "...";
49
+ case "none":
50
+ return "";
51
+ }
52
+ }
53
+ function colorKey(text, theme) {
54
+ if (!theme) {
55
+ return text;
56
+ }
57
+ return theme.semantic.header(text);
58
+ }
59
+ function colorSeparator(text, theme) {
60
+ if (!theme) {
61
+ return text;
62
+ }
63
+ return theme.semantic.secondary(text);
64
+ }
65
+ var KeyValueComponent = class extends BaseTuiComponent {
66
+ metadata = {
67
+ name: "keyvalue",
68
+ description: "Renders key-value pairs in an aligned format",
69
+ version: "0.1.0",
70
+ examples: [
71
+ {
72
+ name: "basic",
73
+ description: "Simple key-value pairs",
74
+ input: {
75
+ pairs: [
76
+ { key: "Name", value: "John Doe" },
77
+ { key: "Email", value: "john@example.com" },
78
+ { key: "Age", value: 30 }
79
+ ]
80
+ }
81
+ },
82
+ {
83
+ name: "equals-separator",
84
+ description: "Using equals sign as separator",
85
+ input: {
86
+ pairs: [
87
+ { key: "HOST", value: "localhost" },
88
+ { key: "PORT", value: 8080 },
89
+ { key: "DEBUG", value: true }
90
+ ],
91
+ separator: "equals"
92
+ }
93
+ },
94
+ {
95
+ name: "arrow-separator",
96
+ description: "Using arrow as separator",
97
+ input: {
98
+ pairs: [
99
+ { key: "Input", value: "data.json" },
100
+ { key: "Output", value: "results.csv" }
101
+ ],
102
+ separator: "arrow"
103
+ }
104
+ },
105
+ {
106
+ name: "dots-separator",
107
+ description: "Using dots as separator (config file style)",
108
+ input: {
109
+ pairs: [
110
+ { key: "Version", value: "1.0.0" },
111
+ { key: "Build", value: 12345 },
112
+ { key: "Status", value: "stable" }
113
+ ],
114
+ separator: "dots"
115
+ }
116
+ },
117
+ {
118
+ name: "no-alignment",
119
+ description: "Without key alignment",
120
+ input: {
121
+ pairs: [
122
+ { key: "Short", value: "value" },
123
+ { key: "A much longer key", value: "another value" }
124
+ ],
125
+ alignKeys: false
126
+ }
127
+ }
128
+ ]
129
+ };
130
+ schema = keyValueInputSchema;
131
+ /**
132
+ * Override getJsonSchema to use direct schema generation.
133
+ */
134
+ getJsonSchema() {
135
+ return zodToJsonSchema(this.schema, {
136
+ name: this.metadata.name,
137
+ $refStrategy: "none"
138
+ });
139
+ }
140
+ render(input, context) {
141
+ const parsed = this.schema.parse(input);
142
+ const separator = getSeparator(parsed.separator);
143
+ const gap = " ".repeat(parsed.gap);
144
+ const theme = context.theme;
145
+ let maxKeyWidth = parsed.minKeyWidth ?? 0;
146
+ if (parsed.alignKeys) {
147
+ for (const pair of parsed.pairs) {
148
+ const keyWidth = getStringWidth(pair.key);
149
+ if (keyWidth > maxKeyWidth) {
150
+ maxKeyWidth = keyWidth;
151
+ }
152
+ }
153
+ }
154
+ const lines = [];
155
+ for (const pair of parsed.pairs) {
156
+ const keyWidth = getStringWidth(pair.key);
157
+ const padding = parsed.alignKeys ? " ".repeat(Math.max(0, maxKeyWidth - keyWidth)) : "";
158
+ const valueStr = String(pair.value);
159
+ const coloredKey = colorKey(pair.key, theme);
160
+ if (separator) {
161
+ const coloredSep = colorSeparator(separator, theme);
162
+ lines.push(`${coloredKey}${padding}${coloredSep}${gap}${valueStr}`);
163
+ } else {
164
+ lines.push(`${coloredKey}${padding}${gap}${valueStr}`);
165
+ }
166
+ }
167
+ const output = lines.join("\n");
168
+ const measured = measureLines(output);
169
+ return {
170
+ output,
171
+ actualWidth: measured.maxWidth,
172
+ lineCount: measured.lineCount
173
+ };
174
+ }
175
+ };
176
+ function createKeyValue() {
177
+ return new KeyValueComponent();
178
+ }
179
+ registry.register(createKeyValue);
180
+ export {
181
+ KeyValueComponent,
182
+ createKeyValue,
183
+ keyValueInputSchema,
184
+ keyValuePairSchema,
185
+ separatorStyleSchema
186
+ };
187
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/keyvalue.ts","../src/schema.ts"],"sourcesContent":["import {\n BaseTuiComponent,\n type ComponentMetadata,\n type RenderContext,\n type RenderResult,\n type TuiTheme,\n getStringWidth,\n measureLines,\n registry,\n} from \"@tuicomponents/core\";\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\nimport {\n keyValueInputSchema,\n type KeyValueInput,\n type KeyValueInputWithDefaults,\n type SeparatorStyle,\n} from \"./schema.js\";\n\n/**\n * Get separator string for the given style.\n */\nfunction getSeparator(style: SeparatorStyle): string {\n switch (style) {\n case \"colon\":\n return \":\";\n case \"equals\":\n return \"=\";\n case \"arrow\":\n return \"→\";\n case \"dots\":\n return \"...\";\n case \"none\":\n return \"\";\n }\n}\n\n/**\n * Apply color to keys.\n */\nfunction colorKey(text: string, theme: TuiTheme | undefined): string {\n if (!theme) {\n return text;\n }\n return theme.semantic.header(text);\n}\n\n/**\n * Apply color to separators.\n */\nfunction colorSeparator(text: string, theme: TuiTheme | undefined): string {\n if (!theme) {\n return text;\n }\n return theme.semantic.secondary(text);\n}\n\n/**\n * KeyValue component for rendering labeled data pairs.\n */\nclass KeyValueComponent extends BaseTuiComponent<\n KeyValueInput,\n typeof keyValueInputSchema\n> {\n readonly metadata: ComponentMetadata<KeyValueInput> = {\n name: \"keyvalue\",\n description: \"Renders key-value pairs in an aligned format\",\n version: \"0.1.0\",\n examples: [\n {\n name: \"basic\",\n description: \"Simple key-value pairs\",\n input: {\n pairs: [\n { key: \"Name\", value: \"John Doe\" },\n { key: \"Email\", value: \"john@example.com\" },\n { key: \"Age\", value: 30 },\n ],\n },\n },\n {\n name: \"equals-separator\",\n description: \"Using equals sign as separator\",\n input: {\n pairs: [\n { key: \"HOST\", value: \"localhost\" },\n { key: \"PORT\", value: 8080 },\n { key: \"DEBUG\", value: true },\n ],\n separator: \"equals\",\n },\n },\n {\n name: \"arrow-separator\",\n description: \"Using arrow as separator\",\n input: {\n pairs: [\n { key: \"Input\", value: \"data.json\" },\n { key: \"Output\", value: \"results.csv\" },\n ],\n separator: \"arrow\",\n },\n },\n {\n name: \"dots-separator\",\n description: \"Using dots as separator (config file style)\",\n input: {\n pairs: [\n { key: \"Version\", value: \"1.0.0\" },\n { key: \"Build\", value: 12345 },\n { key: \"Status\", value: \"stable\" },\n ],\n separator: \"dots\",\n },\n },\n {\n name: \"no-alignment\",\n description: \"Without key alignment\",\n input: {\n pairs: [\n { key: \"Short\", value: \"value\" },\n { key: \"A much longer key\", value: \"another value\" },\n ],\n alignKeys: false,\n },\n },\n ],\n };\n\n readonly schema = keyValueInputSchema;\n\n /**\n * Override getJsonSchema to use direct schema generation.\n */\n override getJsonSchema(): object {\n return zodToJsonSchema(this.schema, {\n name: this.metadata.name,\n $refStrategy: \"none\",\n });\n }\n\n render(input: KeyValueInput, context: RenderContext): RenderResult {\n // Parse and apply defaults\n const parsed: KeyValueInputWithDefaults = this.schema.parse(input);\n const separator = getSeparator(parsed.separator);\n const gap = \" \".repeat(parsed.gap);\n const theme = context.theme;\n\n // Calculate max key width for alignment\n let maxKeyWidth = parsed.minKeyWidth ?? 0;\n if (parsed.alignKeys) {\n for (const pair of parsed.pairs) {\n const keyWidth = getStringWidth(pair.key);\n if (keyWidth > maxKeyWidth) {\n maxKeyWidth = keyWidth;\n }\n }\n }\n\n const lines: string[] = [];\n\n for (const pair of parsed.pairs) {\n const keyWidth = getStringWidth(pair.key);\n const padding = parsed.alignKeys\n ? \" \".repeat(Math.max(0, maxKeyWidth - keyWidth))\n : \"\";\n\n // Format value as string\n const valueStr = String(pair.value);\n\n // Build the line with colored key and separator\n const coloredKey = colorKey(pair.key, theme);\n if (separator) {\n const coloredSep = colorSeparator(separator, theme);\n lines.push(`${coloredKey}${padding}${coloredSep}${gap}${valueStr}`);\n } else {\n lines.push(`${coloredKey}${padding}${gap}${valueStr}`);\n }\n }\n\n const output = lines.join(\"\\n\");\n const measured = measureLines(output);\n\n return {\n output,\n actualWidth: measured.maxWidth,\n lineCount: measured.lineCount,\n };\n }\n}\n\n/**\n * Factory function to create a keyvalue component.\n */\nexport function createKeyValue(): KeyValueComponent {\n return new KeyValueComponent();\n}\n\n// Register with global registry\nregistry.register(createKeyValue);\n\nexport { KeyValueComponent };\n","import { z } from \"zod\";\n\n/**\n * Separator style options.\n */\nexport const separatorStyleSchema = z.enum([\n \"colon\",\n \"equals\",\n \"arrow\",\n \"dots\",\n \"none\",\n]);\n\nexport type SeparatorStyle = z.infer<typeof separatorStyleSchema>;\n\n/**\n * Schema for a single key-value pair.\n */\nexport const keyValuePairSchema = z.object({\n /** Key/label for this pair */\n key: z.string(),\n /** Value for this pair */\n value: z.union([z.string(), z.number(), z.boolean()]),\n});\n\nexport type KeyValuePair = z.infer<typeof keyValuePairSchema>;\n\n/**\n * Schema for keyvalue component input.\n */\nexport const keyValueInputSchema = z.object({\n /** Array of key-value pairs */\n pairs: z.array(keyValuePairSchema),\n /** Separator between key and value */\n separator: separatorStyleSchema.optional().default(\"colon\"),\n /** Align keys to the same width */\n alignKeys: z.boolean().optional().default(true),\n /** Minimum key width (for alignment) */\n minKeyWidth: z.number().int().nonnegative().optional(),\n /** Gap between key+separator and value */\n gap: z.number().int().nonnegative().optional().default(1),\n});\n\n/**\n * Input type (before defaults applied).\n */\nexport type KeyValueInput = z.input<typeof keyValueInputSchema>;\n\n/**\n * Input type (after defaults applied).\n */\nexport type KeyValueInputWithDefaults = z.output<typeof keyValueInputSchema>;\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAKA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;;;ACVhC,SAAS,SAAS;AAKX,IAAM,uBAAuB,EAAE,KAAK;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAOM,IAAM,qBAAqB,EAAE,OAAO;AAAA;AAAA,EAEzC,KAAK,EAAE,OAAO;AAAA;AAAA,EAEd,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC;AAOM,IAAM,sBAAsB,EAAE,OAAO;AAAA;AAAA,EAE1C,OAAO,EAAE,MAAM,kBAAkB;AAAA;AAAA,EAEjC,WAAW,qBAAqB,SAAS,EAAE,QAAQ,OAAO;AAAA;AAAA,EAE1D,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,IAAI;AAAA;AAAA,EAE9C,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS;AAAA;AAAA,EAErD,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C/B,YAAM,WAAW,eAAe,KAAK,GAAG;AACxC,YAAM,UAAU,OAAO,YACnB,IAAI,OAAO,KAAK,IAAI,GAAG,cAAc,QAAQ,CAAC,IAC9C;AAGJ,YAAM,WAAW,OAAO,KAAK,KAAK;AAGlC,YAAM,aAAa,SAAS,KAAK,KAAK,KAAK;AAC3C,UAAI,WAAW;AACb,cAAM,aAAa,eAAe,WAAW,KAAK;AAClD,cAAM,KAAK,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,GAAG,GAAG,QAAQ,EAAE;AAAA,MACpE,OAAO;AACL,cAAM,KAAK,GAAG,UAAU,GAAG,OAAO,GAAG,GAAG,GAAG,QAAQ,EAAE;AAAA,MACvD;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,KAAK,IAAI;AAC9B,UAAM,WAAW,aAAa,MAAM;AAEpC,WAAO;AAAA,MACL;AAAA,MACA,aAAa,SAAS;AAAA,MACtB,WAAW,SAAS;AAAA,IACtB;AAAA,EACF;AACF;AAKO,SAAS,iBAAoC;AAClD,SAAO,IAAI,kBAAkB;AAC/B;AAGA,SAAS,SAAS,cAAc;","names":[]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@tuicomponents/keyvalue",
3
+ "version": "0.1.1",
4
+ "description": "Key-value component for TUI - renders labeled data pairs",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "keywords": [
25
+ "tui",
26
+ "terminal",
27
+ "keyvalue",
28
+ "properties"
29
+ ],
30
+ "license": "UNLICENSED",
31
+ "dependencies": {
32
+ "zod": "^3.24.0",
33
+ "zod-to-json-schema": "^3.24.0",
34
+ "@tuicomponents/core": "0.1.1"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^22.0.0"
38
+ },
39
+ "scripts": {
40
+ "build": "tsup",
41
+ "typecheck": "tsc --noEmit",
42
+ "lint": "eslint src",
43
+ "test": "vitest run",
44
+ "test:watch": "vitest",
45
+ "api-report": "api-extractor run",
46
+ "api-report:update": "api-extractor run --local",
47
+ "clean": "rm -rf dist"
48
+ }
49
+ }