@rogieking/figui3 2.38.3 → 3.0.0
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/README.md +11 -8
- package/components.css +87 -23
- package/dist/fig.js +72 -72
- package/fig.js +540 -288
- package/package.json +2 -1
- package/polyfills/custom-elements-webkit.js +216 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rogieking/figui3",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A lightweight web components library for building Figma plugin and widget UIs with native look and feel",
|
|
5
5
|
"author": "Rogie King",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"fig.css",
|
|
20
20
|
"base.css",
|
|
21
21
|
"components.css",
|
|
22
|
+
"polyfills/",
|
|
22
23
|
"dist/",
|
|
23
24
|
".cursor/skills/",
|
|
24
25
|
"README.md",
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */
|
|
2
|
+
(function (document, customElements, Object) {
|
|
3
|
+
"use strict";
|
|
4
|
+
if (document.importNode.length != 1 || customElements.get("ungap-li")) return;
|
|
5
|
+
var EXTENDS = "extends";
|
|
6
|
+
try {
|
|
7
|
+
var desc = {};
|
|
8
|
+
desc[EXTENDS] = "li";
|
|
9
|
+
var HtmlLI = HTMLLIElement;
|
|
10
|
+
var LI = function () {
|
|
11
|
+
return Reflect.construct(HtmlLI, [], LI);
|
|
12
|
+
};
|
|
13
|
+
LI.prototype = Object.create(HtmlLI.prototype);
|
|
14
|
+
customElements.define("ungap-li", LI, desc);
|
|
15
|
+
if (!/is="ungap-li"/.test(new LI().outerHTML)) throw desc;
|
|
16
|
+
} catch (o_O) {
|
|
17
|
+
(function () {
|
|
18
|
+
var ATTRIBUTE_CHANGED_CALLBACK = "attributeChangedCallback";
|
|
19
|
+
var CONNECTED_CALLBACK = "connectedCallback";
|
|
20
|
+
var DISCONNECTED_CALLBACK = "disconnectedCallback";
|
|
21
|
+
var ElemProto = Element.prototype;
|
|
22
|
+
var assign = Object.assign;
|
|
23
|
+
var create = Object.create;
|
|
24
|
+
var defineProperties = Object.defineProperties;
|
|
25
|
+
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
26
|
+
var setPrototypeOf = Object.setPrototypeOf;
|
|
27
|
+
var define = customElements.define;
|
|
28
|
+
var get = customElements.get;
|
|
29
|
+
var upgrade = customElements.upgrade;
|
|
30
|
+
var whenDefined = customElements.whenDefined;
|
|
31
|
+
var registry = create(null);
|
|
32
|
+
var lifeCycle = new WeakMap();
|
|
33
|
+
var changesOptions = { childList: true, subtree: true };
|
|
34
|
+
|
|
35
|
+
Reflect.ownKeys(self)
|
|
36
|
+
.filter(function (k) {
|
|
37
|
+
return typeof k == "string" && /^HTML(?!Element)/.test(k);
|
|
38
|
+
})
|
|
39
|
+
.forEach(function (k) {
|
|
40
|
+
function HTMLBuiltIn() {}
|
|
41
|
+
var tmp = self[k];
|
|
42
|
+
setPrototypeOf(HTMLBuiltIn, tmp);
|
|
43
|
+
(HTMLBuiltIn.prototype = tmp.prototype).constructor = HTMLBuiltIn;
|
|
44
|
+
tmp = {};
|
|
45
|
+
tmp[k] = { value: HTMLBuiltIn };
|
|
46
|
+
defineProperties(self, tmp);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
new MutationObserver(DOMChanges).observe(document, changesOptions);
|
|
50
|
+
wrapOriginal(Document.prototype, "importNode");
|
|
51
|
+
wrapOriginal(Node.prototype, "cloneNode");
|
|
52
|
+
defineProperties(customElements, {
|
|
53
|
+
define: {
|
|
54
|
+
value: function (name, Class, options) {
|
|
55
|
+
name = name.toLowerCase();
|
|
56
|
+
if (options && EXTENDS in options) {
|
|
57
|
+
registry[name] = assign({}, options, { Class: Class });
|
|
58
|
+
var query = options[EXTENDS] + '[is="' + name + '"]';
|
|
59
|
+
var changes = document.querySelectorAll(query);
|
|
60
|
+
for (var i = 0, length = changes.length; i < length; i++) {
|
|
61
|
+
setupIfNeeded(changes[i]);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
define.apply(customElements, arguments);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
get: {
|
|
69
|
+
value: function (name) {
|
|
70
|
+
return name in registry ? registry[name].Class : get.call(customElements, name);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
upgrade: {
|
|
74
|
+
value: function (node) {
|
|
75
|
+
var info = getInfo(node);
|
|
76
|
+
if (info && !(node instanceof info.Class)) setup(node, info);
|
|
77
|
+
else upgrade.call(customElements, node);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
whenDefined: {
|
|
81
|
+
value: function (name) {
|
|
82
|
+
return name in registry ? Promise.resolve() : whenDefined.call(customElements, name);
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
var createElement = document.createElement;
|
|
87
|
+
defineProperties(document, {
|
|
88
|
+
createElement: {
|
|
89
|
+
value: function (name, options) {
|
|
90
|
+
var node = createElement.call(document, name);
|
|
91
|
+
if (options && "is" in options) {
|
|
92
|
+
node.setAttribute("is", options.is);
|
|
93
|
+
customElements.upgrade(node);
|
|
94
|
+
}
|
|
95
|
+
return node;
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
var attach = getOwnPropertyDescriptor(ElemProto, "attachShadow").value;
|
|
100
|
+
var innerHTML = getOwnPropertyDescriptor(ElemProto, "innerHTML");
|
|
101
|
+
defineProperties(ElemProto, {
|
|
102
|
+
attachShadow: {
|
|
103
|
+
value: function () {
|
|
104
|
+
var root = attach.apply(this, arguments);
|
|
105
|
+
new MutationObserver(DOMChanges).observe(root, changesOptions);
|
|
106
|
+
return root;
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
innerHTML: {
|
|
110
|
+
get: innerHTML.get,
|
|
111
|
+
set: function (HTML) {
|
|
112
|
+
innerHTML.set.call(this, HTML);
|
|
113
|
+
if (/\bis=("|')?[a-z0-9_-]+\1/i.test(HTML)) setupSubNodes(this, setupIfNeeded);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
function DOMChanges(changes) {
|
|
118
|
+
for (var i = 0, length = changes.length; i < length; i++) {
|
|
119
|
+
var change = changes[i];
|
|
120
|
+
var addedNodes = change.addedNodes;
|
|
121
|
+
var removedNodes = change.removedNodes;
|
|
122
|
+
for (var j = 0, len = addedNodes.length; j < len; j++) setupIfNeeded(addedNodes[j]);
|
|
123
|
+
for (var k = 0, len2 = removedNodes.length; k < len2; k++) disconnectIfNeeded(removedNodes[k]);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function attributeChanged(changes) {
|
|
127
|
+
for (var i = 0, length = changes.length; i < length; i++) {
|
|
128
|
+
var change = changes[i];
|
|
129
|
+
var attributeName = change.attributeName;
|
|
130
|
+
var oldValue = change.oldValue;
|
|
131
|
+
var target = change.target;
|
|
132
|
+
var newValue = target.getAttribute(attributeName);
|
|
133
|
+
if (ATTRIBUTE_CHANGED_CALLBACK in target && !(oldValue == newValue && newValue == null))
|
|
134
|
+
target[ATTRIBUTE_CHANGED_CALLBACK](attributeName, oldValue, target.getAttribute(attributeName), null);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function disconnectIfNeeded(node) {
|
|
138
|
+
if (node.nodeType !== 1) return;
|
|
139
|
+
var info = getInfo(node);
|
|
140
|
+
if (info && node instanceof info.Class && DISCONNECTED_CALLBACK in node && lifeCycle.get(node) !== DISCONNECTED_CALLBACK) {
|
|
141
|
+
lifeCycle.set(node, DISCONNECTED_CALLBACK);
|
|
142
|
+
Promise.resolve(node).then(invokeDisconnectedCallback);
|
|
143
|
+
}
|
|
144
|
+
setupSubNodes(node, disconnectIfNeeded);
|
|
145
|
+
}
|
|
146
|
+
function getInfo(node) {
|
|
147
|
+
var is = node.getAttribute("is");
|
|
148
|
+
if (is) {
|
|
149
|
+
is = is.toLowerCase();
|
|
150
|
+
if (is in registry) return registry[is];
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
function invokeConnectedCallback(node) {
|
|
155
|
+
node[CONNECTED_CALLBACK]();
|
|
156
|
+
}
|
|
157
|
+
function invokeDisconnectedCallback(node) {
|
|
158
|
+
node[DISCONNECTED_CALLBACK]();
|
|
159
|
+
}
|
|
160
|
+
function setup(node, info) {
|
|
161
|
+
var Class = info.Class;
|
|
162
|
+
var oa = Class.observedAttributes || [];
|
|
163
|
+
setPrototypeOf(node, Class.prototype);
|
|
164
|
+
if (oa.length) {
|
|
165
|
+
new MutationObserver(attributeChanged).observe(node, {
|
|
166
|
+
attributes: true,
|
|
167
|
+
attributeFilter: oa,
|
|
168
|
+
attributeOldValue: true,
|
|
169
|
+
});
|
|
170
|
+
var changes = [];
|
|
171
|
+
for (var i = 0, length = oa.length; i < length; i++) {
|
|
172
|
+
changes.push({ attributeName: oa[i], oldValue: null, target: node });
|
|
173
|
+
}
|
|
174
|
+
attributeChanged(changes);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function setupIfNeeded(node) {
|
|
178
|
+
if (node.nodeType !== 1) return;
|
|
179
|
+
var info = getInfo(node);
|
|
180
|
+
if (info) {
|
|
181
|
+
if (!(node instanceof info.Class)) setup(node, info);
|
|
182
|
+
if (CONNECTED_CALLBACK in node && node.isConnected && lifeCycle.get(node) !== CONNECTED_CALLBACK) {
|
|
183
|
+
lifeCycle.set(node, CONNECTED_CALLBACK);
|
|
184
|
+
Promise.resolve(node).then(invokeConnectedCallback);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
setupSubNodes(node, setupIfNeeded);
|
|
188
|
+
}
|
|
189
|
+
function setupSubNodes(node, setup) {
|
|
190
|
+
for (
|
|
191
|
+
var t = node.content, nodes = (t && t.nodeType == 11 ? t : node).querySelectorAll("[is]"), i = 0, length = nodes.length;
|
|
192
|
+
i < length;
|
|
193
|
+
i++
|
|
194
|
+
) {
|
|
195
|
+
setup(nodes[i]);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function wrapOriginal(prototype, name) {
|
|
199
|
+
var method = prototype[name];
|
|
200
|
+
var desc = {};
|
|
201
|
+
desc[name] = {
|
|
202
|
+
value: function () {
|
|
203
|
+
var result = method.apply(this, arguments);
|
|
204
|
+
switch (result.nodeType) {
|
|
205
|
+
case 1:
|
|
206
|
+
case 11:
|
|
207
|
+
setupSubNodes(result, setupIfNeeded);
|
|
208
|
+
}
|
|
209
|
+
return result;
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
defineProperties(prototype, desc);
|
|
213
|
+
}
|
|
214
|
+
})();
|
|
215
|
+
}
|
|
216
|
+
})(document, customElements, Object);
|