@rogieking/figui3 1.0.64 → 1.0.65
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/example.html +2 -1
- package/fig.css +2 -13
- package/fig.js +132 -94
- package/package.json +1 -1
package/example.html
CHANGED
package/fig.css
CHANGED
|
@@ -713,19 +713,6 @@ fig-button {
|
|
|
713
713
|
flex-basis: var(--spacer-4);
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
-
/* Upload */
|
|
717
|
-
&[upload],
|
|
718
|
-
&[upload] > button {
|
|
719
|
-
position: relative;
|
|
720
|
-
|
|
721
|
-
& input[type="file"] {
|
|
722
|
-
opacity: 0;
|
|
723
|
-
position: absolute;
|
|
724
|
-
inset: 0;
|
|
725
|
-
appearance: none;
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
|
|
729
716
|
/* Disabled */
|
|
730
717
|
&[disabled="true"],
|
|
731
718
|
&[disabled="true"] > button {
|
|
@@ -765,6 +752,7 @@ fig-button {
|
|
|
765
752
|
&[type="select"],
|
|
766
753
|
&[type="upload"] {
|
|
767
754
|
position: relative;
|
|
755
|
+
overflow: hidden;
|
|
768
756
|
> select,
|
|
769
757
|
> input,
|
|
770
758
|
> fig-dropdown {
|
|
@@ -1984,6 +1972,7 @@ vstack,
|
|
|
1984
1972
|
[vstack] {
|
|
1985
1973
|
display: flex;
|
|
1986
1974
|
flex-direction: column;
|
|
1975
|
+
align-items: start;
|
|
1987
1976
|
gap: var(--spacer-2);
|
|
1988
1977
|
flex-wrap: wrap;
|
|
1989
1978
|
}
|
package/fig.js
CHANGED
|
@@ -5,20 +5,21 @@ function supportsPopover() {
|
|
|
5
5
|
return HTMLElement.prototype.hasOwnProperty("popover");
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
if (window.customElements && !window.customElements.get("fig-button")) {
|
|
9
|
+
/* Button */
|
|
10
|
+
class FigButton extends HTMLElement {
|
|
11
|
+
#type;
|
|
12
|
+
#selected;
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.attachShadow({ mode: "open" });
|
|
16
|
+
}
|
|
17
|
+
connectedCallback() {
|
|
18
|
+
this.render();
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
this.#type = this.getAttribute("type") || "button";
|
|
22
|
+
this.shadowRoot.innerHTML = `
|
|
22
23
|
<style>
|
|
23
24
|
button, button:hover, button:active {
|
|
24
25
|
padding: 0 var(--spacer-2);
|
|
@@ -43,108 +44,143 @@ class FigButton extends HTMLElement {
|
|
|
43
44
|
</button>
|
|
44
45
|
`;
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
this.#selected =
|
|
48
|
+
this.hasAttribute("selected") &&
|
|
49
|
+
this.getAttribute("selected") !== "false";
|
|
50
|
+
this.addEventListener("click", this.handleClick.bind(this));
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
this.button = this.querySelector("button");
|
|
53
|
+
}
|
|
54
|
+
get type() {
|
|
55
|
+
return this.#type;
|
|
56
|
+
}
|
|
57
|
+
set type(value) {
|
|
58
|
+
this.#type = value;
|
|
59
|
+
this.button.type = value;
|
|
60
|
+
this.setAttribute("type", value);
|
|
61
|
+
}
|
|
62
|
+
get selected() {
|
|
63
|
+
return this.#selected;
|
|
64
|
+
}
|
|
65
|
+
set selected(value) {
|
|
66
|
+
this.#selected = value;
|
|
67
|
+
this.setAttribute("selected", value);
|
|
68
|
+
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
handleClick(event) {
|
|
71
|
+
if (this.#type === "toggle") {
|
|
72
|
+
this.selected = !this.#selected;
|
|
73
|
+
}
|
|
74
|
+
if (this.#type === "submit") {
|
|
75
|
+
this.button.click();
|
|
76
|
+
}
|
|
72
77
|
}
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
static get observedAttributes() {
|
|
79
|
+
return ["disabled"];
|
|
75
80
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.button[name] = newValue;
|
|
83
|
-
if (newValue === "false") {
|
|
84
|
-
this.button.removeAttribute(name);
|
|
81
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
82
|
+
if (this.button) {
|
|
83
|
+
this.button[name] = newValue;
|
|
84
|
+
if (newValue === "false") {
|
|
85
|
+
this.button.removeAttribute(name);
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
}
|
|
90
|
+
window.customElements.define("fig-button", FigButton);
|
|
88
91
|
}
|
|
89
|
-
window.customElements.define("fig-button", FigButton);
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
if (window.customElements && !window.customElements.get("fig-dropdown")) {
|
|
94
|
+
/* Dropdown */
|
|
95
|
+
class FigDropdown extends HTMLElement {
|
|
96
|
+
constructor() {
|
|
97
|
+
super();
|
|
98
|
+
this.select = document.createElement("select");
|
|
99
|
+
this.optionsSlot = document.createElement("slot");
|
|
100
|
+
this.attachShadow({ mode: "open" });
|
|
101
|
+
}
|
|
97
102
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
connectedCallback() {
|
|
104
|
+
this.type = this.getAttribute("type") || "select";
|
|
105
|
+
this.value = this.getAttribute("value") || "";
|
|
101
106
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.appendChild(this.select);
|
|
105
|
-
this.shadowRoot.appendChild(this.optionsSlot);
|
|
107
|
+
this.appendChild(this.select);
|
|
108
|
+
this.shadowRoot.appendChild(this.optionsSlot);
|
|
106
109
|
|
|
107
|
-
|
|
110
|
+
this.optionsSlot.addEventListener(
|
|
111
|
+
"slotchange",
|
|
112
|
+
this.slotChange.bind(this)
|
|
113
|
+
);
|
|
108
114
|
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
this.select.addEventListener(
|
|
116
|
+
"input",
|
|
117
|
+
this.handleDropdownInput.bind(this)
|
|
118
|
+
);
|
|
119
|
+
this.select.addEventListener(
|
|
120
|
+
"change",
|
|
121
|
+
this.handleDropdownChange.bind(this)
|
|
122
|
+
);
|
|
123
|
+
}
|
|
111
124
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
slotChange() {
|
|
126
|
+
while (this.select.firstChild) {
|
|
127
|
+
this.select.firstChild.remove();
|
|
128
|
+
}
|
|
129
|
+
if (this.type === "dropdown") {
|
|
130
|
+
const hiddenOption = document.createElement("option");
|
|
131
|
+
hiddenOption.setAttribute("hidden", "true");
|
|
132
|
+
hiddenOption.setAttribute("selected", "true");
|
|
133
|
+
this.select.appendChild(hiddenOption);
|
|
134
|
+
}
|
|
135
|
+
this.optionsSlot.assignedNodes().forEach((option) => {
|
|
136
|
+
if (option.nodeName === "OPTION" || option.nodeName === "OPTGROUP") {
|
|
137
|
+
if (option.hasAttribute("value") && option.hasAttribute("selected")) {
|
|
138
|
+
this.value = option.getAttribute("value");
|
|
139
|
+
}
|
|
140
|
+
this.select.appendChild(option.cloneNode(true));
|
|
126
141
|
}
|
|
127
|
-
|
|
142
|
+
});
|
|
143
|
+
if (this.type === "dropdown") {
|
|
144
|
+
this.select.selectedIndex = -1;
|
|
128
145
|
}
|
|
129
|
-
});
|
|
130
|
-
if (this.type === "dropdown") {
|
|
131
|
-
this.select.selectedIndex = -1;
|
|
132
146
|
}
|
|
133
|
-
}
|
|
134
147
|
|
|
135
|
-
|
|
136
|
-
if (this.type === "dropdown") {
|
|
148
|
+
handleDropdownInput() {
|
|
137
149
|
this.value = this.select.value;
|
|
138
150
|
this.setAttribute("value", this.value);
|
|
139
|
-
|
|
151
|
+
}
|
|
152
|
+
handleDropdownChange() {
|
|
153
|
+
if (this.type === "dropdown") {
|
|
154
|
+
this.select.selectedIndex = -1;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
focus() {
|
|
158
|
+
this.select.focus();
|
|
159
|
+
}
|
|
160
|
+
blur() {
|
|
161
|
+
this.select.blur();
|
|
162
|
+
}
|
|
163
|
+
get value() {
|
|
164
|
+
return this.select?.value;
|
|
165
|
+
}
|
|
166
|
+
set value(value) {
|
|
167
|
+
this.setAttribute("value", value);
|
|
168
|
+
}
|
|
169
|
+
static get observedAttributes() {
|
|
170
|
+
return ["value", "type"];
|
|
171
|
+
}
|
|
172
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
173
|
+
if (name === "value") {
|
|
174
|
+
this.select.value = newValue;
|
|
175
|
+
}
|
|
176
|
+
if (name === "type") {
|
|
177
|
+
this.type = newValue;
|
|
178
|
+
}
|
|
140
179
|
}
|
|
141
180
|
}
|
|
142
|
-
focus() {
|
|
143
|
-
this.select.focus();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
181
|
|
|
147
|
-
customElements.define("fig-dropdown", FigDropdown);
|
|
182
|
+
customElements.define("fig-dropdown", FigDropdown);
|
|
183
|
+
}
|
|
148
184
|
|
|
149
185
|
/* Tooltip */
|
|
150
186
|
class FigTooltip extends HTMLElement {
|
|
@@ -1391,7 +1427,9 @@ class FigImage extends HTMLElement {
|
|
|
1391
1427
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
1392
1428
|
if (name === "src") {
|
|
1393
1429
|
this.src = newValue;
|
|
1394
|
-
this.chit
|
|
1430
|
+
if (this.chit) {
|
|
1431
|
+
this.chit.setAttribute("src", this.src);
|
|
1432
|
+
}
|
|
1395
1433
|
}
|
|
1396
1434
|
if (name === "upload") {
|
|
1397
1435
|
this.upload = newValue.toLowerCase() === "true";
|
package/package.json
CHANGED