@ankhorage/zora 20.0.1 → 20.1.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 (65) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli/commands/create.d.ts +14 -0
  3. package/dist/cli/commands/create.d.ts.map +1 -0
  4. package/dist/cli/commands/create.js +61 -0
  5. package/dist/cli/commands/create.js.map +1 -0
  6. package/dist/cli/index.d.ts +18 -0
  7. package/dist/cli/index.d.ts.map +1 -0
  8. package/dist/cli/index.js +33 -0
  9. package/dist/cli/index.js.map +1 -0
  10. package/dist/features/tree-view/adapters/inbound/TreeItem.d.ts +1 -5
  11. package/dist/features/tree-view/adapters/inbound/TreeItem.d.ts.map +1 -1
  12. package/dist/features/tree-view/adapters/inbound/TreeItem.js +16 -9
  13. package/dist/features/tree-view/adapters/inbound/TreeItem.js.map +1 -1
  14. package/dist/features/tree-view/adapters/inbound/TreeView.d.ts +1 -5
  15. package/dist/features/tree-view/adapters/inbound/TreeView.d.ts.map +1 -1
  16. package/dist/features/tree-view/adapters/inbound/TreeView.js +6 -9
  17. package/dist/features/tree-view/adapters/inbound/TreeView.js.map +1 -1
  18. package/dist/features/tree-view/adapters/inbound/web-artifact/TreeItemRow.d.ts +15 -0
  19. package/dist/features/tree-view/adapters/inbound/web-artifact/TreeItemRow.d.ts.map +1 -0
  20. package/dist/features/tree-view/adapters/inbound/web-artifact/TreeItemRow.js +121 -0
  21. package/dist/features/tree-view/adapters/inbound/web-artifact/TreeItemRow.js.map +1 -0
  22. package/dist/features/tree-view/adapters/inbound/web-artifact/TreeView.d.ts +32 -0
  23. package/dist/features/tree-view/adapters/inbound/web-artifact/TreeView.d.ts.map +1 -0
  24. package/dist/features/tree-view/adapters/inbound/web-artifact/TreeView.js +24 -0
  25. package/dist/features/tree-view/adapters/inbound/web-artifact/TreeView.js.map +1 -0
  26. package/dist/features/tree-view/utils/toggleExpandedIds.d.ts +3 -0
  27. package/dist/features/tree-view/utils/toggleExpandedIds.d.ts.map +1 -0
  28. package/dist/features/tree-view/utils/toggleExpandedIds.js +7 -0
  29. package/dist/features/tree-view/utils/toggleExpandedIds.js.map +1 -0
  30. package/dist/features/web-component-artifact/adapters/outbound/node/createNodeWebComponentArtifactFileSystem.d.ts +4 -0
  31. package/dist/features/web-component-artifact/adapters/outbound/node/createNodeWebComponentArtifactFileSystem.d.ts.map +1 -0
  32. package/dist/features/web-component-artifact/adapters/outbound/node/createNodeWebComponentArtifactFileSystem.js +20 -0
  33. package/dist/features/web-component-artifact/adapters/outbound/node/createNodeWebComponentArtifactFileSystem.js.map +1 -0
  34. package/dist/features/web-component-artifact/application/ports/outbound/WebComponentArtifactFileSystemPort.d.ts +7 -0
  35. package/dist/features/web-component-artifact/application/ports/outbound/WebComponentArtifactFileSystemPort.d.ts.map +1 -0
  36. package/dist/features/web-component-artifact/application/ports/outbound/WebComponentArtifactFileSystemPort.js +2 -0
  37. package/dist/features/web-component-artifact/application/ports/outbound/WebComponentArtifactFileSystemPort.js.map +1 -0
  38. package/dist/features/web-component-artifact/application/use-cases/materializeWebComponentArtifactAsync.d.ts +16 -0
  39. package/dist/features/web-component-artifact/application/use-cases/materializeWebComponentArtifactAsync.d.ts.map +1 -0
  40. package/dist/features/web-component-artifact/application/use-cases/materializeWebComponentArtifactAsync.js +42 -0
  41. package/dist/features/web-component-artifact/application/use-cases/materializeWebComponentArtifactAsync.js.map +1 -0
  42. package/dist/features/web-component-artifact/composition/materializeWebComponentArtifactWithNodeAsync.d.ts +4 -0
  43. package/dist/features/web-component-artifact/composition/materializeWebComponentArtifactWithNodeAsync.d.ts.map +1 -0
  44. package/dist/features/web-component-artifact/composition/materializeWebComponentArtifactWithNodeAsync.js +7 -0
  45. package/dist/features/web-component-artifact/composition/materializeWebComponentArtifactWithNodeAsync.js.map +1 -0
  46. package/package.json +20 -7
  47. package/src/cli/commands/create.ts +96 -0
  48. package/src/cli/index.test.ts +18 -0
  49. package/src/cli/index.ts +50 -0
  50. package/src/features/tree-view/adapters/inbound/TreeItem.tsx +33 -27
  51. package/src/features/tree-view/adapters/inbound/TreeView.tsx +6 -9
  52. package/src/features/tree-view/adapters/inbound/web-artifact/TreeItemRow.tsx +197 -0
  53. package/src/features/tree-view/adapters/inbound/web-artifact/TreeView.test.tsx +28 -0
  54. package/src/features/tree-view/adapters/inbound/web-artifact/TreeView.tsx +91 -0
  55. package/src/features/tree-view/utils/toggleExpandedIds.test.ts +12 -0
  56. package/src/features/tree-view/utils/toggleExpandedIds.ts +9 -0
  57. package/src/features/web-component-artifact/adapters/outbound/node/createNodeWebComponentArtifactFileSystem.ts +22 -0
  58. package/src/features/web-component-artifact/application/ports/outbound/WebComponentArtifactFileSystemPort.ts +6 -0
  59. package/src/features/web-component-artifact/application/use-cases/materializeWebComponentArtifactAsync.test.ts +84 -0
  60. package/src/features/web-component-artifact/application/use-cases/materializeWebComponentArtifactAsync.ts +83 -0
  61. package/src/features/web-component-artifact/composition/materializeWebComponentArtifactWithNodeAsync.ts +16 -0
  62. package/src/platformAcceptance.test.ts +1 -1
  63. package/src/structureOwnership.test.ts +2 -2
  64. package/web-dist/tree-view/TreeView.d.ts +32 -0
  65. package/web-dist/tree-view/TreeView.js +219 -0
