@public-ui/solid 2.0.8 → 2.0.10

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.cjs CHANGED
@@ -1,25 +1,14 @@
1
1
  'use strict';
2
2
 
3
- const camelToKebabCase = (str) => str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
4
- const handleList = (prop, handler) => {
5
- let list;
6
- if (typeof prop === "object" && prop !== null) {
7
- list = "";
8
- for (const key in prop) {
9
- list += handler(key, prop[key]);
10
- }
11
- } else {
12
- list = prop;
13
- }
14
- if (typeof list === "string" && list.trim().length > 0) {
15
- return list.trim();
16
- } else {
17
- return null;
18
- }
3
+ let tagNameTransformer;
4
+ const setTagNameTransformer = (_tagNameTransformer) => {
5
+ tagNameTransformer = _tagNameTransformer;
19
6
  };
7
+
20
8
  function createSolidComponent(tag) {
21
9
  return (props) => {
22
- const node = document.createElement(tag);
10
+ const newTagName = typeof tagNameTransformer === "function" ? tagNameTransformer(tag) : tag;
11
+ const node = document.createElement(newTagName);
23
12
  for (const key in props) {
24
13
  if (key === "children") {
25
14
  const children = Array.isArray(props[key]) ? props[key] : [props[key]];
@@ -30,31 +19,9 @@ function createSolidComponent(tag) {
30
19
  node.innerHTML = child;
31
20
  }
32
21
  });
33
- } else if (key === "debug") {
34
- console.log(tag, props, node);
35
- } else if (key === "ref") {
36
- if (typeof props[key] === "function" && props[key].length > 0) {
37
- props[key](node);
38
- } else {
39
- props[key] = node;
40
- }
41
- } else if (key === "classList") {
42
- const list = handleList(
43
- props["classList"],
44
- (key2, value) => value === true ? `${key2} ` : ""
45
- );
46
- if (list !== null) {
47
- node.setAttribute("class", list);
48
- }
49
- } else if (key === "style") {
50
- const list = handleList(props["style"], (key2, value) => `${key2}:${value};`);
51
- if (list !== null) {
52
- node.setAttribute("style", list);
53
- }
54
22
  } else if (Object.prototype.hasOwnProperty.call(props, key)) {
55
23
  if (typeof props[key] === "string" || typeof props[key] === "number" || typeof props[key] === "boolean") {
56
- const kebabKey = camelToKebabCase(key);
57
- node.setAttribute(kebabKey, props[key]);
24
+ node.setAttribute(key, props[key]);
58
25
  } else {
59
26
  node[key] = props[key];
60
27
  }
@@ -167,3 +134,4 @@ exports.KolTreeItem = KolTreeItem;
167
134
  exports.KolTreeItemWc = KolTreeItemWc;
168
135
  exports.KolTreeWc = KolTreeWc;
169
136
  exports.KolVersion = KolVersion;
137
+ exports.setTagNameTransformer = setTagNameTransformer;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import * as solid_js from 'solid-js';
2
2
  import { JSX } from '@public-ui/components';
3
3
 
4
+ type TagNameTransformer = (tagName: string) => string;
5
+ declare const setTagNameTransformer: (_tagNameTransformer: TagNameTransformer) => void;
6
+
4
7
  declare const KolAbbr: (props: solid_js.PropsWithChildren<JSX.KolAbbr & solid_js.JSX.HTMLAttributes<HTMLKolAbbrElement>>) => HTMLKolAbbrElement;
5
8
  declare const KolAccordion: (props: solid_js.PropsWithChildren<JSX.KolAccordion & solid_js.JSX.HTMLAttributes<HTMLKolAccordionElement>>) => HTMLKolAccordionElement;
6
9
  declare const KolAlert: (props: solid_js.PropsWithChildren<JSX.KolAlert & solid_js.JSX.HTMLAttributes<HTMLKolAlertElement>>) => HTMLKolAlertElement;
@@ -53,4 +56,4 @@ declare const KolTreeItemWc: (props: solid_js.PropsWithChildren<JSX.KolTreeItemW
53
56
  declare const KolTreeWc: (props: solid_js.PropsWithChildren<JSX.KolTreeWc & solid_js.JSX.HTMLAttributes<HTMLKolTreeWcElement>>) => HTMLKolTreeWcElement;
54
57
  declare const KolVersion: (props: solid_js.PropsWithChildren<JSX.KolVersion & solid_js.JSX.HTMLAttributes<HTMLKolVersionElement>>) => HTMLKolVersionElement;
55
58
 
56
- export { KolAbbr, KolAccordion, KolAlert, KolAvatar, KolBadge, KolBreadcrumb, KolButton, KolButtonGroup, KolButtonLink, KolCard, KolDetails, KolForm, KolHeading, KolIcon, KolImage, KolIndentedText, KolInputCheckbox, KolInputColor, KolInputDate, KolInputEmail, KolInputFile, KolInputNumber, KolInputPassword, KolInputRadio, KolInputRange, KolInputText, KolKolibri, KolLink, KolLinkButton, KolLinkGroup, KolLogo, KolModal, KolNav, KolPagination, KolProgress, KolQuote, KolSelect, KolSkipNav, KolSpan, KolSpin, KolSplitButton, KolSymbol, KolTable, KolTabs, KolTextarea, KolToastContainer, KolTree, KolTreeItem, KolTreeItemWc, KolTreeWc, KolVersion };
59
+ export { KolAbbr, KolAccordion, KolAlert, KolAvatar, KolBadge, KolBreadcrumb, KolButton, KolButtonGroup, KolButtonLink, KolCard, KolDetails, KolForm, KolHeading, KolIcon, KolImage, KolIndentedText, KolInputCheckbox, KolInputColor, KolInputDate, KolInputEmail, KolInputFile, KolInputNumber, KolInputPassword, KolInputRadio, KolInputRange, KolInputText, KolKolibri, KolLink, KolLinkButton, KolLinkGroup, KolLogo, KolModal, KolNav, KolPagination, KolProgress, KolQuote, KolSelect, KolSkipNav, KolSpan, KolSpin, KolSplitButton, KolSymbol, KolTable, KolTabs, KolTextarea, KolToastContainer, KolTree, KolTreeItem, KolTreeItemWc, KolTreeWc, KolVersion, setTagNameTransformer };
package/dist/index.mjs CHANGED
@@ -1,23 +1,12 @@
1
- const camelToKebabCase = (str) => str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
2
- const handleList = (prop, handler) => {
3
- let list;
4
- if (typeof prop === "object" && prop !== null) {
5
- list = "";
6
- for (const key in prop) {
7
- list += handler(key, prop[key]);
8
- }
9
- } else {
10
- list = prop;
11
- }
12
- if (typeof list === "string" && list.trim().length > 0) {
13
- return list.trim();
14
- } else {
15
- return null;
16
- }
1
+ let tagNameTransformer;
2
+ const setTagNameTransformer = (_tagNameTransformer) => {
3
+ tagNameTransformer = _tagNameTransformer;
17
4
  };
5
+
18
6
  function createSolidComponent(tag) {
19
7
  return (props) => {
20
- const node = document.createElement(tag);
8
+ const newTagName = typeof tagNameTransformer === "function" ? tagNameTransformer(tag) : tag;
9
+ const node = document.createElement(newTagName);
21
10
  for (const key in props) {
22
11
  if (key === "children") {
23
12
  const children = Array.isArray(props[key]) ? props[key] : [props[key]];
@@ -28,31 +17,9 @@ function createSolidComponent(tag) {
28
17
  node.innerHTML = child;
29
18
  }
30
19
  });
31
- } else if (key === "debug") {
32
- console.log(tag, props, node);
33
- } else if (key === "ref") {
34
- if (typeof props[key] === "function" && props[key].length > 0) {
35
- props[key](node);
36
- } else {
37
- props[key] = node;
38
- }
39
- } else if (key === "classList") {
40
- const list = handleList(
41
- props["classList"],
42
- (key2, value) => value === true ? `${key2} ` : ""
43
- );
44
- if (list !== null) {
45
- node.setAttribute("class", list);
46
- }
47
- } else if (key === "style") {
48
- const list = handleList(props["style"], (key2, value) => `${key2}:${value};`);
49
- if (list !== null) {
50
- node.setAttribute("style", list);
51
- }
52
20
  } else if (Object.prototype.hasOwnProperty.call(props, key)) {
53
21
  if (typeof props[key] === "string" || typeof props[key] === "number" || typeof props[key] === "boolean") {
54
- const kebabKey = camelToKebabCase(key);
55
- node.setAttribute(kebabKey, props[key]);
22
+ node.setAttribute(key, props[key]);
56
23
  } else {
57
24
  node[key] = props[key];
58
25
  }
@@ -114,4 +81,4 @@ const KolTreeItemWc = /* @__PURE__ */ createSolidComponent("kol-tree-item-wc");
114
81
  const KolTreeWc = /* @__PURE__ */ createSolidComponent("kol-tree-wc");
115
82
  const KolVersion = /* @__PURE__ */ createSolidComponent("kol-version");
116
83
 
117
- export { KolAbbr, KolAccordion, KolAlert, KolAvatar, KolBadge, KolBreadcrumb, KolButton, KolButtonGroup, KolButtonLink, KolCard, KolDetails, KolForm, KolHeading, KolIcon, KolImage, KolIndentedText, KolInputCheckbox, KolInputColor, KolInputDate, KolInputEmail, KolInputFile, KolInputNumber, KolInputPassword, KolInputRadio, KolInputRange, KolInputText, KolKolibri, KolLink, KolLinkButton, KolLinkGroup, KolLogo, KolModal, KolNav, KolPagination, KolProgress, KolQuote, KolSelect, KolSkipNav, KolSpan, KolSpin, KolSplitButton, KolSymbol, KolTable, KolTabs, KolTextarea, KolToastContainer, KolTree, KolTreeItem, KolTreeItemWc, KolTreeWc, KolVersion };
84
+ export { KolAbbr, KolAccordion, KolAlert, KolAvatar, KolBadge, KolBreadcrumb, KolButton, KolButtonGroup, KolButtonLink, KolCard, KolDetails, KolForm, KolHeading, KolIcon, KolImage, KolIndentedText, KolInputCheckbox, KolInputColor, KolInputDate, KolInputEmail, KolInputFile, KolInputNumber, KolInputPassword, KolInputRadio, KolInputRange, KolInputText, KolKolibri, KolLink, KolLinkButton, KolLinkGroup, KolLogo, KolModal, KolNav, KolPagination, KolProgress, KolQuote, KolSelect, KolSkipNav, KolSpan, KolSpin, KolSplitButton, KolSymbol, KolTable, KolTabs, KolTextarea, KolToastContainer, KolTree, KolTreeItem, KolTreeItemWc, KolTreeWc, KolVersion, setTagNameTransformer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@public-ui/solid",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "license": "EUPL-1.2",
5
5
  "homepage": "https://public-ui.github.io",
6
6
  "repository": "https://github.com/public-ui/kolibri",
@@ -42,18 +42,18 @@
42
42
  "solidjs"
43
43
  ],
44
44
  "devDependencies": {
45
- "@public-ui/components": "2.0.8",
45
+ "@public-ui/components": "2.0.10",
46
46
  "@types/minimatch": "5.1.2",
47
47
  "@types/minimist": "1.2.5",
48
- "@types/node": "ts5.3",
48
+ "@types/node": "ts5.4",
49
49
  "@types/normalize-package-data": "2.4.4",
50
- "solid-js": "1.8.15",
51
- "typescript": "5.3.3",
50
+ "solid-js": "1.8.16",
51
+ "typescript": "5.4.3",
52
52
  "unbuild": "1.2.1"
53
53
  },
54
54
  "peerDependencies": {
55
- "@public-ui/components": "2.0.8",
56
- "solid-js": ">=1.2.0"
55
+ "@public-ui/components": "2.0.10",
56
+ "solid-js": ">=1.8.16"
57
57
  },
58
58
  "sideEffects": false,
59
59
  "type": "module",