@scalio-cloud/ui 0.109.0 → 0.110.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.
- package/dist/app-kit/ScalioFactoryReset.d.ts +15 -0
- package/dist/app-kit/ScalioFactoryReset.d.ts.map +1 -0
- package/dist/app-kit/ScalioLicensePanel.d.ts +23 -0
- package/dist/app-kit/ScalioLicensePanel.d.ts.map +1 -0
- package/dist/app-kit/ScalioLoginPage.d.ts +1 -1
- package/dist/app-kit/ScalioLoginPage.d.ts.map +1 -1
- package/dist/app-kit/ScalioMailSettings.d.ts +13 -0
- package/dist/app-kit/ScalioMailSettings.d.ts.map +1 -0
- package/dist/app-kit/ScalioRoleTenants.d.ts +22 -0
- package/dist/app-kit/ScalioRoleTenants.d.ts.map +1 -0
- package/dist/app-kit/_uiReact.d.ts +307 -0
- package/dist/app-kit/_uiReact.d.ts.map +1 -0
- package/dist/app-kit/index.d.ts +4 -0
- package/dist/app-kit/index.d.ts.map +1 -1
- package/dist/app-kit/index.js +303 -106
- package/dist/app-kit/index.js.map +1 -1
- package/dist/app-kit/index.mjs +213 -40
- package/dist/app-kit/index.mjs.map +1 -1
- package/dist/config/i18nCheck.d.ts +49 -0
- package/dist/config/i18nCheck.d.ts.map +1 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +187 -4
- package/dist/config/index.js.map +1 -1
- package/dist/config/index.mjs +178 -3
- package/dist/config/index.mjs.map +1 -1
- package/dist/config/openapi.d.ts +34 -0
- package/dist/config/openapi.d.ts.map +1 -0
- package/dist/editor/RichTextEditor.d.ts +58 -0
- package/dist/editor/RichTextEditor.d.ts.map +1 -0
- package/dist/editor/index.d.ts +5 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +350 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/index.mjs +324 -0
- package/dist/editor/index.mjs.map +1 -0
- package/package.json +22 -1
package/dist/config/index.js
CHANGED
|
@@ -20,10 +20,187 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/config/index.ts
|
|
21
21
|
var config_exports = {};
|
|
22
22
|
__export(config_exports, {
|
|
23
|
+
DEFAULT_OPENAPI_TYPEGEN_CONFIG: () => DEFAULT_OPENAPI_TYPEGEN_CONFIG,
|
|
24
|
+
buildOpenApiTypegenArgs: () => buildOpenApiTypegenArgs,
|
|
23
25
|
createEslintConfig: () => createEslintConfig,
|
|
24
|
-
|
|
26
|
+
createOpenApiTypegenConfig: () => createOpenApiTypegenConfig,
|
|
27
|
+
createPostcssConfig: () => createPostcssConfig,
|
|
28
|
+
extractPlaceholders: () => extractPlaceholders,
|
|
29
|
+
formatI18nValidationReport: () => formatI18nValidationReport,
|
|
30
|
+
validateI18nCatalogs: () => validateI18nCatalogs
|
|
25
31
|
});
|
|
26
32
|
module.exports = __toCommonJS(config_exports);
|
|
33
|
+
|
|
34
|
+
// src/config/openapi.ts
|
|
35
|
+
var DEFAULT_OPENAPI_TYPEGEN_CONFIG = {
|
|
36
|
+
input: "../openapi.json",
|
|
37
|
+
output: "src/api/schema.d.ts",
|
|
38
|
+
immutableTypes: true,
|
|
39
|
+
exportType: true,
|
|
40
|
+
alphabetize: true,
|
|
41
|
+
emptyObjectsUnknown: true
|
|
42
|
+
};
|
|
43
|
+
function createOpenApiTypegenConfig(overrides = {}) {
|
|
44
|
+
return {
|
|
45
|
+
...DEFAULT_OPENAPI_TYPEGEN_CONFIG,
|
|
46
|
+
...overrides
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function buildOpenApiTypegenArgs(config = {}) {
|
|
50
|
+
const resolved = createOpenApiTypegenConfig(config);
|
|
51
|
+
const args = [resolved.input, "-o", resolved.output];
|
|
52
|
+
if (resolved.immutableTypes) {
|
|
53
|
+
args.push("--immutable");
|
|
54
|
+
}
|
|
55
|
+
if (resolved.exportType) {
|
|
56
|
+
args.push("--export-type");
|
|
57
|
+
}
|
|
58
|
+
if (resolved.alphabetize) {
|
|
59
|
+
args.push("--alphabetize");
|
|
60
|
+
}
|
|
61
|
+
if (resolved.emptyObjectsUnknown) {
|
|
62
|
+
args.push("--empty-objects-unknown");
|
|
63
|
+
}
|
|
64
|
+
return args;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/config/i18nCheck.ts
|
|
68
|
+
var PLACEHOLDER_RE = /\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}|\{\s*([a-zA-Z0-9_.-]+)\s*\}/g;
|
|
69
|
+
var SHARP_S = "\xDF";
|
|
70
|
+
function extractPlaceholders(text) {
|
|
71
|
+
const found = /* @__PURE__ */ new Set();
|
|
72
|
+
for (const match of text.matchAll(PLACEHOLDER_RE)) {
|
|
73
|
+
const name = match[1] ?? match[2];
|
|
74
|
+
if (name) {
|
|
75
|
+
found.add(name);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return Array.from(found).sort();
|
|
79
|
+
}
|
|
80
|
+
function isGermanLocale(locale) {
|
|
81
|
+
const lower = locale.toLowerCase();
|
|
82
|
+
return lower === "de" || lower.startsWith("de-") || lower.startsWith("de_");
|
|
83
|
+
}
|
|
84
|
+
function sameStringList(a, b) {
|
|
85
|
+
if (a.length !== b.length) return false;
|
|
86
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
87
|
+
if (a[i] !== b[i]) return false;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
function validateI18nCatalogs(catalogs, options = {}) {
|
|
92
|
+
const sourceLocale = options.sourceLocale ?? "en";
|
|
93
|
+
const failOnExtraKeys = options.failOnExtraKeys ?? true;
|
|
94
|
+
const forbidSharpSInGerman = options.forbidSharpSInGerman ?? true;
|
|
95
|
+
const failOnEmptyValues = options.failOnEmptyValues ?? true;
|
|
96
|
+
const issues = [];
|
|
97
|
+
const localeNames = Object.keys(catalogs).sort();
|
|
98
|
+
const source = catalogs[sourceLocale];
|
|
99
|
+
if (!source) {
|
|
100
|
+
issues.push({
|
|
101
|
+
locale: sourceLocale,
|
|
102
|
+
key: "*",
|
|
103
|
+
kind: "missing-source-locale",
|
|
104
|
+
message: `Source locale "${sourceLocale}" is missing from catalogs.`
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
ok: false,
|
|
108
|
+
sourceLocale,
|
|
109
|
+
localesChecked: localeNames,
|
|
110
|
+
issues
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const sourceKeys = Object.keys(source).sort();
|
|
114
|
+
if (failOnEmptyValues) {
|
|
115
|
+
for (const key of sourceKeys) {
|
|
116
|
+
const sourceValue = source[key];
|
|
117
|
+
if (sourceValue !== void 0 && sourceValue.trim().length === 0) {
|
|
118
|
+
issues.push({
|
|
119
|
+
locale: sourceLocale,
|
|
120
|
+
key,
|
|
121
|
+
kind: "empty-value",
|
|
122
|
+
message: `Empty translation value in source locale "${sourceLocale}" for key "${key}".`
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
for (const locale of localeNames) {
|
|
128
|
+
if (locale === sourceLocale) continue;
|
|
129
|
+
const target = catalogs[locale];
|
|
130
|
+
if (!target) continue;
|
|
131
|
+
const targetKeys = Object.keys(target).sort();
|
|
132
|
+
const checkSharpS = forbidSharpSInGerman && isGermanLocale(locale);
|
|
133
|
+
for (const key of sourceKeys) {
|
|
134
|
+
if (!Object.prototype.hasOwnProperty.call(target, key)) {
|
|
135
|
+
issues.push({
|
|
136
|
+
locale,
|
|
137
|
+
key,
|
|
138
|
+
kind: "missing-key",
|
|
139
|
+
message: `Locale "${locale}" is missing key "${key}".`
|
|
140
|
+
});
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const sourceValue = source[key] ?? "";
|
|
144
|
+
const value = target[key] ?? "";
|
|
145
|
+
if (failOnEmptyValues && value.trim().length === 0) {
|
|
146
|
+
issues.push({
|
|
147
|
+
locale,
|
|
148
|
+
key,
|
|
149
|
+
kind: "empty-value",
|
|
150
|
+
message: `Empty translation value in locale "${locale}" for key "${key}".`
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const expectedPlaceholders = extractPlaceholders(sourceValue);
|
|
154
|
+
const actualPlaceholders = extractPlaceholders(value);
|
|
155
|
+
if (!sameStringList(expectedPlaceholders, actualPlaceholders)) {
|
|
156
|
+
issues.push({
|
|
157
|
+
locale,
|
|
158
|
+
key,
|
|
159
|
+
kind: "placeholder-mismatch",
|
|
160
|
+
message: `Placeholder mismatch in "${locale}.${key}": expected [${expectedPlaceholders.join(", ")}], got [${actualPlaceholders.join(", ")}].`
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (checkSharpS && value.includes(SHARP_S)) {
|
|
164
|
+
issues.push({
|
|
165
|
+
locale,
|
|
166
|
+
key,
|
|
167
|
+
kind: "sharp-s",
|
|
168
|
+
message: `Locale "${locale}" key "${key}" contains forbidden sharp-s; use "ss" instead.`
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (failOnExtraKeys) {
|
|
173
|
+
for (const key of targetKeys) {
|
|
174
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) {
|
|
175
|
+
issues.push({
|
|
176
|
+
locale,
|
|
177
|
+
key,
|
|
178
|
+
kind: "extra-key",
|
|
179
|
+
message: `Locale "${locale}" contains unknown key "${key}" not present in "${sourceLocale}".`
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
ok: issues.length === 0,
|
|
187
|
+
sourceLocale,
|
|
188
|
+
localesChecked: localeNames,
|
|
189
|
+
issues
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function formatI18nValidationReport(result) {
|
|
193
|
+
if (result.ok) {
|
|
194
|
+
return `i18n ok (${result.localesChecked.length} locales checked against "${result.sourceLocale}").`;
|
|
195
|
+
}
|
|
196
|
+
const lines = [
|
|
197
|
+
`i18n validation failed (${result.issues.length} issue${result.issues.length === 1 ? "" : "s"}):`,
|
|
198
|
+
...result.issues.map((issue) => ` - [${issue.locale}] (${issue.kind}) ${issue.message}`)
|
|
199
|
+
];
|
|
200
|
+
return lines.join("\n");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// src/config/index.ts
|
|
27
204
|
function createPostcssConfig() {
|
|
28
205
|
return {
|
|
29
206
|
plugins: {
|
|
@@ -36,11 +213,11 @@ function createEslintConfig(options) {
|
|
|
36
213
|
const { js, globals, reactPlugin, reactHooks, ignores = [], rules = {} } = options;
|
|
37
214
|
return [
|
|
38
215
|
{
|
|
39
|
-
ignores: ["build/**", "dist/**", "node_modules/**", "src/vendor/**", ...ignores]
|
|
216
|
+
ignores: ["build/**", "dist/**", "node_modules/**", "src/vendor/**", "**/*.d.ts", ...ignores]
|
|
40
217
|
},
|
|
41
218
|
js.configs.recommended,
|
|
42
219
|
{
|
|
43
|
-
files: ["**/*.{js,jsx,
|
|
220
|
+
files: ["**/*.{js,jsx,cjs,mjs}"],
|
|
44
221
|
linterOptions: {
|
|
45
222
|
reportUnusedDisableDirectives: false
|
|
46
223
|
},
|
|
@@ -79,7 +256,13 @@ function createEslintConfig(options) {
|
|
|
79
256
|
}
|
|
80
257
|
// Annotate the CommonJS export names for ESM import in node:
|
|
81
258
|
0 && (module.exports = {
|
|
259
|
+
DEFAULT_OPENAPI_TYPEGEN_CONFIG,
|
|
260
|
+
buildOpenApiTypegenArgs,
|
|
82
261
|
createEslintConfig,
|
|
83
|
-
|
|
262
|
+
createOpenApiTypegenConfig,
|
|
263
|
+
createPostcssConfig,
|
|
264
|
+
extractPlaceholders,
|
|
265
|
+
formatI18nValidationReport,
|
|
266
|
+
validateI18nCatalogs
|
|
84
267
|
});
|
|
85
268
|
//# sourceMappingURL=index.js.map
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/index.ts"],"sourcesContent":["/**\n * @scalio-cloud/ui/config — Shared build, styling and lint configuration helpers\n * for Scalio frontend apps (ADR 0151).\n */\n\nexport interface ScalioPostcssConfig {\n readonly plugins: {\n readonly tailwindcss: Record<string, never>;\n readonly autoprefixer: Record<string, never>;\n };\n}\n\n/**\n * Standard PostCSS configuration used across Scalio Tailwind 3 frontends.\n */\nexport function createPostcssConfig(): ScalioPostcssConfig {\n return {\n plugins: {\n tailwindcss: {},\n autoprefixer: {},\n },\n };\n}\n\nexport interface CreateEslintConfigOptions {\n readonly js: { readonly configs: { readonly recommended: Record<string, unknown> } };\n readonly globals: {\n readonly browser: Record<string, unknown>;\n readonly node: Record<string, unknown>;\n readonly vitest?: Record<string, unknown>;\n };\n readonly reactPlugin: unknown;\n readonly reactHooks: unknown;\n readonly ignores?: readonly string[];\n readonly rules?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Standard flat ESLint configuration shared across Scalio React frontends.\n */\nexport function createEslintConfig(options: CreateEslintConfigOptions): readonly Record<string, unknown>[] {\n const { js, globals, reactPlugin, reactHooks, ignores = [], rules = {} } = options;\n return [\n {\n ignores: [\"build/**\", \"dist/**\", \"node_modules/**\", \"src/vendor/**\", ...ignores],\n },\n js.configs.recommended,\n {\n files: [\"**/*.{js,jsx,ts,tsx,cjs,mjs}\"],\n linterOptions: {\n reportUnusedDisableDirectives: false,\n },\n languageOptions: {\n ecmaVersion: 2022,\n sourceType: \"module\",\n parserOptions: {\n ecmaFeatures: { jsx: true },\n },\n globals: {\n ...globals.browser,\n ...globals.node,\n ...(globals.vitest ?? {}),\n },\n },\n plugins: {\n react: reactPlugin,\n \"react-hooks\": reactHooks,\n },\n settings: {\n react: { version: \"detect\" },\n },\n rules: {\n \"no-unused-vars\": \"off\",\n \"no-undef\": \"off\",\n \"react/prop-types\": \"off\",\n \"react/react-in-jsx-scope\": \"off\",\n \"no-empty\": \"off\",\n \"no-constant-condition\": \"off\",\n \"no-useless-escape\": \"off\",\n \"no-prototype-builtins\": \"off\",\n ...rules,\n },\n },\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,sBAA2C;AACzD,SAAO;AAAA,IACL,SAAS;AAAA,MACP,aAAa,CAAC;AAAA,MACd,cAAc,CAAC;AAAA,IACjB;AAAA,EACF;AACF;AAkBO,SAAS,mBAAmB,SAAwE;AACzG,QAAM,EAAE,IAAI,SAAS,aAAa,YAAY,UAAU,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI;AAC3E,SAAO;AAAA,IACL;AAAA,MACE,SAAS,CAAC,YAAY,WAAW,mBAAmB,iBAAiB,GAAG,OAAO;AAAA,IACjF;AAAA,IACA,GAAG,QAAQ;AAAA,IACX;AAAA,MACE,OAAO,CAAC,8BAA8B;AAAA,MACtC,eAAe;AAAA,QACb,+BAA+B;AAAA,MACjC;AAAA,MACA,iBAAiB;AAAA,QACf,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,eAAe;AAAA,UACb,cAAc,EAAE,KAAK,KAAK;AAAA,QAC5B;AAAA,QACA,SAAS;AAAA,UACP,GAAG,QAAQ;AAAA,UACX,GAAG,QAAQ;AAAA,UACX,GAAI,QAAQ,UAAU,CAAC;AAAA,QACzB;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACP,OAAO;AAAA,QACP,eAAe;AAAA,MACjB;AAAA,MACA,UAAU;AAAA,QACR,OAAO,EAAE,SAAS,SAAS;AAAA,MAC7B;AAAA,MACA,OAAO;AAAA,QACL,kBAAkB;AAAA,QAClB,YAAY;AAAA,QACZ,oBAAoB;AAAA,QACpB,4BAA4B;AAAA,QAC5B,YAAY;AAAA,QACZ,yBAAyB;AAAA,QACzB,qBAAqB;AAAA,QACrB,yBAAyB;AAAA,QACzB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/config/index.ts","../../src/config/openapi.ts","../../src/config/i18nCheck.ts"],"sourcesContent":["/**\n * @scalio-cloud/ui/config — Shared build, styling and lint configuration helpers\n * for Scalio frontend apps (ADR 0151).\n */\n\nexport interface ScalioPostcssConfig {\n readonly plugins: {\n readonly tailwindcss: Record<string, never>;\n readonly autoprefixer: Record<string, never>;\n };\n}\n\n/**\n * Standard PostCSS configuration used across Scalio Tailwind 3 frontends.\n */\nexport function createPostcssConfig(): ScalioPostcssConfig {\n return {\n plugins: {\n tailwindcss: {},\n autoprefixer: {},\n },\n };\n}\n\nexport interface CreateEslintConfigOptions {\n readonly js: { readonly configs: { readonly recommended: Record<string, unknown> } };\n readonly globals: {\n readonly browser: Record<string, unknown>;\n readonly node: Record<string, unknown>;\n readonly vitest?: Record<string, unknown>;\n };\n readonly reactPlugin: unknown;\n readonly reactHooks: unknown;\n readonly ignores?: readonly string[];\n readonly rules?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Standard flat ESLint configuration shared across Scalio React frontends.\n */\nexport function createEslintConfig(options: CreateEslintConfigOptions): readonly Record<string, unknown>[] {\n const { js, globals, reactPlugin, reactHooks, ignores = [], rules = {} } = options;\n return [\n {\n ignores: [\"build/**\", \"dist/**\", \"node_modules/**\", \"src/vendor/**\", \"**/*.d.ts\", ...ignores],\n },\n js.configs.recommended,\n {\n files: [\"**/*.{js,jsx,cjs,mjs}\"],\n linterOptions: {\n reportUnusedDisableDirectives: false,\n },\n languageOptions: {\n ecmaVersion: 2022,\n sourceType: \"module\",\n parserOptions: {\n ecmaFeatures: { jsx: true },\n },\n globals: {\n ...globals.browser,\n ...globals.node,\n ...(globals.vitest ?? {}),\n },\n },\n plugins: {\n react: reactPlugin,\n \"react-hooks\": reactHooks,\n },\n settings: {\n react: { version: \"detect\" },\n },\n rules: {\n \"no-unused-vars\": \"off\",\n \"no-undef\": \"off\",\n \"react/prop-types\": \"off\",\n \"react/react-in-jsx-scope\": \"off\",\n \"no-empty\": \"off\",\n \"no-constant-condition\": \"off\",\n \"no-useless-escape\": \"off\",\n \"no-prototype-builtins\": \"off\",\n ...rules,\n },\n },\n ];\n}\n\nexport {\n DEFAULT_OPENAPI_TYPEGEN_CONFIG,\n createOpenApiTypegenConfig,\n buildOpenApiTypegenArgs,\n type OpenApiTypegenConfig,\n type OpenApiTypegenOverrides,\n} from \"./openapi.js\";\n\nexport {\n extractPlaceholders,\n validateI18nCatalogs,\n formatI18nValidationReport,\n type I18nCatalog,\n type I18nCatalogMap,\n type I18nIssueKind,\n type I18nValidationIssue,\n type I18nValidationOptions,\n type I18nValidationResult,\n} from \"./i18nCheck.js\";\n","/**\n * Standard OpenAPI-to-TypeScript generation configuration for Scalio frontends.\n *\n * Consumes the `openapi.json` exported by each Rust backend (`utoipa`) and produces\n * deterministic, readonly TypeScript definitions via `openapi-typescript`.\n */\n\nexport interface OpenApiTypegenConfig {\n /** Path to the OpenAPI 3.x specification file (default: `\"../openapi.json\"`). */\n readonly input: string;\n /** Output path for the generated `.d.ts` file (default: `\"src/api/schema.d.ts\"`). */\n readonly output: string;\n /** Emit `readonly` properties on generated object types (default: `true`). */\n readonly immutableTypes: boolean;\n /** Prefer `type` aliases over `interface` declarations (default: `true`). */\n readonly exportType: boolean;\n /** Sort generated keys alphabetically for minimal diffs (default: `true`). */\n readonly alphabetize: boolean;\n /** Emit `Record<string, unknown>` instead of `Record<string, never>` for open objects (default: `true`). */\n readonly emptyObjectsUnknown: boolean;\n}\n\nexport type OpenApiTypegenOverrides = Partial<OpenApiTypegenConfig>;\n\nexport const DEFAULT_OPENAPI_TYPEGEN_CONFIG: OpenApiTypegenConfig = {\n input: \"../openapi.json\",\n output: \"src/api/schema.d.ts\",\n immutableTypes: true,\n exportType: true,\n alphabetize: true,\n emptyObjectsUnknown: true,\n};\n\n/**\n * Returns the standard OpenAPI type generation configuration merged with optional overrides.\n */\nexport function createOpenApiTypegenConfig(\n overrides: OpenApiTypegenOverrides = {},\n): OpenApiTypegenConfig {\n return {\n ...DEFAULT_OPENAPI_TYPEGEN_CONFIG,\n ...overrides,\n };\n}\n\n/**\n * Builds the CLI argument list for `openapi-typescript` from a configuration object.\n *\n * Example usage in an app script:\n * `npx openapi-typescript ...buildOpenApiTypegenArgs()`\n */\nexport function buildOpenApiTypegenArgs(\n config: OpenApiTypegenOverrides = {},\n): readonly string[] {\n const resolved = createOpenApiTypegenConfig(config);\n const args: string[] = [resolved.input, \"-o\", resolved.output];\n\n if (resolved.immutableTypes) {\n args.push(\"--immutable\");\n }\n if (resolved.exportType) {\n args.push(\"--export-type\");\n }\n if (resolved.alphabetize) {\n args.push(\"--alphabetize\");\n }\n if (resolved.emptyObjectsUnknown) {\n args.push(\"--empty-objects-unknown\");\n }\n\n return args;\n}\n","/**\n * Translation catalog validator for Scalio frontends.\n *\n * Ensures that every target locale matches the English source catalog:\n * - No missing or orphan keys\n * - No empty translation values\n * - Identical `{placeholder}` / `{{placeholder}}` sets\n * - Swiss German spelling (no sharp-s `\\u00df`) in German catalogs\n */\n\nexport type I18nCatalog = Readonly<Record<string, string>>;\nexport type I18nCatalogMap = Readonly<Record<string, I18nCatalog>>;\n\nexport type I18nIssueKind =\n | \"missing-source-locale\"\n | \"missing-key\"\n | \"extra-key\"\n | \"empty-value\"\n | \"placeholder-mismatch\"\n | \"sharp-s\";\n\nexport interface I18nValidationIssue {\n readonly locale: string;\n readonly key: string;\n readonly kind: I18nIssueKind;\n readonly message: string;\n}\n\nexport interface I18nValidationOptions {\n /** Authoritative source locale (default: `\"en\"`). */\n readonly sourceLocale?: string;\n /** Report keys that exist in a target locale but not in the source locale (default: `true`). */\n readonly failOnExtraKeys?: boolean;\n /** Forbid sharp-s (`\\u00df`) in German locales (`de`, `de-*`, default: `true`). */\n readonly forbidSharpSInGerman?: boolean;\n /** Report empty or whitespace-only values (default: `true`). */\n readonly failOnEmptyValues?: boolean;\n}\n\nexport interface I18nValidationResult {\n readonly ok: boolean;\n readonly sourceLocale: string;\n readonly localesChecked: readonly string[];\n readonly issues: readonly I18nValidationIssue[];\n}\n\nconst PLACEHOLDER_RE = /\\{\\{\\s*([a-zA-Z0-9_.-]+)\\s*\\}\\}|\\{\\s*([a-zA-Z0-9_.-]+)\\s*\\}/g;\nconst SHARP_S = \"\\u00df\";\n\n/**\n * Extracts all unique `{name}` and `{{name}}` placeholders from a translation string,\n * sorted lexicographically for deterministic comparison.\n */\nexport function extractPlaceholders(text: string): readonly string[] {\n const found = new Set<string>();\n for (const match of text.matchAll(PLACEHOLDER_RE)) {\n const name = match[1] ?? match[2];\n if (name) {\n found.add(name);\n }\n }\n return Array.from(found).sort();\n}\n\nfunction isGermanLocale(locale: string): boolean {\n const lower = locale.toLowerCase();\n return lower === \"de\" || lower.startsWith(\"de-\") || lower.startsWith(\"de_\");\n}\n\nfunction sameStringList(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i += 1) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\n/**\n * Validates a map of locale catalogs (e.g. `{ en: {...}, de: {...} }`) against\n * the source locale catalog.\n */\nexport function validateI18nCatalogs(\n catalogs: I18nCatalogMap,\n options: I18nValidationOptions = {},\n): I18nValidationResult {\n const sourceLocale = options.sourceLocale ?? \"en\";\n const failOnExtraKeys = options.failOnExtraKeys ?? true;\n const forbidSharpSInGerman = options.forbidSharpSInGerman ?? true;\n const failOnEmptyValues = options.failOnEmptyValues ?? true;\n\n const issues: I18nValidationIssue[] = [];\n const localeNames = Object.keys(catalogs).sort();\n const source = catalogs[sourceLocale];\n\n if (!source) {\n issues.push({\n locale: sourceLocale,\n key: \"*\",\n kind: \"missing-source-locale\",\n message: `Source locale \"${sourceLocale}\" is missing from catalogs.`,\n });\n return {\n ok: false,\n sourceLocale,\n localesChecked: localeNames,\n issues,\n };\n }\n\n const sourceKeys = Object.keys(source).sort();\n\n // Check source catalog itself for empty values.\n if (failOnEmptyValues) {\n for (const key of sourceKeys) {\n const sourceValue = source[key];\n if (sourceValue !== undefined && sourceValue.trim().length === 0) {\n issues.push({\n locale: sourceLocale,\n key,\n kind: \"empty-value\",\n message: `Empty translation value in source locale \"${sourceLocale}\" for key \"${key}\".`,\n });\n }\n }\n }\n\n for (const locale of localeNames) {\n if (locale === sourceLocale) continue;\n const target = catalogs[locale];\n if (!target) continue;\n const targetKeys = Object.keys(target).sort();\n const checkSharpS = forbidSharpSInGerman && isGermanLocale(locale);\n\n for (const key of sourceKeys) {\n if (!Object.prototype.hasOwnProperty.call(target, key)) {\n issues.push({\n locale,\n key,\n kind: \"missing-key\",\n message: `Locale \"${locale}\" is missing key \"${key}\".`,\n });\n continue;\n }\n\n const sourceValue = source[key] ?? \"\";\n const value = target[key] ?? \"\";\n if (failOnEmptyValues && value.trim().length === 0) {\n issues.push({\n locale,\n key,\n kind: \"empty-value\",\n message: `Empty translation value in locale \"${locale}\" for key \"${key}\".`,\n });\n }\n\n const expectedPlaceholders = extractPlaceholders(sourceValue);\n const actualPlaceholders = extractPlaceholders(value);\n if (!sameStringList(expectedPlaceholders, actualPlaceholders)) {\n issues.push({\n locale,\n key,\n kind: \"placeholder-mismatch\",\n message: `Placeholder mismatch in \"${locale}.${key}\": expected [${expectedPlaceholders.join(\", \")}], got [${actualPlaceholders.join(\", \")}].`,\n });\n }\n\n if (checkSharpS && value.includes(SHARP_S)) {\n issues.push({\n locale,\n key,\n kind: \"sharp-s\",\n message: `Locale \"${locale}\" key \"${key}\" contains forbidden sharp-s; use \"ss\" instead.`,\n });\n }\n }\n\n if (failOnExtraKeys) {\n for (const key of targetKeys) {\n if (!Object.prototype.hasOwnProperty.call(source, key)) {\n issues.push({\n locale,\n key,\n kind: \"extra-key\",\n message: `Locale \"${locale}\" contains unknown key \"${key}\" not present in \"${sourceLocale}\".`,\n });\n }\n }\n }\n }\n\n return {\n ok: issues.length === 0,\n sourceLocale,\n localesChecked: localeNames,\n issues,\n };\n}\n\n/**\n * Formats an `I18nValidationResult` as a human-readable CI report.\n */\nexport function formatI18nValidationReport(result: I18nValidationResult): string {\n if (result.ok) {\n return `i18n ok (${result.localesChecked.length} locales checked against \"${result.sourceLocale}\").`;\n }\n const lines = [\n `i18n validation failed (${result.issues.length} issue${result.issues.length === 1 ? \"\" : \"s\"}):`,\n ...result.issues.map((issue) => ` - [${issue.locale}] (${issue.kind}) ${issue.message}`),\n ];\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwBO,IAAM,iCAAuD;AAAA,EAClE,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,qBAAqB;AACvB;AAKO,SAAS,2BACd,YAAqC,CAAC,GAChB;AACtB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AACF;AAQO,SAAS,wBACd,SAAkC,CAAC,GAChB;AACnB,QAAM,WAAW,2BAA2B,MAAM;AAClD,QAAM,OAAiB,CAAC,SAAS,OAAO,MAAM,SAAS,MAAM;AAE7D,MAAI,SAAS,gBAAgB;AAC3B,SAAK,KAAK,aAAa;AAAA,EACzB;AACA,MAAI,SAAS,YAAY;AACvB,SAAK,KAAK,eAAe;AAAA,EAC3B;AACA,MAAI,SAAS,aAAa;AACxB,SAAK,KAAK,eAAe;AAAA,EAC3B;AACA,MAAI,SAAS,qBAAqB;AAChC,SAAK,KAAK,yBAAyB;AAAA,EACrC;AAEA,SAAO;AACT;;;ACzBA,IAAM,iBAAiB;AACvB,IAAM,UAAU;AAMT,SAAS,oBAAoB,MAAiC;AACnE,QAAM,QAAQ,oBAAI,IAAY;AAC9B,aAAW,SAAS,KAAK,SAAS,cAAc,GAAG;AACjD,UAAM,OAAO,MAAM,CAAC,KAAK,MAAM,CAAC;AAChC,QAAI,MAAM;AACR,YAAM,IAAI,IAAI;AAAA,IAChB;AAAA,EACF;AACA,SAAO,MAAM,KAAK,KAAK,EAA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;AAAA,UACb,cAAc,EAAE,KAAK,KAAK;AAAA,QAC5B;AAAA,QACA,SAAS;AAAA,UACP,GAAG,QAAQ;AAAA,UACX,GAAG,QAAQ;AAAA,UACX,GAAI,QAAQ,UAAU,CAAC;AAAA,QACzB;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACP,OAAO;AAAA,QACP,eAAe;AAAA,MACjB;AAAA,MACA,UAAU;AAAA,QACR,OAAO,EAAE,SAAS,SAAS;AAAA,MAC7B;AAAA,MACA,OAAO;AAAA,QACL,kBAAkB;AAAA,QAClB,YAAY;AAAA,QACZ,oBAAoB;AAAA,QACpB,4BAA4B;AAAA,QAC5B,YAAY;AAAA,QACZ,yBAAyB;AAAA,QACzB,qBAAqB;AAAA,QACrB,yBAAyB;AAAA,QACzB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/config/index.mjs
CHANGED
|
@@ -1,3 +1,172 @@
|
|
|
1
|
+
// src/config/openapi.ts
|
|
2
|
+
var DEFAULT_OPENAPI_TYPEGEN_CONFIG = {
|
|
3
|
+
input: "../openapi.json",
|
|
4
|
+
output: "src/api/schema.d.ts",
|
|
5
|
+
immutableTypes: true,
|
|
6
|
+
exportType: true,
|
|
7
|
+
alphabetize: true,
|
|
8
|
+
emptyObjectsUnknown: true
|
|
9
|
+
};
|
|
10
|
+
function createOpenApiTypegenConfig(overrides = {}) {
|
|
11
|
+
return {
|
|
12
|
+
...DEFAULT_OPENAPI_TYPEGEN_CONFIG,
|
|
13
|
+
...overrides
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function buildOpenApiTypegenArgs(config = {}) {
|
|
17
|
+
const resolved = createOpenApiTypegenConfig(config);
|
|
18
|
+
const args = [resolved.input, "-o", resolved.output];
|
|
19
|
+
if (resolved.immutableTypes) {
|
|
20
|
+
args.push("--immutable");
|
|
21
|
+
}
|
|
22
|
+
if (resolved.exportType) {
|
|
23
|
+
args.push("--export-type");
|
|
24
|
+
}
|
|
25
|
+
if (resolved.alphabetize) {
|
|
26
|
+
args.push("--alphabetize");
|
|
27
|
+
}
|
|
28
|
+
if (resolved.emptyObjectsUnknown) {
|
|
29
|
+
args.push("--empty-objects-unknown");
|
|
30
|
+
}
|
|
31
|
+
return args;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/config/i18nCheck.ts
|
|
35
|
+
var PLACEHOLDER_RE = /\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}|\{\s*([a-zA-Z0-9_.-]+)\s*\}/g;
|
|
36
|
+
var SHARP_S = "\xDF";
|
|
37
|
+
function extractPlaceholders(text) {
|
|
38
|
+
const found = /* @__PURE__ */ new Set();
|
|
39
|
+
for (const match of text.matchAll(PLACEHOLDER_RE)) {
|
|
40
|
+
const name = match[1] ?? match[2];
|
|
41
|
+
if (name) {
|
|
42
|
+
found.add(name);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return Array.from(found).sort();
|
|
46
|
+
}
|
|
47
|
+
function isGermanLocale(locale) {
|
|
48
|
+
const lower = locale.toLowerCase();
|
|
49
|
+
return lower === "de" || lower.startsWith("de-") || lower.startsWith("de_");
|
|
50
|
+
}
|
|
51
|
+
function sameStringList(a, b) {
|
|
52
|
+
if (a.length !== b.length) return false;
|
|
53
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
54
|
+
if (a[i] !== b[i]) return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
function validateI18nCatalogs(catalogs, options = {}) {
|
|
59
|
+
const sourceLocale = options.sourceLocale ?? "en";
|
|
60
|
+
const failOnExtraKeys = options.failOnExtraKeys ?? true;
|
|
61
|
+
const forbidSharpSInGerman = options.forbidSharpSInGerman ?? true;
|
|
62
|
+
const failOnEmptyValues = options.failOnEmptyValues ?? true;
|
|
63
|
+
const issues = [];
|
|
64
|
+
const localeNames = Object.keys(catalogs).sort();
|
|
65
|
+
const source = catalogs[sourceLocale];
|
|
66
|
+
if (!source) {
|
|
67
|
+
issues.push({
|
|
68
|
+
locale: sourceLocale,
|
|
69
|
+
key: "*",
|
|
70
|
+
kind: "missing-source-locale",
|
|
71
|
+
message: `Source locale "${sourceLocale}" is missing from catalogs.`
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
ok: false,
|
|
75
|
+
sourceLocale,
|
|
76
|
+
localesChecked: localeNames,
|
|
77
|
+
issues
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const sourceKeys = Object.keys(source).sort();
|
|
81
|
+
if (failOnEmptyValues) {
|
|
82
|
+
for (const key of sourceKeys) {
|
|
83
|
+
const sourceValue = source[key];
|
|
84
|
+
if (sourceValue !== void 0 && sourceValue.trim().length === 0) {
|
|
85
|
+
issues.push({
|
|
86
|
+
locale: sourceLocale,
|
|
87
|
+
key,
|
|
88
|
+
kind: "empty-value",
|
|
89
|
+
message: `Empty translation value in source locale "${sourceLocale}" for key "${key}".`
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (const locale of localeNames) {
|
|
95
|
+
if (locale === sourceLocale) continue;
|
|
96
|
+
const target = catalogs[locale];
|
|
97
|
+
if (!target) continue;
|
|
98
|
+
const targetKeys = Object.keys(target).sort();
|
|
99
|
+
const checkSharpS = forbidSharpSInGerman && isGermanLocale(locale);
|
|
100
|
+
for (const key of sourceKeys) {
|
|
101
|
+
if (!Object.prototype.hasOwnProperty.call(target, key)) {
|
|
102
|
+
issues.push({
|
|
103
|
+
locale,
|
|
104
|
+
key,
|
|
105
|
+
kind: "missing-key",
|
|
106
|
+
message: `Locale "${locale}" is missing key "${key}".`
|
|
107
|
+
});
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const sourceValue = source[key] ?? "";
|
|
111
|
+
const value = target[key] ?? "";
|
|
112
|
+
if (failOnEmptyValues && value.trim().length === 0) {
|
|
113
|
+
issues.push({
|
|
114
|
+
locale,
|
|
115
|
+
key,
|
|
116
|
+
kind: "empty-value",
|
|
117
|
+
message: `Empty translation value in locale "${locale}" for key "${key}".`
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const expectedPlaceholders = extractPlaceholders(sourceValue);
|
|
121
|
+
const actualPlaceholders = extractPlaceholders(value);
|
|
122
|
+
if (!sameStringList(expectedPlaceholders, actualPlaceholders)) {
|
|
123
|
+
issues.push({
|
|
124
|
+
locale,
|
|
125
|
+
key,
|
|
126
|
+
kind: "placeholder-mismatch",
|
|
127
|
+
message: `Placeholder mismatch in "${locale}.${key}": expected [${expectedPlaceholders.join(", ")}], got [${actualPlaceholders.join(", ")}].`
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (checkSharpS && value.includes(SHARP_S)) {
|
|
131
|
+
issues.push({
|
|
132
|
+
locale,
|
|
133
|
+
key,
|
|
134
|
+
kind: "sharp-s",
|
|
135
|
+
message: `Locale "${locale}" key "${key}" contains forbidden sharp-s; use "ss" instead.`
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (failOnExtraKeys) {
|
|
140
|
+
for (const key of targetKeys) {
|
|
141
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) {
|
|
142
|
+
issues.push({
|
|
143
|
+
locale,
|
|
144
|
+
key,
|
|
145
|
+
kind: "extra-key",
|
|
146
|
+
message: `Locale "${locale}" contains unknown key "${key}" not present in "${sourceLocale}".`
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
ok: issues.length === 0,
|
|
154
|
+
sourceLocale,
|
|
155
|
+
localesChecked: localeNames,
|
|
156
|
+
issues
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function formatI18nValidationReport(result) {
|
|
160
|
+
if (result.ok) {
|
|
161
|
+
return `i18n ok (${result.localesChecked.length} locales checked against "${result.sourceLocale}").`;
|
|
162
|
+
}
|
|
163
|
+
const lines = [
|
|
164
|
+
`i18n validation failed (${result.issues.length} issue${result.issues.length === 1 ? "" : "s"}):`,
|
|
165
|
+
...result.issues.map((issue) => ` - [${issue.locale}] (${issue.kind}) ${issue.message}`)
|
|
166
|
+
];
|
|
167
|
+
return lines.join("\n");
|
|
168
|
+
}
|
|
169
|
+
|
|
1
170
|
// src/config/index.ts
|
|
2
171
|
function createPostcssConfig() {
|
|
3
172
|
return {
|
|
@@ -11,11 +180,11 @@ function createEslintConfig(options) {
|
|
|
11
180
|
const { js, globals, reactPlugin, reactHooks, ignores = [], rules = {} } = options;
|
|
12
181
|
return [
|
|
13
182
|
{
|
|
14
|
-
ignores: ["build/**", "dist/**", "node_modules/**", "src/vendor/**", ...ignores]
|
|
183
|
+
ignores: ["build/**", "dist/**", "node_modules/**", "src/vendor/**", "**/*.d.ts", ...ignores]
|
|
15
184
|
},
|
|
16
185
|
js.configs.recommended,
|
|
17
186
|
{
|
|
18
|
-
files: ["**/*.{js,jsx,
|
|
187
|
+
files: ["**/*.{js,jsx,cjs,mjs}"],
|
|
19
188
|
linterOptions: {
|
|
20
189
|
reportUnusedDisableDirectives: false
|
|
21
190
|
},
|
|
@@ -53,7 +222,13 @@ function createEslintConfig(options) {
|
|
|
53
222
|
];
|
|
54
223
|
}
|
|
55
224
|
export {
|
|
225
|
+
DEFAULT_OPENAPI_TYPEGEN_CONFIG,
|
|
226
|
+
buildOpenApiTypegenArgs,
|
|
56
227
|
createEslintConfig,
|
|
57
|
-
|
|
228
|
+
createOpenApiTypegenConfig,
|
|
229
|
+
createPostcssConfig,
|
|
230
|
+
extractPlaceholders,
|
|
231
|
+
formatI18nValidationReport,
|
|
232
|
+
validateI18nCatalogs
|
|
58
233
|
};
|
|
59
234
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/index.ts"],"sourcesContent":["/**\n * @scalio-cloud/ui/config — Shared build, styling and lint configuration helpers\n * for Scalio frontend apps (ADR 0151).\n */\n\nexport interface ScalioPostcssConfig {\n readonly plugins: {\n readonly tailwindcss: Record<string, never>;\n readonly autoprefixer: Record<string, never>;\n };\n}\n\n/**\n * Standard PostCSS configuration used across Scalio Tailwind 3 frontends.\n */\nexport function createPostcssConfig(): ScalioPostcssConfig {\n return {\n plugins: {\n tailwindcss: {},\n autoprefixer: {},\n },\n };\n}\n\nexport interface CreateEslintConfigOptions {\n readonly js: { readonly configs: { readonly recommended: Record<string, unknown> } };\n readonly globals: {\n readonly browser: Record<string, unknown>;\n readonly node: Record<string, unknown>;\n readonly vitest?: Record<string, unknown>;\n };\n readonly reactPlugin: unknown;\n readonly reactHooks: unknown;\n readonly ignores?: readonly string[];\n readonly rules?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Standard flat ESLint configuration shared across Scalio React frontends.\n */\nexport function createEslintConfig(options: CreateEslintConfigOptions): readonly Record<string, unknown>[] {\n const { js, globals, reactPlugin, reactHooks, ignores = [], rules = {} } = options;\n return [\n {\n ignores: [\"build/**\", \"dist/**\", \"node_modules/**\", \"src/vendor/**\", ...ignores],\n },\n js.configs.recommended,\n {\n files: [\"**/*.{js,jsx,ts,tsx,cjs,mjs}\"],\n linterOptions: {\n reportUnusedDisableDirectives: false,\n },\n languageOptions: {\n ecmaVersion: 2022,\n sourceType: \"module\",\n parserOptions: {\n ecmaFeatures: { jsx: true },\n },\n globals: {\n ...globals.browser,\n ...globals.node,\n ...(globals.vitest ?? {}),\n },\n },\n plugins: {\n react: reactPlugin,\n \"react-hooks\": reactHooks,\n },\n settings: {\n react: { version: \"detect\" },\n },\n rules: {\n \"no-unused-vars\": \"off\",\n \"no-undef\": \"off\",\n \"react/prop-types\": \"off\",\n \"react/react-in-jsx-scope\": \"off\",\n \"no-empty\": \"off\",\n \"no-constant-condition\": \"off\",\n \"no-useless-escape\": \"off\",\n \"no-prototype-builtins\": \"off\",\n ...rules,\n },\n },\n ];\n}\n"],"mappings":";AAeO,SAAS,sBAA2C;AACzD,SAAO;AAAA,IACL,SAAS;AAAA,MACP,aAAa,CAAC;AAAA,MACd,cAAc,CAAC;AAAA,IACjB;AAAA,EACF;AACF;AAkBO,SAAS,mBAAmB,SAAwE;AACzG,QAAM,EAAE,IAAI,SAAS,aAAa,YAAY,UAAU,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI;AAC3E,SAAO;AAAA,IACL;AAAA,MACE,SAAS,CAAC,YAAY,WAAW,mBAAmB,iBAAiB,GAAG,OAAO;AAAA,IACjF;AAAA,IACA,GAAG,QAAQ;AAAA,IACX;AAAA,MACE,OAAO,CAAC,8BAA8B;AAAA,MACtC,eAAe;AAAA,QACb,+BAA+B;AAAA,MACjC;AAAA,MACA,iBAAiB;AAAA,QACf,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,eAAe;AAAA,UACb,cAAc,EAAE,KAAK,KAAK;AAAA,QAC5B;AAAA,QACA,SAAS;AAAA,UACP,GAAG,QAAQ;AAAA,UACX,GAAG,QAAQ;AAAA,UACX,GAAI,QAAQ,UAAU,CAAC;AAAA,QACzB;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACP,OAAO;AAAA,QACP,eAAe;AAAA,MACjB;AAAA,MACA,UAAU;AAAA,QACR,OAAO,EAAE,SAAS,SAAS;AAAA,MAC7B;AAAA,MACA,OAAO;AAAA,QACL,kBAAkB;AAAA,QAClB,YAAY;AAAA,QACZ,oBAAoB;AAAA,QACpB,4BAA4B;AAAA,QAC5B,YAAY;AAAA,QACZ,yBAAyB;AAAA,QACzB,qBAAqB;AAAA,QACrB,yBAAyB;AAAA,QACzB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/config/openapi.ts","../../src/config/i18nCheck.ts","../../src/config/index.ts"],"sourcesContent":["/**\n * Standard OpenAPI-to-TypeScript generation configuration for Scalio frontends.\n *\n * Consumes the `openapi.json` exported by each Rust backend (`utoipa`) and produces\n * deterministic, readonly TypeScript definitions via `openapi-typescript`.\n */\n\nexport interface OpenApiTypegenConfig {\n /** Path to the OpenAPI 3.x specification file (default: `\"../openapi.json\"`). */\n readonly input: string;\n /** Output path for the generated `.d.ts` file (default: `\"src/api/schema.d.ts\"`). */\n readonly output: string;\n /** Emit `readonly` properties on generated object types (default: `true`). */\n readonly immutableTypes: boolean;\n /** Prefer `type` aliases over `interface` declarations (default: `true`). */\n readonly exportType: boolean;\n /** Sort generated keys alphabetically for minimal diffs (default: `true`). */\n readonly alphabetize: boolean;\n /** Emit `Record<string, unknown>` instead of `Record<string, never>` for open objects (default: `true`). */\n readonly emptyObjectsUnknown: boolean;\n}\n\nexport type OpenApiTypegenOverrides = Partial<OpenApiTypegenConfig>;\n\nexport const DEFAULT_OPENAPI_TYPEGEN_CONFIG: OpenApiTypegenConfig = {\n input: \"../openapi.json\",\n output: \"src/api/schema.d.ts\",\n immutableTypes: true,\n exportType: true,\n alphabetize: true,\n emptyObjectsUnknown: true,\n};\n\n/**\n * Returns the standard OpenAPI type generation configuration merged with optional overrides.\n */\nexport function createOpenApiTypegenConfig(\n overrides: OpenApiTypegenOverrides = {},\n): OpenApiTypegenConfig {\n return {\n ...DEFAULT_OPENAPI_TYPEGEN_CONFIG,\n ...overrides,\n };\n}\n\n/**\n * Builds the CLI argument list for `openapi-typescript` from a configuration object.\n *\n * Example usage in an app script:\n * `npx openapi-typescript ...buildOpenApiTypegenArgs()`\n */\nexport function buildOpenApiTypegenArgs(\n config: OpenApiTypegenOverrides = {},\n): readonly string[] {\n const resolved = createOpenApiTypegenConfig(config);\n const args: string[] = [resolved.input, \"-o\", resolved.output];\n\n if (resolved.immutableTypes) {\n args.push(\"--immutable\");\n }\n if (resolved.exportType) {\n args.push(\"--export-type\");\n }\n if (resolved.alphabetize) {\n args.push(\"--alphabetize\");\n }\n if (resolved.emptyObjectsUnknown) {\n args.push(\"--empty-objects-unknown\");\n }\n\n return args;\n}\n","/**\n * Translation catalog validator for Scalio frontends.\n *\n * Ensures that every target locale matches the English source catalog:\n * - No missing or orphan keys\n * - No empty translation values\n * - Identical `{placeholder}` / `{{placeholder}}` sets\n * - Swiss German spelling (no sharp-s `\\u00df`) in German catalogs\n */\n\nexport type I18nCatalog = Readonly<Record<string, string>>;\nexport type I18nCatalogMap = Readonly<Record<string, I18nCatalog>>;\n\nexport type I18nIssueKind =\n | \"missing-source-locale\"\n | \"missing-key\"\n | \"extra-key\"\n | \"empty-value\"\n | \"placeholder-mismatch\"\n | \"sharp-s\";\n\nexport interface I18nValidationIssue {\n readonly locale: string;\n readonly key: string;\n readonly kind: I18nIssueKind;\n readonly message: string;\n}\n\nexport interface I18nValidationOptions {\n /** Authoritative source locale (default: `\"en\"`). */\n readonly sourceLocale?: string;\n /** Report keys that exist in a target locale but not in the source locale (default: `true`). */\n readonly failOnExtraKeys?: boolean;\n /** Forbid sharp-s (`\\u00df`) in German locales (`de`, `de-*`, default: `true`). */\n readonly forbidSharpSInGerman?: boolean;\n /** Report empty or whitespace-only values (default: `true`). */\n readonly failOnEmptyValues?: boolean;\n}\n\nexport interface I18nValidationResult {\n readonly ok: boolean;\n readonly sourceLocale: string;\n readonly localesChecked: readonly string[];\n readonly issues: readonly I18nValidationIssue[];\n}\n\nconst PLACEHOLDER_RE = /\\{\\{\\s*([a-zA-Z0-9_.-]+)\\s*\\}\\}|\\{\\s*([a-zA-Z0-9_.-]+)\\s*\\}/g;\nconst SHARP_S = \"\\u00df\";\n\n/**\n * Extracts all unique `{name}` and `{{name}}` placeholders from a translation string,\n * sorted lexicographically for deterministic comparison.\n */\nexport function extractPlaceholders(text: string): readonly string[] {\n const found = new Set<string>();\n for (const match of text.matchAll(PLACEHOLDER_RE)) {\n const name = match[1] ?? match[2];\n if (name) {\n found.add(name);\n }\n }\n return Array.from(found).sort();\n}\n\nfunction isGermanLocale(locale: string): boolean {\n const lower = locale.toLowerCase();\n return lower === \"de\" || lower.startsWith(\"de-\") || lower.startsWith(\"de_\");\n}\n\nfunction sameStringList(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i += 1) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\n/**\n * Validates a map of locale catalogs (e.g. `{ en: {...}, de: {...} }`) against\n * the source locale catalog.\n */\nexport function validateI18nCatalogs(\n catalogs: I18nCatalogMap,\n options: I18nValidationOptions = {},\n): I18nValidationResult {\n const sourceLocale = options.sourceLocale ?? \"en\";\n const failOnExtraKeys = options.failOnExtraKeys ?? true;\n const forbidSharpSInGerman = options.forbidSharpSInGerman ?? true;\n const failOnEmptyValues = options.failOnEmptyValues ?? true;\n\n const issues: I18nValidationIssue[] = [];\n const localeNames = Object.keys(catalogs).sort();\n const source = catalogs[sourceLocale];\n\n if (!source) {\n issues.push({\n locale: sourceLocale,\n key: \"*\",\n kind: \"missing-source-locale\",\n message: `Source locale \"${sourceLocale}\" is missing from catalogs.`,\n });\n return {\n ok: false,\n sourceLocale,\n localesChecked: localeNames,\n issues,\n };\n }\n\n const sourceKeys = Object.keys(source).sort();\n\n // Check source catalog itself for empty values.\n if (failOnEmptyValues) {\n for (const key of sourceKeys) {\n const sourceValue = source[key];\n if (sourceValue !== undefined && sourceValue.trim().length === 0) {\n issues.push({\n locale: sourceLocale,\n key,\n kind: \"empty-value\",\n message: `Empty translation value in source locale \"${sourceLocale}\" for key \"${key}\".`,\n });\n }\n }\n }\n\n for (const locale of localeNames) {\n if (locale === sourceLocale) continue;\n const target = catalogs[locale];\n if (!target) continue;\n const targetKeys = Object.keys(target).sort();\n const checkSharpS = forbidSharpSInGerman && isGermanLocale(locale);\n\n for (const key of sourceKeys) {\n if (!Object.prototype.hasOwnProperty.call(target, key)) {\n issues.push({\n locale,\n key,\n kind: \"missing-key\",\n message: `Locale \"${locale}\" is missing key \"${key}\".`,\n });\n continue;\n }\n\n const sourceValue = source[key] ?? \"\";\n const value = target[key] ?? \"\";\n if (failOnEmptyValues && value.trim().length === 0) {\n issues.push({\n locale,\n key,\n kind: \"empty-value\",\n message: `Empty translation value in locale \"${locale}\" for key \"${key}\".`,\n });\n }\n\n const expectedPlaceholders = extractPlaceholders(sourceValue);\n const actualPlaceholders = extractPlaceholders(value);\n if (!sameStringList(expectedPlaceholders, actualPlaceholders)) {\n issues.push({\n locale,\n key,\n kind: \"placeholder-mismatch\",\n message: `Placeholder mismatch in \"${locale}.${key}\": expected [${expectedPlaceholders.join(\", \")}], got [${actualPlaceholders.join(\", \")}].`,\n });\n }\n\n if (checkSharpS && value.includes(SHARP_S)) {\n issues.push({\n locale,\n key,\n kind: \"sharp-s\",\n message: `Locale \"${locale}\" key \"${key}\" contains forbidden sharp-s; use \"ss\" instead.`,\n });\n }\n }\n\n if (failOnExtraKeys) {\n for (const key of targetKeys) {\n if (!Object.prototype.hasOwnProperty.call(source, key)) {\n issues.push({\n locale,\n key,\n kind: \"extra-key\",\n message: `Locale \"${locale}\" contains unknown key \"${key}\" not present in \"${sourceLocale}\".`,\n });\n }\n }\n }\n }\n\n return {\n ok: issues.length === 0,\n sourceLocale,\n localesChecked: localeNames,\n issues,\n };\n}\n\n/**\n * Formats an `I18nValidationResult` as a human-readable CI report.\n */\nexport function formatI18nValidationReport(result: I18nValidationResult): string {\n if (result.ok) {\n return `i18n ok (${result.localesChecked.length} locales checked against \"${result.sourceLocale}\").`;\n }\n const lines = [\n `i18n validation failed (${result.issues.length} issue${result.issues.length === 1 ? \"\" : \"s\"}):`,\n ...result.issues.map((issue) => ` - [${issue.locale}] (${issue.kind}) ${issue.message}`),\n ];\n return lines.join(\"\\n\");\n}\n","/**\n * @scalio-cloud/ui/config — Shared build, styling and lint configuration helpers\n * for Scalio frontend apps (ADR 0151).\n */\n\nexport interface ScalioPostcssConfig {\n readonly plugins: {\n readonly tailwindcss: Record<string, never>;\n readonly autoprefixer: Record<string, never>;\n };\n}\n\n/**\n * Standard PostCSS configuration used across Scalio Tailwind 3 frontends.\n */\nexport function createPostcssConfig(): ScalioPostcssConfig {\n return {\n plugins: {\n tailwindcss: {},\n autoprefixer: {},\n },\n };\n}\n\nexport interface CreateEslintConfigOptions {\n readonly js: { readonly configs: { readonly recommended: Record<string, unknown> } };\n readonly globals: {\n readonly browser: Record<string, unknown>;\n readonly node: Record<string, unknown>;\n readonly vitest?: Record<string, unknown>;\n };\n readonly reactPlugin: unknown;\n readonly reactHooks: unknown;\n readonly ignores?: readonly string[];\n readonly rules?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Standard flat ESLint configuration shared across Scalio React frontends.\n */\nexport function createEslintConfig(options: CreateEslintConfigOptions): readonly Record<string, unknown>[] {\n const { js, globals, reactPlugin, reactHooks, ignores = [], rules = {} } = options;\n return [\n {\n ignores: [\"build/**\", \"dist/**\", \"node_modules/**\", \"src/vendor/**\", \"**/*.d.ts\", ...ignores],\n },\n js.configs.recommended,\n {\n files: [\"**/*.{js,jsx,cjs,mjs}\"],\n linterOptions: {\n reportUnusedDisableDirectives: false,\n },\n languageOptions: {\n ecmaVersion: 2022,\n sourceType: \"module\",\n parserOptions: {\n ecmaFeatures: { jsx: true },\n },\n globals: {\n ...globals.browser,\n ...globals.node,\n ...(globals.vitest ?? {}),\n },\n },\n plugins: {\n react: reactPlugin,\n \"react-hooks\": reactHooks,\n },\n settings: {\n react: { version: \"detect\" },\n },\n rules: {\n \"no-unused-vars\": \"off\",\n \"no-undef\": \"off\",\n \"react/prop-types\": \"off\",\n \"react/react-in-jsx-scope\": \"off\",\n \"no-empty\": \"off\",\n \"no-constant-condition\": \"off\",\n \"no-useless-escape\": \"off\",\n \"no-prototype-builtins\": \"off\",\n ...rules,\n },\n },\n ];\n}\n\nexport {\n DEFAULT_OPENAPI_TYPEGEN_CONFIG,\n createOpenApiTypegenConfig,\n buildOpenApiTypegenArgs,\n type OpenApiTypegenConfig,\n type OpenApiTypegenOverrides,\n} from \"./openapi.js\";\n\nexport {\n extractPlaceholders,\n validateI18nCatalogs,\n formatI18nValidationReport,\n type I18nCatalog,\n type I18nCatalogMap,\n type I18nIssueKind,\n type I18nValidationIss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AU;AAAA,QACR,OAAO,EAAE,SAAS,SAAS;AAAA,MAC7B;AAAA,MACA,OAAO;AAAA,QACL,kBAAkB;AAAA,QAClB,YAAY;AAAA,QACZ,oBAAoB;AAAA,QACpB,4BAA4B;AAAA,QAC5B,YAAY;AAAA,QACZ,yBAAyB;AAAA,QACzB,qBAAqB;AAAA,QACrB,yBAAyB;AAAA,QACzB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard OpenAPI-to-TypeScript generation configuration for Scalio frontends.
|
|
3
|
+
*
|
|
4
|
+
* Consumes the `openapi.json` exported by each Rust backend (`utoipa`) and produces
|
|
5
|
+
* deterministic, readonly TypeScript definitions via `openapi-typescript`.
|
|
6
|
+
*/
|
|
7
|
+
export interface OpenApiTypegenConfig {
|
|
8
|
+
/** Path to the OpenAPI 3.x specification file (default: `"../openapi.json"`). */
|
|
9
|
+
readonly input: string;
|
|
10
|
+
/** Output path for the generated `.d.ts` file (default: `"src/api/schema.d.ts"`). */
|
|
11
|
+
readonly output: string;
|
|
12
|
+
/** Emit `readonly` properties on generated object types (default: `true`). */
|
|
13
|
+
readonly immutableTypes: boolean;
|
|
14
|
+
/** Prefer `type` aliases over `interface` declarations (default: `true`). */
|
|
15
|
+
readonly exportType: boolean;
|
|
16
|
+
/** Sort generated keys alphabetically for minimal diffs (default: `true`). */
|
|
17
|
+
readonly alphabetize: boolean;
|
|
18
|
+
/** Emit `Record<string, unknown>` instead of `Record<string, never>` for open objects (default: `true`). */
|
|
19
|
+
readonly emptyObjectsUnknown: boolean;
|
|
20
|
+
}
|
|
21
|
+
export type OpenApiTypegenOverrides = Partial<OpenApiTypegenConfig>;
|
|
22
|
+
export declare const DEFAULT_OPENAPI_TYPEGEN_CONFIG: OpenApiTypegenConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the standard OpenAPI type generation configuration merged with optional overrides.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createOpenApiTypegenConfig(overrides?: OpenApiTypegenOverrides): OpenApiTypegenConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Builds the CLI argument list for `openapi-typescript` from a configuration object.
|
|
29
|
+
*
|
|
30
|
+
* Example usage in an app script:
|
|
31
|
+
* `npx openapi-typescript ...buildOpenApiTypegenArgs()`
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildOpenApiTypegenArgs(config?: OpenApiTypegenOverrides): readonly string[];
|
|
34
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/config/openapi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,oBAAoB;IACnC,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,8EAA8E;IAC9E,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,4GAA4G;IAC5G,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;CACvC;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEpE,eAAO,MAAM,8BAA8B,EAAE,oBAO5C,CAAC;AAEF;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,GAAE,uBAA4B,GACtC,oBAAoB,CAKtB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,GAAE,uBAA4B,GACnC,SAAS,MAAM,EAAE,CAkBnB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ScalioLang } from "../core/index.js";
|
|
3
|
+
export interface RichTextEditorLabels {
|
|
4
|
+
readonly richText: string;
|
|
5
|
+
readonly html: string;
|
|
6
|
+
readonly toolbarLabel: string;
|
|
7
|
+
readonly heading1: string;
|
|
8
|
+
readonly heading2: string;
|
|
9
|
+
readonly heading3: string;
|
|
10
|
+
readonly bold: string;
|
|
11
|
+
readonly italic: string;
|
|
12
|
+
readonly underline: string;
|
|
13
|
+
readonly bulletList: string;
|
|
14
|
+
readonly orderedList: string;
|
|
15
|
+
readonly link: string;
|
|
16
|
+
readonly unlink: string;
|
|
17
|
+
readonly clearFormatting: string;
|
|
18
|
+
readonly linkUrlPlaceholder: string;
|
|
19
|
+
readonly applyLink: string;
|
|
20
|
+
readonly cancel: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const DEFAULT_RICH_TEXT_LABELS: Readonly<Record<ScalioLang, RichTextEditorLabels>>;
|
|
23
|
+
export interface RichTextEditorProps {
|
|
24
|
+
/** Controlled HTML value. */
|
|
25
|
+
readonly value: string;
|
|
26
|
+
/** Called with updated HTML on every edit. */
|
|
27
|
+
readonly onChange: (html: string) => void;
|
|
28
|
+
/** Test identifier prefix (matches legacy `RichTextEditor` test IDs). */
|
|
29
|
+
readonly testId?: string;
|
|
30
|
+
/** UI language for toolbar tooltips and tabs (`"en"` default, `"de"` uses Swiss spelling). */
|
|
31
|
+
readonly lang?: ScalioLang;
|
|
32
|
+
/** Optional label overrides. */
|
|
33
|
+
readonly labels?: Partial<RichTextEditorLabels>;
|
|
34
|
+
/** Disable editing (read-only view). */
|
|
35
|
+
readonly disabled?: boolean;
|
|
36
|
+
/** Allow switching to raw HTML mode (default: `true`). */
|
|
37
|
+
readonly allowHtmlMode?: boolean;
|
|
38
|
+
/** Minimum height CSS class for editor area (default: `"min-h-[320px]"`). */
|
|
39
|
+
readonly minHeightClass?: string;
|
|
40
|
+
/** Optional extra container class name. */
|
|
41
|
+
readonly className?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalize and validate a user-entered link URL. Rejects `javascript:` and similar schemes.
|
|
45
|
+
*/
|
|
46
|
+
export declare function sanitizeLinkUrl(raw: string): string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Standardized, accessible Rich-Text Editor on `@tiptap/react` (ADR 0151 fe/F10).
|
|
49
|
+
*
|
|
50
|
+
* 1:1 drop-in replacement for `react-quill-new` across Scalio frontends:
|
|
51
|
+
* - Semantic `@scalio-cloud/ui` tokens (light and dark mode)
|
|
52
|
+
* - WCAG 2.2 AA toolbar (`role="toolbar"`, `aria-pressed`, keyboard focus rings)
|
|
53
|
+
* - Inline link input (no browser `window.prompt()` popups)
|
|
54
|
+
* - Optional raw HTML view (`data-testid="${testId}-mode-html"` / `${testId}-html`)
|
|
55
|
+
*/
|
|
56
|
+
export declare function RichTextEditor({ value, onChange, testId, lang, labels: labelOverrides, disabled, allowHtmlMode, minHeightClass, className, }: RichTextEditorProps): React.ReactElement;
|
|
57
|
+
export declare const ScalioRichTextEditor: typeof RichTextEditor;
|
|
58
|
+
//# sourceMappingURL=RichTextEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../../src/editor/RichTextEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAkBnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,Q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,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,MAA2B,EAC3B,IAAW,EACX,MAAM,EAAE,cAAc,EACtB,QAAgB,EAChB,aAAoB,EACpB,cAAgC,EAChC,SAAc,GACf,EAAE,mBAAmB,GAAG,KAAK,CAAC,YAAY,CAuQ1C;AAED,eAAO,MAAM,oBAAoB,uBAAiB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @scalio-cloud/ui/editor — Shared accessible TipTap Rich-Text Editor (ADR 0151 fe/F10).
|
|
3
|
+
*/
|
|
4
|
+
export { DEFAULT_RICH_TEXT_LABELS, RichTextEditor, ScalioRichTextEditor, sanitizeLinkUrl, type RichTextEditorLabels, type RichTextEditorProps, } from "./RichTextEditor.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/editor/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC"}
|