@stanko/ctrls 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ctrls/ctrl-boolean.js +4 -0
- package/dist/ctrls/ctrl-dual-range.d.ts +2 -2
- package/dist/ctrls/ctrl-dual-range.js +6 -0
- package/dist/ctrls/ctrl-easing.d.ts +2 -2
- package/dist/ctrls/ctrl-easing.js +3 -0
- package/dist/ctrls/ctrl-radio.d.ts +2 -2
- package/dist/ctrls/ctrl-radio.js +2 -1
- package/dist/ctrls/ctrl-range.d.ts +2 -2
- package/dist/ctrls/ctrl-range.js +4 -0
- package/dist/ctrls/ctrl-seed.js +3 -1
- package/dist/ctrls/index.d.ts +30 -34
- package/dist/ctrls.css +0 -4
- package/dist/ctrls.css.map +1 -1
- package/dist/utils/generate-seed.js +3 -1
- package/dist/utils/string-utils.d.ts +1 -0
- package/dist/utils/string-utils.js +6 -3
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { checkIcon } from "../utils/icons";
|
|
2
|
+
import { toHtmlId } from "../utils/string-utils";
|
|
2
3
|
export class BooleanCtrl {
|
|
3
4
|
constructor(config, onChange, onInput) {
|
|
4
5
|
this.type = "boolean";
|
|
@@ -15,9 +16,12 @@ export class BooleanCtrl {
|
|
|
15
16
|
return value.toString();
|
|
16
17
|
};
|
|
17
18
|
this.buildUI = () => {
|
|
19
|
+
const id = toHtmlId(this.name);
|
|
18
20
|
const input = document.createElement("input");
|
|
19
21
|
input.classList.add("ctrls__boolean-input");
|
|
20
22
|
input.setAttribute("type", "checkbox");
|
|
23
|
+
input.setAttribute("id", id);
|
|
24
|
+
input.setAttribute("name", id);
|
|
21
25
|
input.checked = this.value;
|
|
22
26
|
input.addEventListener("change", () => {
|
|
23
27
|
this.value = input.checked;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import DualRangeInput from "@stanko/dual-range-input";
|
|
2
|
-
import type { Ctrl, CtrlChangeHandler, CtrlType,
|
|
2
|
+
import type { Ctrl, CtrlChangeHandler, CtrlType, ConfigFor } from ".";
|
|
3
3
|
export type DualRangeControlOptions = {
|
|
4
4
|
min: number;
|
|
5
5
|
max: number;
|
|
@@ -25,7 +25,7 @@ export declare class DualRangeCtrl implements Ctrl<DualRangeValue> {
|
|
|
25
25
|
maxInput: HTMLInputElement;
|
|
26
26
|
dualRange: DualRangeInput;
|
|
27
27
|
valueSpan: HTMLSpanElement;
|
|
28
|
-
constructor(config:
|
|
28
|
+
constructor(config: ConfigFor<"dual-range">, onChange: CtrlChangeHandler<DualRangeValue>, onInput: CtrlChangeHandler<DualRangeValue>);
|
|
29
29
|
parse: (string: string) => {
|
|
30
30
|
min: number;
|
|
31
31
|
max: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import random from "../utils/random";
|
|
2
2
|
import DualRangeInput from "@stanko/dual-range-input";
|
|
3
3
|
import { roundToStep } from "../utils/round-to-step";
|
|
4
|
+
import { toHtmlId } from "../utils/string-utils";
|
|
4
5
|
export class DualRangeCtrl {
|
|
5
6
|
constructor(config, onChange, onInput) {
|
|
6
7
|
this.type = "dual-range";
|
|
@@ -28,6 +29,7 @@ export class DualRangeCtrl {
|
|
|
28
29
|
};
|
|
29
30
|
this.buildUI = () => {
|
|
30
31
|
const { min, max, step, value } = this;
|
|
32
|
+
const id = toHtmlId(this.name);
|
|
31
33
|
const changeHandler = () => {
|
|
32
34
|
this.value = {
|
|
33
35
|
min: parseFloat(minInput.value),
|
|
@@ -46,6 +48,8 @@ export class DualRangeCtrl {
|
|
|
46
48
|
};
|
|
47
49
|
const minInput = document.createElement("input");
|
|
48
50
|
minInput.setAttribute("type", "range");
|
|
51
|
+
minInput.setAttribute("name", `${id}-min`);
|
|
52
|
+
minInput.setAttribute("id", `${id}-min`);
|
|
49
53
|
minInput.setAttribute("min", min.toString());
|
|
50
54
|
minInput.setAttribute("max", max.toString());
|
|
51
55
|
minInput.setAttribute("step", step.toString());
|
|
@@ -54,6 +58,8 @@ export class DualRangeCtrl {
|
|
|
54
58
|
minInput.addEventListener("change", changeHandler);
|
|
55
59
|
const maxInput = document.createElement("input");
|
|
56
60
|
maxInput.setAttribute("type", "range");
|
|
61
|
+
maxInput.setAttribute("name", `${id}-max`);
|
|
62
|
+
maxInput.setAttribute("id", `${id}-max`);
|
|
57
63
|
maxInput.setAttribute("min", min.toString());
|
|
58
64
|
maxInput.setAttribute("max", max.toString());
|
|
59
65
|
maxInput.setAttribute("step", step.toString());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Ctrl, CtrlChangeHandler, CtrlType,
|
|
1
|
+
import type { Ctrl, CtrlChangeHandler, CtrlType, ConfigFor } from ".";
|
|
2
2
|
export type Easing = [number, number, number, number];
|
|
3
3
|
export declare class EasingCtrl implements Ctrl<Easing> {
|
|
4
4
|
type: CtrlType;
|
|
@@ -15,7 +15,7 @@ export declare class EasingCtrl implements Ctrl<Easing> {
|
|
|
15
15
|
lines: SVGLineElement[];
|
|
16
16
|
path: SVGPathElement;
|
|
17
17
|
presets: Record<string, Easing>;
|
|
18
|
-
constructor(config:
|
|
18
|
+
constructor(config: ConfigFor<"easing">, onChange: CtrlChangeHandler<Easing>, onInput: CtrlChangeHandler<Easing>);
|
|
19
19
|
parse: (string: string) => Easing;
|
|
20
20
|
getRandomValue: () => Easing;
|
|
21
21
|
getDefaultValue: () => Easing;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import random from "../utils/random";
|
|
2
2
|
import BezierEasing from "bezier-easing";
|
|
3
|
+
import { toHtmlId } from "../utils/string-utils";
|
|
3
4
|
const easings = {
|
|
4
5
|
EASE: [0.25, 0.1, 0.25, 1],
|
|
5
6
|
LINEAR: [0, 0, 1, 1],
|
|
@@ -51,6 +52,7 @@ export class EasingCtrl {
|
|
|
51
52
|
};
|
|
52
53
|
this.buildUI = () => {
|
|
53
54
|
const { value } = this;
|
|
55
|
+
const id = toHtmlId(this.name);
|
|
54
56
|
const line1 = document.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
55
57
|
line1.setAttribute("class", "ctrls__easing-line ctrls__easing-line--1");
|
|
56
58
|
line1.setAttribute("x1", "0");
|
|
@@ -213,6 +215,7 @@ export class EasingCtrl {
|
|
|
213
215
|
controlWrapper.classList.add("ctrls__easing-wrapper");
|
|
214
216
|
controlWrapper.appendChild(ticks);
|
|
215
217
|
controlWrapper.appendChild(control);
|
|
218
|
+
controlWrapper.setAttribute("id", id);
|
|
216
219
|
const right = document.createElement("div");
|
|
217
220
|
right.classList.add("ctrls__control-right");
|
|
218
221
|
right.appendChild(controlWrapper);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Ctrl, CtrlChangeHandler, CtrlType,
|
|
1
|
+
import type { Ctrl, CtrlChangeHandler, CtrlType, ConfigFor } from ".";
|
|
2
2
|
type Option = {
|
|
3
3
|
label: string;
|
|
4
4
|
value: string;
|
|
@@ -18,7 +18,7 @@ export declare class RadioCtrl implements Ctrl<string> {
|
|
|
18
18
|
element: HTMLElement;
|
|
19
19
|
columns: 1 | 2 | 3 | 4 | 5;
|
|
20
20
|
id: string;
|
|
21
|
-
constructor(config:
|
|
21
|
+
constructor(config: ConfigFor<"radio">, onChange: CtrlChangeHandler<string>, onInput: CtrlChangeHandler<string>);
|
|
22
22
|
parse: (string: string) => string;
|
|
23
23
|
getRandomValue: () => string;
|
|
24
24
|
getDefaultValue: () => string;
|
package/dist/ctrls/ctrl-radio.js
CHANGED
|
@@ -24,6 +24,7 @@ export class RadioCtrl {
|
|
|
24
24
|
const input = document.createElement("input");
|
|
25
25
|
input.setAttribute("type", "radio");
|
|
26
26
|
input.setAttribute("name", this.id);
|
|
27
|
+
input.setAttribute("id", `${this.id}-${toKebabCase(item.value)}`);
|
|
27
28
|
input.setAttribute("value", item.value);
|
|
28
29
|
input.checked = item.value === value;
|
|
29
30
|
input.addEventListener("change", () => {
|
|
@@ -77,7 +78,7 @@ export class RadioCtrl {
|
|
|
77
78
|
this.columns = config.columns || 3;
|
|
78
79
|
this.name = config.name;
|
|
79
80
|
this.label = config.label || config.name;
|
|
80
|
-
this.id = `
|
|
81
|
+
this.id = `ctrls__${toKebabCase(config.name)}-${getRandomString()}`;
|
|
81
82
|
const defaultValue = this.items.find((item) => item.value === config.defaultValue);
|
|
82
83
|
this.value = defaultValue?.value || this.getDefaultValue();
|
|
83
84
|
this.isRandomizationDisabled = config.isRandomizationDisabled || false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Ctrl, CtrlChangeHandler, CtrlType,
|
|
1
|
+
import type { Ctrl, CtrlChangeHandler, CtrlType, ConfigFor } from ".";
|
|
2
2
|
export declare class RangeCtrl implements Ctrl<number> {
|
|
3
3
|
type: CtrlType;
|
|
4
4
|
name: string;
|
|
@@ -13,7 +13,7 @@ export declare class RangeCtrl implements Ctrl<number> {
|
|
|
13
13
|
element: HTMLElement;
|
|
14
14
|
input: HTMLInputElement;
|
|
15
15
|
valueSpan: HTMLSpanElement;
|
|
16
|
-
constructor(config:
|
|
16
|
+
constructor(config: ConfigFor<"range">, onChange: CtrlChangeHandler<number>, onInput: CtrlChangeHandler<number>);
|
|
17
17
|
parse: (string: string) => number;
|
|
18
18
|
getRandomValue: () => number;
|
|
19
19
|
getDefaultValue: () => number;
|
package/dist/ctrls/ctrl-range.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import random from "../utils/random";
|
|
2
2
|
import { roundToStep } from "../utils/round-to-step";
|
|
3
|
+
import { toHtmlId } from "../utils/string-utils";
|
|
3
4
|
export class RangeCtrl {
|
|
4
5
|
constructor(config, onChange, onInput) {
|
|
5
6
|
this.type = "range";
|
|
@@ -19,9 +20,12 @@ export class RangeCtrl {
|
|
|
19
20
|
};
|
|
20
21
|
this.buildUI = () => {
|
|
21
22
|
const { min, max, step, value } = this;
|
|
23
|
+
const id = toHtmlId(this.name);
|
|
22
24
|
const input = document.createElement("input");
|
|
23
25
|
input.classList.add("ctrls__range-input");
|
|
24
26
|
input.setAttribute("type", "range");
|
|
27
|
+
input.setAttribute("id", id);
|
|
28
|
+
input.setAttribute("name", id);
|
|
25
29
|
input.setAttribute("min", min.toString());
|
|
26
30
|
input.setAttribute("max", max.toString());
|
|
27
31
|
input.setAttribute("step", step.toString());
|
package/dist/ctrls/ctrl-seed.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import generateSeed from "../utils/generate-seed";
|
|
2
2
|
import { refreshIcon } from "../utils/icons";
|
|
3
|
+
import { toHtmlId } from "../utils/string-utils";
|
|
3
4
|
export class SeedCtrl {
|
|
4
5
|
constructor(config, onChange, onInput) {
|
|
5
6
|
this.type = "seed";
|
|
@@ -20,12 +21,13 @@ export class SeedCtrl {
|
|
|
20
21
|
};
|
|
21
22
|
this.buildUI = () => {
|
|
22
23
|
const { value } = this;
|
|
23
|
-
const id =
|
|
24
|
+
const id = toHtmlId(this.name);
|
|
24
25
|
const input = document.createElement("input");
|
|
25
26
|
input.classList.add("ctrls__seed-input");
|
|
26
27
|
input.setAttribute("type", "text");
|
|
27
28
|
input.setAttribute("value", value.toString());
|
|
28
29
|
input.setAttribute("id", id);
|
|
30
|
+
input.setAttribute("name", id);
|
|
29
31
|
input.addEventListener("change", () => {
|
|
30
32
|
this.value = this.parse(input.value);
|
|
31
33
|
this.onChange(this.name, this.value);
|
package/dist/ctrls/index.d.ts
CHANGED
|
@@ -31,57 +31,51 @@ export interface Ctrl<T> {
|
|
|
31
31
|
update: (value: T) => void;
|
|
32
32
|
element: HTMLElement;
|
|
33
33
|
}
|
|
34
|
-
export
|
|
35
|
-
export type ControlConstructor<T> = new (...args: any[]) => T;
|
|
36
|
-
export interface CtrlTypeRegistry {
|
|
34
|
+
export interface CtrlTypeMap {
|
|
37
35
|
boolean: {
|
|
38
|
-
config: CtrlConfig<boolean>;
|
|
39
|
-
instance: BooleanCtrl;
|
|
40
36
|
value: boolean;
|
|
41
37
|
};
|
|
42
38
|
range: {
|
|
43
|
-
config: CtrlConfig<number> & {
|
|
44
|
-
min: number;
|
|
45
|
-
max: number;
|
|
46
|
-
step?: number;
|
|
47
|
-
};
|
|
48
|
-
instance: RangeCtrl;
|
|
49
39
|
value: number;
|
|
40
|
+
min: number;
|
|
41
|
+
max: number;
|
|
42
|
+
step?: number;
|
|
50
43
|
};
|
|
51
44
|
radio: {
|
|
52
|
-
config: CtrlConfig<string> & {
|
|
53
|
-
items: Record<string, string>;
|
|
54
|
-
columns?: 1 | 2 | 3 | 4 | 5;
|
|
55
|
-
};
|
|
56
|
-
instance: RadioCtrl;
|
|
57
45
|
value: string;
|
|
46
|
+
items: Record<string, string>;
|
|
47
|
+
columns?: 1 | 2 | 3 | 4 | 5;
|
|
58
48
|
};
|
|
59
49
|
seed: {
|
|
60
|
-
config: CtrlConfig<string>;
|
|
61
|
-
instance: SeedCtrl;
|
|
62
50
|
value: string;
|
|
63
51
|
};
|
|
64
52
|
easing: {
|
|
65
|
-
config: CtrlConfig<Easing> & {
|
|
66
|
-
presets: Record<string, Easing>;
|
|
67
|
-
};
|
|
68
|
-
instance: EasingCtrl;
|
|
69
53
|
value: Easing;
|
|
54
|
+
presets?: Record<string, Easing>;
|
|
70
55
|
};
|
|
71
56
|
"dual-range": {
|
|
72
|
-
config: CtrlConfig<DualRangeValue> & {
|
|
73
|
-
min: number;
|
|
74
|
-
max: number;
|
|
75
|
-
step?: number;
|
|
76
|
-
};
|
|
77
|
-
instance: DualRangeCtrl;
|
|
78
57
|
value: DualRangeValue;
|
|
58
|
+
min: number;
|
|
59
|
+
max: number;
|
|
60
|
+
step?: number;
|
|
79
61
|
};
|
|
80
62
|
}
|
|
81
|
-
export type TypedControlConfig =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
63
|
+
export type TypedControlConfig = {
|
|
64
|
+
[K in CtrlType]: {
|
|
65
|
+
type: K;
|
|
66
|
+
name: string;
|
|
67
|
+
label?: string;
|
|
68
|
+
defaultValue?: CtrlTypeMap[K]["value"];
|
|
69
|
+
isRandomizationDisabled?: boolean;
|
|
70
|
+
} & Omit<CtrlTypeMap[K], "value">;
|
|
71
|
+
}[CtrlType];
|
|
72
|
+
export type ConfigFor<T extends CtrlType> = Extract<TypedControlConfig, {
|
|
73
|
+
type: T;
|
|
74
|
+
}>;
|
|
75
|
+
type ExtractValues<Configs extends readonly TypedControlConfig[]> = {
|
|
76
|
+
[C in Configs[number] as C["name"]]: CtrlTypeMap[C["type"]]["value"];
|
|
77
|
+
};
|
|
78
|
+
type DerivedProps<Configs extends readonly TypedControlConfig[]> = {
|
|
85
79
|
[C in Extract<Configs[number], {
|
|
86
80
|
type: "easing";
|
|
87
81
|
}> as `${C["name"]}Easing`]: ReturnType<typeof BezierEasing>;
|
|
@@ -90,6 +84,7 @@ type OptionsMap<Configs extends readonly TypedControlConfig[]> = {
|
|
|
90
84
|
type: "seed";
|
|
91
85
|
}> as `${C["name"]}Rng`]: PRNG;
|
|
92
86
|
};
|
|
87
|
+
type OptionsMap<Configs extends readonly TypedControlConfig[]> = ExtractValues<Configs> & DerivedProps<Configs>;
|
|
93
88
|
type ControlsOptions = {
|
|
94
89
|
showRandomizeButton?: boolean;
|
|
95
90
|
storage?: "hash" | "none";
|
|
@@ -97,10 +92,11 @@ type ControlsOptions = {
|
|
|
97
92
|
parent?: Element;
|
|
98
93
|
title?: string;
|
|
99
94
|
};
|
|
95
|
+
type CtrlComponent = BooleanCtrl | RangeCtrl | RadioCtrl | SeedCtrl | EasingCtrl | DualRangeCtrl;
|
|
100
96
|
export declare class Ctrls<Configs extends readonly TypedControlConfig[]> {
|
|
101
97
|
options: ControlsOptions;
|
|
102
|
-
controls:
|
|
103
|
-
controlsMap: Record<string,
|
|
98
|
+
controls: CtrlComponent[];
|
|
99
|
+
controlsMap: Record<string, CtrlComponent>;
|
|
104
100
|
element: HTMLDivElement;
|
|
105
101
|
onChange?: (updatedValues: Partial<ReturnType<typeof this.getValues>>) => void;
|
|
106
102
|
onInput?: (updatedValues: Partial<ReturnType<typeof this.getValues>>) => void;
|
package/dist/ctrls.css
CHANGED
package/dist/ctrls.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../node_modules/@stanko/dual-range-input/dist/index.css","../src/scss/_ctrls.scss"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;;AC3IF;EACE;AAAA;AAAA;EAGA;EACA;EACA;EACA;EACA;EAGA;EACA;EAEA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EACA;EACA;EAGA;EACA;EAGA;EAGA;EAEA;EACA;EAEA;EACA;EAGA;EAGA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;EAGA;EACA;EAEA;EAEA;EACA;EAEA;EAGA;EAEA;EACA;;;AA+CF;EACE;IA3CA;IAEA;IACA;IAGA;IACA;IACA;IACA;IACA;IACA;IAGA;IAGA;IACA;IACA;IAGA;IACA;IAGA;IAGA;IAEA;IAGA;IAGA;AAAA;AAAA;;;AAWF;EAhDE;EAEA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EACA;EACA;EAGA;EACA;EAGA;EAGA;EAEA;EAGA;EAGA;AAAA;AAAA;;;AAiBF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;AAAA;AAAA;EAGE;EACA;EACA;;AAGF;AAAA;EAEE;EACA;EACA;;AAGF;EACE;EACA;;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;;AAGF;EAEE;EACA;;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;;;AAGF;AAGA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;;AAGF;EAEE;;AAGF;EACE;EACA;EACA,YACE;;AAIJ;EACE;;;AAKJ;EACE;EACA;EACA;EACA;EACA;;AAEA;EAEE;EACA;;;AAOA;EACE;;AAGF;AAAA;AAAA;EAEE;;;AAKN;AAEA;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../node_modules/@stanko/dual-range-input/dist/index.css","../src/scss/_ctrls.scss"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;;AC3IF;EACE;AAAA;AAAA;EAGA;EACA;EACA;EACA;EACA;EAGA;EACA;EAEA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EACA;EACA;EAGA;EACA;EAGA;EAGA;EAEA;EACA;EAEA;EACA;EAGA;EAGA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;EAGA;EACA;EAEA;EAEA;EACA;EAEA;EAGA;EAEA;EACA;;;AA+CF;EACE;IA3CA;IAEA;IACA;IAGA;IACA;IACA;IACA;IACA;IACA;IAGA;IAGA;IACA;IACA;IAGA;IACA;IAGA;IAGA;IAEA;IAGA;IAGA;AAAA;AAAA;;;AAWF;EAhDE;EAEA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EAGA;EAGA;EACA;EACA;EAGA;EACA;EAGA;EAGA;EAEA;EAGA;EAGA;AAAA;AAAA;;;AAiBF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;AAAA;AAAA;EAGE;EACA;EACA;;AAGF;AAAA;EAEE;EACA;EACA;;AAGF;EACE;EACA;;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;;AAGF;EAEE;EACA;;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;;;AAGF;AAGA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;;AAGF;EAEE;;AAGF;EACE;EACA;EACA,YACE;;AAIJ;EACE;;;AAKJ;EACE;EACA;EACA;EACA;EACA;;AAEA;EAEE;EACA;;;AAOA;EACE;;AAGF;AAAA;AAAA;EAEE;;;AAKN;AAEA;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;;;AAKA;AAAA;EACE;EACA;EACA;;;AAIJ;AAEA;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;;;AAKJ;EACE;EACA;EACA;;;AAIF;EACE;;;AAIF;EACE;;;AAIF;EACE;EACA;;;AAGF;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;;AAmCJ;EA5BE;EACA;EACA;EACA;EACA;EAEA;;;AA0BF;EAhCE;EACA;EACA;EACA;EACA;EAEA;;;AA8BF;EAtBE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAkBA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;;;AAKF;EAvDE;EACA;EACA;EACA;EACA;EAEA;;;AAqDF;EA7CE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAwCA;EACA;;;AAGF;EACE;EACA;;;AAGF;AAEA;EAGE;;AAEA;EACE;;AANJ;EASE;EACA;EAEA;EACA;EACA;EAEA;EACA;EACA;EACA;EAEA;EACA;EACA;;AAEA;EACE;;;AAIJ;AAEA;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;EAEF;EACA;EACA;;AAEA;EAEE;EACA;;;AAIJ;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;AAEA;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;;AAIJ;EACE;EACA;;AAIE;EACE;;;AAKN;AAEA;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;;AAEA;AAAA;EAEE;EACA;EACA;;;AAIJ;EACE;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YACE;;AAGF;EAEE;EACA;;;AAIJ;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EAEE;;AAEA;EACE;EACA","file":"ctrls.css"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import Alea from "./alea";
|
|
1
2
|
import random from "./random";
|
|
2
3
|
import { words } from "./words";
|
|
4
|
+
const rng = Alea();
|
|
3
5
|
export default function generateSeed() {
|
|
4
6
|
return [1, 2, 3]
|
|
5
7
|
.map(() => {
|
|
6
|
-
const index = random(0, words.length - 1,
|
|
8
|
+
const index = random(0, words.length - 1, rng, 0);
|
|
7
9
|
return words[index];
|
|
8
10
|
})
|
|
9
11
|
.join("-");
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
export const toHtmlId = (str) => {
|
|
2
|
+
return `ctrls__${toKebabCase(str)}`;
|
|
3
|
+
};
|
|
1
4
|
export const toKebabCase = (str) => {
|
|
2
|
-
return str.replace(/([a-z])([A-Z])/g,
|
|
5
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
3
6
|
};
|
|
4
7
|
export const toCamelCase = (str) => {
|
|
5
|
-
return str.replace(/([-_ ][a-z])/g, (group) => group.toUpperCase().replace(/[-_ ]/,
|
|
8
|
+
return str.replace(/([-_ ][a-z])/g, (group) => group.toUpperCase().replace(/[-_ ]/, ""));
|
|
6
9
|
};
|
|
7
10
|
export const toSpaceCase = (str) => {
|
|
8
|
-
return str.replace(/([a-z])([A-Z])/g,
|
|
11
|
+
return str.replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase();
|
|
9
12
|
};
|