@seedgrid/fe-components 2026.4.17 → 2026.4.19
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/ai/seedgrid-components.manifest.json +5231 -3622
- package/dist/commons/dismissSgToast.meta.d.ts +4 -0
- package/dist/commons/dismissSgToast.meta.d.ts.map +1 -0
- package/dist/commons/dismissSgToast.meta.js +69 -0
- package/dist/commons/dismissSgWhistle.meta.d.ts +4 -0
- package/dist/commons/dismissSgWhistle.meta.d.ts.map +1 -0
- package/dist/commons/dismissSgWhistle.meta.js +69 -0
- package/dist/commons/subscribeSgToasts.meta.d.ts +4 -0
- package/dist/commons/subscribeSgToasts.meta.d.ts.map +1 -0
- package/dist/commons/subscribeSgToasts.meta.js +71 -0
- package/dist/commons/subscribeSgWhistles.meta.d.ts +4 -0
- package/dist/commons/subscribeSgWhistles.meta.d.ts.map +1 -0
- package/dist/commons/subscribeSgWhistles.meta.js +71 -0
- package/dist/commons/toast.meta.d.ts +4 -0
- package/dist/commons/toast.meta.d.ts.map +1 -0
- package/dist/commons/toast.meta.js +138 -0
- package/dist/commons/whistle.meta.d.ts +4 -0
- package/dist/commons/whistle.meta.d.ts.map +1 -0
- package/dist/commons/whistle.meta.js +166 -0
- package/dist/environment/useSgEnvironment.meta.d.ts +4 -0
- package/dist/environment/useSgEnvironment.meta.d.ts.map +1 -0
- package/dist/environment/useSgEnvironment.meta.js +96 -0
- package/dist/environment/useSgNamespaceProvider.meta.d.ts +4 -0
- package/dist/environment/useSgNamespaceProvider.meta.d.ts.map +1 -0
- package/dist/environment/useSgNamespaceProvider.meta.js +62 -0
- package/dist/environment/useSgPersistence.meta.d.ts +4 -0
- package/dist/environment/useSgPersistence.meta.d.ts.map +1 -0
- package/dist/environment/useSgPersistence.meta.js +111 -0
- package/dist/environment/useSgPersistentState.meta.d.ts +4 -0
- package/dist/environment/useSgPersistentState.meta.d.ts.map +1 -0
- package/dist/environment/useSgPersistentState.meta.js +114 -0
- package/dist/gadgets/clock/themes/useSgClockThemeResolver.meta.d.ts +4 -0
- package/dist/gadgets/clock/themes/useSgClockThemeResolver.meta.d.ts.map +1 -0
- package/dist/gadgets/clock/themes/useSgClockThemeResolver.meta.js +83 -0
- package/dist/gadgets/clock/useSgTime.meta.d.ts +4 -0
- package/dist/gadgets/clock/useSgTime.meta.d.ts.map +1 -0
- package/dist/gadgets/clock/useSgTime.meta.js +83 -0
- package/dist/i18n/useComponentsI18n.meta.d.ts +4 -0
- package/dist/i18n/useComponentsI18n.meta.d.ts.map +1 -0
- package/dist/i18n/useComponentsI18n.meta.js +76 -0
- package/dist/inputs/SgAutocomplete.js +42 -9
- package/dist/sandbox.cjs +44 -44
- package/package.json +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export const sgMeta = {
|
|
2
|
+
version: "0.1",
|
|
3
|
+
componentId: "hook.components-i18n",
|
|
4
|
+
package: "@seedgrid/fe-components",
|
|
5
|
+
exportName: "useComponentsI18n",
|
|
6
|
+
slug: "use-components-i18n",
|
|
7
|
+
displayName: "useComponentsI18n",
|
|
8
|
+
category: "hook",
|
|
9
|
+
subcategory: "internationalization",
|
|
10
|
+
description: "Hook para acessar contexto de internacionalizacao dos componentes SeedGrid. Fornece locale atual e funcoes de traducao.",
|
|
11
|
+
tags: ["hook", "i18n", "internationalization", "locale", "translation"],
|
|
12
|
+
capabilities: ["locale-access", "message-resolution", "dynamic-translation"],
|
|
13
|
+
fieldSemantics: ["i18nContext", "locale", "translation"],
|
|
14
|
+
props: [
|
|
15
|
+
{
|
|
16
|
+
name: "returns.locale",
|
|
17
|
+
type: "SgComponentsLocale",
|
|
18
|
+
description: "Locale atual (pt-BR, en-US, es, fr, pt-PT, en, etc).",
|
|
19
|
+
semanticRole: "data",
|
|
20
|
+
bindable: true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "returns.messages",
|
|
24
|
+
type: "SgComponentsMessages",
|
|
25
|
+
description: "Dicionario de mensagens para o locale atual.",
|
|
26
|
+
semanticRole: "data",
|
|
27
|
+
bindable: false
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
states: ["pt-BR", "pt-PT", "en-US", "en", "es", "fr"],
|
|
31
|
+
examples: [
|
|
32
|
+
{
|
|
33
|
+
id: "basic",
|
|
34
|
+
title: "Acessar locale e mensagens",
|
|
35
|
+
file: "apps/showcase/src/app/components/hooks/use-components-i18n/samples/basic.tsx.sample",
|
|
36
|
+
kind: "sample"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "with-translation",
|
|
40
|
+
title: "Usar para traducao de mensagens",
|
|
41
|
+
file: "apps/showcase/src/app/components/hooks/use-components-i18n/samples/with-translation.tsx.sample",
|
|
42
|
+
kind: "sample"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
showcase: {
|
|
46
|
+
route: "/components/hooks/use-components-i18n",
|
|
47
|
+
hasPlayground: false,
|
|
48
|
+
hasPropsTable: true
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export const aiHints = {
|
|
52
|
+
version: "0.1",
|
|
53
|
+
preferredUseCases: [
|
|
54
|
+
"Acessar mensagens traduzidas dentro de componentes customizados.",
|
|
55
|
+
"Validar se um locale especifico esta configurado.",
|
|
56
|
+
"Implementar fallback para mensagens customizadas em diferentes locales."
|
|
57
|
+
],
|
|
58
|
+
avoidUseCases: [
|
|
59
|
+
"Usar para traducao de strings fora do contexto de componentes SeedGrid.",
|
|
60
|
+
"Supor que o hook valida o locale; sempre checar o resultado."
|
|
61
|
+
],
|
|
62
|
+
synonyms: ["i18n context", "locale hook", "translation context"],
|
|
63
|
+
relatedEntityFields: ["locale", "language", "translation", "i18n"],
|
|
64
|
+
compositionHints: [
|
|
65
|
+
"Envolver a arvore com SgComponentsI18nProvider antes de usar.",
|
|
66
|
+
"Usar setComponentsI18n() para alternar locale dinamicamente.",
|
|
67
|
+
"Combinar com getBuiltInComponentsMessages() para mensagens builtin."
|
|
68
|
+
],
|
|
69
|
+
rankingSignals: {
|
|
70
|
+
freeText: 0.8,
|
|
71
|
+
structuredChoice: 0.7,
|
|
72
|
+
date: 0,
|
|
73
|
+
number: 0,
|
|
74
|
+
denseLayout: 0.4
|
|
75
|
+
}
|
|
76
|
+
};
|
|
@@ -26,6 +26,7 @@ function SgAutocompleteBase(props) {
|
|
|
26
26
|
const loadingText = loadingTextProp ?? t(i18n, "components.autocomplete.loading");
|
|
27
27
|
const effectiveGrouped = grouped ?? groupped ?? false;
|
|
28
28
|
const [inputValue, setInputValue] = React.useState(value ?? "");
|
|
29
|
+
const [internalError, setInternalError] = React.useState(null);
|
|
29
30
|
const [items, setItems] = React.useState([]);
|
|
30
31
|
const [loading, setLoading] = React.useState(false);
|
|
31
32
|
const [open, setOpen] = React.useState(false);
|
|
@@ -53,11 +54,14 @@ function SgAutocompleteBase(props) {
|
|
|
53
54
|
React.useEffect(() => {
|
|
54
55
|
if (value === undefined)
|
|
55
56
|
return;
|
|
56
|
-
setLastSelected(value);
|
|
57
57
|
// Never clobber what the user is actively typing.
|
|
58
58
|
if (isFocusedRef.current)
|
|
59
59
|
return;
|
|
60
|
+
setLastSelected(value);
|
|
60
61
|
setInputValue(value);
|
|
62
|
+
if (!value) {
|
|
63
|
+
setInternalError(null);
|
|
64
|
+
}
|
|
61
65
|
}, [value]);
|
|
62
66
|
React.useEffect(() => {
|
|
63
67
|
if (!value) {
|
|
@@ -138,6 +142,7 @@ function SgAutocompleteBase(props) {
|
|
|
138
142
|
const selection = formatSelection ? formatSelection(item) : item.label;
|
|
139
143
|
setSelectedItem(item);
|
|
140
144
|
setInputValue(selection);
|
|
145
|
+
setInternalError(null);
|
|
141
146
|
onChange?.(selection);
|
|
142
147
|
setLastSelected(selection);
|
|
143
148
|
onSelect?.(item);
|
|
@@ -152,8 +157,14 @@ function SgAutocompleteBase(props) {
|
|
|
152
157
|
if (selectedItem && next !== (formatSelection ? formatSelection(selectedItem) : selectedItem.label)) {
|
|
153
158
|
setSelectedItem(null);
|
|
154
159
|
}
|
|
160
|
+
setInternalError(null);
|
|
155
161
|
setInputValue(next);
|
|
156
|
-
|
|
162
|
+
if (allowCustomValue || next.length === 0) {
|
|
163
|
+
onChange?.(next);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
onChange?.("");
|
|
167
|
+
}
|
|
157
168
|
if (next.length === 0) {
|
|
158
169
|
setItems([]);
|
|
159
170
|
setOpen(false);
|
|
@@ -178,9 +189,20 @@ function SgAutocompleteBase(props) {
|
|
|
178
189
|
return;
|
|
179
190
|
}
|
|
180
191
|
isFocusedRef.current = false;
|
|
181
|
-
if (!allowCustomValue &&
|
|
182
|
-
|
|
183
|
-
|
|
192
|
+
if (!allowCustomValue && inputValue !== lastSelected) {
|
|
193
|
+
if (lastSelected) {
|
|
194
|
+
setInputValue(lastSelected);
|
|
195
|
+
setInternalError(null);
|
|
196
|
+
onChange?.(lastSelected);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
setInputValue("");
|
|
200
|
+
setSelectedItem(null);
|
|
201
|
+
setInternalError(props.required
|
|
202
|
+
? props.requiredMessage ?? t(i18n, "components.inputs.required")
|
|
203
|
+
: null);
|
|
204
|
+
onChange?.("");
|
|
205
|
+
}
|
|
184
206
|
}
|
|
185
207
|
setOpen(false);
|
|
186
208
|
onOpenChange?.(false);
|
|
@@ -293,9 +315,20 @@ function SgAutocompleteBase(props) {
|
|
|
293
315
|
return;
|
|
294
316
|
if (dropdownRef.current?.contains(event.target))
|
|
295
317
|
return;
|
|
296
|
-
if (!allowCustomValue &&
|
|
297
|
-
|
|
298
|
-
|
|
318
|
+
if (!allowCustomValue && inputValue !== lastSelected) {
|
|
319
|
+
if (lastSelected) {
|
|
320
|
+
setInputValue(lastSelected);
|
|
321
|
+
setInternalError(null);
|
|
322
|
+
onChange?.(lastSelected);
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
setInputValue("");
|
|
326
|
+
setSelectedItem(null);
|
|
327
|
+
setInternalError(props.required
|
|
328
|
+
? props.requiredMessage ?? t(i18n, "components.inputs.required")
|
|
329
|
+
: null);
|
|
330
|
+
onChange?.("");
|
|
331
|
+
}
|
|
299
332
|
}
|
|
300
333
|
setOpen(false);
|
|
301
334
|
onOpenChange?.(false);
|
|
@@ -317,7 +350,7 @@ function SgAutocompleteBase(props) {
|
|
|
317
350
|
window.removeEventListener("scroll", handleLayoutChange, true);
|
|
318
351
|
};
|
|
319
352
|
}, [open, syncDropdownPosition]);
|
|
320
|
-
return (_jsxs("div", { className: "relative", ref: wrapperRef, children: [_jsx(SgInputText, { ...rest, enabled: enabled, readOnly: readOnly, borderRadius: borderRadius, iconButtons: mergedIconButtons, inputProps: {
|
|
353
|
+
return (_jsxs("div", { className: "relative", ref: wrapperRef, children: [_jsx(SgInputText, { ...rest, error: resolveFieldError(rest.error, internalError ?? undefined), enabled: enabled, readOnly: readOnly, borderRadius: borderRadius, iconButtons: mergedIconButtons, inputProps: {
|
|
321
354
|
...inputProps,
|
|
322
355
|
ref: inputRef,
|
|
323
356
|
autoComplete: "off",
|