@threadlabs/looma 0.6.4 → 0.7.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 (259) hide show
  1. package/components/ui-button/ui-button.html +103 -81
  2. package/components/ui-checkbox/ui-checkbox.html +4 -1
  3. package/components/ui-combobox/ui-combobox.html +40 -3
  4. package/components/ui-combobox/ui-combobox.js +27 -5
  5. package/components/ui-select/ui-select.html +3 -5
  6. package/dist/index.js +1 -1
  7. package/package.json +2 -2
  8. package/styles/ui-affordance-scope.css +1 -1
  9. package/styles/ui-avatar-group.css +1 -1
  10. package/styles/ui-avatar.css +1 -1
  11. package/styles/ui-badge.css +1 -1
  12. package/styles/ui-button.css +112 -80
  13. package/styles/ui-callout.css +1 -1
  14. package/styles/ui-checkbox.css +5 -2
  15. package/styles/ui-cluster.css +1 -1
  16. package/styles/ui-combobox.css +38 -1
  17. package/styles/ui-container.css +1 -1
  18. package/styles/ui-context-menu.css +1 -1
  19. package/styles/ui-dialog.css +1 -1
  20. package/styles/ui-disclosure.css +1 -1
  21. package/styles/ui-editable.css +1 -1
  22. package/styles/ui-editor-insert-table-grid.css +1 -1
  23. package/styles/ui-editor-mention-menu.css +1 -1
  24. package/styles/ui-editor-slash-menu.css +1 -1
  25. package/styles/ui-editor-table-context-menu.css +1 -1
  26. package/styles/ui-editor-table-overlay.css +1 -1
  27. package/styles/ui-editor-table-toolbar.css +1 -1
  28. package/styles/ui-editor-toolbar.css +1 -1
  29. package/styles/ui-floating-action-button.css +1 -1
  30. package/styles/ui-form-field.css +1 -1
  31. package/styles/ui-grid.css +1 -1
  32. package/styles/ui-icon-button.css +1 -1
  33. package/styles/ui-icon.css +1 -1
  34. package/styles/ui-input.css +1 -1
  35. package/styles/ui-menu-item.css +1 -1
  36. package/styles/ui-menu.css +1 -1
  37. package/styles/ui-popover.css +1 -1
  38. package/styles/ui-radio-group.css +1 -1
  39. package/styles/ui-radio.css +1 -1
  40. package/styles/ui-reel.css +1 -1
  41. package/styles/ui-search-result-row.css +1 -1
  42. package/styles/ui-search-shell.css +1 -1
  43. package/styles/ui-select.css +4 -5
  44. package/styles/ui-separator.css +1 -1
  45. package/styles/ui-sidebar.css +1 -1
  46. package/styles/ui-stack.css +1 -1
  47. package/styles/ui-switch.css +1 -1
  48. package/styles/ui-switcher.css +1 -1
  49. package/styles/ui-tabs.css +1 -1
  50. package/styles/ui-textarea.css +1 -1
  51. package/styles/ui-toast-region.css +1 -1
  52. package/styles/ui-tooltip.css +1 -1
  53. package/styles/ui-top-bar.css +1 -1
  54. package/styles/ui-tree-item.css +1 -1
  55. package/styles/ui-tree.css +1 -1
  56. package/theme-dark.css +6 -30
  57. package/theme-high-contrast.css +30 -20
  58. package/theme-light.css +2 -16
  59. package/tokens.css +33 -24
  60. package/vanilla/UiAffordanceScope.d.ts +1 -1
  61. package/vanilla/UiAffordanceScope.js +1 -1
  62. package/vanilla/UiAvatar.d.ts +1 -1
  63. package/vanilla/UiAvatar.js +1 -1
  64. package/vanilla/UiAvatarGroup.d.ts +1 -1
  65. package/vanilla/UiAvatarGroup.js +1 -1
  66. package/vanilla/UiBadge.d.ts +1 -1
  67. package/vanilla/UiBadge.js +1 -1
  68. package/vanilla/UiButton.d.ts +2 -2
  69. package/vanilla/UiButton.js +2 -2
  70. package/vanilla/UiCallout.d.ts +1 -1
  71. package/vanilla/UiCallout.js +1 -1
  72. package/vanilla/UiCheckbox.d.ts +1 -1
  73. package/vanilla/UiCheckbox.js +1 -1
  74. package/vanilla/UiCluster.d.ts +1 -1
  75. package/vanilla/UiCluster.js +1 -1
  76. package/vanilla/UiCombobox.d.ts +1 -1
  77. package/vanilla/UiCombobox.js +2 -2
  78. package/vanilla/UiContainer.d.ts +1 -1
  79. package/vanilla/UiContainer.js +1 -1
  80. package/vanilla/UiContextMenu.d.ts +1 -1
  81. package/vanilla/UiContextMenu.js +1 -1
  82. package/vanilla/UiDialog.d.ts +1 -1
  83. package/vanilla/UiDialog.js +1 -1
  84. package/vanilla/UiDisclosure.d.ts +1 -1
  85. package/vanilla/UiDisclosure.js +1 -1
  86. package/vanilla/UiEditable.d.ts +1 -1
  87. package/vanilla/UiEditable.js +1 -1
  88. package/vanilla/UiEditorInsertTableGrid.d.ts +1 -1
  89. package/vanilla/UiEditorInsertTableGrid.js +1 -1
  90. package/vanilla/UiEditorMentionMenu.d.ts +1 -1
  91. package/vanilla/UiEditorMentionMenu.js +1 -1
  92. package/vanilla/UiEditorSlashMenu.d.ts +1 -1
  93. package/vanilla/UiEditorSlashMenu.js +1 -1
  94. package/vanilla/UiEditorTableContextMenu.d.ts +1 -1
  95. package/vanilla/UiEditorTableContextMenu.js +1 -1
  96. package/vanilla/UiEditorTableOverlay.d.ts +1 -1
  97. package/vanilla/UiEditorTableOverlay.js +1 -1
  98. package/vanilla/UiEditorTableToolbar.d.ts +1 -1
  99. package/vanilla/UiEditorTableToolbar.js +1 -1
  100. package/vanilla/UiEditorToolbar.d.ts +1 -1
  101. package/vanilla/UiEditorToolbar.js +1 -1
  102. package/vanilla/UiFloatingActionButton.d.ts +1 -1
  103. package/vanilla/UiFloatingActionButton.js +1 -1
  104. package/vanilla/UiFormField.d.ts +1 -1
  105. package/vanilla/UiFormField.js +1 -1
  106. package/vanilla/UiGrid.d.ts +1 -1
  107. package/vanilla/UiGrid.js +1 -1
  108. package/vanilla/UiIcon.d.ts +1 -1
  109. package/vanilla/UiIcon.js +1 -1
  110. package/vanilla/UiIconButton.d.ts +1 -1
  111. package/vanilla/UiIconButton.js +1 -1
  112. package/vanilla/UiInput.d.ts +1 -1
  113. package/vanilla/UiInput.js +1 -1
  114. package/vanilla/UiMenu.d.ts +1 -1
  115. package/vanilla/UiMenu.js +1 -1
  116. package/vanilla/UiMenuItem.d.ts +1 -1
  117. package/vanilla/UiMenuItem.js +1 -1
  118. package/vanilla/UiPopover.d.ts +1 -1
  119. package/vanilla/UiPopover.js +1 -1
  120. package/vanilla/UiRadio.d.ts +1 -1
  121. package/vanilla/UiRadio.js +1 -1
  122. package/vanilla/UiRadioGroup.d.ts +1 -1
  123. package/vanilla/UiRadioGroup.js +1 -1
  124. package/vanilla/UiReel.d.ts +1 -1
  125. package/vanilla/UiReel.js +1 -1
  126. package/vanilla/UiSearchResultRow.d.ts +1 -1
  127. package/vanilla/UiSearchResultRow.js +1 -1
  128. package/vanilla/UiSearchShell.d.ts +1 -1
  129. package/vanilla/UiSearchShell.js +1 -1
  130. package/vanilla/UiSelect.d.ts +1 -2
  131. package/vanilla/UiSelect.js +4 -7
  132. package/vanilla/UiSeparator.d.ts +1 -1
  133. package/vanilla/UiSeparator.js +1 -1
  134. package/vanilla/UiSidebar.d.ts +1 -1
  135. package/vanilla/UiSidebar.js +1 -1
  136. package/vanilla/UiStack.d.ts +1 -1
  137. package/vanilla/UiStack.js +1 -1
  138. package/vanilla/UiSwitch.d.ts +1 -1
  139. package/vanilla/UiSwitch.js +1 -1
  140. package/vanilla/UiSwitcher.d.ts +1 -1
  141. package/vanilla/UiSwitcher.js +1 -1
  142. package/vanilla/UiTabs.d.ts +1 -1
  143. package/vanilla/UiTabs.js +1 -1
  144. package/vanilla/UiTextarea.d.ts +1 -1
  145. package/vanilla/UiTextarea.js +1 -1
  146. package/vanilla/UiToastRegion.d.ts +1 -1
  147. package/vanilla/UiToastRegion.js +1 -1
  148. package/vanilla/UiTooltip.d.ts +1 -1
  149. package/vanilla/UiTooltip.js +1 -1
  150. package/vanilla/UiTopBar.d.ts +1 -1
  151. package/vanilla/UiTopBar.js +1 -1
  152. package/vanilla/UiTree.d.ts +1 -1
  153. package/vanilla/UiTree.js +1 -1
  154. package/vanilla/UiTreeItem.d.ts +1 -1
  155. package/vanilla/UiTreeItem.js +1 -1
  156. package/vue/UiAffordanceScope.vue +8 -84
  157. package/vue/UiAvatar.d.ts +1 -1
  158. package/vue/UiAvatar.vue +9 -106
  159. package/vue/UiAvatarGroup.vue +9 -96
  160. package/vue/UiBadge.vue +1 -1
  161. package/vue/UiButton.d.ts +2 -2
  162. package/vue/UiButton.vue +104 -97
  163. package/vue/UiCallout.vue +1 -1
  164. package/vue/UiCheckbox.vue +26 -124
  165. package/vue/UiCluster.vue +1 -1
  166. package/vue/UiCombobox.d.ts +1 -1
  167. package/vue/UiCombobox.vue +270 -479
  168. package/vue/UiContainer.vue +1 -1
  169. package/vue/UiContextMenu.vue +34 -141
  170. package/vue/UiDialog.vue +25 -126
  171. package/vue/UiDisclosure.vue +26 -138
  172. package/vue/UiEditable.vue +46 -158
  173. package/vue/UiEditorInsertTableGrid.vue +19 -138
  174. package/vue/UiEditorMentionMenu.vue +17 -124
  175. package/vue/UiEditorSlashMenu.vue +17 -109
  176. package/vue/UiEditorTableContextMenu.vue +34 -122
  177. package/vue/UiEditorTableOverlay.vue +61 -167
  178. package/vue/UiEditorTableToolbar.vue +34 -142
  179. package/vue/UiEditorToolbar.vue +1 -1
  180. package/vue/UiFloatingActionButton.vue +1 -1
  181. package/vue/UiFormField.vue +7 -79
  182. package/vue/UiGrid.vue +1 -1
  183. package/vue/UiIcon.vue +8 -84
  184. package/vue/UiIconButton.vue +7 -79
  185. package/vue/UiInput.vue +7 -79
  186. package/vue/UiMenu.vue +42 -127
  187. package/vue/UiMenuItem.vue +1 -1
  188. package/vue/UiPopover.vue +25 -121
  189. package/vue/UiRadio.vue +22 -123
  190. package/vue/UiRadioGroup.d.ts +1 -1
  191. package/vue/UiRadioGroup.vue +32 -119
  192. package/vue/UiReel.vue +1 -1
  193. package/vue/UiSearchResultRow.vue +1 -1
  194. package/vue/UiSearchShell.vue +25 -121
  195. package/vue/UiSelect.d.ts +0 -2
  196. package/vue/UiSelect.vue +9 -85
  197. package/vue/UiSeparator.vue +1 -1
  198. package/vue/UiSidebar.vue +32 -133
  199. package/vue/UiStack.vue +1 -1
  200. package/vue/UiSwitch.vue +22 -123
  201. package/vue/UiSwitcher.vue +1 -1
  202. package/vue/UiTabs.vue +24 -128
  203. package/vue/UiTextarea.vue +7 -79
  204. package/vue/UiToastRegion.vue +37 -126
  205. package/vue/UiTooltip.vue +25 -124
  206. package/vue/UiTopBar.vue +1 -1
  207. package/vue/UiTree.vue +56 -137
  208. package/vue/UiTreeItem.vue +28 -144
  209. package/vue/chunks/UiAffordanceScope.js +9 -78
  210. package/vue/chunks/UiAvatar.js +13 -89
  211. package/vue/chunks/UiAvatarGroup.js +10 -80
  212. package/vue/chunks/UiBadge.js +1 -1
  213. package/vue/chunks/UiButton.js +3 -3
  214. package/vue/chunks/UiCallout.js +1 -1
  215. package/vue/chunks/UiCheckbox.js +17 -95
  216. package/vue/chunks/UiCluster.js +1 -1
  217. package/vue/chunks/UiCombobox.js +115 -326
  218. package/vue/chunks/UiContainer.js +1 -1
  219. package/vue/chunks/UiContextMenu.js +21 -113
  220. package/vue/chunks/UiDialog.js +20 -99
  221. package/vue/chunks/UiDisclosure.js +22 -112
  222. package/vue/chunks/UiEditable.js +32 -128
  223. package/vue/chunks/UiEditorInsertTableGrid.js +22 -116
  224. package/vue/chunks/UiEditorMentionMenu.js +18 -116
  225. package/vue/chunks/UiEditorSlashMenu.js +15 -101
  226. package/vue/chunks/UiEditorTableContextMenu.js +12 -91
  227. package/vue/chunks/UiEditorTableOverlay.js +29 -120
  228. package/vue/chunks/UiEditorTableToolbar.js +16 -111
  229. package/vue/chunks/UiEditorToolbar.js +1 -1
  230. package/vue/chunks/UiFloatingActionButton.js +1 -1
  231. package/vue/chunks/UiFormField.js +8 -73
  232. package/vue/chunks/UiGrid.js +1 -1
  233. package/vue/chunks/UiIcon.js +9 -78
  234. package/vue/chunks/UiIconButton.js +8 -73
  235. package/vue/chunks/UiInput.js +8 -73
  236. package/vue/chunks/UiMenu.js +25 -111
  237. package/vue/chunks/UiMenuItem.js +1 -1
  238. package/vue/chunks/UiPopover.js +18 -105
  239. package/vue/chunks/UiRadio.js +17 -95
  240. package/vue/chunks/UiRadioGroup.js +23 -105
  241. package/vue/chunks/UiReel.js +1 -1
  242. package/vue/chunks/UiSearchResultRow.js +1 -1
  243. package/vue/chunks/UiSearchShell.js +17 -94
  244. package/vue/chunks/UiSelect.js +8 -79
  245. package/vue/chunks/UiSeparator.js +1 -1
  246. package/vue/chunks/UiSidebar.js +23 -108
  247. package/vue/chunks/UiStack.js +1 -1
  248. package/vue/chunks/UiSwitch.js +17 -95
  249. package/vue/chunks/UiSwitcher.js +1 -1
  250. package/vue/chunks/UiTabs.js +22 -103
  251. package/vue/chunks/UiTextarea.js +8 -73
  252. package/vue/chunks/UiToastRegion.js +27 -112
  253. package/vue/chunks/UiTooltip.js +18 -106
  254. package/vue/chunks/UiTopBar.js +1 -1
  255. package/vue/chunks/UiTree.js +31 -109
  256. package/vue/chunks/UiTreeItem.js +29 -119
  257. package/vue/chunks/host.js +101 -0
  258. package/vue/components.css +844 -797
  259. 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, createElementVNode, defineComponent, mergeProps, onBeforeUnmount, onMounted, openBlock, ref, renderSlot, shallowRef, watchEffect } from "vue";
