@kokimoki/kit 1.6.6 → 1.6.7
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.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/kokimoki-kit-plugin.js +20 -11
- package/dist/preprocess-style.js +13 -14
- package/dist/preprocess-style.spec.js +1 -1
- package/dist/schema-builder.d.ts +89 -74
- package/dist/schema-builder.js +149 -132
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/zod.d.ts +1 -0
- package/dist/zod.js +5 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./kokimoki-kit-plugin"), exports);
|
|
18
18
|
__exportStar(require("./preprocess-style"), exports);
|
|
19
|
+
// Re-export Zod utilities for schema definition
|
|
20
|
+
__exportStar(require("./zod"), exports);
|
|
@@ -15,24 +15,34 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.kokimokiKitPlugin =
|
|
39
|
+
exports.kokimokiKitPlugin = kokimokiKitPlugin;
|
|
30
40
|
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
31
41
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
32
|
-
const preprocess_style_1 = require("./preprocess-style");
|
|
33
|
-
const version_1 = require("./version");
|
|
34
42
|
const yaml = __importStar(require("yaml"));
|
|
35
43
|
const v4_1 = require("zod/v4");
|
|
44
|
+
const preprocess_style_1 = require("./preprocess-style");
|
|
45
|
+
const version_1 = require("./version");
|
|
36
46
|
function kokimokiKitPlugin(config) {
|
|
37
47
|
return {
|
|
38
48
|
name: "kokimoki-kit",
|
|
@@ -212,4 +222,3 @@ function kokimokiKitPlugin(config) {
|
|
|
212
222
|
},
|
|
213
223
|
};
|
|
214
224
|
}
|
|
215
|
-
exports.kokimokiKitPlugin = kokimokiKitPlugin;
|
package/dist/preprocess-style.js
CHANGED
|
@@ -3,9 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.hexToRgb = hexToRgb;
|
|
7
|
+
exports.rgbToHex = rgbToHex;
|
|
8
|
+
exports.revertReplaceForColorPickers = revertReplaceForColorPickers;
|
|
9
|
+
exports.hexToTailwindRgbString = hexToTailwindRgbString;
|
|
10
|
+
exports.getLuminance = getLuminance;
|
|
11
|
+
exports.calculateRatio = calculateRatio;
|
|
12
|
+
exports.handleStringColor = handleStringColor;
|
|
13
|
+
exports.destringRgb = destringRgb;
|
|
14
|
+
exports.generateA11yOnColor = generateA11yOnColor;
|
|
15
|
+
exports.generatePalette = generatePalette;
|
|
16
|
+
exports.preprocessStyle = preprocessStyle;
|
|
8
17
|
const colorjs_io_1 = __importDefault(require("colorjs.io"));
|
|
18
|
+
const colornames_1 = __importDefault(require("colornames"));
|
|
9
19
|
// List of rgb tuple variable names (possibly temporary system to support color picker for these variables)
|
|
10
20
|
const rgbTupleVariableNames = [
|
|
11
21
|
"theme-font-color-base",
|
|
@@ -103,12 +113,10 @@ function hexToRgb(hex) {
|
|
|
103
113
|
b: parseInt(b, 16),
|
|
104
114
|
};
|
|
105
115
|
}
|
|
106
|
-
exports.hexToRgb = hexToRgb;
|
|
107
116
|
function rgbToHex(r, g, b) {
|
|
108
117
|
const toHex = (c) => `0${c.toString(16)}`.slice(-2);
|
|
109
118
|
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
110
119
|
}
|
|
111
|
-
exports.rgbToHex = rgbToHex;
|
|
112
120
|
// export function replaceForColorPickers(code: string) {
|
|
113
121
|
// return code.replace(
|
|
114
122
|
// /--([a-z0-9-]+):\s*(\d+)\s+(\d+)\s+(\d+);/gi,
|
|
@@ -145,7 +153,6 @@ function revertReplaceForColorPickers(code) {
|
|
|
145
153
|
return match;
|
|
146
154
|
});
|
|
147
155
|
}
|
|
148
|
-
exports.revertReplaceForColorPickers = revertReplaceForColorPickers;
|
|
149
156
|
function lighten(hex, intensity) {
|
|
150
157
|
const color = hexToRgb(`#${hex}`);
|
|
151
158
|
if (!color)
|
|
@@ -172,7 +179,6 @@ function hexToTailwindRgbString(hex) {
|
|
|
172
179
|
const [, r, g, b] = colorParts;
|
|
173
180
|
return `${parseInt(r, 16)} ${parseInt(g, 16)} ${parseInt(b, 16)}`;
|
|
174
181
|
}
|
|
175
|
-
exports.hexToTailwindRgbString = hexToTailwindRgbString;
|
|
176
182
|
function getLuminance(r, g, b) {
|
|
177
183
|
const { _r, _g, _b } = typeof r === "object"
|
|
178
184
|
? { _r: r.r, _g: r.g, _b: r.b }
|
|
@@ -186,7 +192,6 @@ function getLuminance(r, g, b) {
|
|
|
186
192
|
});
|
|
187
193
|
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
|
|
188
194
|
}
|
|
189
|
-
exports.getLuminance = getLuminance;
|
|
190
195
|
function calculateRatio(luminance1, luminance2) {
|
|
191
196
|
const lum1 = typeof luminance1 === "string"
|
|
192
197
|
? getLuminance(handleStringColor(luminance1))
|
|
@@ -200,7 +205,6 @@ function calculateRatio(luminance1, luminance2) {
|
|
|
200
205
|
? (lum2 + 0.05) / (lum1 + 0.05)
|
|
201
206
|
: (lum1 + 0.05) / (lum2 + 0.05);
|
|
202
207
|
}
|
|
203
|
-
exports.calculateRatio = calculateRatio;
|
|
204
208
|
function handleStringColor(colorString, returnType = "rgb") {
|
|
205
209
|
// if it's a css variable
|
|
206
210
|
if (colorString.includes("--")) {
|
|
@@ -224,7 +228,6 @@ function handleStringColor(colorString, returnType = "rgb") {
|
|
|
224
228
|
}
|
|
225
229
|
return colorString;
|
|
226
230
|
}
|
|
227
|
-
exports.handleStringColor = handleStringColor;
|
|
228
231
|
function cssColorToHex(colorString) {
|
|
229
232
|
if (colorString.includes("#"))
|
|
230
233
|
return colorString;
|
|
@@ -251,13 +254,11 @@ function destringRgb(rgbString) {
|
|
|
251
254
|
b: parseInt(rgb[3], 10),
|
|
252
255
|
};
|
|
253
256
|
}
|
|
254
|
-
exports.destringRgb = destringRgb;
|
|
255
257
|
function generateA11yOnColor(hex) {
|
|
256
258
|
const black = calculateRatio(hex, "#000000");
|
|
257
259
|
const white = calculateRatio(hex, "#FFFFFF");
|
|
258
260
|
return black < white ? "0 0 0" : "255 255 255";
|
|
259
261
|
}
|
|
260
|
-
exports.generateA11yOnColor = generateA11yOnColor;
|
|
261
262
|
function generatePalette(baseColor) {
|
|
262
263
|
const hexValidation = new RegExp(/^#[0-9a-f]{6}$/i);
|
|
263
264
|
if (!hexValidation.test(baseColor))
|
|
@@ -299,7 +300,6 @@ function generatePalette(baseColor) {
|
|
|
299
300
|
});
|
|
300
301
|
return response;
|
|
301
302
|
}
|
|
302
|
-
exports.generatePalette = generatePalette;
|
|
303
303
|
function preprocessGfcThemeBlock(code) {
|
|
304
304
|
// Generate map of defined css variables
|
|
305
305
|
const cssVariableMap = {};
|
|
@@ -353,7 +353,7 @@ function preprocessDaisyThemeBlock(code) {
|
|
|
353
353
|
const hStr = (h || 0).toFixed(1); // h can be NaN for achromatic colors
|
|
354
354
|
return `--${name}: ${lStr}% ${cStr} ${hStr};`;
|
|
355
355
|
}
|
|
356
|
-
catch
|
|
356
|
+
catch {
|
|
357
357
|
// unable to parse color
|
|
358
358
|
return `--${name}: ${value};`;
|
|
359
359
|
}
|
|
@@ -376,4 +376,3 @@ function preprocessStyle(code) {
|
|
|
376
376
|
}
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
|
-
exports.preprocessStyle = preprocessStyle;
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const preprocess_style_1 = require("./preprocess-style");
|
|
7
6
|
const assert_1 = __importDefault(require("assert"));
|
|
7
|
+
const preprocess_style_1 = require("./preprocess-style");
|
|
8
8
|
describe("rgb-utils", () => {
|
|
9
9
|
// data-theme detection
|
|
10
10
|
describe("data-theme detection", () => {
|
package/dist/schema-builder.d.ts
CHANGED
|
@@ -1,95 +1,110 @@
|
|
|
1
1
|
export interface FieldOptions {
|
|
2
|
-
|
|
2
|
+
label?: string;
|
|
3
3
|
}
|
|
4
4
|
export declare abstract class Field<T> {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
readonly options: FieldOptions;
|
|
6
|
+
constructor(options: FieldOptions);
|
|
7
|
+
abstract get value(): T;
|
|
8
|
+
abstract get schema(): any;
|
|
9
9
|
}
|
|
10
10
|
export declare class BooleanField extends Field<boolean> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
value: boolean;
|
|
12
|
+
constructor(value: boolean, options?: FieldOptions);
|
|
13
|
+
get schema(): {
|
|
14
|
+
type: string;
|
|
15
|
+
default: boolean;
|
|
16
|
+
};
|
|
17
17
|
}
|
|
18
|
-
export declare class ConstField<T extends string> extends Field<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
export declare class ConstField<T extends string> extends Field<
|
|
19
|
+
string extends T ? never : T
|
|
20
|
+
> {
|
|
21
|
+
value: string extends T ? never : T;
|
|
22
|
+
constructor(value: string extends T ? never : T, options?: FieldOptions);
|
|
23
|
+
get schema(): {
|
|
24
|
+
const: string extends T ? never : T;
|
|
25
|
+
};
|
|
24
26
|
}
|
|
25
27
|
export declare class ImageField extends Field<string> {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
value: string;
|
|
29
|
+
constructor(value: string, options?: FieldOptions);
|
|
30
|
+
get schema(): {
|
|
31
|
+
type: string;
|
|
32
|
+
default: string;
|
|
33
|
+
};
|
|
32
34
|
}
|
|
33
35
|
export declare class TextField extends Field<string> {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
value: string;
|
|
37
|
+
constructor(value: string, options?: FieldOptions);
|
|
38
|
+
get schema(): {
|
|
39
|
+
type: string;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
40
42
|
}
|
|
41
|
-
export declare class EnumField<T extends Record<string, string>> extends Field<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
export declare class EnumField<T extends Record<string, string>> extends Field<
|
|
44
|
+
keyof T
|
|
45
|
+
> {
|
|
46
|
+
enumValues: T;
|
|
47
|
+
value: keyof T;
|
|
48
|
+
constructor(enumValues: T, value: keyof T, options?: FieldOptions);
|
|
49
|
+
get schema(): {
|
|
50
|
+
enum: string[];
|
|
51
|
+
};
|
|
48
52
|
}
|
|
49
53
|
export declare class IntegerField extends Field<number> {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
value: number;
|
|
55
|
+
constructor(value: number, options?: FieldOptions);
|
|
56
|
+
get schema(): {
|
|
57
|
+
type: string;
|
|
58
|
+
default: number;
|
|
59
|
+
};
|
|
56
60
|
}
|
|
57
61
|
export declare class FloatField extends Field<number> {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
value: number;
|
|
63
|
+
constructor(value: number, options?: FieldOptions);
|
|
64
|
+
get schema(): {
|
|
65
|
+
type: string;
|
|
66
|
+
default: number;
|
|
67
|
+
};
|
|
64
68
|
}
|
|
65
|
-
export declare class FormGroup<
|
|
69
|
+
export declare class FormGroup<
|
|
70
|
+
T extends Record<string, Field<any>>,
|
|
71
|
+
O extends Record<string, Field<any>>,
|
|
72
|
+
> extends Field<
|
|
73
|
+
{
|
|
66
74
|
[key in keyof T]: T[key]["value"];
|
|
67
|
-
} & Partial<{
|
|
75
|
+
} & Partial<{
|
|
68
76
|
[key in keyof O]: O[key]["value"];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
}>
|
|
78
|
+
> {
|
|
79
|
+
requiredFields: T;
|
|
80
|
+
optionalFields: O;
|
|
81
|
+
constructor(requiredFields: T, optionalFields?: O, options?: FieldOptions);
|
|
82
|
+
get value(): {
|
|
83
|
+
[key in keyof T]: T[key]["value"];
|
|
84
|
+
} & Partial<{
|
|
85
|
+
[key in keyof O]: O[key]["value"];
|
|
86
|
+
}>;
|
|
87
|
+
get schema(): {
|
|
88
|
+
type: string;
|
|
89
|
+
properties: any;
|
|
90
|
+
required: string[];
|
|
91
|
+
};
|
|
83
92
|
}
|
|
84
93
|
export declare class FormArray<T> extends Field<T[]> {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
private factory;
|
|
95
|
+
value: Field<T>["value"][];
|
|
96
|
+
constructor(
|
|
97
|
+
factory: () => Field<T>,
|
|
98
|
+
value: Field<T>["value"][],
|
|
99
|
+
options?: FieldOptions,
|
|
100
|
+
);
|
|
101
|
+
get schema(): {
|
|
102
|
+
type: string;
|
|
103
|
+
items: any;
|
|
104
|
+
default: T[];
|
|
105
|
+
};
|
|
95
106
|
}
|
|
107
|
+
export declare class Form<
|
|
108
|
+
R extends Record<string, Field<any>>,
|
|
109
|
+
O extends Record<string, Field<any>>,
|
|
110
|
+
> extends FormGroup<R, O> {}
|
package/dist/schema-builder.js
CHANGED
|
@@ -1,166 +1,183 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Form =
|
|
3
|
+
exports.Form =
|
|
4
|
+
exports.FormArray =
|
|
5
|
+
exports.FormGroup =
|
|
6
|
+
exports.FloatField =
|
|
7
|
+
exports.IntegerField =
|
|
8
|
+
exports.EnumField =
|
|
9
|
+
exports.TextField =
|
|
10
|
+
exports.ImageField =
|
|
11
|
+
exports.ConstField =
|
|
12
|
+
exports.BooleanField =
|
|
13
|
+
exports.Field =
|
|
14
|
+
void 0;
|
|
4
15
|
const defaultFieldOptions = {};
|
|
5
16
|
class Field {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
17
|
+
options;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.options = options;
|
|
20
|
+
}
|
|
10
21
|
}
|
|
11
22
|
exports.Field = Field;
|
|
12
23
|
class BooleanField extends Field {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
value;
|
|
25
|
+
constructor(value, options = defaultFieldOptions) {
|
|
26
|
+
super(options);
|
|
27
|
+
this.value = value;
|
|
28
|
+
}
|
|
29
|
+
get schema() {
|
|
30
|
+
return {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
default: this.value,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
24
35
|
}
|
|
25
36
|
exports.BooleanField = BooleanField;
|
|
26
37
|
class ConstField extends Field {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
value;
|
|
39
|
+
constructor(value, options = defaultFieldOptions) {
|
|
40
|
+
super(options);
|
|
41
|
+
this.value = value;
|
|
42
|
+
}
|
|
43
|
+
get schema() {
|
|
44
|
+
return {
|
|
45
|
+
const: this.value,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
37
48
|
}
|
|
38
49
|
exports.ConstField = ConstField;
|
|
39
50
|
class ImageField extends Field {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
value;
|
|
52
|
+
constructor(value, options = defaultFieldOptions) {
|
|
53
|
+
super(options);
|
|
54
|
+
this.value = value;
|
|
55
|
+
}
|
|
56
|
+
get schema() {
|
|
57
|
+
return {
|
|
58
|
+
type: "string",
|
|
59
|
+
default: this.value,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
51
62
|
}
|
|
52
63
|
exports.ImageField = ImageField;
|
|
53
64
|
class TextField extends Field {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
value;
|
|
66
|
+
constructor(value, options = defaultFieldOptions) {
|
|
67
|
+
super(options);
|
|
68
|
+
this.value = value;
|
|
69
|
+
}
|
|
70
|
+
get schema() {
|
|
71
|
+
return {
|
|
72
|
+
type: "string",
|
|
73
|
+
default: this.value,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
65
76
|
}
|
|
66
77
|
exports.TextField = TextField;
|
|
67
78
|
class EnumField extends Field {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
enumValues;
|
|
80
|
+
value;
|
|
81
|
+
constructor(enumValues, value, options = defaultFieldOptions) {
|
|
82
|
+
super(options);
|
|
83
|
+
this.enumValues = enumValues;
|
|
84
|
+
this.value = value;
|
|
85
|
+
}
|
|
86
|
+
get schema() {
|
|
87
|
+
return {
|
|
88
|
+
enum: Object.keys(this.enumValues),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
80
91
|
}
|
|
81
92
|
exports.EnumField = EnumField;
|
|
82
93
|
class IntegerField extends Field {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
value;
|
|
95
|
+
constructor(value, options = defaultFieldOptions) {
|
|
96
|
+
super(options);
|
|
97
|
+
this.value = value;
|
|
98
|
+
}
|
|
99
|
+
get schema() {
|
|
100
|
+
return {
|
|
101
|
+
type: "integer",
|
|
102
|
+
default: this.value,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
94
105
|
}
|
|
95
106
|
exports.IntegerField = IntegerField;
|
|
96
107
|
class FloatField extends Field {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
value;
|
|
109
|
+
constructor(value, options = defaultFieldOptions) {
|
|
110
|
+
super(options);
|
|
111
|
+
this.value = value;
|
|
112
|
+
}
|
|
113
|
+
get schema() {
|
|
114
|
+
return {
|
|
115
|
+
type: "number",
|
|
116
|
+
default: this.value,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
108
119
|
}
|
|
109
120
|
exports.FloatField = FloatField;
|
|
110
121
|
class FormGroup extends Field {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
122
|
+
requiredFields;
|
|
123
|
+
optionalFields;
|
|
124
|
+
constructor(
|
|
125
|
+
requiredFields,
|
|
126
|
+
optionalFields = {},
|
|
127
|
+
options = defaultFieldOptions,
|
|
128
|
+
) {
|
|
129
|
+
super(options);
|
|
130
|
+
this.requiredFields = requiredFields;
|
|
131
|
+
this.optionalFields = optionalFields;
|
|
132
|
+
}
|
|
133
|
+
get value() {
|
|
134
|
+
const value = Object.entries(this.requiredFields).reduce(
|
|
135
|
+
(acc, [key, field]) => {
|
|
136
|
+
acc[key] = field.value;
|
|
137
|
+
return acc;
|
|
138
|
+
},
|
|
139
|
+
{},
|
|
140
|
+
);
|
|
141
|
+
Object.entries(this.optionalFields).forEach(([key, field]) => {
|
|
142
|
+
if (field.value !== undefined) {
|
|
143
|
+
value[key] = field.value;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
get schema() {
|
|
149
|
+
const properties = {};
|
|
150
|
+
Object.entries(this.requiredFields).forEach(([key, field]) => {
|
|
151
|
+
properties[key] = field.schema;
|
|
152
|
+
});
|
|
153
|
+
Object.entries(this.optionalFields).forEach(([key, field]) => {
|
|
154
|
+
properties[key] = field.schema;
|
|
155
|
+
});
|
|
156
|
+
return {
|
|
157
|
+
type: "object",
|
|
158
|
+
properties,
|
|
159
|
+
required: Object.keys(this.requiredFields),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
144
162
|
}
|
|
145
163
|
exports.FormGroup = FormGroup;
|
|
146
164
|
class FormArray extends Field {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
165
|
+
factory;
|
|
166
|
+
value;
|
|
167
|
+
constructor(factory, value, options = defaultFieldOptions) {
|
|
168
|
+
super(options);
|
|
169
|
+
this.factory = factory;
|
|
170
|
+
this.value = value;
|
|
171
|
+
}
|
|
172
|
+
get schema() {
|
|
173
|
+
const field = this.factory();
|
|
174
|
+
return {
|
|
175
|
+
type: "array",
|
|
176
|
+
items: field.schema,
|
|
177
|
+
default: this.value,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
162
180
|
}
|
|
163
181
|
exports.FormArray = FormArray;
|
|
164
|
-
class Form extends FormGroup {
|
|
165
|
-
}
|
|
182
|
+
class Form extends FormGroup {}
|
|
166
183
|
exports.Form = Form;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const KOKIMOKI_KIT_VERSION = "1.6.
|
|
1
|
+
export declare const KOKIMOKI_KIT_VERSION = "1.6.7";
|
package/dist/version.js
CHANGED
package/dist/zod.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { z, type ZodType } from "zod/v4";
|
package/dist/zod.js
ADDED