@peektravel/app-utilities 0.5.2 → 0.5.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/README.md +69 -14
- package/dist/index.cjs +102 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -5
- package/dist/index.d.ts +76 -5
- package/dist/index.js +101 -40
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +35 -1
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +35 -1
- package/dist/ui/index.js.map +1 -1
- package/docs/ui.md +26 -2
- package/docs/webhooks.md +80 -9
- package/llms.txt +28 -9
- package/package.json +1 -1
package/dist/ui/index.js
CHANGED
|
@@ -160,9 +160,43 @@ function classes(...parts) {
|
|
|
160
160
|
function reflectControlValue(control, value) {
|
|
161
161
|
if (control && control.value !== value) control.value = value;
|
|
162
162
|
}
|
|
163
|
+
function attrNameFor(propName) {
|
|
164
|
+
return propName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
165
|
+
}
|
|
166
|
+
function reflectToAttribute(el, attr, value) {
|
|
167
|
+
if (value === null || value === void 0 || value === false) {
|
|
168
|
+
el.removeAttribute(attr);
|
|
169
|
+
} else if (value === true) {
|
|
170
|
+
el.setAttribute(attr, "");
|
|
171
|
+
} else if (typeof value === "object") {
|
|
172
|
+
el.setAttribute(attr, JSON.stringify(value));
|
|
173
|
+
} else {
|
|
174
|
+
el.setAttribute(attr, String(value));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function addReactSafeSetters(ctor) {
|
|
178
|
+
const observed = new Set(
|
|
179
|
+
ctor.observedAttributes ?? []
|
|
180
|
+
);
|
|
181
|
+
let proto = ctor.prototype;
|
|
182
|
+
while (proto && proto !== OdyElement.prototype && proto !== HTMLElement.prototype && proto !== Object.prototype) {
|
|
183
|
+
for (const [name, desc] of Object.entries(Object.getOwnPropertyDescriptors(proto))) {
|
|
184
|
+
if (typeof desc.get !== "function" || desc.set) continue;
|
|
185
|
+
const attr = attrNameFor(name);
|
|
186
|
+
const set = observed.has(attr) ? function reflectingSetter(value) {
|
|
187
|
+
reflectToAttribute(this, attr, value);
|
|
188
|
+
} : function ignoringSetter() {
|
|
189
|
+
};
|
|
190
|
+
Object.defineProperty(proto, name, { ...desc, set });
|
|
191
|
+
}
|
|
192
|
+
proto = Object.getPrototypeOf(proto);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
163
195
|
function define(tag, ctor) {
|
|
164
196
|
if (typeof customElements === "undefined") return;
|
|
165
|
-
if (
|
|
197
|
+
if (customElements.get(tag)) return;
|
|
198
|
+
addReactSafeSetters(ctor);
|
|
199
|
+
customElements.define(tag, ctor);
|
|
166
200
|
}
|
|
167
201
|
|
|
168
202
|
// src/ui/icons-data.ts
|