@threadlabs/looma 0.6.4 → 0.6.5

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 (247) hide show
  1. package/package.json +2 -2
  2. package/styles/ui-affordance-scope.css +1 -1
  3. package/styles/ui-avatar-group.css +1 -1
  4. package/styles/ui-avatar.css +1 -1
  5. package/styles/ui-badge.css +1 -1
  6. package/styles/ui-button.css +1 -1
  7. package/styles/ui-callout.css +1 -1
  8. package/styles/ui-checkbox.css +1 -1
  9. package/styles/ui-cluster.css +1 -1
  10. package/styles/ui-combobox.css +1 -1
  11. package/styles/ui-container.css +1 -1
  12. package/styles/ui-context-menu.css +1 -1
  13. package/styles/ui-dialog.css +1 -1
  14. package/styles/ui-disclosure.css +1 -1
  15. package/styles/ui-editable.css +1 -1
  16. package/styles/ui-editor-insert-table-grid.css +1 -1
  17. package/styles/ui-editor-mention-menu.css +1 -1
  18. package/styles/ui-editor-slash-menu.css +1 -1
  19. package/styles/ui-editor-table-context-menu.css +1 -1
  20. package/styles/ui-editor-table-overlay.css +1 -1
  21. package/styles/ui-editor-table-toolbar.css +1 -1
  22. package/styles/ui-editor-toolbar.css +1 -1
  23. package/styles/ui-floating-action-button.css +1 -1
  24. package/styles/ui-form-field.css +1 -1
  25. package/styles/ui-grid.css +1 -1
  26. package/styles/ui-icon-button.css +1 -1
  27. package/styles/ui-icon.css +1 -1
  28. package/styles/ui-input.css +1 -1
  29. package/styles/ui-menu-item.css +1 -1
  30. package/styles/ui-menu.css +1 -1
  31. package/styles/ui-popover.css +1 -1
  32. package/styles/ui-radio-group.css +1 -1
  33. package/styles/ui-radio.css +1 -1
  34. package/styles/ui-reel.css +1 -1
  35. package/styles/ui-search-result-row.css +1 -1
  36. package/styles/ui-search-shell.css +1 -1
  37. package/styles/ui-select.css +1 -1
  38. package/styles/ui-separator.css +1 -1
  39. package/styles/ui-sidebar.css +1 -1
  40. package/styles/ui-stack.css +1 -1
  41. package/styles/ui-switch.css +1 -1
  42. package/styles/ui-switcher.css +1 -1
  43. package/styles/ui-tabs.css +1 -1
  44. package/styles/ui-textarea.css +1 -1
  45. package/styles/ui-toast-region.css +1 -1
  46. package/styles/ui-tooltip.css +1 -1
  47. package/styles/ui-top-bar.css +1 -1
  48. package/styles/ui-tree-item.css +1 -1
  49. package/styles/ui-tree.css +1 -1
  50. package/vanilla/UiAffordanceScope.d.ts +1 -1
  51. package/vanilla/UiAffordanceScope.js +1 -1
  52. package/vanilla/UiAvatar.d.ts +1 -1
  53. package/vanilla/UiAvatar.js +1 -1
  54. package/vanilla/UiAvatarGroup.d.ts +1 -1
  55. package/vanilla/UiAvatarGroup.js +1 -1
  56. package/vanilla/UiBadge.d.ts +1 -1
  57. package/vanilla/UiBadge.js +1 -1
  58. package/vanilla/UiButton.d.ts +1 -1
  59. package/vanilla/UiButton.js +1 -1
  60. package/vanilla/UiCallout.d.ts +1 -1
  61. package/vanilla/UiCallout.js +1 -1
  62. package/vanilla/UiCheckbox.d.ts +1 -1
  63. package/vanilla/UiCheckbox.js +1 -1
  64. package/vanilla/UiCluster.d.ts +1 -1
  65. package/vanilla/UiCluster.js +1 -1
  66. package/vanilla/UiCombobox.d.ts +1 -1
  67. package/vanilla/UiCombobox.js +1 -1
  68. package/vanilla/UiContainer.d.ts +1 -1
  69. package/vanilla/UiContainer.js +1 -1
  70. package/vanilla/UiContextMenu.d.ts +1 -1
  71. package/vanilla/UiContextMenu.js +1 -1
  72. package/vanilla/UiDialog.d.ts +1 -1
  73. package/vanilla/UiDialog.js +1 -1
  74. package/vanilla/UiDisclosure.d.ts +1 -1
  75. package/vanilla/UiDisclosure.js +1 -1
  76. package/vanilla/UiEditable.d.ts +1 -1
  77. package/vanilla/UiEditable.js +1 -1
  78. package/vanilla/UiEditorInsertTableGrid.d.ts +1 -1
  79. package/vanilla/UiEditorInsertTableGrid.js +1 -1
  80. package/vanilla/UiEditorMentionMenu.d.ts +1 -1
  81. package/vanilla/UiEditorMentionMenu.js +1 -1
  82. package/vanilla/UiEditorSlashMenu.d.ts +1 -1
  83. package/vanilla/UiEditorSlashMenu.js +1 -1
  84. package/vanilla/UiEditorTableContextMenu.d.ts +1 -1
  85. package/vanilla/UiEditorTableContextMenu.js +1 -1
  86. package/vanilla/UiEditorTableOverlay.d.ts +1 -1
  87. package/vanilla/UiEditorTableOverlay.js +1 -1
  88. package/vanilla/UiEditorTableToolbar.d.ts +1 -1
  89. package/vanilla/UiEditorTableToolbar.js +1 -1
  90. package/vanilla/UiEditorToolbar.d.ts +1 -1
  91. package/vanilla/UiEditorToolbar.js +1 -1
  92. package/vanilla/UiFloatingActionButton.d.ts +1 -1
  93. package/vanilla/UiFloatingActionButton.js +1 -1
  94. package/vanilla/UiFormField.d.ts +1 -1
  95. package/vanilla/UiFormField.js +1 -1
  96. package/vanilla/UiGrid.d.ts +1 -1
  97. package/vanilla/UiGrid.js +1 -1
  98. package/vanilla/UiIcon.d.ts +1 -1
  99. package/vanilla/UiIcon.js +1 -1
  100. package/vanilla/UiIconButton.d.ts +1 -1
  101. package/vanilla/UiIconButton.js +1 -1
  102. package/vanilla/UiInput.d.ts +1 -1
  103. package/vanilla/UiInput.js +1 -1
  104. package/vanilla/UiMenu.d.ts +1 -1
  105. package/vanilla/UiMenu.js +1 -1
  106. package/vanilla/UiMenuItem.d.ts +1 -1
  107. package/vanilla/UiMenuItem.js +1 -1
  108. package/vanilla/UiPopover.d.ts +1 -1
  109. package/vanilla/UiPopover.js +1 -1
  110. package/vanilla/UiRadio.d.ts +1 -1
  111. package/vanilla/UiRadio.js +1 -1
  112. package/vanilla/UiRadioGroup.d.ts +1 -1
  113. package/vanilla/UiRadioGroup.js +1 -1
  114. package/vanilla/UiReel.d.ts +1 -1
  115. package/vanilla/UiReel.js +1 -1
  116. package/vanilla/UiSearchResultRow.d.ts +1 -1
  117. package/vanilla/UiSearchResultRow.js +1 -1
  118. package/vanilla/UiSearchShell.d.ts +1 -1
  119. package/vanilla/UiSearchShell.js +1 -1
  120. package/vanilla/UiSelect.d.ts +1 -1
  121. package/vanilla/UiSelect.js +1 -1
  122. package/vanilla/UiSeparator.d.ts +1 -1
  123. package/vanilla/UiSeparator.js +1 -1
  124. package/vanilla/UiSidebar.d.ts +1 -1
  125. package/vanilla/UiSidebar.js +1 -1
  126. package/vanilla/UiStack.d.ts +1 -1
  127. package/vanilla/UiStack.js +1 -1
  128. package/vanilla/UiSwitch.d.ts +1 -1
  129. package/vanilla/UiSwitch.js +1 -1
  130. package/vanilla/UiSwitcher.d.ts +1 -1
  131. package/vanilla/UiSwitcher.js +1 -1
  132. package/vanilla/UiTabs.d.ts +1 -1
  133. package/vanilla/UiTabs.js +1 -1
  134. package/vanilla/UiTextarea.d.ts +1 -1
  135. package/vanilla/UiTextarea.js +1 -1
  136. package/vanilla/UiToastRegion.d.ts +1 -1
  137. package/vanilla/UiToastRegion.js +1 -1
  138. package/vanilla/UiTooltip.d.ts +1 -1
  139. package/vanilla/UiTooltip.js +1 -1
  140. package/vanilla/UiTopBar.d.ts +1 -1
  141. package/vanilla/UiTopBar.js +1 -1
  142. package/vanilla/UiTree.d.ts +1 -1
  143. package/vanilla/UiTree.js +1 -1
  144. package/vanilla/UiTreeItem.d.ts +1 -1
  145. package/vanilla/UiTreeItem.js +1 -1
  146. package/vue/UiAffordanceScope.vue +8 -84
  147. package/vue/UiAvatar.d.ts +1 -1
  148. package/vue/UiAvatar.vue +9 -106
  149. package/vue/UiAvatarGroup.vue +9 -96
  150. package/vue/UiBadge.vue +1 -1
  151. package/vue/UiButton.vue +1 -1
  152. package/vue/UiCallout.vue +1 -1
  153. package/vue/UiCheckbox.vue +22 -123
  154. package/vue/UiCluster.vue +1 -1
  155. package/vue/UiCombobox.d.ts +1 -1
  156. package/vue/UiCombobox.vue +224 -475
  157. package/vue/UiContainer.vue +1 -1
  158. package/vue/UiContextMenu.vue +34 -141
  159. package/vue/UiDialog.vue +25 -126
  160. package/vue/UiDisclosure.vue +26 -138
  161. package/vue/UiEditable.vue +46 -158
  162. package/vue/UiEditorInsertTableGrid.vue +19 -138
  163. package/vue/UiEditorMentionMenu.vue +17 -124
  164. package/vue/UiEditorSlashMenu.vue +17 -109
  165. package/vue/UiEditorTableContextMenu.vue +34 -122
  166. package/vue/UiEditorTableOverlay.vue +61 -167
  167. package/vue/UiEditorTableToolbar.vue +34 -142
  168. package/vue/UiEditorToolbar.vue +1 -1
  169. package/vue/UiFloatingActionButton.vue +1 -1
  170. package/vue/UiFormField.vue +7 -79
  171. package/vue/UiGrid.vue +1 -1
  172. package/vue/UiIcon.vue +8 -84
  173. package/vue/UiIconButton.vue +7 -79
  174. package/vue/UiInput.vue +7 -79
  175. package/vue/UiMenu.vue +42 -127
  176. package/vue/UiMenuItem.vue +1 -1
  177. package/vue/UiPopover.vue +25 -121
  178. package/vue/UiRadio.vue +22 -123
  179. package/vue/UiRadioGroup.d.ts +1 -1
  180. package/vue/UiRadioGroup.vue +32 -119
  181. package/vue/UiReel.vue +1 -1
  182. package/vue/UiSearchResultRow.vue +1 -1
  183. package/vue/UiSearchShell.vue +25 -121
  184. package/vue/UiSelect.vue +7 -79
  185. package/vue/UiSeparator.vue +1 -1
  186. package/vue/UiSidebar.vue +32 -133
  187. package/vue/UiStack.vue +1 -1
  188. package/vue/UiSwitch.vue +22 -123
  189. package/vue/UiSwitcher.vue +1 -1
  190. package/vue/UiTabs.vue +24 -128
  191. package/vue/UiTextarea.vue +7 -79
  192. package/vue/UiToastRegion.vue +37 -126
  193. package/vue/UiTooltip.vue +25 -124
  194. package/vue/UiTopBar.vue +1 -1
  195. package/vue/UiTree.vue +56 -137
  196. package/vue/UiTreeItem.vue +28 -144
  197. package/vue/chunks/UiAffordanceScope.js +9 -78
  198. package/vue/chunks/UiAvatar.js +13 -89
  199. package/vue/chunks/UiAvatarGroup.js +10 -80
  200. package/vue/chunks/UiBadge.js +1 -1
  201. package/vue/chunks/UiButton.js +1 -1
  202. package/vue/chunks/UiCallout.js +1 -1
  203. package/vue/chunks/UiCheckbox.js +17 -95
  204. package/vue/chunks/UiCluster.js +1 -1
  205. package/vue/chunks/UiCombobox.js +114 -325
  206. package/vue/chunks/UiContainer.js +1 -1
  207. package/vue/chunks/UiContextMenu.js +21 -113
  208. package/vue/chunks/UiDialog.js +20 -99
  209. package/vue/chunks/UiDisclosure.js +22 -112
  210. package/vue/chunks/UiEditable.js +32 -128
  211. package/vue/chunks/UiEditorInsertTableGrid.js +22 -116
  212. package/vue/chunks/UiEditorMentionMenu.js +18 -116
  213. package/vue/chunks/UiEditorSlashMenu.js +15 -101
  214. package/vue/chunks/UiEditorTableContextMenu.js +12 -91
  215. package/vue/chunks/UiEditorTableOverlay.js +29 -120
  216. package/vue/chunks/UiEditorTableToolbar.js +16 -111
  217. package/vue/chunks/UiEditorToolbar.js +1 -1
  218. package/vue/chunks/UiFloatingActionButton.js +1 -1
  219. package/vue/chunks/UiFormField.js +8 -73
  220. package/vue/chunks/UiGrid.js +1 -1
  221. package/vue/chunks/UiIcon.js +9 -78
  222. package/vue/chunks/UiIconButton.js +8 -73
  223. package/vue/chunks/UiInput.js +8 -73
  224. package/vue/chunks/UiMenu.js +25 -111
  225. package/vue/chunks/UiMenuItem.js +1 -1
  226. package/vue/chunks/UiPopover.js +18 -105
  227. package/vue/chunks/UiRadio.js +17 -95
  228. package/vue/chunks/UiRadioGroup.js +23 -105
  229. package/vue/chunks/UiReel.js +1 -1
  230. package/vue/chunks/UiSearchResultRow.js +1 -1
  231. package/vue/chunks/UiSearchShell.js +17 -94
  232. package/vue/chunks/UiSelect.js +8 -73
  233. package/vue/chunks/UiSeparator.js +1 -1
  234. package/vue/chunks/UiSidebar.js +23 -108
  235. package/vue/chunks/UiStack.js +1 -1
  236. package/vue/chunks/UiSwitch.js +17 -95
  237. package/vue/chunks/UiSwitcher.js +1 -1
  238. package/vue/chunks/UiTabs.js +22 -103
  239. package/vue/chunks/UiTextarea.js +8 -73
  240. package/vue/chunks/UiToastRegion.js +27 -112
  241. package/vue/chunks/UiTooltip.js +18 -106
  242. package/vue/chunks/UiTopBar.js +1 -1
  243. package/vue/chunks/UiTree.js +31 -109
  244. package/vue/chunks/UiTreeItem.js +29 -119
  245. package/vue/chunks/host.js +101 -0
  246. package/vue/components.css +706 -706
  247. package/vue/host.ts +154 -0
