@perkyzz/emvb 1.0.0 → 1.2.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/README.md +9 -0
- package/THIRD_PARTY_NOTICES.md +1 -0
- package/package.json +10 -9
- package/src/admin/agents-api.ts +5 -1
- package/src/admin/bulk-api.ts +67 -0
- package/src/admin/content-api.ts +39 -6
- package/src/admin/copy-rich-text.ts +119 -0
- package/src/admin/dialog-tab-wrap.ts +78 -0
- package/src/admin/editor/A11yCopilot.tsx +2 -0
- package/src/admin/editor/Editor.tsx +24 -7
- package/src/admin/editor/ScheduleDialog.tsx +167 -0
- package/src/admin/editor/Timeline.tsx +6 -2
- package/src/admin/editor/TopBar.tsx +60 -8
- package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
- package/src/admin/editor/canvas/DeviceBar.tsx +22 -9
- package/src/admin/editor/canvas/canvas-scale.ts +3 -3
- package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
- package/src/admin/editor/dnd/new-element.ts +68 -0
- package/src/admin/editor/editor-chrome.tsx +16 -5
- package/src/admin/editor/editor-commands.ts +10 -4
- package/src/admin/editor/editor-css.ts +2 -1
- package/src/admin/editor/element-chrome.ts +22 -0
- package/src/admin/editor/panels/ElementPanel.tsx +34 -17
- package/src/admin/editor/panels/SettingsPanel.tsx +2 -2
- package/src/admin/editor/panels/settings/DraftTextField.tsx +33 -1
- package/src/admin/editor/panels/settings/EffectsControls.tsx +79 -1
- package/src/admin/editor/panels/settings/FieldBindControl.tsx +6 -1
- package/src/admin/editor/panels/settings/FieldControl.tsx +10 -1
- package/src/admin/editor/panels/settings/IconControls.tsx +11 -0
- package/src/admin/editor/panels/settings/IconPicker.tsx +4 -1
- package/src/admin/editor/panels/settings/ItemList.tsx +36 -2
- package/src/admin/editor/panels/settings/LengthRow.tsx +36 -3
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +18 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +7 -0
- package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
- package/src/admin/editor/panels/settings/length-units.ts +15 -3
- package/src/admin/editor/panels/settings/style-sections.ts +1 -0
- package/src/admin/editor/panels/style-target.ts +17 -4
- package/src/admin/editor/section-templates.ts +26 -4
- package/src/admin/editor/store.ts +15 -3
- package/src/admin/editor/useEditorCommands.ts +7 -5
- package/src/admin/editor/useEditorData.ts +4 -0
- package/src/admin/editor/useNodeActions.ts +4 -2
- package/src/admin/editor/useSave.ts +47 -3
- package/src/admin/export-api.ts +238 -0
- package/src/admin/index.tsx +6 -1
- package/src/admin/menus-api.ts +113 -0
- package/src/admin/pages/ExportDialog.tsx +395 -0
- package/src/admin/pages/ImportElementorDialog.tsx +25 -1
- package/src/admin/pages/PageList.tsx +67 -2
- package/src/admin/pages/ThemePartList.tsx +37 -1
- package/src/admin/pages/bulk.tsx +303 -0
- package/src/admin/search.ts +20 -0
- package/src/admin/theme-api.ts +4 -0
- package/src/admin/ui.ts +11 -2
- package/src/admin/widgets/CanvasField.tsx +8 -0
- package/src/admin/widgets/ConvertToRichText.tsx +136 -0
- package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
- package/src/admin/widgets/convert-body.ts +73 -2
- package/src/astro/EmVBPage.astro +3 -0
- package/src/astro/render.ts +47 -22
- package/src/astro/request-data.ts +3 -0
- package/src/astro/resolve-theme.ts +88 -51
- package/src/astro/tabs/runtime.ts +16 -6
- package/src/astro/visitor.ts +23 -4
- package/src/astro/widgets/EmVBAlertsRuntime.astro +8 -0
- package/src/astro/widgets/EmVBCarouselRuntime.astro +8 -0
- package/src/astro/widgets/EmVBLightboxRuntime.astro +8 -0
- package/src/astro/widgets/EmVBWidgetRuntimes.astro +19 -0
- package/src/astro/widgets/alerts.ts +37 -0
- package/src/astro/widgets/carousel.ts +167 -0
- package/src/astro/widgets/index.ts +1 -0
- package/src/astro/widgets/lightbox.ts +123 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +103 -3
- package/src/core/arrange.ts +57 -1
- package/src/core/bounded-array.ts +16 -13
- package/src/core/contract.ts +26 -3
- package/src/core/css/generate.ts +83 -21
- package/src/core/css/scope.ts +10 -2
- package/src/core/css/trace.ts +33 -8
- package/src/core/design/classes.ts +25 -5
- package/src/core/design/devices.ts +78 -2
- package/src/core/design/variables.ts +14 -1
- package/src/core/elements/icon-svg.ts +135 -0
- package/src/core/elements/index.ts +33 -127
- package/src/core/elements/widgets.ts +907 -0
- package/src/core/export/runtimes.generated.ts +12 -0
- package/src/core/export/site.ts +579 -0
- package/src/core/export/zip.ts +95 -0
- package/src/core/extensions/schema.ts +2 -1
- package/src/core/geo-trust.ts +18 -0
- package/src/core/history/diff.ts +25 -0
- package/src/core/icons/social.generated.ts +29 -0
- package/src/core/image-edit/schema.ts +2 -1
- package/src/core/import/elementor/atomic.ts +22 -9
- package/src/core/import/elementor/context.ts +18 -0
- package/src/core/import/elementor/index.ts +72 -11
- package/src/core/import/elementor/style.ts +21 -1
- package/src/core/import/elementor/widgets.ts +394 -133
- package/src/core/index.ts +14 -0
- package/src/core/issue-cap.ts +19 -0
- package/src/core/json-schema.ts +8 -1
- package/src/core/limits.ts +6 -0
- package/src/core/loop-collections.ts +33 -0
- package/src/core/perf/meter.ts +37 -19
- package/src/core/portable-text-export.ts +243 -0
- package/src/core/proposals.ts +8 -2
- package/src/core/public-attributes.ts +30 -0
- package/src/core/render/index.ts +115 -13
- package/src/core/render/tabs.ts +18 -11
- package/src/core/render/vnode.ts +44 -6
- package/src/core/sanitize/css.ts +26 -0
- package/src/core/sanitize/svg-upload.ts +276 -23
- package/src/core/sanitize/svg.ts +3 -3
- package/src/core/schema/descriptors.ts +4 -0
- package/src/core/schema/design.ts +8 -7
- package/src/core/schema/layout.ts +406 -18
- package/src/core/schema/style.ts +49 -1
- package/src/core/search-text.ts +70 -0
- package/src/core/shadowing-ids.ts +41 -0
- package/src/core/theme/conditions.ts +2 -1
- package/src/core/theme/float.ts +1 -0
- package/src/core/theme/parse-doc.ts +10 -5
- package/src/core/theme/popup-rules.ts +16 -0
- package/src/core/theme/triggers.ts +3 -2
- package/src/core/validate.ts +3 -2
- package/src/index.ts +23 -2
- package/src/mcp/ports.ts +18 -7
- package/src/mcp/proposals.ts +36 -11
- package/src/mcp/read.ts +2 -3
- package/src/mcp/tools.ts +1 -1
- package/src/server/agent-settings.ts +12 -1
- package/src/server/hooks.ts +41 -6
- package/src/server/icon-routes.ts +52 -12
- package/src/server/mcp-routes.ts +11 -5
- package/src/server/plugin.ts +27 -2
- package/src/server/presence.ts +5 -1
- package/src/server/proposals.ts +16 -4
- package/src/server/requests.ts +60 -11
- package/src/server/site-origin.ts +13 -0
- package/src/server/targets.ts +26 -0
package/src/core/css/generate.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
type StateDeclarations,
|
|
20
20
|
} from "../sanitize/css.ts";
|
|
21
21
|
import { STYLE_STATES, type StyleStateName } from "../schema/state-names.ts";
|
|
22
|
-
import { DEVICE_MEDIA, type Device } from "../theme/popup-rules.ts";
|
|
22
|
+
import { DEVICE_MEDIA, type Device, type EditorDevice } from "../theme/popup-rules.ts";
|
|
23
23
|
import { LOOP_KEYFRAMES, MOTION_KEYFRAMES } from "../sanitize/motion.ts";
|
|
24
24
|
|
|
25
25
|
export type CssInput = {
|
|
@@ -30,6 +30,9 @@ export type CssInput = {
|
|
|
30
30
|
id: string;
|
|
31
31
|
declarations: Declaration[];
|
|
32
32
|
states?: StateDeclarations;
|
|
33
|
+
/** W-959: Wide screen overrides (2400 px and up), and its hide override. */
|
|
34
|
+
wide?: Declaration[];
|
|
35
|
+
wideHidden?: boolean;
|
|
33
36
|
/** Laptop (W-956), tablet and mobile overrides (W-096). Desktop stays in `declarations`. */
|
|
34
37
|
laptop?: Declaration[];
|
|
35
38
|
tablet?: Declaration[];
|
|
@@ -52,9 +55,27 @@ export type CssInput = {
|
|
|
52
55
|
* device instead of the frame's width, so the Desktop canvas never picks up tablet styles in a
|
|
53
56
|
* narrow window. Without it, the rules sit in their media queries as usual.
|
|
54
57
|
*/
|
|
55
|
-
previewDevice?:
|
|
58
|
+
previewDevice?: EditorDevice;
|
|
56
59
|
};
|
|
57
60
|
|
|
61
|
+
/**
|
|
62
|
+
* W-959: a class's Wide screen overrides and hide. `renderableDesign` moved the class's
|
|
63
|
+
* `style.wide` to `devices.wide` and `wideHidden`; the values build on Desktop's.
|
|
64
|
+
*/
|
|
65
|
+
function classWide(cls: unknown): { wide: Declaration[]; wideHidden?: boolean } {
|
|
66
|
+
const { style, devices, wideHidden } = cls as {
|
|
67
|
+
style?: unknown;
|
|
68
|
+
devices?: { wide?: unknown };
|
|
69
|
+
wideHidden?: unknown;
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
wide: devices?.wide
|
|
73
|
+
? styleDeclarations(withInheritedLayers(devices.wide, style ?? {})).declarations
|
|
74
|
+
: [],
|
|
75
|
+
...(typeof wideHidden === "boolean" ? { wideHidden } : {}),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
58
79
|
/** Focus is keyboard focus (W-089): `:focus-visible`, never `:focus`. */
|
|
59
80
|
const STATE_PSEUDO: Readonly<Record<StyleStateName, string>> = {
|
|
60
81
|
hover: ":hover",
|
|
@@ -139,6 +160,22 @@ const usesLoop = (declarations: readonly Declaration[]) =>
|
|
|
139
160
|
* local states beat class states, and Active beats Hover when both apply. Transitions sit on the
|
|
140
161
|
* base rule, and one closing `prefers-reduced-motion: reduce` block turns them all off.
|
|
141
162
|
*/
|
|
163
|
+
/**
|
|
164
|
+
* The element base rules for these types, in the order every sheet writes them (W-971 reads
|
|
165
|
+
* the same order to write them once for all theme parts on a page).
|
|
166
|
+
*/
|
|
167
|
+
export function baseRulesFor(
|
|
168
|
+
types: Iterable<string>,
|
|
169
|
+
baseCss: ReadonlyMap<string, string>,
|
|
170
|
+
): string {
|
|
171
|
+
return [...types]
|
|
172
|
+
.toSorted((a, b) =>
|
|
173
|
+
cssTypeName(a) < cssTypeName(b) ? -1 : cssTypeName(a) > cssTypeName(b) ? 1 : 0,
|
|
174
|
+
)
|
|
175
|
+
.map((type) => baseCss.get(type) ?? "")
|
|
176
|
+
.join("");
|
|
177
|
+
}
|
|
178
|
+
|
|
142
179
|
export function generateCss({
|
|
143
180
|
design,
|
|
144
181
|
usedTypes,
|
|
@@ -200,6 +237,7 @@ export function generateCss({
|
|
|
200
237
|
? [
|
|
201
238
|
{
|
|
202
239
|
selector: `.${className}`,
|
|
240
|
+
...classWide(cls),
|
|
203
241
|
// W-210: a device that sets one background layer keeps the layers it inherits.
|
|
204
242
|
laptop: styleDeclarations(withInheritedLayers(cls.devices?.laptop, cls.style ?? {}))
|
|
205
243
|
.declarations,
|
|
@@ -222,6 +260,8 @@ export function generateCss({
|
|
|
222
260
|
}),
|
|
223
261
|
...localRules.map((rule) => ({
|
|
224
262
|
selector: `.emvb-e-${rule.id}`,
|
|
263
|
+
wide: rule.wide ?? [],
|
|
264
|
+
wideHidden: rule.wideHidden,
|
|
225
265
|
laptop: rule.laptop ?? [],
|
|
226
266
|
tablet: rule.tablet ?? [],
|
|
227
267
|
mobile: rule.mobile ?? [],
|
|
@@ -230,18 +270,20 @@ export function generateCss({
|
|
|
230
270
|
})),
|
|
231
271
|
];
|
|
232
272
|
/** A device block: in its media query, or, for a previewed device, on or off outright. */
|
|
233
|
-
const forDevices = (devices: readonly
|
|
273
|
+
const forDevices = (devices: readonly EditorDevice[], query: string, body: string) => {
|
|
234
274
|
if (!body) return "";
|
|
235
275
|
if (previewDevice === undefined) return `@media ${query}{${body}}`;
|
|
236
276
|
return devices.includes(previewDevice) ? body : "";
|
|
237
277
|
};
|
|
238
|
-
const at = (query: string, which: "laptop" | "tablet" | "mobile") =>
|
|
278
|
+
const at = (query: string, which: "wide" | "laptop" | "tablet" | "mobile") =>
|
|
239
279
|
forDevices(
|
|
240
|
-
which === "
|
|
241
|
-
? ["
|
|
242
|
-
: which === "
|
|
243
|
-
? ["tablet", "mobile"]
|
|
244
|
-
:
|
|
280
|
+
which === "wide"
|
|
281
|
+
? ["wide"]
|
|
282
|
+
: which === "laptop"
|
|
283
|
+
? ["laptop", "tablet", "mobile"]
|
|
284
|
+
: which === "tablet"
|
|
285
|
+
? ["tablet", "mobile"]
|
|
286
|
+
: ["mobile"],
|
|
245
287
|
query,
|
|
246
288
|
responsive.map((rule) => block(rule.selector, rule[which])).join(""),
|
|
247
289
|
);
|
|
@@ -249,15 +291,35 @@ export function generateCss({
|
|
|
249
291
|
* W-956: Desktop and Laptop hidden together keep the one `min-width: 1025px` rule every page
|
|
250
292
|
* saved before Laptop had; hidden on only one of them, each gets its own range.
|
|
251
293
|
*/
|
|
252
|
-
|
|
253
|
-
|
|
294
|
+
/**
|
|
295
|
+
* W-959: Wide screen follows Desktop's hide unless `wide.hidden` says otherwise. An element
|
|
296
|
+
* that Wide screen shows again gets a Desktop range that stops at 2399.98 px (`notWide`); one
|
|
297
|
+
* hidden on Wide screen only gets the Wide screen rule. Rules without `wide.hidden` keep the
|
|
298
|
+
* CSS they had.
|
|
299
|
+
*/
|
|
300
|
+
type HideRule = { hiddenOn?: readonly Device[] | undefined; wideHidden?: boolean | undefined };
|
|
301
|
+
const hide = (
|
|
302
|
+
devices: readonly Device[],
|
|
303
|
+
query: string,
|
|
304
|
+
wide: "follows" | "notWide" | "only" = "follows",
|
|
305
|
+
) => {
|
|
306
|
+
const hidden = (rule: HideRule) => {
|
|
254
307
|
const on = rule.hiddenOn ?? [];
|
|
308
|
+
if (wide === "only") return rule.wideHidden === true && !on.includes("desktop");
|
|
309
|
+
if (devices.includes("desktop") && (rule.wideHidden === false) !== (wide === "notWide"))
|
|
310
|
+
return false;
|
|
255
311
|
if (devices.includes("desktop") && devices.includes("laptop"))
|
|
256
312
|
return on.includes("desktop") && on.includes("laptop");
|
|
257
313
|
if (devices[0] === "desktop") return on.includes("desktop") && !on.includes("laptop");
|
|
258
314
|
if (devices[0] === "laptop") return on.includes("laptop") && !on.includes("desktop");
|
|
259
315
|
return on.includes(devices[0] as Device);
|
|
260
316
|
};
|
|
317
|
+
const previewed: EditorDevice[] =
|
|
318
|
+
wide === "only"
|
|
319
|
+
? ["wide"]
|
|
320
|
+
: wide === "follows" && devices.includes("desktop")
|
|
321
|
+
? ["wide", ...devices]
|
|
322
|
+
: [...devices];
|
|
261
323
|
// W-443: a captioned image hides its figure too, or the caption stayed on its own.
|
|
262
324
|
const selectors = responsive
|
|
263
325
|
.filter(hidden)
|
|
@@ -267,18 +329,18 @@ export function generateCss({
|
|
|
267
329
|
: ["hideSelector" in rule && rule.hideSelector ? rule.hideSelector : rule.selector],
|
|
268
330
|
);
|
|
269
331
|
return forDevices(
|
|
270
|
-
|
|
332
|
+
previewed,
|
|
271
333
|
query,
|
|
272
334
|
selectors.length > 0 ? `${selectors.join(",")}{display:none}` : "",
|
|
273
335
|
);
|
|
274
336
|
};
|
|
275
337
|
for (const rule of responsive) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
if (
|
|
338
|
+
const devices = [rule.wide ?? [], rule.laptop, rule.tablet, rule.mobile];
|
|
339
|
+
if (devices.some(usesMotion)) motion = true;
|
|
340
|
+
if (devices.some(usesLoop)) loops = true;
|
|
279
341
|
if (
|
|
280
342
|
!entrances.includes(rule.selector) &&
|
|
281
|
-
|
|
343
|
+
devices.flat().some((d) => d.property === "animation")
|
|
282
344
|
) {
|
|
283
345
|
entrances.push(rule.selector);
|
|
284
346
|
}
|
|
@@ -313,11 +375,7 @@ export function generateCss({
|
|
|
313
375
|
// W-801: a looping video kept playing for visitors who ask for reduced motion.
|
|
314
376
|
"@media (prefers-reduced-motion: reduce){.emvb-bg-video{display:none}}"
|
|
315
377
|
: "",
|
|
316
|
-
|
|
317
|
-
.toSorted((a, b) =>
|
|
318
|
-
cssTypeName(a) < cssTypeName(b) ? -1 : cssTypeName(a) > cssTypeName(b) ? 1 : 0,
|
|
319
|
-
)
|
|
320
|
-
.map((type) => baseCss.get(type) ?? ""),
|
|
378
|
+
baseRulesFor(usedTypes, baseCss),
|
|
321
379
|
...classes,
|
|
322
380
|
...locals,
|
|
323
381
|
...localRules
|
|
@@ -326,11 +384,15 @@ export function generateCss({
|
|
|
326
384
|
(rule) =>
|
|
327
385
|
`@container (min-width:${rule.queryMin}px){${block(`.emvb-e-${rule.id}`, rule.query ?? [])}}`,
|
|
328
386
|
),
|
|
387
|
+
at(DEVICE_MEDIA.wide, "wide"),
|
|
329
388
|
at(DEVICE_MEDIA.laptop, "laptop"),
|
|
330
389
|
at(DEVICE_MEDIA.tablet, "tablet"),
|
|
331
390
|
at(DEVICE_MEDIA.mobile, "mobile"),
|
|
332
391
|
hide(["desktop", "laptop"], DEVICE_MEDIA.hideDesktop),
|
|
333
392
|
hide(["desktop"], DEVICE_MEDIA.hideDesktopOnly),
|
|
393
|
+
hide(["desktop", "laptop"], DEVICE_MEDIA.hideDesktopNotWide, "notWide"),
|
|
394
|
+
hide(["desktop"], DEVICE_MEDIA.hideDesktopOnlyNotWide, "notWide"),
|
|
395
|
+
hide([], DEVICE_MEDIA.wide, "only"),
|
|
334
396
|
hide(["laptop"], DEVICE_MEDIA.hideLaptop),
|
|
335
397
|
hide(["tablet"], DEVICE_MEDIA.hideTablet),
|
|
336
398
|
hide(["mobile"], DEVICE_MEDIA.hideMobile),
|
package/src/core/css/scope.ts
CHANGED
|
@@ -61,7 +61,15 @@ const GROUPING_AT_RULE = /^@(media|supports|container|layer)\b/;
|
|
|
61
61
|
|
|
62
62
|
/** Prefixes every style rule in `css`, inside `@media` and `@supports` too. Keyframes stay as they are. */
|
|
63
63
|
export function scopeCss(css: string, token: string): string {
|
|
64
|
-
|
|
64
|
+
return scopeWith(css, `:where(.${scopeClass(token)}) `);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** W-971: the same, scoped to several renders at once (`:where(.emvb-s-a,.emvb-s-b) `). */
|
|
68
|
+
export function scopeCssAll(css: string, tokens: readonly string[]): string {
|
|
69
|
+
return scopeWith(css, `:where(${tokens.map((t) => `.${scopeClass(t)}`).join(",")}) `);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function scopeWith(css: string, prefix: string): string {
|
|
65
73
|
let out = "";
|
|
66
74
|
let i = 0;
|
|
67
75
|
while (i < css.length) {
|
|
@@ -74,7 +82,7 @@ export function scopeCss(css: string, token: string): string {
|
|
|
74
82
|
const end = blockEnd(css, open);
|
|
75
83
|
const body = css.slice(open + 1, end - 1);
|
|
76
84
|
if (GROUPING_AT_RULE.test(prelude)) {
|
|
77
|
-
out += `${prelude}{${
|
|
85
|
+
out += `${prelude}{${scopeWith(body, prefix)}}`;
|
|
78
86
|
} else if (prelude.startsWith("@")) {
|
|
79
87
|
out += css.slice(i, end).trim();
|
|
80
88
|
} else {
|
package/src/core/css/trace.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { DefaultStyleTag, DesignSystem } from "../schema/design.ts";
|
|
|
2
2
|
import type { LayoutNode } from "../schema/layout.ts";
|
|
3
3
|
import type { StyleStateName } from "../schema/state-names.ts";
|
|
4
4
|
import { flattenMotion } from "../migrate/v18.ts";
|
|
5
|
-
import type { FlatStyleProps, StyleProps } from "../schema/style.ts";
|
|
5
|
+
import type { FlatStyleProps, OwnStyle, StyleProps } from "../schema/style.ts";
|
|
6
6
|
|
|
7
|
-
export type TraceDevice = "desktop" | "laptop" | "tablet" | "mobile";
|
|
7
|
+
export type TraceDevice = "wide" | "desktop" | "laptop" | "tablet" | "mobile";
|
|
8
8
|
|
|
9
9
|
/** Where one style value comes from (W-318). */
|
|
10
10
|
export type StyleSource = {
|
|
@@ -39,7 +39,24 @@ export function defaultTagFor(node: LayoutNode): DefaultStyleTag | undefined {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const LAYER = {
|
|
42
|
+
const LAYER = {
|
|
43
|
+
wide: "Wide screen",
|
|
44
|
+
desktop: "Desktop",
|
|
45
|
+
laptop: "Laptop",
|
|
46
|
+
tablet: "Tablet",
|
|
47
|
+
mobile: "Mobile",
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
50
|
+
/** W-959: an own style's Desktop values and its Wide screen ones (without `hidden`), apart. */
|
|
51
|
+
function splitWide(style: OwnStyle | undefined): { desktop?: StyleProps; wide?: StyleProps } {
|
|
52
|
+
if (!style) return {};
|
|
53
|
+
const { wide, ...desktop } = style;
|
|
54
|
+
const { hidden: _hidden, ...values } = wide ?? {};
|
|
55
|
+
return {
|
|
56
|
+
desktop,
|
|
57
|
+
...(Object.keys(values).length > 0 ? { wide: values } : {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
43
60
|
const STATE_LABEL: Record<StyleStateName, string> = {
|
|
44
61
|
hover: "Hover",
|
|
45
62
|
focus: "Focus",
|
|
@@ -50,7 +67,8 @@ type Owner = {
|
|
|
50
67
|
kind: "class" | "local";
|
|
51
68
|
label: string;
|
|
52
69
|
classId?: string;
|
|
53
|
-
|
|
70
|
+
desktop?: StyleProps;
|
|
71
|
+
wide?: StyleProps;
|
|
54
72
|
devices?: { laptop?: StyleProps; tablet?: StyleProps; mobile?: StyleProps };
|
|
55
73
|
states?: Partial<Record<StyleStateName, StyleProps>>;
|
|
56
74
|
};
|
|
@@ -84,7 +102,7 @@ export function styleLayers(
|
|
|
84
102
|
kind: "class",
|
|
85
103
|
label: `.${cls.name}`,
|
|
86
104
|
classId: cls.id,
|
|
87
|
-
|
|
105
|
+
...splitWide(cls.style),
|
|
88
106
|
};
|
|
89
107
|
if (cls.devices) owner.devices = cls.devices;
|
|
90
108
|
if (cls.states) owner.states = cls.states;
|
|
@@ -93,7 +111,7 @@ export function styleLayers(
|
|
|
93
111
|
owners.push({
|
|
94
112
|
kind: "local",
|
|
95
113
|
label: "This element",
|
|
96
|
-
...(node.style ?
|
|
114
|
+
...(node.style ? splitWide(node.style) : {}),
|
|
97
115
|
...(node.devices ? { devices: node.devices } : {}),
|
|
98
116
|
...(node.states ? { states: node.states as Owner["states"] } : {}),
|
|
99
117
|
});
|
|
@@ -103,8 +121,15 @@ export function styleLayers(
|
|
|
103
121
|
label: owner.label,
|
|
104
122
|
...(owner.classId ? { classId: owner.classId } : {}),
|
|
105
123
|
};
|
|
106
|
-
if (owner.
|
|
107
|
-
|
|
124
|
+
if (owner.desktop)
|
|
125
|
+
layers.push({ source: { ...base, layer: LAYER.desktop }, style: owner.desktop });
|
|
126
|
+
if (device === "wide" && owner.wide) {
|
|
127
|
+
layers.push({ source: { ...base, layer: LAYER.wide }, style: owner.wide });
|
|
128
|
+
}
|
|
129
|
+
if (
|
|
130
|
+
(device === "laptop" || device === "tablet" || device === "mobile") &&
|
|
131
|
+
owner.devices?.laptop
|
|
132
|
+
) {
|
|
108
133
|
layers.push({ source: { ...base, layer: LAYER.laptop }, style: owner.devices.laptop });
|
|
109
134
|
}
|
|
110
135
|
if ((device === "tablet" || device === "mobile") && owner.devices?.tablet) {
|
|
@@ -2,7 +2,7 @@ import { clipText } from "../limits.ts";
|
|
|
2
2
|
import type { DesignSystem } from "../schema/design.ts";
|
|
3
3
|
import type { Layout, LayoutNode } from "../schema/layout.ts";
|
|
4
4
|
import { patchNestedStyle } from "../migrate/v18.ts";
|
|
5
|
-
import type { StylePatch, StyleProps } from "../schema/style.ts";
|
|
5
|
+
import type { OwnStyle, StylePatch, StyleProps } from "../schema/style.ts";
|
|
6
6
|
import { localStyleOf, withLocalStyle } from "../local-style.ts";
|
|
7
7
|
import { forEachNode, slugify, updateNode } from "../tree-ops.ts";
|
|
8
8
|
|
|
@@ -82,10 +82,26 @@ const filled = (style: object | undefined) =>
|
|
|
82
82
|
!!style && Object.values(style).some((value) => value !== undefined);
|
|
83
83
|
|
|
84
84
|
/** Whether an element has local styles: base, hover/focus/active or tablet/mobile (W-134). */
|
|
85
|
+
/**
|
|
86
|
+
* W-983: an own style split into what moves to a class and the Wide screen hide
|
|
87
|
+
* (`style.wide.hidden`), which is visibility and stays on the element like `hiddenOn`.
|
|
88
|
+
*/
|
|
89
|
+
function splitWideHide(style: OwnStyle | undefined): {
|
|
90
|
+
style: OwnStyle | undefined;
|
|
91
|
+
hidden: boolean | undefined;
|
|
92
|
+
} {
|
|
93
|
+
const hidden = style?.wide?.hidden;
|
|
94
|
+
if (!style || hidden === undefined) return { style, hidden: undefined };
|
|
95
|
+
const { wide, ...rest } = style;
|
|
96
|
+
const { hidden: _hidden, ...values } = wide ?? {};
|
|
97
|
+
const next: OwnStyle = Object.keys(values).length > 0 ? { ...rest, wide: values } : rest;
|
|
98
|
+
return { style: Object.keys(next).length > 0 ? next : undefined, hidden };
|
|
99
|
+
}
|
|
100
|
+
|
|
85
101
|
export function hasLocalStyles(node: LayoutNode): boolean {
|
|
86
102
|
const local = localStyleOf(node);
|
|
87
103
|
return (
|
|
88
|
-
filled(local.style) ||
|
|
104
|
+
filled(splitWideHide(local.style).style) ||
|
|
89
105
|
Object.values(local.states ?? {}).some(filled) ||
|
|
90
106
|
Object.values(local.devices ?? {}).some(filled)
|
|
91
107
|
);
|
|
@@ -120,7 +136,7 @@ export function localToClassRefusal(design: DesignSystem, node: LayoutNode): str
|
|
|
120
136
|
/**
|
|
121
137
|
* Moves an element's local, state and tablet/mobile styles into a new class, applied last on the
|
|
122
138
|
* element and added last in Site styles, so it wins over the element's other classes as the local
|
|
123
|
-
* styles did (W-134). Visibility (`hiddenOn
|
|
139
|
+
* styles did (W-134). Visibility (`hiddenOn`, and W-983 the Wide screen hide) stays on the element. Null when it can't run. Pure.
|
|
124
140
|
*/
|
|
125
141
|
export function localStylesToClass(
|
|
126
142
|
design: DesignSystem,
|
|
@@ -135,14 +151,18 @@ export function localStylesToClass(
|
|
|
135
151
|
let id = base;
|
|
136
152
|
for (let n = 2; taken.has(id); n++) id = `${base}-${n}`;
|
|
137
153
|
const local = localStyleOf(node);
|
|
154
|
+
const { style: moved, hidden: wideHidden } = splitWideHide(local.style);
|
|
138
155
|
const cls = {
|
|
139
156
|
id,
|
|
140
157
|
name: trimmed,
|
|
141
|
-
style: (
|
|
158
|
+
style: (moved ?? {}) as StyleProps,
|
|
142
159
|
...(local.states ? { states: local.states } : {}),
|
|
143
160
|
...(local.devices ? { devices: local.devices } : {}),
|
|
144
161
|
};
|
|
145
|
-
const cleared = withLocalStyle(node,
|
|
162
|
+
const cleared = withLocalStyle(node, {
|
|
163
|
+
...(local.hiddenOn ? { hiddenOn: local.hiddenOn } : {}),
|
|
164
|
+
...(wideHidden !== undefined ? { style: { wide: { hidden: wideHidden } } } : {}),
|
|
165
|
+
});
|
|
146
166
|
return {
|
|
147
167
|
design: { ...design, classes: [...classes, cls] },
|
|
148
168
|
node: { ...cleared, classes: addClassId(node.classes ?? [], id) },
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DesignSystem } from "../schema/design.ts";
|
|
2
2
|
import { editClass } from "./classes.ts";
|
|
3
3
|
import { patchNestedStyle } from "../migrate/v18.ts";
|
|
4
|
-
import type { DeviceStyles, StylePatch, StyleProps } from "../schema/style.ts";
|
|
5
|
-
import { DEVICES, type Device, type StyleDevice } from "../theme/popup-rules.ts";
|
|
4
|
+
import type { DeviceStyles, OwnStyle, StylePatch, StyleProps, WideStyle } from "../schema/style.ts";
|
|
5
|
+
import { DEVICES, type Device, type EditorDevice, type StyleDevice } from "../theme/popup-rules.ts";
|
|
6
6
|
|
|
7
7
|
export type ResponsiveDevice = StyleDevice;
|
|
8
8
|
|
|
@@ -48,3 +48,79 @@ export function toggleHidden(
|
|
|
48
48
|
const next = DEVICES.filter((item) => set.has(item));
|
|
49
49
|
return next.length > 0 ? next : undefined;
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* W-959: merge `patch` into an own style's Wide screen record (`style.wide`), keeping its
|
|
54
|
+
* `hidden`. An emptied record is dropped. Pure.
|
|
55
|
+
*/
|
|
56
|
+
export function patchWideStyle<T extends OwnStyle | undefined>(
|
|
57
|
+
style: T,
|
|
58
|
+
patch: StylePatch,
|
|
59
|
+
): OwnStyle | undefined {
|
|
60
|
+
const { wide, ...desktop } = style ?? {};
|
|
61
|
+
const { hidden, ...values } = wide ?? {};
|
|
62
|
+
const merged = patchNestedStyle(values, patch) as StyleProps;
|
|
63
|
+
const nextWide: WideStyle = { ...merged, ...(hidden === undefined ? {} : { hidden }) };
|
|
64
|
+
const next: OwnStyle =
|
|
65
|
+
Object.keys(nextWide).length > 0 ? { ...desktop, wide: nextWide } : desktop;
|
|
66
|
+
return Object.keys(next).length > 0 ? next : undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** `patchWideStyle` on a design class. Pure. */
|
|
70
|
+
export function patchClassWide(
|
|
71
|
+
design: DesignSystem,
|
|
72
|
+
classId: string,
|
|
73
|
+
patch: StylePatch,
|
|
74
|
+
): DesignSystem {
|
|
75
|
+
return editClass(design, classId, (next) => {
|
|
76
|
+
next.style = patchWideStyle(next.style, patch) ?? {};
|
|
77
|
+
return next;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** An element or class whose hide can be read and toggled per device. */
|
|
82
|
+
type Hideable = { hiddenOn?: readonly Device[] | undefined; style?: OwnStyle | undefined };
|
|
83
|
+
|
|
84
|
+
/** Whether it is hidden on `device`. Wide screen follows Desktop unless `wide.hidden` is set. */
|
|
85
|
+
export function hiddenOnDevice(owner: Hideable, device: EditorDevice): boolean {
|
|
86
|
+
if (device === "wide") return owner.style?.wide?.hidden ?? !!owner.hiddenOn?.includes("desktop");
|
|
87
|
+
return !!owner.hiddenOn?.includes(device);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* W-959: hide or show on one device, Wide screen included. Wide screen follows Desktop until it is
|
|
92
|
+
* set on its own: toggling Desktop never touches `wide.hidden`, so hiding on Desktop hides on wide
|
|
93
|
+
* screens too. Toggling Wide screen stores its choice, and drops it when it matches Desktop again
|
|
94
|
+
* (back to following Desktop). Returns the new `hiddenOn` and `style` (either may be undefined).
|
|
95
|
+
* Pure.
|
|
96
|
+
*/
|
|
97
|
+
export function toggleHiddenOn(
|
|
98
|
+
owner: Hideable,
|
|
99
|
+
device: EditorDevice,
|
|
100
|
+
): { hiddenOn: Device[] | undefined; style: OwnStyle | undefined } {
|
|
101
|
+
if (device !== "wide")
|
|
102
|
+
return { hiddenOn: toggleHidden(owner.hiddenOn, device), style: owner.style };
|
|
103
|
+
const desktop = !!owner.hiddenOn?.includes("desktop");
|
|
104
|
+
const wide = !hiddenOnDevice(owner, "wide");
|
|
105
|
+
const { wide: oldWide, ...rest } = owner.style ?? {};
|
|
106
|
+
const { hidden: _old, ...values } = oldWide ?? {};
|
|
107
|
+
const nextWide: WideStyle = { ...values, ...(wide === desktop ? {} : { hidden: wide }) };
|
|
108
|
+
const style: OwnStyle = Object.keys(nextWide).length > 0 ? { ...rest, wide: nextWide } : rest;
|
|
109
|
+
return {
|
|
110
|
+
hiddenOn: owner.hiddenOn && owner.hiddenOn.length > 0 ? [...owner.hiddenOn] : undefined,
|
|
111
|
+
style: Object.keys(style).length > 0 ? style : undefined,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** W-959: whether Wide screen's hide is its own choice, or still follows Desktop. */
|
|
116
|
+
export const wideHideIsOwn = (owner: Hideable): boolean => owner.style?.wide?.hidden !== undefined;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Hidden on every device, so it never shows (W-409, W-413, W-500). W-959: an element hidden on
|
|
120
|
+
* all four that Wide screen shows again (`wide.hidden: false`) still shows on wide screens. Reads
|
|
121
|
+
* a stored node (`style.wide.hidden`) or a rendered one (`wideHidden`).
|
|
122
|
+
*/
|
|
123
|
+
export function hiddenOnEveryDevice(owner: Hideable & { wideHidden?: boolean }): boolean {
|
|
124
|
+
if (!DEVICES.every((device) => owner.hiddenOn?.includes(device))) return false;
|
|
125
|
+
return (owner.wideHidden ?? owner.style?.wide?.hidden) !== false;
|
|
126
|
+
}
|
|
@@ -33,7 +33,7 @@ export function refMatchesKind(ref: VariableRefLike, kind: VariableKind): boolea
|
|
|
33
33
|
const matches = (value: unknown, id: string, kind: VariableKind | undefined) =>
|
|
34
34
|
isVariableRef(value) && value.var === id && (kind === undefined || refMatchesKind(value, kind));
|
|
35
35
|
|
|
36
|
-
const NESTED_COLOR_KEYS = new Set(["boxShadow", "iconShadow", "gradient", "overlay"]);
|
|
36
|
+
const NESTED_COLOR_KEYS = new Set(["boxShadow", "iconShadow", "gradient", "overlay", "wide"]);
|
|
37
37
|
|
|
38
38
|
/** Every value that can be a variable, including nested colours (W-356). */
|
|
39
39
|
export function forEachStyleRef(
|
|
@@ -57,6 +57,9 @@ export function forEachStyleRef(
|
|
|
57
57
|
visit(stop.color, `overlay.gradient.stops.${index}`);
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
+
// W-959: an own style's Wide screen values use variables too.
|
|
61
|
+
const wide = (style as { wide?: StyleProps }).wide;
|
|
62
|
+
if (wide) forEachStyleRef(wide, (value, path) => visit(value, `wide.${path}`));
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
function collectStyleUsages(
|
|
@@ -167,6 +170,16 @@ function stripRefsFromStyle(
|
|
|
167
170
|
delete next["overlay"];
|
|
168
171
|
changed = true;
|
|
169
172
|
}
|
|
173
|
+
// W-959: and in the own style's Wide screen values (`hidden` stays when they all go).
|
|
174
|
+
const wide = (style as { wide?: StyleProps & { hidden?: boolean } }).wide;
|
|
175
|
+
if (wide) {
|
|
176
|
+
const stripped = stripRefsFromStyle(wide, id, kind);
|
|
177
|
+
if (stripped !== wide) {
|
|
178
|
+
changed = true;
|
|
179
|
+
if (stripped) next["wide"] = stripped;
|
|
180
|
+
else delete next["wide"];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
170
183
|
if (!changed) return style;
|
|
171
184
|
return Object.keys(next).length === 0 ? undefined : (next as StyleProps);
|
|
172
185
|
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SVG of an icon (W-025, W-234, W-237, W-238): a bundled Lucide icon or a picked one, sized,
|
|
3
|
+
* its stroke width themable and, when asked, painted in one colour. The Icon element and the
|
|
4
|
+
* 1.2 widgets that show an icon (W-1020) draw it here.
|
|
5
|
+
*/
|
|
6
|
+
import { getBundledIcon } from "../icons/catalog.ts";
|
|
7
|
+
import type { VNode } from "../render/vnode.ts";
|
|
8
|
+
import { sanitizeSvgMarkup } from "../sanitize/svg.ts";
|
|
9
|
+
|
|
10
|
+
/** Root stroke widths the Stroke width control can override (W-237); Lucide and Tabler use 2. */
|
|
11
|
+
export const ICON_STROKE_WIDTHS = ["1", "1.5", "2", "2.5", "3"] as const;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* W-237: a stroke icon's root `stroke-width` moves into a class whose CSS reads the wrapper's
|
|
15
|
+
* `--emvb-icon-stroke` with the original width as fallback; any other width stays as it was.
|
|
16
|
+
*/
|
|
17
|
+
function strokeClass(svgAttrs: Record<string, string>): void {
|
|
18
|
+
const width = svgAttrs["stroke-width"];
|
|
19
|
+
if (!width || !(ICON_STROKE_WIDTHS as readonly string[]).includes(width)) return;
|
|
20
|
+
if (!svgAttrs.stroke || svgAttrs.stroke === "none") return;
|
|
21
|
+
delete svgAttrs["stroke-width"];
|
|
22
|
+
const cls = `emvb-icon-sw${width.replace(".", "_")}`;
|
|
23
|
+
svgAttrs.class = svgAttrs.class ? `${svgAttrs.class} ${cls}` : cls;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Whether an icon's SVG is stroke-drawn with an adjustable width (the panel shows the control). */
|
|
27
|
+
export function iconHasAdjustableStroke(svg: string | undefined): boolean {
|
|
28
|
+
if (!svg) return true; // bundled Lucide
|
|
29
|
+
const picked = sanitizeSvgMarkup(svg);
|
|
30
|
+
if (!picked) return false;
|
|
31
|
+
const attrs = pickedIconAttrs(picked.attrs);
|
|
32
|
+
const before = attrs["stroke-width"];
|
|
33
|
+
strokeClass(attrs);
|
|
34
|
+
return before !== undefined && attrs["stroke-width"] === undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Paint attributes a multi-colour SVG sets its colours with (W-238). */
|
|
38
|
+
const PAINT_ATTRS = ["fill", "stroke", "stop-color"] as const;
|
|
39
|
+
|
|
40
|
+
const ownColor = (value: string | undefined) =>
|
|
41
|
+
value !== undefined && value !== "none" && value.toLowerCase() !== "currentcolor";
|
|
42
|
+
|
|
43
|
+
/** W-238: every fill, stroke and gradient stop becomes the icon's colour; `none` stays none. */
|
|
44
|
+
function monochrome(nodes: (VNode | string)[]): (VNode | string)[] {
|
|
45
|
+
return nodes.map((child) => {
|
|
46
|
+
if (typeof child === "string") return child;
|
|
47
|
+
const attrs = { ...child.attrs };
|
|
48
|
+
for (const name of PAINT_ATTRS) if (ownColor(attrs[name])) attrs[name] = "currentColor";
|
|
49
|
+
return { ...child, attrs, children: monochrome(child.children) };
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The root too; without a fill, SVG paints black, so it gets the icon's colour. */
|
|
54
|
+
function monochromeRoot(attrs: Record<string, string>): void {
|
|
55
|
+
if (attrs.fill === undefined || ownColor(attrs.fill)) attrs.fill = "currentColor";
|
|
56
|
+
if (ownColor(attrs.stroke)) attrs.stroke = "currentColor";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether an icon's SVG paints with its own colours (W-238): any fill, stroke or stop other than
|
|
61
|
+
* `none`/`currentColor`, or a root without a fill (SVG's default is black). The panel offers
|
|
62
|
+
* Force single colour only then. Bundled Lucide icons follow the icon's colour already.
|
|
63
|
+
*/
|
|
64
|
+
export function iconHasOwnColors(svg: string | undefined): boolean {
|
|
65
|
+
if (!svg) return false;
|
|
66
|
+
const picked = sanitizeSvgMarkup(svg);
|
|
67
|
+
if (!picked) return false;
|
|
68
|
+
if (picked.attrs.fill === undefined || PAINT_ATTRS.some((name) => ownColor(picked.attrs[name])))
|
|
69
|
+
return true;
|
|
70
|
+
const walk = (nodes: (VNode | string)[]): boolean =>
|
|
71
|
+
nodes.some(
|
|
72
|
+
(child) =>
|
|
73
|
+
typeof child !== "string" &&
|
|
74
|
+
(PAINT_ATTRS.some((name) => ownColor(child.attrs[name])) || walk(child.children)),
|
|
75
|
+
);
|
|
76
|
+
return walk(picked.children);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A picked icon's root attributes minus what the element sets itself (size, name, id). */
|
|
80
|
+
function pickedIconAttrs(attrs: Record<string, string>): Record<string, string> {
|
|
81
|
+
const kept: Record<string, string> = { xmlns: "http://www.w3.org/2000/svg" };
|
|
82
|
+
for (const [name, value] of Object.entries(attrs)) {
|
|
83
|
+
if (name === "width" || name === "height" || name === "id" || name === "role") continue;
|
|
84
|
+
if (name.startsWith("aria-") || name === "focusable") continue;
|
|
85
|
+
kept[name] = value;
|
|
86
|
+
}
|
|
87
|
+
if (!kept.viewBox) kept.viewBox = "0 0 24 24";
|
|
88
|
+
return kept;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* W-1020: an icon's `<svg>` at `size` px with `aria` (its name, or `aria-hidden`), or undefined
|
|
93
|
+
* when the id is unknown and no SVG is stored.
|
|
94
|
+
*/
|
|
95
|
+
export function iconGlyph(
|
|
96
|
+
props: { iconId: string; iconSvg?: string | undefined; singleColor?: boolean | undefined },
|
|
97
|
+
size: number,
|
|
98
|
+
aria: Record<string, string>,
|
|
99
|
+
): VNode | undefined {
|
|
100
|
+
// W-234: a picked library icon carries its own SVG; the allowlist checks it on every render.
|
|
101
|
+
const picked = props.iconSvg ? sanitizeSvgMarkup(props.iconSvg) : undefined;
|
|
102
|
+
const bundled = picked ? undefined : getBundledIcon(props.iconId);
|
|
103
|
+
if (!picked && !bundled) return undefined;
|
|
104
|
+
const svgAttrs: Record<string, string> = picked
|
|
105
|
+
? {
|
|
106
|
+
...pickedIconAttrs(picked.attrs),
|
|
107
|
+
width: String(size),
|
|
108
|
+
height: String(size),
|
|
109
|
+
focusable: "false",
|
|
110
|
+
}
|
|
111
|
+
: {
|
|
112
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
113
|
+
width: String(size),
|
|
114
|
+
height: String(size),
|
|
115
|
+
viewBox: "0 0 24 24",
|
|
116
|
+
fill: "none",
|
|
117
|
+
stroke: "currentColor",
|
|
118
|
+
"stroke-width": "2",
|
|
119
|
+
"stroke-linecap": "round",
|
|
120
|
+
"stroke-linejoin": "round",
|
|
121
|
+
focusable: "false",
|
|
122
|
+
};
|
|
123
|
+
Object.assign(svgAttrs, aria);
|
|
124
|
+
const children: (VNode | string)[] = picked
|
|
125
|
+
? picked.children
|
|
126
|
+
: (bundled?.children ?? []).map((child) => ({
|
|
127
|
+
tag: child.tag,
|
|
128
|
+
attrs: { ...child.attrs },
|
|
129
|
+
children: [],
|
|
130
|
+
}));
|
|
131
|
+
strokeClass(svgAttrs);
|
|
132
|
+
const single = picked !== undefined && props.singleColor === true;
|
|
133
|
+
if (single) monochromeRoot(svgAttrs);
|
|
134
|
+
return { tag: "svg", attrs: svgAttrs, children: single ? monochrome(children) : children };
|
|
135
|
+
}
|