@kayr/umbika-web-renderer 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +46 -2
- package/THIRD_PARTY_LICENSES.txt +20 -0
- package/dist/browser/umbika.min.css +23 -0
- package/dist/browser/umbika.min.d.mts +437 -0
- package/dist/browser/umbika.min.d.ts +437 -0
- package/dist/browser/umbika.min.js +60 -0
- package/dist/browser/umbika.min.mjs +60 -0
- package/dist/casconda.d.ts +2 -0
- package/dist/casconda.d.ts.map +1 -0
- package/dist/contracts.d.ts +165 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/dom-identity.d.ts +17 -0
- package/dist/dom-identity.d.ts.map +1 -0
- package/dist/field-presentation.d.ts +26 -0
- package/dist/field-presentation.d.ts.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/layout.d.ts +25 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/mount.d.ts +14 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/render-nodes.d.ts +18 -0
- package/dist/render-nodes.d.ts.map +1 -0
- package/dist/renderers/multi-select.d.ts +18 -0
- package/dist/renderers/multi-select.d.ts.map +1 -0
- package/dist/renderers/object.d.ts +6 -0
- package/dist/renderers/object.d.ts.map +1 -0
- package/dist/renderers/output.d.ts +6 -0
- package/dist/renderers/output.d.ts.map +1 -0
- package/dist/renderers/select.d.ts +6 -0
- package/dist/renderers/select.d.ts.map +1 -0
- package/dist/renderers/table.d.ts +6 -0
- package/dist/renderers/table.d.ts.map +1 -0
- package/dist/renderers/text.d.ts +8 -0
- package/dist/renderers/text.d.ts.map +1 -0
- package/dist/row-details.d.ts +89 -0
- package/dist/row-details.d.ts.map +1 -0
- package/dist/standalone/contracts.d.ts +77 -0
- package/dist/standalone/contracts.d.ts.map +1 -0
- package/dist/standalone/index.d.ts +7 -0
- package/dist/standalone/index.d.ts.map +1 -0
- package/dist/standalone/mount.d.ts +9 -0
- package/dist/standalone/mount.d.ts.map +1 -0
- package/dist/summary.d.ts +29 -0
- package/dist/summary.d.ts.map +1 -0
- package/dist/tags.d.ts +32 -0
- package/dist/tags.d.ts.map +1 -0
- package/package.json +78 -4
- package/src/casconda.js +10 -0
- package/src/contracts.js +79 -0
- package/src/dom-identity.js +31 -0
- package/src/field-presentation.js +71 -0
- package/src/index.js +9 -0
- package/src/layout.js +176 -0
- package/src/mount.js +569 -0
- package/src/render-nodes.js +77 -0
- package/src/renderers/multi-select.js +211 -0
- package/src/renderers/object.js +43 -0
- package/src/renderers/output.js +87 -0
- package/src/renderers/select.js +104 -0
- package/src/renderers/table.js +344 -0
- package/src/renderers/text.js +82 -0
- package/src/row-details.js +305 -0
- package/src/standalone/contracts.js +22 -0
- package/src/standalone/index.js +5 -0
- package/src/standalone/mount.js +128 -0
- package/src/summary.js +135 -0
- package/src/tags.js +69 -0
- package/styles/base.css +432 -0
- package/styles/standalone.css +2 -0
- package/styles/themes/default.css +99 -0
- package/vendor/LICENSE +21 -0
- package/vendor/README.md +33 -0
- package/vendor/casconda.min.d.mts +340 -0
- package/vendor/casconda.min.d.ts +340 -0
- package/vendor/casconda.min.mjs +1 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { computed, rx } from "../casconda.js";
|
|
2
|
+
import { _resourcePathKey, _structuralDomId } from "../dom-identity.js";
|
|
3
|
+
import { _renderErrors } from "../field-presentation.js";
|
|
4
|
+
import { _tableLayoutAt } from "../layout.js";
|
|
5
|
+
import {
|
|
6
|
+
_summaryColumns,
|
|
7
|
+
_primarySummaryValue,
|
|
8
|
+
_summaryValueAt,
|
|
9
|
+
_visibleErrorCount,
|
|
10
|
+
} from "../summary.js";
|
|
11
|
+
import {
|
|
12
|
+
article,
|
|
13
|
+
button,
|
|
14
|
+
caption,
|
|
15
|
+
div,
|
|
16
|
+
foreach,
|
|
17
|
+
h2,
|
|
18
|
+
p,
|
|
19
|
+
section,
|
|
20
|
+
table as tableTag,
|
|
21
|
+
tbody,
|
|
22
|
+
td,
|
|
23
|
+
th,
|
|
24
|
+
thead,
|
|
25
|
+
tr,
|
|
26
|
+
} from "../tags.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {import("../contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveFieldNode>} resource
|
|
30
|
+
* @param {import("../contracts.js").NodeRendererContext} context
|
|
31
|
+
*/
|
|
32
|
+
export function _renderTableField(resource, context) {
|
|
33
|
+
const initial = resource.get();
|
|
34
|
+
if (!initial || initial.type !== "table") return "";
|
|
35
|
+
|
|
36
|
+
const tableName = initial.label ?? initial.id;
|
|
37
|
+
const titleId = _structuralDomId(
|
|
38
|
+
context.instanceId,
|
|
39
|
+
"table-title",
|
|
40
|
+
initial.path,
|
|
41
|
+
);
|
|
42
|
+
const addId = _structuralDomId(context.instanceId, "add-row", initial.path);
|
|
43
|
+
const errorsId = _structuralDomId(
|
|
44
|
+
context.instanceId,
|
|
45
|
+
"table-errors",
|
|
46
|
+
initial.path,
|
|
47
|
+
);
|
|
48
|
+
const layout = _tableLayoutAt(context.layout, context.definitionPath);
|
|
49
|
+
const mode = layout?.mode ?? "cards";
|
|
50
|
+
const rows = computed(() => {
|
|
51
|
+
const current = resource.get();
|
|
52
|
+
return current?.type === "table" ? current.rows : [];
|
|
53
|
+
}, resource);
|
|
54
|
+
const columns = computed(() => {
|
|
55
|
+
const current = resource.get();
|
|
56
|
+
return _summaryColumns(
|
|
57
|
+
current?.type === "table" ? current.rows : [],
|
|
58
|
+
layout?.columns,
|
|
59
|
+
);
|
|
60
|
+
}, resource);
|
|
61
|
+
|
|
62
|
+
return section(
|
|
63
|
+
{
|
|
64
|
+
id: _structuralDomId(context.instanceId, "table", initial.path),
|
|
65
|
+
class:
|
|
66
|
+
mode === "table"
|
|
67
|
+
? "umbika-table umbika-table--summary"
|
|
68
|
+
: "umbika-table",
|
|
69
|
+
"data-umbika-kind": "table",
|
|
70
|
+
"aria-labelledby": titleId,
|
|
71
|
+
"aria-describedby": errorsId,
|
|
72
|
+
tabindex: "-1",
|
|
73
|
+
"data-umbika-invalid": rx.attr(resource, (node) =>
|
|
74
|
+
node?.type === "table" && node.errors.length > 0 ? "true" : "false",
|
|
75
|
+
),
|
|
76
|
+
},
|
|
77
|
+
h2(
|
|
78
|
+
{ id: titleId, class: "umbika-table__heading" },
|
|
79
|
+
rx.text(
|
|
80
|
+
resource,
|
|
81
|
+
(
|
|
82
|
+
/** @type {import("@kayr/umbika-core").ActiveFieldNode | undefined} */ node,
|
|
83
|
+
) => (node?.type === "table" ? (node.label ?? node.id) : ""),
|
|
84
|
+
),
|
|
85
|
+
),
|
|
86
|
+
mode === "table"
|
|
87
|
+
? _renderSummaryTable(resource, rows, columns, tableName, context)
|
|
88
|
+
: _renderCards(rows, tableName, context),
|
|
89
|
+
p(
|
|
90
|
+
{ class: "umbika-table__empty" },
|
|
91
|
+
rx.text(
|
|
92
|
+
resource,
|
|
93
|
+
(
|
|
94
|
+
/** @type {import("@kayr/umbika-core").ActiveFieldNode | undefined} */ node,
|
|
95
|
+
) =>
|
|
96
|
+
node?.type === "table" && node.rows.length === 0
|
|
97
|
+
? `No ${tableName} rows.`
|
|
98
|
+
: "",
|
|
99
|
+
),
|
|
100
|
+
),
|
|
101
|
+
_renderErrors(errorsId, resource),
|
|
102
|
+
button(
|
|
103
|
+
{
|
|
104
|
+
id: addId,
|
|
105
|
+
class: "umbika-table__add-row",
|
|
106
|
+
type: "button",
|
|
107
|
+
"aria-label": `Add row to ${tableName}`,
|
|
108
|
+
onclick: () => {
|
|
109
|
+
const current = resource.get();
|
|
110
|
+
if (current?.type === "table") {
|
|
111
|
+
context.appendRow?.(
|
|
112
|
+
current.path,
|
|
113
|
+
mode === "table",
|
|
114
|
+
addId,
|
|
115
|
+
context.definitionPath,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
"Add row",
|
|
121
|
+
),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {import("../contracts.js").ResourceListSource<import("@kayr/umbika-core").ActiveTableRow>} rows
|
|
127
|
+
* @param {string} tableName
|
|
128
|
+
* @param {import("../contracts.js").NodeRendererContext} context
|
|
129
|
+
*/
|
|
130
|
+
function _renderCards(rows, tableName, context) {
|
|
131
|
+
return div(
|
|
132
|
+
{ class: "umbika-table__rows" },
|
|
133
|
+
foreach(
|
|
134
|
+
{ id: _resourcePathKey, resource: true },
|
|
135
|
+
rows,
|
|
136
|
+
(
|
|
137
|
+
/** @type {import("@kayr/umbika-core").ActiveTableRow} */ initial,
|
|
138
|
+
/** @type {number} */ _index,
|
|
139
|
+
/** @type {import("../contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveTableRow>} */ row,
|
|
140
|
+
) => {
|
|
141
|
+
const children = computed(() => row.get()?.children ?? [], row);
|
|
142
|
+
return article(
|
|
143
|
+
{
|
|
144
|
+
id: _structuralDomId(context.instanceId, "row", initial.path),
|
|
145
|
+
class: "umbika-table__row",
|
|
146
|
+
"data-umbika-row-id": initial.id,
|
|
147
|
+
"aria-label": `${tableName} row`,
|
|
148
|
+
},
|
|
149
|
+
div(
|
|
150
|
+
{ class: "umbika-table__fields" },
|
|
151
|
+
context.renderNodes(children, context.definitionPath),
|
|
152
|
+
),
|
|
153
|
+
button(
|
|
154
|
+
{
|
|
155
|
+
class: "umbika-table__remove-row",
|
|
156
|
+
type: "button",
|
|
157
|
+
"aria-label": `Remove row from ${tableName}`,
|
|
158
|
+
onclick: () => {
|
|
159
|
+
const current = row.get();
|
|
160
|
+
if (current) context.removeRow?.(current.path);
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
"Remove row",
|
|
164
|
+
),
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
),
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @param {import("../contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveFieldNode>} table
|
|
173
|
+
* @param {import("../contracts.js").ResourceListSource<import("@kayr/umbika-core").ActiveTableRow>} rows
|
|
174
|
+
* @param {import("../contracts.js").ResourceListSource<import("../contracts.js").OwnedWebTableColumnLayout>} columns
|
|
175
|
+
* @param {string} tableName
|
|
176
|
+
* @param {import("../contracts.js").NodeRendererContext} context
|
|
177
|
+
*/
|
|
178
|
+
function _renderSummaryTable(table, rows, columns, tableName, context) {
|
|
179
|
+
return div(
|
|
180
|
+
{ class: "umbika-data-table__overflow" },
|
|
181
|
+
tableTag(
|
|
182
|
+
{ class: "umbika-data-table" },
|
|
183
|
+
caption({ class: "umbika-visually-hidden" }, tableName),
|
|
184
|
+
thead(
|
|
185
|
+
tr(
|
|
186
|
+
foreach(
|
|
187
|
+
{ id: "key", resource: true },
|
|
188
|
+
columns,
|
|
189
|
+
(
|
|
190
|
+
/** @type {import("../contracts.js").OwnedWebTableColumnLayout} */ _initial,
|
|
191
|
+
/** @type {number} */ _index,
|
|
192
|
+
/** @type {import("../contracts.js").KeyedItemResource<import("../contracts.js").OwnedWebTableColumnLayout>} */ column,
|
|
193
|
+
) =>
|
|
194
|
+
th(
|
|
195
|
+
{
|
|
196
|
+
scope: "col",
|
|
197
|
+
"data-umbika-align": rx.attr(
|
|
198
|
+
column,
|
|
199
|
+
(
|
|
200
|
+
/** @type {import("../contracts.js").OwnedWebTableColumnLayout | undefined} */ current,
|
|
201
|
+
) => current?.align ?? "start",
|
|
202
|
+
),
|
|
203
|
+
},
|
|
204
|
+
rx.text(
|
|
205
|
+
column,
|
|
206
|
+
(
|
|
207
|
+
/** @type {import("../contracts.js").OwnedWebTableColumnLayout | undefined} */ current,
|
|
208
|
+
) => current?.label ?? "",
|
|
209
|
+
),
|
|
210
|
+
),
|
|
211
|
+
),
|
|
212
|
+
th({ scope: "col", class: "umbika-data-table__actions" }, "Actions"),
|
|
213
|
+
),
|
|
214
|
+
),
|
|
215
|
+
tbody(
|
|
216
|
+
foreach(
|
|
217
|
+
{ id: _resourcePathKey, resource: true },
|
|
218
|
+
rows,
|
|
219
|
+
(
|
|
220
|
+
/** @type {import("@kayr/umbika-core").ActiveTableRow} */ initial,
|
|
221
|
+
/** @type {number} */ _index,
|
|
222
|
+
/** @type {import("../contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveTableRow>} */ row,
|
|
223
|
+
) =>
|
|
224
|
+
_renderSummaryRow(initial, row, table, columns, tableName, context),
|
|
225
|
+
),
|
|
226
|
+
),
|
|
227
|
+
),
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @param {import("@kayr/umbika-core").ActiveTableRow} initial
|
|
233
|
+
* @param {import("../contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveTableRow>} row
|
|
234
|
+
* @param {import("../contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveFieldNode>} table
|
|
235
|
+
* @param {import("../contracts.js").ResourceListSource<import("../contracts.js").OwnedWebTableColumnLayout>} columns
|
|
236
|
+
* @param {string} tableName
|
|
237
|
+
* @param {import("../contracts.js").NodeRendererContext} context
|
|
238
|
+
*/
|
|
239
|
+
function _renderSummaryRow(initial, row, table, columns, tableName, context) {
|
|
240
|
+
const rowId = _structuralDomId(context.instanceId, "row", initial.path);
|
|
241
|
+
const editId = _structuralDomId(context.instanceId, "edit-row", initial.path);
|
|
242
|
+
const errorsId = _structuralDomId(
|
|
243
|
+
context.instanceId,
|
|
244
|
+
"row-errors",
|
|
245
|
+
initial.path,
|
|
246
|
+
);
|
|
247
|
+
const errorCount = computed(
|
|
248
|
+
() => _visibleErrorCount(row.get()?.children ?? []),
|
|
249
|
+
row,
|
|
250
|
+
);
|
|
251
|
+
const open = (/** @type {string} */ openerId) => {
|
|
252
|
+
const current = row.get();
|
|
253
|
+
if (current)
|
|
254
|
+
context.openRow?.(current.path, openerId, context.definitionPath);
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
return tr(
|
|
258
|
+
{
|
|
259
|
+
id: rowId,
|
|
260
|
+
class: "umbika-data-table__row",
|
|
261
|
+
"data-umbika-row-id": initial.id,
|
|
262
|
+
"aria-describedby": errorsId,
|
|
263
|
+
"data-umbika-invalid": rx.attr(
|
|
264
|
+
errorCount,
|
|
265
|
+
(/** @type {number} */ count) => (count > 0 ? "true" : "false"),
|
|
266
|
+
),
|
|
267
|
+
},
|
|
268
|
+
foreach(
|
|
269
|
+
{ id: "key", resource: true },
|
|
270
|
+
columns,
|
|
271
|
+
(
|
|
272
|
+
/** @type {import("../contracts.js").OwnedWebTableColumnLayout} */ _initialColumn,
|
|
273
|
+
/** @type {number} */ _index,
|
|
274
|
+
/** @type {import("../contracts.js").KeyedItemResource<import("../contracts.js").OwnedWebTableColumnLayout>} */ column,
|
|
275
|
+
) => {
|
|
276
|
+
return td(
|
|
277
|
+
{
|
|
278
|
+
"data-umbika-align": rx.attr(
|
|
279
|
+
column,
|
|
280
|
+
(
|
|
281
|
+
/** @type {import("../contracts.js").OwnedWebTableColumnLayout | undefined} */ current,
|
|
282
|
+
) => current?.align ?? "start",
|
|
283
|
+
),
|
|
284
|
+
"aria-label": rx.attr(
|
|
285
|
+
row,
|
|
286
|
+
(
|
|
287
|
+
/** @type {import("@kayr/umbika-core").ActiveTableRow | undefined} */ currentRow,
|
|
288
|
+
) =>
|
|
289
|
+
currentRow &&
|
|
290
|
+
_summaryValueAt(currentRow, _initialColumn.path).available
|
|
291
|
+
? null
|
|
292
|
+
: "Unavailable",
|
|
293
|
+
),
|
|
294
|
+
},
|
|
295
|
+
rx.text(
|
|
296
|
+
row,
|
|
297
|
+
(
|
|
298
|
+
/** @type {import("@kayr/umbika-core").ActiveTableRow | undefined} */ currentRow,
|
|
299
|
+
) =>
|
|
300
|
+
currentRow
|
|
301
|
+
? _summaryValueAt(currentRow, _initialColumn.path).display
|
|
302
|
+
: "—",
|
|
303
|
+
),
|
|
304
|
+
);
|
|
305
|
+
},
|
|
306
|
+
),
|
|
307
|
+
td(
|
|
308
|
+
{ class: "umbika-data-table__actions" },
|
|
309
|
+
p(
|
|
310
|
+
{
|
|
311
|
+
id: errorsId,
|
|
312
|
+
class: "umbika-data-table__row-errors",
|
|
313
|
+
"aria-live": "polite",
|
|
314
|
+
},
|
|
315
|
+
rx.text(errorCount, (count) =>
|
|
316
|
+
count > 0 ? `${count} ${count === 1 ? "error" : "errors"}` : "",
|
|
317
|
+
),
|
|
318
|
+
),
|
|
319
|
+
button(
|
|
320
|
+
{
|
|
321
|
+
id: editId,
|
|
322
|
+
type: "button",
|
|
323
|
+
class: "umbika-data-table__edit",
|
|
324
|
+
"aria-label": rx.attr(row, (currentRow) =>
|
|
325
|
+
currentRow
|
|
326
|
+
? _editRowLabel(currentRow, columns.get(), tableName)
|
|
327
|
+
: `Edit row in ${tableName}`,
|
|
328
|
+
),
|
|
329
|
+
"aria-describedby": errorsId,
|
|
330
|
+
onclick: () => open(editId),
|
|
331
|
+
},
|
|
332
|
+
"Edit",
|
|
333
|
+
),
|
|
334
|
+
),
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** @param {import("@kayr/umbika-core").ActiveTableRow} row @param {readonly import("../contracts.js").OwnedWebTableColumnLayout[]} columns @param {string} tableName */
|
|
339
|
+
function _editRowLabel(row, columns, tableName) {
|
|
340
|
+
const primary = _primarySummaryValue(row, columns);
|
|
341
|
+
return primary.available
|
|
342
|
+
? `Edit ${primary.display} in ${tableName}`
|
|
343
|
+
: `Edit row in ${tableName}`;
|
|
344
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ref, rx } from "../casconda.js";
|
|
2
|
+
import {
|
|
3
|
+
_fieldDescription,
|
|
4
|
+
_fieldPresentation,
|
|
5
|
+
} from "../field-presentation.js";
|
|
6
|
+
import { div, input } from "../tags.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {import("../contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveFieldNode>} resource
|
|
10
|
+
* @param {import("../contracts.js").NodeRendererContext} context
|
|
11
|
+
*/
|
|
12
|
+
export function _renderTextField(resource, context) {
|
|
13
|
+
const initial = resource.get();
|
|
14
|
+
if (!initial || initial.type !== "text") return "";
|
|
15
|
+
|
|
16
|
+
const presentation = _fieldPresentation(
|
|
17
|
+
context.instanceId,
|
|
18
|
+
initial,
|
|
19
|
+
resource,
|
|
20
|
+
);
|
|
21
|
+
const draft = ref(_textDisplayValue(initial.value));
|
|
22
|
+
|
|
23
|
+
// The draft is local to this Casconda-owned control. Its synchronous
|
|
24
|
+
// publication sets the engine value before the declarative blur action.
|
|
25
|
+
draft.subscribe((/** @type {unknown} */ value) => {
|
|
26
|
+
const current = resource.get();
|
|
27
|
+
if (!current || current.type !== "text") return;
|
|
28
|
+
context.setText?.(current.path, String(value));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return div(
|
|
32
|
+
{
|
|
33
|
+
class: "umbika-field",
|
|
34
|
+
"data-umbika-kind": "text",
|
|
35
|
+
},
|
|
36
|
+
presentation.label,
|
|
37
|
+
_fieldDescription(presentation.descriptionId, "Text response"),
|
|
38
|
+
input({
|
|
39
|
+
id: presentation.control,
|
|
40
|
+
class: "umbika-field__control",
|
|
41
|
+
type: "text",
|
|
42
|
+
bind: {
|
|
43
|
+
ref: draft,
|
|
44
|
+
source: resource,
|
|
45
|
+
read: (
|
|
46
|
+
/** @type {import("@kayr/umbika-core").ActiveFieldNode | undefined} */ node,
|
|
47
|
+
) => (node?.type === "text" ? _textDisplayValue(node.value) : ""),
|
|
48
|
+
event: "blur",
|
|
49
|
+
},
|
|
50
|
+
required: rx.prop(
|
|
51
|
+
resource,
|
|
52
|
+
(
|
|
53
|
+
/** @type {import("@kayr/umbika-core").ActiveFieldNode | undefined} */ node,
|
|
54
|
+
) => (node?.type === "text" ? node.required : false),
|
|
55
|
+
),
|
|
56
|
+
"aria-required": rx.attr(
|
|
57
|
+
resource,
|
|
58
|
+
(
|
|
59
|
+
/** @type {import("@kayr/umbika-core").ActiveFieldNode | undefined} */ node,
|
|
60
|
+
) => String(node?.type === "text" && node.required),
|
|
61
|
+
),
|
|
62
|
+
"aria-invalid": rx.attr(
|
|
63
|
+
resource,
|
|
64
|
+
(
|
|
65
|
+
/** @type {import("@kayr/umbika-core").ActiveFieldNode | undefined} */ node,
|
|
66
|
+
) => String(node?.type === "text" && node.errors.length > 0),
|
|
67
|
+
),
|
|
68
|
+
"aria-describedby": presentation.describedBy,
|
|
69
|
+
onblur: () => {
|
|
70
|
+
const current = resource.get();
|
|
71
|
+
if (!current || current.type !== "text") return;
|
|
72
|
+
context.touchText?.(current.path);
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
presentation.errors,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @param {unknown} value */
|
|
80
|
+
export function _textDisplayValue(value) {
|
|
81
|
+
return value === undefined || value === null ? "" : String(value);
|
|
82
|
+
}
|