@ostack.tech/ui-kform-scaffolder 0.3.0 → 0.3.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/ostack-ui-kform-scaffolder.js +5 -123
- package/dist/ostack-ui-kform-scaffolder.js.map +1 -1
- package/dist/types/SchematicBuilder.d.ts +2 -2
- package/dist/types/SchematicKind.d.ts +3 -3
- package/dist/types/index.d.ts +24 -24
- package/dist/types/main.d.ts +0 -1
- package/dist/types/scaffolding/ScaffoldingData.d.ts +2 -2
- package/dist/types/scaffolding/kotlin/KtData.d.ts +2 -2
- package/dist/types/scaffolding/reactApp/ReactAppData.d.ts +2 -2
- package/dist/types/scaffolding/reactApp/util/reactAppLayout.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldActions.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldApi.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldAppComponent.d.ts +3 -3
- package/dist/types/scaffolding/scaffolders/scaffoldAppContext.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldExternalContexts.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldFormPages.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldGradleProject.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldGradleWrapper.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldIssueMessages.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldMain.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldProjectMisc.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldResponses.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldSerializer.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldStyles.d.ts +2 -2
- package/dist/types/scaffolding/scaffolders/scaffoldViteProject.d.ts +2 -2
- package/dist/webapp/assets/{index-BzAvefdh.js → index-DQxMC8FJ.js} +96 -96
- package/dist/webapp/index.html +1 -1
- package/package.json +3 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useConfig, UseTableValuesSerializerConfig as UseTableValuesSerializerConfig$1, addEjsTemplateFile, addTemplateFile, joinPaths, tsFile, code, anySchematicKind as anySchematicKind$1, bigDecimalSchematicKind as bigDecimalSchematicKind$1, bigIntegerSchematicKind as bigIntegerSchematicKind$1, booleanSchematicKind as booleanSchematicKind$1, byteSchematicKind as byteSchematicKind$1, classSchematicKind as classSchematicKind$1, doubleSchematicKind as doubleSchematicKind$1, enumSchematicKind as enumSchematicKind$1, fileSchematicKind as fileSchematicKind$1, floatSchematicKind as floatSchematicKind$1, intSchematicKind as intSchematicKind$1, ListableBuilderWithoutKindSelect, createSchematic, listSchematicKind, localDateSchematicKind as localDateSchematicKind$1, longSchematicKind as longSchematicKind$1, shortSchematicKind as shortSchematicKind$1, stringSchematicKind as stringSchematicKind$1, tableSchematicKind as tableSchematicKind$1, annotate, SchematicBuilder as SchematicBuilder$1, configScaffolder, scaffoldSchemas, scaffoldModels, scaffoldValidator } from "@ostack.tech/kform-scaffolder";
|
|
3
3
|
import { useRef } from "react";
|
|
4
|
+
import { capitalCase, camelCase, kebabCase, constantCase, sentenceCase, pascalCase } from "change-case";
|
|
4
5
|
const LOCALES = JSON.parse('["en-GB","en-US","fr","pt"]');
|
|
5
6
|
function DefaultLocaleConfig({
|
|
6
7
|
defaultValue = "en-US",
|
|
@@ -68,125 +69,6 @@ function UseTableValuesSerializerConfig({
|
|
|
68
69
|
}
|
|
69
70
|
);
|
|
70
71
|
}
|
|
71
|
-
const SPLIT_LOWER_UPPER_RE = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu");
|
|
72
|
-
const SPLIT_UPPER_UPPER_RE = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu");
|
|
73
|
-
const SPLIT_SEPARATE_NUMBER_RE = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u");
|
|
74
|
-
const DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
75
|
-
const SPLIT_REPLACE_VALUE = "$1\0$2";
|
|
76
|
-
const DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
|
|
77
|
-
function split(value) {
|
|
78
|
-
let result = value.trim();
|
|
79
|
-
result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
80
|
-
result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
81
|
-
let start = 0;
|
|
82
|
-
let end = result.length;
|
|
83
|
-
while (result.charAt(start) === "\0")
|
|
84
|
-
start++;
|
|
85
|
-
if (start === end)
|
|
86
|
-
return [];
|
|
87
|
-
while (result.charAt(end - 1) === "\0")
|
|
88
|
-
end--;
|
|
89
|
-
return result.slice(start, end).split(/\0/g);
|
|
90
|
-
}
|
|
91
|
-
function splitSeparateNumbers(value) {
|
|
92
|
-
const words = split(value);
|
|
93
|
-
for (let i = 0; i < words.length; i++) {
|
|
94
|
-
const word = words[i];
|
|
95
|
-
const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
|
|
96
|
-
if (match) {
|
|
97
|
-
const offset = match.index + (match[1] ?? match[2]).length;
|
|
98
|
-
words.splice(i, 1, word.slice(0, offset), word.slice(offset));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return words;
|
|
102
|
-
}
|
|
103
|
-
function noCase(input, options) {
|
|
104
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
105
|
-
return prefix + words.map(lowerFactory(options?.locale)).join(options?.delimiter ?? " ") + suffix;
|
|
106
|
-
}
|
|
107
|
-
function camelCase(input, options) {
|
|
108
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
109
|
-
const lower = lowerFactory(options?.locale);
|
|
110
|
-
const upper = upperFactory(options?.locale);
|
|
111
|
-
const transform = pascalCaseTransformFactory(lower, upper);
|
|
112
|
-
return prefix + words.map((word, index) => {
|
|
113
|
-
if (index === 0)
|
|
114
|
-
return lower(word);
|
|
115
|
-
return transform(word, index);
|
|
116
|
-
}).join("") + suffix;
|
|
117
|
-
}
|
|
118
|
-
function pascalCase(input, options) {
|
|
119
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
120
|
-
const lower = lowerFactory(options?.locale);
|
|
121
|
-
const upper = upperFactory(options?.locale);
|
|
122
|
-
const transform = pascalCaseTransformFactory(lower, upper);
|
|
123
|
-
return prefix + words.map(transform).join("") + suffix;
|
|
124
|
-
}
|
|
125
|
-
function capitalCase(input, options) {
|
|
126
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
127
|
-
const lower = lowerFactory(options?.locale);
|
|
128
|
-
const upper = upperFactory(options?.locale);
|
|
129
|
-
return prefix + words.map(capitalCaseTransformFactory(lower, upper)).join(" ") + suffix;
|
|
130
|
-
}
|
|
131
|
-
function constantCase(input, options) {
|
|
132
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
133
|
-
return prefix + words.map(upperFactory(options?.locale)).join("_") + suffix;
|
|
134
|
-
}
|
|
135
|
-
function kebabCase(input, options) {
|
|
136
|
-
return noCase(input, { delimiter: "-", ...options });
|
|
137
|
-
}
|
|
138
|
-
function sentenceCase(input, options) {
|
|
139
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
140
|
-
const lower = lowerFactory(options?.locale);
|
|
141
|
-
const upper = upperFactory(options?.locale);
|
|
142
|
-
const transform = capitalCaseTransformFactory(lower, upper);
|
|
143
|
-
return prefix + words.map((word, index) => {
|
|
144
|
-
if (index === 0)
|
|
145
|
-
return transform(word);
|
|
146
|
-
return lower(word);
|
|
147
|
-
}).join(" ") + suffix;
|
|
148
|
-
}
|
|
149
|
-
function lowerFactory(locale) {
|
|
150
|
-
return locale === false ? (input) => input.toLowerCase() : (input) => input.toLocaleLowerCase(locale);
|
|
151
|
-
}
|
|
152
|
-
function upperFactory(locale) {
|
|
153
|
-
return (input) => input.toLocaleUpperCase(locale);
|
|
154
|
-
}
|
|
155
|
-
function capitalCaseTransformFactory(lower, upper) {
|
|
156
|
-
return (word) => `${upper(word[0])}${lower(word.slice(1))}`;
|
|
157
|
-
}
|
|
158
|
-
function pascalCaseTransformFactory(lower, upper) {
|
|
159
|
-
return (word, index) => {
|
|
160
|
-
const char0 = word[0];
|
|
161
|
-
const initial = index > 0 && char0 >= "0" && char0 <= "9" ? "_" + char0 : upper(char0);
|
|
162
|
-
return initial + lower(word.slice(1));
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
function splitPrefixSuffix(input, options = {}) {
|
|
166
|
-
const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
|
|
167
|
-
const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
168
|
-
const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
169
|
-
let prefixIndex = 0;
|
|
170
|
-
let suffixIndex = input.length;
|
|
171
|
-
while (prefixIndex < input.length) {
|
|
172
|
-
const char = input.charAt(prefixIndex);
|
|
173
|
-
if (!prefixCharacters.includes(char))
|
|
174
|
-
break;
|
|
175
|
-
prefixIndex++;
|
|
176
|
-
}
|
|
177
|
-
while (suffixIndex > prefixIndex) {
|
|
178
|
-
const index = suffixIndex - 1;
|
|
179
|
-
const char = input.charAt(index);
|
|
180
|
-
if (!suffixCharacters.includes(char))
|
|
181
|
-
break;
|
|
182
|
-
suffixIndex = index;
|
|
183
|
-
}
|
|
184
|
-
return [
|
|
185
|
-
input.slice(0, prefixIndex),
|
|
186
|
-
splitFn(input.slice(prefixIndex, suffixIndex)),
|
|
187
|
-
input.slice(suffixIndex)
|
|
188
|
-
];
|
|
189
|
-
}
|
|
190
72
|
const loadTsxEjs = 'import { LoadAction } from "@ostack.tech/ui-kform";\nimport { decode<%= formClass %>FromString, <%= formClass %>FormMode } from "<%= kmpModuleName %>";\nimport { use<%= formClass %>Context } from "../<%= formClass %>Context.ts";\n\nexport function Load() {\n const { externalContexts } = use<%= formClass %>Context();\n\n return (\n externalContexts.mode !== <%= formClass %>FormMode.READ && (\n <LoadAction\n decode={async (file) => decode<%= formClass %>FromString(await file.text())}\n mimeTypes={["<%= serializationMimeType %>"]}\n extensions={[".<%= serializationFormat %>"]}\n />\n )\n );\n}\n';
|
|
191
73
|
const saveTsxEjs = 'import { SaveAction } from "@ostack.tech/ui-kform";\nimport { format } from "date-fns";\nimport { type <%= formClass %>, encode<%= formClass %>ToString, <%= formClass %>FormMode } from "<%= kmpModuleName %>";\nimport { use<%= formClass %>Context } from "../<%= formClass %>Context.ts";\n\nexport function Save() {\n const { externalContexts } = use<%= formClass %>Context();\n\n return (\n <SaveAction\n encode={(<%= formVar %>: <%= formClass %>) => encode<%= formClass %>ToString(<%= formVar %>, true)}\n disableOverwrite={externalContexts.mode === <%= formClass %>FormMode.READ}\n fileName={() => `<%= formTitle %> ${format(new Date(), "yyyy-MM-dd")}.<%= serializationFormat %>`}\n mimeTypes={["<%= serializationMimeType %>"]}\n extensions={[".<%= serializationFormat %>"]}\n />\n );\n}\n';
|
|
192
74
|
const submitTsxEjs = 'import { LocatedValidationWarning } from "@ostack.tech/kform";\nimport { SubmitAction } from "@ostack.tech/ui-kform";\nimport {\n type <%= formClass %>,\n <%= formClass %>FormMode,\n <%= formClass %>SubmitSuccess,\n <%= formClass %>SubmitValidationError,\n <%= formClass %>SubmitError,\n} from "<%= kmpModuleName %>";\nimport { use<%= formClass %>Context } from "../<%= formClass %>Context.ts";\nimport { submit } from "../api/submit.ts";\n\nexport function Submit() {\n const { externalContexts } = use<%= formClass %>Context();\n\n const handleSubmit = async (\n <%= formVar %>: <%= formClass %>,\n acceptedWarnings?: LocatedValidationWarning[],\n ) => {\n const response = await submit(<%= formVar %>, acceptedWarnings);\n if (response instanceof <%= formClass %>SubmitSuccess) {\n return response.redirectTo;\n } else if (response instanceof <%= formClass %>SubmitValidationError) {\n return response.issues;\n } else {\n throw response as <%= formClass %>SubmitError;\n }\n };\n\n const handleSuccessfulSubmit = (redirectTo: string) => {\n window.location.href = redirectTo;\n };\n\n return (\n externalContexts.mode !== <%= formClass %>FormMode.READ && (\n <SubmitAction\n onSubmit={handleSubmit}\n onSuccessfulSubmit={handleSuccessfulSubmit}\n <%_ if (useTableValuesSerializer) { -%>\n convertExternalIssuesTableRowIndicesToIds\n <%_ } -%>\n />\n )\n );\n}\n';
|
|
@@ -1093,7 +975,7 @@ function scaffoldGradleProject(schematic, data) {
|
|
|
1093
975
|
filePackage: data.currentPackage,
|
|
1094
976
|
formId: kebabCase(schematic.name),
|
|
1095
977
|
formTitle: capitalCase(schematic.name),
|
|
1096
|
-
kFormVersion: "0.31.
|
|
978
|
+
kFormVersion: "0.31.4",
|
|
1097
979
|
serializationFormat: data.serializationFormat ?? "json",
|
|
1098
980
|
usesKotlinxDatetime: usesKotlinxDatetime(schematic, data),
|
|
1099
981
|
usesKtMath: usesKtMath(schematic)
|
|
@@ -1644,9 +1526,9 @@ function scaffoldViteProject(schematic, data) {
|
|
|
1644
1526
|
formId: kebabCase(schematic.name),
|
|
1645
1527
|
formClass: schematic.name,
|
|
1646
1528
|
formTitle: capitalCase(schematic.name),
|
|
1647
|
-
ostackUiVersion: "0.3.
|
|
1648
|
-
kFormVersion: "0.31.
|
|
1649
|
-
dependencyVersions: JSON.parse('{"@eslint/js":"^9.
|
|
1529
|
+
ostackUiVersion: "0.3.2",
|
|
1530
|
+
kFormVersion: "0.31.4",
|
|
1531
|
+
dependencyVersions: JSON.parse('{"@eslint/js":"^9.38.0","@fortawesome/fontawesome-svg-core":"^7.1.0","@fortawesome/free-brands-svg-icons":"^7.1.0","@fortawesome/free-regular-svg-icons":"^7.1.0","@fortawesome/free-solid-svg-icons":"^7.1.0","@ostack.tech/kform":"~0.31.4","@ostack.tech/kform-react":"~0.31.4","@ostack.tech/kform-scaffolder":"~0.31.4","@storybook/addon-docs":"^9.1.13","@storybook/addon-links":"^9.1.13","@storybook/react-vite":"^9.1.13","@types/node":"^22.18.12","@types/react":"^19.2.2","@types/react-dom":"^19.2.2","@vitejs/plugin-react-swc":"^4.1.0","change-case":"^5.4.4","cpy-cli":"^6.0.0","date-fns":"^4.1.0","eslint":"^9.38.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","eslint-plugin-react-hooks":"^6.1.1","eslint-plugin-react-refresh":"^0.4.24","eslint-plugin-simple-import-sort":"^12.1.1","eslint-plugin-storybook":"^9.1.13","globals":"^16.4.0","happy-dom":"^20.0.8","lint-staged":"^16.2.6","prettier":"^3.6.2","prettier-plugin-jsdoc":"^1.3.3","react":"^19.2.0","react-dom":"^19.2.0","react-router":"^7.9.4","react-router-dom":"^7.9.4","rimraf":"^6.0.1","sass-embedded":"^1.93.2","simple-git-hooks":"^2.13.1","storybook":"^9.1.13","terser":"^5.44.0","tslib":"^2.8.1","typescript":"~5.9.3","typescript-eslint":"^8.46.2","vite":"^7.1.12","vite-plugin-dts":"^4.5.4","vitest":"^4.0.1","zustand":"^5.0.8"}'),
|
|
1650
1532
|
externalContextsData: data.serializationFormat === "json" ? "{}" : `<${schematic.name}ExternalContexts />`
|
|
1651
1533
|
};
|
|
1652
1534
|
addEjsTemplateFile(data, "react-app/package.json", packageJsonEjs, ejsData);
|