litos-ui 0.23.0 → 0.24.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 (312) hide show
  1. package/README.md +2 -2
  2. package/README.zh-CN.md +2 -2
  3. package/lib/base.d.ts +3 -2
  4. package/lib/base.js +11 -8
  5. package/lib/button/index.d.ts +21 -5
  6. package/lib/button/index.js +115 -62
  7. package/lib/button/index.less_inline.js +2 -3
  8. package/lib/button/style.js +1 -2
  9. package/lib/calendar/index.d.ts +1 -0
  10. package/lib/calendar/index.js +19 -17
  11. package/lib/calendar/index.less_inline.js +1 -2
  12. package/lib/calendar/langs.js +21 -11
  13. package/lib/card/index.js +8 -9
  14. package/lib/card/index.less_inline.js +1 -2
  15. package/lib/carousel/index.js +10 -11
  16. package/lib/carousel/index.less_inline.js +1 -2
  17. package/lib/carousel/item.js +1 -2
  18. package/lib/carousel/item.less_inline.js +1 -2
  19. package/lib/carousel/timer.js +1 -2
  20. package/lib/check/check.d.ts +40 -8
  21. package/lib/check/check.js +200 -65
  22. package/lib/check/check.less_inline.js +2 -3
  23. package/lib/check/checkbox.js +2 -3
  24. package/lib/check/checkbox.less_inline.js +2 -3
  25. package/lib/check/checkbox_group.js +1 -2
  26. package/lib/check/index.d.ts +28 -8
  27. package/lib/check/index.js +151 -46
  28. package/lib/check/index.less_inline.js +1 -2
  29. package/lib/check/radio.js +2 -3
  30. package/lib/check/radio.less_inline.js +1 -2
  31. package/lib/check/radio_group.js +2 -3
  32. package/lib/collapse/index.d.ts +12 -4
  33. package/lib/collapse/index.js +80 -46
  34. package/lib/collapse/index.less_inline.js +2 -3
  35. package/lib/collapse/item.d.ts +35 -9
  36. package/lib/collapse/item.js +219 -57
  37. package/lib/collapse/item.less_inline.js +2 -3
  38. package/lib/collapse/types.d.ts +17 -3
  39. package/lib/color_picker/index.d.ts +4 -2
  40. package/lib/color_picker/index.js +26 -17
  41. package/lib/color_picker/index.less_inline.js +1 -2
  42. package/lib/date_picker/index.d.ts +5 -1
  43. package/lib/date_picker/index.js +39 -23
  44. package/lib/date_picker/index.less_inline.js +1 -2
  45. package/lib/date_picker_ori/index.d.ts +7 -2
  46. package/lib/date_picker_ori/index.js +123 -47
  47. package/lib/date_picker_ori/index.less_inline.js +1 -2
  48. package/lib/description_panel/index.js +2 -10
  49. package/lib/description_panel/index.less_inline.js +1 -2
  50. package/lib/dialog/dialog_box.js +28 -29
  51. package/lib/dialog/dialog_container.css_inline.js +1 -2
  52. package/lib/dialog/dialog_container.js +13 -14
  53. package/lib/dialog/dialog_container_style.js +1 -2
  54. package/lib/dialog/index.d.ts +2 -0
  55. package/lib/dialog/index.js +11 -9
  56. package/lib/dropdown/index.d.ts +39 -0
  57. package/lib/dropdown/index.js +98 -0
  58. package/lib/entries/base.js +1 -2
  59. package/lib/entries/button.js +5 -6
  60. package/lib/entries/calendar.js +5 -6
  61. package/lib/entries/card.js +5 -6
  62. package/lib/entries/carousel-item.js +5 -6
  63. package/lib/entries/carousel.js +5 -6
  64. package/lib/entries/checkbox-group.js +5 -6
  65. package/lib/entries/checkbox.js +5 -6
  66. package/lib/entries/collapse-item.d.ts +0 -1
  67. package/lib/entries/collapse-item.js +6 -6
  68. package/lib/entries/collapse.d.ts +0 -1
  69. package/lib/entries/collapse.js +11 -6
  70. package/lib/entries/color-picker.js +5 -6
  71. package/lib/entries/date-picker-ori.js +5 -6
  72. package/lib/entries/date-picker.js +5 -6
  73. package/lib/entries/description-panel.js +5 -6
  74. package/lib/entries/dialog-box.js +1 -2
  75. package/lib/entries/dialog-container.js +5 -6
  76. package/lib/entries/dialog.js +1 -2
  77. package/lib/entries/dropdown.d.ts +2 -0
  78. package/lib/entries/dropdown.js +1 -0
  79. package/lib/entries/form-item.js +5 -6
  80. package/lib/entries/form.js +5 -6
  81. package/lib/entries/icon-arrow-down.js +5 -6
  82. package/lib/entries/icon-arrow-left.js +5 -6
  83. package/lib/entries/icon-arrow-right.js +5 -6
  84. package/lib/entries/icon-arrow-up.js +5 -6
  85. package/lib/entries/icon-base.js +5 -6
  86. package/lib/entries/icon-calendar.js +5 -6
  87. package/lib/entries/icon-caret-bottom.js +5 -6
  88. package/lib/entries/icon-caret-top.js +5 -6
  89. package/lib/entries/icon-close-filled.js +5 -6
  90. package/lib/entries/icon-close.js +5 -6
  91. package/lib/entries/icon-copy.js +5 -6
  92. package/lib/entries/icon-d-arrow-left.js +5 -6
  93. package/lib/entries/icon-d-arrow-right.js +5 -6
  94. package/lib/entries/icon-delete.js +5 -6
  95. package/lib/entries/icon-eye-outline.js +5 -6
  96. package/lib/entries/icon-font-icon.js +5 -6
  97. package/lib/entries/icon-info.js +5 -6
  98. package/lib/entries/icon-loading.js +5 -6
  99. package/lib/entries/icon-minus.js +5 -6
  100. package/lib/entries/icon-moon.js +5 -6
  101. package/lib/entries/icon-more.js +5 -6
  102. package/lib/entries/icon-picture.js +5 -6
  103. package/lib/entries/icon-plus.js +5 -6
  104. package/lib/entries/icon-reduction.js +5 -6
  105. package/lib/entries/icon-refresh-left.js +5 -6
  106. package/lib/entries/icon-refresh-right.js +5 -6
  107. package/lib/entries/icon-refresh.js +5 -6
  108. package/lib/entries/icon-search.js +5 -6
  109. package/lib/entries/icon-select.js +5 -6
  110. package/lib/entries/icon-sort.js +5 -6
  111. package/lib/entries/icon-success.js +5 -6
  112. package/lib/entries/icon-sun.js +5 -6
  113. package/lib/entries/icon-theme-default.js +5 -6
  114. package/lib/entries/icon-warn.js +5 -6
  115. package/lib/entries/icon-zoom-in.js +5 -6
  116. package/lib/entries/icon-zoom-out.js +5 -6
  117. package/lib/entries/image-preview.js +5 -6
  118. package/lib/entries/image.js +5 -6
  119. package/lib/entries/input-number.js +5 -6
  120. package/lib/entries/input.js +5 -6
  121. package/lib/entries/list.js +5 -6
  122. package/lib/entries/loading.js +1 -2
  123. package/lib/entries/mask.js +5 -6
  124. package/lib/entries/md-input.js +5 -6
  125. package/lib/entries/menu.js +5 -6
  126. package/lib/entries/message.js +1 -2
  127. package/lib/entries/modal-box.js +1 -2
  128. package/lib/entries/modal.js +5 -6
  129. package/lib/entries/notification-box.js +1 -2
  130. package/lib/entries/notification.js +1 -2
  131. package/lib/entries/page-header.js +5 -6
  132. package/lib/entries/pagination.js +5 -6
  133. package/lib/entries/polygon.js +5 -6
  134. package/lib/entries/popconfirm.js +1 -2
  135. package/lib/entries/popover.js +1 -2
  136. package/lib/entries/qrcode.js +5 -6
  137. package/lib/entries/radio-group.js +5 -6
  138. package/lib/entries/radio.js +5 -6
  139. package/lib/entries/select-ori.js +5 -6
  140. package/lib/entries/select.js +5 -6
  141. package/lib/entries/space.js +5 -6
  142. package/lib/entries/switch.js +5 -6
  143. package/lib/entries/tabbar-item.js +5 -6
  144. package/lib/entries/tabbar.js +5 -6
  145. package/lib/entries/table.js +5 -6
  146. package/lib/entries/tabs.js +1 -2
  147. package/lib/entries/tag.js +5 -6
  148. package/lib/entries/theme-color.js +5 -6
  149. package/lib/entries/theme.js +5 -6
  150. package/lib/entries/transition.js +1 -2
  151. package/lib/entries/upload.js +5 -6
  152. package/lib/entries/utils.js +1 -2
  153. package/lib/form/accessibility.d.ts +15 -0
  154. package/lib/form/accessibility.js +56 -0
  155. package/lib/form/autocomplete.d.ts +21 -0
  156. package/lib/form/autocomplete.js +59 -0
  157. package/lib/form/context.d.ts +157 -0
  158. package/lib/form/context.js +88 -0
  159. package/lib/form/form_inner.d.ts +99 -24
  160. package/lib/form/form_inner.js +424 -72
  161. package/lib/form/form_item.d.ts +35 -11
  162. package/lib/form/form_item.js +210 -78
  163. package/lib/form/form_item.less_inline.js +2 -3
  164. package/lib/form/form_item_style.d.ts +3 -0
  165. package/lib/form/form_item_style.js +7 -0
  166. package/lib/form/index.d.ts +69 -15
  167. package/lib/form/index.js +501 -101
  168. package/lib/form/index.less_inline.js +1 -2
  169. package/lib/form/owner.d.ts +78 -0
  170. package/lib/form/owner.js +138 -0
  171. package/lib/form/style.d.ts +3 -0
  172. package/lib/form/style.js +7 -0
  173. package/lib/icon/arrow_down.js +1 -2
  174. package/lib/icon/arrow_left.js +1 -2
  175. package/lib/icon/arrow_right.js +1 -2
  176. package/lib/icon/arrow_up.js +1 -2
  177. package/lib/icon/base.js +1 -2
  178. package/lib/icon/calendar.js +1 -2
  179. package/lib/icon/caret_bottom.js +1 -2
  180. package/lib/icon/caret_top.js +1 -2
  181. package/lib/icon/close.js +1 -2
  182. package/lib/icon/close_filled.js +1 -2
  183. package/lib/icon/copy.js +1 -2
  184. package/lib/icon/d_arrow_left.js +1 -2
  185. package/lib/icon/d_arrow_right.js +1 -2
  186. package/lib/icon/delete.js +1 -2
  187. package/lib/icon/eye_outline.js +1 -2
  188. package/lib/icon/font_icon.js +1 -2
  189. package/lib/icon/icon_style.js +1 -2
  190. package/lib/icon/index.less_inline.js +1 -2
  191. package/lib/icon/info.js +1 -2
  192. package/lib/icon/loading.js +1 -2
  193. package/lib/icon/minus.js +1 -2
  194. package/lib/icon/moon.js +1 -2
  195. package/lib/icon/more.js +1 -2
  196. package/lib/icon/picture.js +1 -2
  197. package/lib/icon/plus.js +1 -2
  198. package/lib/icon/reduction.js +1 -2
  199. package/lib/icon/refresh.js +1 -2
  200. package/lib/icon/refresh_left.js +1 -2
  201. package/lib/icon/refresh_right.js +1 -2
  202. package/lib/icon/search.js +1 -2
  203. package/lib/icon/select.js +1 -2
  204. package/lib/icon/sort.js +1 -2
  205. package/lib/icon/success.js +1 -2
  206. package/lib/icon/sun.js +1 -2
  207. package/lib/icon/theme_default.js +1 -2
  208. package/lib/icon/warn.js +1 -2
  209. package/lib/icon/zoom_in.js +1 -2
  210. package/lib/icon/zoom_out.js +1 -2
  211. package/lib/image/image_preview.js +1 -2
  212. package/lib/image/image_preview.less_inline.js +1 -2
  213. package/lib/image/index.js +1 -2
  214. package/lib/image/index.less_inline.js +1 -2
  215. package/lib/index.d.ts +2 -1
  216. package/lib/index.js +88 -87
  217. package/lib/input/index.d.ts +18 -1
  218. package/lib/input/index.js +151 -48
  219. package/lib/input/index.less_inline.js +2 -3
  220. package/lib/input/input_inner.less_inline.js +1 -2
  221. package/lib/input/style.d.ts +3 -0
  222. package/lib/input/style.js +7 -0
  223. package/lib/input_number/index.d.ts +7 -0
  224. package/lib/input_number/index.js +70 -48
  225. package/lib/input_number/index.less_inline.js +1 -2
  226. package/lib/input_number/style.js +1 -2
  227. package/lib/list/index.js +4 -5
  228. package/lib/list/index.less_inline.js +1 -2
  229. package/lib/loading/index.js +1 -2
  230. package/lib/mask/index.js +2 -7
  231. package/lib/mask/index.less_inline.js +1 -2
  232. package/lib/md_input/index.d.ts +11 -2
  233. package/lib/md_input/index.js +63 -27
  234. package/lib/md_input/index.less_inline.js +2 -3
  235. package/lib/menu/index.js +2 -7
  236. package/lib/menu/index.less_inline.js +1 -2
  237. package/lib/message/index.js +1 -2
  238. package/lib/modal/index.js +15 -16
  239. package/lib/modal/index.less_inline.js +1 -2
  240. package/lib/modal/modal_box.js +24 -25
  241. package/lib/notification/index.js +15 -29
  242. package/lib/notification/index.less_inline.js +1 -2
  243. package/lib/notification/notification_box.js +2 -3
  244. package/lib/notification/placement.js +1 -2
  245. package/lib/notification/style.js +1 -2
  246. package/lib/page_header/index.js +1 -2
  247. package/lib/page_header/index.less_inline.js +1 -2
  248. package/lib/pagination/index.js +26 -25
  249. package/lib/pagination/index.less_inline.js +2 -3
  250. package/lib/polygon/index.js +1 -2
  251. package/lib/polygon/index.less_inline.js +1 -2
  252. package/lib/qrcode/index.js +1 -2
  253. package/lib/qrcode/index.less_inline.js +1 -2
  254. package/lib/select/index.d.ts +21 -2
  255. package/lib/select/index.js +138 -77
  256. package/lib/select/index.less_inline.js +1 -2
  257. package/lib/select_ori/index.d.ts +9 -1
  258. package/lib/select_ori/index.js +36 -24
  259. package/lib/select_ori/index.less_inline.js +1 -2
  260. package/lib/space/index.js +1 -2
  261. package/lib/space/index.less_inline.js +1 -2
  262. package/lib/styles/animation/index.css_inline.js +1 -2
  263. package/lib/styles/animation/index.js +1 -2
  264. package/lib/styles/mask/index.css_inline.js +1 -2
  265. package/lib/styles/mask/index.js +1 -2
  266. package/lib/switch/index.d.ts +6 -0
  267. package/lib/switch/index.js +31 -16
  268. package/lib/switch/index.less_inline.js +1 -2
  269. package/lib/tabbar/index.js +1 -2
  270. package/lib/tabbar/index.less_inline.js +1 -2
  271. package/lib/tabbar/item.js +1 -2
  272. package/lib/tabbar/item.less_inline.js +1 -2
  273. package/lib/table/index.d.ts +2 -0
  274. package/lib/table/index.js +12 -4
  275. package/lib/table/index.less_inline.js +1 -2
  276. package/lib/tabs/index.js +1 -2
  277. package/lib/tag/index.d.ts +11 -3
  278. package/lib/tag/index.js +25 -24
  279. package/lib/tag/index.less_inline.js +2 -3
  280. package/lib/theme/appearance.d.ts +5 -0
  281. package/lib/theme/appearance.js +34 -0
  282. package/lib/theme/index.js +83 -39
  283. package/lib/theme/index.less_inline.js +1 -2
  284. package/lib/theme/theme_color.js +1 -2
  285. package/lib/upload/index.js +28 -41
  286. package/lib/upload/index.less_inline.js +2 -3
  287. package/lib/upload/style.js +1 -2
  288. package/lib/utils/clickoutside.js +1 -2
  289. package/lib/utils/event.js +1 -2
  290. package/lib/utils/index.d.ts +27 -5
  291. package/lib/utils/index.js +43 -22
  292. package/lib/utils/popover.js +7 -16
  293. package/lib/utils/transition.js +1 -2
  294. package/package.json +16 -13
  295. package/styles/dark.css +10 -2
  296. package/styles/dropdown.css +46 -0
  297. package/styles/reset.css +0 -1
  298. package/styles/select.css +5 -0
  299. package/styles/themes/apple.css +47 -0
  300. package/styles/{theme-coral.css → themes/coral.css} +5 -3
  301. package/styles/themes/deep-sea-blue.css +12 -0
  302. package/styles/themes/gamboge.css +15 -0
  303. package/styles/{theme-jade.css → themes/jade.css} +5 -3
  304. package/styles/themes/lotus-seed.css +12 -0
  305. package/styles/{theme-tangerine.css → themes/tangerine.css} +5 -3
  306. package/styles/themes.css +8 -0
  307. package/styles/vars.css +8 -2
  308. package/types/preact.d.ts +43 -0
  309. package/lib/form/types.d.ts +0 -7
  310. package/lib/utils/context_provide.d.ts +0 -10
  311. package/lib/utils/context_provide.js +0 -22
  312. package/lib/utils/signal_types.d.ts +0 -5
