@loccal/ui 0.0.0-stage → 0.2.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 (246) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +38 -3
  4. package/dist/components/ui/accordion.d.ts +6 -0
  5. package/dist/components/ui/accordion.js +17 -0
  6. package/dist/components/ui/ai-panel.d.ts +47 -0
  7. package/dist/components/ui/ai-panel.js +74 -0
  8. package/dist/components/ui/alert-dialog.d.ts +18 -0
  9. package/dist/components/ui/alert-dialog.js +42 -0
  10. package/dist/components/ui/alert.d.ts +10 -0
  11. package/dist/components/ui/alert.js +27 -0
  12. package/dist/components/ui/avatar.d.ts +11 -0
  13. package/dist/components/ui/avatar.js +23 -0
  14. package/dist/components/ui/badge.d.ts +7 -0
  15. package/dist/components/ui/badge.js +36 -0
  16. package/dist/components/ui/breadcrumb.d.ts +10 -0
  17. package/dist/components/ui/breadcrumb.js +36 -0
  18. package/dist/components/ui/button-group.d.ts +10 -0
  19. package/dist/components/ui/button-group.js +36 -0
  20. package/dist/components/ui/button.d.ts +8 -0
  21. package/dist/components/ui/button.js +34 -0
  22. package/dist/components/ui/calendar.d.ts +10 -0
  23. package/dist/components/ui/calendar.js +76 -0
  24. package/dist/components/ui/card.d.ts +11 -0
  25. package/dist/components/ui/card.js +24 -0
  26. package/dist/components/ui/chart.d.ts +44 -0
  27. package/dist/components/ui/chart.js +132 -0
  28. package/dist/components/ui/checkbox.d.ts +3 -0
  29. package/dist/components/ui/checkbox.js +9 -0
  30. package/dist/components/ui/collapsible.d.ts +5 -0
  31. package/dist/components/ui/collapsible.js +13 -0
  32. package/dist/components/ui/command-block.d.ts +28 -0
  33. package/dist/components/ui/command-block.js +58 -0
  34. package/dist/components/ui/command.d.ts +19 -0
  35. package/dist/components/ui/command.js +35 -0
  36. package/dist/components/ui/connection-status.d.ts +29 -0
  37. package/dist/components/ui/connection-status.js +26 -0
  38. package/dist/components/ui/context-menu.d.ts +29 -0
  39. package/dist/components/ui/context-menu.js +51 -0
  40. package/dist/components/ui/data-table.d.ts +49 -0
  41. package/dist/components/ui/data-table.js +100 -0
  42. package/dist/components/ui/dialog.d.ts +18 -0
  43. package/dist/components/ui/dialog.js +37 -0
  44. package/dist/components/ui/drawer.d.ts +16 -0
  45. package/dist/components/ui/drawer.js +75 -0
  46. package/dist/components/ui/dropdown-menu.d.ts +29 -0
  47. package/dist/components/ui/dropdown-menu.js +51 -0
  48. package/dist/components/ui/dropzone.d.ts +11 -0
  49. package/dist/components/ui/dropzone.js +39 -0
  50. package/dist/components/ui/empty.d.ts +11 -0
  51. package/dist/components/ui/empty.js +33 -0
  52. package/dist/components/ui/field.d.ts +24 -0
  53. package/dist/components/ui/field.js +68 -0
  54. package/dist/components/ui/file-tree.d.ts +42 -0
  55. package/dist/components/ui/file-tree.js +85 -0
  56. package/dist/components/ui/hash-chain.d.ts +43 -0
  57. package/dist/components/ui/hash-chain.js +34 -0
  58. package/dist/components/ui/history-palette.d.ts +37 -0
  59. package/dist/components/ui/history-palette.js +44 -0
  60. package/dist/components/ui/hover-card.d.ts +5 -0
  61. package/dist/components/ui/hover-card.js +14 -0
  62. package/dist/components/ui/icon-base.d.ts +15 -0
  63. package/dist/components/ui/icon-base.js +18 -0
  64. package/dist/components/ui/icon.d.ts +15 -0
  65. package/dist/components/ui/icon.js +32 -0
  66. package/dist/components/ui/icons-compat.d.ts +32 -0
  67. package/dist/components/ui/icons-compat.js +34 -0
  68. package/dist/components/ui/icons.d.ts +1048 -0
  69. package/dist/components/ui/icons.js +264 -0
  70. package/dist/components/ui/input-group.d.ts +18 -0
  71. package/dist/components/ui/input-group.js +57 -0
  72. package/dist/components/ui/input-otp.d.ts +11 -0
  73. package/dist/components/ui/input-otp.js +21 -0
  74. package/dist/components/ui/input.d.ts +3 -0
  75. package/dist/components/ui/input.js +7 -0
  76. package/dist/components/ui/kbd.d.ts +3 -0
  77. package/dist/components/ui/kbd.js +9 -0
  78. package/dist/components/ui/label.d.ts +3 -0
  79. package/dist/components/ui/label.js +7 -0
  80. package/dist/components/ui/locale-switch.d.ts +9 -0
  81. package/dist/components/ui/locale-switch.js +31 -0
  82. package/dist/components/ui/log-panel.d.ts +28 -0
  83. package/dist/components/ui/log-panel.js +59 -0
  84. package/dist/components/ui/menubar.d.ts +29 -0
  85. package/dist/components/ui/menubar.js +56 -0
  86. package/dist/components/ui/metric-grid.d.ts +20 -0
  87. package/dist/components/ui/metric-grid.js +14 -0
  88. package/dist/components/ui/model-list.d.ts +33 -0
  89. package/dist/components/ui/model-list.js +69 -0
  90. package/dist/components/ui/navigation-menu.d.ts +11 -0
  91. package/dist/components/ui/navigation-menu.js +31 -0
  92. package/dist/components/ui/number-field.d.ts +29 -0
  93. package/dist/components/ui/number-field.js +65 -0
  94. package/dist/components/ui/pagination.d.ts +17 -0
  95. package/dist/components/ui/pagination.js +26 -0
  96. package/dist/components/ui/pane-tree.d.ts +18 -0
  97. package/dist/components/ui/pane-tree.js +65 -0
  98. package/dist/components/ui/popover.d.ts +9 -0
  99. package/dist/components/ui/popover.js +23 -0
  100. package/dist/components/ui/progress.d.ts +7 -0
  101. package/dist/components/ui/progress.js +20 -0
  102. package/dist/components/ui/radio-group.d.ts +5 -0
  103. package/dist/components/ui/radio-group.js +12 -0
  104. package/dist/components/ui/resizable.d.ts +7 -0
  105. package/dist/components/ui/resizable.js +14 -0
  106. package/dist/components/ui/scroll-area.d.ts +5 -0
  107. package/dist/components/ui/scroll-area.js +11 -0
  108. package/dist/components/ui/select.d.ts +15 -0
  109. package/dist/components/ui/select.js +34 -0
  110. package/dist/components/ui/separator.d.ts +3 -0
  111. package/dist/components/ui/separator.js +8 -0
  112. package/dist/components/ui/settings-layout.d.ts +31 -0
  113. package/dist/components/ui/settings-layout.js +45 -0
  114. package/dist/components/ui/sheet.d.ts +14 -0
  115. package/dist/components/ui/sheet.js +37 -0
  116. package/dist/components/ui/shell-picker.d.ts +18 -0
  117. package/dist/components/ui/shell-picker.js +17 -0
  118. package/dist/components/ui/skeleton.d.ts +2 -0
  119. package/dist/components/ui/skeleton.js +6 -0
  120. package/dist/components/ui/slider.d.ts +3 -0
  121. package/dist/components/ui/slider.js +12 -0
  122. package/dist/components/ui/sonner.d.ts +3 -0
  123. package/dist/components/ui/sonner.js +25 -0
  124. package/dist/components/ui/spinner.d.ts +2 -0
  125. package/dist/components/ui/spinner.js +7 -0
  126. package/dist/components/ui/split-button.d.ts +21 -0
  127. package/dist/components/ui/split-button.js +14 -0
  128. package/dist/components/ui/stat.d.ts +10 -0
  129. package/dist/components/ui/stat.js +8 -0
  130. package/dist/components/ui/status-bar.d.ts +13 -0
  131. package/dist/components/ui/status-bar.js +15 -0
  132. package/dist/components/ui/stepper.d.ts +13 -0
  133. package/dist/components/ui/stepper.js +11 -0
  134. package/dist/components/ui/switch.d.ts +5 -0
  135. package/dist/components/ui/switch.js +8 -0
  136. package/dist/components/ui/table.d.ts +10 -0
  137. package/dist/components/ui/table.js +28 -0
  138. package/dist/components/ui/tabs.d.ts +10 -0
  139. package/dist/components/ui/tabs.js +29 -0
  140. package/dist/components/ui/terminal-tabs.d.ts +31 -0
  141. package/dist/components/ui/terminal-tabs.js +109 -0
  142. package/dist/components/ui/terminal-view.d.ts +51 -0
  143. package/dist/components/ui/terminal-view.js +189 -0
  144. package/dist/components/ui/textarea.d.ts +3 -0
  145. package/dist/components/ui/textarea.js +6 -0
  146. package/dist/components/ui/timeline.d.ts +9 -0
  147. package/dist/components/ui/timeline.js +18 -0
  148. package/dist/components/ui/toggle-group.d.ts +11 -0
  149. package/dist/components/ui/toggle-group.js +24 -0
  150. package/dist/components/ui/toggle.d.ts +8 -0
  151. package/dist/components/ui/toggle.js +26 -0
  152. package/dist/components/ui/tooltip.d.ts +6 -0
  153. package/dist/components/ui/tooltip.js +17 -0
  154. package/dist/components/ui/tree-view.d.ts +20 -0
  155. package/dist/components/ui/tree-view.js +41 -0
  156. package/dist/components/ui/window-frame.d.ts +35 -0
  157. package/dist/components/ui/window-frame.js +49 -0
  158. package/dist/lib/ai-markdown.d.ts +13 -0
  159. package/dist/lib/ai-markdown.js +46 -0
  160. package/dist/lib/command-risk.d.ts +6 -0
  161. package/dist/lib/command-risk.js +42 -0
  162. package/dist/lib/file-kind.d.ts +10 -0
  163. package/dist/lib/file-kind.js +63 -0
  164. package/dist/lib/format.d.ts +9 -0
  165. package/dist/lib/format.js +30 -0
  166. package/dist/lib/i18n-core.d.ts +20 -0
  167. package/dist/lib/i18n-core.js +36 -0
  168. package/dist/lib/i18n.d.ts +15 -0
  169. package/dist/lib/i18n.js +68 -0
  170. package/dist/lib/icon-data.d.ts +276 -0
  171. package/dist/lib/icon-data.js +307 -0
  172. package/dist/lib/icon-shapes.d.ts +14 -0
  173. package/dist/lib/icon-shapes.js +47 -0
  174. package/dist/lib/log-filter.d.ts +23 -0
  175. package/dist/lib/log-filter.js +44 -0
  176. package/dist/lib/number-field.d.ts +11 -0
  177. package/dist/lib/number-field.js +30 -0
  178. package/dist/lib/pane-tree.d.ts +39 -0
  179. package/dist/lib/pane-tree.js +92 -0
  180. package/dist/lib/platform.d.ts +10 -0
  181. package/dist/lib/platform.js +24 -0
  182. package/dist/lib/shell-meta.d.ts +7 -0
  183. package/dist/lib/shell-meta.js +70 -0
  184. package/dist/lib/tab-order.d.ts +6 -0
  185. package/dist/lib/tab-order.js +24 -0
  186. package/dist/lib/table-sort.d.ts +16 -0
  187. package/dist/lib/table-sort.js +66 -0
  188. package/dist/lib/terminal-themes.d.ts +30 -0
  189. package/dist/lib/terminal-themes.js +90 -0
  190. package/dist/lib/utils.d.ts +2 -0
  191. package/dist/lib/utils.js +5 -0
  192. package/dist-cdn/loccal-ui.css +971 -0
  193. package/dist-cdn/loccal-ui.min.js +1 -0
  194. package/dist-wc/base.d.ts +31 -0
  195. package/dist-wc/base.js +104 -0
  196. package/dist-wc/button.d.ts +12 -0
  197. package/dist-wc/button.js +47 -0
  198. package/dist-wc/calendar.d.ts +16 -0
  199. package/dist-wc/calendar.js +106 -0
  200. package/dist-wc/choice.d.ts +17 -0
  201. package/dist-wc/choice.js +76 -0
  202. package/dist-wc/command.d.ts +32 -0
  203. package/dist-wc/command.js +181 -0
  204. package/dist-wc/data-table.d.ts +22 -0
  205. package/dist-wc/data-table.js +128 -0
  206. package/dist-wc/dialog.d.ts +29 -0
  207. package/dist-wc/dialog.js +94 -0
  208. package/dist-wc/disclosure.d.ts +17 -0
  209. package/dist-wc/disclosure.js +91 -0
  210. package/dist-wc/fields2.d.ts +38 -0
  211. package/dist-wc/fields2.js +133 -0
  212. package/dist-wc/file-tree.d.ts +19 -0
  213. package/dist-wc/file-tree.js +97 -0
  214. package/dist-wc/floating.d.ts +32 -0
  215. package/dist-wc/floating.js +91 -0
  216. package/dist-wc/index.d.ts +23 -0
  217. package/dist-wc/index.js +24 -0
  218. package/dist-wc/input-otp.d.ts +14 -0
  219. package/dist-wc/input-otp.js +82 -0
  220. package/dist-wc/navigation-menu.d.ts +14 -0
  221. package/dist-wc/navigation-menu.js +75 -0
  222. package/dist-wc/number-field.d.ts +13 -0
  223. package/dist-wc/number-field.js +67 -0
  224. package/dist-wc/resizable.d.ts +14 -0
  225. package/dist-wc/resizable.js +57 -0
  226. package/dist-wc/select.d.ts +17 -0
  227. package/dist-wc/select.js +80 -0
  228. package/dist-wc/static.d.ts +1 -0
  229. package/dist-wc/static.js +175 -0
  230. package/dist-wc/status-bar.d.ts +11 -0
  231. package/dist-wc/status-bar.js +54 -0
  232. package/dist-wc/styles.css +971 -0
  233. package/dist-wc/tabs.d.ts +16 -0
  234. package/dist-wc/tabs.js +62 -0
  235. package/dist-wc/terminal-tabs.d.ts +16 -0
  236. package/dist-wc/terminal-tabs.js +79 -0
  237. package/dist-wc/toaster.d.ts +16 -0
  238. package/dist-wc/toaster.js +68 -0
  239. package/dist-wc/toggle.d.ts +30 -0
  240. package/dist-wc/toggle.js +101 -0
  241. package/dist-wc/tree.d.ts +17 -0
  242. package/dist-wc/tree.js +72 -0
  243. package/docs/ARQUITETURA-VANILLA.md +54 -0
  244. package/docs/VERSIONING.md +88 -0
  245. package/package.json +1058 -6
  246. package/styles.css +426 -0
