@thi.ng/hiccup-css 2.2.19 → 2.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/animation.js +19 -51
- package/api.js +24 -28
- package/attribs.js +14 -45
- package/comment.js +14 -10
- package/conditional.js +30 -30
- package/css.js +18 -18
- package/impl.js +86 -84
- package/import.js +6 -4
- package/inject.js +18 -27
- package/keyframes.js +28 -23
- package/media.js +4 -1
- package/namespace.js +7 -5
- package/package.json +10 -7
- package/quoted-functions.js +10 -8
- package/supports.js +4 -1
- package/units.js +39 -28
package/CHANGELOG.md
CHANGED
package/animation.js
CHANGED
|
@@ -1,53 +1,21 @@
|
|
|
1
1
|
import { at_keyframes } from "./keyframes.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* 0% {
|
|
22
|
-
* opacity: 0;
|
|
23
|
-
* }
|
|
24
|
-
* 100% {
|
|
25
|
-
* opacity: 1;
|
|
26
|
-
* }
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* .fadein {
|
|
30
|
-
* animation-duration: 250ms;
|
|
31
|
-
* animation-name: fadein;
|
|
32
|
-
* animation-delay: 0.5s;
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @param id - animation name
|
|
37
|
-
* @param opts - animation config options
|
|
38
|
-
* @param keyframes - keyframes
|
|
39
|
-
*/
|
|
40
|
-
export const animation = (id, opts, ...keyframes) => {
|
|
41
|
-
opts = {
|
|
42
|
-
duration: "250ms",
|
|
43
|
-
name: id,
|
|
44
|
-
...opts,
|
|
45
|
-
};
|
|
46
|
-
return [
|
|
47
|
-
at_keyframes.apply(null, [id, ...keyframes]),
|
|
48
|
-
[
|
|
49
|
-
`.${id}`,
|
|
50
|
-
Object.keys(opts).reduce((acc, k) => ((acc[`animation-${k}`] = opts[k]), acc), {}),
|
|
51
|
-
],
|
|
52
|
-
];
|
|
2
|
+
const animation = (id, opts, ...keyframes) => {
|
|
3
|
+
opts = {
|
|
4
|
+
duration: "250ms",
|
|
5
|
+
name: id,
|
|
6
|
+
...opts
|
|
7
|
+
};
|
|
8
|
+
return [
|
|
9
|
+
at_keyframes.apply(null, [id, ...keyframes]),
|
|
10
|
+
[
|
|
11
|
+
`.${id}`,
|
|
12
|
+
Object.keys(opts).reduce(
|
|
13
|
+
(acc, k) => (acc[`animation-${k}`] = opts[k], acc),
|
|
14
|
+
{}
|
|
15
|
+
)
|
|
16
|
+
]
|
|
17
|
+
];
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
animation
|
|
53
21
|
};
|
package/api.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
decls: "",
|
|
12
|
-
declStart: "{",
|
|
13
|
-
declEnd: "}",
|
|
14
|
-
indent: "",
|
|
15
|
-
comments: false,
|
|
1
|
+
const DEFAULT_VENDORS = ["-moz-", "-ms-", "-o-", "-webkit-"];
|
|
2
|
+
const COMPACT = {
|
|
3
|
+
rules: "",
|
|
4
|
+
ruleSep: ",",
|
|
5
|
+
valSep: "",
|
|
6
|
+
decls: "",
|
|
7
|
+
declStart: "{",
|
|
8
|
+
declEnd: "}",
|
|
9
|
+
indent: "",
|
|
10
|
+
comments: false
|
|
16
11
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
const PRETTY = {
|
|
13
|
+
rules: "\n",
|
|
14
|
+
ruleSep: ", ",
|
|
15
|
+
valSep: " ",
|
|
16
|
+
decls: "\n",
|
|
17
|
+
declStart: " {\n",
|
|
18
|
+
declEnd: "}\n",
|
|
19
|
+
indent: " ",
|
|
20
|
+
comments: true
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
COMPACT,
|
|
24
|
+
DEFAULT_VENDORS,
|
|
25
|
+
PRETTY
|
|
30
26
|
};
|
package/attribs.js
CHANGED
|
@@ -1,46 +1,15 @@
|
|
|
1
1
|
const $ = (op) => (id, x, caseSensitve = false) => `[${id}${op}="${x}"${caseSensitve ? " i" : ""}]`;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Returns attrib selector `[id~=x]`
|
|
18
|
-
*
|
|
19
|
-
* @param id -
|
|
20
|
-
* @param x -
|
|
21
|
-
* @param caseSensitive -
|
|
22
|
-
*/
|
|
23
|
-
export const attribContains = $("~");
|
|
24
|
-
/**
|
|
25
|
-
* Returns attrib selector `[id^=x]`
|
|
26
|
-
*
|
|
27
|
-
* @param id -
|
|
28
|
-
* @param x -
|
|
29
|
-
* @param caseSensitive -
|
|
30
|
-
*/
|
|
31
|
-
export const attribPrefix = $("^");
|
|
32
|
-
/**
|
|
33
|
-
* Returns attrib selector `[id$=x]`
|
|
34
|
-
*
|
|
35
|
-
* @param id -
|
|
36
|
-
* @param x -
|
|
37
|
-
* @param caseSensitive -
|
|
38
|
-
*/
|
|
39
|
-
export const attribSuffix = $("$");
|
|
40
|
-
/**
|
|
41
|
-
* Returns attrib selector `[id*=x]`
|
|
42
|
-
* @param id -
|
|
43
|
-
* @param x -
|
|
44
|
-
* @param caseSensitive -
|
|
45
|
-
*/
|
|
46
|
-
export const attribMatches = $("*");
|
|
2
|
+
const withAttrib = (id) => `[${id}]`;
|
|
3
|
+
const attribEq = $("");
|
|
4
|
+
const attribContains = $("~");
|
|
5
|
+
const attribPrefix = $("^");
|
|
6
|
+
const attribSuffix = $("$");
|
|
7
|
+
const attribMatches = $("*");
|
|
8
|
+
export {
|
|
9
|
+
attribContains,
|
|
10
|
+
attribEq,
|
|
11
|
+
attribMatches,
|
|
12
|
+
attribPrefix,
|
|
13
|
+
attribSuffix,
|
|
14
|
+
withAttrib
|
|
15
|
+
};
|
package/comment.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { indent } from "./impl.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
const comment = (body, force = false) => (acc, opts) => {
|
|
3
|
+
const space = indent(opts);
|
|
4
|
+
const inner = indent(opts, opts.depth + 1);
|
|
5
|
+
if (opts.format.comments || force) {
|
|
6
|
+
acc.push(
|
|
7
|
+
space + "/*",
|
|
8
|
+
body.split("\n").map((l) => inner + l).join("\n"),
|
|
9
|
+
space + "*/"
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
return acc;
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
comment
|
|
12
16
|
};
|
package/conditional.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { isString } from "@thi.ng/checks/is-string";
|
|
2
2
|
import { expand, indent } from "./impl.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const conditional = (type, cond, rules) => (acc, opts) => {
|
|
4
|
+
const space = indent(opts);
|
|
5
|
+
acc.push(`${space}${type} ${formatCond(cond)}${opts.format.declStart}`);
|
|
6
|
+
opts.depth++;
|
|
7
|
+
expand(acc, [], rules, opts);
|
|
8
|
+
opts.depth--;
|
|
9
|
+
acc.push(space + opts.format.declEnd);
|
|
10
|
+
return acc;
|
|
11
11
|
};
|
|
12
12
|
const formatCond = (cond) => {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if (isString(cond)) {
|
|
14
|
+
return cond;
|
|
15
|
+
}
|
|
16
|
+
const acc = [];
|
|
17
|
+
for (let c in cond) {
|
|
18
|
+
if (cond.hasOwnProperty(c)) {
|
|
19
|
+
let v = cond[c];
|
|
20
|
+
if (v === true) {
|
|
21
|
+
v = c;
|
|
22
|
+
} else if (v === false) {
|
|
23
|
+
v = "not " + c;
|
|
24
|
+
} else if (v === "only") {
|
|
25
|
+
v += " " + c;
|
|
26
|
+
} else {
|
|
27
|
+
v = `(${c}:${v})`;
|
|
28
|
+
}
|
|
29
|
+
acc.push(v);
|
|
15
30
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
v = c;
|
|
22
|
-
}
|
|
23
|
-
else if (v === false) {
|
|
24
|
-
v = "not " + c;
|
|
25
|
-
}
|
|
26
|
-
else if (v === "only") {
|
|
27
|
-
v += " " + c;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
v = `(${c}:${v})`;
|
|
31
|
-
}
|
|
32
|
-
acc.push(v);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return acc.join(" and ");
|
|
31
|
+
}
|
|
32
|
+
return acc.join(" and ");
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
conditional
|
|
36
36
|
};
|
package/css.js
CHANGED
|
@@ -5,22 +5,22 @@ import { isPlainObject } from "@thi.ng/checks/is-plain-object";
|
|
|
5
5
|
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
|
|
6
6
|
import { COMPACT, DEFAULT_VENDORS } from "./api.js";
|
|
7
7
|
import { expand, formatDecls } from "./impl.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
const css = (rules, opts) => {
|
|
9
|
+
opts = {
|
|
10
|
+
format: COMPACT,
|
|
11
|
+
vendors: DEFAULT_VENDORS,
|
|
12
|
+
fns: {},
|
|
13
|
+
depth: 0,
|
|
14
|
+
...opts
|
|
15
|
+
};
|
|
16
|
+
isArray(opts.autoprefix) && (opts.autoprefix = new Set(opts.autoprefix));
|
|
17
|
+
return isPlainObject(rules) ? formatDecls(rules, opts) : isFunction(rules) ? rules([], opts).join(opts.format.rules) : expand(
|
|
18
|
+
[],
|
|
19
|
+
[],
|
|
20
|
+
isArray(rules) ? rules : isNotStringAndIterable(rules) ? [...rules] : illegalArgs(`invalid rules`),
|
|
21
|
+
opts
|
|
22
|
+
).join(opts.format.rules);
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
css
|
|
26
26
|
};
|
package/impl.js
CHANGED
|
@@ -11,97 +11,99 @@ import { permutations } from "@thi.ng/transducers/permutations";
|
|
|
11
11
|
import { repeat } from "@thi.ng/transducers/repeat";
|
|
12
12
|
import { str } from "@thi.ng/transducers/str";
|
|
13
13
|
import { transduce } from "@thi.ng/transducers/transduce";
|
|
14
|
-
const EMPTY = new Set();
|
|
14
|
+
const EMPTY = /* @__PURE__ */ new Set();
|
|
15
15
|
const NO_SPACES = ":[";
|
|
16
|
-
const xfSel = comp(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
else if (isFn) {
|
|
40
|
-
process(i, r());
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
illegalArgs(`quoted fn ('${r}') only allowed at head position`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else if (isPlainObject(r)) {
|
|
47
|
-
curr = Object.assign(curr || {}, r);
|
|
48
|
-
}
|
|
49
|
-
else if (r != null) {
|
|
50
|
-
sel.push(r);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
for (let i = 0; i < n; i++) {
|
|
54
|
-
if (process(i, rules[i])) {
|
|
55
|
-
return acc;
|
|
16
|
+
const xfSel = comp(
|
|
17
|
+
flatten(),
|
|
18
|
+
map((x) => NO_SPACES.indexOf(x.charAt(0)) >= 0 ? x : " " + x)
|
|
19
|
+
);
|
|
20
|
+
const withScope = (xf, scope) => comp(
|
|
21
|
+
xf,
|
|
22
|
+
map((x) => isString(x) && x.indexOf(" .") == 0 ? x + scope : x)
|
|
23
|
+
);
|
|
24
|
+
const expand = (acc, parent, rules, opts) => {
|
|
25
|
+
const n = rules.length;
|
|
26
|
+
const sel = [];
|
|
27
|
+
let curr, isFn;
|
|
28
|
+
const process = (i, r) => {
|
|
29
|
+
let rfn = null;
|
|
30
|
+
if (isArray(r)) {
|
|
31
|
+
expand(acc, makeSelector(parent, sel), r, opts);
|
|
32
|
+
} else if (isIterable(r) && !isString(r)) {
|
|
33
|
+
expand(acc, makeSelector(parent, sel), [...r], opts);
|
|
34
|
+
} else if ((isFn = isFunction(r)) || (rfn = opts.fns[r])) {
|
|
35
|
+
if (!parent.length) {
|
|
36
|
+
if (rfn) {
|
|
37
|
+
rfn.apply(null, rules.slice(i + 1))(acc, opts);
|
|
38
|
+
return true;
|
|
56
39
|
}
|
|
40
|
+
r(acc, opts);
|
|
41
|
+
} else if (isFn) {
|
|
42
|
+
process(i, r());
|
|
43
|
+
} else {
|
|
44
|
+
illegalArgs(`quoted fn ('${r}') only allowed at head position`);
|
|
45
|
+
}
|
|
46
|
+
} else if (isPlainObject(r)) {
|
|
47
|
+
curr = Object.assign(curr || {}, r);
|
|
48
|
+
} else if (r != null) {
|
|
49
|
+
sel.push(r);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
for (let i = 0; i < n; i++) {
|
|
53
|
+
if (process(i, rules[i])) {
|
|
54
|
+
return acc;
|
|
57
55
|
}
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
}
|
|
57
|
+
curr && acc.push(formatRule(parent, sel, curr, opts));
|
|
58
|
+
return acc;
|
|
60
59
|
};
|
|
61
60
|
const makeSelector = (parent, curr) => parent.length ? [...permutations(parent, curr)] : curr;
|
|
62
61
|
const formatRule = (parent, sel, curr, opts) => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
const f = opts.format;
|
|
63
|
+
const space = indent(opts);
|
|
64
|
+
const xf = opts.scope ? withScope(xfSel, opts.scope) : xfSel;
|
|
65
|
+
return [
|
|
66
|
+
space,
|
|
67
|
+
transduce(
|
|
68
|
+
map(
|
|
69
|
+
(sel2) => transduce(xf, str(), isArray(sel2) ? sel2 : [sel2]).trim()
|
|
70
|
+
),
|
|
71
|
+
str(f.ruleSep),
|
|
72
|
+
makeSelector(parent, sel)
|
|
73
|
+
),
|
|
74
|
+
f.declStart,
|
|
75
|
+
formatDecls(curr, opts),
|
|
76
|
+
space,
|
|
77
|
+
f.declEnd
|
|
78
|
+
].join("");
|
|
74
79
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (prefixes.has(r)) {
|
|
93
|
-
for (let v of opts.vendors) {
|
|
94
|
-
acc.push(`${space}${v}${r}:${f.valSep}${val};`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
acc.push(`${space}${r}:${f.valSep}${val};`);
|
|
80
|
+
const formatDecls = (rules, opts) => {
|
|
81
|
+
const f = opts.format;
|
|
82
|
+
const prefixes = opts.autoprefix || EMPTY;
|
|
83
|
+
const space = indent(opts, opts.depth + 1);
|
|
84
|
+
const acc = [];
|
|
85
|
+
for (let r in rules) {
|
|
86
|
+
if (rules.hasOwnProperty(r)) {
|
|
87
|
+
let val = rules[r];
|
|
88
|
+
if (isFunction(val)) {
|
|
89
|
+
val = val(rules);
|
|
90
|
+
}
|
|
91
|
+
if (isArray(val)) {
|
|
92
|
+
val = val.map((v) => isArray(v) ? v.join(" ") : v).join(f.ruleSep);
|
|
93
|
+
}
|
|
94
|
+
if (prefixes.has(r)) {
|
|
95
|
+
for (let v of opts.vendors) {
|
|
96
|
+
acc.push(`${space}${v}${r}:${f.valSep}${val};`);
|
|
98
97
|
}
|
|
98
|
+
}
|
|
99
|
+
acc.push(`${space}${r}:${f.valSep}${val};`);
|
|
99
100
|
}
|
|
100
|
-
|
|
101
|
+
}
|
|
102
|
+
return acc.join(f.decls) + f.decls;
|
|
103
|
+
};
|
|
104
|
+
const indent = (opts, d = opts.depth) => d > 1 ? [...repeat(opts.format.indent, d)].join("") : d > 0 ? opts.format.indent : "";
|
|
105
|
+
export {
|
|
106
|
+
expand,
|
|
107
|
+
formatDecls,
|
|
108
|
+
indent
|
|
101
109
|
};
|
|
102
|
-
/** @internal */
|
|
103
|
-
export const indent = (opts, d = opts.depth) => d > 1
|
|
104
|
-
? [...repeat(opts.format.indent, d)].join("")
|
|
105
|
-
: d > 0
|
|
106
|
-
? opts.format.indent
|
|
107
|
-
: "";
|
package/import.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const at_import = (url, ...queries) => (acc, opts) => (acc.push(
|
|
2
|
+
queries.length ? `@import url(${url}) ${queries.join(opts.format.ruleSep)};` : `@import url(${url});`
|
|
3
|
+
), acc);
|
|
4
|
+
export {
|
|
5
|
+
at_import
|
|
6
|
+
};
|
package/inject.js
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
sheet.textContent = css;
|
|
20
|
-
}
|
|
21
|
-
if (first) {
|
|
22
|
-
head.insertBefore(sheet, head.firstChild);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
head.appendChild(sheet);
|
|
26
|
-
}
|
|
27
|
-
return sheet;
|
|
1
|
+
const injectStyleSheet = (css, first = false) => {
|
|
2
|
+
const head = document.getElementsByTagName("head")[0];
|
|
3
|
+
const sheet = document.createElement("style");
|
|
4
|
+
sheet.setAttribute("type", "text/css");
|
|
5
|
+
if (sheet.styleSheet !== void 0) {
|
|
6
|
+
sheet.styleSheet.cssText = css;
|
|
7
|
+
} else {
|
|
8
|
+
sheet.textContent = css;
|
|
9
|
+
}
|
|
10
|
+
if (first) {
|
|
11
|
+
head.insertBefore(sheet, head.firstChild);
|
|
12
|
+
} else {
|
|
13
|
+
head.appendChild(sheet);
|
|
14
|
+
}
|
|
15
|
+
return sheet;
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
injectStyleSheet
|
|
28
19
|
};
|
package/keyframes.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { formatDecls, indent } from "./impl.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
function at_keyframes(id, ...args) {
|
|
3
|
+
const stops = args.length === 1 ? args[0] : { 0: args[0], 100: args[1] };
|
|
4
|
+
return (acc, opts) => {
|
|
5
|
+
const outer = indent(opts);
|
|
6
|
+
opts.depth++;
|
|
7
|
+
const inner = indent(opts);
|
|
8
|
+
acc.push(`${outer}@keyframes ${id}${opts.format.declStart}`);
|
|
9
|
+
for (let s in stops) {
|
|
10
|
+
if (stops.hasOwnProperty(s)) {
|
|
11
|
+
acc.push(
|
|
12
|
+
[
|
|
13
|
+
inner,
|
|
14
|
+
s + "%",
|
|
15
|
+
opts.format.declStart,
|
|
16
|
+
formatDecls(stops[s], opts),
|
|
17
|
+
inner,
|
|
18
|
+
opts.format.declEnd
|
|
19
|
+
].join("")
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
opts.depth--;
|
|
24
|
+
acc.push(outer + opts.format.declEnd);
|
|
25
|
+
return acc;
|
|
26
|
+
};
|
|
25
27
|
}
|
|
28
|
+
export {
|
|
29
|
+
at_keyframes
|
|
30
|
+
};
|
package/media.js
CHANGED
package/namespace.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
acc);
|
|
1
|
+
function at_namespace(...args) {
|
|
2
|
+
return (acc, _) => (acc.push(
|
|
3
|
+
args.length > 1 ? `@namespace ${args[0]} url(${args[1]});` : `@namespace url(${args[0]});`
|
|
4
|
+
), acc);
|
|
6
5
|
}
|
|
6
|
+
export {
|
|
7
|
+
at_namespace
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/hiccup-css",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.20",
|
|
4
4
|
"description": "CSS from nested JS data structures",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "yarn
|
|
27
|
+
"build": "yarn build:esbuild && yarn build:decl",
|
|
28
|
+
"build:decl": "tsc --declaration --emitDeclarationOnly",
|
|
29
|
+
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
|
|
28
30
|
"clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",
|
|
29
31
|
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
30
32
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
@@ -33,13 +35,14 @@
|
|
|
33
35
|
"test": "bun test"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"@thi.ng/api": "^8.9.
|
|
37
|
-
"@thi.ng/checks": "^3.4.
|
|
38
|
-
"@thi.ng/errors": "^2.4.
|
|
39
|
-
"@thi.ng/transducers": "^8.8.
|
|
38
|
+
"@thi.ng/api": "^8.9.12",
|
|
39
|
+
"@thi.ng/checks": "^3.4.12",
|
|
40
|
+
"@thi.ng/errors": "^2.4.6",
|
|
41
|
+
"@thi.ng/transducers": "^8.8.15"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@microsoft/api-extractor": "^7.38.3",
|
|
45
|
+
"esbuild": "^0.19.8",
|
|
43
46
|
"rimraf": "^5.0.5",
|
|
44
47
|
"tools": "^0.0.1",
|
|
45
48
|
"typedoc": "^0.25.4",
|
|
@@ -125,5 +128,5 @@
|
|
|
125
128
|
],
|
|
126
129
|
"year": 2016
|
|
127
130
|
},
|
|
128
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
|
|
129
132
|
}
|
package/quoted-functions.js
CHANGED
|
@@ -4,12 +4,14 @@ import { at_keyframes } from "./keyframes.js";
|
|
|
4
4
|
import { at_media } from "./media.js";
|
|
5
5
|
import { at_namespace } from "./namespace.js";
|
|
6
6
|
import { at_supports } from "./supports.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const QUOTED_FNS = {
|
|
8
|
+
"@comment": comment,
|
|
9
|
+
"@import": at_import,
|
|
10
|
+
"@keyframes": at_keyframes,
|
|
11
|
+
"@media": at_media,
|
|
12
|
+
"@namespace": at_namespace,
|
|
13
|
+
"@supports": at_supports
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
QUOTED_FNS
|
|
15
17
|
};
|
package/supports.js
CHANGED
package/units.js
CHANGED
|
@@ -1,28 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
let PRECISION = 4;
|
|
2
|
+
const setPrecision = (n) => PRECISION = n;
|
|
3
|
+
const ff = (x) => x === (x | 0) ? String(x) : x.toFixed(PRECISION);
|
|
4
|
+
const em = (x) => `${ff(x)}em`;
|
|
5
|
+
const ex = (x) => `${ff(x)}ex`;
|
|
6
|
+
const rem = (x) => `${ff(x)}rem`;
|
|
7
|
+
const percent = (x) => `${ff(x)}%`;
|
|
8
|
+
const px = (x) => `${ff(x)}px`;
|
|
9
|
+
const vh = (x) => `${ff(x)}vh`;
|
|
10
|
+
const vw = (x) => `${ff(x)}vw`;
|
|
11
|
+
const vmin = (x) => `${ff(x)}vmin`;
|
|
12
|
+
const vmax = (x) => `${ff(x)}vmax`;
|
|
13
|
+
const ms = (x) => `${x | 0}ms`;
|
|
14
|
+
const second = (x) => `${ff(x)}s`;
|
|
15
|
+
const sec = second;
|
|
16
|
+
const deg = (x) => `${ff(x)}deg`;
|
|
17
|
+
const rad = (x) => `${ff(x)}rad`;
|
|
18
|
+
const turn = (x) => `${ff(x)}turn`;
|
|
19
|
+
const url = (x) => `url(${x})`;
|
|
20
|
+
export {
|
|
21
|
+
PRECISION,
|
|
22
|
+
deg,
|
|
23
|
+
em,
|
|
24
|
+
ex,
|
|
25
|
+
ms,
|
|
26
|
+
percent,
|
|
27
|
+
px,
|
|
28
|
+
rad,
|
|
29
|
+
rem,
|
|
30
|
+
sec,
|
|
31
|
+
second,
|
|
32
|
+
setPrecision,
|
|
33
|
+
turn,
|
|
34
|
+
url,
|
|
35
|
+
vh,
|
|
36
|
+
vmax,
|
|
37
|
+
vmin,
|
|
38
|
+
vw
|
|
39
|
+
};
|