@devschile/chucao 1.8.0 → 2.0.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.
Files changed (128) hide show
  1. package/README.md +1 -0
  2. package/dist/chucao/chucao.esm.js +1 -1
  3. package/dist/chucao/p-10658dc9.entry.js +2 -0
  4. package/dist/chucao/p-10658dc9.entry.js.map +1 -0
  5. package/dist/chucao/p-19dde4f9.entry.js +2 -0
  6. package/dist/chucao/p-19dde4f9.entry.js.map +1 -0
  7. package/dist/chucao/p-2e20c7a1.entry.js +2 -0
  8. package/dist/chucao/p-2e20c7a1.entry.js.map +1 -0
  9. package/dist/chucao/{p-2d7e81b2.entry.js → p-66dce533.entry.js} +2 -2
  10. package/dist/chucao/p-75184fe1.entry.js +2 -0
  11. package/dist/chucao/p-75184fe1.entry.js.map +1 -0
  12. package/dist/chucao/{p-cbb2b478.entry.js → p-96c852f5.entry.js} +2 -2
  13. package/dist/chucao/p-BaKXvAYc.js +3 -0
  14. package/dist/chucao/p-BaKXvAYc.js.map +1 -0
  15. package/dist/chucao/{p-e8fe65bb.entry.js → p-a0ec231a.entry.js} +2 -2
  16. package/dist/chucao/{p-df73f786.entry.js → p-e48912c7.entry.js} +2 -2
  17. package/dist/chucao/{p-cfb6db53.entry.js → p-f04d2f75.entry.js} +2 -2
  18. package/dist/chucao/{p-1cc7042e.entry.js → p-f62e1da2.entry.js} +2 -2
  19. package/dist/cjs/ch-accordion.cjs.entry.js +1 -1
  20. package/dist/cjs/ch-alert_8.cjs.entry.js +184 -7
  21. package/dist/cjs/ch-alert_8.cjs.entry.js.map +1 -1
  22. package/dist/cjs/ch-checkbox.cjs.entry.js +62 -3
  23. package/dist/cjs/ch-checkbox.cjs.entry.js.map +1 -1
  24. package/dist/cjs/ch-divider.cjs.entry.js +1 -1
  25. package/dist/cjs/ch-link.cjs.entry.js +1 -1
  26. package/dist/cjs/ch-modal.cjs.entry.js +1 -1
  27. package/dist/cjs/ch-radio.cjs.entry.js +62 -3
  28. package/dist/cjs/ch-radio.cjs.entry.js.map +1 -1
  29. package/dist/cjs/ch-tabs.cjs.entry.js +1 -1
  30. package/dist/cjs/ch-textarea.cjs.entry.js +62 -3
  31. package/dist/cjs/ch-textarea.cjs.entry.js.map +1 -1
  32. package/dist/cjs/ch-tooltip.cjs.entry.js +1 -1
  33. package/dist/cjs/chucao.cjs.js +2 -2
  34. package/dist/cjs/{index-DMeDkSQU.js → index-C9Abf0td.js} +58 -6
  35. package/dist/cjs/index-C9Abf0td.js.map +1 -0
  36. package/dist/cjs/loader.cjs.js +2 -2
  37. package/dist/collection/components/ch-checkbox/ch-checkbox.css +10 -0
  38. package/dist/collection/components/ch-checkbox/ch-checkbox.js +64 -4
  39. package/dist/collection/components/ch-checkbox/ch-checkbox.js.map +1 -1
  40. package/dist/collection/components/ch-input/ch-input.css +11 -0
  41. package/dist/collection/components/ch-input/ch-input.js +64 -4
  42. package/dist/collection/components/ch-input/ch-input.js.map +1 -1
  43. package/dist/collection/components/ch-radio/ch-radio.css +10 -0
  44. package/dist/collection/components/ch-radio/ch-radio.js +64 -4
  45. package/dist/collection/components/ch-radio/ch-radio.js.map +1 -1
  46. package/dist/collection/components/ch-select/ch-select.css +11 -0
  47. package/dist/collection/components/ch-select/ch-select.js +64 -4
  48. package/dist/collection/components/ch-select/ch-select.js.map +1 -1
  49. package/dist/collection/components/ch-switch/ch-switch.css +10 -0
  50. package/dist/collection/components/ch-switch/ch-switch.js +64 -4
  51. package/dist/collection/components/ch-switch/ch-switch.js.map +1 -1
  52. package/dist/collection/components/ch-textarea/ch-textarea.css +11 -0
  53. package/dist/collection/components/ch-textarea/ch-textarea.js +64 -4
  54. package/dist/collection/components/ch-textarea/ch-textarea.js.map +1 -1
  55. package/dist/components/ch-accordion.js +1 -1
  56. package/dist/components/ch-alert.js +1 -1
  57. package/dist/components/ch-badge.js +1 -1
  58. package/dist/components/ch-button.js +1 -1
  59. package/dist/components/ch-card.js +1 -1
  60. package/dist/components/ch-checkbox.js +1 -1
  61. package/dist/components/ch-checkbox.js.map +1 -1
  62. package/dist/components/ch-divider.js +1 -1
  63. package/dist/components/ch-input.js +1 -1
  64. package/dist/components/ch-input.js.map +1 -1
  65. package/dist/components/ch-link.js +1 -1
  66. package/dist/components/ch-modal.js +1 -1
  67. package/dist/components/ch-radio.js +1 -1
  68. package/dist/components/ch-radio.js.map +1 -1
  69. package/dist/components/ch-select.js +1 -1
  70. package/dist/components/ch-select.js.map +1 -1
  71. package/dist/components/ch-spinner.js +1 -1
  72. package/dist/components/ch-switch.js +1 -1
  73. package/dist/components/ch-switch.js.map +1 -1
  74. package/dist/components/ch-tabs.js +1 -1
  75. package/dist/components/ch-textarea.js +1 -1
  76. package/dist/components/ch-textarea.js.map +1 -1
  77. package/dist/components/ch-tooltip.js +1 -1
  78. package/dist/components/index.js +1 -1
  79. package/dist/components/p-DL-bL54o.js +2 -0
  80. package/dist/components/p-DL-bL54o.js.map +1 -0
  81. package/dist/esm/ch-accordion.entry.js +1 -1
  82. package/dist/esm/ch-alert_8.entry.js +184 -7
  83. package/dist/esm/ch-alert_8.entry.js.map +1 -1
  84. package/dist/esm/ch-checkbox.entry.js +62 -3
  85. package/dist/esm/ch-checkbox.entry.js.map +1 -1
  86. package/dist/esm/ch-divider.entry.js +1 -1
  87. package/dist/esm/ch-link.entry.js +1 -1
  88. package/dist/esm/ch-modal.entry.js +1 -1
  89. package/dist/esm/ch-radio.entry.js +62 -3
  90. package/dist/esm/ch-radio.entry.js.map +1 -1
  91. package/dist/esm/ch-tabs.entry.js +1 -1
  92. package/dist/esm/ch-textarea.entry.js +62 -3
  93. package/dist/esm/ch-textarea.entry.js.map +1 -1
  94. package/dist/esm/ch-tooltip.entry.js +1 -1
  95. package/dist/esm/chucao.js +3 -3
  96. package/dist/esm/{index-Bvah_WQV.js → index-BaKXvAYc.js} +58 -6
  97. package/dist/esm/index-BaKXvAYc.js.map +1 -0
  98. package/dist/esm/loader.js +3 -3
  99. package/dist/types/components/ch-checkbox/ch-checkbox.d.ts +9 -0
  100. package/dist/types/components/ch-input/ch-input.d.ts +9 -0
  101. package/dist/types/components/ch-radio/ch-radio.d.ts +9 -0
  102. package/dist/types/components/ch-select/ch-select.d.ts +9 -0
  103. package/dist/types/components/ch-switch/ch-switch.d.ts +9 -0
  104. package/dist/types/components/ch-textarea/ch-textarea.d.ts +9 -0
  105. package/dist/types/components.d.ts +24 -0
  106. package/hydrate/index.js +426 -52
  107. package/hydrate/index.mjs +426 -52
  108. package/package.json +4 -1
  109. package/dist/chucao/p-13ab5f9a.entry.js +0 -2
  110. package/dist/chucao/p-13ab5f9a.entry.js.map +0 -1
  111. package/dist/chucao/p-23c5220b.entry.js +0 -2
  112. package/dist/chucao/p-23c5220b.entry.js.map +0 -1
  113. package/dist/chucao/p-421cda05.entry.js +0 -2
  114. package/dist/chucao/p-421cda05.entry.js.map +0 -1
  115. package/dist/chucao/p-Bvah_WQV.js +0 -3
  116. package/dist/chucao/p-Bvah_WQV.js.map +0 -1
  117. package/dist/chucao/p-c16b18b7.entry.js +0 -2
  118. package/dist/chucao/p-c16b18b7.entry.js.map +0 -1
  119. package/dist/cjs/index-DMeDkSQU.js.map +0 -1
  120. package/dist/components/p-hyy-cLgi.js +0 -2
  121. package/dist/components/p-hyy-cLgi.js.map +0 -1
  122. package/dist/esm/index-Bvah_WQV.js.map +0 -1
  123. /package/dist/chucao/{p-2d7e81b2.entry.js.map → p-66dce533.entry.js.map} +0 -0
  124. /package/dist/chucao/{p-cbb2b478.entry.js.map → p-96c852f5.entry.js.map} +0 -0
  125. /package/dist/chucao/{p-e8fe65bb.entry.js.map → p-a0ec231a.entry.js.map} +0 -0
  126. /package/dist/chucao/{p-df73f786.entry.js.map → p-e48912c7.entry.js.map} +0 -0
  127. /package/dist/chucao/{p-cfb6db53.entry.js.map → p-f04d2f75.entry.js.map} +0 -0
  128. /package/dist/chucao/{p-1cc7042e.entry.js.map → p-f62e1da2.entry.js.map} +0 -0