@@ -1,71 +1,176 @@
1
- import { unitNumberStr as e } from "../utils/index.js";
2
- import t from "../form/form_inner.js";
3
- import n from "./index.less_inline.js";
4
- import { $$ as r, off as i, on as a } from "utilane/browser";
5
- import { signal as o } from "alien-signals";
6
- //#region src/components/check/index.ts
7
- var s = class extends t {
8
- values;
9
- multiple;
10
- _state;
1
+ import e from "../form/form_inner.js";
2
+ import t from "./index.less_inline.js";
3
+ import { unitNumberStr as n } from "../utils/index.js";
4
+ import { createFormContextProvider as r, provideFormContext as i, requestFormContext as a } from "../form/context.js";
5
+ import o from "./check.js";
6
+ import { $$ as s } from "utilane/browser";
7
+ // src/components/check/index.ts
8
+ var c = class extends e {
9
+ values = [];
10
+ multiple = !0;
11
+ selectedRadio;
12
+ provider = r();
13
+ groupProvider = {
14
+ ...this.provider,
15
+ registerField: (e) => {
16
+ let t = this.provider.registerField(e);
17
+ return e.target instanceof o && e.target.addEventListener("change", this._handleChange), this.syncMembers(), () => {
18
+ t() && (e.target.removeEventListener("change", this._handleChange), this.syncMembers());
19
+ };
20
+ },
21
+ fieldStateChanged: () => this.syncMembers(),
22
+ getFieldChecked: (e) => e instanceof o && this.isMemberChecked(e),
23
+ requestFieldChecked: (e, t) => {
24
+ e instanceof o && this.setMemberChecked(e, t);
25
+ },
26
+ getRadioMembers: () => this.getRadioMembers()
27
+ };
28
+ stopProviding;
29
+ constructor() {
30
+ super(), this._state = {};
31
+ }
11
32
  setValue(e) {
12
- super.setValue(e), this.rendered && this.updateChecked();
33
+ this.updateChecked(e), super.setValue(e), this.publishConfiguration();
13
34
  }
14
- constructor() {
15
- super(!1), this.multiple = !0, this.values = o([]), this._state = {};
35
+ get intrinsicDefaultValue() {
36
+ return this.multiple ? "" : null;
37
+ }
38
+ get defaultValue() {
39
+ return super.defaultValue;
40
+ }
41
+ set defaultValue(e) {
42
+ !this.multiple && e == null ? this.removeAttribute("value") : super.defaultValue = e;
16
43
  }
17
44
  static get observedAttributes() {
18
45
  return [
19
- "disabled",
20
- "value",
21
- "name",
22
- "inner-block",
23
- "gap"
46
+ ...e.observedAttributes,
47
+ "gap",
48
+ "required"
24
49
  ];
25
50
  }
26
- attributeChange(t, n, r) {
27
- t === "gap" && (this._state.gap = e(r));
51
+ attributeChange(e, t, r) {
52
+ e === "gap" && (this._state.gap = n(r)), e === "required" && this.syncNativeValidity();
28
53
  }
29
54
  updateDOM(e) {
30
55
  e.has("gap") && this._updateGap();
31
56
  }
32
57
  connectedCallback() {
33
- this.loadStyleText([n]), this.updateChecked(), super.connectedCallback(), this._updateGap();
34
- }
35
- afterInit() {
36
- a(this.root, "change", this.#e), a(this, "check-context-request", this._privide);
58
+ this.stopProviding = i(this, "group", this.groupProvider), this.updateChecked(this.value), this.publishConfiguration(), this.loadStyleText([t]), super.connectedCallback();
59
+ for (let e of this.querySelectorAll("*")) e instanceof o && a(e, "group") === this.groupProvider && e.refreshFormContext();
60
+ this._updateGap();
37
61
  }
38
62
  beforeDestroy() {
39
- i(this.root, "change", this.#e), i(this, "check-context-request", this._privide), this.values([]);
63
+ for (let { target: e } of this.provider.getFields()) e.removeEventListener("change", this._handleChange);
64
+ this.stopProviding?.(), this.stopProviding = void 0, this.provider.dispose(), this.selectedRadio = void 0;
40
65
  }
41
66
  render() {
42
- return r("slot");
67
+ return s("slot");
68
+ }
69
+ disabledChange() {
70
+ this.classList.toggle("is-disabled", this.isDisabled()), this.publishConfiguration(), this.syncNativeValidity();
71
+ }
72
+ publishConfiguration() {
73
+ this.provider?.updateConfiguration({
74
+ values: [...this.values],
75
+ multiple: this.multiple,
76
+ disabled: this.isDisabled()
77
+ });
43
78
  }
44
- _privide = (e) => {
45
- let { context: t, callback: n } = e.detail;
46
- t === "check-context-request" && n(this.values);
47
- };
48
79
  _updateGap = () => {
49
80
  this._state.gap ? this.style.setProperty("--l-check-gap", this._state.gap) : this.style.removeProperty("--l-check-gap");
50
81
  };
51
- #e = (e) => {
82
+ _handleChange = (e) => {
83
+ let t = e.composedPath()[0];
84
+ if (!(t instanceof o) || a(t, "group") !== this.groupProvider) return;
52
85
  e.stopPropagation();
53
- let t = e.detail.value, n = this.values(), r = n.indexOf(t);
54
- this.multiple ? (r === -1 ? n.push(t) : n.splice(r, 1), this.setAttribute("value", n.join("&"))) : r === -1 && this.setAttribute("value", t), this.emit("change", {
55
- detail: { value: this.multiple ? n : t },
56
- composed: !0
86
+ let n = e.detail?.checked ?? t.getChecked();
87
+ this.setMemberChecked(t, n), this.validateInput(), this.emit("change", {
88
+ detail: { value: this.multiple ? [...this.values] : t.token },
89
+ composed: !0,
90
+ bubbles: !0
57
91
  });
58
92
  };
59
- updateChecked() {
60
- let e = [];
61
- if (this.value) {
62
- if (this.multiple) {
63
- let t = this.value.split("&");
64
- e.push(...t.map((e) => decodeURIComponent(e)));
65
- } else e = [this.value];
66
- } else e = [];
67
- this.values(e);
93
+ isMemberChecked(e) {
94
+ return this.multiple ? this.values.includes(e.token) : this.selectedRadio === e;
95
+ }
96
+ setMemberChecked(e, t) {
97
+ if (this.isMemberChecked(e) === t) return;
98
+ if (!this.multiple) {
99
+ this.selectedRadio = t ? e : void 0, this.value = t ? e.token : null;
100
+ return;
101
+ }
102
+ let n = t ? [...this.values, e.token] : this.values.filter((t) => t !== e.token);
103
+ this.value = this.encodeValues(n);
104
+ }
105
+ encodeValues(e) {
106
+ return e.length === 1 && e[0] === "" ? "&" : e.map(encodeURIComponent).join("&");
107
+ }
108
+ updateChecked(e) {
109
+ this.values = e == null || this.multiple && e === "" ? [] : this.multiple ? [...new Set(String(e).split("&").map((e) => {
110
+ try {
111
+ e = decodeURIComponent(e);
112
+ } catch {}
113
+ return o.normalizeToken(e);
114
+ }))] : [o.normalizeToken(String(e))], this.reconcileRadio();
115
+ }
116
+ reconcileRadio() {
117
+ if (this.multiple) return;
118
+ let [e] = this.values, t = this.provider?.getFields() ?? [];
119
+ this.selectedRadio?.token === e && t.some(({ target: e }) => e === this.selectedRadio) || (this.selectedRadio = t.map(({ target: e }) => e).find((t) => t instanceof o && t.token === e));
120
+ }
121
+ syncMembers() {
122
+ let e = this.selectedRadio;
123
+ this.reconcileRadio(), e !== this.selectedRadio && this.publishConfiguration(), this.multiple || o.syncRadioTabStops(this.getRadioMembers(), this.selectedRadio), this.syncNativeValue();
124
+ }
125
+ getRadioMembers() {
126
+ return this.multiple ? [] : this.provider.getFields().map(({ target: e }) => e).filter((e) => e instanceof o && e._inputType === "radio");
127
+ }
128
+ serializeFormValue() {
129
+ let e = this.matchingValues(!1);
130
+ if (!this.multiple) return e[0] ?? null;
131
+ let t = this.getName();
132
+ if (!t || !e.length) return null;
133
+ let n = new FormData();
134
+ for (let r of e) n.append(t, r);
135
+ return n;
136
+ }
137
+ get requiredSelection() {
138
+ return this.matchingValues(!1).length > 0;
139
+ }
140
+ get nativeValueMissing() {
141
+ return !this.requiredSelection;
142
+ }
143
+ get valueSnapshot() {
144
+ let e = this.matchingValues(!0);
145
+ return e.length === this.values.length ? this.value : this.multiple ? this.encodeValues(e) : null;
146
+ }
147
+ matchingValues(e) {
148
+ if (!this.multiple) return this.selectedRadio && (e || !this.selectedRadio.isDisabled()) ? [this.selectedRadio.token] : [];
149
+ let t = /* @__PURE__ */ new Set();
150
+ for (let { target: n } of this.provider?.getFields() ?? []) n instanceof o && (e || !n.isDisabled()) && t.add(n.token);
151
+ return (this.values ?? []).filter((e) => t.has(e));
152
+ }
153
+ serializeFormState() {
154
+ if (this.multiple) return super.serializeFormState();
155
+ let e = this.value ?? null;
156
+ return JSON.stringify({
157
+ version: 1,
158
+ value: e,
159
+ emptySelected: e === "" || void 0
160
+ });
161
+ }
162
+ formStateRestoreCallback(e, t) {
163
+ if (!this.multiple && typeof e == "string") try {
164
+ let t = JSON.parse(e);
165
+ t?.version === 1 && t.value === "" && !t.emptySelected && (e = JSON.stringify({
166
+ version: 1,
167
+ value: null
168
+ }));
169
+ } catch {}
170
+ super.formStateRestoreCallback(e, t);
171
+ }
172
+ reset() {
173
+ this.selectedRadio = void 0, super.reset();
68
174
  }
69
175
  };
70
- //#endregion
71
- export { s as default };
176
+ export { c as default };
@@ -1,4 +1,3 @@
1
- //#region src/components/check/index.less?inline
1
+ // src/components/check/index.less?inline
2
2
  var e = ":host{align-items:center;gap:var(--l-check-gap,0px);display:flex}";
3
- //#endregion
4
3
  export { e as default };
@@ -1,15 +1,14 @@
1
1
  import e from "./check.js";
2
2
  import t from "./check.less_inline.js";
3
3
  import n from "./radio.less_inline.js";
4
- //#region src/components/check/radio.ts
4
+ // src/components/check/radio.ts
5
5
  var r = class extends e {
6
6
  static baseName = "radio";
7
7
  connectedCallback() {
8
8
  this.loadStyleText([t, n]), super.connectedCallback();
9
9
  }
10
10
  _doChangeAction() {
11
- this.setChecked(!0), this.emitChange();
11
+ super._doChangeAction();
12
12
  }
13
13
  };
14
- //#endregion
15
14
  export { r as default };
@@ -1,4 +1,3 @@
1
- //#region src/components/check/radio.less?inline
1
+ // src/components/check/radio.less?inline
2
2
  var e = ".l-check__inner{border-radius:50%}.l-check__inner:after{content:\"\";background-color:#0000;border-radius:50%;width:60%;height:60%;transition:background-color .3s ease-in-out;display:block}:host(.is-checked) .l-check__inner:after{background-color:var(--l-primary-color,#722ed1)}:host(.is-disabled) .l-check__inner{border-color:var(--l-disabled-color,#e6e6e6)}:host(.is-disabled) .l-check__inner:after{background-color:var(--l-disabled-color,#e6e6e6)}";
3
- //#endregion
4
3
  export { e as default };
@@ -1,10 +1,9 @@
1
1
  import e from "./index.js";
2
- //#region src/components/check/radio_group.ts
2
+ // src/components/check/radio_group.ts
3
3
  var t = class extends e {
4
4
  static baseName = "radio-group";
5
5
  constructor() {
6
- super(), this.multiple = !1;
6
+ super(), this.multiple = !1, this.internals.role = "radiogroup";
7
7
  }
8
8
  };
9
- //#endregion
10
9
  export { t as default };
@@ -1,4 +1,5 @@
1
1
  import BaseComponent from "../base";
2
+ import type { CollapseExpandChange } from "./types";
2
3
  type CollapseState = {
3
4
  borderRadius?: string;
4
5
  grid?: boolean;
@@ -7,11 +8,14 @@ type CollapseState = {
7
8
  };
8
9
  export default class Collapase extends BaseComponent<CollapseState> {
9
10
  static baseName: string;
10
- private context;
11
- private expands;
11
+ private _layout;
12
+ private readonly context;
13
+ private _expandedProps;
14
+ private readonly _items;
15
+ private readonly expands;
12
16
  constructor();
13
17
  static get observedAttributes(): string[];
14
- attributeChanged(name: string, oldValue: string, newValue: string): void;
18
+ attributeChanged(name: string, oldValue: string, newValue: string | null): void;
15
19
  protected updateDOM(changedProps: Set<string>): void;
16
20
  render_v2(): {
17
21
  template: HTMLElement;
@@ -21,6 +25,10 @@ export default class Collapase extends BaseComponent<CollapseState> {
21
25
  afterInit(): void;
22
26
  private _provide;
23
27
  beforeDestroy(): void;
24
- _onChange: (e: CustomEvent) => void;
28
+ private _registerItem;
29
+ private _applyExpandedProps;
30
+ private _updateItemExpand;
31
+ private _setItemExpand;
32
+ _onChange: (e: CustomEvent<CollapseExpandChange>) => void;
25
33
  }
26
34
  export {};
@@ -1,19 +1,27 @@
1
1
  import e from "../base.js";
2
- import { kebabToCamel as t, parseAttrValue as n, unitNumberStr as r } from "../utils/index.js";
3
- import i from "./index.less_inline.js";
4
- import { $$ as a, off as o, on as s } from "utilane/browser";
5
- import { signal as c } from "alien-signals";
6
- //#region src/components/collapse/index.ts
7
- var l = class extends e {
2
+ import { parseAttrValue as t, unitNumberStr as n } from "../utils/index.js";
3
+ import r from "./index.less_inline.js";
4
+ import { $$ as i, off as a, on as o } from "utilane/browser";
5
+ // src/components/collapse/index.ts
6
+ var s = class extends e {
8
7
  static baseName = "collapse";
9
- context;
10
- expands;
8
+ _layout = {
9
+ arrowPlacement: "left",
10
+ headerJustify: "flex-start",
11
+ background: !1
12
+ };
13
+ context = ((e) => {
14
+ if (e === void 0) return this._layout;
15
+ this._layout = e, this.rendered && this._setStyleAndClass();
16
+ });
17
+ _expandedProps = [];
18
+ _items = /* @__PURE__ */ new Set();
19
+ expands = ((e) => {
20
+ if (e === void 0) return this._expandedProps;
21
+ this._applyExpandedProps(e);
22
+ });
11
23
  constructor() {
12
- super(), this.version = 2, this.context = c({
13
- arrowPlacement: "left",
14
- headerJustify: "flex-start",
15
- background: !1
16
- }), this.expands = c([]), this._state = {
24
+ super(), this.version = 2, this._state = {
17
25
  grid: !1,
18
26
  accordion: !1
19
27
  };
@@ -30,74 +38,100 @@ var l = class extends e {
30
38
  "prop"
31
39
  ];
32
40
  }
33
- attributeChanged(e, i, a) {
41
+ attributeChanged(e, r, i) {
34
42
  switch (e) {
35
43
  case "arrow-placement":
44
+ this.context({
45
+ ...this._layout,
46
+ arrowPlacement: i === "right" ? "right" : "left"
47
+ });
48
+ break;
36
49
  case "header-justify":
37
- let i = { ...this.context() };
38
- i[t(e)] = a, this.context(i);
50
+ this.context({
51
+ ...this._layout,
52
+ headerJustify: i === "flex-end" || i === "space-between" ? i : "flex-start"
53
+ });
39
54
  break;
40
55
  case "gap":
41
56
  this.context({
42
- ...this.context(),
43
- gap: r(a)
57
+ ...this._layout,
58
+ gap: n(i) || void 0
44
59
  });
45
60
  break;
46
61
  case "border-radius":
47
- this._state.borderRadius = r(a);
62
+ this._state.borderRadius = n(i) || void 0;
48
63
  break;
49
64
  case "background":
50
65
  this.context({
51
- ...this.context(),
52
- background: n(a, !1, e)
66
+ ...this._layout,
67
+ background: t(i, !1, e)
53
68
  });
54
69
  break;
55
- case "accordion":
56
70
  case "grid":
57
- this._state[e] = n(a, !1, e);
71
+ this._state.grid = t(i, !1, e);
72
+ break;
73
+ case "accordion": {
74
+ this._state.accordion = t(i, !1, e);
75
+ let n = this._expandedProps;
76
+ this._state.accordion && n.length > 1 && this._updateItemExpand({
77
+ prop: n[0],
78
+ expand: !0
79
+ });
80
+ break;
81
+ }
82
+ case "prop": {
83
+ let e = i === null ? [] : i.split("&"), t = this._state.accordion ? e.slice(0, 1) : e;
84
+ this._state.prop = i === null ? void 0 : t.join("&"), this._applyExpandedProps(t);
58
85
  break;
59
- case "prop": if (a !== this._state.prop) {
60
- this._state.prop = a;
61
- let e = [], t = a.split("&");
62
- for (let n = 0, r = t.length; n < r; n++) e.push(t[n]);
63
- this.expands(e);
64
86
  }
65
87
  }
66
88
  }
67
89
  updateDOM(e) {
68
- (e.has("gap") || e.has("borderRadius") || e.has("grid")) && this._setStyleAndClass();
90
+ (e.has("border-radius") || e.has("grid")) && this._setStyleAndClass();
69
91
  }
70
92
  render_v2() {
71
93
  return {
72
- template: a("slot"),
73
- style: i
94
+ template: i("slot"),
95
+ style: r
74
96
  };
75
97
  }
76
98
  _setStyleAndClass() {
77
- this.context().gap ? this.style.setProperty("--l-collapse-gap", this.context().gap) : this.style.removeProperty("--l-collapse-gap"), this._state.borderRadius ? this.style.setProperty("--l-collapse-border-radius", this._state.borderRadius) : this.style.removeProperty("--l-collapse-border-radius"), this._state.grid ? this.classList.add("l-collapse-grid") : this.classList.remove("l-collapse-grid");
99
+ let { gap: e, arrowPlacement: t, headerJustify: n, background: r } = this._layout, i = t === "right", a = i === (n === "flex-end") ? "flex-start" : "flex-end";
100
+ this.style.setProperty("--_l-collapse-gap-attribute", e ?? ""), this.style.setProperty("--_l-collapse-radius-attribute", this._state.borderRadius ?? ""), this.style.setProperty("--l-collapse-header-direction", i ? "row-reverse" : "row"), this.style.setProperty("--l-collapse-header-justify", n === "space-between" ? n : a), this.classList.toggle("l-collapse-background", r), this.classList.toggle("l-collapse-spaced", !!e), this.classList.toggle("l-collapse-grid", !!this._state.grid);
78
101
  }
79
102
  afterInit() {
80
- this._setStyleAndClass(), s(this, "collapse-context-request", this._provide), s(this, "expand-change", this._onChange);
103
+ this._setStyleAndClass(), o(this, "collapse-context-request", this._provide), this.dispatchEvent(new Event("collapse-context-ready"));
81
104
  }
82
105
  _provide(e) {
83
106
  let { context: t, callback: n } = e.detail;
84
- t === "collapse-context-request" && n(this.context, this.expands);
107
+ t === "collapse-context-request" && n(this.context, this.expands, this._setItemExpand, this._registerItem);
85
108
  }
86
109
  beforeDestroy() {
87
- o(this, "collapse-context-request", this._provide), o(this, "expand-change", this._onChange);
110
+ a(this, "collapse-context-request", this._provide), this._items.clear();
88
111
  }
89
- _onChange = (e) => {
90
- let t = e.detail, n = this.expands();
91
- if (t.expand) this._state.accordion ? n = [t.prop] : n.includes(t.prop) || n.push(t.prop);
92
- else {
93
- let e = n.indexOf(t.prop);
94
- e !== -1 && n.splice(e, 1);
112
+ _registerItem = (e) => (this._items.add(e), () => {
113
+ this._items.delete(e);
114
+ });
115
+ _applyExpandedProps(e) {
116
+ if (this._expandedProps !== e) {
117
+ this._expandedProps = e;
118
+ for (let e of this._items) e.applyExpand(this._expandedProps.includes(e.getProp()));
95
119
  }
96
- this.expands([...n]), this._state.prop = n.join("&"), this.emit("change", { detail: {
97
- expands: n,
98
- value: this._state.prop
120
+ }
121
+ _updateItemExpand = ({ prop: e, expand: t }) => {
122
+ let n = this._expandedProps, r = n;
123
+ t ? this._state.accordion ? (n.length !== 1 || n[0] !== e) && (r = [e]) : n.includes(e) || (r = [...n, e]) : n.includes(e) && (r = n.filter((t) => t !== e)), r !== n && (this._state.prop = r.join("&"), this._applyExpandedProps(r));
124
+ };
125
+ _setItemExpand = (e, t = !1) => {
126
+ if (this._updateItemExpand(e), !t) return;
127
+ let n = this._expandedProps;
128
+ this.emit("change", { detail: {
129
+ expands: [...n],
130
+ value: n.join("&")
99
131
  } });
100
132
  };
133
+ _onChange = (e) => {
134
+ this._setItemExpand(e.detail, !0);
135
+ };
101
136
  };
102
- //#endregion
103
- export { l as default };
137
+ export { s as default };
@@ -1,4 +1,3 @@
1
- //#region src/components/collapse/index.less?inline
2
- var e = ":host{--l-collapse-border-color:var(--l-border-color,#dedede);--l-collapse-border-radius:0px;gap:var(--l-collapse-gap,0px);box-sizing:border-box;grid-template-columns:1fr;display:grid}:host(.l-collapse-grid){grid-template-columns:repeat(auto-fill,minmax(200px,1fr));align-items:start}";
3
- //#endregion
1
+ // src/components/collapse/index.less?inline
2
+ var e = ":host{--_l-collapse-gap-attribute:initial;--_l-collapse-radius-attribute:initial;--l-collapse-border-color:var(--l-border-color,#dedede);--l-collapse-border-radius:var(--_l-collapse-radius-attribute,0px);--l-collapse-gap:var(--_l-collapse-gap-attribute,0px);--l-collapse-header-direction:row;--l-collapse-header-justify:flex-start;--l-collapse-frame-width:0px;--l-collapse-header-padding:10px 0;--l-collapse-content-padding:0 0 15px;--l-collapse-item-background:transparent;--l-collapse-content-background:transparent;--l-collapse-spaced-border-width:0px;--l-collapse-spaced-radius:initial;gap:var(--l-collapse-gap,0px);box-sizing:border-box;grid-template-columns:1fr;display:grid}:host(.l-collapse-background){--l-collapse-frame-width:1px;--l-collapse-header-padding:10px 15px;--l-collapse-content-padding:15px;--l-collapse-item-background:var(--_l-collapse-header-fill,#00000005);--l-collapse-content-background:var(--_l-collapse-panel-fill,#fff)}:host(.l-collapse-spaced){--l-collapse-spaced-border-width:var(--l-collapse-frame-width);--l-collapse-spaced-radius:var(--l-collapse-border-radius)}:host(.l-collapse-grid){grid-template-columns:repeat(auto-fill,minmax(200px,1fr));align-items:start}";
4
3
  export { e as default };
@@ -1,6 +1,5 @@
1
- import type { Signal } from "../utils/signal_types";
2
1
  import BaseComponent from "../base";
3
- import type { CollapseContext } from "./types";
2
+ import type { CollapseAccessor, CollapseContext, CollapseExpandChange, SetCollapseItemExpand } from "./types";
4
3
  type CollapaseItemState = {
5
4
  prop: string;
6
5
  headerText: string;
@@ -9,27 +8,54 @@ type CollapaseItemState = {
9
8
  export default class CollapaseItem extends BaseComponent<CollapaseItemState> {
10
9
  static baseName: string;
11
10
  private $header?;
11
+ private $toggle?;
12
+ private $titleSlot?;
13
+ private _captionObserver?;
12
14
  context?: CollapseContext;
13
- private _ctxStop?;
14
- private _expandStop?;
15
- expands?: Signal<string[]>;
15
+ private _pendingExpand?;
16
+ private _pendingGroup?;
17
+ private _setGroupExpand?;
18
+ private _unregisterGroupItem?;
19
+ private _visualExpanded;
20
+ private _expandFrame?;
21
+ private _expandAnimation?;
22
+ private _stopWatchingExpansion?;
23
+ expands?: CollapseAccessor<string[]>;
16
24
  constructor();
17
25
  protected updateDOM(changedProps: Set<string>): void;
18
26
  _setStyleAndClass(): void;
19
27
  static get observedAttributes(): string[];
20
- protected attributeChanged(name: string, oldValue: string, newValue: string): void;
28
+ protected attributeChanged(name: string, oldValue: string, newValue: string | null): void;
21
29
  render_v2(): {
22
30
  template: DocumentFragment;
23
31
  style: string;
24
32
  };
33
+ private _headingLevel;
34
+ private _createHeaderText;
35
+ private _updateHeaderText;
36
+ private _setTitleSlot;
37
+ private _observeTitleCaption;
38
+ private _updateToggleLabel;
25
39
  afterInit(): void;
40
+ private _connectGroup;
41
+ private _receiveGroupContext;
42
+ private _handleGroupReady;
26
43
  beforeDestroy(): void;
27
44
  _handleExpandsChange: () => void;
28
- _handleHeaderTap: () => void;
45
+ _handleHeaderTap: (event?: Event) => void;
46
+ private _applyExpand;
47
+ private _applyAttributeExpand;
29
48
  _updateLayout: () => void;
30
- contextInject: (ctx: CollapseContext, exds: Signal<string[]>) => void;
49
+ contextInject: (ctx: CollapseContext, exds: CollapseAccessor<string[]>, setGroupExpand?: SetCollapseItemExpand) => void;
31
50
  _handleExpand(): void;
32
- _emitChange: () => void;
51
+ private _commitExpansion;
52
+ private _expandedHeight;
53
+ private _playHeightAnimation;
54
+ private _watchExpansion;
55
+ private _settleExpansion;
56
+ private _cancelExpandAnimation;
57
+ private _cancelHeightAnimation;
58
+ _emitChange: (detail?: CollapseExpandChange) => void;
33
59
  _createContentElement(hide?: boolean): HTMLElement;
34
60
  }
35
61
  export {};