@@ -0,0 +1,219 @@
1
+ // src/features/tree-view/adapters/inbound/web-artifact/TreeView.tsx
2
+ import React2 from "react";
3
+
4
+ // src/features/tree-view/utils/toggleExpandedIds.ts
5
+ function toggleExpandedIds(expandedIds, id) {
6
+ return expandedIds.includes(id) ? expandedIds.filter((expandedId) => expandedId !== id) : [...expandedIds, id];
7
+ }
8
+
9
+ // src/features/tree-view/adapters/inbound/web-artifact/TreeItemRow.tsx
10
+ import React from "react";
11
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
12
+ import { createElement } from "react";
13
+ function TreeItemRow(props) {
14
+ const { node } = props;
15
+ const hasChildren = node.children !== undefined && node.children.length > 0;
16
+ const expanded = props.expandedIds.includes(node.id);
17
+ const selected = props.selectedId === node.id;
18
+ const content = props.renderItem?.({
19
+ node,
20
+ depth: props.depth,
21
+ selected,
22
+ expanded,
23
+ hasChildren
24
+ }) ?? /* @__PURE__ */ jsxDEV(TreeItemDefaultContent, {
25
+ node
26
+ }, undefined, false, undefined, this);
27
+ return /* @__PURE__ */ jsxDEV(Fragment, {
28
+ children: [
29
+ /* @__PURE__ */ jsxDEV("div", {
30
+ "aria-disabled": node.disabled === true ? true : undefined,
31
+ "aria-expanded": hasChildren ? expanded : undefined,
32
+ "aria-selected": selected,
33
+ onClick: () => selectNode(props),
34
+ onKeyDown: (event) => selectNodeFromKeyboard(event, props),
35
+ role: "treeitem",
36
+ tabIndex: node.disabled || props.onSelect === undefined ? undefined : 0,
37
+ style: createRowStyle(props.depth, selected, node.disabled, props.onSelect !== undefined),
38
+ children: [
39
+ content,
40
+ /* @__PURE__ */ jsxDEV(TreeItemActions, {
41
+ actions: node.actions
42
+ }, undefined, false, undefined, this),
43
+ /* @__PURE__ */ jsxDEV(TreeItemExpander, {
44
+ expanded,
45
+ hasChildren,
46
+ nodeId: node.id,
47
+ onToggleExpand: props.onToggleExpand
48
+ }, undefined, false, undefined, this)
49
+ ]
50
+ }, undefined, true, undefined, this),
51
+ hasChildren && expanded ? /* @__PURE__ */ jsxDEV(TreeItemChildren, {
52
+ ...props
53
+ }, undefined, false, undefined, this) : null
54
+ ]
55
+ }, undefined, true, undefined, this);
56
+ }
57
+ function TreeItemDefaultContent({
58
+ node
59
+ }) {
60
+ return /* @__PURE__ */ jsxDEV(Fragment, {
61
+ children: [
62
+ node.icon === undefined ? null : /* @__PURE__ */ jsxDEV("span", {
63
+ "aria-hidden": "true",
64
+ style: ICON_STYLE,
65
+ children: node.icon
66
+ }, undefined, false, undefined, this),
67
+ /* @__PURE__ */ jsxDEV("span", {
68
+ style: LABEL_STYLE,
69
+ children: node.label
70
+ }, undefined, false, undefined, this),
71
+ node.meta === undefined ? null : /* @__PURE__ */ jsxDEV("span", {
72
+ style: META_STYLE,
73
+ children: node.meta
74
+ }, undefined, false, undefined, this)
75
+ ]
76
+ }, undefined, true, undefined, this);
77
+ }
78
+ function TreeItemActions({ actions }) {
79
+ if (actions === undefined)
80
+ return null;
81
+ return /* @__PURE__ */ jsxDEV("span", {
82
+ onClick: (event) => event.stopPropagation(),
83
+ onKeyDown: (event) => event.stopPropagation(),
84
+ style: INLINE_STYLE,
85
+ children: actions
86
+ }, undefined, false, undefined, this);
87
+ }
88
+ function TreeItemExpander(props) {
89
+ if (!props.hasChildren)
90
+ return null;
91
+ return /* @__PURE__ */ jsxDEV("button", {
92
+ "aria-label": props.expanded ? "Collapse" : "Expand",
93
+ onClick: (event) => {
94
+ event.stopPropagation();
95
+ props.onToggleExpand(props.nodeId);
96
+ },
97
+ style: EXPANDER_STYLE,
98
+ type: "button",
99
+ children: props.expanded ? "⌄" : "›"
100
+ }, undefined, false, undefined, this);
101
+ }
102
+ function TreeItemChildren(props) {
103
+ return /* @__PURE__ */ jsxDEV("div", {
104
+ role: "group",
105
+ children: props.node.children?.map((child) => /* @__PURE__ */ createElement(TreeItemRow, {
106
+ ...props,
107
+ key: child.id,
108
+ depth: props.depth + 1,
109
+ node: child
110
+ }))
111
+ }, undefined, false, undefined, this);
112
+ }
113
+ function selectNode(props) {
114
+ if (!props.node.disabled)
115
+ props.onSelect?.(props.node.id);
116
+ }
117
+ function selectNodeFromKeyboard(event, props) {
118
+ if (props.node.disabled || event.key !== "Enter" && event.key !== " ")
119
+ return;
120
+ event.preventDefault();
121
+ props.onSelect?.(props.node.id);
122
+ }
123
+ function createRowStyle(depth, selected, disabled, selectable) {
124
+ return {
125
+ ...ROW_STYLE,
126
+ background: selected ? "color-mix(in srgb, currentColor 10%, transparent)" : "transparent",
127
+ cursor: disabled ? "default" : selectable ? "pointer" : "inherit",
128
+ opacity: disabled ? 0.5 : 1,
129
+ paddingLeft: depth * 16 + 6
130
+ };
131
+ }
132
+ var ROW_STYLE = {
133
+ alignItems: "center",
134
+ borderRadius: 6,
135
+ display: "flex",
136
+ gap: 6,
137
+ minHeight: 28,
138
+ paddingRight: 4,
139
+ userSelect: "none"
140
+ };
141
+ var INLINE_STYLE = {
142
+ display: "inline-flex",
143
+ flexShrink: 0
144
+ };
145
+ var ICON_STYLE = INLINE_STYLE;
146
+ var LABEL_STYLE = {
147
+ flex: 1,
148
+ minWidth: 0,
149
+ overflow: "hidden",
150
+ textOverflow: "ellipsis",
151
+ whiteSpace: "nowrap"
152
+ };
153
+ var META_STYLE = {
154
+ flexShrink: 0,
155
+ opacity: 0.65
156
+ };
157
+ var EXPANDER_STYLE = {
158
+ alignItems: "center",
159
+ appearance: "none",
160
+ background: "transparent",
161
+ border: 0,
162
+ color: "inherit",
163
+ cursor: "pointer",
164
+ display: "inline-flex",
165
+ flexShrink: 0,
166
+ font: "inherit",
167
+ height: 24,
168
+ justifyContent: "center",
169
+ padding: 0,
170
+ width: 24
171
+ };
172
+
173
+ // src/features/tree-view/adapters/inbound/web-artifact/TreeView.tsx
174
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
175
+ function TreeView({
176
+ nodes,
177
+ selectedId,
178
+ expandedIds: controlledExpandedIds,
179
+ defaultExpandedIds,
180
+ onSelect,
181
+ onExpandedChange,
182
+ renderItem,
183
+ className,
184
+ style,
185
+ ariaLabel = "Tree"
186
+ }) {
187
+ const [internalExpandedIds, setInternalExpandedIds] = React2.useState(defaultExpandedIds ?? []);
188
+ const isControlled = controlledExpandedIds !== undefined;
189
+ const expandedIds = isControlled ? controlledExpandedIds : internalExpandedIds;
190
+ const handleToggleExpand = React2.useCallback((id) => {
191
+ const nextExpandedIds = toggleExpandedIds(expandedIds, id);
192
+ if (!isControlled)
193
+ setInternalExpandedIds(nextExpandedIds);
194
+ onExpandedChange?.(nextExpandedIds);
195
+ }, [expandedIds, isControlled, onExpandedChange]);
196
+ return /* @__PURE__ */ jsxDEV2("div", {
197
+ "aria-label": ariaLabel,
198
+ className,
199
+ role: "tree",
200
+ style: { ...TREE_STYLE, ...style },
201
+ children: nodes.map((node) => /* @__PURE__ */ jsxDEV2(TreeItemRow, {
202
+ depth: 0,
203
+ expandedIds,
204
+ node,
205
+ onSelect,
206
+ onToggleExpand: handleToggleExpand,
207
+ renderItem,
208
+ selectedId
209
+ }, node.id, false, undefined, this))
210
+ }, undefined, false, undefined, this);
211
+ }
212
+ var TREE_STYLE = {
213
+ display: "flex",
214
+ flexDirection: "column",
215
+ minWidth: 0
216
+ };
217
+ export {
218
+ TreeView
219
+ };