@thi.ng/hdom-components 4.0.47 → 5.0.3

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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@thi.ng/hdom-components",
3
- "version": "4.0.47",
3
+ "version": "5.0.3",
4
4
  "description": "Raw, skinnable UI & SVG components for @thi.ng/hdom",
5
+ "type": "module",
5
6
  "module": "./index.js",
6
- "main": "./lib/index.js",
7
- "umd:main": "./lib/index.umd.js",
8
7
  "typings": "./index.d.ts",
8
+ "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
@@ -24,33 +24,26 @@
24
24
  "author": "Karsten Schmidt <k+npm@thi.ng>",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
- "build": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module",
28
- "build:release": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module all",
29
- "build:es6": "tsc --declaration",
30
- "build:test": "rimraf build && tsc -p test/tsconfig.json",
31
- "build:check": "tsc --isolatedModules --noEmit",
32
- "test": "mocha test",
33
- "cover": "nyc mocha test && nyc report --reporter=lcov",
34
- "clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib utils",
35
- "doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
36
- "doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
27
+ "build": "yarn clean && tsc --declaration",
28
+ "clean": "rimraf *.js *.d.ts *.map doc utils",
29
+ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
37
30
  "doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
38
- "pub": "yarn build:release && yarn publish --access public"
31
+ "doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
32
+ "doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
33
+ "pub": "yarn build && yarn publish --access public",
34
+ "test": "testament test"
39
35
  },
40
36
  "dependencies": {
41
- "@thi.ng/adapt-dpi": "^1.0.23",
42
- "@thi.ng/api": "^7.1.9",
43
- "@thi.ng/checks": "^2.9.10",
44
- "@thi.ng/math": "^4.0.5",
45
- "@thi.ng/transducers": "^7.9.1",
46
- "@thi.ng/transducers-stats": "^1.1.73"
37
+ "@thi.ng/adapt-dpi": "^2.0.3",
38
+ "@thi.ng/api": "^8.0.3",
39
+ "@thi.ng/checks": "^3.0.3",
40
+ "@thi.ng/math": "^5.0.3",
41
+ "@thi.ng/transducers": "^8.0.3",
42
+ "@thi.ng/transducers-stats": "^2.0.3"
43
+ },
44
+ "devDependencies": {
45
+ "@thi.ng/testament": "^0.1.3"
47
46
  },
48
- "files": [
49
- "*.js",
50
- "*.d.ts",
51
- "lib",
52
- "utils"
53
- ],
54
47
  "keywords": [
55
48
  "browser",
56
49
  "typescript"
@@ -58,11 +51,59 @@
58
51
  "publishConfig": {
59
52
  "access": "public"
60
53
  },
61
- "sideEffects": false,
54
+ "engines": {
55
+ "node": ">=12.7"
56
+ },
57
+ "files": [
58
+ "*.js",
59
+ "*.d.ts",
60
+ "utils"
61
+ ],
62
+ "exports": {
63
+ ".": {
64
+ "import": "./index.js"
65
+ },
66
+ "./button-group": {
67
+ "import": "./button-group.js"
68
+ },
69
+ "./button": {
70
+ "import": "./button.js"
71
+ },
72
+ "./canvas": {
73
+ "import": "./canvas.js"
74
+ },
75
+ "./dropdown": {
76
+ "import": "./dropdown.js"
77
+ },
78
+ "./fps-counter": {
79
+ "import": "./fps-counter.js"
80
+ },
81
+ "./link": {
82
+ "import": "./link.js"
83
+ },
84
+ "./notification": {
85
+ "import": "./notification.js"
86
+ },
87
+ "./pager": {
88
+ "import": "./pager.js"
89
+ },
90
+ "./sparkline": {
91
+ "import": "./sparkline.js"
92
+ },
93
+ "./title": {
94
+ "import": "./title.js"
95
+ },
96
+ "./toggle": {
97
+ "import": "./toggle.js"
98
+ },
99
+ "./utils/merge-attribs": {
100
+ "import": "./utils/merge-attribs.js"
101
+ }
102
+ },
62
103
  "thi.ng": {
63
104
  "parent": "@thi.ng/hdom",
64
105
  "status": "beta",
65
106
  "year": 2018
66
107
  },
67
- "gitHead": "84a067278ef79ccd538eeb652046eb8e03f3e34e"
108
+ "gitHead": "1fb38cac74d6c009d96855c28784a267a81badf1"
68
109
  }