@@ -170,6 +170,12 @@ var HYDRATE_CHILD_ID = "c-id";
170
170
  var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
171
171
  var MAX_LAZY_LOAD_RETRIES = 3;
172
172
  var LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
173
+ var FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
174
+ "formAssociatedCallback",
175
+ "formResetCallback",
176
+ "formDisabledCallback",
177
+ "formStateRestoreCallback"
178
+ ];
173
179
  var win = typeof window !== "undefined" ? window : {};
174
180
  var plt = {
175
181
  $flags$: 0,
@@ -1127,7 +1133,9 @@ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
1127
1133
  }
1128
1134
  if (propValue != null && !isComplexType(propValue)) {
1129
1135
  if (propType & 4 /* Boolean */) {
1130
- {
1136
+ if (isFormAssociated && typeof propValue === "string") {
1137
+ return propValue === "" || !!propValue;
1138
+ } else {
1131
1139
  return propValue === "false" ? false : propValue === "" || !!propValue;
1132
1140
  }
1133
1141
  }
@@ -1580,6 +1588,14 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1580
1588
  const isHostElement = isHost(renderFnResults);
1581
1589
  const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
1582
1590
  hostTagName = hostElm.tagName;
1591
+ if (cmpMeta.$attrsToReflect$) {
1592
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1593
+ cmpMeta.$attrsToReflect$.forEach(([propName, attribute]) => {
1594
+ {
1595
+ rootVnode.$attrs$[attribute] = hostElm[propName];
1596
+ }
1597
+ });
1598
+ }
1583
1599
  if (isInitialLoad && rootVnode.$attrs$) {
1584
1600
  for (const key of Object.keys(rootVnode.$attrs$)) {
1585
1601
  if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
@@ -1784,7 +1800,9 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
1784
1800
  const instance = hostRef.$lazyInstance$ ;
1785
1801
  newVal = parsePropertyValue(
1786
1802
  newVal,
1787
- cmpMeta.$members$[propName][0]);
1803
+ cmpMeta.$members$[propName][0],
1804
+ !!(cmpMeta.$flags$ & 64 /* formAssociated */)
1805
+ );
1788
1806
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1789
1807
  const didValueChange = newVal !== oldVal && !areBothNaN;
1790
1808
  if ((!(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
@@ -1828,6 +1846,26 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
1828
1846
  var proxyComponent = (Cstr, cmpMeta, flags) => {
1829
1847
  var _a, _b;
1830
1848
  const prototype = Cstr.prototype;
1849
+ if (cmpMeta.$flags$ & 64 /* formAssociated */ && flags & 1 /* isElementConstructor */) {
1850
+ FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS.forEach((cbName) => {
1851
+ Object.defineProperty(prototype, cbName, {
1852
+ value(...args) {
1853
+ var _a2;
1854
+ const hostRef = getHostRef(this);
1855
+ const instance = hostRef == null ? void 0 : hostRef.$lazyInstance$ ;
1856
+ if (!instance) {
1857
+ (_a2 = hostRef == null ? void 0 : hostRef.$onReadyPromise$) == null ? void 0 : _a2.then((asyncInstance) => {
1858
+ const cb = asyncInstance[cbName];
1859
+ typeof cb === "function" && cb.call(asyncInstance, ...args);
1860
+ });
1861
+ } else {
1862
+ const cb = instance[cbName] ;
1863
+ typeof cb === "function" && cb.call(instance, ...args);
1864
+ }
1865
+ }
1866
+ });
1867
+ });
1868
+ }
1831
1869
  if (cmpMeta.$members$ || BUILD.propChangeCallback) {
1832
1870
  {
1833
1871
  if (Cstr.watchers && !cmpMeta.$watchers$) {
@@ -1877,7 +1915,9 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1877
1915
  origSetter.apply(this, [
1878
1916
  parsePropertyValue(
1879
1917
  newValue,
1880
- memberFlags)
1918
+ memberFlags,
1919
+ !!(cmpMeta.$flags$ & 64 /* formAssociated */)
1920
+ )
1881
1921
  ]);
1882
1922
  newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
1883
1923
  setValue(this, memberName, newValue, cmpMeta);
@@ -1902,7 +1942,9 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1902
1942
  }
1903
1943
  ref.$lazyInstance$[memberName] = parsePropertyValue(
1904
1944
  newValue,
1905
- memberFlags);
1945
+ memberFlags,
1946
+ !!(cmpMeta.$flags$ & 64 /* formAssociated */)
1947
+ );
1906
1948
  setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
1907
1949
  };
1908
1950
  if (ref.$lazyInstance$) {
@@ -1961,8 +2003,12 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1961
2003
  /* @__PURE__ */ new Set([
1962
2004
  ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
1963
2005
  ...members.filter(([_, m]) => m[0] & 31 /* HasAttribute */).map(([propName, m]) => {
2006
+ var _a2;
1964
2007
  const attrName = m[1] || propName;
1965
2008
  attrNameToPropName.set(attrName, propName);
2009
+ if (m[0] & 512 /* ReflectAttr */) {
2010
+ (_a2 = cmpMeta.$attrsToReflect$) == null ? void 0 : _a2.push([propName, attrName]);
2011
+ }
1966
2012
  return attrName;
1967
2013
  })
1968
2014
  ])
@@ -2192,6 +2238,9 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2192
2238
  {
2193
2239
  cmpMeta.$listeners$ = compactMeta[3];
2194
2240
  }
2241
+ {
2242
+ cmpMeta.$attrsToReflect$ = [];
2243
+ }
2195
2244
  {
2196
2245
  cmpMeta.$watchers$ = normalizeWatchers(compactMeta[4]);
2197
2246
  cmpMeta.$serializers$ = (_a2 = compactMeta[5]) != null ? _a2 : {};
@@ -2262,6 +2311,9 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
2262
2311
  return (_a3 = getHostRef(this)) == null ? void 0 : _a3.$onReadyPromise$;
2263
2312
  }
2264
2313
  };
2314
+ if (cmpMeta.$flags$ & 64 /* formAssociated */) {
2315
+ HostElement.formAssociated = true;
2316
+ }
2265
2317
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
2266
2318
  if (!exclude.includes(tagName) && !customElements2.get(tagName)) {
2267
2319
  cmpTags.push(tagName);
@@ -2343,6 +2395,6 @@ exports.h = h;
2343
2395
  exports.promiseResolve = promiseResolve;
2344
2396
  exports.registerInstance = registerInstance;
2345
2397
  exports.setNonce = setNonce;
2346
- //# sourceMappingURL=index-DMeDkSQU.js.map
2398
+ //# sourceMappingURL=index-C9Abf0td.js.map
2347
2399
 
2348
- //# sourceMappingURL=index-DMeDkSQU.js.map
2400
+ //# sourceMappingURL=index-C9Abf0td.js.map