@jsswift/ui 1.0.54 → 2.0.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/dist/css/animation.css +36 -36
- package/dist/css/base.css +374 -374
- package/dist/css/docs.css +54 -54
- package/dist/css/fonts-nunito.css +2 -2
- package/dist/css/min-ui.css +1 -1
- package/dist/css/responsive-base.css +549 -549
- package/dist/css/responsive.css +3225 -3225
- package/dist/css/ui-components.css +2902 -2930
- package/dist/css/ui-light.css +3853 -3881
- package/dist/css/ui-light.min.css +1 -1
- package/dist/css/ui.css +6530 -6558
- package/dist/css/ui.min.css +1 -1
- package/dist/min-ui.js +12 -12
- package/dist/ui.js +4354 -9379
- package/dist/ui.min.js +12 -12
- package/package.json +2 -2
- package/src/00-bootstrap.js +305 -305
- package/src/01-foundation-helpers.js +328 -325
- package/src/10-primitives-layout.js +242 -242
- package/src/20-display-content.js +76 -76
- package/src/21-list-content.js +21 -21
- package/src/22-banner-content.js +376 -376
- package/src/23-tooltip.js +9 -9
- package/src/31-form-advanced.js +141 -141
- package/src/40-navigation.js +81 -81
- package/src/41-tab-panel.js +37 -37
- package/src/50-feedback.js +52 -52
- package/src/51-feedback-service.js +166 -166
- package/src/60-shell-app.js +1082 -1082
- package/src/61-form-service.js +5 -5
- package/src/70-dialog.js +34 -34
- package/src/71-menu-overlays.js +73 -73
- package/src/80-data.js +38 -38
- package/src/css/animation.css +36 -36
- package/src/css/base.css +374 -374
- package/src/css/docs.css +54 -54
- package/src/css/fonts-nunito.css +2 -2
- package/src/css/responsive.css +3225 -3225
- package/src/css/ui-components.css +2902 -2930
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
const UI_SHADOW_TOKENS = new Set(["none", "sm", "md", "lg"]);
|
|
2
|
-
const sizeMap = {
|
|
3
|
-
xxs: { font: "9px", pad: "2px 5px" },
|
|
4
|
-
xs: { font: "10px", pad: "2px 6px" },
|
|
5
|
-
sm: { font: "11px", pad: "2px 7px" },
|
|
6
|
-
md: { font: "12px", pad: "2px 8px" },
|
|
7
|
-
lg: { font: "13px", pad: "3px 10px" },
|
|
8
|
-
xl: { font: "14px", pad: "4px 12px" },
|
|
9
|
-
xxl: { font: "15px", pad: "5px 14px" },
|
|
10
|
-
xxxl: { font: "16px", pad: "6px 16px" }
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// normalize color is RGB | RGBA | HEX | color name
|
|
14
|
-
const isTokenCSS = (value) => {
|
|
15
|
-
// se la parola contiene un trattino - è un token
|
|
16
|
-
if (value.indexOf("-") > -1) return true;
|
|
17
|
-
}
|
|
18
|
-
const normalizeState = (value) => {
|
|
19
|
-
if (!value) return "";
|
|
20
|
-
const key = String(value).toLowerCase();
|
|
21
|
-
return UI_STATE_ALIASES[key] || "";
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const normalizeRadius = (value) => {
|
|
25
|
-
if (value == null) return null;
|
|
26
|
-
const key = String(value).toLowerCase();
|
|
27
|
-
if (key === "full") return "xxxl";
|
|
28
|
-
if (UI_RADIUS_TOKENS.has(key)) return key;
|
|
29
|
-
return null;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const normalizeShadow = (value) => {
|
|
33
|
-
if (value === true) return "sm";
|
|
34
|
-
if (value == null || value === false) return null;
|
|
35
|
-
const key = String(value).toLowerCase();
|
|
36
|
-
if (UI_SHADOW_TOKENS.has(key)) return key;
|
|
37
|
-
return null;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const isUIPlainObject = (value) => value && typeof value === "object" && !value.nodeType && !Array.isArray(value) && !(value instanceof Function);
|
|
41
|
-
const isListItemNode = (value) => value && value.nodeType === 1 && String(value.tagName || "").toLowerCase() === "li";
|
|
1
|
+
const UI_SHADOW_TOKENS = new Set(["none", "sm", "md", "lg"]);
|
|
2
|
+
const sizeMap = {
|
|
3
|
+
xxs: { font: "9px", pad: "2px 5px" },
|
|
4
|
+
xs: { font: "10px", pad: "2px 6px" },
|
|
5
|
+
sm: { font: "11px", pad: "2px 7px" },
|
|
6
|
+
md: { font: "12px", pad: "2px 8px" },
|
|
7
|
+
lg: { font: "13px", pad: "3px 10px" },
|
|
8
|
+
xl: { font: "14px", pad: "4px 12px" },
|
|
9
|
+
xxl: { font: "15px", pad: "5px 14px" },
|
|
10
|
+
xxxl: { font: "16px", pad: "6px 16px" }
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// normalize color is RGB | RGBA | HEX | color name
|
|
14
|
+
const isTokenCSS = (value) => {
|
|
15
|
+
// se la parola contiene un trattino - è un token
|
|
16
|
+
if (value.indexOf("-") > -1) return true;
|
|
17
|
+
}
|
|
18
|
+
const normalizeState = (value) => {
|
|
19
|
+
if (!value) return "";
|
|
20
|
+
const key = String(value).toLowerCase();
|
|
21
|
+
return UI_STATE_ALIASES[key] || "";
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const normalizeRadius = (value) => {
|
|
25
|
+
if (value == null) return null;
|
|
26
|
+
const key = String(value).toLowerCase();
|
|
27
|
+
if (key === "full") return "xxxl";
|
|
28
|
+
if (UI_RADIUS_TOKENS.has(key)) return key;
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const normalizeShadow = (value) => {
|
|
33
|
+
if (value === true) return "sm";
|
|
34
|
+
if (value == null || value === false) return null;
|
|
35
|
+
const key = String(value).toLowerCase();
|
|
36
|
+
if (UI_SHADOW_TOKENS.has(key)) return key;
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const isUIPlainObject = (value) => value && typeof value === "object" && !value.nodeType && !Array.isArray(value) && !(value instanceof Function);
|
|
41
|
+
const isListItemNode = (value) => value && value.nodeType === 1 && String(value.tagName || "").toLowerCase() === "li";
|
|
42
42
|
const asNodeArray = (value) => {
|
|
43
43
|
if (value == null || value === false || value === "") return [];
|
|
44
44
|
return Array.isArray(value) ? value : [value];
|
|
@@ -49,9 +49,9 @@ JSswift.isListItemNode = isListItemNode;
|
|
|
49
49
|
JSswift.asNodeArray = asNodeArray;
|
|
50
50
|
|
|
51
51
|
const UI_RESPONSIVE_DEVICES = [
|
|
52
|
-
{ key: "mobile", aliases: ["mobile", "mobil"], prefix: "
|
|
53
|
-
{ key: "tablet", aliases: ["tablet"], prefix: "
|
|
54
|
-
{ key: "pc", aliases: ["pc", "desktop"], prefix: "
|
|
52
|
+
{ key: "mobile", aliases: ["mobile", "mobil"], prefix: "jss-" },
|
|
53
|
+
{ key: "tablet", aliases: ["tablet"], prefix: "jss-tablet-" },
|
|
54
|
+
{ key: "pc", aliases: ["pc", "desktop"], prefix: "jss-pc-" }
|
|
55
55
|
];
|
|
56
56
|
const UI_RESPONSIVE_PROP_KEYS = UI_RESPONSIVE_DEVICES.flatMap((device) => device.aliases);
|
|
57
57
|
const uiResponsiveHasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj || {}, key);
|
|
@@ -96,7 +96,7 @@ const uiResponsiveClassList = (props = {}, rules = []) => {
|
|
|
96
96
|
const list = Array.isArray(resolved) ? resolved : [resolved];
|
|
97
97
|
for (const suffix of list) {
|
|
98
98
|
if (!suffix) continue;
|
|
99
|
-
tokens.push(String(suffix).startsWith("
|
|
99
|
+
tokens.push(String(suffix).startsWith("jss-") ? suffix : `${device.prefix}${suffix}`);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -119,7 +119,7 @@ const uiResponsiveDefaultValue = (value, rule = {}) => {
|
|
|
119
119
|
if (typeof rule.mapValue === "function") return rule.mapValue(value, rule);
|
|
120
120
|
if (typeof value === "number") return rule.number === "raw" ? String(value) : `${value}px`;
|
|
121
121
|
if (rule.token && typeof value === "string" && JSswift.uiSizes?.includes(value)) {
|
|
122
|
-
return `var(--
|
|
122
|
+
return `var(--jss-${rule.token}-${value})`;
|
|
123
123
|
}
|
|
124
124
|
return String(value);
|
|
125
125
|
};
|
|
@@ -129,7 +129,7 @@ const uiResponsiveSetStyle = (style, name, value) => {
|
|
|
129
129
|
else style[name] = value;
|
|
130
130
|
};
|
|
131
131
|
const uiResponsiveVarClass = (deviceKey, varName) => {
|
|
132
|
-
return deviceKey === "mobile" ? `
|
|
132
|
+
return deviceKey === "mobile" ? `jss-rsp-${varName}` : `jss-rsp-${deviceKey}-${varName}`;
|
|
133
133
|
};
|
|
134
134
|
const uiResponsiveAddClass = (target, className) => {
|
|
135
135
|
if (!target || !className) return;
|
|
@@ -140,7 +140,13 @@ const uiResponsiveAddClass = (target, className) => {
|
|
|
140
140
|
target.class = uiClass([target.class, className]);
|
|
141
141
|
};
|
|
142
142
|
const uiApplyResponsiveProps = (target, props = {}, rules = []) => {
|
|
143
|
-
if (!target || !props
|
|
143
|
+
if (!target || !props) return target;
|
|
144
|
+
const configurations = [];
|
|
145
|
+
for (const device of UI_RESPONSIVE_DEVICES) {
|
|
146
|
+
const deviceProps = uiResponsivePropsFor(props, device);
|
|
147
|
+
if (deviceProps) configurations.push([device.key, deviceProps]);
|
|
148
|
+
}
|
|
149
|
+
if (!configurations.length) return target;
|
|
144
150
|
const style = target.style || {};
|
|
145
151
|
let hasResponsiveVars = false;
|
|
146
152
|
|
|
@@ -151,22 +157,19 @@ const uiApplyResponsiveProps = (target, props = {}, rules = []) => {
|
|
|
151
157
|
const value = uiResponsiveDefaultValue(rawValue, rule);
|
|
152
158
|
if (!value) return;
|
|
153
159
|
const varName = rule.var || rule.css;
|
|
154
|
-
const prefix = deviceKey === "mobile" ? "--
|
|
160
|
+
const prefix = deviceKey === "mobile" ? "--jss-rsp-" : `--jss-rsp-${deviceKey}-`;
|
|
155
161
|
uiResponsiveSetStyle(style, `${prefix}${varName}`, value);
|
|
156
162
|
uiResponsiveAddClass(target, uiResponsiveVarClass(deviceKey, varName));
|
|
157
163
|
hasResponsiveVars = true;
|
|
158
164
|
};
|
|
159
165
|
|
|
160
166
|
setVar("mobile", props);
|
|
161
|
-
for (const
|
|
162
|
-
const deviceProps = uiResponsivePropsFor(props, device);
|
|
163
|
-
if (deviceProps) setVar(device.key, deviceProps);
|
|
164
|
-
}
|
|
167
|
+
for (const [deviceKey, deviceProps] of configurations) setVar(deviceKey, deviceProps);
|
|
165
168
|
}
|
|
166
169
|
|
|
167
170
|
if (hasResponsiveVars) {
|
|
168
171
|
if (!target.nodeType) target.style = style;
|
|
169
|
-
uiResponsiveAddClass(target, "
|
|
172
|
+
uiResponsiveAddClass(target, "jss-rsp");
|
|
170
173
|
}
|
|
171
174
|
return target;
|
|
172
175
|
};
|
|
@@ -188,209 +191,209 @@ JSswift.omit = (obj, keys = []) => {
|
|
|
188
191
|
};
|
|
189
192
|
|
|
190
193
|
const applyCommonProps = (props = {}) => {
|
|
191
|
-
const classTokens = [];
|
|
192
|
-
const style = {};
|
|
193
|
-
|
|
194
|
-
classTokens.push(
|
|
195
|
-
uiWhen(props.clickable, "
|
|
196
|
-
uiWhen(props.dense, "
|
|
197
|
-
uiWhen(props.flat, "
|
|
198
|
-
uiWhen(props.border, "
|
|
199
|
-
uiWhen(props.glossy, "
|
|
200
|
-
uiWhen(props.glow, "
|
|
201
|
-
uiWhen(props.glass, "
|
|
202
|
-
uiWhen(props.shadow, "
|
|
203
|
-
uiWhen(props.outline, "
|
|
204
|
-
uiWhen(props.rounded, "
|
|
205
|
-
uiWhen(props.gradient, "
|
|
206
|
-
uiWhen(props.textGradient, "
|
|
207
|
-
uiWhen(props.lightShadow, "
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
if (uiIsReactive(props.color)) {
|
|
211
|
-
classTokens.push(() => {
|
|
212
|
-
const v = uiUnwrap(props.color);
|
|
213
|
-
const state = normalizeState(v);
|
|
214
|
-
return state ? `
|
|
215
|
-
});
|
|
216
|
-
style.backgroundColor = () => {
|
|
217
|
-
const v = uiUnwrap(props.color);
|
|
218
|
-
const state = normalizeState(v);
|
|
219
|
-
if (state) return "";
|
|
220
|
-
if (v && isTokenCSS(String(v))) return `var(--
|
|
221
|
-
return v || "";
|
|
222
|
-
};
|
|
223
|
-
} else {
|
|
224
|
-
const state = normalizeState(props.color);
|
|
225
|
-
if (state) {
|
|
226
|
-
classTokens.push(`
|
|
227
|
-
} else if (props.color && isTokenCSS(props.color)) {
|
|
228
|
-
style.backgroundColor = `var(--
|
|
229
|
-
} else if (props.color) {
|
|
230
|
-
style.backgroundColor = props.color;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// facciamo text color per i token
|
|
235
|
-
if (uiIsReactive(props.textColor)) {
|
|
236
|
-
style.color = () => {
|
|
237
|
-
const v = uiUnwrap(props.textColor);
|
|
238
|
-
if (v && isTokenCSS(String(v))) return `var(--
|
|
239
|
-
return v || "";
|
|
240
|
-
};
|
|
241
|
-
} else if (props.textColor && isTokenCSS(props.textColor)) {
|
|
242
|
-
style.color = `var(--
|
|
243
|
-
} else if (props.textColor) {
|
|
244
|
-
style.color = props.textColor;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (uiIsReactive(props.size)) {
|
|
248
|
-
classTokens.push(() => {
|
|
249
|
-
const v = uiUnwrap(props.size);
|
|
250
|
-
if (typeof v === "string" && JSswift.uiSizes?.includes(v)) return `
|
|
251
|
-
return "";
|
|
252
|
-
});
|
|
253
|
-
} else {
|
|
254
|
-
const size = props.size;
|
|
255
|
-
if (typeof size === "string" && JSswift.uiSizes?.includes(size)) {
|
|
256
|
-
classTokens.push(`
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (uiIsReactive(props.shadow)) {
|
|
261
|
-
classTokens.push(() => {
|
|
262
|
-
const v = uiUnwrap(props.shadow);
|
|
263
|
-
const shadow = normalizeShadow(v);
|
|
264
|
-
return shadow ? `
|
|
265
|
-
});
|
|
266
|
-
style.boxShadow = () => {
|
|
267
|
-
const v = uiUnwrap(props.shadow);
|
|
268
|
-
const shadow = normalizeShadow(v);
|
|
269
|
-
if (shadow || v == null || v === false) return "";
|
|
270
|
-
return typeof v === "string" ? v : "";
|
|
271
|
-
};
|
|
272
|
-
} else {
|
|
273
|
-
const shadow = normalizeShadow(props.shadow);
|
|
274
|
-
if (shadow) classTokens.push(`
|
|
275
|
-
else if (props.shadow && typeof props.shadow === "string") {
|
|
276
|
-
style.boxShadow = props.shadow;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (classTokens.length) {
|
|
281
|
-
props.class = uiClass([props.class, ...classTokens]);
|
|
282
|
-
}
|
|
283
|
-
if (Object.keys(style).length) {
|
|
284
|
-
props.style = { ...style, ...(props.style || {}) };
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
const normalizeArgsBase = JSswift.uiNormalizeArgs;
|
|
289
|
-
JSswift.uiNormalizeArgs = function (args) {
|
|
290
|
-
const out = normalizeArgsBase(args);
|
|
291
|
-
const props = out.props || {};
|
|
292
|
-
if (props && Object.prototype.hasOwnProperty.call(props, "children")) {
|
|
293
|
-
const propChildren = props.children;
|
|
294
|
-
if (!out.children || out.children.length === 0) {
|
|
295
|
-
out.children = Array.isArray(propChildren) ? propChildren : [propChildren];
|
|
296
|
-
}
|
|
297
|
-
delete props.children;
|
|
298
|
-
}
|
|
299
|
-
applyCommonProps(props);
|
|
300
|
-
return out;
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
// --------------------------------
|
|
304
|
-
// 2) UI PRIMITIVES (layout + atoms)
|
|
305
|
-
// --------------------------------
|
|
306
|
-
const UI = window._;
|
|
307
|
-
|
|
308
|
-
/*
|
|
309
|
-
UI.Row
|
|
310
|
-
UI.Col
|
|
311
|
-
UI.Spacer
|
|
312
|
-
UI.Container
|
|
313
|
-
UI.Card
|
|
314
|
-
UI.Btn
|
|
315
|
-
UI.Input
|
|
316
|
-
UI.Select
|
|
317
|
-
UI.Layout
|
|
318
|
-
UI.Footer
|
|
319
|
-
UI.Toolbar
|
|
320
|
-
UI.Grid
|
|
321
|
-
UI.GridCol
|
|
322
|
-
UI.Icon
|
|
323
|
-
UI.Badge
|
|
324
|
-
UI.Avatar
|
|
325
|
-
UI.Chip
|
|
326
|
-
UI.Tooltip
|
|
327
|
-
UI.List
|
|
328
|
-
UI.Item
|
|
329
|
-
UI.Separator
|
|
330
|
-
UI.Checkbox
|
|
331
|
-
UI.Radio
|
|
332
|
-
UI.Toggle
|
|
333
|
-
UI.Slider
|
|
334
|
-
UI.Rating
|
|
194
|
+
const classTokens = [];
|
|
195
|
+
const style = {};
|
|
196
|
+
|
|
197
|
+
classTokens.push(
|
|
198
|
+
uiWhen(props.clickable, "jss-clickable"),
|
|
199
|
+
uiWhen(props.dense, "jss-dense"),
|
|
200
|
+
uiWhen(props.flat, "jss-flat"),
|
|
201
|
+
uiWhen(props.border, "jss-border"),
|
|
202
|
+
uiWhen(props.glossy, "jss-glossy"),
|
|
203
|
+
uiWhen(props.glow, "jss-glow"),
|
|
204
|
+
uiWhen(props.glass, "jss-glass"),
|
|
205
|
+
uiWhen(props.shadow, "jss-shadow"),
|
|
206
|
+
uiWhen(props.outline, "jss-outline"),
|
|
207
|
+
uiWhen(props.rounded, "jss-rounded"),
|
|
208
|
+
uiWhen(props.gradient, "jss-gradient"),
|
|
209
|
+
uiWhen(props.textGradient, "jss-text-gradient"),
|
|
210
|
+
uiWhen(props.lightShadow, "jss-light-shadow")
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
if (uiIsReactive(props.color)) {
|
|
214
|
+
classTokens.push(() => {
|
|
215
|
+
const v = uiUnwrap(props.color);
|
|
216
|
+
const state = normalizeState(v);
|
|
217
|
+
return state ? `jss-state-${state}` : "";
|
|
218
|
+
});
|
|
219
|
+
style.backgroundColor = () => {
|
|
220
|
+
const v = uiUnwrap(props.color);
|
|
221
|
+
const state = normalizeState(v);
|
|
222
|
+
if (state) return "";
|
|
223
|
+
if (v && isTokenCSS(String(v))) return `var(--jss-${v})`;
|
|
224
|
+
return v || "";
|
|
225
|
+
};
|
|
226
|
+
} else {
|
|
227
|
+
const state = normalizeState(props.color);
|
|
228
|
+
if (state) {
|
|
229
|
+
classTokens.push(`jss-state-${state}`);
|
|
230
|
+
} else if (props.color && isTokenCSS(props.color)) {
|
|
231
|
+
style.backgroundColor = `var(--jss-${props.color})`;
|
|
232
|
+
} else if (props.color) {
|
|
233
|
+
style.backgroundColor = props.color;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// facciamo text color per i token
|
|
238
|
+
if (uiIsReactive(props.textColor)) {
|
|
239
|
+
style.color = () => {
|
|
240
|
+
const v = uiUnwrap(props.textColor);
|
|
241
|
+
if (v && isTokenCSS(String(v))) return `var(--jss-${v})`;
|
|
242
|
+
return v || "";
|
|
243
|
+
};
|
|
244
|
+
} else if (props.textColor && isTokenCSS(props.textColor)) {
|
|
245
|
+
style.color = `var(--jss-${props.textColor})`;
|
|
246
|
+
} else if (props.textColor) {
|
|
247
|
+
style.color = props.textColor;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (uiIsReactive(props.size)) {
|
|
251
|
+
classTokens.push(() => {
|
|
252
|
+
const v = uiUnwrap(props.size);
|
|
253
|
+
if (typeof v === "string" && JSswift.uiSizes?.includes(v)) return `jss-size-${v}`;
|
|
254
|
+
return "";
|
|
255
|
+
});
|
|
256
|
+
} else {
|
|
257
|
+
const size = props.size;
|
|
258
|
+
if (typeof size === "string" && JSswift.uiSizes?.includes(size)) {
|
|
259
|
+
classTokens.push(`jss-size-${size}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (uiIsReactive(props.shadow)) {
|
|
264
|
+
classTokens.push(() => {
|
|
265
|
+
const v = uiUnwrap(props.shadow);
|
|
266
|
+
const shadow = normalizeShadow(v);
|
|
267
|
+
return shadow ? `jss-shadow-${shadow}` : "";
|
|
268
|
+
});
|
|
269
|
+
style.boxShadow = () => {
|
|
270
|
+
const v = uiUnwrap(props.shadow);
|
|
271
|
+
const shadow = normalizeShadow(v);
|
|
272
|
+
if (shadow || v == null || v === false) return "";
|
|
273
|
+
return typeof v === "string" ? v : "";
|
|
274
|
+
};
|
|
275
|
+
} else {
|
|
276
|
+
const shadow = normalizeShadow(props.shadow);
|
|
277
|
+
if (shadow) classTokens.push(`jss-shadow-${shadow}`);
|
|
278
|
+
else if (props.shadow && typeof props.shadow === "string") {
|
|
279
|
+
style.boxShadow = props.shadow;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (classTokens.length) {
|
|
284
|
+
props.class = uiClass([props.class, ...classTokens]);
|
|
285
|
+
}
|
|
286
|
+
if (Object.keys(style).length) {
|
|
287
|
+
props.style = { ...style, ...(props.style || {}) };
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const normalizeArgsBase = JSswift.uiNormalizeArgs;
|
|
292
|
+
JSswift.uiNormalizeArgs = function (args) {
|
|
293
|
+
const out = normalizeArgsBase(args);
|
|
294
|
+
const props = out.props || {};
|
|
295
|
+
if (props && Object.prototype.hasOwnProperty.call(props, "children")) {
|
|
296
|
+
const propChildren = props.children;
|
|
297
|
+
if (!out.children || out.children.length === 0) {
|
|
298
|
+
out.children = Array.isArray(propChildren) ? propChildren : [propChildren];
|
|
299
|
+
}
|
|
300
|
+
delete props.children;
|
|
301
|
+
}
|
|
302
|
+
applyCommonProps(props);
|
|
303
|
+
return out;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// --------------------------------
|
|
307
|
+
// 2) UI PRIMITIVES (layout + atoms)
|
|
308
|
+
// --------------------------------
|
|
309
|
+
const UI = window._;
|
|
310
|
+
|
|
311
|
+
/*
|
|
312
|
+
UI.Row
|
|
313
|
+
UI.Col
|
|
314
|
+
UI.Spacer
|
|
315
|
+
UI.Container
|
|
316
|
+
UI.Card
|
|
317
|
+
UI.Btn
|
|
318
|
+
UI.Input
|
|
319
|
+
UI.Select
|
|
320
|
+
UI.Layout
|
|
321
|
+
UI.Footer
|
|
322
|
+
UI.Toolbar
|
|
323
|
+
UI.Grid
|
|
324
|
+
UI.GridCol
|
|
325
|
+
UI.Icon
|
|
326
|
+
UI.Badge
|
|
327
|
+
UI.Avatar
|
|
328
|
+
UI.Chip
|
|
329
|
+
UI.Tooltip
|
|
330
|
+
UI.List
|
|
331
|
+
UI.Item
|
|
332
|
+
UI.Separator
|
|
333
|
+
UI.Checkbox
|
|
334
|
+
UI.Radio
|
|
335
|
+
UI.Toggle
|
|
336
|
+
UI.Slider
|
|
337
|
+
UI.Rating
|
|
335
338
|
UI.Datepicker
|
|
336
339
|
UI.Calendar
|
|
337
340
|
UI.Date
|
|
338
|
-
UI.Time
|
|
339
|
-
UI.Tabs
|
|
340
|
-
UI.RouteTab
|
|
341
|
-
UI.Breadcrumbs
|
|
342
|
-
UI.Pagination
|
|
343
|
-
UI.Spinner
|
|
344
|
-
UI.Progress
|
|
345
|
-
UI.LoadingBar
|
|
346
|
-
UI.Banner
|
|
347
|
-
UI.Header
|
|
348
|
-
UI.Drawer
|
|
349
|
-
UI.Page
|
|
350
|
-
UI.AppShell
|
|
351
|
-
UI.Parallax
|
|
352
|
-
*/
|
|
353
|
-
|
|
354
|
-
function flattenSlotValue(value) {
|
|
355
|
-
if (!value) return null;
|
|
356
|
-
if (!Array.isArray(value)) return value;
|
|
357
|
-
const out = [];
|
|
358
|
-
const stack = value.slice();
|
|
359
|
-
while (stack.length) {
|
|
360
|
-
const item = stack.shift();
|
|
361
|
-
if (!item) continue;
|
|
362
|
-
if (Array.isArray(item)) stack.unshift(...item);
|
|
363
|
-
else out.push(item);
|
|
364
|
-
}
|
|
365
|
-
return out.length ? out : null;
|
|
366
|
-
}
|
|
341
|
+
UI.Time
|
|
342
|
+
UI.Tabs
|
|
343
|
+
UI.RouteTab
|
|
344
|
+
UI.Breadcrumbs
|
|
345
|
+
UI.Pagination
|
|
346
|
+
UI.Spinner
|
|
347
|
+
UI.Progress
|
|
348
|
+
UI.LoadingBar
|
|
349
|
+
UI.Banner
|
|
350
|
+
UI.Header
|
|
351
|
+
UI.Drawer
|
|
352
|
+
UI.Page
|
|
353
|
+
UI.AppShell
|
|
354
|
+
UI.Parallax
|
|
355
|
+
*/
|
|
356
|
+
|
|
357
|
+
function flattenSlotValue(value) {
|
|
358
|
+
if (!value) return null;
|
|
359
|
+
if (!Array.isArray(value)) return value;
|
|
360
|
+
const out = [];
|
|
361
|
+
const stack = value.slice();
|
|
362
|
+
while (stack.length) {
|
|
363
|
+
const item = stack.shift();
|
|
364
|
+
if (!item) continue;
|
|
365
|
+
if (Array.isArray(item)) stack.unshift(...item);
|
|
366
|
+
else out.push(item);
|
|
367
|
+
}
|
|
368
|
+
return out.length ? out : null;
|
|
369
|
+
}
|
|
367
370
|
const STYLE_PROP_TOKEN_MAP = {
|
|
368
|
-
padding: "p",
|
|
369
|
-
paddingTop: "p",
|
|
370
|
-
paddingRight: "p",
|
|
371
|
-
paddingBottom: "p",
|
|
372
|
-
paddingLeft: "p",
|
|
373
|
-
paddingInline: "p",
|
|
374
|
-
paddingInlineStart: "p",
|
|
375
|
-
paddingInlineEnd: "p",
|
|
376
|
-
paddingBlock: "p",
|
|
377
|
-
paddingBlockStart: "p",
|
|
378
|
-
paddingBlockEnd: "p",
|
|
379
|
-
margin: "m",
|
|
380
|
-
marginTop: "m",
|
|
381
|
-
marginRight: "m",
|
|
382
|
-
marginBottom: "m",
|
|
383
|
-
marginLeft: "m",
|
|
384
|
-
marginInline: "m",
|
|
385
|
-
marginInlineStart: "m",
|
|
386
|
-
marginInlineEnd: "m",
|
|
387
|
-
marginBlock: "m",
|
|
388
|
-
marginBlockStart: "m",
|
|
389
|
-
marginBlockEnd: "m",
|
|
390
|
-
width: "w",
|
|
391
|
-
minWidth: "w",
|
|
392
|
-
maxWidth: "w",
|
|
393
|
-
height: "h",
|
|
371
|
+
padding: "p",
|
|
372
|
+
paddingTop: "p",
|
|
373
|
+
paddingRight: "p",
|
|
374
|
+
paddingBottom: "p",
|
|
375
|
+
paddingLeft: "p",
|
|
376
|
+
paddingInline: "p",
|
|
377
|
+
paddingInlineStart: "p",
|
|
378
|
+
paddingInlineEnd: "p",
|
|
379
|
+
paddingBlock: "p",
|
|
380
|
+
paddingBlockStart: "p",
|
|
381
|
+
paddingBlockEnd: "p",
|
|
382
|
+
margin: "m",
|
|
383
|
+
marginTop: "m",
|
|
384
|
+
marginRight: "m",
|
|
385
|
+
marginBottom: "m",
|
|
386
|
+
marginLeft: "m",
|
|
387
|
+
marginInline: "m",
|
|
388
|
+
marginInlineStart: "m",
|
|
389
|
+
marginInlineEnd: "m",
|
|
390
|
+
marginBlock: "m",
|
|
391
|
+
marginBlockStart: "m",
|
|
392
|
+
marginBlockEnd: "m",
|
|
393
|
+
width: "w",
|
|
394
|
+
minWidth: "w",
|
|
395
|
+
maxWidth: "w",
|
|
396
|
+
height: "h",
|
|
394
397
|
minHeight: "h",
|
|
395
398
|
maxHeight: "h"
|
|
396
399
|
};
|
|
@@ -465,78 +468,78 @@ JSswift.uiResponsiveStyleRules = UI_RESPONSIVE_STYLE_RULES;
|
|
|
465
468
|
JSswift.uiResponsiveCommonStyleRules = UI_RESPONSIVE_COMMON_STYLE_RULES;
|
|
466
469
|
const camelToCssProperty = (name) => name.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
467
470
|
const applyStyleProp = (obj, value, name, tokenName) => {
|
|
468
|
-
if (value == null || value === false || value === "") return;
|
|
469
|
-
obj.style.setProperty(camelToCssProperty(name), unitCover(value, tokenName));
|
|
470
|
-
};
|
|
471
|
-
function setPropertyProps(obj, props) {
|
|
472
|
-
if (props.size) {
|
|
473
|
-
if (typeof props.size === "number") {
|
|
474
|
-
obj.style.setProperty("--
|
|
475
|
-
} else if (JSswift.uiSizes.includes(props.size)) {
|
|
476
|
-
obj.style.setProperty("--
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
471
|
+
if (value == null || value === false || value === "") return;
|
|
472
|
+
obj.style.setProperty(camelToCssProperty(name), unitCover(value, tokenName));
|
|
473
|
+
};
|
|
474
|
+
function setPropertyProps(obj, props) {
|
|
475
|
+
if (props.size) {
|
|
476
|
+
if (typeof props.size === "number") {
|
|
477
|
+
obj.style.setProperty("--jss-font-size", `${props.size}px`);
|
|
478
|
+
} else if (JSswift.uiSizes.includes(props.size)) {
|
|
479
|
+
obj.style.setProperty("--jss-font-size", `var(--jss-font-size-${props.size})`);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
480
483
|
Object.entries(STYLE_PROP_TOKEN_MAP).forEach(([name, tokenName]) => {
|
|
481
484
|
if (uiResponsiveHasProp(props, name)) return;
|
|
482
485
|
applyStyleProp(obj, props[name], name, tokenName);
|
|
483
486
|
});
|
|
484
487
|
uiApplyResponsiveProps(obj, props, UI_RESPONSIVE_COMMON_STYLE_RULES);
|
|
485
|
-
|
|
486
|
-
// gradient
|
|
487
|
-
if (props.gradient) {
|
|
488
|
-
if (typeof props.gradient == "number") {
|
|
489
|
-
obj.style.setProperty("--set-gradient-deg", `${props.gradient}deg`);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
// radius
|
|
493
|
-
if (props.radius) {
|
|
494
|
-
if (typeof props.radius == "number") {
|
|
495
|
-
obj.style.setProperty("--set-border-radius", `${props.radius}px`);
|
|
496
|
-
} else if (JSswift.uiSizes.includes(props.radius)) {
|
|
497
|
-
obj.style.setProperty("--set-border-radius", `var(--
|
|
498
|
-
} else {
|
|
499
|
-
obj.style.setProperty("--set-border-radius", `${props.radius}`);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
function uiOptionNode(props = {}, ...children) {
|
|
506
|
-
const el = document.createElement("option");
|
|
507
|
-
if (props && typeof props === "object") {
|
|
508
|
-
if (props.value != null) el.value = String(props.value);
|
|
509
|
-
if (props.label != null) el.label = String(props.label);
|
|
510
|
-
if (props.disabled != null) el.disabled = !!props.disabled;
|
|
511
|
-
if (props.selected != null) el.selected = !!props.selected;
|
|
512
|
-
if (props.class != null) el.className = String(props.class);
|
|
513
|
-
}
|
|
514
|
-
const content = children.flat ? children.flat(Infinity) : children;
|
|
515
|
-
if (content.length) {
|
|
516
|
-
content.forEach((child) => {
|
|
517
|
-
if (child == null || child === false) return;
|
|
518
|
-
if (child instanceof Node) el.appendChild(child);
|
|
519
|
-
else el.appendChild(document.createTextNode(String(child)));
|
|
520
|
-
});
|
|
521
|
-
} else if (props && props.text != null) {
|
|
522
|
-
el.textContent = String(props.text);
|
|
523
|
-
}
|
|
524
|
-
return el;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
JSswift.ui.getSlot = (slots, name) => {
|
|
528
|
-
if (!slots) return null;
|
|
529
|
-
return Object.prototype.hasOwnProperty.call(slots, name) ? slots[name] : null;
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
JSswift.ui.renderSlot = (slots, name, ctx, fallback) => {
|
|
533
|
-
const slot = JSswift.ui.getSlot(slots, name);
|
|
534
|
-
const hasSlot = slot !== null && slot !== undefined;
|
|
535
|
-
const raw = hasSlot ? (typeof slot === "function" ? slot(ctx || {}) : slot) : fallback;
|
|
536
|
-
if (raw == null) return null;
|
|
537
|
-
return flattenSlotValue(JSswift.ui.slot(raw));
|
|
538
|
-
};
|
|
539
|
-
|
|
488
|
+
|
|
489
|
+
// gradient
|
|
490
|
+
if (props.gradient) {
|
|
491
|
+
if (typeof props.gradient == "number") {
|
|
492
|
+
obj.style.setProperty("--set-gradient-deg", `${props.gradient}deg`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
// radius
|
|
496
|
+
if (props.radius) {
|
|
497
|
+
if (typeof props.radius == "number") {
|
|
498
|
+
obj.style.setProperty("--set-border-radius", `${props.radius}px`);
|
|
499
|
+
} else if (JSswift.uiSizes.includes(props.radius)) {
|
|
500
|
+
obj.style.setProperty("--set-border-radius", `var(--jss-r-${props.radius})`);
|
|
501
|
+
} else {
|
|
502
|
+
obj.style.setProperty("--set-border-radius", `${props.radius}`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function uiOptionNode(props = {}, ...children) {
|
|
509
|
+
const el = document.createElement("option");
|
|
510
|
+
if (props && typeof props === "object") {
|
|
511
|
+
if (props.value != null) el.value = String(props.value);
|
|
512
|
+
if (props.label != null) el.label = String(props.label);
|
|
513
|
+
if (props.disabled != null) el.disabled = !!props.disabled;
|
|
514
|
+
if (props.selected != null) el.selected = !!props.selected;
|
|
515
|
+
if (props.class != null) el.className = String(props.class);
|
|
516
|
+
}
|
|
517
|
+
const content = children.flat ? children.flat(Infinity) : children;
|
|
518
|
+
if (content.length) {
|
|
519
|
+
content.forEach((child) => {
|
|
520
|
+
if (child == null || child === false) return;
|
|
521
|
+
if (child instanceof Node) el.appendChild(child);
|
|
522
|
+
else el.appendChild(document.createTextNode(String(child)));
|
|
523
|
+
});
|
|
524
|
+
} else if (props && props.text != null) {
|
|
525
|
+
el.textContent = String(props.text);
|
|
526
|
+
}
|
|
527
|
+
return el;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
JSswift.ui.getSlot = (slots, name) => {
|
|
531
|
+
if (!slots) return null;
|
|
532
|
+
return Object.prototype.hasOwnProperty.call(slots, name) ? slots[name] : null;
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
JSswift.ui.renderSlot = (slots, name, ctx, fallback) => {
|
|
536
|
+
const slot = JSswift.ui.getSlot(slots, name);
|
|
537
|
+
const hasSlot = slot !== null && slot !== undefined;
|
|
538
|
+
const raw = hasSlot ? (typeof slot === "function" ? slot(ctx || {}) : slot) : fallback;
|
|
539
|
+
if (raw == null) return null;
|
|
540
|
+
return flattenSlotValue(JSswift.ui.slot(raw));
|
|
541
|
+
};
|
|
542
|
+
|
|
540
543
|
const renderSlotToArray = (slots, name, ctx, fallback) => {
|
|
541
544
|
const v = JSswift.ui.renderSlot(slots, name, ctx, fallback);
|
|
542
545
|
if (!v) return [];
|
|
@@ -688,7 +691,7 @@ const uiCreateShortcodeHint = (props = {}, options = {}) => {
|
|
|
688
691
|
const specs = uiResolveShortcodeList(props);
|
|
689
692
|
if (!uiIsShortcodeVisible(props) || !specs.length || typeof document === "undefined") return null;
|
|
690
693
|
const node = document.createElement("span");
|
|
691
|
-
node.className = options.className || "
|
|
694
|
+
node.className = options.className || "jss-shortcode";
|
|
692
695
|
node.setAttribute("aria-hidden", "true");
|
|
693
696
|
node.textContent = uiFormatShortcodeList(specs);
|
|
694
697
|
return node;
|
|
@@ -799,8 +802,8 @@ const uiFocusShortcutTarget = (target, options = {}) => {
|
|
|
799
802
|
|
|
800
803
|
const unitCover = (v, name = 'size') => {
|
|
801
804
|
if (typeof v === "number") return v + "px";
|
|
802
|
-
if (JSswift.uiSizes.includes(v)) return `var(--
|
|
805
|
+
if (JSswift.uiSizes.includes(v)) return `var(--jss-${name}-${v})`;
|
|
803
806
|
if (typeof v === "string") return v;
|
|
804
|
-
return v;
|
|
805
|
-
};
|
|
806
|
-
|
|
807
|
+
return v;
|
|
808
|
+
};
|
|
809
|
+
|