@asteby/metacore-runtime-react 13.4.0 → 13.4.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @asteby/metacore-runtime-react
|
|
2
2
|
|
|
3
|
+
## 13.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f03fe86: fix(action-modal): render `dynamic_select` action fields as the searchable async picker instead of a plain text input
|
|
8
|
+
|
|
9
|
+
ActionModalDispatcher's GenericActionModal had its own field renderer that keyed
|
|
10
|
+
off `field.type` and had no `dynamic_select` case, so a declarative action field
|
|
11
|
+
with `type: "dynamic_select"` (e.g. the Diario/Cuenta pickers of a journal entry)
|
|
12
|
+
fell through to a plain text `<Input>`. It now resolves the widget the same way
|
|
13
|
+
DynamicForm does (`resolveWidget`) and routes `dynamic_select` to
|
|
14
|
+
`DynamicSelectField`, keeping action modals and the standalone form in lockstep.
|
|
15
|
+
|
|
3
16
|
## 13.4.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-modal-dispatcher.d.ts","sourceRoot":"","sources":["../src/action-modal-dispatcher.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"action-modal-dispatcher.d.ts","sourceRoot":"","sources":["../src/action-modal-dispatcher.tsx"],"names":[],"mappings":"AA6CA,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAExB,MAAM,sBAAsB,CAAA;AAE7B,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAA;AAEhD,wBAAgB,qBAAqB,CAAC,EAClC,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,GACZ,EAAE,gBAAgB,kDAiDlB"}
|
|
@@ -15,7 +15,8 @@ import { toast } from 'sonner';
|
|
|
15
15
|
import { useApi } from './api-context';
|
|
16
16
|
import { DynamicIcon } from './dynamic-icon';
|
|
17
17
|
import { DynamicLineItems } from './dynamic-line-items';
|
|
18
|
-
import {
|
|
18
|
+
import { DynamicSelectField } from './dynamic-select-field';
|
|
19
|
+
import { isLineItemsField, resolveWidget } from './dynamic-form-schema';
|
|
19
20
|
// Canonical registry lives in @asteby/metacore-sdk
|
|
20
21
|
import { getActionComponent, } from '@asteby/metacore-sdk';
|
|
21
22
|
export function ActionModalDispatcher({ open, onOpenChange, action, model, record, endpoint, onSuccess, }) {
|
|
@@ -126,12 +127,20 @@ function renderField(field, value, onChange) {
|
|
|
126
127
|
if (isLineItemsField(field)) {
|
|
127
128
|
return _jsx(DynamicLineItems, { field: field, value: value, onChange: onChange });
|
|
128
129
|
}
|
|
129
|
-
|
|
130
|
+
// Resolve the widget the same way DynamicForm does (explicit widget wins,
|
|
131
|
+
// else inferred from type) so action modals and the standalone form stay in
|
|
132
|
+
// lockstep — previously this switch keyed off `field.type` and silently
|
|
133
|
+
// dropped `dynamic_select` to a plain text input.
|
|
134
|
+
const widget = resolveWidget(field);
|
|
135
|
+
if (widget === 'dynamic_select') {
|
|
136
|
+
return _jsx(DynamicSelectField, { field: field, value: value, onChange: onChange });
|
|
137
|
+
}
|
|
138
|
+
switch (widget) {
|
|
130
139
|
case 'textarea':
|
|
131
140
|
return _jsx(Textarea, { id: field.key, value: value || '', onChange: (e) => onChange(e.target.value), placeholder: field.placeholder });
|
|
132
141
|
case 'select':
|
|
133
142
|
return (_jsxs(Select, { value: value || '', onValueChange: onChange, children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: field.placeholder || 'Seleccionar...' }) }), _jsx(SelectContent, { children: field.options?.map((opt) => _jsx(SelectItem, { value: opt.value, children: opt.label }, opt.value)) })] }));
|
|
134
|
-
case '
|
|
143
|
+
case 'switch':
|
|
135
144
|
return _jsx(Switch, { id: field.key, checked: !!value, onCheckedChange: onChange });
|
|
136
145
|
case 'number':
|
|
137
146
|
return _jsx(Input, { id: field.key, type: "number", value: value ?? '', onChange: (e) => onChange(e.target.valueAsNumber || ''), placeholder: field.placeholder });
|
package/package.json
CHANGED
|
@@ -39,7 +39,8 @@ import { toast } from 'sonner'
|
|
|
39
39
|
import { useApi } from './api-context'
|
|
40
40
|
import { DynamicIcon } from './dynamic-icon'
|
|
41
41
|
import { DynamicLineItems } from './dynamic-line-items'
|
|
42
|
-
import {
|
|
42
|
+
import { DynamicSelectField } from './dynamic-select-field'
|
|
43
|
+
import { isLineItemsField, resolveWidget } from './dynamic-form-schema'
|
|
43
44
|
import type { ActionFieldDef } from './types'
|
|
44
45
|
// Canonical registry lives in @asteby/metacore-sdk
|
|
45
46
|
import {
|
|
@@ -271,7 +272,15 @@ function renderField(
|
|
|
271
272
|
if (isLineItemsField(field)) {
|
|
272
273
|
return <DynamicLineItems field={field} value={value} onChange={onChange} />
|
|
273
274
|
}
|
|
274
|
-
|
|
275
|
+
// Resolve the widget the same way DynamicForm does (explicit widget wins,
|
|
276
|
+
// else inferred from type) so action modals and the standalone form stay in
|
|
277
|
+
// lockstep — previously this switch keyed off `field.type` and silently
|
|
278
|
+
// dropped `dynamic_select` to a plain text input.
|
|
279
|
+
const widget = resolveWidget(field)
|
|
280
|
+
if (widget === 'dynamic_select') {
|
|
281
|
+
return <DynamicSelectField field={field} value={value} onChange={onChange} />
|
|
282
|
+
}
|
|
283
|
+
switch (widget) {
|
|
275
284
|
case 'textarea':
|
|
276
285
|
return <Textarea id={field.key} value={value || ''} onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => onChange(e.target.value)} placeholder={field.placeholder} />
|
|
277
286
|
case 'select':
|
|
@@ -283,7 +292,7 @@ function renderField(
|
|
|
283
292
|
</SelectContent>
|
|
284
293
|
</Select>
|
|
285
294
|
)
|
|
286
|
-
case '
|
|
295
|
+
case 'switch':
|
|
287
296
|
return <Switch id={field.key} checked={!!value} onCheckedChange={onChange} />
|
|
288
297
|
case 'number':
|
|
289
298
|
return <Input id={field.key} type="number" value={value ?? ''} onChange={(e: React.ChangeEvent<HTMLInputElement>) => onChange(e.target.valueAsNumber || '')} placeholder={field.placeholder} />
|