@thi.ng/hiccup-css 2.1.63 → 2.2.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-08-27T11:20:59Z
3
+ - **Last updated**: 2023-09-06T13:36:28Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,24 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [2.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup-css@2.2.0) (2023-09-02)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add customizable unit formatter precision ([2db3071](https://github.com/thi-ng/umbrella/commit/2db3071))
17
+ - set default prec to 4 fractional digits
18
+ - add setPrecision() to customize unit formatters
19
+ - add vmin/vmax() unit formatters
20
+ - update all other unit formatters
21
+
22
+ #### ♻️ Refactoring
23
+
24
+ - update at_keyframes() arg types ([5de6a92](https://github.com/thi-ng/umbrella/commit/5de6a92))
25
+ - add Keyframe type alias
26
+ - update animation() args/opts ([ba47f93](https://github.com/thi-ng/umbrella/commit/ba47f93))
27
+ - update AnimationOpts
28
+ - use Keyframe type for args
29
+
12
30
  ### [2.1.39](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup-css@2.1.39) (2023-02-17)
13
31
 
14
32
  #### 🩹 Bug fixes
package/README.md CHANGED
@@ -117,7 +117,7 @@ For Node.js REPL:
117
117
  const hiccupCss = await import("@thi.ng/hiccup-css");
118
118
  ```
119
119
 
120
- Package sizes (brotli'd, pre-treeshake): ESM: 1.99 KB
120
+ Package sizes (brotli'd, pre-treeshake): ESM: 2.08 KB
121
121
 
122
122
  ## Dependencies
123
123
 
@@ -134,9 +134,10 @@ directory are using this package.
134
134
 
135
135
  A selection:
136
136
 
137
- | Screenshot | Description | Live demo | Source |
138
- |:-----------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------|:------------------------------------------------------|:-----------------------------------------------------------------------------------|
139
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/hdom-benchmark2.png" width="240"/> | hdom update performance benchmark w/ config options | [Demo](https://demo.thi.ng/umbrella/hdom-benchmark2/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-benchmark2) |
137
+ | Screenshot | Description | Live demo | Source |
138
+ |:-----------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------|:------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------|
139
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/hdom-benchmark2.png" width="240"/> | hdom update performance benchmark w/ config options | [Demo](https://demo.thi.ng/umbrella/hdom-benchmark2/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hdom-benchmark2) |
140
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/hiccup-css-image-transition.jpg" width="240"/> | Generating pure CSS image transitions | [Demo](https://demo.thi.ng/umbrella/hiccup-css-image-transition/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/hiccup-css-image-transition) |
140
141
 
141
142
  ## API
142
143
 
package/animation.d.ts CHANGED
@@ -1,9 +1,10 @@
1
+ import { type Keyframe } from "./keyframes.js";
1
2
  export interface AnimationOpts {
2
3
  delay: string;
3
4
  direction: "unset" | "inherit" | "initial" | "normal" | "reverse" | "alternate" | "alternate-reverse";
4
5
  duration: string;
5
6
  "fill-mode": "none" | "forwards" | "backwards" | "both";
6
- "iteration-count": number;
7
+ "iteration-count": number | string;
7
8
  "play-state": "unset" | "inherit" | "initial" | "paused" | "running";
8
9
  "timing-function": string;
9
10
  }
@@ -45,5 +46,5 @@ export interface AnimationOpts {
45
46
  * @param opts - animation config options
46
47
  * @param keyframes - keyframes
47
48
  */
48
- export declare const animation: (id: string, opts: Partial<AnimationOpts>, ...keyframes: any) => (any[] | import("./api.js").RuleFn)[];
49
+ export declare const animation: (id: string, opts: Partial<AnimationOpts>, ...keyframes: Keyframe[]) => (any[] | import("./api.js").RuleFn)[];
49
50
  //# sourceMappingURL=animation.d.ts.map
package/keyframes.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { RuleFn } from "./api.js";
2
+ export type Keyframe = Record<string, any>;
2
3
  /**
3
4
  * Rule function for `@keyframes`. If a single declaration object is given,
4
5
  * it's keys are used as keyframe stops and their values as their declarations
@@ -42,6 +43,6 @@ import type { RuleFn } from "./api.js";
42
43
  * @param id -
43
44
  * @param stops -
44
45
  */
45
- export declare function at_keyframes(id: string, stops: any): RuleFn;
46
- export declare function at_keyframes(id: string, from: any, to: any): RuleFn;
46
+ export declare function at_keyframes(id: string, stops: Keyframe): RuleFn;
47
+ export declare function at_keyframes(id: string, from: Keyframe, to: Keyframe): RuleFn;
47
48
  //# sourceMappingURL=keyframes.d.ts.map
package/keyframes.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { formatDecls, indent } from "./impl.js";
2
- import { percent } from "./units.js";
3
2
  export function at_keyframes(id, ...args) {
4
3
  const stops = args.length === 1 ? args[0] : { 0: args[0], 100: args[1] };
5
4
  return (acc, opts) => {
@@ -11,7 +10,7 @@ export function at_keyframes(id, ...args) {
11
10
  if (stops.hasOwnProperty(s)) {
12
11
  acc.push([
13
12
  inner,
14
- percent(s),
13
+ s + "%",
15
14
  opts.format.declStart,
16
15
  formatDecls(stops[s], opts),
17
16
  inner,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/hiccup-css",
3
- "version": "2.1.63",
3
+ "version": "2.2.1",
4
4
  "description": "CSS from nested JS data structures",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -37,7 +37,7 @@
37
37
  "@thi.ng/api": "^8.9.5",
38
38
  "@thi.ng/checks": "^3.4.5",
39
39
  "@thi.ng/errors": "^2.3.5",
40
- "@thi.ng/transducers": "^8.6.4"
40
+ "@thi.ng/transducers": "^8.6.5"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@microsoft/api-extractor": "^7.36.4",
@@ -127,5 +127,5 @@
127
127
  ],
128
128
  "year": 2016
129
129
  },
130
- "gitHead": "34c3bd36b0133af05abc7fe66affa01dd99704ac\n"
130
+ "gitHead": "1bbef970bab7f7def0700e587cf0471e1e1ef9f3\n"
131
131
  }
package/units.d.ts CHANGED
@@ -1,3 +1,12 @@
1
+ export declare let PRECISION: number;
2
+ /**
3
+ * Sets the number of fractional digits used for formatting various floating
4
+ * point values in the serialized SVG. The current value can be read via
5
+ * {@link PRECISION}.
6
+ *
7
+ * @param n
8
+ */
9
+ export declare const setPrecision: (n: number) => number;
1
10
  export declare const em: (x: number) => string;
2
11
  export declare const ex: (x: number) => string;
3
12
  export declare const rem: (x: number) => string;
@@ -5,9 +14,14 @@ export declare const percent: (x: number) => string;
5
14
  export declare const px: (x: number) => string;
6
15
  export declare const vh: (x: number) => string;
7
16
  export declare const vw: (x: number) => string;
17
+ export declare const vmin: (x: number) => string;
18
+ export declare const vmax: (x: number) => string;
8
19
  export declare const ms: (x: number) => string;
20
+ export declare const second: (x: number) => string;
21
+ /** @deprecated use {@link second} */
9
22
  export declare const sec: (x: number) => string;
10
23
  export declare const deg: (x: number) => string;
11
24
  export declare const rad: (x: number) => string;
12
25
  export declare const turn: (x: number) => string;
26
+ export declare const url: (x: string) => string;
13
27
  //# sourceMappingURL=units.d.ts.map
package/units.js CHANGED
@@ -1,12 +1,28 @@
1
- export const em = (x) => `${x}em`;
2
- export const ex = (x) => `${x}ex`;
3
- export const rem = (x) => `${x}rem`;
4
- export const percent = (x) => `${x}%`;
5
- export const px = (x) => `${x}px`;
6
- export const vh = (x) => `${x}vh`;
7
- export const vw = (x) => `${x}vw`;
1
+ export let PRECISION = 4;
2
+ /**
3
+ * Sets the number of fractional digits used for formatting various floating
4
+ * point values in the serialized SVG. The current value can be read via
5
+ * {@link PRECISION}.
6
+ *
7
+ * @param n
8
+ */
9
+ export const setPrecision = (n) => (PRECISION = n);
10
+ /** @internal */
11
+ const ff = (x) => (x === (x | 0) ? String(x) : x.toFixed(PRECISION));
12
+ export const em = (x) => `${ff(x)}em`;
13
+ export const ex = (x) => `${ff(x)}ex`;
14
+ export const rem = (x) => `${ff(x)}rem`;
15
+ export const percent = (x) => `${ff(x)}%`;
16
+ export const px = (x) => `${ff(x)}px`;
17
+ export const vh = (x) => `${ff(x)}vh`;
18
+ export const vw = (x) => `${ff(x)}vw`;
19
+ export const vmin = (x) => `${ff(x)}vmin`;
20
+ export const vmax = (x) => `${ff(x)}vmax`;
8
21
  export const ms = (x) => `${x | 0}ms`;
9
- export const sec = (x) => `${x}s`;
10
- export const deg = (x) => `${x}deg`;
11
- export const rad = (x) => `${x}rad`;
12
- export const turn = (x) => `${x}turn`;
22
+ export const second = (x) => `${ff(x)}s`;
23
+ /** @deprecated use {@link second} */
24
+ export const sec = second;
25
+ export const deg = (x) => `${ff(x)}deg`;
26
+ export const rad = (x) => `${ff(x)}rad`;
27
+ export const turn = (x) => `${ff(x)}turn`;
28
+ export const url = (x) => `url(${x})`;