@telamonjs/ui 1.3.0 → 1.3.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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 25f34e0: `ConfirmActionDialog` (and `confirmDialog.inputs` on row actions) focuses the first input on open,
8
+ so a reason can be typed right away. Without inputs, focus still starts on Cancel.
9
+
3
10
  ## 1.3.0
4
11
 
5
12
  ### Minor Changes
@@ -127,127 +127,140 @@ function ConfirmActionDialog({
127
127
  };
128
128
  return /* @__PURE__ */ jsxs(AlertDialog, { open, onOpenChange: handleOpenChange, children: [
129
129
  children && /* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: true, children }),
130
- /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
131
- /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
132
- /* @__PURE__ */ jsx(AlertDialogTitle, { children: node(title) || t("dialog.confirmActionTitle") }),
133
- description && /* @__PURE__ */ jsx(AlertDialogDescription, { children: node(description) })
134
- ] }),
135
- body,
136
- inputs && inputs.length > 0 && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: inputs.map((input) => {
137
- const id = `${idPrefix}-${input.name}`;
138
- const errorId = `${id}-error`;
139
- const helpId = `${id}-help`;
140
- const listId = `${id}-suggestions`;
141
- const message = fieldError(input);
142
- const asError = !!message && (attempted || disableUntilValid && !!touched[input.name]);
143
- const shown = asError || !!message && (disableUntilValid || !!lengthMessage(input));
144
- const describedBy = [input.description && helpId, shown && errorId].filter(Boolean).join(" ") || void 0;
145
- const placeholder = text(input.placeholder);
146
- const common = {
147
- id,
148
- name: input.name,
149
- required: input.required,
150
- disabled: pending,
151
- placeholder,
152
- inputMode: input.inputMode,
153
- autoComplete: input.autoComplete,
154
- "aria-invalid": asError ? true : void 0,
155
- "aria-describedby": describedBy
156
- };
157
- return /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
158
- /* @__PURE__ */ jsxs(Label, { htmlFor: id, children: [
159
- text(input.label),
160
- input.required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-destructive", children: " *" })
130
+ /* @__PURE__ */ jsxs(
131
+ AlertDialogContent,
132
+ {
133
+ onOpenAutoFocus: (event) => {
134
+ const first = inputs?.[0];
135
+ if (!first) return;
136
+ const field = document.getElementById(`${idPrefix}-${first.name}`);
137
+ if (!field) return;
138
+ event.preventDefault();
139
+ field.focus();
140
+ },
141
+ children: [
142
+ /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
143
+ /* @__PURE__ */ jsx(AlertDialogTitle, { children: node(title) || t("dialog.confirmActionTitle") }),
144
+ description && /* @__PURE__ */ jsx(AlertDialogDescription, { children: node(description) })
161
145
  ] }),
162
- input.type === "textarea" ? /* @__PURE__ */ jsx(
163
- Textarea,
164
- {
165
- ...common,
166
- rows: input.rows,
167
- value: values[input.name] ?? "",
168
- onChange: (e) => setValue(input.name, e.target.value)
169
- }
170
- ) : input.type === "select" ? /* @__PURE__ */ jsxs(
171
- Select,
172
- {
173
- value: values[input.name] ?? "",
174
- onValueChange: (v) => setValue(input.name, v),
146
+ body,
147
+ inputs && inputs.length > 0 && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: inputs.map((input) => {
148
+ const id = `${idPrefix}-${input.name}`;
149
+ const errorId = `${id}-error`;
150
+ const helpId = `${id}-help`;
151
+ const listId = `${id}-suggestions`;
152
+ const message = fieldError(input);
153
+ const asError = !!message && (attempted || disableUntilValid && !!touched[input.name]);
154
+ const shown = asError || !!message && (disableUntilValid || !!lengthMessage(input));
155
+ const describedBy = [input.description && helpId, shown && errorId].filter(Boolean).join(" ") || void 0;
156
+ const placeholder = text(input.placeholder);
157
+ const common = {
158
+ id,
159
+ name: input.name,
160
+ required: input.required,
175
161
  disabled: pending,
176
- children: [
162
+ placeholder,
163
+ inputMode: input.inputMode,
164
+ autoComplete: input.autoComplete,
165
+ "aria-invalid": asError ? true : void 0,
166
+ "aria-describedby": describedBy
167
+ };
168
+ return /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
169
+ /* @__PURE__ */ jsxs(Label, { htmlFor: id, children: [
170
+ text(input.label),
171
+ input.required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-destructive", children: " *" })
172
+ ] }),
173
+ input.type === "textarea" ? /* @__PURE__ */ jsx(
174
+ Textarea,
175
+ {
176
+ ...common,
177
+ rows: input.rows,
178
+ value: values[input.name] ?? "",
179
+ onChange: (e) => setValue(input.name, e.target.value)
180
+ }
181
+ ) : input.type === "select" ? /* @__PURE__ */ jsxs(
182
+ Select,
183
+ {
184
+ value: values[input.name] ?? "",
185
+ onValueChange: (v) => setValue(input.name, v),
186
+ disabled: pending,
187
+ children: [
188
+ /* @__PURE__ */ jsx(
189
+ SelectTrigger,
190
+ {
191
+ id,
192
+ "aria-invalid": common["aria-invalid"],
193
+ "aria-describedby": describedBy,
194
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: placeholder || t("common.select") })
195
+ }
196
+ ),
197
+ /* @__PURE__ */ jsx(SelectContent, { children: (input.options ?? []).map(asOption).map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: text(option.label) }, option.value)) })
198
+ ]
199
+ }
200
+ ) : input.type === "date" ? /* @__PURE__ */ jsx(
201
+ Input,
202
+ {
203
+ ...common,
204
+ type: "date",
205
+ min: input.min,
206
+ max: input.max,
207
+ value: values[input.name] ?? "",
208
+ onChange: (e) => setValue(input.name, e.target.value)
209
+ }
210
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
177
211
  /* @__PURE__ */ jsx(
178
- SelectTrigger,
212
+ Input,
179
213
  {
180
- id,
181
- "aria-invalid": common["aria-invalid"],
182
- "aria-describedby": describedBy,
183
- children: /* @__PURE__ */ jsx(SelectValue, { placeholder: placeholder || t("common.select") })
214
+ ...common,
215
+ type: "text",
216
+ list: input.suggestions?.length ? listId : void 0,
217
+ value: values[input.name] ?? "",
218
+ onChange: (e) => setValue(input.name, e.target.value)
184
219
  }
185
220
  ),
186
- /* @__PURE__ */ jsx(SelectContent, { children: (input.options ?? []).map(asOption).map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: text(option.label) }, option.value)) })
187
- ]
188
- }
189
- ) : input.type === "date" ? /* @__PURE__ */ jsx(
190
- Input,
221
+ input.suggestions?.length ? /* @__PURE__ */ jsx("datalist", { id: listId, children: input.suggestions.map((s) => /* @__PURE__ */ jsx("option", { value: s }, s)) }) : null
222
+ ] }),
223
+ input.description && /* @__PURE__ */ jsx("p", { id: helpId, className: "text-xs text-muted-foreground", children: text(input.description) }),
224
+ shown && message && /* @__PURE__ */ jsx(
225
+ "p",
226
+ {
227
+ id: errorId,
228
+ "data-state": asError ? "error" : "hint",
229
+ className: asError ? "text-sm text-destructive" : "text-sm text-muted-foreground",
230
+ children: text(message)
231
+ }
232
+ )
233
+ ] }, input.name);
234
+ }) }),
235
+ error && /* @__PURE__ */ jsx(
236
+ "p",
191
237
  {
192
- ...common,
193
- type: "date",
194
- min: input.min,
195
- max: input.max,
196
- value: values[input.name] ?? "",
197
- onChange: (e) => setValue(input.name, e.target.value)
238
+ role: "alert",
239
+ "data-testid": "confirm-action-error",
240
+ className: "text-sm text-destructive",
241
+ children: error
198
242
  }
199
- ) : /* @__PURE__ */ jsxs(Fragment, { children: [
200
- /* @__PURE__ */ jsx(
201
- Input,
243
+ ),
244
+ /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
245
+ /* @__PURE__ */ jsx(AlertDialogCancel, { "data-testid": "modal-cancel", disabled: pending, children: text(cancelText) || t("common.cancel") }),
246
+ /* @__PURE__ */ jsxs(
247
+ AlertDialogAction,
202
248
  {
203
- ...common,
204
- type: "text",
205
- list: input.suggestions?.length ? listId : void 0,
206
- value: values[input.name] ?? "",
207
- onChange: (e) => setValue(input.name, e.target.value)
249
+ "data-testid": "modal-confirm",
250
+ disabled: pending || confirmDisabled || disableUntilValid && invalid,
251
+ "aria-busy": pending || void 0,
252
+ className: variant === "destructive" ? "bg-red-500 text-white hover:bg-red-600" : "",
253
+ onClick: handleConfirm,
254
+ children: [
255
+ pending && /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin", "aria-hidden": "true" }),
256
+ pending && text(pendingText) || text(confirmText) || t("common.confirm")
257
+ ]
208
258
  }
209
- ),
210
- input.suggestions?.length ? /* @__PURE__ */ jsx("datalist", { id: listId, children: input.suggestions.map((s) => /* @__PURE__ */ jsx("option", { value: s }, s)) }) : null
211
- ] }),
212
- input.description && /* @__PURE__ */ jsx("p", { id: helpId, className: "text-xs text-muted-foreground", children: text(input.description) }),
213
- shown && message && /* @__PURE__ */ jsx(
214
- "p",
215
- {
216
- id: errorId,
217
- "data-state": asError ? "error" : "hint",
218
- className: asError ? "text-sm text-destructive" : "text-sm text-muted-foreground",
219
- children: text(message)
220
- }
221
- )
222
- ] }, input.name);
223
- }) }),
224
- error && /* @__PURE__ */ jsx(
225
- "p",
226
- {
227
- role: "alert",
228
- "data-testid": "confirm-action-error",
229
- className: "text-sm text-destructive",
230
- children: error
231
- }
232
- ),
233
- /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
234
- /* @__PURE__ */ jsx(AlertDialogCancel, { "data-testid": "modal-cancel", disabled: pending, children: text(cancelText) || t("common.cancel") }),
235
- /* @__PURE__ */ jsxs(
236
- AlertDialogAction,
237
- {
238
- "data-testid": "modal-confirm",
239
- disabled: pending || confirmDisabled || disableUntilValid && invalid,
240
- "aria-busy": pending || void 0,
241
- className: variant === "destructive" ? "bg-red-500 text-white hover:bg-red-600" : "",
242
- onClick: handleConfirm,
243
- children: [
244
- pending && /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin", "aria-hidden": "true" }),
245
- pending && text(pendingText) || text(confirmText) || t("common.confirm")
246
- ]
247
- }
248
- )
249
- ] })
250
- ] })
259
+ )
260
+ ] })
261
+ ]
262
+ }
263
+ )
251
264
  ] });