package/pager.js CHANGED
@@ -1,4 +1,5 @@
1
- import { map, range } from "@thi.ng/transducers";
1
+ import { map } from "@thi.ng/transducers/map";
2
+ import { range } from "@thi.ng/transducers/range";
2
3
  /**
3
4
  * Higher order container component for paged navigation buttons. The
4
5
  * returned component function takes these arguments:
@@ -44,7 +45,14 @@ import { map, range } from "@thi.ng/transducers";
44
45
  * @param opts -
45
46
  */
46
47
  export const pager = (_opts) => {
47
- const opts = Object.assign({ navStep: 1, labelFirst: "<<", labelPrev: "<", labelNext: ">", labelLast: ">>" }, _opts);
48
+ const opts = {
49
+ navStep: 1,
50
+ labelFirst: "<<",
51
+ labelPrev: "<",
52
+ labelNext: ">",
53
+ labelLast: ">>",
54
+ ..._opts,
55
+ };
48
56
  return (_, id, num, pageLen = 10, maxBts = 5) => {
49
57
  const bt = opts.button;
50
58
  const step = opts.navStep;
package/sparkline.js CHANGED
@@ -1,5 +1,6 @@
1
- import { fitClamped } from "@thi.ng/math";
2
- import { mapIndexed, str } from "@thi.ng/transducers";
1
+ import { fitClamped } from "@thi.ng/math/fit";
2
+ import { mapIndexed } from "@thi.ng/transducers/map-indexed";
3
+ import { str } from "@thi.ng/transducers/str";
3
4
  /**
4
5
  * Customizable, stateless SVG sparkline component.
5
6
  *
@@ -8,7 +9,15 @@ import { mapIndexed, str } from "@thi.ng/transducers";
8
9
  * @param vals - data values
9
10
  */
10
11
  export const sparkline = (_, _opts, vals) => {
11
- const opts = Object.assign({ min: 0, max: 100, width: 50, height: 16, col: "red", r: 1.5 }, _opts);
12
+ const opts = {
13
+ min: 0,
14
+ max: 100,
15
+ width: 50,
16
+ height: 16,
17
+ col: "red",
18
+ r: 1.5,
19
+ ..._opts,
20
+ };
12
21
  const n = vals.length;
13
22
  const s = opts.width / n;
14
23
  const r = opts.r;
package/title.js CHANGED
@@ -15,7 +15,13 @@
15
15
  * @param opts -
16
16
  */
17
17
  export const title = (_opts) => {
18
- const opts = Object.assign({ element: "h1", attribs: {}, subElement: "small", subAttribs: {} }, _opts);
18
+ const opts = {
19
+ element: "h1",
20
+ attribs: {},
21
+ subElement: "small",
22
+ subAttribs: {},
23
+ ..._opts,
24
+ };
19
25
  return (_, title, subtitle) => [
20
26
  opts.element,
21
27
  opts.attribs,
package/toggle.js CHANGED
@@ -9,7 +9,11 @@ const DEFAULT_OPTS = {
9
9
  fgOff: { fill: "#fff" },
10
10
  };
11
11
  export const slideToggleDot = (opts = {}) => {
12
- const _opts = Object.assign(Object.assign({ r: 5 }, DEFAULT_OPTS), opts);
12
+ const _opts = {
13
+ r: 5,
14
+ ...DEFAULT_OPTS,
15
+ ...opts,
16
+ };
13
17
  const { r, pad, margin, vertical } = _opts;
14
18
  const m2 = margin * 2;
15
19
  const br = r + pad;
@@ -22,20 +26,35 @@ export const slideToggleDot = (opts = {}) => {
22
26
  ? { width: totalH, height: totalW }
23
27
  : { width: totalW, height: totalH };
24
28
  const style = { transition: `all ${_opts.anim}ms ease-out` };
25
- const bgOn = Object.assign(Object.assign({ x: margin, y: margin, rx: br, ry: br }, (vertical ? { width: height, height: width } : { width, height })), _opts.bgOn);
26
- const bgOff = Object.assign(Object.assign({}, bgOn), _opts.bgOff);
27
- const shapeOn = Object.assign(Object.assign(Object.assign({}, (vertical ? { cx, cy: cx } : { cx: width + margin - br, cy: cx })), _opts.fgOn), { style,
28
- r });
29
- const shapeOff = Object.assign(Object.assign(Object.assign({}, shapeOn), (vertical ? { cy: width + margin - br } : { cx })), _opts.fgOff);
30
- return (_, attribs, state) => [
31
- "svg",
32
- Object.assign(Object.assign({}, svgSize), attribs),
33
- ["rect", state ? bgOn : bgOff],
34
- ["circle", state ? shapeOn : shapeOff],
35
- ];
29
+ const bgOn = {
30
+ x: margin,
31
+ y: margin,
32
+ rx: br,
33
+ ry: br,
34
+ ...(vertical ? { width: height, height: width } : { width, height }),
35
+ ..._opts.bgOn,
36
+ };
37
+ const bgOff = { ...bgOn, ..._opts.bgOff };
38
+ const shapeOn = {
39
+ ...(vertical ? { cx, cy: cx } : { cx: width + margin - br, cy: cx }),
40
+ ..._opts.fgOn,
41
+ style,
42
+ r,
43
+ };
44
+ const shapeOff = {
45
+ ...shapeOn,
46
+ ...(vertical ? { cy: width + margin - br } : { cx }),
47
+ ..._opts.fgOff,
48
+ };
49
+ return $toggle("circle", svgSize, bgOn, bgOff, shapeOn, shapeOff);
36
50
  };
37
51
  export const slideToggleRect = (opts = {}) => {
38
- const _opts = Object.assign(Object.assign({ w: 10, h: 10 }, DEFAULT_OPTS), opts);
52
+ const _opts = {
53
+ w: 10,
54
+ h: 10,
55
+ ...DEFAULT_OPTS,
56
+ ...opts,
57
+ };
39
58
  const { w, h, pad, margin, vertical } = _opts;
40
59
  const m2 = margin * 2;
41
60
  const pm = pad + margin;
@@ -43,17 +62,33 @@ export const slideToggleRect = (opts = {}) => {
43
62
  const height = vertical ? (h + pad) * 2 : h + pad * 2;
44
63
  const svgSize = { width: width + m2, height: height + m2 };
45
64
  const style = { transition: `all ${_opts.anim}ms ease-out` };
46
- const bgOn = Object.assign(Object.assign({}, _opts.bgOn), { width,
47
- height, x: margin, y: margin });
48
- const bgOff = Object.assign(Object.assign({}, bgOn), _opts.bgOff);
49
- const shapeOn = Object.assign(Object.assign(Object.assign({}, (vertical
50
- ? { x: pm, y: pm }
51
- : { x: width + margin - pad - w, y: pm })), _opts.fgOn), { style, width: w, height: h });
52
- const shapeOff = Object.assign(Object.assign(Object.assign({}, shapeOn), (vertical ? { y: height + margin - pad - h } : { x: pm })), _opts.fgOff);
53
- return (_, attribs, state) => [
54
- "svg",
55
- Object.assign(Object.assign({}, svgSize), attribs),
56
- ["rect", state ? bgOn : bgOff],
57
- ["rect", state ? shapeOn : shapeOff],
58
- ];
65
+ const bgOn = {
66
+ ..._opts.bgOn,
67
+ width,
68
+ height,
69
+ x: margin,
70
+ y: margin,
71
+ };
72
+ const bgOff = { ...bgOn, ..._opts.bgOff };
73
+ const shapeOn = {
74
+ ...(vertical
75
+ ? { x: pm, y: pm }
76
+ : { x: width + margin - pad - w, y: pm }),
77
+ ..._opts.fgOn,
78
+ style,
79
+ width: w,
80
+ height: h,
81
+ };
82
+ const shapeOff = {
83
+ ...shapeOn,
84
+ ...(vertical ? { y: height + margin - pad - h } : { x: pm }),
85
+ ..._opts.fgOff,
86
+ };
87
+ return $toggle("rect", svgSize, bgOn, bgOff, shapeOn, shapeOff);
59
88
  };
89
+ const $toggle = (shape, size, bgOn, bgOff, shapeOn, shapeOff) => (_, attribs, state) => [
90
+ "svg",
91
+ { ...size, ...attribs },
92
+ ["rect", state ? bgOn : bgOff],
93
+ [shape, state ? shapeOn : shapeOff],
94
+ ];
@@ -11,8 +11,8 @@
11
11
  export const mergeAttribs = (base, xs) => {
12
12
  if (!xs)
13
13
  return base;
14
- const res = Object.assign(Object.assign({}, base), xs);
14
+ const res = { ...base, ...xs };
15
15
  base.class && xs.class && (res.class = base.class + " " + xs.class);
16
- base.style && xs.style && (res.style = Object.assign(Object.assign({}, base.style), xs.style));
16
+ base.style && xs.style && (res.style = { ...base.style, ...xs.style });
17
17
  return res;
18
18
  };
package/lib/index.js DELETED
@@ -1,333 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var adaptDpi = require('@thi.ng/adapt-dpi');
6
- var transducers = require('@thi.ng/transducers');
7
- var transducersStats = require('@thi.ng/transducers-stats');
8
- var math = require('@thi.ng/math');
9
- var checks = require('@thi.ng/checks');
10
-
11
- const mergeAttribs = (base, xs) => {
12
- if (!xs)
13
- return base;
14
- const res = Object.assign(Object.assign({}, base), xs);
15
- base.class && xs.class && (res.class = base.class + " " + xs.class);
16
- base.style && xs.style && (res.style = Object.assign(Object.assign({}, base.style), xs.style));
17
- return res;
18
- };
19
-
20
- const button = (opts) => {
21
- opts = Object.assign({ tag: "a", tagDisabled: "span", preventDefault: true, attribs: {} }, opts);
22
- !opts.attribs.role && (opts.attribs.role = "button");
23
- return (_, args, ...body) => args.disabled
24
- ? [
25
- opts.tagDisabled,
26
- Object.assign(Object.assign({}, mergeAttribs(opts.attribsDisabled, args.attribs)), { disabled: true }),
27
- ...body,
28
- ]
29
- : [
30
- opts.tag,
31
- Object.assign(Object.assign({}, mergeAttribs(opts.attribs, args.attribs)), { onclick: opts.preventDefault
32
- ? (e) => (e.preventDefault(), args.onclick(e))
33
- : args.onclick }),
34
- ...body,
35
- ];
36
- };
37
-
38
- const buttonGroup = (opts) => (_, args, ...buttons) => [
39
- "div",
40
- mergeAttribs(opts.attribs, args.attribs),
41
- ...groupBody(opts, args.disabled, buttons),
42
- ];
43
- const groupBody = (opts, disabled, buttons) => {
44
- switch (buttons.length) {
45
- case 0:
46
- return [];
47
- case 1:
48
- return [bt(opts.inner || opts.first, disabled, buttons[0])];
49
- case 2:
50
- return [
51
- bt(opts.first, disabled, buttons[0]),
52
- bt(opts.last || opts.first, disabled, buttons[1]),
53
- ];
54
- default: {
55
- const res = [bt(opts.first, disabled, buttons[0])];
56
- const el = opts.inner || opts.first;
57
- const n = buttons.length - 1;
58
- for (let i = 1; i < n; i++) {
59
- res[i] = bt(el, disabled, buttons[i]);
60
- }
61
- res[n] = bt(opts.last || opts.first, disabled, buttons[n]);
62
- return res;
63
- }
64
- }
65
- };
66
- const bt = (el, disabled, bt) => disabled ? [el, Object.assign(Object.assign({}, bt[0]), { disabled: true }), ...bt.slice(1)] : [el, ...bt];
67
-
68
- const _canvas = (type, handlers, opts) => {
69
- let el;
70
- let ctx;
71
- let frame = 0;
72
- let time = 0;
73
- return {
74
- init(_el, hctx, ...args) {
75
- el = _el;
76
- adaptDpi.adaptDPI(el, el.width, el.height);
77
- ctx = el.getContext(type, opts);
78
- time = Date.now();
79
- handlers.init && handlers.init(el, ctx, hctx, ...args);
80
- handlers.update &&
81
- handlers.update(el, ctx, hctx, time, frame++, ...args);
82
- },
83
- render(hctx, ...args) {
84
- ctx &&
85
- handlers.update &&
86
- handlers.update(el, ctx, hctx, Date.now() - time, frame++, ...args);
87
- return ["canvas", args[0]];
88
- },
89
- release(hctx, ...args) {
90
- handlers.release && handlers.release(el, ctx, hctx, ...args);
91
- },
92
- };
93
- };
94
- const canvasWebGL = (handlers, opts) => _canvas("webgl", handlers, opts);
95
- const canvasWebGL2 = (handlers, opts) => _canvas("webgl2", handlers, opts);
96
- const canvas2D = (handlers, opts) => _canvas("2d", handlers, opts);
97
-
98
- const option = ([value, label, disabled], sel) => [
99
- "option",
100
- { value, disabled: !!disabled, selected: value === sel },
101
- label,
102
- ];
103
- const optgroup = (attribs, options, sel) => [
104
- "optgroup",
105
- Object.assign(Object.assign({}, attribs), { label: attribs.label || "--" }),
106
- ...options.map((o) => option(o, sel)),
107
- ];
108
- const dropdown = (_, attribs, options, sel) => ["select", attribs, ...options.map((o) => option(o, sel))];
109
- const groupedDropdown = (_, attribs, groups, sel) => ["select", attribs, ...groups.map((o) => optgroup(o[0], o[1], sel))];
110
-
111
- const sparkline = (_, _opts, vals) => {
112
- const opts = Object.assign({ min: 0, max: 100, width: 50, height: 16, col: "red", r: 1.5 }, _opts);
113
- const n = vals.length;
114
- const s = opts.width / n;
115
- const r = opts.r;
116
- const h = opts.height - r;
117
- return [
118
- "svg",
119
- {
120
- width: opts.width + 2 * r,
121
- height: opts.height,
122
- stroke: opts.col,
123
- fill: "none",
124
- },
125
- [
126
- "polyline",
127
- {
128
- points: transducers.str(",", transducers.mapIndexed((i, y) => [
129
- (i * s) | 0,
130
- math.fitClamped(y, opts.min, opts.max, h, r) | 0,
131
- ], 0, vals)),
132
- },
133
- ],
134
- [
135
- "circle",
136
- {
137
- cx: ((n - 1) * s) | 0,
138
- cy: math.fitClamped(vals[n - 1], opts.min, opts.max, h, r) | 0,
139
- r,
140
- fill: opts.col,
141
- },
142
- ],
143
- ];
144
- };
145
-
146
- const fpsCounter = (_opts) => {
147
- const opts = Object.assign({ history: 25, smooth: 5, labelPeriod: 250, sparkline: {} }, _opts);
148
- return {
149
- init() {
150
- this.last = Date.now();
151
- this.lastLabel = this.last;
152
- this.buffer = [];
153
- this.ma = transducers.step(transducersStats.sma(opts.smooth));
154
- },
155
- render() {
156
- const t = Date.now();
157
- const fps = 1000 / (t - this.last);
158
- this.last = t;
159
- if (!this.buffer)
160
- return ["div"];
161
- const smoothFps = this.ma(fps);
162
- if (!smoothFps)
163
- return ["div"];
164
- this.buffer.push(smoothFps);
165
- this.buffer.length > opts.history && this.buffer.shift();
166
- const updateLabel = t - this.lastLabel > opts.labelPeriod;
167
- updateLabel && (this.lastLabel = t);
168
- return [
169
- "div",
170
- [
171
- sparkline,
172
- Object.assign({ min: 0, max: 65 }, opts.sparkline),
173
- this.buffer,
174
- ],
175
- [
176
- "span",
177
- { __skip: !updateLabel },
178
- smoothFps ? smoothFps.toFixed(2) + " fps" : "",
179
- ],
180
- ];
181
- },
182
- };
183
- };
184
-
185
- const link = (attribs, body) => [
186
- "a",
187
- checks.isString(attribs) ? { href: attribs } : attribs,
188
- body,
189
- ];
190
- const appLink = (_, attribs, onclick, body) => [
191
- "a",
192
- Object.assign({ href: "#", onclick: (e) => {
193
- e.preventDefault();
194
- onclick(e);
195
- } }, attribs),
196
- body,
197
- ];
198
-
199
- const notification = (opts = {}) => {
200
- return (_, args, body) => [
201
- "div",
202
- Object.assign(Object.assign({}, opts.attribs), args.attribs),
203
- opts.icon,
204
- body,
205
- opts.close && args.onclose
206
- ? [appLink, opts.attribsClose, args.onclose, opts.close]
207
- : undefined,
208
- ];
209
- };
210
-
211
- const pager = (_opts) => {
212
- const opts = Object.assign({ navStep: 1, labelFirst: "<<", labelPrev: "<", labelNext: ">", labelLast: ">>" }, _opts);
213
- return (_, id, num, pageLen = 10, maxBts = 5) => {
214
- const bt = opts.button;
215
- const step = opts.navStep;
216
- const maxID = Math.floor(Math.max(0, num - 1) / pageLen);
217
- id = Math.max(Math.min(id, maxID), 0);
218
- return [
219
- opts.root,
220
- [
221
- opts.groupPrev,
222
- bt(0, id, maxID, opts.labelFirst, !id),
223
- bt(Math.max(id - step, 0), id, maxID, opts.labelPrev, !id),
224
- ],
225
- [
226
- opts.groupPages,
227
- transducers.map((i) => bt(i, id, maxID, i + 1, i === id), pageRange(id, maxID, maxBts)),
228
- ],
229
- [
230
- opts.groupNext,
231
- bt(Math.min(id + step, maxID), id, maxID, opts.labelNext, id >= maxID),
232
- bt(maxID, id, maxID, opts.labelLast, id >= maxID),
233
- ],
234
- ];
235
- };
236
- };
237
- const pageRange = (id, maxID, maxBt) => {
238
- if (maxID > maxBt - 1) {
239
- const from = Math.max(Math.min(id - (maxBt >> 1), maxID - maxBt + 1), 0);
240
- return transducers.range(from, from + maxBt);
241
- }
242
- return transducers.range(0, maxID + 1);
243
- };
244
-
245
- const title = (_opts) => {
246
- const opts = Object.assign({ element: "h1", attribs: {}, subElement: "small", subAttribs: {} }, _opts);
247
- return (_, title, subtitle) => [
248
- opts.element,
249
- opts.attribs,
250
- title,
251
- subtitle ? [opts.subElement, opts.subAttribs, subtitle] : undefined,
252
- ];
253
- };
254
-
255
- const DEFAULT_OPTS = {
256
- anim: 100,
257
- pad: 1,
258
- margin: 0,
259
- vertical: false,
260
- bgOn: { fill: "#000" },
261
- bgOff: { fill: "#999" },
262
- fgOn: { fill: "#fff" },
263
- fgOff: { fill: "#fff" },
264
- };
265
- const slideToggleDot = (opts = {}) => {
266
- const _opts = Object.assign(Object.assign({ r: 5 }, DEFAULT_OPTS), opts);
267
- const { r, pad, margin, vertical } = _opts;
268
- const m2 = margin * 2;
269
- const br = r + pad;
270
- const cx = br + margin;
271
- const width = (r * 2 + pad) * 2;
272
- const height = br * 2;
273
- const totalW = width + m2;
274
- const totalH = height + m2;
275
- const svgSize = vertical
276
- ? { width: totalH, height: totalW }
277
- : { width: totalW, height: totalH };
278
- const style = { transition: `all ${_opts.anim}ms ease-out` };
279
- const bgOn = Object.assign(Object.assign({ x: margin, y: margin, rx: br, ry: br }, (vertical ? { width: height, height: width } : { width, height })), _opts.bgOn);
280
- const bgOff = Object.assign(Object.assign({}, bgOn), _opts.bgOff);
281
- const shapeOn = Object.assign(Object.assign(Object.assign({}, (vertical ? { cx, cy: cx } : { cx: width + margin - br, cy: cx })), _opts.fgOn), { style,
282
- r });
283
- const shapeOff = Object.assign(Object.assign(Object.assign({}, shapeOn), (vertical ? { cy: width + margin - br } : { cx })), _opts.fgOff);
284
- return (_, attribs, state) => [
285
- "svg",
286
- Object.assign(Object.assign({}, svgSize), attribs),
287
- ["rect", state ? bgOn : bgOff],
288
- ["circle", state ? shapeOn : shapeOff],
289
- ];
290
- };
291
- const slideToggleRect = (opts = {}) => {
292
- const _opts = Object.assign(Object.assign({ w: 10, h: 10 }, DEFAULT_OPTS), opts);
293
- const { w, h, pad, margin, vertical } = _opts;
294
- const m2 = margin * 2;
295
- const pm = pad + margin;
296
- const width = vertical ? w + pad * 2 : (w + pad) * 2;
297
- const height = vertical ? (h + pad) * 2 : h + pad * 2;
298
- const svgSize = { width: width + m2, height: height + m2 };
299
- const style = { transition: `all ${_opts.anim}ms ease-out` };
300
- const bgOn = Object.assign(Object.assign({}, _opts.bgOn), { width,
301
- height, x: margin, y: margin });
302
- const bgOff = Object.assign(Object.assign({}, bgOn), _opts.bgOff);
303
- const shapeOn = Object.assign(Object.assign(Object.assign({}, (vertical
304
- ? { x: pm, y: pm }
305
- : { x: width + margin - pad - w, y: pm })), _opts.fgOn), { style, width: w, height: h });
306
- const shapeOff = Object.assign(Object.assign(Object.assign({}, shapeOn), (vertical ? { y: height + margin - pad - h } : { x: pm })), _opts.fgOff);
307
- return (_, attribs, state) => [
308
- "svg",
309
- Object.assign(Object.assign({}, svgSize), attribs),
310
- ["rect", state ? bgOn : bgOff],
311
- ["rect", state ? shapeOn : shapeOff],
312
- ];
313
- };
314
-
315
- exports.appLink = appLink;
316
- exports.button = button;
317
- exports.buttonGroup = buttonGroup;
318
- exports.canvas2D = canvas2D;
319
- exports.canvasWebGL = canvasWebGL;
320
- exports.canvasWebGL2 = canvasWebGL2;
321
- exports.dropdown = dropdown;
322
- exports.fpsCounter = fpsCounter;
323
- exports.groupedDropdown = groupedDropdown;
324
- exports.link = link;
325
- exports.mergeAttribs = mergeAttribs;
326
- exports.notification = notification;
327
- exports.optgroup = optgroup;
328
- exports.option = option;
329
- exports.pager = pager;
330
- exports.slideToggleDot = slideToggleDot;
331
- exports.slideToggleRect = slideToggleRect;
332
- exports.sparkline = sparkline;
333
- exports.title = title;