@usefillo/dom 0.24.1 → 0.25.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/dist/index.js CHANGED
@@ -25,7 +25,6 @@ import {
25
25
  isValidPartialNumberText,
26
26
  localeForNotation,
27
27
  normalizeFormSchema,
28
- normalizeFormTheme,
29
28
  parseGroupedNumber,
30
29
  parsePhone,
31
30
  pipeBlock,
@@ -36,7 +35,7 @@ import {
36
35
  reachablePageSequence,
37
36
  REQUIRED_FIELD_MESSAGE,
38
37
  requiredFieldMessage,
39
- resolveThemeAppearance,
38
+ resolveThemeDom,
40
39
  shouldAutoSubmit,
41
40
  syncCodeForm,
42
41
  toE164,
@@ -71,17 +70,10 @@ function el(tag, options = {}) {
71
70
  return node;
72
71
  }
73
72
  function themeStyle(node, theme) {
74
- const safeTheme = resolveThemeAppearance(normalizeFormTheme(theme));
75
- if (!safeTheme) return;
76
- if (safeTheme.colorScheme) node.setAttribute("data-fillo-color-scheme", safeTheme.colorScheme);
77
- if (safeTheme.primary) node.style.setProperty("--fillo-primary", safeTheme.primary);
78
- if (safeTheme.background) node.style.setProperty("--fillo-bg", safeTheme.background);
79
- if (safeTheme.text) node.style.setProperty("--fillo-text", safeTheme.text);
80
- if (safeTheme.radius) node.style.setProperty("--fillo-radius", safeTheme.radius);
81
- if (safeTheme.fontFamily) node.style.setProperty("--fillo-font", safeTheme.fontFamily);
82
- if (safeTheme.primary || safeTheme.background || safeTheme.text) {
83
- node.setAttribute("data-fillo-has-color-theme", "");
84
- }
73
+ const dom = resolveThemeDom(theme);
74
+ if (!dom) return;
75
+ for (const [name, value] of Object.entries(dom.attrs)) node.setAttribute(name, value);
76
+ for (const [name, value] of Object.entries(dom.vars)) node.style.setProperty(name, value);
85
77
  }
86
78
  function safeHttpUrl(href) {
87
79
  try {
@@ -1362,6 +1354,11 @@ function closeIcon() {
1362
1354
  icon.setAttribute("class", "fillo-file-action-icon");
1363
1355
  return icon;
1364
1356
  }
1357
+ function groupIcon(path) {
1358
+ const icon = uploadSvg([path], 16);
1359
+ icon.setAttribute("class", "fillo-group-icon");
1360
+ return icon;
1361
+ }
1365
1362
  function fileActionBtn(className, label, content, onClick) {
1366
1363
  const btn = el("button", { className, attrs: { type: "button", "aria-label": label } });
1367
1364
  btn.append(content);
@@ -1662,12 +1659,12 @@ function repeatingGroup(context) {
1662
1659
  const header = el("div", { className: "fillo-group-instance-header" });
1663
1660
  const removeBtn = el("button", {
1664
1661
  className: "fillo-group-remove",
1665
- text: "\xD7",
1666
1662
  attrs: {
1667
1663
  type: "button",
1668
1664
  "aria-label": DEFAULT_FIELD_STRINGS.groupRemoveLabel(item, index + 1)
1669
1665
  }
1670
1666
  });
1667
+ removeBtn.appendChild(groupIcon("M6 6l12 12M18 6 6 18"));
1671
1668
  const canRemove = count > floor;
1672
1669
  removeBtn.toggleAttribute("disabled", !canRemove);
1673
1670
  if (!canRemove) {
@@ -1720,9 +1717,9 @@ function repeatingGroup(context) {
1720
1717
  const atMax = count >= field.maxInstances;
1721
1718
  const addBtn = el("button", {
1722
1719
  className: "fillo-group-add",
1723
- text: field.addLabel || DEFAULT_FIELD_STRINGS.groupAdd,
1724
1720
  attrs: { type: "button" }
1725
1721
  });
1722
+ addBtn.append(groupIcon("M12 5v14M5 12h14"), field.addLabel || DEFAULT_FIELD_STRINGS.groupAdd);
1726
1723
  addBtn.toggleAttribute("disabled", atMax);
1727
1724
  if (atMax) {
1728
1725
  addBtn.setAttribute("aria-disabled", "true");