@@ -1,5 +1,6 @@
1
+ import { n as useComponentHost, t as createDispatch } from "./host.js";
1
2
  import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
2
- import { computed, createElementBlock, defineComponent, mergeProps, onBeforeUnmount, onMounted, openBlock, ref, renderSlot, shallowRef, watchEffect } from "vue";
3
+ import { computed, createElementBlock, defineComponent, mergeProps, openBlock, ref, renderSlot } from "vue";
3
4
  import * as controllerModule from "@threadlabs/looma/components/ui-tree/ui-tree.js";
4
5
  //#region .build/vue/UiTree.vue?vue&type=script&setup=true&lang.ts
5
6
  var _hoisted_1 = ["data-ui-tree-state"];
@@ -25,115 +26,36 @@ var UiTree_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
25
26
  const root = ref(null);
26
27
  /** The values the styles' :host-state() rules test. */
27
28
  const hostState = computed(() => [props.density && `density density=${props.density}`].filter(Boolean).join(" "));
28
- /** Dispatches a component event to Vue listeners and, for controllers and page code, on the root. */
29
- function dispatch(name, detail) {
30
- const declared = {
31
- reorder: {
32
- bubbles: true,
33
- composed: true,
34
- cancelable: false
35
- },
36
- "reorder-rejected": {
37
- bubbles: true,
38
- composed: true,
39
- cancelable: false
40
- }
41
- };
42
- const checks = {
43
- reorder: (detail) => detail !== null && typeof detail === "object" && !Array.isArray(detail) && typeof detail["sourceId"] === "string" && typeof detail["targetId"] === "string" && (detail["position"] === "before" || detail["position"] === "inside" || detail["position"] === "after") && typeof detail["sourceType"] === "string" && typeof detail["targetType"] === "string" && typeof detail["sourceScope"] === "string" && typeof detail["targetScope"] === "string" && (detail["trigger"] === "keyboard" || detail["trigger"] === "pointer" || detail["trigger"] === "programmatic") && Object.keys(detail).every((key) => [
44
- "sourceId",
45
- "targetId",
46
- "position",
47
- "sourceType",
48
- "targetType",
49
- "sourceScope",
50
- "targetScope",
51
- "trigger"
52
- ].includes(key)),
53
- "reorder-rejected": (detail) => detail !== null && typeof detail === "object" && !Array.isArray(detail) && typeof detail["sourceId"] === "string" && typeof detail["targetId"] === "string" && (detail["position"] === "before" || detail["position"] === "inside" || detail["position"] === "after") && detail["reason"] === "max-depth" && Number.isInteger(detail["maxDepth"]) && Number.isInteger(detail["resultingDepth"]) && (detail["trigger"] === "keyboard" || detail["trigger"] === "pointer" || detail["trigger"] === "programmatic") && Object.keys(detail).every((key) => [
54
- "sourceId",
55
- "targetId",
56
- "position",
57
- "reason",
58
- "maxDepth",
59
- "resultingDepth",
60
- "trigger"
61
- ].includes(key))
62
- };
63
- if (detail !== void 0 && checks[name] !== void 0 && !checks[name](detail)) throw new TypeError(`HR002: Event \`${name}\` detail does not satisfy its declared type.`);
64
- const emitEvent = emit;
65
- emitEvent(name, detail);
66
- if (detail !== null && typeof detail === "object" && "maxDepth" in detail) emitEvent("update:maxDepth", detail["maxDepth"]);
67
- return root.value?.dispatchEvent(new CustomEvent(name, {
68
- bubbles: true,
69
- composed: true,
70
- ...declared[name],
71
- detail
72
- })) ?? true;
73
- }
74
- function read(name) {
75
- return props[name];
76
- }
77
- function write(name, value) {
78
- throw new TypeError(`Only declared state is writable; \`${name}\` is not.`);
79
- }
80
- const stops = [];
81
- const host = {
82
- get element() {
83
- return root.value;
29
+ const isReorderDetail = (detail) => detail !== null && typeof detail === "object" && !Array.isArray(detail) && typeof detail["sourceId"] === "string" && typeof detail["targetId"] === "string" && (detail["position"] === "before" || detail["position"] === "inside" || detail["position"] === "after") && typeof detail["sourceType"] === "string" && typeof detail["targetType"] === "string" && typeof detail["sourceScope"] === "string" && typeof detail["targetScope"] === "string" && (detail["trigger"] === "keyboard" || detail["trigger"] === "pointer" || detail["trigger"] === "programmatic") && Object.keys(detail).every((key) => [
30
+ "sourceId",
31
+ "targetId",
32
+ "position",
33
+ "sourceType",
34
+ "targetType",
35
+ "sourceScope",
36
+ "targetScope",
37
+ "trigger"
38
+ ].includes(key));
39
+ const isReorderRejectedDetail = (detail) => detail !== null && typeof detail === "object" && !Array.isArray(detail) && typeof detail["sourceId"] === "string" && typeof detail["targetId"] === "string" && (detail["position"] === "before" || detail["position"] === "inside" || detail["position"] === "after") && detail["reason"] === "max-depth" && Number.isInteger(detail["maxDepth"]) && Number.isInteger(detail["resultingDepth"]) && (detail["trigger"] === "keyboard" || detail["trigger"] === "pointer" || detail["trigger"] === "programmatic") && Object.keys(detail).every((key) => [
40
+ "sourceId",
41
+ "targetId",
42
+ "position",
43
+ "reason",
44
+ "maxDepth",
45
+ "resultingDepth",
46
+ "trigger"
47
+ ].includes(key));
48
+ const dispatch = createDispatch(root, emit, {
49
+ checks: {
50
+ reorder: isReorderDetail,
51
+ "reorder-rejected": isReorderRejectedDetail
84
52
  },
85
- state: new Proxy({}, {
86
- get: (_target, name) => typeof name === "string" ? read(name) : void 0,
87
- set: (_target, name, value) => typeof name === "string" && write(name, value)
88
- }),
89
- refs: {},
90
- elements: new Proxy({}, { get: (_target, name) => {
91
- if (typeof name !== "string" || root.value === null) return void 0;
92
- return (root.value instanceof HTMLFormElement ? root.value : root.value.querySelector("form"))?.elements.namedItem(name) ?? root.value.querySelector(`[name="${CSS.escape(name)}"]`) ?? void 0;
93
- } }),
94
- signal(initialValue) {
95
- const value = shallowRef(initialValue);
96
- return {
97
- get: () => value.value,
98
- set: (next) => {
99
- if (!Object.is(value.value, next)) value.value = next;
100
- },
101
- update: (next) => {
102
- const updated = next(value.value);
103
- if (!Object.is(value.value, updated)) value.value = updated;
104
- }
105
- };
106
- },
107
- computed(compute) {
108
- const value = computed(compute);
109
- return { get: () => value.value };
110
- },
111
- effect(run) {
112
- const stop = watchEffect((onCleanup) => {
113
- const cleanup = run();
114
- if (typeof cleanup === "function") onCleanup(cleanup);
115
- }, { flush: "post" });
116
- stops.push(stop);
117
- return stop;
118
- },
119
- on(event, listener) {
120
- const element = root.value;
121
- element?.addEventListener(event, listener);
122
- const off = () => element?.removeEventListener(event, listener);
123
- stops.push(off);
124
- return off;
125
- },
126
- dispatch
127
- };
128
- let cleanup;
129
- onMounted(() => {
130
- Promise.resolve(controllerModule.default(host)).then((result) => {
131
- cleanup = result;
132
- });
53
+ modeled: ["maxDepth"]
133
54
  });
134
- onBeforeUnmount(() => {
135
- for (const stop of stops.splice(0)) stop();
136
- if (typeof cleanup === "function") cleanup();
55
+ useComponentHost(controllerModule.default, {
56
+ root,
57
+ dispatch,
58
+ props
137
59
  });
138
60
  return (_ctx, _cache) => {
139
61
  return openBlock(), createElementBlock("div", mergeProps({
@@ -146,6 +68,6 @@ var UiTree_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
146
68
  }), [renderSlot(_ctx.$slots, "default", {}, void 0, true)], 16, _hoisted_1);
147
69
  };
148
70
  }
149
- }), [["__scopeId", "data-v-e94f7a5c"]]);
71
+ }), [["__scopeId", "data-v-89a4437c"]]);
150
72
  //#endregion
