@jsswift/ui 1.0.45 → 1.0.47
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/min-ui.js +4 -4
- package/dist/ui.js +10562 -14121
- package/dist/ui.min.js +4 -4
- package/package.json +2 -2
- package/src/01-foundation-helpers.js +0 -402
- package/src/10-primitives-layout.js +15 -1014
- package/src/20-display-content.js +484 -718
- package/src/21-list-content.js +246 -341
- package/src/22-banner-content.js +3 -116
- package/src/23-tooltip.js +276 -326
- package/src/31-form-advanced.js +2638 -3003
- package/src/40-navigation.js +1262 -1454
- package/src/41-tab-panel.js +896 -1090
- package/src/50-feedback.js +999 -1209
- package/src/60-shell-app.js +5 -265
- package/src/61-form-service.js +304 -386
- package/src/70-dialog.js +209 -277
- package/src/71-menu-overlays.js +1175 -1400
- package/src/80-data.js +433 -503
- package/src/modules.json +59 -23
package/src/21-list-content.js
CHANGED
|
@@ -1,341 +1,246 @@
|
|
|
1
|
-
UI.List = (...args) => {
|
|
2
|
-
const { props, children } = JSswift.uiNormalizeArgs(args);
|
|
3
|
-
const slots = props.slots || {};
|
|
4
|
-
const ordered = !!uiUnwrap(props.number ?? props.ordered);
|
|
5
|
-
const marker = uiUnwrap(props.marker);
|
|
6
|
-
const itemSource = uiUnwrap(props.items);
|
|
7
|
-
const items = Array.isArray(itemSource) ? itemSource : (itemSource == null ? [] : [itemSource]);
|
|
8
|
-
|
|
9
|
-
const buildItemProps = (entryProps = {}) => {
|
|
10
|
-
const baseProps = props.itemProps || {};
|
|
11
|
-
const merged = { ...baseProps, ...entryProps };
|
|
12
|
-
if (props.divider != null && merged.divider == null) merged.divider = props.divider;
|
|
13
|
-
merged.class = uiClass([baseProps.class, props.itemClass, entryProps.class]);
|
|
14
|
-
merged.style = {
|
|
15
|
-
...(baseProps.style || {}),
|
|
16
|
-
...(props.itemStyle || {}),
|
|
17
|
-
...(entryProps.style || {})
|
|
18
|
-
};
|
|
19
|
-
return merged;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const normalizeResolvedNode = (value) => {
|
|
23
|
-
if (value == null || value === false) return [];
|
|
24
|
-
if (isListItemNode(value)) return [value];
|
|
25
|
-
if (isUIPlainObject(value)) {
|
|
26
|
-
const itemChildren = value.children != null
|
|
27
|
-
? asNodeArray(value.children)
|
|
28
|
-
: (value.content != null
|
|
29
|
-
? asNodeArray(value.content)
|
|
30
|
-
: asNodeArray(value.node));
|
|
31
|
-
return [UI.Item(buildItemProps(value), ...itemChildren)];
|
|
32
|
-
}
|
|
33
|
-
if (Array.isArray(value)) {
|
|
34
|
-
return [UI.Item(buildItemProps(), ...value)];
|
|
35
|
-
}
|
|
36
|
-
if (value?.nodeType) {
|
|
37
|
-
return [UI.Item(buildItemProps(), value)];
|
|
38
|
-
}
|
|
39
|
-
return [UI.Item(buildItemProps(), value)];
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const normalizeItemNode = (value, index, total, useItemSlot = true) => {
|
|
43
|
-
if (value == null || value === false) return [];
|
|
44
|
-
if (useItemSlot) {
|
|
45
|
-
const ctx = {
|
|
46
|
-
item: value,
|
|
47
|
-
index,
|
|
48
|
-
count: total,
|
|
49
|
-
first: index === 0,
|
|
50
|
-
last: index === total - 1
|
|
51
|
-
};
|
|
52
|
-
const slotted = renderSlotToArray(slots, "item", ctx, null);
|
|
53
|
-
if (slotted.length) {
|
|
54
|
-
return slotted.flatMap((node) => normalizeResolvedNode(node));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return normalizeResolvedNode(value);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const content = [];
|
|
61
|
-
items.forEach((item, index) => {
|
|
62
|
-
content.push(...normalizeItemNode(item, index, items.length));
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const defaultNodes = renderSlotToArray(slots, "default", { items, count: items.length }, children);
|
|
66
|
-
defaultNodes.forEach((node, index) => {
|
|
67
|
-
content.push(...normalizeItemNode(node, items.length + index, items.length + defaultNodes.length, false));
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
if (!content.length) {
|
|
71
|
-
const emptyNodes = renderSlotToArray(slots, "empty", { items, count: 0 }, props.empty);
|
|
72
|
-
if (emptyNodes.length) {
|
|
73
|
-
if (emptyNodes.length === 1 && isListItemNode(emptyNodes[0])) {
|
|
74
|
-
content.push(emptyNodes[0]);
|
|
75
|
-
} else {
|
|
76
|
-
content.push(UI.Item({ class: "cms-item-empty", flat: true }, ...emptyNodes));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const cls = uiClass([
|
|
82
|
-
"cms-list",
|
|
83
|
-
uiWhen(props.dense, "dense"),
|
|
84
|
-
uiWhen(props.divider, "divider"),
|
|
85
|
-
uiWhen(marker === false || marker === "none", "cms-list-no-marker"),
|
|
86
|
-
props.class
|
|
87
|
-
]);
|
|
88
|
-
const p = JSswift.omit(props, [
|
|
89
|
-
"dense", "divider", "slots", "number", "ordered", "items", "itemClass", "itemStyle", "itemProps",
|
|
90
|
-
"empty", "marker", "gap"
|
|
91
|
-
]);
|
|
92
|
-
p.class = cls;
|
|
93
|
-
p.style = {
|
|
94
|
-
...(props.style || {})
|
|
95
|
-
};
|
|
96
|
-
const gap = uiStyleValue(props.gap, toCssSize);
|
|
97
|
-
if (gap != null) p.style["--cms-list-gap"] = gap;
|
|
98
|
-
if (marker != null && marker !== false && marker !== true && marker !== "none") {
|
|
99
|
-
p.style.listStyleType = String(marker);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const list = _[ordered ? "ol" : "ul"](p, ...content);
|
|
103
|
-
return list;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
"
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
asideNodes.length ? _.div({ class: "cms-item-aside" }, ...asideNodes) : null
|
|
248
|
-
)
|
|
249
|
-
);
|
|
250
|
-
setPropertyProps(item, props);
|
|
251
|
-
return item;
|
|
252
|
-
};
|
|
253
|
-
if (JSswift.isDev?.()) {
|
|
254
|
-
UI.meta = UI.meta || {};
|
|
255
|
-
UI.meta.Item = {
|
|
256
|
-
signature: "UI.Item(...children) | UI.Item(props, ...children)",
|
|
257
|
-
props: {
|
|
258
|
-
label: "String|Node|Function|Array",
|
|
259
|
-
title: "String|Node|Function|Array",
|
|
260
|
-
subtitle: "String|Node|Function|Array",
|
|
261
|
-
meta: "String|Node|Function|Array",
|
|
262
|
-
body: "String|Node|Function|Array",
|
|
263
|
-
icon: "String|Node|Function|Array",
|
|
264
|
-
iconRight: "String|Node|Function|Array",
|
|
265
|
-
aside: "Node|Function|Array",
|
|
266
|
-
actions: "Node|Function|Array",
|
|
267
|
-
clickable: "boolean",
|
|
268
|
-
to: "string",
|
|
269
|
-
active: "boolean",
|
|
270
|
-
selected: "boolean",
|
|
271
|
-
disabled: "boolean",
|
|
272
|
-
color: "string",
|
|
273
|
-
state: "Alias of color",
|
|
274
|
-
size: "string|number",
|
|
275
|
-
outline: "boolean",
|
|
276
|
-
shadow: "boolean|string",
|
|
277
|
-
lightShadow: "boolean",
|
|
278
|
-
border: "boolean",
|
|
279
|
-
glossy: "boolean",
|
|
280
|
-
glow: "boolean",
|
|
281
|
-
glass: "boolean",
|
|
282
|
-
gradient: "boolean|number",
|
|
283
|
-
textGradient: "boolean",
|
|
284
|
-
radius: "string|number",
|
|
285
|
-
divider: "boolean",
|
|
286
|
-
slots: "{ icon?, title?, subtitle?, meta?, body?, aside?, actions?, default? }",
|
|
287
|
-
class: "string",
|
|
288
|
-
style: "object"
|
|
289
|
-
},
|
|
290
|
-
slots: {
|
|
291
|
-
icon: "Leading visual/icon",
|
|
292
|
-
title: "Main title content",
|
|
293
|
-
subtitle: "Secondary text",
|
|
294
|
-
meta: "Top meta content",
|
|
295
|
-
body: "Body content",
|
|
296
|
-
aside: "Trailing content",
|
|
297
|
-
actions: "Actions row",
|
|
298
|
-
default: "Fallback body content"
|
|
299
|
-
},
|
|
300
|
-
returns: "HTMLLIElement",
|
|
301
|
-
description: "Structured item for simple lists, feeds, task lists, and clickable rows."
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
// Esempio: JSswift.ui.Item({}, "Elemento")
|
|
305
|
-
|
|
306
|
-
UI.Separator = (...args) => {
|
|
307
|
-
const { props } = JSswift.uiNormalizeArgs(args);
|
|
308
|
-
const cls = uiClass(["cms-separator", uiWhen(props.vertical, "vertical"), props.class]);
|
|
309
|
-
const p = JSswift.omit(props, ["vertical", "size", "slots"]);
|
|
310
|
-
p.class = cls;
|
|
311
|
-
const style = { borderColor: "var(--cms-border)", ...(props.style || {}) };
|
|
312
|
-
const sizeValue = uiUnwrap(props.size);
|
|
313
|
-
const vertical = uiUnwrap(props.vertical);
|
|
314
|
-
if (sizeValue != null) {
|
|
315
|
-
const size = toCssSize(sizeValue);
|
|
316
|
-
if (vertical) style.width = size;
|
|
317
|
-
else style.height = size;
|
|
318
|
-
}
|
|
319
|
-
p.style = style;
|
|
320
|
-
return _.hr(p);
|
|
321
|
-
};
|
|
322
|
-
if (JSswift.isDev?.()) {
|
|
323
|
-
UI.meta = UI.meta || {};
|
|
324
|
-
UI.meta.Separator = {
|
|
325
|
-
signature: "UI.Separator() | UI.Separator(props)",
|
|
326
|
-
props: {
|
|
327
|
-
vertical: "boolean",
|
|
328
|
-
size: "string|number",
|
|
329
|
-
slots: "{ default? }",
|
|
330
|
-
class: "string",
|
|
331
|
-
style: "object"
|
|
332
|
-
},
|
|
333
|
-
slots: {
|
|
334
|
-
default: "Unused (separator has no content)"
|
|
335
|
-
},
|
|
336
|
-
returns: "HTMLHRElement",
|
|
337
|
-
description: "Separatore orizzontale o verticale."
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
// Esempio: JSswift.ui.Separator()
|
|
341
|
-
|
|
1
|
+
UI.List = (...args) => {
|
|
2
|
+
const { props, children } = JSswift.uiNormalizeArgs(args);
|
|
3
|
+
const slots = props.slots || {};
|
|
4
|
+
const ordered = !!uiUnwrap(props.number ?? props.ordered);
|
|
5
|
+
const marker = uiUnwrap(props.marker);
|
|
6
|
+
const itemSource = uiUnwrap(props.items);
|
|
7
|
+
const items = Array.isArray(itemSource) ? itemSource : (itemSource == null ? [] : [itemSource]);
|
|
8
|
+
|
|
9
|
+
const buildItemProps = (entryProps = {}) => {
|
|
10
|
+
const baseProps = props.itemProps || {};
|
|
11
|
+
const merged = { ...baseProps, ...entryProps };
|
|
12
|
+
if (props.divider != null && merged.divider == null) merged.divider = props.divider;
|
|
13
|
+
merged.class = uiClass([baseProps.class, props.itemClass, entryProps.class]);
|
|
14
|
+
merged.style = {
|
|
15
|
+
...(baseProps.style || {}),
|
|
16
|
+
...(props.itemStyle || {}),
|
|
17
|
+
...(entryProps.style || {})
|
|
18
|
+
};
|
|
19
|
+
return merged;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const normalizeResolvedNode = (value) => {
|
|
23
|
+
if (value == null || value === false) return [];
|
|
24
|
+
if (isListItemNode(value)) return [value];
|
|
25
|
+
if (isUIPlainObject(value)) {
|
|
26
|
+
const itemChildren = value.children != null
|
|
27
|
+
? asNodeArray(value.children)
|
|
28
|
+
: (value.content != null
|
|
29
|
+
? asNodeArray(value.content)
|
|
30
|
+
: asNodeArray(value.node));
|
|
31
|
+
return [UI.Item(buildItemProps(value), ...itemChildren)];
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
return [UI.Item(buildItemProps(), ...value)];
|
|
35
|
+
}
|
|
36
|
+
if (value?.nodeType) {
|
|
37
|
+
return [UI.Item(buildItemProps(), value)];
|
|
38
|
+
}
|
|
39
|
+
return [UI.Item(buildItemProps(), value)];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const normalizeItemNode = (value, index, total, useItemSlot = true) => {
|
|
43
|
+
if (value == null || value === false) return [];
|
|
44
|
+
if (useItemSlot) {
|
|
45
|
+
const ctx = {
|
|
46
|
+
item: value,
|
|
47
|
+
index,
|
|
48
|
+
count: total,
|
|
49
|
+
first: index === 0,
|
|
50
|
+
last: index === total - 1
|
|
51
|
+
};
|
|
52
|
+
const slotted = renderSlotToArray(slots, "item", ctx, null);
|
|
53
|
+
if (slotted.length) {
|
|
54
|
+
return slotted.flatMap((node) => normalizeResolvedNode(node));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return normalizeResolvedNode(value);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const content = [];
|
|
61
|
+
items.forEach((item, index) => {
|
|
62
|
+
content.push(...normalizeItemNode(item, index, items.length));
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const defaultNodes = renderSlotToArray(slots, "default", { items, count: items.length }, children);
|
|
66
|
+
defaultNodes.forEach((node, index) => {
|
|
67
|
+
content.push(...normalizeItemNode(node, items.length + index, items.length + defaultNodes.length, false));
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (!content.length) {
|
|
71
|
+
const emptyNodes = renderSlotToArray(slots, "empty", { items, count: 0 }, props.empty);
|
|
72
|
+
if (emptyNodes.length) {
|
|
73
|
+
if (emptyNodes.length === 1 && isListItemNode(emptyNodes[0])) {
|
|
74
|
+
content.push(emptyNodes[0]);
|
|
75
|
+
} else {
|
|
76
|
+
content.push(UI.Item({ class: "cms-item-empty", flat: true }, ...emptyNodes));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const cls = uiClass([
|
|
82
|
+
"cms-list",
|
|
83
|
+
uiWhen(props.dense, "dense"),
|
|
84
|
+
uiWhen(props.divider, "divider"),
|
|
85
|
+
uiWhen(marker === false || marker === "none", "cms-list-no-marker"),
|
|
86
|
+
props.class
|
|
87
|
+
]);
|
|
88
|
+
const p = JSswift.omit(props, [
|
|
89
|
+
"dense", "divider", "slots", "number", "ordered", "items", "itemClass", "itemStyle", "itemProps",
|
|
90
|
+
"empty", "marker", "gap"
|
|
91
|
+
]);
|
|
92
|
+
p.class = cls;
|
|
93
|
+
p.style = {
|
|
94
|
+
...(props.style || {})
|
|
95
|
+
};
|
|
96
|
+
const gap = uiStyleValue(props.gap, toCssSize);
|
|
97
|
+
if (gap != null) p.style["--cms-list-gap"] = gap;
|
|
98
|
+
if (marker != null && marker !== false && marker !== true && marker !== "none") {
|
|
99
|
+
p.style.listStyleType = String(marker);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const list = _[ordered ? "ol" : "ul"](p, ...content);
|
|
103
|
+
return list;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Esempio: JSswift.ui.List({}, JSswift.ui.Item({}, "Item"))
|
|
107
|
+
|
|
108
|
+
UI.Item = (...args) => {
|
|
109
|
+
const { props, children } = JSswift.uiNormalizeArgs(args);
|
|
110
|
+
if (props.state != null && props.color == null) props.color = props.state;
|
|
111
|
+
applyCommonProps(props);
|
|
112
|
+
const slots = props.slots || {};
|
|
113
|
+
const interactive = uiComputed([props.clickable, props.to], () => !!(uiUnwrap(props.clickable) || uiUnwrap(props.to)));
|
|
114
|
+
const active = uiComputed([props.active, props.selected], () => !!(uiUnwrap(props.active) || uiUnwrap(props.selected)));
|
|
115
|
+
const hasSurface = !!(
|
|
116
|
+
props.color != null || props.outline || props.border || props.glossy || props.glow || props.glass ||
|
|
117
|
+
props.shadow || props.gradient || props.textGradient || props.lightShadow || props.radius ||
|
|
118
|
+
props.rounded || props.flat
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const resolveIcon = (value, size, as) => {
|
|
122
|
+
const raw = uiUnwrap(value);
|
|
123
|
+
if (raw == null || raw === false || raw === "") return null;
|
|
124
|
+
if (typeof raw === "string") return UI.Icon({ name: raw, size: size || "sm" });
|
|
125
|
+
return JSswift.ui.slot(raw, { as });
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const iconNodes = renderSlotToArray(slots, "icon", {}, resolveIcon(props.icon, props.iconSize || props.size, "icon"));
|
|
129
|
+
const titleNodes = renderSlotToArray(slots, "title", {}, props.title ?? props.label);
|
|
130
|
+
const subtitleNodes = renderSlotToArray(slots, "subtitle", {}, props.subtitle ?? props.caption ?? props.description);
|
|
131
|
+
const metaNodes = renderSlotToArray(slots, "meta", {}, props.meta ?? props.eyebrow);
|
|
132
|
+
const bodyNodes = renderSlotToArray(slots, "body", {}, props.body ?? props.content);
|
|
133
|
+
const defaultNodes = renderSlotToArray(slots, "default", {}, children);
|
|
134
|
+
const actionsNodes = renderSlotToArray(slots, "actions", {}, props.actions ?? props.footer);
|
|
135
|
+
const asideFallback = props.aside ?? props.trailing ?? resolveIcon(props.iconRight, props.iconSize || props.size, "iconRight");
|
|
136
|
+
const asideNodes = renderSlotToArray(slots, "aside", {}, asideFallback);
|
|
137
|
+
|
|
138
|
+
const mergedBodyNodes = [...bodyNodes, ...defaultNodes];
|
|
139
|
+
const isInline = !(
|
|
140
|
+
hasSurface || props.clickable || props.to || iconNodes.length || titleNodes.length ||
|
|
141
|
+
subtitleNodes.length || metaNodes.length || actionsNodes.length || asideNodes.length ||
|
|
142
|
+
bodyNodes.length
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const cls = uiClass([
|
|
146
|
+
"cms-item",
|
|
147
|
+
uiWhen(props.divider, "divider"),
|
|
148
|
+
uiWhen(hasSurface, "cms-clear-set"),
|
|
149
|
+
uiWhen(hasSurface, "cms-singularity"),
|
|
150
|
+
uiWhen(hasSurface, "cms-item-surface"),
|
|
151
|
+
uiWhen(isInline, "cms-item-inline"),
|
|
152
|
+
uiWhen(interactive, "cms-item-clickable"),
|
|
153
|
+
uiWhen(active, "is-active"),
|
|
154
|
+
uiWhen(props.disabled, "is-disabled"),
|
|
155
|
+
props.class
|
|
156
|
+
]);
|
|
157
|
+
const p = JSswift.omit(props, [
|
|
158
|
+
"divider", "slots", "label", "title", "subtitle", "caption", "description", "meta", "eyebrow",
|
|
159
|
+
"body", "content", "children", "node", "icon", "iconRight", "iconSize", "aside", "trailing",
|
|
160
|
+
"actions", "footer", "clickable", "to", "active", "selected", "disabled", "state",
|
|
161
|
+
"color", "size", "outline", "flat", "border", "glossy", "glow", "glass", "gradient",
|
|
162
|
+
"textGradient", "lightShadow", "shadow", "rounded", "radius", "textColor", "dense"
|
|
163
|
+
]);
|
|
164
|
+
p.class = cls;
|
|
165
|
+
p.style = {
|
|
166
|
+
...(props.style || {})
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const userOnClick = props.onClick;
|
|
170
|
+
const userOnKeydown = props.onKeydown;
|
|
171
|
+
const onClick = (e) => {
|
|
172
|
+
userOnClick?.(e);
|
|
173
|
+
if (e.defaultPrevented || uiUnwrap(props.disabled)) return;
|
|
174
|
+
const to = uiUnwrap(props.to);
|
|
175
|
+
if (to && JSswift.router?.navigate) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
JSswift.router.navigate(to);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const onKeydown = (e) => {
|
|
181
|
+
userOnKeydown?.(e);
|
|
182
|
+
if (e.defaultPrevented || uiUnwrap(props.disabled)) return;
|
|
183
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
onClick(e);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
if (uiUnwrap(props.disabled)) {
|
|
189
|
+
p["aria-disabled"] = "true";
|
|
190
|
+
}
|
|
191
|
+
if (uiUnwrap(props.clickable) || uiUnwrap(props.to)) {
|
|
192
|
+
p.onClick = onClick;
|
|
193
|
+
p.onKeydown = onKeydown;
|
|
194
|
+
if (p.tabIndex == null) p.tabIndex = uiUnwrap(props.disabled) ? -1 : 0;
|
|
195
|
+
if (p.role == null) p.role = "button";
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const titleSection = titleNodes.length ? _.div({ class: "cms-item-title" }, ...titleNodes) : null;
|
|
199
|
+
const subtitleSection = subtitleNodes.length ? _.div({ class: "cms-item-subtitle" }, ...subtitleNodes) : null;
|
|
200
|
+
const metaSection = metaNodes.length ? _.div({ class: "cms-item-meta" }, ...metaNodes) : null;
|
|
201
|
+
const bodySection = mergedBodyNodes.length
|
|
202
|
+
? _.div({ class: uiClass(["cms-item-body", uiWhen(!(titleNodes.length || subtitleNodes.length || metaNodes.length), "is-standalone")]) }, ...mergedBodyNodes)
|
|
203
|
+
: null;
|
|
204
|
+
const actionsSection = actionsNodes.length ? _.div({ class: "cms-item-actions" }, ...actionsNodes) : null;
|
|
205
|
+
|
|
206
|
+
const item = _.li(
|
|
207
|
+
p,
|
|
208
|
+
_.div(
|
|
209
|
+
{ class: "cms-item-row" },
|
|
210
|
+
iconNodes.length ? _.div({ class: "cms-item-icon" }, ...iconNodes) : null,
|
|
211
|
+
_.div(
|
|
212
|
+
{ class: "cms-item-main" },
|
|
213
|
+
metaSection,
|
|
214
|
+
titleSection,
|
|
215
|
+
subtitleSection,
|
|
216
|
+
bodySection,
|
|
217
|
+
actionsSection
|
|
218
|
+
),
|
|
219
|
+
asideNodes.length ? _.div({ class: "cms-item-aside" }, ...asideNodes) : null
|
|
220
|
+
)
|
|
221
|
+
);
|
|
222
|
+
setPropertyProps(item, props);
|
|
223
|
+
return item;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// Esempio: JSswift.ui.Item({}, "Elemento")
|
|
227
|
+
|
|
228
|
+
UI.Separator = (...args) => {
|
|
229
|
+
const { props } = JSswift.uiNormalizeArgs(args);
|
|
230
|
+
const cls = uiClass(["cms-separator", uiWhen(props.vertical, "vertical"), props.class]);
|
|
231
|
+
const p = JSswift.omit(props, ["vertical", "size", "slots"]);
|
|
232
|
+
p.class = cls;
|
|
233
|
+
const style = { borderColor: "var(--cms-border)", ...(props.style || {}) };
|
|
234
|
+
const sizeValue = uiUnwrap(props.size);
|
|
235
|
+
const vertical = uiUnwrap(props.vertical);
|
|
236
|
+
if (sizeValue != null) {
|
|
237
|
+
const size = toCssSize(sizeValue);
|
|
238
|
+
if (vertical) style.width = size;
|
|
239
|
+
else style.height = size;
|
|
240
|
+
}
|
|
241
|
+
p.style = style;
|
|
242
|
+
return _.hr(p);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// Esempio: JSswift.ui.Separator()
|
|
246
|
+
|