252
265
  }
253
266
  export {
@@ -7,4 +7,4 @@ export type { ModuleMetadata, ListConfig, ExportAllOptions, CrudColumnDef, FormC
7
7
  export type { ColorPreset, StatItem, HeaderBadgeConfig, HeaderStatsConfig, DialogHeaderConfig, DialogHeaderProps, StatsGridProps, } from '../types/dialog-header';
8
8
  export type { MenuItem, SingleMenuItem, GroupMenuItem, SeparatorMenuItem, MenuItemType, MenuVariant, IconComponent, } from '../types/menu';
9
9
  export type { Density, GapSize, DialogSize, DialogHeight, FieldLayout, CardFieldLayout, } from '../utils/spacing';
10
- export declare const version = "1.3.0";
10
+ export declare const version = "1.3.1";
@@ -1,6 +1,6 @@
1
1
  // src/exports/types-constants.ts
2
2
  import { createPaginatedResponse, asQueryFn } from "../types/pagination.js";
3
- var version = "1.3.0";
3
+ var version = "1.3.1";
4
4
  export {
5
5
  asQueryFn,
6
6
  createPaginatedResponse,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telamonjs/ui",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "description": "Admin framework for Next.js + React: declarative CRUD (CrudConfig + TanStack Query), 36-type field system, rich dialogs, app shell, dashboards and charts",
6
6
  "main": "dist/index.js",