tera-system-ui 0.0.10 → 0.0.12

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.
@@ -5,7 +5,6 @@
5
5
  import IconCheck from "../icons/IconCheck.svelte";
6
6
  import {getGlobalContext} from "../tera-ui-context/global-context";
7
7
  import * as m from '../../paraglide/messages.js'
8
- import {languageTag} from "../../paraglide/runtime";
9
8
 
10
9
  let {
11
10
  children,
@@ -0,0 +1,3 @@
1
+ # ignore everything because the directory is auto-generated by inlang paraglide-js
2
+ # for more info visit https://inlang.com/m/gerre34r/paraglide-js
3
+ *
@@ -0,0 +1 @@
1
+ export function text_select_language(): string;
@@ -0,0 +1,18 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file contains language specific message functions for tree-shaking.
4
+ *
5
+ *! WARNING: Only import messages from this file if you want to manually
6
+ *! optimize your bundle. Else, import from the `messages.js` file.
7
+ *
8
+ * Your bundler will (in the future) automatically replace the index function
9
+ * with a language specific message function in the build step.
10
+ */
11
+
12
+
13
+ /**
14
+ *
15
+ * @returns {string}
16
+ */
17
+ /* @__NO_SIDE_EFFECTS__ */
18
+ export const text_select_language = () => `Sprache auswählen`
@@ -0,0 +1 @@
1
+ export function text_select_language(): string;
@@ -0,0 +1,18 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file contains language specific message functions for tree-shaking.
4
+ *
5
+ *! WARNING: Only import messages from this file if you want to manually
6
+ *! optimize your bundle. Else, import from the `messages.js` file.
7
+ *
8
+ * Your bundler will (in the future) automatically replace the index function
9
+ * with a language specific message function in the build step.
10
+ */
11
+
12
+
13
+ /**
14
+ *
15
+ * @returns {string}
16
+ */
17
+ /* @__NO_SIDE_EFFECTS__ */
18
+ export const text_select_language = () => `Select language`
@@ -0,0 +1 @@
1
+ export function text_select_language(): string;
@@ -0,0 +1,18 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file contains language specific message functions for tree-shaking.
4
+ *
5
+ *! WARNING: Only import messages from this file if you want to manually
6
+ *! optimize your bundle. Else, import from the `messages.js` file.
7
+ *
8
+ * Your bundler will (in the future) automatically replace the index function
9
+ * with a language specific message function in the build step.
10
+ */
11
+
12
+
13
+ /**
14
+ *
15
+ * @returns {string}
16
+ */
17
+ /* @__NO_SIDE_EFFECTS__ */
18
+ export const text_select_language = () => `Seleccionar idioma`
@@ -0,0 +1 @@
1
+ export function text_select_language(): string;
@@ -0,0 +1,18 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file contains language specific message functions for tree-shaking.
4
+ *
5
+ *! WARNING: Only import messages from this file if you want to manually
6
+ *! optimize your bundle. Else, import from the `messages.js` file.
7
+ *
8
+ * Your bundler will (in the future) automatically replace the index function
9
+ * with a language specific message function in the build step.
10
+ */
11
+
12
+
13
+ /**
14
+ *
15
+ * @returns {string}
16
+ */
17
+ /* @__NO_SIDE_EFFECTS__ */
18
+ export const text_select_language = () => `Sélectionner la langue`
@@ -0,0 +1 @@
1
+ export function text_select_language(): string;
@@ -0,0 +1,18 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file contains language specific message functions for tree-shaking.
4
+ *
5
+ *! WARNING: Only import messages from this file if you want to manually
6
+ *! optimize your bundle. Else, import from the `messages.js` file.
7
+ *
8
+ * Your bundler will (in the future) automatically replace the index function
9
+ * with a language specific message function in the build step.
10
+ */
11
+
12
+
13
+ /**
14
+ *
15
+ * @returns {string}
16
+ */
17
+ /* @__NO_SIDE_EFFECTS__ */
18
+ export const text_select_language = () => `Seleziona la lingua`
@@ -0,0 +1 @@
1
+ export function text_select_language(): string;
@@ -0,0 +1,18 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file contains language specific message functions for tree-shaking.
4
+ *
5
+ *! WARNING: Only import messages from this file if you want to manually
6
+ *! optimize your bundle. Else, import from the `messages.js` file.
7
+ *
8
+ * Your bundler will (in the future) automatically replace the index function
9
+ * with a language specific message function in the build step.
10
+ */
11
+
12
+
13
+ /**
14
+ *
15
+ * @returns {string}
16
+ */
17
+ /* @__NO_SIDE_EFFECTS__ */
18
+ export const text_select_language = () => `Selecionar idioma`
@@ -0,0 +1 @@
1
+ export function text_select_language(): string;
@@ -0,0 +1,18 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file contains language specific message functions for tree-shaking.
4
+ *
5
+ *! WARNING: Only import messages from this file if you want to manually
6
+ *! optimize your bundle. Else, import from the `messages.js` file.
7
+ *
8
+ * Your bundler will (in the future) automatically replace the index function
9
+ * with a language specific message function in the build step.
10
+ */
11
+
12
+
13
+ /**
14
+ *
15
+ * @returns {string}
16
+ */
17
+ /* @__NO_SIDE_EFFECTS__ */
18
+ export const text_select_language = () => `Выберите язык`
@@ -0,0 +1 @@
1
+ export function text_select_language(): string;
@@ -0,0 +1,18 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file contains language specific message functions for tree-shaking.
4
+ *
5
+ *! WARNING: Only import messages from this file if you want to manually
6
+ *! optimize your bundle. Else, import from the `messages.js` file.
7
+ *
8
+ * Your bundler will (in the future) automatically replace the index function
9
+ * with a language specific message function in the build step.
10
+ */
11
+
12
+
13
+ /**
14
+ *
15
+ * @returns {string}
16
+ */
17
+ /* @__NO_SIDE_EFFECTS__ */
18
+ export const text_select_language = () => `Chọn ngôn ngữ`
@@ -0,0 +1,3 @@
1
+ export function text_select_language(params?: {}, options?: {
2
+ languageTag?: "de" | "en" | "es" | "fr" | "pt" | "vi" | "ru" | "it";
3
+ }): string;
@@ -0,0 +1,38 @@
1
+ /* eslint-disable */
2
+ import { languageTag } from "./runtime.js"
3
+ import * as de from "./messages/de.js"
4
+ import * as en from "./messages/en.js"
5
+ import * as es from "./messages/es.js"
6
+ import * as fr from "./messages/fr.js"
7
+ import * as pt from "./messages/pt.js"
8
+ import * as vi from "./messages/vi.js"
9
+ import * as ru from "./messages/ru.js"
10
+ import * as it from "./messages/it.js"
11
+
12
+
13
+ /**
14
+ * This message has been compiled by [inlang paraglide](https://inlang.com/m/gerre34r/library-inlang-paraglideJs).
15
+ *
16
+ * - Don't edit the message's code. Use [Sherlock (VS Code extension)](https://inlang.com/m/r7kp499g/app-inlang-ideExtension),
17
+ * the [web editor](https://inlang.com/m/tdozzpar/app-inlang-finkLocalizationEditor) instead, or edit the translation files manually.
18
+ *
19
+ * - The params are NonNullable<unknown> because the inlang SDK does not provide information on the type of a param (yet).
20
+ *
21
+ * @param {{}} params
22
+ * @param {{ languageTag?: "de" | "en" | "es" | "fr" | "pt" | "vi" | "ru" | "it" }} options
23
+ * @returns {string}
24
+ */
25
+ /* @__NO_SIDE_EFFECTS__ */
26
+ export const text_select_language = (params = {}, options = {}) => {
27
+ return {
28
+ de: de.text_select_language,
29
+ en: en.text_select_language,
30
+ es: es.text_select_language,
31
+ fr: fr.text_select_language,
32
+ it: it.text_select_language,
33
+ pt: pt.text_select_language,
34
+ ru: ru.text_select_language,
35
+ vi: vi.text_select_language
36
+ }[options.languageTag ?? languageTag()]()
37
+ }
38
+
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Check if something is an available language tag.
3
+ *
4
+ * @example
5
+ * if (isAvailableLanguageTag(params.locale)) {
6
+ * setLanguageTag(params.locale)
7
+ * } else {
8
+ * setLanguageTag("en")
9
+ * }
10
+ *
11
+ * @param {any} thing
12
+ * @returns {thing is AvailableLanguageTag}
13
+ */
14
+ export function isAvailableLanguageTag(thing: any): thing is AvailableLanguageTag;
15
+ /**
16
+ * The project's source language tag.
17
+ *
18
+ * @example
19
+ * if (newlySelectedLanguageTag === sourceLanguageTag){
20
+ * // do nothing as the source language tag is the default language
21
+ * return
22
+ * }
23
+ */
24
+ export const sourceLanguageTag: "en";
25
+ /**
26
+ * The project's available language tags.
27
+ *
28
+ * @example
29
+ * if (availableLanguageTags.includes(userSelectedLanguageTag) === false){
30
+ * throw new Error("Language tag not available")
31
+ * }
32
+ */
33
+ export const availableLanguageTags: readonly ["de", "en", "es", "fr", "pt", "vi", "ru", "it"];
34
+ /**
35
+ * Get the current language tag.
36
+ *
37
+ * @example
38
+ * if (languageTag() === "de"){
39
+ * console.log("Germany 🇩🇪")
40
+ * } else if (languageTag() === "nl"){
41
+ * console.log("Netherlands 🇳🇱")
42
+ * }
43
+ *
44
+ * @type {() => AvailableLanguageTag}
45
+ */
46
+ export let languageTag: () => AvailableLanguageTag;
47
+ export function setLanguageTag(tag: AvailableLanguageTag | (() => AvailableLanguageTag)): void;
48
+ export function onSetLanguageTag(fn: (languageTag: AvailableLanguageTag) => void): void;
49
+ /**
50
+ * A language tag that is available in the project.
51
+ */
52
+ export type AvailableLanguageTag = (typeof availableLanguageTags)[number];
@@ -0,0 +1,141 @@
1
+ /* eslint-disable */
2
+ /** @type {((tag: AvailableLanguageTag) => void) | undefined} */
3
+ let _onSetLanguageTag
4
+
5
+ /**
6
+ * The project's source language tag.
7
+ *
8
+ * @example
9
+ * if (newlySelectedLanguageTag === sourceLanguageTag){
10
+ * // do nothing as the source language tag is the default language
11
+ * return
12
+ * }
13
+ */
14
+ export const sourceLanguageTag = "en"
15
+
16
+ /**
17
+ * The project's available language tags.
18
+ *
19
+ * @example
20
+ * if (availableLanguageTags.includes(userSelectedLanguageTag) === false){
21
+ * throw new Error("Language tag not available")
22
+ * }
23
+ */
24
+ export const availableLanguageTags = /** @type {const} */ (["de","en","es","fr","pt","vi","ru","it"])
25
+
26
+ /**
27
+ * Get the current language tag.
28
+ *
29
+ * @example
30
+ * if (languageTag() === "de"){
31
+ * console.log("Germany 🇩🇪")
32
+ * } else if (languageTag() === "nl"){
33
+ * console.log("Netherlands 🇳🇱")
34
+ * }
35
+ *
36
+ * @type {() => AvailableLanguageTag}
37
+ */
38
+ export let languageTag = () => sourceLanguageTag
39
+
40
+ /**
41
+ * Set the language tag.
42
+ *
43
+ * @example
44
+ *
45
+ * // changing to language
46
+ * setLanguageTag("en")
47
+ *
48
+ * // passing a getter function also works.
49
+ * //
50
+ * // a getter function is useful for resolving a language tag
51
+ * // on the server where every request has a different language tag
52
+ * setLanguageTag(() => {
53
+ * return request.languageTag
54
+ * })
55
+ *
56
+ * @param {AvailableLanguageTag | (() => AvailableLanguageTag)} tag
57
+ */
58
+ export const setLanguageTag = (tag) => {
59
+ if (typeof tag === "function") {
60
+ languageTag = enforceLanguageTag(tag)
61
+ } else {
62
+ languageTag = enforceLanguageTag(() => tag)
63
+ }
64
+ // call the callback function if it has been defined
65
+ if (_onSetLanguageTag !== undefined) {
66
+ _onSetLanguageTag(languageTag())
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Wraps an untrusted function and enforces that it returns a language tag.
72
+ * @param {() => AvailableLanguageTag} unsafeLanguageTag
73
+ * @returns {() => AvailableLanguageTag}
74
+ */
75
+ function enforceLanguageTag(unsafeLanguageTag) {
76
+ return () => {
77
+ const tag = unsafeLanguageTag()
78
+ if(!isAvailableLanguageTag(tag)) {
79
+ throw new Error(`languageTag() didn't return a valid language tag. Check your setLanguageTag call`)
80
+ }
81
+ return tag
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Set the `onSetLanguageTag()` callback function.
87
+ *
88
+ * The function can be used to trigger client-side side-effects such as
89
+ * making a new request to the server with the updated language tag,
90
+ * or re-rendering the UI on the client (SPA apps).
91
+ *
92
+ * - Don't use this function on the server (!).
93
+ * Triggering a side-effect is only useful on the client because a server-side
94
+ * environment doesn't need to re-render the UI.
95
+ *
96
+ * - The `onSetLanguageTag()` callback can only be defined once to avoid unexpected behavior.
97
+ *
98
+ * @example
99
+ * // if you use inlang paraglide on the server, make sure
100
+ * // to not call `onSetLanguageTag()` on the server
101
+ * if (isServer === false) {
102
+ * onSetLanguageTag((tag) => {
103
+ * // (for example) make a new request to the
104
+ * // server with the updated language tag
105
+ * window.location.href = `/${tag}/${window.location.pathname}`
106
+ * })
107
+ * }
108
+ *
109
+ * @param {(languageTag: AvailableLanguageTag) => void} fn
110
+ */
111
+ export const onSetLanguageTag = (fn) => {
112
+ _onSetLanguageTag = fn
113
+ }
114
+
115
+ /**
116
+ * Check if something is an available language tag.
117
+ *
118
+ * @example
119
+ * if (isAvailableLanguageTag(params.locale)) {
120
+ * setLanguageTag(params.locale)
121
+ * } else {
122
+ * setLanguageTag("en")
123
+ * }
124
+ *
125
+ * @param {any} thing
126
+ * @returns {thing is AvailableLanguageTag}
127
+ */
128
+ export function isAvailableLanguageTag(thing) {
129
+ return availableLanguageTags.includes(thing)
130
+ }
131
+
132
+ // ------ TYPES ------
133
+
134
+ /**
135
+ * A language tag that is available in the project.
136
+ *
137
+ * @example
138
+ * setLanguageTag(request.languageTag as AvailableLanguageTag)
139
+ *
140
+ * @typedef {typeof availableLanguageTags[number]} AvailableLanguageTag
141
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tera-system-ui",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",