3
+ import { computed, createElementBlock, createElementVNode, defineComponent, mergeProps, openBlock, ref, renderSlot } from "vue";
3
4
  import * as controllerModule from "@threadlabs/looma/components/ui-tooltip/ui-tooltip.js";
4
5
  //#region .build/vue/UiTooltip.vue?vue&type=script&setup=true&lang.ts
5
6
  var _hoisted_1 = ["hidden", "data-ui-tooltip-state"];
@@ -41,112 +42,23 @@ var UiTooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
41
42
  props.placement && "placement",
42
43
  `placement=${encodeURIComponent(props.placement)}`
43
44
  ].filter(Boolean).join(" "));
44
- /** Dispatches a component event to Vue listeners and, for controllers and page code, on the root. */
45
- function dispatch(name, detail) {
46
- const declared = {
47
- open: {
48
- bubbles: true,
49
- composed: true,
50
- cancelable: false
51
- },
52
- close: {
53
- bubbles: true,
54
- composed: true,
55
- cancelable: false
56
- }
57
- };
58
- const checks = {
59
- open: (detail) => detail !== null && typeof detail === "object" && !Array.isArray(detail) && typeof detail["open"] === "boolean" && (detail["reason"] === "action" || detail["reason"] === "programmatic" || detail["reason"] === "light-dismiss" || detail["reason"] === "escape") && (detail["trigger"] === "keyboard" || detail["trigger"] === "pointer" || detail["trigger"] === "programmatic") && Object.keys(detail).every((key) => [
60
- "open",
61
- "reason",
62
- "trigger"
63
- ].includes(key)),
64
- close: (detail) => detail !== null && typeof detail === "object" && !Array.isArray(detail) && typeof detail["open"] === "boolean" && (detail["reason"] === "action" || detail["reason"] === "programmatic" || detail["reason"] === "light-dismiss" || detail["reason"] === "escape") && (detail["trigger"] === "keyboard" || detail["trigger"] === "pointer" || detail["trigger"] === "programmatic") && Object.keys(detail).every((key) => [
65
- "open",
66
- "reason",
67
- "trigger"
68
- ].includes(key))
69
- };
70
- if (detail !== void 0 && checks[name] !== void 0 && !checks[name](detail)) throw new TypeError(`HR002: Event \`${name}\` detail does not satisfy its declared type.`);
71
- const emitEvent = emit;
72
- emitEvent(name, detail);
73
- if (detail !== null && typeof detail === "object" && "open" in detail) emitEvent("update:open", detail["open"]);
74
- if (detail !== null && typeof detail === "object" && "trigger" in detail) emitEvent("update:trigger", detail["trigger"]);
75
- return root.value?.dispatchEvent(new CustomEvent(name, {
76
- bubbles: true,
77
- composed: true,
78
- ...declared[name],
79
- detail
80
- })) ?? true;
81
- }
82
- function read(name) {
83
- if (name === "internalOpen") return internalOpen.value;
84
- return props[name];
85
- }
86
- function write(name, value) {
87
- if (name === "internalOpen") {
88
- internalOpen.value = value;
89
- return true;
90
- }
91
- throw new TypeError(`Only declared state is writable; \`${name}\` is not.`);
92
- }
93
- const stops = [];
94
- const host = {
95
- get element() {
96
- return root.value;
45
+ const isOpenDetail = (detail) => detail !== null && typeof detail === "object" && !Array.isArray(detail) && typeof detail["open"] === "boolean" && (detail["reason"] === "action" || detail["reason"] === "programmatic" || detail["reason"] === "light-dismiss" || detail["reason"] === "escape") && (detail["trigger"] === "keyboard" || detail["trigger"] === "pointer" || detail["trigger"] === "programmatic") && Object.keys(detail).every((key) => [
46
+ "open",
47
+ "reason",
48
+ "trigger"
49
+ ].includes(key));
50
+ const dispatch = createDispatch(root, emit, {
51
+ checks: {
52
+ open: isOpenDetail,
53
+ close: isOpenDetail
97
54
  },
98
- state: new Proxy({}, {
99
- get: (_target, name) => typeof name === "string" ? read(name) : void 0,
100
- set: (_target, name, value) => typeof name === "string" && write(name, value)
101
- }),
102
- refs: {},
103
- elements: new Proxy({}, { get: (_target, name) => {
104
- if (typeof name !== "string" || root.value === null) return void 0;
105
- return (root.value instanceof HTMLFormElement ? root.value : root.value.querySelector("form"))?.elements.namedItem(name) ?? root.value.querySelector(`[name="${CSS.escape(name)}"]`) ?? void 0;
106
- } }),
107
- signal(initialValue) {
108
- const value = shallowRef(initialValue);
109
- return {
110
- get: () => value.value,
111
- set: (next) => {
112
- if (!Object.is(value.value, next)) value.value = next;
113
- },
114
- update: (next) => {
115
- const updated = next(value.value);
116
- if (!Object.is(value.value, updated)) value.value = updated;
117
- }
118
- };
119
- },
120
- computed(compute) {
121
- const value = computed(compute);
122
- return { get: () => value.value };
123
- },
124
- effect(run) {
125
- const stop = watchEffect((onCleanup) => {
126
- const cleanup = run();
127
- if (typeof cleanup === "function") onCleanup(cleanup);
128
- }, { flush: "post" });
129
- stops.push(stop);
130
- return stop;
131
- },
132
- on(event, listener) {
133
- const element = root.value;
134
- element?.addEventListener(event, listener);
135
- const off = () => element?.removeEventListener(event, listener);
136
- stops.push(off);
137
- return off;
138
- },
139
- dispatch
140
- };
141
- let cleanup;
142
- onMounted(() => {
143
- Promise.resolve(controllerModule.default(host)).then((result) => {
144
- cleanup = result;
145
- });
55
+ modeled: ["open", "trigger"]
146
56
  });
147
- onBeforeUnmount(() => {
148
- for (const stop of stops.splice(0)) stop();
149
- if (typeof cleanup === "function") cleanup();
57
+ useComponentHost(controllerModule.default, {
58
+ root,
59
+ dispatch,
60
+ props,
61
+ state: { internalOpen }
150
62
  });
151
63
  return (_ctx, _cache) => {
152
64
  return openBlock(), createElementBlock("span", mergeProps({
@@ -160,6 +72,6 @@ var UiTooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
160
72
  }), [createElementVNode("div", _hoisted_2, [renderSlot(_ctx.$slots, "default", {}, void 0, true)])], 16, _hoisted_1);
161
73
  };
162
74
  }
163
- }), [["__scopeId", "data-v-3af2132e"]]);
75
+ }), [["__scopeId", "data-v-5952fbd4"]]);
164
76
  //#endregion
165
77
  export { UiTooltip_default as t };
@@ -20,6 +20,6 @@ var UiTopBar_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PUR
20
20
  ], 16);
21
21
  };
22
22
  }
23
- }), [["__scopeId", "data-v-88437f08"]]);
23
+ }), [["__scopeId", "data-v-d08120f9"]]);
24
24
  //#endregion
25
25
  export { UiTopBar_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, 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 };