@humandialog/forms.svelte 1.6.0 → 1.6.1
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/components/combo/combo.svelte +4 -4
- package/components/date_utils.d.ts +3 -3
- package/components/date_utils.js +59 -56
- package/components/paginator.svelte +10 -2
- package/components/tags.palette.svelte +8 -3
- package/i18n.d.ts +2 -0
- package/i18n.js +26 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import { FaChevronDown, FaTimes } from "svelte-icons/fa";
|
|
|
7
7
|
import Icon from "../icon.svelte";
|
|
8
8
|
import { reef } from "@humandialog/auth.svelte/dist/index.js";
|
|
9
9
|
import { showMenu } from "../menu.js";
|
|
10
|
+
import { ext, i18n } from "../../i18n.js";
|
|
10
11
|
export let label = "";
|
|
11
12
|
export let self = null;
|
|
12
13
|
export let a = "";
|
|
@@ -229,7 +230,7 @@ function openDropdownAsMenu() {
|
|
|
229
230
|
let operations = [];
|
|
230
231
|
if (hasNone)
|
|
231
232
|
operations.push({
|
|
232
|
-
caption: "
|
|
233
|
+
caption: `<${i18n({ en: "blank", es: "blanco", pl: "pusty" })}>`,
|
|
233
234
|
action: (f) => on_choose(null)
|
|
234
235
|
});
|
|
235
236
|
if (definition && definition.collection)
|
|
@@ -237,12 +238,11 @@ function openDropdownAsMenu() {
|
|
|
237
238
|
const _filtered_source = filtered_source ? filtered_source : definition.source;
|
|
238
239
|
_filtered_source.forEach((i) => {
|
|
239
240
|
operations.push({
|
|
240
|
-
caption: i.Name
|
|
241
|
+
caption: i.Name ? ext(i.Name) : i.Key,
|
|
241
242
|
icon: i.Icon ?? void 0,
|
|
242
243
|
action: (f) => on_choose(i)
|
|
243
244
|
});
|
|
244
245
|
});
|
|
245
|
-
console.log("operations", operations);
|
|
246
246
|
showMenu(rect, operations);
|
|
247
247
|
}
|
|
248
248
|
export function hide() {
|
|
@@ -295,7 +295,7 @@ function get_combo_text() {
|
|
|
295
295
|
if (!is_dropdown_open) {
|
|
296
296
|
let found = selected_item(item, a);
|
|
297
297
|
if (found)
|
|
298
|
-
return found.Name
|
|
298
|
+
return found.Name ? ext(found.Name) : found.Key;
|
|
299
299
|
else
|
|
300
300
|
return placeholder;
|
|
301
301
|
} else
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function getFormattedStringDate(d: any, type?: string): string;
|
|
2
2
|
export function getNiceStringDateTime(d: any): string;
|
|
3
|
-
export function getNiceStringDate(d: any):
|
|
4
|
-
export function dayName(d: any):
|
|
5
|
-
export function monthName(m: any):
|
|
3
|
+
export function getNiceStringDate(d: any): any;
|
|
4
|
+
export function dayName(d: any): any;
|
|
5
|
+
export function monthName(m: any): any;
|
package/components/date_utils.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
|
|
2
|
+
import {getCurrentLanguageKey} from '../i18n.js'
|
|
3
|
+
|
|
2
4
|
export function getFormattedStringDate(d, type = "datetime")
|
|
3
5
|
{
|
|
4
6
|
if(!d)
|
|
@@ -86,11 +88,11 @@ export function getNiceStringDate(d)
|
|
|
86
88
|
|
|
87
89
|
let days_diff = day - current_day;
|
|
88
90
|
if(days_diff == 0)
|
|
89
|
-
return
|
|
91
|
+
return today();
|
|
90
92
|
else if(days_diff == 1)
|
|
91
|
-
return
|
|
93
|
+
return tomorrow();
|
|
92
94
|
else if(days_diff == -1)
|
|
93
|
-
return
|
|
95
|
+
return yesterday();
|
|
94
96
|
else if(days_diff > 0 && days_diff <= 7)
|
|
95
97
|
{
|
|
96
98
|
if(day_of_week > current_day_of_week)
|
|
@@ -122,67 +124,68 @@ export function getNiceStringDate(d)
|
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
|
|
127
|
+
function today()
|
|
126
128
|
{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return 'Mon';
|
|
134
|
-
|
|
135
|
-
case 2:
|
|
136
|
-
return 'Tue';
|
|
137
|
-
|
|
138
|
-
case 3:
|
|
139
|
-
return 'Wed';
|
|
129
|
+
const lang = getCurrentLanguageKey()
|
|
130
|
+
if(Object.keys(abbrCloseLang).includes(lang))
|
|
131
|
+
return abbrCloseLang[lang][1]
|
|
132
|
+
else
|
|
133
|
+
return abbrCloseLang.en[1]
|
|
134
|
+
}
|
|
140
135
|
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
function tomorrow()
|
|
137
|
+
{
|
|
138
|
+
const lang = getCurrentLanguageKey()
|
|
139
|
+
if(Object.keys(abbrCloseLang).includes(lang))
|
|
140
|
+
return abbrCloseLang[lang][2]
|
|
141
|
+
else
|
|
142
|
+
return abbrCloseLang.en[2]
|
|
143
|
+
}
|
|
143
144
|
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
function yesterday()
|
|
146
|
+
{
|
|
147
|
+
const lang = getCurrentLanguageKey()
|
|
148
|
+
if(Object.keys(abbrCloseLang).includes(lang))
|
|
149
|
+
return abbrCloseLang[lang][0]
|
|
150
|
+
else
|
|
151
|
+
return abbrCloseLang.en[0]
|
|
152
|
+
}
|
|
146
153
|
|
|
147
|
-
case 6:
|
|
148
|
-
return 'Sat';
|
|
149
|
-
|
|
150
|
-
case 7:
|
|
151
|
-
return 'Sun';
|
|
152
|
-
}
|
|
153
154
|
|
|
154
|
-
|
|
155
|
+
export function dayName(d)
|
|
156
|
+
{
|
|
157
|
+
const lang = getCurrentLanguageKey()
|
|
158
|
+
if(Object.keys(abbrDaysLang).includes(lang))
|
|
159
|
+
return abbrDaysLang[lang][d]
|
|
160
|
+
else
|
|
161
|
+
return abbrDaysLang.en[d]
|
|
155
162
|
}
|
|
156
163
|
|
|
157
164
|
export function monthName(m)
|
|
158
165
|
{
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
case 9:
|
|
180
|
-
return "Oct";
|
|
181
|
-
case 10:
|
|
182
|
-
return "Nov";
|
|
183
|
-
case 11:
|
|
184
|
-
return "Dec";
|
|
185
|
-
}
|
|
166
|
+
const lang = getCurrentLanguageKey()
|
|
167
|
+
if(Object.keys(abbrMonthsLang).includes(lang))
|
|
168
|
+
return abbrMonthsLang[lang][m]
|
|
169
|
+
else
|
|
170
|
+
return abbrMonthsLang.en[m]
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// translations
|
|
174
|
+
|
|
175
|
+
const abbrCloseLang = {
|
|
176
|
+
en: ['yesterday', 'today', 'tomorrow'],
|
|
177
|
+
es: ['ayer', 'hoy', 'mañana'],
|
|
178
|
+
pl: ['wczoraj', 'dziś', 'jutro']
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const abbrDaysLang = {
|
|
182
|
+
en: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
183
|
+
es: ['dom', 'lun', 'mar', 'miérc', 'juev', 'vier', 'sáb', 'dom'],
|
|
184
|
+
pl: ['nie', 'pon', 'wto', 'śro', 'czw', 'pią', 'sob', 'nie']
|
|
185
|
+
}
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
const abbrMonthsLang = {
|
|
188
|
+
en: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
189
|
+
es: ['ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'set', 'oct', 'nov', 'dic'],
|
|
190
|
+
pl: ['sty', 'lut', 'mar', 'kwi', 'maj', 'cze', 'lip', 'sie', 'wrz', 'paź', 'lis', 'gru']
|
|
188
191
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
|
|
3
|
+
import {i18n} from '../i18n.js'
|
|
4
|
+
|
|
3
5
|
export let pageNo
|
|
4
6
|
export let allPagesNo
|
|
5
7
|
export let onPage
|
|
@@ -67,7 +69,9 @@
|
|
|
67
69
|
<li>
|
|
68
70
|
<button on:click={onPrevPage}
|
|
69
71
|
class="flex items-center justify-center px-3 h-8 ms-0 leading-tight text-stone-500 bg-white border border-e-0 border-stone-300 rounded-s-lg hover:bg-stone-100 hover:text-stone-700 dark:bg-stone-800 dark:border-stone-700 dark:text-stone-400 dark:hover:bg-stone-700 dark:hover:text-white">
|
|
70
|
-
<span class="sr-only">
|
|
72
|
+
<span class="sr-only">
|
|
73
|
+
{ i18n({en: 'Previous', es: 'Anterior', pl: 'Wcześniejsze'}) }
|
|
74
|
+
</span>
|
|
71
75
|
<svg class="w-2.5 h-2.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
|
|
72
76
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 1 1 5l4 4"/>
|
|
73
77
|
</svg>
|
|
@@ -94,7 +98,11 @@
|
|
|
94
98
|
<!--a href="#" aria-current="page" class="">3</a-->
|
|
95
99
|
<li>
|
|
96
100
|
<button on:click={onNextPage} class="flex items-center justify-center px-3 h-8 leading-tight text-stone-500 bg-white border border-stone-300 rounded-e-lg hover:bg-stone-100 hover:text-stone-700 dark:bg-stone-800 dark:border-stone-700 dark:text-stone-400 dark:hover:bg-stone-700 dark:hover:text-white">
|
|
97
|
-
<span class="sr-only">
|
|
101
|
+
<span class="sr-only">
|
|
102
|
+
|
|
103
|
+
{ i18n({en: 'Next', es: 'Siguiente', pl: 'Następne'}) }
|
|
104
|
+
|
|
105
|
+
</span>
|
|
98
106
|
<svg class="w-2.5 h-2.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
|
|
99
107
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
|
|
100
108
|
</svg>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import TagColorsPalette from './tag.colors.svelte'
|
|
5
5
|
import { tick } from 'svelte';
|
|
6
6
|
import { isDeviceSmallerThan } from '../utils';
|
|
7
|
+
import {i18n} from '../i18n'
|
|
7
8
|
|
|
8
9
|
export let usedTags = []
|
|
9
10
|
export let allTags = []
|
|
@@ -194,9 +195,13 @@
|
|
|
194
195
|
onCustomClick={(e) => onTagSelected(tag)}/>
|
|
195
196
|
{/each}
|
|
196
197
|
{:else if allowNewTags}
|
|
197
|
-
<p>
|
|
198
|
+
<p>
|
|
199
|
+
{ i18n({en: 'Create tag:', es: 'Crear etiqueta:', pl: 'Utwrórz etykietę:'}) }
|
|
200
|
+
</p>
|
|
198
201
|
{:else}
|
|
199
|
-
<p>
|
|
202
|
+
<p>
|
|
203
|
+
{ i18n({en: 'No tags', es: 'Sin etiquetas', pl: 'Żadnych etykiet'}) }
|
|
204
|
+
</p>
|
|
200
205
|
{/if}
|
|
201
206
|
|
|
202
207
|
{/key}
|
|
@@ -211,7 +216,7 @@
|
|
|
211
216
|
on:input={onTextInput}
|
|
212
217
|
on:blur={onTextBlur}
|
|
213
218
|
on:keydown={onKeyDown}
|
|
214
|
-
placeholder=
|
|
219
|
+
placeholder={i18n({en: 'Type to filter or create tag', es: 'Escriba para filtrar o crear una etiqueta', pl: 'Wpisz, aby filtrować lub utworzyć tag'})}>
|
|
215
220
|
{#if allowNewTags}
|
|
216
221
|
<button class="block w-5 h-5 mt-0.5 ml-auto mr-2
|
|
217
222
|
text-stone-600 hover:text-stone-800 hover:bg-stone-200 active:bg-stone-200 border-stone-200
|
package/i18n.d.ts
CHANGED
package/i18n.js
CHANGED
|
@@ -160,3 +160,29 @@ export function i18n(list)
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
export function extractTranslated(str)
|
|
164
|
+
{
|
|
165
|
+
if(str.startsWith('_;'))
|
|
166
|
+
{
|
|
167
|
+
const body = str.replace(/^_;\s*/, ''); // cut prefix "_; "
|
|
168
|
+
return i18n(body);
|
|
169
|
+
}
|
|
170
|
+
else if(str.startsWith('__;'))
|
|
171
|
+
{
|
|
172
|
+
const body = str.replace(/^__;\s*/, ''); // cut prefix "__; "
|
|
173
|
+
const PAIRS = /([A-Za-z]{2})\s*:\s*([^;]*)/g;
|
|
174
|
+
const dict = {};
|
|
175
|
+
|
|
176
|
+
for (const [, code, text] of body.matchAll(PAIRS))
|
|
177
|
+
dict[code.toLowerCase()] = text.trim();
|
|
178
|
+
|
|
179
|
+
return i18n(dict)
|
|
180
|
+
}
|
|
181
|
+
else
|
|
182
|
+
return str
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function ext(str)
|
|
186
|
+
{
|
|
187
|
+
return extractTranslated(str)
|
|
188
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -72,5 +72,5 @@ export { default as IcH2 } from './components/document/internal/h2.icon.svelte';
|
|
|
72
72
|
export { default as IcH3 } from './components/document/internal/h3.icon.svelte';
|
|
73
73
|
export { default as IcH4 } from './components/document/internal/h4.icon.svelte';
|
|
74
74
|
export { registerKicksObserver, unregisterKicksObserver, forceKicksChecking } from './kicks.js';
|
|
75
|
-
export { i18n, setLanguages, getLanguages, setCurrentLanguage, getCurrentLanguage, getCurrentLanguageIdx, getCurrentLanguageKey } from './i18n.js';
|
|
75
|
+
export { i18n, extractTranslated, ext, setLanguages, getLanguages, setCurrentLanguage, getCurrentLanguage, getCurrentLanguageIdx, getCurrentLanguageKey } from './i18n.js';
|
|
76
76
|
export { i18nPreprocess } from './i18n-preprocess.js';
|
package/index.js
CHANGED
|
@@ -78,5 +78,5 @@ export { default as IcH2 } from './components/document/internal/h2.icon.svelte';
|
|
|
78
78
|
export { default as IcH3 } from './components/document/internal/h3.icon.svelte';
|
|
79
79
|
export { default as IcH4 } from './components/document/internal/h4.icon.svelte';
|
|
80
80
|
export { registerKicksObserver, unregisterKicksObserver, forceKicksChecking } from './kicks.js';
|
|
81
|
-
export { i18n, setLanguages, getLanguages, setCurrentLanguage, getCurrentLanguage, getCurrentLanguageIdx, getCurrentLanguageKey } from './i18n.js';
|
|
81
|
+
export { i18n, extractTranslated, ext, setLanguages, getLanguages, setCurrentLanguage, getCurrentLanguage, getCurrentLanguageIdx, getCurrentLanguageKey } from './i18n.js';
|
|
82
82
|
export { i18nPreprocess } from './i18n-preprocess.js';
|