@hyvor/design 0.0.54 → 0.0.56
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/components/FormControl/Caption.svelte +1 -1
- package/dist/components/FormControl/Caption.svelte.d.ts +1 -0
- package/dist/components/FormControl/InputGroup.svelte +1 -1
- package/dist/components/FormControl/InputGroup.svelte.d.ts +1 -0
- package/dist/components/FormControl/Validation.svelte +2 -1
- package/dist/components/FormControl/Validation.svelte.d.ts +3 -0
- package/dist/components/Internationalization/T.svelte +34 -20
- package/dist/components/Internationalization/T.svelte.d.ts +2 -1
- package/dist/components/Internationalization/i18n.d.ts +2 -0
- package/dist/components/Internationalization/i18n.js +4 -0
- package/dist/components/Internationalization/t.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script>import { IconCheckCircleFill, IconExclamationTriangleFill, IconInfoCircleFill } from "@hyvor/icons";
|
|
2
2
|
export let state = "error";
|
|
3
|
+
export let role = "alert";
|
|
3
4
|
</script>
|
|
4
5
|
|
|
5
|
-
<div class="validation {state}">
|
|
6
|
+
<div class="validation {state}" {role} {...$$restProps}>
|
|
6
7
|
<div class="icon">
|
|
7
8
|
|
|
8
9
|
{#if state === 'error'}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { AriaRole } from "svelte/elements";
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
5
|
+
[x: string]: any;
|
|
4
6
|
state?: "error" | "success" | "warning" | undefined;
|
|
7
|
+
role?: AriaRole | undefined;
|
|
5
8
|
};
|
|
6
9
|
events: {
|
|
7
10
|
[evt: string]: CustomEvent<any>;
|
|
@@ -6,16 +6,26 @@ import { getMessage as getMessageBase } from "./t.js";
|
|
|
6
6
|
export let key;
|
|
7
7
|
export let params = {};
|
|
8
8
|
let hasComponentParams = false;
|
|
9
|
+
function getElementFunc(el) {
|
|
10
|
+
return (chunks) => {
|
|
11
|
+
const children = typeof chunks === "string" ? chunks : chunks.join("");
|
|
12
|
+
return `<${el}>${children}</${el}>`;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
9
15
|
function getParamsForBackend() {
|
|
10
16
|
let retParams = {};
|
|
11
17
|
for (let [key2, value] of Object.entries(params)) {
|
|
12
18
|
let newValue;
|
|
13
|
-
if (typeof value === "object" && value !== null
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
if (typeof value === "object" && value !== null) {
|
|
20
|
+
if (value.hasOwnProperty("component")) {
|
|
21
|
+
newValue = (chunks) => {
|
|
22
|
+
const children = typeof chunks === "string" ? chunks : chunks.join("");
|
|
23
|
+
return children;
|
|
24
|
+
};
|
|
25
|
+
hasComponentParams = true;
|
|
26
|
+
} else if (value.hasOwnProperty("element")) {
|
|
27
|
+
newValue = getElementFunc(value.element);
|
|
28
|
+
}
|
|
19
29
|
} else {
|
|
20
30
|
newValue = value;
|
|
21
31
|
}
|
|
@@ -28,20 +38,24 @@ function getParamsForFrontend() {
|
|
|
28
38
|
let retParams = {};
|
|
29
39
|
for (let [key2, value] of Object.entries(params)) {
|
|
30
40
|
let newValue;
|
|
31
|
-
if (typeof value === "object" && value !== null
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
if (typeof value === "object" && value !== null) {
|
|
42
|
+
if (value.hasOwnProperty("component")) {
|
|
43
|
+
const { component, props } = value;
|
|
44
|
+
newValue = (chunks) => {
|
|
45
|
+
const children = typeof chunks === "string" ? chunks : chunks.join("");
|
|
46
|
+
const id = key2 + "-" + Math.random().toString(36).substring(7) + "-" + Date.now().toString();
|
|
47
|
+
componentBindings.set(id, {
|
|
48
|
+
component,
|
|
49
|
+
props: {
|
|
50
|
+
...props,
|
|
51
|
+
children
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return '<span id="' + id + '">' + children + "</span>";
|
|
55
|
+
};
|
|
56
|
+
} else if (value.hasOwnProperty("element")) {
|
|
57
|
+
newValue = getElementFunc(value.element);
|
|
58
|
+
}
|
|
45
59
|
} else {
|
|
46
60
|
newValue = value;
|
|
47
61
|
}
|
|
@@ -5,7 +5,8 @@ declare const __propDef: {
|
|
|
5
5
|
props: {
|
|
6
6
|
key: string;
|
|
7
7
|
params?: Record<string, PrimitiveType | {
|
|
8
|
-
|
|
8
|
+
element?: string | undefined;
|
|
9
|
+
component?: ComponentType | undefined;
|
|
9
10
|
props?: Record<string, any> | undefined;
|
|
10
11
|
}> | undefined;
|
|
11
12
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="svelte" />
|
|
2
|
+
import type { PrimitiveType } from "intl-messageformat";
|
|
2
3
|
import { type Readable, type Writable } from "svelte/store";
|
|
3
4
|
export type i18nLoaderType = () => Promise<any>;
|
|
4
5
|
interface LanguageBase {
|
|
@@ -28,6 +29,7 @@ export declare class InternationalizationService {
|
|
|
28
29
|
register(language: Language): void;
|
|
29
30
|
found(code: string): boolean;
|
|
30
31
|
languageByCode(code: string): LanguageWithLoader | undefined;
|
|
32
|
+
t(key: string, params?: Record<string, PrimitiveType>): string;
|
|
31
33
|
}
|
|
32
34
|
export declare function getStringByKey(messages: Record<string, any>, key: string): string | undefined;
|
|
33
35
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { deepmerge } from "deepmerge-ts";
|
|
2
2
|
import { writable, derived } from "svelte/store";
|
|
3
|
+
import { t } from "./t.js";
|
|
3
4
|
export class InternationalizationService {
|
|
4
5
|
languages = [];
|
|
5
6
|
locale;
|
|
@@ -58,6 +59,9 @@ export class InternationalizationService {
|
|
|
58
59
|
languageByCode(code) {
|
|
59
60
|
return this.languages.find(l => l.code === code);
|
|
60
61
|
}
|
|
62
|
+
t(key, params = {}) {
|
|
63
|
+
return t(key, params, this);
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
export function getStringByKey(messages, key) {
|
|
63
67
|
const keys = key.split('.');
|
|
@@ -3,5 +3,6 @@ import { type InternationalizationService } from "./i18n.js";
|
|
|
3
3
|
type ParamValue = PrimitiveType | ((chunks: string | string[]) => string);
|
|
4
4
|
type ParamsType = Record<string, ParamValue>;
|
|
5
5
|
export declare function getMessage(key: string, params: ParamsType, $strings: Record<string, any>, $locale: string): string;
|
|
6
|
+
export type TParams = Record<string, PrimitiveType>;
|
|
6
7
|
export declare function t(key: string, params?: Record<string, PrimitiveType>, i18n?: InternationalizationService | null): string;
|
|
7
8
|
export {};
|