builder-settings-types 0.0.32 → 0.0.35
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.
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(l,t){for(const e in l)if(l.hasOwnProperty(e)){const s=l[e];t(e,s)}}class C{setOnChange(t){this.onChange=t,g(this.settings,(e,s)=>{s.setOnChange(t)})}constructor(t){this.title=t.title,this.settings=t.settings,Object.assign(this,t.settings)}draw(){const t=document.createElement("div");t.className="setting-group";const e=document.createElement("div");e.className="setting-group-title";const s=document.createElement("h3");s.textContent=this.title;const n=document.createElement("span");n.className="setting-group-arrow",n.innerHTML=`
|
|
2
2
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
3
3
|
<path d="M5 7.5L10 12.5L15 7.5" stroke="#344054" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
4
|
</svg>
|
|
5
|
-
`;const i=document.createElement("div");i.className="setting-group-content";for(const
|
|
5
|
+
`;const i=document.createElement("div");i.className="setting-group-content";for(const a in this.settings){const u=this.settings[a].draw();i.appendChild(u)}return e.onclick=()=>{i.classList.toggle("collapsed"),n.classList.toggle("rotated")},e.appendChild(s),e.appendChild(n),t.appendChild(e),t.appendChild(i),t}}function v(l){switch(l){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0]}}class m{constructor(t={}){this.props=t,this.value=this.props.default,this.title=t.title||"",this.value=t.default}setOnChange(t){this.onChange=t}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const i=document.createElement("div");if(i.className="icon-container",t.icon){let a=this.createIcon(t.icon,t.iconClassName);i.appendChild(a)}if(t.title){const a=this.createLabel(t.title,t.labelClassName);i.appendChild(a)}e.appendChild(i)}const s=document.createElement("div");s.className=t.inputClassName||"";const n=document.createElement("input");return n.value=t.value||v(t.inputType),n.type=t.inputType,n.oninput=i=>{const a=i.target;let c=a.value;t.inputType==="number"?c=Number(a.value):(t.inputType==="color"||t.inputType==="date")&&(c=a.value),this.value=c,this.onChange&&this.onChange(this.value)},t.inputCustomizer&&t.inputCustomizer(n),s.appendChild(n),e.appendChild(s),e}createLabel(t,e){const s=document.createElement("span");return s.textContent=t,s.className="input-label "+(e||""),s}createIcon(t,e){const s=document.createElement("span");return s.className="input-icon "+(e||""),s.innerHTML=t,s}}class h extends m{constructor(t={}){super(t),this.inputType="number"}draw(){const t=e=>{this.props.minValue!==void 0&&(e.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(e.max=String(this.props.maxValue)),this.props.className&&e.classList.add(this.props.className),e.addEventListener("input",()=>{const s=this.props.minValue??Number.MIN_SAFE_INTEGER,n=this.props.maxValue??Number.MAX_SAFE_INTEGER;let i=Number(e.value);i<s&&(i=s),i>n&&(i=n),e.value=String(i)})};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,icon:this.props.icon,inputClassName:"number-setting-input "+this.props.inputClassName,wrapperClassName:"number-setting-wrapper "+this.props.wrapperClassName,inputCustomizer:t})}}class w extends C{constructor(){super({title:"Margin",settings:{margin:new h({title:"Margin All"}),marginTop:new h({title:"Margin Top"}),marginRight:new h({title:"Margin Right"}),marginBottom:new h({title:"Margin Bottom"}),marginLeft:new h({title:"Margin Left"})}})}getCssCode(){return`
|
|
6
6
|
margin-botton: ${this.settings.marginBottom.value}px;
|
|
7
7
|
margin-top: ${this.settings.marginTop.value}px;
|
|
8
8
|
margin-right: ${this.settings.marginRight.value}px;
|
|
9
9
|
margin-left: ${this.settings.marginLeft.value}px;
|
|
10
|
-
`}}class
|
|
10
|
+
`}}class N extends m{constructor(t){super(t),this.inputType="color",this.icon="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>"}draw(){const t=document.createElement("div");t.className="color-setting-wrapper";const e=document.createElement("div");e.className="icon-container";const s=this.createIcon(this.icon),n=this.createLabel("Color");n.className="color-text",e.appendChild(s),e.appendChild(n);const i=document.createElement("div");i.className="color-input-wrapper";let a,c;a=this.createInput({value:this.value,inputType:"text",inputClassName:"color-text-input",inputCustomizer:p=>{p.oninput=r=>{var d;let o=r.target.value;this.value=o,(d=this.onChange)==null||d.call(this,o),u.style.backgroundColor=o}}}),c=this.createInput({value:this.value,inputType:this.inputType,inputClassName:"color-picker",inputCustomizer:p=>{p.oninput=r=>{var d;let o=r.target.value;this.value=o,(d=this.onChange)==null||d.call(this,o),u.style.backgroundColor=o}}});const u=document.createElement("div");return u.className="color-preview",u.style.backgroundColor=this.value||"",c.oninput=p=>{var o;let r=p.target.value;this.value=r,(o=this.onChange)==null||o.call(this,r),u.style.backgroundColor=r},a.oninput=p=>{var o;let r=p.target.value;this.value=r,(o=this.onChange)==null||o.call(this,r),u.style.backgroundColor=r},i.appendChild(u),i.appendChild(a),i.appendChild(c),t.appendChild(e),t.appendChild(i),t}}class f extends m{constructor(t={}){super(t),this.inputType="text"}draw(){return this.createInput({value:this.value,inputType:this.inputType})}}class y extends h{constructor(t){super({...t,minValue:0,maxValue:100,icon:x,title:t.title||"Opacity",inputClassName:"number-setting-input",wrapperClassName:"opacity-setting-wrapper"}),this.inputType="number"}}const x=`
|
|
11
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
12
|
+
<path d="M3.69749 15.365C3.54749 15.365 3.40502 15.305 3.30002 15.2C1.77752 13.6775 0.9375 11.6525 0.9375 9.5C0.9375 5.0525 4.5525 1.4375 9 1.4375C11.1525 1.4375 13.1775 2.2775 14.7 3.8C14.805 3.905 14.865 4.0475 14.865 4.1975C14.865 4.3475 14.805 4.49 14.7 4.595L4.09502 15.2C3.99002 15.305 3.84749 15.365 3.69749 15.365ZM9 2.5625C5.175 2.5625 2.0625 5.675 2.0625 9.5C2.0625 11.165 2.64751 12.74 3.71251 13.9925L13.4925 4.2125C12.24 3.1475 10.665 2.5625 9 2.5625Z" fill="#667085"/>
|
|
13
|
+
<path d="M9.00026 17.5623C6.84776 17.5623 4.82278 16.7223 3.30028 15.1998C3.19528 15.0948 3.13525 14.9523 3.13525 14.8023C3.13525 14.6523 3.19528 14.5098 3.30028 14.4048L13.9052 3.79984C14.1227 3.58234 14.4827 3.58234 14.7002 3.79984C16.2227 5.32234 17.0628 7.34734 17.0628 9.49984C17.0628 13.9473 13.4478 17.5623 9.00026 17.5623ZM4.50777 14.7873C5.76027 15.8523 7.33526 16.4373 9.00026 16.4373C12.8253 16.4373 15.9378 13.3248 15.9378 9.49984C15.9378 7.83484 15.3527 6.25984 14.2878 5.00734L4.50777 14.7873Z" fill="#667085"/>
|
|
14
|
+
</svg>
|
|
15
|
+
`;class b extends m{constructor(t={}){super(t),this.inputType="select"}draw(){const t=document.createElement("div");if(t.classList.add("custom-select-container"),this.props.title){const n=document.createElement("label");n.textContent=this.props.title,n.classList.add("custom-select-title"),t.appendChild(n)}if(this.props.icon){const n=document.createElement("span");n.innerHTML=this.props.icon,n.classList.add("custom-select-icon"),t.appendChild(n)}const e=document.createElement("select");e.classList.add("custom-select"),e.onchange=n=>{var i;(i=this.onChange)==null||i.call(this,n.target.value)};let s=[];return this.props.getOptions&&(s=this.props.getOptions()),this.props.options&&s.push(...this.props.options),s.forEach(({value:n,name:i})=>{const a=document.createElement("option");a.value=n,a.textContent=i,e.appendChild(a)}),this.props.value&&(e.value=this.props.value),t.appendChild(e),t}}exports.ColorSetting=N;exports.MarginSettingGroup=w;exports.NumberSetting=h;exports.OpacitySetting=y;exports.SelectSetting=b;exports.Setting=m;exports.SettingGroup=C;exports.StringSetting=f;exports.iterateSettings=g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.setting-group{padding:16px;border-bottom:solid 1px var(--color-border);border-radius:8px;background-color:var(--color-bg)
|
|
1
|
+
.setting-group{padding:16px;display:flex;flex-direction:column;gap:8px;border-bottom:solid 1px var(--color-border);border-radius:8px;background-color:var(--color-bg)}.setting-group .setting-group{margin-bottom:8px;background-color:var(--color-white)!important;padding:12px;border-bottom:unset;border:1px solid var(--color-border-secondary);box-shadow:0 12px 16px -4px #10182814,0 4px 6px -2px #10182808}.setting-group-title{display:flex;align-items:center;justify-content:space-between;cursor:pointer}.setting-group-title h3{font-size:14px;font-weight:700;line-height:24px}.setting-group-arrow{display:flex;transition:transform .3s ease-in-out}.setting-group-arrow.rotated{transform:rotate(180deg)}.setting-group-content{display:flex;flex-direction:column;gap:8px;overflow:hidden;max-height:500px;opacity:1;transition:max-height .5s ease-in-out,opacity .4s ease-in-out}.setting-group-content.collapsed{max-height:0;opacity:0}.icon-container{display:flex;align-items:center;gap:4px}.icon-container .input-icon{display:flex;align-items:center;justify-content:center;color:var(--color-text)}.icon-container .input-label{color:var(--color-text)}.number-setting-wrapper{display:flex;justify-content:space-between;align-items:center;gap:16px}.number-setting-input{width:120px;padding:8px;border-radius:8px;border:1px solid var(--color-border);background:var(--color-bg)}.color-setting-wrapper{display:flex;align-items:center;justify-content:space-between;gap:2px}.icon-container{display:flex;align-items:center;gap:.25rem}.color-text{color:var(--color-text)}.color-input-wrapper{position:relative;padding:8px 8px 8px 4px;width:120px;height:33px;display:flex;align-items:center;gap:8px;border:1px solid var(--color-border);border-radius:8px;background-color:var(--color-bg)}.color-text-input{border:none;outline:none;width:60%;color:var(--color-input-text);font-size:14px;text-align:center;background:transparent}.color-picker{position:absolute;left:0;top:0;width:25px;height:25px;opacity:0;cursor:pointer}.color-preview{width:25px;height:25px;border-radius:4px;border:1px solid #ccc;margin-right:6px}.opacity-setting-wrapper{display:flex;align-items:center;justify-content:space-between}.opacity-setting-input{width:120px;padding:8px;border-radius:8px;border:1px solid var(--color-border);background:var(--color-bg)}.custom-select-container{display:flex;flex-direction:column;gap:4px;max-width:200px}.custom-select-title{font-size:14px;font-weight:700;color:#333}.custom-select-icon{display:flex;align-items:center}.custom-select{padding:8px;font-size:14px;border:1px solid #ccc;border-radius:4px;cursor:pointer}.custom-select:focus{border-color:#007bff;outline:none}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
function
|
|
2
|
-
for (const e in
|
|
3
|
-
if (
|
|
4
|
-
const
|
|
5
|
-
t(e,
|
|
1
|
+
function g(l, t) {
|
|
2
|
+
for (const e in l)
|
|
3
|
+
if (l.hasOwnProperty(e)) {
|
|
4
|
+
const s = l[e];
|
|
5
|
+
t(e, s);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
class
|
|
8
|
+
class C {
|
|
9
9
|
setOnChange(t) {
|
|
10
|
-
this.onChange = t,
|
|
11
|
-
|
|
10
|
+
this.onChange = t, g(this.settings, (e, s) => {
|
|
11
|
+
s.setOnChange(t);
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
constructor(t) {
|
|
@@ -19,62 +19,112 @@ class d {
|
|
|
19
19
|
t.className = "setting-group";
|
|
20
20
|
const e = document.createElement("div");
|
|
21
21
|
e.className = "setting-group-title";
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
22
|
+
const s = document.createElement("h3");
|
|
23
|
+
s.textContent = this.title;
|
|
24
|
+
const n = document.createElement("span");
|
|
25
|
+
n.className = "setting-group-arrow", n.innerHTML = `
|
|
26
26
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
27
27
|
<path d="M5 7.5L10 12.5L15 7.5" stroke="#344054" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"/>
|
|
28
28
|
</svg>
|
|
29
29
|
`;
|
|
30
30
|
const i = document.createElement("div");
|
|
31
31
|
i.className = "setting-group-content";
|
|
32
|
-
for (const
|
|
33
|
-
const
|
|
34
|
-
i.appendChild(
|
|
32
|
+
for (const a in this.settings) {
|
|
33
|
+
const u = this.settings[a].draw();
|
|
34
|
+
i.appendChild(u);
|
|
35
35
|
}
|
|
36
36
|
return e.onclick = () => {
|
|
37
|
-
i.classList.toggle("collapsed"),
|
|
38
|
-
}, e.appendChild(
|
|
37
|
+
i.classList.toggle("collapsed"), n.classList.toggle("rotated");
|
|
38
|
+
}, e.appendChild(s), e.appendChild(n), t.appendChild(e), t.appendChild(i), t;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function v(l) {
|
|
42
|
+
switch (l) {
|
|
43
|
+
case "number":
|
|
44
|
+
return 0;
|
|
45
|
+
case "text":
|
|
46
|
+
return "";
|
|
47
|
+
case "select":
|
|
48
|
+
return null;
|
|
49
|
+
case "color":
|
|
50
|
+
return "#000000";
|
|
51
|
+
case "date":
|
|
52
|
+
return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
39
53
|
}
|
|
40
54
|
}
|
|
41
|
-
class
|
|
55
|
+
class m {
|
|
42
56
|
constructor(t = {}) {
|
|
43
|
-
this.props = t, this.value = this.props.default, this.title = t.title || "
|
|
57
|
+
this.props = t, this.value = this.props.default, this.title = t.title || "", this.value = t.default;
|
|
44
58
|
}
|
|
45
59
|
setOnChange(t) {
|
|
46
60
|
this.onChange = t;
|
|
47
61
|
}
|
|
48
|
-
createInput(t
|
|
62
|
+
createInput(t) {
|
|
63
|
+
t = { ...this.props.inputProps, ...t };
|
|
64
|
+
const e = document.createElement("div");
|
|
65
|
+
if (e.className = t.wrapperClassName || "", t.title || t.icon) {
|
|
66
|
+
const i = document.createElement("div");
|
|
67
|
+
if (i.className = "icon-container", t.icon) {
|
|
68
|
+
let a = this.createIcon(t.icon, t.iconClassName);
|
|
69
|
+
i.appendChild(a);
|
|
70
|
+
}
|
|
71
|
+
if (t.title) {
|
|
72
|
+
const a = this.createLabel(t.title, t.labelClassName);
|
|
73
|
+
i.appendChild(a);
|
|
74
|
+
}
|
|
75
|
+
e.appendChild(i);
|
|
76
|
+
}
|
|
77
|
+
const s = document.createElement("div");
|
|
78
|
+
s.className = t.inputClassName || "";
|
|
49
79
|
const n = document.createElement("input");
|
|
50
|
-
return n.value = t, n.type =
|
|
51
|
-
const
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
}, n;
|
|
80
|
+
return n.value = t.value || v(t.inputType), n.type = t.inputType, n.oninput = (i) => {
|
|
81
|
+
const a = i.target;
|
|
82
|
+
let c = a.value;
|
|
83
|
+
t.inputType === "number" ? c = Number(a.value) : (t.inputType === "color" || t.inputType === "date") && (c = a.value), this.value = c, this.onChange && this.onChange(this.value);
|
|
84
|
+
}, t.inputCustomizer && t.inputCustomizer(n), s.appendChild(n), e.appendChild(s), e;
|
|
85
|
+
}
|
|
86
|
+
createLabel(t, e) {
|
|
87
|
+
const s = document.createElement("span");
|
|
88
|
+
return s.textContent = t, s.className = "input-label " + (e || ""), s;
|
|
89
|
+
}
|
|
90
|
+
createIcon(t, e) {
|
|
91
|
+
const s = document.createElement("span");
|
|
92
|
+
return s.className = "input-icon " + (e || ""), s.innerHTML = t, s;
|
|
55
93
|
}
|
|
56
94
|
}
|
|
57
|
-
class
|
|
95
|
+
class h extends m {
|
|
58
96
|
constructor(t = {}) {
|
|
59
|
-
super(t), this.
|
|
97
|
+
super(t), this.inputType = "number";
|
|
60
98
|
}
|
|
61
99
|
draw() {
|
|
62
|
-
const t =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
100
|
+
const t = (e) => {
|
|
101
|
+
this.props.minValue !== void 0 && (e.min = String(this.props.minValue)), this.props.maxValue !== void 0 && (e.max = String(this.props.maxValue)), this.props.className && e.classList.add(this.props.className), e.addEventListener("input", () => {
|
|
102
|
+
const s = this.props.minValue ?? Number.MIN_SAFE_INTEGER, n = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
|
|
103
|
+
let i = Number(e.value);
|
|
104
|
+
i < s && (i = s), i > n && (i = n), e.value = String(i);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
return this.createInput({
|
|
108
|
+
value: this.value,
|
|
109
|
+
inputType: this.inputType,
|
|
110
|
+
title: this.props.title,
|
|
111
|
+
icon: this.props.icon,
|
|
112
|
+
inputClassName: "number-setting-input " + this.props.inputClassName,
|
|
113
|
+
wrapperClassName: "number-setting-wrapper " + this.props.wrapperClassName,
|
|
114
|
+
inputCustomizer: t
|
|
115
|
+
});
|
|
66
116
|
}
|
|
67
117
|
}
|
|
68
|
-
class
|
|
118
|
+
class N extends C {
|
|
69
119
|
constructor() {
|
|
70
120
|
super({
|
|
71
121
|
title: "Margin",
|
|
72
122
|
settings: {
|
|
73
|
-
margin: new
|
|
74
|
-
marginTop: new
|
|
75
|
-
marginRight: new
|
|
76
|
-
marginBottom: new
|
|
77
|
-
marginLeft: new
|
|
123
|
+
margin: new h({ title: "Margin All" }),
|
|
124
|
+
marginTop: new h({ title: "Margin Top" }),
|
|
125
|
+
marginRight: new h({ title: "Margin Right" }),
|
|
126
|
+
marginBottom: new h({ title: "Margin Bottom" }),
|
|
127
|
+
marginLeft: new h({ title: "Margin Left" })
|
|
78
128
|
}
|
|
79
129
|
});
|
|
80
130
|
}
|
|
@@ -87,9 +137,9 @@ class m extends d {
|
|
|
87
137
|
`;
|
|
88
138
|
}
|
|
89
139
|
}
|
|
90
|
-
class
|
|
140
|
+
class f extends m {
|
|
91
141
|
constructor(t) {
|
|
92
|
-
super(t), this.inputType = "color";
|
|
142
|
+
super(t), this.inputType = "color", this.icon = "<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";
|
|
93
143
|
}
|
|
94
144
|
// onChange?: (color: string) => void
|
|
95
145
|
draw() {
|
|
@@ -97,38 +147,111 @@ class C extends g {
|
|
|
97
147
|
t.className = "color-setting-wrapper";
|
|
98
148
|
const e = document.createElement("div");
|
|
99
149
|
e.className = "icon-container";
|
|
100
|
-
const n =
|
|
101
|
-
n.
|
|
102
|
-
const a = document.createElement("span");
|
|
103
|
-
a.textContent = "Color", a.className = "color-text", e.appendChild(n), e.appendChild(a);
|
|
150
|
+
const s = this.createIcon(this.icon), n = this.createLabel("Color");
|
|
151
|
+
n.className = "color-text", e.appendChild(s), e.appendChild(n);
|
|
104
152
|
const i = document.createElement("div");
|
|
105
153
|
i.className = "color-input-wrapper";
|
|
106
|
-
let
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
154
|
+
let a, c;
|
|
155
|
+
a = this.createInput({
|
|
156
|
+
value: this.value,
|
|
157
|
+
inputType: "text",
|
|
158
|
+
inputClassName: "color-text-input",
|
|
159
|
+
// icon: this.icon,
|
|
160
|
+
inputCustomizer: (p) => {
|
|
161
|
+
p.oninput = (r) => {
|
|
162
|
+
var d;
|
|
163
|
+
let o = r.target.value;
|
|
164
|
+
this.value = o, (d = this.onChange) == null || d.call(this, o), u.style.backgroundColor = o;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}), c = this.createInput({
|
|
168
|
+
value: this.value,
|
|
169
|
+
inputType: this.inputType,
|
|
170
|
+
inputClassName: "color-picker",
|
|
171
|
+
inputCustomizer: (p) => {
|
|
172
|
+
p.oninput = (r) => {
|
|
173
|
+
var d;
|
|
174
|
+
let o = r.target.value;
|
|
175
|
+
this.value = o, (d = this.onChange) == null || d.call(this, o), u.style.backgroundColor = o;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
const u = document.createElement("div");
|
|
180
|
+
return u.className = "color-preview", u.style.backgroundColor = this.value || "", c.oninput = (p) => {
|
|
181
|
+
var o;
|
|
182
|
+
let r = p.target.value;
|
|
183
|
+
this.value = r, (o = this.onChange) == null || o.call(this, r), u.style.backgroundColor = r;
|
|
184
|
+
}, a.oninput = (p) => {
|
|
185
|
+
var o;
|
|
186
|
+
let r = p.target.value;
|
|
187
|
+
this.value = r, (o = this.onChange) == null || o.call(this, r), u.style.backgroundColor = r;
|
|
188
|
+
}, i.appendChild(u), i.appendChild(a), i.appendChild(c), t.appendChild(e), t.appendChild(i), t;
|
|
116
189
|
}
|
|
117
190
|
}
|
|
118
|
-
class
|
|
191
|
+
class x extends m {
|
|
119
192
|
constructor(t = {}) {
|
|
120
193
|
super(t), this.inputType = "text";
|
|
121
194
|
}
|
|
122
195
|
draw() {
|
|
123
|
-
return this.createInput(
|
|
196
|
+
return this.createInput({
|
|
197
|
+
value: this.value,
|
|
198
|
+
inputType: this.inputType
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
class E extends h {
|
|
203
|
+
constructor(t) {
|
|
204
|
+
super({
|
|
205
|
+
...t,
|
|
206
|
+
minValue: 0,
|
|
207
|
+
maxValue: 100,
|
|
208
|
+
icon: w,
|
|
209
|
+
title: t.title || "Opacity",
|
|
210
|
+
inputClassName: "number-setting-input",
|
|
211
|
+
wrapperClassName: "opacity-setting-wrapper"
|
|
212
|
+
}), this.inputType = "number";
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const w = `
|
|
216
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
217
|
+
<path d="M3.69749 15.365C3.54749 15.365 3.40502 15.305 3.30002 15.2C1.77752 13.6775 0.9375 11.6525 0.9375 9.5C0.9375 5.0525 4.5525 1.4375 9 1.4375C11.1525 1.4375 13.1775 2.2775 14.7 3.8C14.805 3.905 14.865 4.0475 14.865 4.1975C14.865 4.3475 14.805 4.49 14.7 4.595L4.09502 15.2C3.99002 15.305 3.84749 15.365 3.69749 15.365ZM9 2.5625C5.175 2.5625 2.0625 5.675 2.0625 9.5C2.0625 11.165 2.64751 12.74 3.71251 13.9925L13.4925 4.2125C12.24 3.1475 10.665 2.5625 9 2.5625Z" fill="#667085"/>
|
|
218
|
+
<path d="M9.00026 17.5623C6.84776 17.5623 4.82278 16.7223 3.30028 15.1998C3.19528 15.0948 3.13525 14.9523 3.13525 14.8023C3.13525 14.6523 3.19528 14.5098 3.30028 14.4048L13.9052 3.79984C14.1227 3.58234 14.4827 3.58234 14.7002 3.79984C16.2227 5.32234 17.0628 7.34734 17.0628 9.49984C17.0628 13.9473 13.4478 17.5623 9.00026 17.5623ZM4.50777 14.7873C5.76027 15.8523 7.33526 16.4373 9.00026 16.4373C12.8253 16.4373 15.9378 13.3248 15.9378 9.49984C15.9378 7.83484 15.3527 6.25984 14.2878 5.00734L4.50777 14.7873Z" fill="#667085"/>
|
|
219
|
+
</svg>
|
|
220
|
+
`;
|
|
221
|
+
class y extends m {
|
|
222
|
+
constructor(t = {}) {
|
|
223
|
+
super(t), this.inputType = "select";
|
|
224
|
+
}
|
|
225
|
+
draw() {
|
|
226
|
+
const t = document.createElement("div");
|
|
227
|
+
if (t.classList.add("custom-select-container"), this.props.title) {
|
|
228
|
+
const n = document.createElement("label");
|
|
229
|
+
n.textContent = this.props.title, n.classList.add("custom-select-title"), t.appendChild(n);
|
|
230
|
+
}
|
|
231
|
+
if (this.props.icon) {
|
|
232
|
+
const n = document.createElement("span");
|
|
233
|
+
n.innerHTML = this.props.icon, n.classList.add("custom-select-icon"), t.appendChild(n);
|
|
234
|
+
}
|
|
235
|
+
const e = document.createElement("select");
|
|
236
|
+
e.classList.add("custom-select"), e.onchange = (n) => {
|
|
237
|
+
var i;
|
|
238
|
+
(i = this.onChange) == null || i.call(this, n.target.value);
|
|
239
|
+
};
|
|
240
|
+
let s = [];
|
|
241
|
+
return this.props.getOptions && (s = this.props.getOptions()), this.props.options && s.push(...this.props.options), s.forEach(({ value: n, name: i }) => {
|
|
242
|
+
const a = document.createElement("option");
|
|
243
|
+
a.value = n, a.textContent = i, e.appendChild(a);
|
|
244
|
+
}), this.props.value && (e.value = this.props.value), t.appendChild(e), t;
|
|
124
245
|
}
|
|
125
246
|
}
|
|
126
247
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
248
|
+
f as ColorSetting,
|
|
249
|
+
N as MarginSettingGroup,
|
|
250
|
+
h as NumberSetting,
|
|
251
|
+
E as OpacitySetting,
|
|
252
|
+
y as SelectSetting,
|
|
253
|
+
m as Setting,
|
|
254
|
+
C as SettingGroup,
|
|
255
|
+
x as StringSetting,
|
|
256
|
+
g as iterateSettings
|
|
134
257
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export declare class ColorSetting extends Setting<string> {
|
|
1
|
+
export declare class ColorSetting extends Setting<string, ColorSettingProps> {
|
|
2
2
|
inputType: InputTypes;
|
|
3
3
|
constructor(props: ColorSettingProps);
|
|
4
|
+
icon: string;
|
|
4
5
|
draw(): HTMLElement;
|
|
5
6
|
}
|
|
6
7
|
|
|
@@ -15,9 +16,21 @@ export declare interface IDrawable {
|
|
|
15
16
|
draw(): HTMLElement;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
declare type InputProps = {
|
|
20
|
+
iconClassName?: string;
|
|
21
|
+
labelClassName?: string;
|
|
22
|
+
value: any;
|
|
23
|
+
inputType: InputTypes;
|
|
24
|
+
title?: string;
|
|
25
|
+
icon?: string;
|
|
26
|
+
inputCustomizer?: (input: HTMLInputElement) => void;
|
|
27
|
+
inputClassName?: string;
|
|
28
|
+
wrapperClassName?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
18
31
|
export declare type InputTypes = 'number' | 'text' | 'select' | 'color' | 'date';
|
|
19
32
|
|
|
20
|
-
export declare function iterateSettings<T extends Record<string, Setting<any> | SettingGroup<any>>>(settings: T, callback: (key: string, setting: Setting<any> | SettingGroup<any>) => void): void;
|
|
33
|
+
export declare function iterateSettings<T extends Record<string, Setting<any, any> | SettingGroup<any>>>(settings: T, callback: (key: string, setting: Setting<any, any> | SettingGroup<any>) => void): void;
|
|
21
34
|
|
|
22
35
|
export declare class MarginSettingGroup extends SettingGroup<{
|
|
23
36
|
margin: NumberSetting;
|
|
@@ -30,34 +43,63 @@ export declare class MarginSettingGroup extends SettingGroup<{
|
|
|
30
43
|
getCssCode(): string;
|
|
31
44
|
}
|
|
32
45
|
|
|
33
|
-
export declare
|
|
46
|
+
export declare class NumberSetting extends Setting<number, NumberSettingsProps> {
|
|
47
|
+
inputType: InputTypes;
|
|
48
|
+
constructor(props?: NumberSettingsProps);
|
|
49
|
+
draw(): HTMLElement;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export declare interface NumberSettingsProps extends SettingProps<number> {
|
|
34
53
|
minValue?: number;
|
|
35
54
|
maxValue?: number;
|
|
36
55
|
className?: string;
|
|
56
|
+
inputClassName?: string;
|
|
57
|
+
wrapperClassName?: string;
|
|
37
58
|
}
|
|
38
59
|
|
|
39
|
-
export declare class
|
|
40
|
-
protected props: NumberInputProps;
|
|
60
|
+
export declare class OpacitySetting extends NumberSetting {
|
|
41
61
|
inputType: InputTypes;
|
|
42
|
-
constructor(props
|
|
43
|
-
|
|
62
|
+
constructor(props: OpacitySettingProps);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export declare interface OpacitySettingProps extends NumberSettingsProps {
|
|
44
66
|
}
|
|
45
67
|
|
|
46
68
|
declare type Primitive = string | number | boolean | symbol | bigint | null | undefined;
|
|
47
69
|
|
|
48
|
-
export declare
|
|
49
|
-
|
|
70
|
+
export declare class SelectSetting extends Setting<string, SelectSettingProps> {
|
|
71
|
+
inputType: InputTypes;
|
|
72
|
+
constructor(props?: SelectSettingProps);
|
|
73
|
+
draw(): HTMLElement;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export declare interface SelectSettingProps extends SettingProps<string> {
|
|
77
|
+
value?: string;
|
|
78
|
+
options?: {
|
|
79
|
+
value: string;
|
|
80
|
+
name: string;
|
|
81
|
+
}[];
|
|
82
|
+
getOptions?: () => {
|
|
83
|
+
value: string;
|
|
84
|
+
name: string;
|
|
85
|
+
}[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export declare abstract class Setting<T, P extends SettingProps<T>> implements IDrawable, IChangable<T> {
|
|
89
|
+
protected props: P;
|
|
50
90
|
value: T | undefined;
|
|
51
91
|
title: string | undefined;
|
|
52
92
|
abstract inputType: T extends Primitive ? InputTypes : Record<keyof T, InputTypes>;
|
|
53
93
|
onChange: ((value: T) => void) | undefined;
|
|
54
|
-
constructor(props?:
|
|
94
|
+
constructor(props?: P);
|
|
55
95
|
setOnChange(onChange: (value: T) => void): void;
|
|
56
96
|
abstract draw(): HTMLElement;
|
|
57
|
-
createInput(
|
|
97
|
+
createInput(props: InputProps): HTMLElement;
|
|
98
|
+
createLabel(title: string, className?: string): HTMLSpanElement;
|
|
99
|
+
createIcon(icon: string, className?: string): HTMLSpanElement;
|
|
58
100
|
}
|
|
59
101
|
|
|
60
|
-
export declare class SettingGroup<T extends Record<string, Setting<any> | SettingGroup<any>>> implements IDrawable, IChangable<T> {
|
|
102
|
+
export declare class SettingGroup<T extends Record<string, Setting<any, any> | SettingGroup<any>>> implements IDrawable, IChangable<T> {
|
|
61
103
|
title: string;
|
|
62
104
|
settings: T;
|
|
63
105
|
onChange?: ((value: T) => void) | undefined;
|
|
@@ -75,17 +117,19 @@ export declare interface SettingProps<T> {
|
|
|
75
117
|
default?: T;
|
|
76
118
|
title?: string;
|
|
77
119
|
placeholder?: string;
|
|
120
|
+
icon?: string;
|
|
121
|
+
inputProps?: InputProps;
|
|
78
122
|
}
|
|
79
123
|
|
|
80
|
-
export declare
|
|
81
|
-
maxLength?: number;
|
|
82
|
-
value?: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export declare class StringSetting extends Setting<string> {
|
|
124
|
+
export declare class StringSetting extends Setting<string, StringSettingsProps> {
|
|
86
125
|
inputType: InputTypes;
|
|
87
|
-
constructor(props?:
|
|
126
|
+
constructor(props?: StringSettingsProps);
|
|
88
127
|
draw(): HTMLElement;
|
|
89
128
|
}
|
|
90
129
|
|
|
130
|
+
export declare interface StringSettingsProps extends SettingProps<string> {
|
|
131
|
+
maxLength?: number;
|
|
132
|
+
value?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
91
135
|
export { }
|
package/package.json
CHANGED