@rettangoli/ui 1.0.1 → 1.0.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/dist/rettangoli-iife-ui.min.js +74 -74
- package/package.json +4 -4
- package/src/entry-iife-ui.js +1 -1
- package/src/primitives/checkbox.js +26 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rettangoli/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A UI component library for building web interfaces.",
|
|
5
5
|
"main": "dist/rettangoli-esm.min.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"check:contracts": "rtgl check --dir src/components",
|
|
33
33
|
"check:contracts:yahtml": "rtgl check --dir src/components",
|
|
34
34
|
"copy:css": "node copy-css.js",
|
|
35
|
-
"build:dev": "rtgl fe build -d && bun run esbuild-dev.js && npm run copy:css",
|
|
36
|
-
"build": "rtgl fe build && bun run esbuild.js && bun run esbuild-dev.js && npm run copy:css",
|
|
35
|
+
"build:dev": "rtgl fe build -d -o ./.generated/fe-entry.js && bun run esbuild-dev.js && npm run copy:css",
|
|
36
|
+
"build": "rtgl fe build -o ./.generated/fe-entry.js && bun run esbuild.js && bun run esbuild-dev.js && npm run copy:css",
|
|
37
37
|
"prepack": "npm run build",
|
|
38
38
|
"vt:generate": "bun run build:dev && rtgl vt generate",
|
|
39
39
|
"vt:docker": "bun run build:dev && bash -lc 'IMAGE=\"han4wluc/rtgl:playwright-v1.57.0-rtgl-v1.0.0-rc27\"; docker pull \"$IMAGE\" >/dev/null 2>&1 || IMAGE=\"han4wluc/rtgl:playwright-v1.57.0-rtgl-v1.0.0-rc26\"; docker run --rm --user $(id -u):$(id -g) -v \"$PWD:/app\" -w /app \"$IMAGE\" rtgl vt screenshot'",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"homepage": "https://github.com/yuusoft-org/rettangoli#readme",
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@floating-ui/dom": "^1.6.13",
|
|
65
|
-
"@rettangoli/fe": "1.0.
|
|
65
|
+
"@rettangoli/fe": "1.0.3",
|
|
66
66
|
"commander": "^13.1.0",
|
|
67
67
|
"jempl": "1.0.0",
|
|
68
68
|
"js-yaml": "^4.1.0",
|
package/src/entry-iife-ui.js
CHANGED
|
@@ -89,6 +89,7 @@ class RettangoliCheckboxElement extends HTMLElement {
|
|
|
89
89
|
|
|
90
90
|
constructor() {
|
|
91
91
|
super();
|
|
92
|
+
this._isSyncingLabelState = false;
|
|
92
93
|
RettangoliCheckboxElement.initializeStyleSheet();
|
|
93
94
|
this.shadow = this.attachShadow({ mode: "open" });
|
|
94
95
|
this.shadow.adoptedStyleSheets = [RettangoliCheckboxElement.styleSheet];
|
|
@@ -270,22 +271,33 @@ class RettangoliCheckboxElement extends HTMLElement {
|
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
_updateLabelState() {
|
|
273
|
-
|
|
274
|
-
this.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
if (
|
|
279
|
-
|
|
274
|
+
if (this._isSyncingLabelState) return;
|
|
275
|
+
this._isSyncingLabelState = true;
|
|
276
|
+
try {
|
|
277
|
+
const fallbackLabel = this.getAttribute("label");
|
|
278
|
+
const fallbackText = fallbackLabel ?? "";
|
|
279
|
+
if (this._labelSlotElement.textContent !== fallbackText) {
|
|
280
|
+
this._labelSlotElement.textContent = fallbackText;
|
|
280
281
|
}
|
|
281
|
-
return node.nodeType === Node.ELEMENT_NODE;
|
|
282
|
-
});
|
|
283
|
-
const hasFallbackLabel = typeof fallbackLabel === "string" && fallbackLabel.trim().length > 0;
|
|
284
282
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
283
|
+
const assignedNodes = this._labelSlotElement.assignedNodes({ flatten: true });
|
|
284
|
+
const hasAssignedLabel = assignedNodes.some((node) => {
|
|
285
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
286
|
+
return node.textContent.trim().length > 0;
|
|
287
|
+
}
|
|
288
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
289
|
+
});
|
|
290
|
+
const hasFallbackLabel =
|
|
291
|
+
typeof fallbackLabel === "string" && fallbackLabel.trim().length > 0;
|
|
292
|
+
|
|
293
|
+
const shouldHaveLabel = hasAssignedLabel || hasFallbackLabel;
|
|
294
|
+
if (shouldHaveLabel && !this.hasAttribute("has-label")) {
|
|
295
|
+
this.setAttribute("has-label", "");
|
|
296
|
+
} else if (!shouldHaveLabel && this.hasAttribute("has-label")) {
|
|
297
|
+
this.removeAttribute("has-label");
|
|
298
|
+
}
|
|
299
|
+
} finally {
|
|
300
|
+
this._isSyncingLabelState = false;
|
|
289
301
|
}
|
|
290
302
|
}
|
|
291
303
|
}
|