@@ -0,0 +1,16 @@
1
+ import { LoccalElement } from "./base.ts";
2
+ /**
3
+ * `<loccal-tabs value orientation activation>`: filhos `[data-part=list]` com `[data-part=tab][data-value]`
4
+ * e paineis `[data-part=panel][data-value]`. Evento: `loccal-value-change` { value }.
5
+ * Chame `refresh()` depois de adicionar/remover abas por script.
6
+ */
7
+ export declare class LoccalTabs extends LoccalElement {
8
+ #private;
9
+ static deferWhenEmpty: boolean;
10
+ static observedAttributes: string[];
11
+ get value(): string | undefined;
12
+ set value(v: string | undefined);
13
+ refresh(): void;
14
+ protected setup(): void;
15
+ protected update(): void;
16
+ }
@@ -0,0 +1,62 @@
1
+ import { applyAttrs, bindTabs, createTabs, getTabsProps, resolveLabels, TABS_LABELS } from "@loccal/core";
2
+ import { define, LoccalElement } from "./base.js";
3
+ /**
4
+ * `<loccal-tabs value orientation activation>`: filhos `[data-part=list]` com `[data-part=tab][data-value]`
5
+ * e paineis `[data-part=panel][data-value]`. Evento: `loccal-value-change` { value }.
6
+ * Chame `refresh()` depois de adicionar/remover abas por script.
7
+ */
8
+ export class LoccalTabs extends LoccalElement {
9
+ static deferWhenEmpty = true;
10
+ static observedAttributes = ["value", "orientation", "activation", "locale", "labels"];
11
+ #machine = createTabs({}, (value) => {
12
+ this.setAttribute("value", value);
13
+ this.emit("loccal-value-change", { value });
14
+ });
15
+ #list;
16
+ get value() {
17
+ return this.#machine.state.value;
18
+ }
19
+ set value(v) {
20
+ v === undefined ? this.removeAttribute("value") : this.setAttribute("value", v);
21
+ }
22
+ #collect() {
23
+ return Array.from(this.querySelectorAll("[data-part=tab]")).map((t) => ({ value: t.dataset.value ?? "", disabled: t.hasAttribute("disabled") }));
24
+ }
25
+ refresh() {
26
+ if (!this.isConnected)
27
+ return;
28
+ this.#machine.send({ type: "SET_TABS", tabs: this.#collect() });
29
+ this.update();
30
+ }
31
+ setup() {
32
+ const list = this.querySelector("[data-part=list]");
33
+ if (!list)
34
+ throw new Error("loccal-tabs: falta um elemento [data-part=list]");
35
+ this.#list = list;
36
+ const tabs = this.#collect();
37
+ this.#machine.patch({ tabs, value: this.getAttribute("value") ?? tabs.find((t) => !t.disabled)?.value });
38
+ this.#machine.patch({ focused: this.#machine.state.value });
39
+ this.own(bindTabs(list, this.#machine, getComputedStyle(this).direction === "rtl"));
40
+ this.own(this.#machine.subscribe(() => this.#render()));
41
+ }
42
+ update() {
43
+ const v = this.getAttribute("value");
44
+ this.#machine.patch({
45
+ ...(v !== null && v !== this.#machine.state.value ? { value: v, focused: v } : {}),
46
+ orientation: this.getAttribute("orientation") ?? "horizontal",
47
+ activation: this.getAttribute("activation") ?? "automatic",
48
+ });
49
+ this.#render();
50
+ }
51
+ #render() {
52
+ const s = this.#machine.state;
53
+ const labels = resolveLabels(TABS_LABELS, this.locale, this.labels);
54
+ applyAttrs(this, getTabsProps(s, "root", this.uid));
55
+ applyAttrs(this.#list, getTabsProps(s, "list", this.uid, undefined, labels.tabs));
56
+ for (const t of this.querySelectorAll("[data-part=tab]"))
57
+ applyAttrs(t, getTabsProps(s, "tab", this.uid, t.dataset.value));
58
+ for (const p of this.querySelectorAll("[data-part=panel]"))
59
+ applyAttrs(p, getTabsProps(s, "panel", this.uid, p.dataset.value));
60
+ }
61
+ }
62
+ define("loccal-tabs", LoccalTabs);
@@ -0,0 +1,16 @@
1
+ import { type TerminalTab } from "@loccal/core";
2
+ import { LoccalElement } from "./base.ts";
3
+ /**
4
+ * `<loccal-terminal-tabs active-id>` com propriedade `tabs: {id,title,status?,exitCode?}[]`.
5
+ * Teclado: setas, Home/End, Alt+setas reordena, F2 renomeia, Delete/Ctrl+W fecha. Arrastar reordena.
6
+ * Eventos: loccal-select {id}, loccal-close {id}, loccal-new, loccal-rename {id,title}, loccal-reorder {tabs}.
7
+ * Uso nao controlado: o elemento ja aplica fechar/reordenar/renomear; redefina `tabs` para impor outro estado.
8
+ */
9
+ export declare class LoccalTerminalTabs extends LoccalElement {
10
+ #private;
11
+ static observedAttributes: string[];
12
+ get tabs(): TerminalTab[];
13
+ set tabs(tabs: TerminalTab[]);
14
+ protected setup(): void;
15
+ protected update(): void;
16
+ }
@@ -0,0 +1,79 @@
1
+ import { applyAttrs, bindTabList, createTabList, getTabListProps, loccalIcon, resolveLabels, TERMINAL_TABS_LABELS } from "@loccal/core";
2
+ import { define, el, icon, LoccalElement } from "./base.js";
3
+ /**
4
+ * `<loccal-terminal-tabs active-id>` com propriedade `tabs: {id,title,status?,exitCode?}[]`.
5
+ * Teclado: setas, Home/End, Alt+setas reordena, F2 renomeia, Delete/Ctrl+W fecha. Arrastar reordena.
6
+ * Eventos: loccal-select {id}, loccal-close {id}, loccal-new, loccal-rename {id,title}, loccal-reorder {tabs}.
7
+ * Uso nao controlado: o elemento ja aplica fechar/reordenar/renomear; redefina `tabs` para impor outro estado.
8
+ */
9
+ export class LoccalTerminalTabs extends LoccalElement {
10
+ static observedAttributes = ["active-id", "locale", "labels"];
11
+ #pending;
12
+ #machine = createTabList({}, {
13
+ onSelect: (id) => {
14
+ this.setAttribute("active-id", id);
15
+ this.emit("loccal-select", { id });
16
+ },
17
+ onClose: (id) => this.emit("loccal-close", { id }),
18
+ onRename: (id, title) => this.emit("loccal-rename", { id, title }),
19
+ onReorder: (tabs) => this.emit("loccal-reorder", { tabs }),
20
+ });
21
+ #list;
22
+ #newBtn;
23
+ #key = "";
24
+ get tabs() {
25
+ return this.#machine.state.tabs;
26
+ }
27
+ set tabs(tabs) {
28
+ if (!this.isConnected)
29
+ this.#pending = tabs;
30
+ else
31
+ this.#machine.send({ type: "SET_TABS", tabs });
32
+ }
33
+ setup() {
34
+ this.replaceChildren();
35
+ this.#list = el("div");
36
+ this.#newBtn = el("button", {}, icon(loccalIcon("plus", 14)));
37
+ this.append(this.#list, this.#newBtn);
38
+ if (this.#pending)
39
+ this.#machine.send({ type: "SET_TABS", tabs: this.#pending });
40
+ this.own(bindTabList({ list: this.#list, newButton: this.#newBtn, onNew: () => this.emit("loccal-new", {}) }, this.#machine, getComputedStyle(this).direction === "rtl"));
41
+ this.own(this.#machine.subscribe(() => this.#render()));
42
+ }
43
+ update() {
44
+ const id = this.getAttribute("active-id");
45
+ if (id && id !== this.#machine.state.activeId)
46
+ this.#machine.patch({ activeId: id });
47
+ this.#render();
48
+ }
49
+ #render() {
50
+ const s = this.#machine.state;
51
+ const labels = resolveLabels(TERMINAL_TABS_LABELS, this.locale, this.labels);
52
+ applyAttrs(this, getTabListProps(s, "root", this.uid));
53
+ applyAttrs(this.#list, getTabListProps(s, "list", this.uid, undefined, labels));
54
+ applyAttrs(this.#newBtn, getTabListProps(s, "new", this.uid, undefined, labels));
55
+ // `draft` nao entra na chave: digitar no campo de renomear nao pode recriar o input (perderia o foco).
56
+ const key = JSON.stringify([s.tabs, s.activeId, s.editingId, s.dragId, s.overId, labels]);
57
+ if (key === this.#key)
58
+ return;
59
+ this.#key = key;
60
+ this.#list.replaceChildren(...s.tabs.map((t) => this.#tab(s, t, labels)));
61
+ }
62
+ #tab(s, t, labels) {
63
+ const node = el("div");
64
+ applyAttrs(node, getTabListProps(s, "tab", this.uid, t.id));
65
+ node.append(el("span", { "data-part": "status", "data-status": t.status ?? "running" }));
66
+ if (s.editingId === t.id) {
67
+ const input = el("input");
68
+ applyAttrs(input, getTabListProps(s, "rename-input", this.uid, t.id, labels));
69
+ node.append(input);
70
+ }
71
+ else
72
+ node.append(el("span", { "data-part": "title" }, t.title));
73
+ const close = el("button", {}, icon(loccalIcon("x", 12)));
74
+ applyAttrs(close, getTabListProps(s, "close", this.uid, t.id, labels));
75
+ node.append(close);
76
+ return node;
77
+ }
78
+ }
79
+ define("loccal-terminal-tabs", LoccalTerminalTabs);
@@ -0,0 +1,16 @@
1
+ import { type ToastOptions, type Toaster } from "@loccal/core";
2
+ import { LoccalElement } from "./base.ts";
3
+ export { toast } from "@loccal/core";
4
+ /**
5
+ * `<loccal-toaster position="bottom-right">`: area de notificacoes. Use `toast("Salvo")`, `toast.success(...)` (de `@loccal/ui/wc/toaster`).
6
+ * Pausa os temporizadores com hover/foco. Texto da regiao e do botao via `labels`/`locale`.
7
+ */
8
+ export declare class LoccalToaster extends LoccalElement {
9
+ static observedAttributes: string[];
10
+ /** Fila usada (padrao: a global do `toast()`). */
11
+ queue: Toaster;
12
+ /** Atalho: `el.toast("Salvo", { type: "success" })`. */
13
+ toast(message: string, options?: ToastOptions): string;
14
+ protected setup(): void;
15
+ protected update(): void;
16
+ }
@@ -0,0 +1,68 @@
1
+ import { applyAttrs, getToastProps, getToasterProps, loccalIcon, resolveLabels, toaster, TOAST_LABELS } from "@loccal/core";
2
+ import { define, el, icon, LoccalElement } from "./base.js";
3
+ export { toast } from "@loccal/core";
4
+ /**
5
+ * `<loccal-toaster position="bottom-right">`: area de notificacoes. Use `toast("Salvo")`, `toast.success(...)` (de `@loccal/ui/wc/toaster`).
6
+ * Pausa os temporizadores com hover/foco. Texto da regiao e do botao via `labels`/`locale`.
7
+ */
8
+ export class LoccalToaster extends LoccalElement {
9
+ static observedAttributes = ["position", "locale", "labels"];
10
+ /** Fila usada (padrao: a global do `toast()`). */
11
+ queue = toaster;
12
+ /** Atalho: `el.toast("Salvo", { type: "success" })`. */
13
+ toast(message, options) {
14
+ return this.queue.add(message, options);
15
+ }
16
+ setup() {
17
+ const pause = () => this.queue.pause();
18
+ const resume = () => this.queue.resume();
19
+ this.addEventListener("pointerenter", pause);
20
+ this.addEventListener("pointerleave", resume);
21
+ this.addEventListener("focusin", pause);
22
+ this.addEventListener("focusout", resume);
23
+ this.own(() => {
24
+ this.removeEventListener("pointerenter", pause);
25
+ this.removeEventListener("pointerleave", resume);
26
+ this.removeEventListener("focusin", pause);
27
+ this.removeEventListener("focusout", resume);
28
+ });
29
+ this.own(this.queue.subscribe(() => this.update()));
30
+ }
31
+ update() {
32
+ const labels = resolveLabels(TOAST_LABELS, this.locale, this.labels);
33
+ applyAttrs(this, getToasterProps(this.getAttribute("position") ?? "bottom-right", labels.region));
34
+ const wanted = this.queue.state.toasts;
35
+ const existing = new Map(Array.from(this.querySelectorAll("[data-part=toast]")).map((n) => [n.getAttribute("data-id"), n]));
36
+ for (const [id, node] of existing)
37
+ if (!wanted.some((t) => t.id === id))
38
+ node.remove();
39
+ for (const t of wanted) {
40
+ let node = existing.get(t.id);
41
+ if (!node) {
42
+ node = el("div");
43
+ this.append(node);
44
+ node.append(el("div", { "data-part": "title" }), el("div", { "data-part": "description" }));
45
+ }
46
+ applyAttrs(node, getToastProps(t));
47
+ node.querySelector("[data-part=title]").textContent = t.message;
48
+ const desc = node.querySelector("[data-part=description]");
49
+ desc.textContent = t.description ?? "";
50
+ desc.hidden = !t.description;
51
+ node.querySelector("[data-part=action]")?.remove();
52
+ node.querySelector("[data-part=close]")?.remove();
53
+ if (t.action) {
54
+ const a = el("button", { "data-part": "action", type: "button" }, t.action.label);
55
+ a.addEventListener("click", () => {
56
+ t.action.onClick?.();
57
+ this.queue.dismiss(t.id);
58
+ });
59
+ node.append(a);
60
+ }
61
+ const close = el("button", { "data-part": "close", type: "button", "aria-label": labels.dismiss });
62
+ close.append(icon(loccalIcon("x", 14)));
63
+ close.addEventListener("click", () => this.queue.dismiss(t.id));
64
+ node.append(close);
65
+ }
66
+ }
67
+ }
68
+ define("loccal-toaster", LoccalToaster);
@@ -0,0 +1,30 @@
1
+ import { type ToggleKind } from "@loccal/core";
2
+ import { LoccalElement } from "./base.ts";
3
+ /** `<loccal-switch>` e `<loccal-checkbox>`: envolvem um `<button role=switch|checkbox>`. Evento: `loccal-checked-change` { checked }. */
4
+ declare abstract class ToggleElement extends LoccalElement {
5
+ #private;
6
+ protected abstract readonly kind: ToggleKind;
7
+ static deferWhenEmpty: boolean;
8
+ static observedAttributes: string[];
9
+ get button(): HTMLButtonElement;
10
+ get checked(): boolean;
11
+ set checked(v: boolean);
12
+ protected setup(): void;
13
+ protected update(): void;
14
+ }
15
+ export declare class LoccalSwitch extends ToggleElement {
16
+ protected readonly kind: "switch";
17
+ }
18
+ export declare class LoccalCheckbox extends ToggleElement {
19
+ protected readonly kind: "checkbox";
20
+ }
21
+ /** `<loccal-toggle pressed variant size>`: botao de alternancia (aria-pressed). Evento: `loccal-pressed-change`. */
22
+ export declare class LoccalToggle extends LoccalElement {
23
+ #private;
24
+ static deferWhenEmpty: boolean;
25
+ static observedAttributes: string[];
26
+ get button(): HTMLButtonElement;
27
+ protected setup(): void;
28
+ protected update(): void;
29
+ }
30
+ export {};
@@ -0,0 +1,101 @@
1
+ import { applyAttrs, checkboxMarkSvg, bindButton, bindToggle, createButton, createToggle, getToggleIndicatorProps, getTogglePressedProps, getToggleProps } from "@loccal/core";
2
+ import { define, LoccalElement } from "./base.js";
3
+ /** `<loccal-switch>` e `<loccal-checkbox>`: envolvem um `<button role=switch|checkbox>`. Evento: `loccal-checked-change` { checked }. */
4
+ class ToggleElement extends LoccalElement {
5
+ static deferWhenEmpty = false;
6
+ static observedAttributes = ["checked", "disabled", "required", "size", "name", "value", "locale"];
7
+ #machine = createToggle({}, (checked) => {
8
+ checked ? this.setAttribute("checked", "") : this.removeAttribute("checked");
9
+ this.emit("loccal-checked-change", { checked });
10
+ });
11
+ #inner;
12
+ #input;
13
+ get button() {
14
+ return this.#inner;
15
+ }
16
+ get checked() {
17
+ return this.#machine.state.checked === true;
18
+ }
19
+ set checked(v) {
20
+ v ? this.setAttribute("checked", "") : this.removeAttribute("checked");
21
+ }
22
+ setup() {
23
+ // Reconexao (ex.: Angular move o no): reaproveita o botao existente em vez de duplicar.
24
+ const existing = this.querySelector(":scope > button[data-slot]");
25
+ if (existing)
26
+ this.#inner = existing;
27
+ else {
28
+ this.#inner = document.createElement("button");
29
+ this.#inner.append(document.createElement("span"));
30
+ this.append(this.#inner);
31
+ }
32
+ this.own(bindToggle(this.#inner, this.#machine));
33
+ }
34
+ update() {
35
+ const checked = this.getAttribute("checked");
36
+ this.#machine.patch({
37
+ checked: checked === "indeterminate" ? "indeterminate" : checked !== null && checked !== "false",
38
+ disabled: this.bool("disabled"),
39
+ required: this.bool("required"),
40
+ });
41
+ const s = this.#machine.state;
42
+ applyAttrs(this.#inner, getToggleProps(this.kind, s, { size: this.getAttribute("size") ?? undefined }));
43
+ const mark = this.#inner.firstElementChild;
44
+ applyAttrs(mark, getToggleIndicatorProps(this.kind, s));
45
+ mark.innerHTML = this.kind === "checkbox" ? checkboxMarkSvg(s.checked) : "";
46
+ const name = this.getAttribute("name");
47
+ if (name && !this.#input) {
48
+ this.#input = document.createElement("input");
49
+ this.#input.type = "checkbox";
50
+ this.#input.tabIndex = -1;
51
+ this.#input.setAttribute("aria-hidden", "true");
52
+ this.#input.setAttribute("data-loccal-sr-only", "");
53
+ this.append(this.#input);
54
+ }
55
+ if (this.#input) {
56
+ this.#input.name = name ?? "";
57
+ this.#input.value = this.getAttribute("value") ?? "on";
58
+ this.#input.checked = s.checked === true;
59
+ this.#input.disabled = s.disabled;
60
+ }
61
+ }
62
+ }
63
+ export class LoccalSwitch extends ToggleElement {
64
+ kind = "switch";
65
+ }
66
+ export class LoccalCheckbox extends ToggleElement {
67
+ kind = "checkbox";
68
+ }
69
+ define("loccal-switch", LoccalSwitch);
70
+ define("loccal-checkbox", LoccalCheckbox);
71
+ /** `<loccal-toggle pressed variant size>`: botao de alternancia (aria-pressed). Evento: `loccal-pressed-change`. */
72
+ export class LoccalToggle extends LoccalElement {
73
+ static deferWhenEmpty = true;
74
+ static observedAttributes = ["pressed", "variant", "size", "disabled"];
75
+ #machine = createButton({ pressed: false }, (pressed) => {
76
+ pressed ? this.setAttribute("pressed", "") : this.removeAttribute("pressed");
77
+ this.emit("loccal-pressed-change", { pressed });
78
+ });
79
+ #inner;
80
+ get button() {
81
+ return this.#inner;
82
+ }
83
+ setup() {
84
+ const existing = this.querySelector(":scope > button[data-slot]");
85
+ if (existing)
86
+ this.#inner = existing;
87
+ else {
88
+ this.#inner = document.createElement("button");
89
+ this.#inner.append(...Array.from(this.childNodes));
90
+ this.append(this.#inner);
91
+ }
92
+ this.own(bindButton(this.#inner, this.#machine));
93
+ }
94
+ update() {
95
+ const p = this.getAttribute("pressed");
96
+ this.#machine.patch({ pressed: p !== null && p !== "false", disabled: this.bool("disabled") });
97
+ const s = this.#machine.state;
98
+ applyAttrs(this.#inner, getTogglePressedProps(s.pressed === true, { variant: this.getAttribute("variant") ?? undefined, size: this.getAttribute("size") ?? undefined, disabled: s.disabled }));
99
+ }
100
+ }
101
+ define("loccal-toggle", LoccalToggle);
@@ -0,0 +1,17 @@
1
+ import { LoccalElement } from "./base.ts";
2
+ /**
3
+ * `<loccal-tree-view selected="id" expanded="a,b" aria-label>`: itens `[data-part=item][data-id]`, cada um com `[data-part=row]`
4
+ * (area clicavel) e, se for ramo, um `[data-part=group]` com os filhos. Setas, Home/End, Enter/Espaco e `*` navegam.
5
+ * Eventos: `loccal-select` { id }, `loccal-expanded-change` { expanded }.
6
+ */
7
+ export declare class LoccalTreeView extends LoccalElement {
8
+ #private;
9
+ static deferWhenEmpty: boolean;
10
+ static observedAttributes: string[];
11
+ get selected(): string | null;
12
+ set selected(id: string | null);
13
+ get expanded(): string[];
14
+ set expanded(ids: string[]);
15
+ protected setup(): void;
16
+ protected update(): void;
17
+ }
@@ -0,0 +1,72 @@
1
+ import { applyAttrs, bindTree, createTree, getTreeGroupProps, getTreeItemProps, getTreeProps } from "@loccal/core";
2
+ import { define, LoccalElement } from "./base.js";
3
+ /**
4
+ * `<loccal-tree-view selected="id" expanded="a,b" aria-label>`: itens `[data-part=item][data-id]`, cada um com `[data-part=row]`
5
+ * (area clicavel) e, se for ramo, um `[data-part=group]` com os filhos. Setas, Home/End, Enter/Espaco e `*` navegam.
6
+ * Eventos: `loccal-select` { id }, `loccal-expanded-change` { expanded }.
7
+ */
8
+ export class LoccalTreeView extends LoccalElement {
9
+ static deferWhenEmpty = true;
10
+ static observedAttributes = ["selected", "expanded"];
11
+ #machine = createTree({}, {
12
+ onSelect: (id) => {
13
+ this.setAttribute("selected", id);
14
+ this.emit("loccal-select", { id });
15
+ },
16
+ onExpandedChange: (expanded) => {
17
+ this.setAttribute("expanded", expanded.join(","));
18
+ this.emit("loccal-expanded-change", { expanded });
19
+ },
20
+ });
21
+ #observer;
22
+ get selected() {
23
+ return this.#machine.state.selected;
24
+ }
25
+ set selected(id) {
26
+ id === null ? this.removeAttribute("selected") : this.setAttribute("selected", id);
27
+ }
28
+ get expanded() {
29
+ return this.#machine.state.expanded;
30
+ }
31
+ set expanded(ids) {
32
+ this.setAttribute("expanded", ids.join(","));
33
+ }
34
+ setup() {
35
+ this.own(bindTree(this, this.#machine));
36
+ this.own(this.#machine.subscribe(() => this.#render()));
37
+ this.#observer = new MutationObserver(() => this.#render());
38
+ this.#observer.observe(this, { childList: true, subtree: true });
39
+ this.own(() => this.#observer?.disconnect());
40
+ }
41
+ update() {
42
+ const sel = this.getAttribute("selected");
43
+ const exp = this.getAttribute("expanded");
44
+ this.#machine.patch({
45
+ selected: sel || null,
46
+ ...(exp !== null && { expanded: exp.split(",").map((s) => s.trim()).filter(Boolean) }),
47
+ });
48
+ this.#render();
49
+ }
50
+ #render() {
51
+ const s = this.#machine.state;
52
+ this.#observer?.disconnect();
53
+ applyAttrs(this, getTreeProps(this.getAttribute("aria-label") ?? undefined));
54
+ let first = true;
55
+ const walk = (container, level) => {
56
+ const kids = Array.from(container.children).filter((c) => c.getAttribute("data-part") === "item");
57
+ kids.forEach((el, i) => {
58
+ const group = Array.from(el.children).find((c) => c.getAttribute("data-part") === "group");
59
+ const id = el.getAttribute("data-id") ?? el.getAttribute("value") ?? (el.querySelector("[data-part=row]")?.textContent ?? "").trim();
60
+ applyAttrs(el, getTreeItemProps(s, { id, branch: !!group, level, setsize: kids.length, posinset: i + 1, first }));
61
+ first = false;
62
+ if (group) {
63
+ applyAttrs(group, getTreeGroupProps(s, id));
64
+ walk(group, level + 1);
65
+ }
66
+ });
67
+ };
68
+ walk(this, 1);
69
+ this.#observer?.observe(this, { childList: true, subtree: true });
70
+ }
71
+ }
72
+ define("loccal-tree-view", LoccalTreeView);
@@ -0,0 +1,54 @@
1
+ # Arquitetura do Loccal UI
2
+
3
+ O Loccal UI separa o comportamento dos componentes (maquinas de estado, teclado, ARIA, foco) da camada que desenha na tela. Assim o mesmo componente existe como React, como custom element e como adaptador para Vue, Svelte e Angular, com o mesmo markup e o mesmo CSS.
4
+
5
+ ## Pacotes
6
+
7
+ | Pacote | Papel |
8
+ | --- | --- |
9
+ | `@loccal/core` | Nucleo headless em TypeScript, sem dependencias e sem acesso a DOM no import (seguro para SSR). Maquinas de estado, teclado, a11y, i18n, icones e tokens CSS. |
10
+ | `@loccal/ui` | Componentes React (Tailwind 4) por subpath, o CSS base (`styles.css`) e a camada vanilla em `@loccal/ui/wc` (custom elements em Light DOM) com bundle para CDN. |
11
+ | `@loccal/react` | Adaptadores React 19 / Next, compativeis com RSC. |
12
+ | `@loccal/vue` | Adaptadores Vue 3. |
13
+ | `@loccal/svelte` | Componentes Svelte 5 (runes). |
14
+ | `@loccal/angular` | Componentes Angular standalone sobre os custom elements. |
15
+
16
+ ## Contrato da maquina
17
+
18
+ Cada componente headless expoe tres pecas:
19
+
20
+ 1. `createX(options)` devolve uma maquina com `state`, `send(event)`, `subscribe(fn)` e `destroy()`. As transicoes sao puras e testaveis sem DOM.
21
+ 2. `getXProps(snapshot, parte, labels)` devolve os atributos (`role`, `aria-*`, `data-state`, `tabindex`, `id`) de cada parte. E uma funcao pura, usada tambem no servidor.
22
+ 3. `bindX(elements, machine)` liga eventos de teclado, ponteiro e foco no cliente e devolve a funcao de limpeza.
23
+
24
+ Os adaptadores usam 1 e 2 para renderizar e 3 depois de montar. O custom element usa as tres em `connectedCallback`.
25
+
26
+ ## Estilo e tokens
27
+
28
+ - Os tokens sao variaveis CSS (`--background`, `--primary`, `--radius` e a densidade desktop). Tema claro e escuro por atributo `data-theme` ou `prefers-color-scheme`.
29
+ - A camada vanilla usa CSS puro com `@layer`, seletores por `data-slot` e `data-variant`, sem Tailwind em runtime. Apps com Tailwind continuam podendo sobrescrever com utilitarios.
30
+ - Icones sao dados (`loccalIcon(nome, tamanho)`), renderizados como SVG com traco unico de 1,5px.
31
+
32
+ ## Internacionalizacao
33
+
34
+ Todo texto visivel vem de `labels`, com padrao em pt-BR. Os idiomas pt-BR, en-US e es-ES sao suportados. O custom element aceita `labels` como propriedade ou como atributo JSON; os adaptadores recebem a prop `labels`. A troca global de idioma usa `setLoccalLocale` e o evento `loccal:locale-changed`.
35
+
36
+ ## SSR, hidratacao e CDN
37
+
38
+ - No servidor, os adaptadores usam `getXProps` com o estado inicial para emitir ARIA correto, sem tocar no DOM.
39
+ - Na hidratacao, o controlador so liga eventos no cliente. Os atributos do servidor e do cliente vem da mesma funcao, sem divergencia.
40
+ - HTML puro: carregue `loccal-ui.min.js` como modulo e `loccal-ui.css`, e use `<loccal-dialog>` e os demais elementos. Com bundler: `import "@loccal/ui/wc/dialog"`.
41
+
42
+ ## Testes
43
+
44
+ - Core: `node --test`, sobre maquinas e funcoes de props puras.
45
+ - Custom elements e adaptadores: Vitest com happy-dom, cobrindo foco preso, ESC, setas, ARIA e rotulos nos tres idiomas.
46
+ - Exemplos: um app minimo por alvo (HTML, React, Next, Vue, Svelte, Angular), compilado nos testes.
47
+ - Contrato: `contract/api.json` registra a API publica; o teste falha se ela mudar sem um changeset adequado.
48
+
49
+ ## Adicionando um componente a camada vanilla
50
+
51
+ 1. Maquina e funcoes de props em `packages/core`.
52
+ 2. Custom element em `packages/ui/wc`.
53
+ 3. Adaptadores em `packages/react`, `packages/vue`, `packages/svelte` e `packages/angular`.
54
+ 4. Os cinco exemplos em `packages/examples/snippets/<slug>/` e a matriz de suporte (`npm run matrix`).
@@ -0,0 +1,88 @@
1
+ # Versionamento e distribuicao do Loccal UI
2
+
3
+ ## Decisao de arquitetura
4
+
5
+ | Tema | Decisao | Motivo |
6
+ | --- | --- | --- |
7
+ | Pacote | `@loccal/ui` em `packages/ui` (workspace npm) | Um artefato instalavel por npm, pnpm, yarn e bun. |
8
+ | Fonte | Continua em `components/ui` e `lib` na raiz | O site de docs e o pacote usam o mesmo codigo; nao ha copia para divergir. O build compila essas pastas. |
9
+ | Formato | ESM + `.d.ts`, um arquivo por componente, diretiva `"use client"` preservada | Tree-shaking natural e compatibilidade com RSC (Next) e Vite. |
10
+ | Entradas | `exports` por subpath: `@loccal/ui/button`, `@loccal/ui/lib/utils`, `@loccal/ui/styles.css`. Sem barrel na raiz | Cada componente e uma entrada versionavel e nao puxa dependencias opcionais dos outros (recharts, xterm, cmdk). |
11
+ | `sideEffects` | `["**/*.css"]` | JS e livre de efeitos colaterais; so o CSS nao pode ser podado. |
12
+ | Estilos | `@loccal/ui/styles.css` (tokens, variantes `data-*`, utilitarios) com `@source "./dist"` | Tailwind 4 do app enxerga as classes do pacote sem configuracao. |
13
+ | Dependencias | `dependencies`: clsx, tailwind-merge, class-variance-authority. `peerDependencies`: react, react-dom, @base-ui/react, tailwindcss, tw-animate-css. Peers opcionais: cmdk, recharts, sonner, next-themes, react-day-picker, react-resizable-panels, input-otp, @xterm/* | O app instala so o que usa. |
14
+
15
+ Os modulos `lib/registry` e `lib/highlight` pertencem ao site e ficam fora do pacote.
16
+
17
+ ## Como um app fixa versao
18
+
19
+ 1. Instale uma versao exata (sem `^`):
20
+ ```
21
+ npm install @loccal/ui@0.1.0 --save-exact
22
+ pnpm add @loccal/ui@0.1.0 --save-exact
23
+ yarn add @loccal/ui@0.1.0 --exact
24
+ bun add @loccal/ui@0.1.0 --exact
25
+ ```
26
+ 2. Importe por subpath e carregue o CSS uma vez:
27
+ ```ts
28
+ import "@loccal/ui/styles.css"
29
+ import { Button } from "@loccal/ui/button"
30
+ import { cn } from "@loccal/ui/lib/utils"
31
+ ```
32
+ 3. Atualize apenas quando quiser: leia o `CHANGELOG.md`, suba a versao, rode build e testes. Dentro da mesma major nada quebra.
33
+
34
+ Antes da primeira publicacao no npm, o app pode usar o tarball gerado por `npm pack` (`"@loccal/ui": "file:./vendor/loccal-ui-0.1.0.tgz"`). Depois da publicacao troque por `"@loccal/ui": "0.1.0"`.
35
+
36
+ ## Regras de versao (semver rigoroso)
37
+
38
+ - `patch`: correcao sem mudar a API publica (props, variantes, nomes de export, classes de estilo contratuais).
39
+ - `minor`: adicao compativel: componente novo, prop opcional, variante nova, export novo.
40
+ - `major`: remover/renomear export ou prop, tornar prop obrigatoria, estreitar tipo, remover variante, mudar o comportamento de forma observavel.
41
+ - Evolucao e aditiva por padrao. Para substituir algo, adicione o novo, marque o antigo como `@deprecated` (JSDoc) e remova so na proxima major.
42
+ - Uma versao publicada nunca e alterada nem despublicada; correcoes saem em nova versao.
43
+
44
+ ## Changelog por componente
45
+
46
+ Usamos changesets (`.changeset/`). Cada changeset tem uma linha por componente, prefixada com o nome:
47
+
48
+ ```
49
+ ---
50
+ "@loccal/ui": minor
51
+ ---
52
+
53
+ button: nova variante `soft`
54
+ dialog: prop `onOpenChangeComplete`
55
+ ```
56
+
57
+ `npx changeset version` consolida em `packages/ui/CHANGELOG.md`; o prefixo permite filtrar por componente. Alem disso, `contract/api.json` e o livro-razao por componente: cada modulo, export e prop traz `since` (a versao em que apareceu).
58
+
59
+ ## Teste de contrato da API publica
60
+
61
+ `contract/api.json` e um snapshot extraido pelo compilador TypeScript (exports e props de cada modulo).
62
+
63
+ - `npm run contract --prefix packages/ui` (e `test`, e `prepack`) compara o codigo com o snapshot.
64
+ - Quebra (export/prop removido, opcional virando obrigatorio, tipo estreitado, nova prop obrigatoria) falha, a menos que exista um changeset `"@loccal/ui": major` pendente.
65
+ - Adicao compativel tambem falha ate o snapshot ser atualizado com `npm run contract:update --prefix packages/ui` (o diff do snapshot aparece no PR).
66
+ - Apos `changeset version`, `node packages/ui/scripts/contract.mjs stamp` troca `"since": "next"` pela versao liberada.
67
+
68
+ ## Fluxo de release
69
+
70
+ ```
71
+ npx changeset # descreve a mudanca (por componente)
72
+ npm run contract:update --prefix packages/ui # se a API mudou
73
+ npx changeset version # sobe a versao e gera o CHANGELOG
74
+ node packages/ui/scripts/contract.mjs stamp # carimba since
75
+ npm run verify:pack --prefix packages/ui # empacota e compila num projeto vazio
76
+ npm run build --prefix packages/ui && (cd packages/ui && npm pack) # gera o tarball
77
+ ```
78
+
79
+ A publicacao (`npm publish --access public` na pasta de cada pacote, com a conta dona do escopo `@loccal`) so deve ser feita com confirmacao explicita do responsavel. O workflow `.github/workflows/release.yml` publica via changesets apenas quando o segredo `NPM_TOKEN` existir.
80
+
81
+ ## Verificacoes
82
+
83
+ - `npm test --prefix packages/ui`: contrato, exports e reescrita de imports.
84
+ - `npm run verify:pack --prefix packages/ui [-- --pm npm|pnpm|yarn|bun]`: `npm pack`, instalacao num projeto vazio, `tsc` consumindo `@loccal/ui/button`, `@loccal/ui/badge`, `@loccal/ui/lib/utils` e import ESM real no Node.
85
+
86
+ ## Adicionando um componente
87
+
88
+ Crie `components/ui/<nome>.tsx` (imports internos como `@/lib/utils`), rode `npm run build --prefix packages/ui` e `npm run contract:update --prefix packages/ui`, adicione um changeset `minor`. O export `@loccal/ui/<nome>` e gerado sozinho.