151
73
  export { UiTree_default as t };
@@ -1,5 +1,6 @@
1
+ import { n as useComponentHost, t as createDispatch } from "./host.js";
1
2
  import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
2
- import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeProps, onBeforeUnmount, onMounted, openBlock, ref, renderSlot, shallowRef, toDisplayString, useTemplateRef, watchEffect } from "vue";
3
+ import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeProps, openBlock, ref, renderSlot, toDisplayString, useTemplateRef } from "vue";
3
4
  import * as controllerModule from "@threadlabs/looma/components/ui-tree-item/ui-tree-item.js";
4
5
  //#region .build/vue/UiTreeItem.vue?vue&type=script&setup=true&lang.ts
5
6
  var _hoisted_1 = [
@@ -78,128 +79,37 @@ var UiTreeItem_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__P
78
79
  const isContainer = ref(false);
79
80
  /** The values the styles' :host-state() rules test. */
80
81
  const hostState = computed(() => [props.selected && "selected", props.disabled && "disabled"].filter(Boolean).join(" "));
81
- /** Dispatches a component event to Vue listeners and, for controllers and page code, on the root. */
82
- function dispatch(name, detail) {
83
- const declared = { expand: {
82
+ const isExpandDetail = (detail) => detail !== null && typeof detail === "object" && !Array.isArray(detail) && typeof detail["id"] === "string" && typeof detail["expanded"] === "boolean" && (detail["trigger"] === "keyboard" || detail["trigger"] === "pointer" || detail["trigger"] === "programmatic") && Object.keys(detail).every((key) => [
83
+ "id",
84
+ "expanded",
85
+ "trigger"
86
+ ].includes(key));
87
+ const dispatch = createDispatch(root, emit, {
88
+ declared: { expand: {
84
89
  bubbles: false,
85
90
  composed: true,
86
91
  cancelable: false
87
- } };
88
- const checks = { expand: (detail) => detail !== null && typeof detail === "object" && !Array.isArray(detail) && typeof detail["id"] === "string" && typeof detail["expanded"] === "boolean" && (detail["trigger"] === "keyboard" || detail["trigger"] === "pointer" || detail["trigger"] === "programmatic") && Object.keys(detail).every((key) => [
89
- "id",
90
- "expanded",
91
- "trigger"
92
- ].includes(key)) };
93
- if (detail !== void 0 && checks[name] !== void 0 && !checks[name](detail)) throw new TypeError(`HR002: Event \`${name}\` detail does not satisfy its declared type.`);
94
- const emitEvent = emit;
95
- emitEvent(name, detail);
96
- if (detail !== null && typeof detail === "object" && "expanded" in detail) emitEvent("update:expanded", detail["expanded"]);
97
- return root.value?.dispatchEvent(new CustomEvent(name, {
98
- bubbles: true,
99
- composed: true,
100
- ...declared[name],
101
- detail
102
- })) ?? true;
103
- }
104
- function read(name) {
105
- if (name === "internalExpanded") return internalExpanded.value;
106
- if (name === "structuralLevel") return structuralLevel.value;
107
- if (name === "tabStop") return tabStop.value;
108
- if (name === "isContainer") return isContainer.value;
109
- return props[name];
110
- }
111
- function write(name, value) {
112
- if (name === "internalExpanded") {
113
- internalExpanded.value = value;
114
- return true;
115
- }
116
- if (name === "structuralLevel") {
117
- structuralLevel.value = value;
118
- return true;
119
- }
120
- if (name === "tabStop") {
121
- tabStop.value = value;
122
- return true;
123
- }
124
- if (name === "isContainer") {
125
- isContainer.value = value;
126
- return true;
127
- }
128
- throw new TypeError(`Only declared state is writable; \`${name}\` is not.`);
129
- }
130
- const stops = [];
131
- const host = {
132
- get element() {
133
- return root.value;
134
- },
135
- state: new Proxy({}, {
136
- get: (_target, name) => typeof name === "string" ? read(name) : void 0,
137
- set: (_target, name, value) => typeof name === "string" && write(name, value)
138
- }),
92
+ } },
93
+ checks: { expand: isExpandDetail },
94
+ modeled: ["expanded"]
95
+ });
96
+ useComponentHost(controllerModule.default, {
97
+ root,
98
+ dispatch,
99
+ props,
139
100
  refs: {
140
- get row() {
141
- return rowElement.value;
142
- },
143
- get dragHandle() {
144
- return dragHandleElement.value;
145
- },
146
- get disclosure() {
147
- return disclosureElement.value;
148
- },
149
- get actions() {
150
- return actionsElement.value;
151
- },
152
- get children() {
153
- return childrenElement.value;
154
- }
101
+ row: rowElement,
102
+ dragHandle: dragHandleElement,
103
+ disclosure: disclosureElement,
104
+ actions: actionsElement,
105
+ children: childrenElement
155
106
  },
156
- elements: new Proxy({}, { get: (_target, name) => {
157
- if (typeof name !== "string" || root.value === null) return void 0;
158
- return (root.value instanceof HTMLFormElement ? root.value : root.value.querySelector("form"))?.elements.namedItem(name) ?? root.value.querySelector(`[name="${CSS.escape(name)}"]`) ?? void 0;
159
- } }),
160
- signal(initialValue) {
161
- const value = shallowRef(initialValue);
162
- return {
163
- get: () => value.value,
164
- set: (next) => {
165
- if (!Object.is(value.value, next)) value.value = next;
166
- },
167
- update: (next) => {
168
- const updated = next(value.value);
169
- if (!Object.is(value.value, updated)) value.value = updated;
170
- }
171
- };
172
- },
173
- computed(compute) {
174
- const value = computed(compute);
175
- return { get: () => value.value };
176
- },
177
- effect(run) {
178
- const stop = watchEffect((onCleanup) => {
179
- const cleanup = run();
180
- if (typeof cleanup === "function") onCleanup(cleanup);
181
- }, { flush: "post" });
182
- stops.push(stop);
183
- return stop;
184
- },
185
- on(event, listener) {
186
- const element = root.value;
187
- element?.addEventListener(event, listener);
188
- const off = () => element?.removeEventListener(event, listener);
189
- stops.push(off);
190
- return off;
191
- },
192
- dispatch
193
- };
194
- let cleanup;
195
- onMounted(() => {
196
- Promise.resolve(controllerModule.default(host)).then((result) => {
197
- cleanup = result;
198
- });
199
- });
200
- onBeforeUnmount(() => {
201
- for (const stop of stops.splice(0)) stop();
202
- if (typeof cleanup === "function") cleanup();
107
+ state: {
108
+ internalExpanded,
109
+ structuralLevel,
110
+ tabStop,
111
+ isContainer
112
+ }
203
113
  });
204
114
  return (_ctx, _cache) => {
205
115
  return openBlock(), createElementBlock("div", mergeProps({
@@ -300,6 +210,6 @@ var UiTreeItem_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__P
300
210
  ], 16, _hoisted_1);
301
211
  };
302
212
  }
303
- }), [["__scopeId", "data-v-07ef6009"]]);
213
+ }), [["__scopeId", "data-v-9b8fd08d"]]);
304
214
  //#endregion
