@pure-ds/core 0.4.0 → 0.4.2

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.
@@ -546,7 +546,7 @@ export class SchemaForm extends LitElement {
546
546
  }
547
547
 
548
548
  const fieldsetClass =
549
- layoutClasses.length > 0 ? layoutClasses.join(" ") : undefined;
549
+ layoutClasses.length > 0 ? layoutClasses.join(" ") : "stack-sm";
550
550
 
551
551
  // Render basic fieldset
552
552
  const fieldsetContent = html`
@@ -1140,7 +1140,7 @@ export class SchemaForm extends LitElement {
1140
1140
  : node.widgetKey === "checkbox-group"
1141
1141
  ? "group"
1142
1142
  : undefined;
1143
- const fieldsetClass = ui?.["ui:class"];
1143
+ const fieldsetClass = ui?.["ui:class"] ?? "stack-sm";
1144
1144
  return html`
1145
1145
  <fieldset
1146
1146
  data-path=${path}
@@ -34,11 +34,11 @@ export const enhancerMetadata = [
34
34
  `.trim(),
35
35
  },
36
36
  {
37
- selector: "form [required]",
37
+ selector: "form[data-required]",
38
38
  description:
39
39
  "Enhances required form fields using an asterisk in the label.",
40
40
  demoHtml: `
41
- <form action'#" method="post">
41
+ <form data-required action="#" method="post">
42
42
  <label>
43
43
  <span>Field Label</span>
44
44
  <input type="text" required>
@@ -212,28 +212,38 @@ function enhanceRange(elem) {
212
212
  }
213
213
 
214
214
  function enhanceRequired(elem) {
215
- const label = elem.closest("label");
216
- if (!label) return;
217
- if (label.querySelector(".required-asterisk")) return;
218
-
219
- const asterisk = document.createElement("span");
220
- asterisk.classList.add("required-asterisk");
221
- asterisk.textContent = "*";
222
- asterisk.style.marginLeft = "4px";
223
- label.querySelector("span").appendChild(asterisk);
224
-
225
- const form = elem.closest("form");
226
- if (form && !form.querySelector(".required-legend")) {
227
- const legend = document.createElement("div");
228
- legend.classList.add("required-legend", "pill", "pill-outline");
229
- legend.style.fontSize = "0.9em";
230
- legend.style.marginBottom = "8px";
231
- legend.textContent = "* Required fields";
232
- form.insertBefore(
233
- legend,
234
- form.querySelector(".form-actions") || form.lastElementChild
235
- );
215
+
216
+ if (elem.dataset.enhancedRequired) return;
217
+ elem.dataset.enhancedRequired = "true";
218
+
219
+ const enhanceRequiredField = (input) => {
220
+
221
+ const label = input.closest("label");
222
+ if (!label) return;
223
+ if (label.querySelector(".required-asterisk")) return;
224
+
225
+ const asterisk = document.createElement("span");
226
+ asterisk.classList.add("required-asterisk");
227
+ asterisk.textContent = "*";
228
+ asterisk.style.marginLeft = "4px";
229
+ label.querySelector("span").appendChild(asterisk);
230
+
231
+ const form = input.closest("form");
232
+ if (form && !form.querySelector(".required-legend")) {
233
+ const legend = document.createElement("small");
234
+ legend.classList.add("required-legend");
235
+ legend.textContent = "* Required fields";
236
+ form.insertBefore(
237
+ legend,
238
+ form.querySelector(".form-actions") || form.lastElementChild
239
+ );
240
+ }
236
241
  }
242
+
243
+ elem.querySelectorAll("[required]").forEach((input) => {
244
+ enhanceRequiredField(input);
245
+ });
246
+
237
247
  }
238
248
 
239
249
  function enhanceOpenGroup(elem) {
@@ -344,7 +354,7 @@ const enhancerRunners = new Map([
344
354
  ["nav[data-dropdown]", enhanceDropdown],
345
355
  ["label[data-toggle]", enhanceToggle],
346
356
  ['input[type="range"]', enhanceRange],
347
- ["form [required]", enhanceRequired],
357
+ ["form[data-required]", enhanceRequired],
348
358
  ["fieldset[role=group][data-open]", enhanceOpenGroup],
349
359
  ["button, a[class*='btn-']", enhanceButtonWorking],
350
360
  ]);
@@ -1831,11 +1831,7 @@ form {
1831
1831
  }
1832
1832
 
1833
1833
  fieldset {
1834
- margin: 0 0 var(--spacing-${
1835
- Number.isFinite(Math.round((gapValue * sectionSpacingValue) / 4))
1836
- ? Math.round((gapValue * sectionSpacingValue) / 4)
1837
- : 1
1838
- }) 0;
1834
+ margin: 0
1839
1835
  padding: var(--spacing-5);
1840
1836
  width: 100%;
1841
1837
  background-color: color-mix(in oklab, var(--color-surface-subtle) 50%, transparent 50%);
@@ -1910,7 +1906,6 @@ fieldset fieldset fieldset > legend { font-size: var(--font-size-sm); }
1910
1906
 
1911
1907
  label {
1912
1908
  display: block;
1913
- margin-bottom: var(--spacing-3);
1914
1909
  font-weight: var(--font-weight-medium);
1915
1910
  color: var(--color-text-primary);
1916
1911
  font-size: var(--font-size-sm);
@@ -2630,16 +2625,7 @@ a.btn-working {
2630
2625
  border: ${borderWidth}px solid var(--color-border);
2631
2626
  border-radius: var(--radius-md);
2632
2627
  background-color: var(--color-surface-base);
2633
-
2634
- fieldset {
2635
- background-color: transparent;
2636
- margin-bottom: var(--spacing-3);
2637
-
2638
- &:last-of-type {
2639
- margin-bottom: 0;
2640
- }
2641
- }
2642
-
2628
+
2643
2629
  .array-controls {
2644
2630
  padding-top: var(--spacing-3);
2645
2631
  border-top: ${borderWidth}px solid var(--color-border);
@@ -3093,8 +3079,7 @@ dialog {
3093
3079
  overlay 0.2s ease allow-discrete,
3094
3080
  display 0.2s ease allow-discrete;
3095
3081
 
3096
- /* Overflow handling */
3097
- overflow: hidden;
3082
+
3098
3083
  }
3099
3084
 
3100
3085
  /* Open state */
@@ -3196,7 +3181,7 @@ dialog {
3196
3181
  form > article,
3197
3182
  .dialog-body {
3198
3183
  flex: 1;
3199
- padding: var(--spacing-6);
3184
+ padding: var(--spacing-3) var(--spacing-6);
3200
3185
  overflow-y: auto;
3201
3186
  overflow-x: hidden;
3202
3187
  }