@peektravel/app-utilities 0.5.2 → 0.5.4
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 +44 -1
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +10 -1
- package/dist/ui/index.d.ts +10 -1
- package/dist/ui/index.js +44 -1
- package/dist/ui/index.js.map +1 -1
- package/docs/ui.md +30 -6
- package/docs/webhooks.md +80 -9
- package/llms.txt +28 -9
- package/package.json +1 -1
package/dist/ui/index.cjs
CHANGED
|
@@ -162,9 +162,43 @@ function classes(...parts) {
|
|
|
162
162
|
function reflectControlValue(control, value) {
|
|
163
163
|
if (control && control.value !== value) control.value = value;
|
|
164
164
|
}
|
|
165
|
+
function attrNameFor(propName) {
|
|
166
|
+
return propName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
167
|
+
}
|
|
168
|
+
function reflectToAttribute(el, attr, value) {
|
|
169
|
+
if (value === null || value === void 0 || value === false) {
|
|
170
|
+
el.removeAttribute(attr);
|
|
171
|
+
} else if (value === true) {
|
|
172
|
+
el.setAttribute(attr, "");
|
|
173
|
+
} else if (typeof value === "object") {
|
|
174
|
+
el.setAttribute(attr, JSON.stringify(value));
|
|
175
|
+
} else {
|
|
176
|
+
el.setAttribute(attr, String(value));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function addReactSafeSetters(ctor) {
|
|
180
|
+
const observed = new Set(
|
|
181
|
+
ctor.observedAttributes ?? []
|
|
182
|
+
);
|
|
183
|
+
let proto = ctor.prototype;
|
|
184
|
+
while (proto && proto !== OdyElement.prototype && proto !== HTMLElement.prototype && proto !== Object.prototype) {
|
|
185
|
+
for (const [name, desc] of Object.entries(Object.getOwnPropertyDescriptors(proto))) {
|
|
186
|
+
if (typeof desc.get !== "function" || desc.set) continue;
|
|
187
|
+
const attr = attrNameFor(name);
|
|
188
|
+
const set = observed.has(attr) ? function reflectingSetter(value) {
|
|
189
|
+
reflectToAttribute(this, attr, value);
|
|
190
|
+
} : function ignoringSetter() {
|
|
191
|
+
};
|
|
192
|
+
Object.defineProperty(proto, name, { ...desc, set });
|
|
193
|
+
}
|
|
194
|
+
proto = Object.getPrototypeOf(proto);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
165
197
|
function define(tag, ctor) {
|
|
166
198
|
if (typeof customElements === "undefined") return;
|
|
167
|
-
if (
|
|
199
|
+
if (customElements.get(tag)) return;
|
|
200
|
+
addReactSafeSetters(ctor);
|
|
201
|
+
customElements.define(tag, ctor);
|
|
168
202
|
}
|
|
169
203
|
|
|
170
204
|
// src/ui/icons-data.ts
|
|
@@ -1960,6 +1994,15 @@ var OdyCheckboxGroup = class extends OdyElement {
|
|
|
1960
1994
|
get options() {
|
|
1961
1995
|
return parseOptions2(this.attr("options"));
|
|
1962
1996
|
}
|
|
1997
|
+
/**
|
|
1998
|
+
* Accepts an array of `{ label, value }` and stores it as the JSON `options`
|
|
1999
|
+
* attribute. Mirrors `<ody-dropdown-*>` so `el.options = [...]` works across
|
|
2000
|
+
* the data-driven elements. `options` is observed, so this triggers a
|
|
2001
|
+
* re-render via `attributeChangedCallback`.
|
|
2002
|
+
*/
|
|
2003
|
+
set options(next) {
|
|
2004
|
+
this.setAttribute("options", JSON.stringify(Array.isArray(next) ? next : []));
|
|
2005
|
+
}
|
|
1963
2006
|
render() {
|
|
1964
2007
|
const size = this.attr("size", "small");
|
|
1965
2008
|
const isDisabled = this.flag("disabled");
|