305
215
  export { UiTreeItem_default as t };
@@ -0,0 +1,101 @@
1
+ import { computed, onBeforeUnmount, onMounted, shallowRef, watchEffect } from "vue";
2
+ //#region .build/vue/host.ts
3
+ /**
4
+ * The controller host, built from Vue refs, effects, and lifecycle. Reads and writes reach the
5
+ * component's own refs, so a controller's change renders as any other Vue change does, and the
6
+ * effects and listeners it opens close when the component unmounts.
7
+ */
8
+ function useComponentHost(controller, options) {
9
+ const { root, dispatch, props, refs = {}, state = {}, computed: computedValues = {} } = options;
10
+ const stops = [];
11
+ const read = (name) => Object.hasOwn(state, name) ? state[name].value : Object.hasOwn(computedValues, name) ? computedValues[name].value : props?.[name];
12
+ const host = {
13
+ get element() {
14
+ return root.value;
15
+ },
16
+ state: new Proxy({}, {
17
+ get: (_target, name) => typeof name === "string" ? read(name) : void 0,
18
+ set: (_target, name, value) => {
19
+ if (typeof name !== "string" || !Object.hasOwn(state, name)) throw new TypeError(`Only declared state is writable; \`${String(name)}\` is not.`);
20
+ state[name].value = value;
21
+ return true;
22
+ }
23
+ }),
24
+ refs: Object.defineProperties({}, Object.fromEntries(Object.entries(refs).map(([name, ref]) => [name, {
25
+ enumerable: true,
26
+ get: () => ref.value
27
+ }]))),
28
+ elements: new Proxy({}, { get: (_target, name) => {
29
+ if (typeof name !== "string" || root.value === null) return void 0;
30
+ return (root.value instanceof HTMLFormElement ? root.value : root.value.querySelector("form"))?.elements.namedItem(name) ?? root.value.querySelector(`[name="${CSS.escape(name)}"]`) ?? void 0;
31
+ } }),
32
+ signal(initialValue) {
33
+ const value = shallowRef(initialValue);
34
+ return {
35
+ get: () => value.value,
36
+ set: (next) => {
37
+ value.value = next;
38
+ },
39
+ update: (next) => {
40
+ value.value = next(value.value);
41
+ }
42
+ };
43
+ },
44
+ computed(compute) {
45
+ const value = computed(compute);
46
+ return { get: () => value.value };
47
+ },
48
+ effect(run) {
49
+ const stop = watchEffect((onCleanup) => {
50
+ const cleanup = run();
51
+ if (typeof cleanup === "function") onCleanup(cleanup);
52
+ }, { flush: "post" });
53
+ stops.push(stop);
54
+ return stop;
55
+ },
56
+ on(event, listener) {
57
+ const element = root.value;
58
+ element?.addEventListener(event, listener);
59
+ const off = () => element?.removeEventListener(event, listener);
60
+ stops.push(off);
61
+ return off;
62
+ },
63
+ dispatch
64
+ };
65
+ let cleanup;
66
+ let started;
67
+ onMounted(() => {
68
+ started = Promise.resolve(controller?.(host)).then((result) => {
69
+ if (typeof result === "function") cleanup = result;
70
+ });
71
+ });
72
+ onBeforeUnmount(() => {
73
+ for (const stop of stops.splice(0)) stop();
74
+ if (typeof cleanup === "function") cleanup();
75
+ });
76
+ /** `ready` settles once the controller has started; a method exposed by the component awaits it. */
77
+ return {
78
+ host,
79
+ ready: () => started
80
+ };
81
+ }
82
+ /** Dispatches a component event to Vue listeners and, for controllers and page code, on the root. */
83
+ function createDispatch(root, emit, options = {}) {
84
+ const { declared = {}, checks = {}, modeled = [] } = options;
85
+ return (name, detail) => {
86
+ const check = checks[name];
87
+ if (detail !== void 0 && check !== void 0 && !check(detail)) throw new TypeError(`HR002: Event \`${name}\` detail does not satisfy its declared type.`);
88
+ emit?.(name, detail);
89
+ if (detail !== null && typeof detail === "object") {
90
+ for (const prop of modeled) if (prop in detail) emit?.(`update:${prop}`, detail[prop]);
91
+ }
92
+ return root.value?.dispatchEvent(new CustomEvent(name, {
93
+ bubbles: true,
94
+ composed: true,
95
+ ...declared[name],
96
+ detail
97
+ })) ?? true;
98
+ };
99
+ }
100
+ //#endregion
101
+ export { useComponentHost as n, createDispatch as t };