@vivix-labs/dashboard-projects 1.0.0-beta → 1.0.0-beta.2

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.
@@ -0,0 +1,93 @@
1
+ Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -1,75 +1,15 @@
1
- /* packages/studio-workbench/src/home.css */
2
- @font-face {
3
- font-family: "Inria Serif";
4
- font-style: italic;
5
- font-weight: 700;
6
- font-display: swap;
7
- src: url("./assets/inria-serif-latin-700-italic-UNRIXGAH.woff2") format("woff2");
8
- }
9
- .studio-home {
10
- display: grid;
11
- gap: 8px;
12
- inline-size: 100%;
13
- max-inline-size: 1920px;
14
- align-self: center;
1
+ /* packages/dashboard-projects/src/card.css */
2
+ .studio-home-panel {
3
+ --home-panel-inset: 16px;
15
4
  min-width: 0;
5
+ border-radius: 12px;
6
+ background: var(--vx-background-dialog);
16
7
  }
17
- .studio-home-toolbar,
18
8
  .studio-home-panel > header {
19
9
  display: flex;
20
10
  align-items: center;
21
11
  justify-content: space-between;
22
12
  gap: 8px;
23
- }
24
- .studio-home-toolbar {
25
- flex-wrap: wrap;
26
- }
27
- .studio-home-hero {
28
- position: relative;
29
- overflow: hidden;
30
- min-block-size: 123px;
31
- border-radius: 16px;
32
- isolation: isolate;
33
- container: dashboard-hero / inline-size;
34
- background:
35
- linear-gradient(
36
- 90deg,
37
- rgb(255 255 255 / 40%),
38
- rgb(255 255 255 / 60%) 55.28%),
39
- url("./assets/hero-base-5KRPU5WN.png") 50% 32.44% / 108.95% 839.02% no-repeat;
40
- }
41
- .studio-home-hero::before {
42
- position: absolute;
43
- left: 53.31%;
44
- top: calc(50% - 2.365cqw);
45
- width: max(85.56cqw, 380px);
46
- height: max(114.04cqw, 507px);
47
- transform: translate(-50%, -50%) rotate(90deg);
48
- z-index: -1;
49
- content: "";
50
- --hero-wash: light-dark(rgb(255 255 255 / 40%), rgb(0 0 0 / 70%));
51
- background: linear-gradient(var(--hero-wash), var(--hero-wash)), url("./assets/hero-landscape-H35LYO4H.png") center / cover;
52
- }
53
- .studio-home-hero h1 {
54
- color: var(--vx-text-primary);
55
- margin: 0;
56
- font: italic 700 32px/1.15 "Inria Serif", serif;
57
- }
58
- .studio-home-hero p {
59
- margin: 0;
60
- color: var(--vx-text-secondary);
61
- }
62
- .studio-home-panels {
63
- display: grid;
64
- gap: 8px;
65
- min-width: 0;
66
- }
67
- .studio-home-panel {
68
- min-width: 0;
69
- border-radius: 12px;
70
- background: var(--vx-background-dialog);
71
- }
72
- .studio-home-panel > header {
73
13
  min-height: 44px;
74
14
  padding: 0 var(--home-panel-inset);
75
15
  }
@@ -79,9 +19,9 @@
79
19
  }
80
20
  .studio-home-grid {
81
21
  display: grid;
82
- grid-template-columns: repeat(auto-fill, minmax(min(100%, 178px), 1fr));
22
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, max(150px, calc((100% - 32px) / 5))), 1fr));
83
23
  gap: 8px;
84
- padding: 12px;
24
+ padding: 0 var(--home-panel-inset) var(--home-panel-inset);
85
25
  }
86
26
  .studio-home-tile {
87
27
  display: grid;
@@ -112,6 +52,7 @@
112
52
  color: var(--vx-text-secondary);
113
53
  }
114
54
  .studio-home-cover {
55
+ position: relative;
115
56
  display: grid;
116
57
  width: 100%;
117
58
  aspect-ratio: 16 / 9;
@@ -119,9 +60,7 @@
119
60
  overflow: hidden;
120
61
  border-radius: 8px;
121
62
  background: var(--vx-surface-input);
122
- }
123
- .studio-home-cover {
124
- position: relative;
63
+ color: var(--vx-text-placeholder);
125
64
  }
126
65
  .studio-home-cover img,
127
66
  .studio-home-cover video {
@@ -134,123 +73,6 @@
134
73
  .studio-home-cover:has(img, video) {
135
74
  background: #151515;
136
75
  }
137
- .studio-home-template {
138
- container-type: inline-size;
139
- position: relative;
140
- min-width: 0;
141
- }
142
- .studio-home-template > button:last-child {
143
- position: absolute;
144
- inset: 0 0 auto;
145
- translate: 0 -50%;
146
- top: 28.125cqw;
147
- margin: auto;
148
- height: max-content;
149
- width: max-content;
150
- opacity: 0;
151
- background: var(--vx-background-page);
152
- }
153
- .studio-home-template:hover > button:last-child,
154
- .studio-home-template:focus-within > button:last-child {
155
- opacity: 1;
156
- }
157
- .studio-home-empty {
158
- padding: 12px;
159
- margin: 0;
160
- color: var(--vx-text-secondary);
161
- }
162
- .studio-home-dialog textarea {
163
- box-sizing: border-box;
164
- width: 100%;
165
- resize: vertical;
166
- padding: 10px;
167
- border: 1px solid var(--vx-border-secondary);
168
- border-radius: 8px;
169
- background: var(--vx-surface-input);
170
- color: var(--vx-text-primary);
171
- font: inherit;
172
- }
173
- .studio-home-dialog .studio-home-preview {
174
- margin-bottom: 12px;
175
- max-height: 240px;
176
- }
177
- @media (max-width: 660px) {
178
- .studio-home-hero h1 {
179
- font-size: 24px;
180
- }
181
- .studio-home-grid {
182
- grid-template-columns: repeat(auto-fill, minmax(min(100%, 132px), 1fr));
183
- }
184
- }
185
- @media (hover: none) {
186
- .studio-home-template > button:last-child {
187
- opacity: 1;
188
- }
189
- }
190
- .studio-home {
191
- --home-panel-inset: 16px;
192
- }
193
- .studio-home-toolbar > .vx-segment {
194
- width: max-content;
195
- max-width: 100%;
196
- border: 1px solid var(--vx-border-secondary);
197
- border-radius: 999px;
198
- }
199
- .studio-home-hero-copy {
200
- padding: 24px 343px 32px 24px;
201
- }
202
- .studio-home-grid {
203
- padding: 0 var(--home-panel-inset) var(--home-panel-inset);
204
- }
205
- .studio-home-grid:not(.studio-home-gallery) {
206
- grid-template-columns: repeat(auto-fill, minmax(min(100%, max(150px, calc((100% - 32px) / 5))), 1fr));
207
- }
208
- .studio-home-views {
209
- margin-block-start: 4px;
210
- --vx-tabs-primary-height: 55px;
211
- }
212
- .studio-home-views .vx-tabs {
213
- padding-inline: var(--home-panel-inset);
214
- border-block-end: 1px solid var(--vx-border-secondary);
215
- }
216
- .studio-home-views .vx-tab-list {
217
- gap: var(--vx-space-16);
218
- }
219
- .studio-home-views [role=tab] {
220
- padding-inline: 0;
221
- }
222
- .studio-home-views .studio-home-empty {
223
- padding: var(--home-panel-inset);
224
- }
225
- .studio-home-template-summary {
226
- color: var(--vx-text-secondary-readable);
227
- font: var(--vx-typography-inter-12-regular);
228
- }
229
- .studio-home-gallery {
230
- padding-block-start: var(--home-panel-inset);
231
- grid-template-columns: repeat(auto-fill, minmax(min(100%, max(240px, calc((100% - 24px) / 4))), 1fr));
232
- }
233
- .studio-home-template > button:last-child:not(:focus-visible) {
234
- pointer-events: none;
235
- }
236
- .studio-home-template:hover > button:last-child,
237
- .studio-home-template:focus-within > button:last-child {
238
- pointer-events: auto;
239
- }
240
- @media (hover: none) {
241
- .studio-home-template > button:last-child:not(:focus-visible) {
242
- pointer-events: auto;
243
- opacity: 1;
244
- }
245
- }
246
- @media (max-width: 660px) {
247
- .studio-home {
248
- --home-panel-inset: 12px;
249
- }
250
- .studio-home-grid:not(.studio-home-gallery) {
251
- grid-template-columns: repeat(auto-fill, minmax(min(100%, 132px), 1fr));
252
- }
253
- }
254
76
  .studio-home-create .studio-home-cover {
255
77
  border: 1px dashed var(--vx-border-secondary);
256
78
  background: var(--vx-surface-input);
@@ -265,42 +87,27 @@
265
87
  }
266
88
  .studio-home-create-form {
267
89
  display: grid;
268
- gap: var(--vx-space-12);
90
+ gap: var(--vx-space-16);
91
+ }
92
+ .studio-home-create-field {
93
+ display: grid;
94
+ gap: var(--vx-space-8);
95
+ color: var(--vx-text-secondary);
96
+ font: var(--vx-typography-inter-14-regular);
269
97
  }
270
98
  .studio-home-create-form p {
99
+ margin: 0;
271
100
  color: var(--vx-text-secondary-readable);
272
101
  }
273
- .studio-home-toolbar .vx-segment-item {
274
- padding-inline: var(--vx-space-16);
275
- border-radius: 999px;
276
- font: var(--vx-typography-inter-16-medium);
277
- }
278
- .studio-home-toolbar input:checked + .vx-segment-item {
279
- color: var(--vx-state-success);
280
- background: color-mix(in srgb, var(--vx-state-success) 16%, var(--vx-background-page));
281
- }
282
102
  .studio-home-view-all.vx-button {
283
103
  background: transparent;
284
104
  color: var(--vx-state-success);
285
105
  }
286
- .studio-home-actions {
287
- display: flex;
288
- gap: 8px;
289
- align-items: center;
290
- margin-inline-start: auto;
291
- }
292
- .studio-home-script-preview {
293
- position: absolute;
294
- inset: 10% 12% 0;
295
- padding: 8px 10px;
296
- white-space: pre-line;
297
- overflow: hidden;
298
- overflow-wrap: anywhere;
299
- background: var(--vx-background-dialog);
300
- border-radius: 4px 4px 0 0;
301
- font:
302
- 12px/1.4 "Inria Serif",
303
- Georgia,
304
- serif;
305
- mask-image: linear-gradient(#000 65%, transparent);
106
+ @media (max-width: 660px) {
107
+ .studio-home-panel {
108
+ --home-panel-inset: 12px;
109
+ }
110
+ .studio-home-grid {
111
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, 132px), 1fr));
112
+ }
306
113
  }
@@ -1,17 +1,210 @@
1
1
  // packages/dashboard-projects/src/client.tsx
2
- import "react";
3
-
4
- // packages/studio-workbench/src/dashboard-card.tsx
5
- import * as React2 from "react";
6
- import { z as z2 } from "vivix-studio/sdk/shared";
2
+ import * as React from "react";
3
+ import { z } from "vivix-studio/sdk/shared";
7
4
 
8
5
  // packages/ui-system/dist/button.js
9
6
  import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
10
7
 
11
8
  // packages/ui-system/dist/icon.js
12
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
+ var iconGeometry = {
11
+ add: {
12
+ width: 16,
13
+ height: 16,
14
+ slot: 16
15
+ },
16
+ check: {
17
+ width: 12,
18
+ height: 12,
19
+ slot: 12
20
+ },
21
+ "check-on-content": {
22
+ width: 12,
23
+ height: 12,
24
+ slot: 12
25
+ },
26
+ "chevron-up": {
27
+ width: 12,
28
+ height: 12,
29
+ slot: 12
30
+ },
31
+ expand: {
32
+ width: 16,
33
+ height: 16,
34
+ slot: 16
35
+ },
36
+ "chevron-down": {
37
+ width: 12,
38
+ height: 12,
39
+ slot: 12
40
+ },
41
+ clear: {
42
+ width: 14.5332,
43
+ height: 14.5332,
44
+ slot: 16
45
+ },
46
+ grid: {
47
+ width: 13.2039,
48
+ height: 13.2,
49
+ slot: 16
50
+ },
51
+ list: {
52
+ width: 13.3372,
53
+ height: 12.0039,
54
+ slot: 16
55
+ },
56
+ search: {
57
+ width: 13.2,
58
+ height: 13.2,
59
+ slot: 16
60
+ },
61
+ calendar: {
62
+ width: 16,
63
+ height: 16,
64
+ slot: 16
65
+ },
66
+ import: {
67
+ width: 16,
68
+ height: 16,
69
+ slot: 16
70
+ },
71
+ magic: {
72
+ width: 14.0625,
73
+ height: 15.5625,
74
+ slot: 18
75
+ },
76
+ select: {
77
+ width: 14.6298,
78
+ height: 16.065,
79
+ slot: 18
80
+ },
81
+ area: {
82
+ width: 16.125,
83
+ height: 16.125,
84
+ slot: 18
85
+ },
86
+ draw: {
87
+ width: 16.125,
88
+ height: 16.125,
89
+ slot: 18
90
+ },
91
+ close: {
92
+ width: 18,
93
+ height: 18,
94
+ slot: 18
95
+ },
96
+ reset: {
97
+ width: 16.35,
98
+ height: 16.35,
99
+ slot: 18
100
+ },
101
+ more: {
102
+ width: 16,
103
+ height: 16,
104
+ slot: 16
105
+ },
106
+ play: {
107
+ width: 12.381,
108
+ height: 13.2143,
109
+ slot: 20
110
+ },
111
+ pause: {
112
+ width: 14.1905,
113
+ height: 14.1905,
114
+ slot: 20
115
+ },
116
+ mute: {
117
+ width: 17.5239,
118
+ height: 14.1922,
119
+ slot: 20
120
+ },
121
+ volume: {
122
+ width: 17.5239,
123
+ height: 14.1922,
124
+ slot: 20
125
+ },
126
+ fullscreen: {
127
+ width: 20,
128
+ height: 20,
129
+ slot: 20
130
+ },
131
+ "placeholder-image": {
132
+ width: 20,
133
+ height: 20,
134
+ slot: 20
135
+ },
136
+ "placeholder-video": {
137
+ width: 17.9199,
138
+ height: 16.2506,
139
+ slot: 20
140
+ },
141
+ "placeholder-audio": {
142
+ width: 17.5017,
143
+ height: 17.4992,
144
+ slot: 20
145
+ },
146
+ "placeholder-script": {
147
+ width: 17.0834,
148
+ height: 17.0837,
149
+ slot: 20
150
+ },
151
+ export: {
152
+ width: 11.8667,
153
+ height: 13.2,
154
+ slot: 16
155
+ },
156
+ edit: {
157
+ width: 10.8791,
158
+ height: 12.0459,
159
+ slot: 14
160
+ },
161
+ "play-cover": {
162
+ width: 12.9167,
163
+ height: 13.7501,
164
+ slot: 20
165
+ },
166
+ "playback-play": {
167
+ width: 13.29564,
168
+ height: 14.1905,
169
+ slot: 20
170
+ },
171
+ "playback-play-large": {
172
+ width: 15.95477,
173
+ height: 17.0286,
174
+ slot: 24
175
+ },
176
+ "pause-large": {
177
+ width: 17.0286,
178
+ height: 17.0286,
179
+ slot: 24
180
+ },
181
+ "volume-large": {
182
+ width: 21.02868,
183
+ height: 17.03064,
184
+ slot: 24
185
+ },
186
+ "mute-large": {
187
+ width: 21.0286,
188
+ height: 17.0307,
189
+ slot: 24
190
+ },
191
+ "fullscreen-large": {
192
+ width: 24,
193
+ height: 24,
194
+ slot: 24
195
+ }
196
+ };
13
197
  function Icon({ name, size }) {
14
- return _jsx("span", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, style: size === void 0 ? void 0 : { "--vx-icon-size": `${size}px` } });
198
+ const geometry = iconGeometry[name];
199
+ const style = {
200
+ ...geometry && {
201
+ "--vx-icon-native-size": `${geometry.slot}px`,
202
+ "--vx-icon-width": `${geometry.width / geometry.slot * 100}%`,
203
+ "--vx-icon-height": `${geometry.height / geometry.slot * 100}%`
204
+ },
205
+ ...size === void 0 ? {} : { "--vx-icon-size": `${size}px` }
206
+ };
207
+ return _jsx("span", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, style });
15
208
  }
16
209
 
17
210
  // packages/ui-system/dist/button-variants.js
@@ -76,113 +269,105 @@ function TextInput({ label, value, onValueChange, size = "medium", ...props }) {
76
269
  }
77
270
 
78
271
  // packages/ui-system/dist/dialog.js
79
- import { jsx as _jsx5, jsxs as _jsxs4 } from "react/jsx-runtime";
80
- import { useEffect, useId as useId2, useLayoutEffect, useRef } from "react";
81
- function Dialog({ title, open, onOpenChange, children, actions, className }) {
272
+ import { jsx as _jsx5, jsxs as _jsxs4, Fragment as _Fragment } from "react/jsx-runtime";
273
+ import { useId as useId2, useLayoutEffect, useRef, useState } from "react";
274
+ import { createPortal } from "react-dom";
275
+
276
+ // packages/ui-system/dist/dialog-surface.js
277
+ function createDialogSurface(anchor) {
278
+ const source = anchor.ownerDocument;
279
+ let target;
280
+ try {
281
+ target = source.defaultView?.top?.document ?? source;
282
+ } catch {
283
+ return void 0;
284
+ }
285
+ if (target === source)
286
+ return void 0;
287
+ const host = target.createElement("div");
288
+ host.dataset.studioDialogSurface = "";
289
+ const shadow = host.attachShadow({ mode: "open" });
290
+ for (const original of source.querySelectorAll('link[rel="stylesheet"], style')) {
291
+ const clone = original.cloneNode(true);
292
+ if (original.tagName === "LINK")
293
+ clone.setAttribute("href", original.href);
294
+ shadow.append(clone);
295
+ }
296
+ const theme = anchor.closest("[data-vx-theme]");
297
+ const root = target.createElement("div");
298
+ root.dataset.vxTheme = theme?.dataset.vxTheme ?? "light";
299
+ root.className = theme?.className ?? "";
300
+ root.style.display = "contents";
301
+ const style = source.defaultView.getComputedStyle(anchor);
302
+ for (const name of style)
303
+ if (name.startsWith("--"))
304
+ root.style.setProperty(name, style.getPropertyValue(name));
305
+ shadow.append(root);
306
+ let container = root;
307
+ const ancestors = [];
308
+ for (let parent = anchor.parentElement; parent && parent !== theme; parent = parent.parentElement)
309
+ ancestors.unshift(parent);
310
+ for (const original of ancestors) {
311
+ const wrapper = target.createElement("div");
312
+ wrapper.className = original.className;
313
+ for (const { name, value } of original.attributes)
314
+ if (name.startsWith("data-"))
315
+ wrapper.setAttribute(name, value);
316
+ wrapper.style.display = "contents";
317
+ container.append(wrapper);
318
+ container = wrapper;
319
+ }
320
+ target.body.append(host);
321
+ return { root: container, dispose: () => host.remove() };
322
+ }
323
+
324
+ // packages/ui-system/dist/dialog.js
325
+ function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default" }) {
82
326
  const ref = useRef(null);
327
+ const anchor = useRef(null);
328
+ const [surface, setSurface] = useState();
83
329
  const heading = useId2();
84
- useEffect(() => {
85
- const dialog = ref.current;
86
- if (!dialog || dialog.open === open)
330
+ useLayoutEffect(() => {
331
+ if (!open || !anchor.current)
87
332
  return;
88
- if (open)
89
- dialog.showModal();
90
- else
91
- dialog.close();
333
+ const mounted = createDialogSurface(anchor.current);
334
+ const active = anchor.current.getRootNode().activeElement;
335
+ setSurface(mounted?.root ?? null);
336
+ return () => {
337
+ mounted?.dispose();
338
+ setSurface(void 0);
339
+ queueMicrotask(() => {
340
+ if (active?.isConnected)
341
+ active.focus();
342
+ });
343
+ };
92
344
  }, [open]);
93
345
  useLayoutEffect(() => {
94
- const dialog = ref.current;
346
+ const dialog2 = ref.current;
347
+ if (!open || surface === void 0 || !dialog2)
348
+ return;
349
+ dialog2.showModal();
95
350
  return () => {
96
- if (dialog?.open)
97
- dialog.close();
351
+ if (dialog2.open)
352
+ dialog2.close();
98
353
  };
99
- }, []);
100
- return _jsxs4("dialog", { ref, className: className ? `vx-dialog ${className}` : "vx-dialog", "aria-labelledby": heading, onCancel: (event) => {
354
+ }, [open, surface]);
355
+ const dialog = _jsxs4("dialog", { ref, className: className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, "aria-labelledby": heading, onCancel: (event) => {
101
356
  event.preventDefault();
102
357
  event.stopPropagation();
103
358
  onOpenChange(false);
104
359
  }, onClose: (event) => {
105
- if (open && !event.currentTarget.open)
360
+ if (open && event.currentTarget.isConnected && !event.currentTarget.open)
106
361
  onOpenChange(false);
107
362
  }, children: [_jsxs4("header", { children: [_jsx5("h2", { id: heading, children: title }), _jsx5(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) })] }), _jsx5("div", { className: "vx-dialog-body", children }), actions && _jsx5("footer", { children: actions })] });
363
+ return _jsxs4(_Fragment, { children: [_jsx5("span", { ref: anchor, hidden: true }), open && (surface ? createPortal(dialog, surface) : dialog)] });
108
364
  }
109
365
 
110
- // packages/studio-workbench/src/query-view.ts
111
- import { z } from "vivix-studio/sdk/shared";
112
- var pageSources = ["projects", "assets", "tasks"];
113
- var columnName = z.string().min(1).max(200).refine((value) => !/[\u0000-\u001f]/.test(value));
114
- var scalar = z.union([z.null(), z.string(), z.number().finite()]);
115
- var customViewSchema = z.object({
116
- source: z.enum(pageSources),
117
- projectId: z.uuid().optional(),
118
- name: z.string().trim().min(1).max(120),
119
- sql: z.string().trim().min(1).max(32e3),
120
- params: z.union([z.array(scalar), z.record(z.string(), scalar)]).default([]),
121
- columns: z.array(
122
- z.object({
123
- path: columnName,
124
- label: z.string().min(1).max(120).optional(),
125
- width: z.number().int().min(80).max(600).default(140),
126
- visible: z.boolean().default(true),
127
- format: z.enum(["text", "categories", "date", "json"]).default("text"),
128
- role: z.enum(["name", "preview", "state", "project"]).optional()
129
- }).strict()
130
- ).min(1).max(60).refine(
131
- (columns) => new Set(columns.map((c) => c.path)).size === columns.length,
132
- "Column names must be unique."
133
- ),
134
- identity: z.object({
135
- row: columnName.default("rowId"),
136
- project: columnName.default("projectId"),
137
- ref: columnName.default("ref"),
138
- outputs: columnName.default("outputRefs")
139
- }).strict().default({ row: "rowId", project: "projectId", ref: "ref", outputs: "outputRefs" })
140
- }).strict();
141
- var column = (path, label, width = 140, extra = {}) => ({ path, label, width, visible: true, format: "text", ...extra });
142
- function defaultSql(source, favorites = false) {
143
- if (source === "projects")
144
- return "SELECT * FROM studio_projects ORDER BY createdAt DESC, rowId ASC";
145
- const table = favorites ? "studio_asset_versions" : `studio_${source}`;
146
- return `SELECT a.*, p.name AS projectName, p.available AS projectAvailable FROM ${table} AS a LEFT JOIN studio_projects AS p ON p.projectId = a.projectId${favorites ? " WHERE a.favorite = 1" : ""} ORDER BY a.createdAt DESC, a.rowId ASC`;
147
- }
148
- function defaultView(source) {
149
- const columns = source === "projects" ? [
150
- column("previewUrl", "Preview", 120, { role: "preview" }),
151
- column("name", "Project title", 260, { role: "name" }),
152
- column("assetCount", "Assets", 120),
153
- column("available", "Available", 120),
154
- column("createdAt", "Created Time", 160, { format: "date" })
155
- ] : source === "assets" ? [
156
- column("previewUrl", "Preview", 120, { role: "preview" }),
157
- column("name", "Asset", 240, { role: "name" }),
158
- column("kind", "Format", 100),
159
- column("prompt", "Prompt", 280),
160
- column("projectName", "Project", 180, { role: "project" }),
161
- column("modelId", "Model", 160),
162
- column("createdAt", "Created Time", 160, { format: "date" }),
163
- column("purpose", "Purpose", 140, { visible: false })
164
- ] : [
165
- column("previewUrl", "Preview", 120, { role: "preview" }),
166
- column("name", "Task", 260, { role: "name" }),
167
- column("state", "Status", 180, { role: "state" }),
168
- column("costLabel", "Actual cost", 180),
169
- column("kind", "Format", 100),
170
- column("prompt", "Prompt", 280),
171
- column("projectName", "Project", 200, { role: "project" }),
172
- column("modelId", "Model", 160),
173
- column("createdAt", "Created Time", 160, { format: "date" })
174
- ];
175
- return {
176
- id: `default:${source}`,
177
- revision: 0,
178
- view: customViewSchema.parse({
179
- source,
180
- name: "All",
181
- sql: defaultSql(source),
182
- columns
183
- })
184
- };
185
- }
366
+ // packages/dashboard-projects/src/client.tsx
367
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
368
+ var Config = z.object({ studioInstance: z.string().min(1).nullable().default(null) });
369
+ var dependencies = (config) => config.studioInstance ? [config.studioInstance] : [];
370
+ var projectsSql = "SELECT * FROM studio_projects ORDER BY createdAt DESC, rowId ASC";
186
371
  function decodeRef(value) {
187
372
  let item = value;
188
373
  if (typeof item === "string") {
@@ -202,230 +387,172 @@ function decodeRef(value) {
202
387
  versionId: ref.versionId
203
388
  } : null;
204
389
  }
205
- function rowRef(row, view) {
206
- return decodeRef(row[view.identity.ref]);
207
- }
208
-
209
- // packages/studio-workbench/src/text-preview.ts
210
- async function readTextPreview(response, signal, maxBytes = 128 * 1024) {
211
- if (!response.ok || !response.body) throw Error("The text preview could not be loaded.");
212
- const reader = response.body.getReader();
213
- const decoder = new TextDecoder();
214
- let text = "", used = 0, truncated = false;
215
- const cancel = () => {
216
- void reader.cancel(signal.reason).catch(() => void 0);
217
- };
218
- signal.addEventListener("abort", cancel, { once: true });
219
- try {
220
- while (true) {
221
- signal.throwIfAborted();
222
- const chunk = await reader.read();
223
- signal.throwIfAborted();
224
- if (chunk.done) break;
225
- const remaining = maxBytes - used;
226
- text += decoder.decode(chunk.value.subarray(0, remaining), { stream: true });
227
- used += Math.min(remaining, chunk.value.byteLength);
228
- if (chunk.value.byteLength > remaining) {
229
- truncated = true;
230
- break;
231
- }
232
- }
233
- text += decoder.decode();
234
- return { text, truncated };
235
- } finally {
236
- signal.removeEventListener("abort", cancel);
237
- await reader.cancel().catch(() => void 0);
238
- reader.releaseLock();
239
- }
240
- }
241
-
242
- // packages/studio-workbench/src/studio-glyph.tsx
243
- import "react";
244
- import { jsx } from "react/jsx-runtime";
245
- var paths = {
246
- projects: [
247
- "M6.66803 5.83333H10.0023M10.0023 5.83333H13.9617C15.7177 5.83333 16.5958 5.83333 17.2265 6.25466C17.4995 6.43706 17.734 6.67143 17.9164 6.94441C18.2448 7.43568 18.3173 8.07703 18.3333 9.16667M10.0023 5.83333L9.47426 4.7776C9.03683 3.90298 8.63709 3.0226 7.66768 2.65917C7.2431 2.5 6.75807 2.5 5.78802 2.5C4.27388 2.5 3.51681 2.5 2.94874 2.81693C2.54379 3.04285 2.20966 3.37689 1.98368 3.78172C1.66667 4.34964 1.66667 5.1065 1.66667 6.62023V9.16667C1.66667 13.095 1.66667 15.0592 2.88739 16.2796C4.10811 17.5 6.07283 17.5 10.0023 17.5",
248
- "M15 16.4773C16.4728 16.4773 17.6667 15.2562 17.6667 13.75C17.6667 12.2438 16.4728 11.0227 15 11.0227M15 16.4773C13.5272 16.4773 12.3333 15.2562 12.3333 13.75C12.3333 12.2438 13.5272 11.0227 15 11.0227M15 16.4773V17.5M15 11.0227V10M12.5761 12.2624L11.667 11.7045M18.3333 15.7955L17.4243 15.2376M17.4239 12.2624L18.333 11.7045M11.6667 15.7955L12.5757 15.2376"
249
- ],
250
- assets: [
251
- "M2.5 2.5H17.5C17.9602 2.5 18.3333 2.8731 18.3333 3.33333V5.83333C18.3333 6.29357 17.9602 6.66667 17.5 6.66667H2.5C2.03976 6.66667 1.66667 6.29357 1.66667 5.83333V3.33333C1.66667 2.8731 2.03976 2.5 2.5 2.5Z",
252
- "M3.33333 6.66667V15.8333C3.33333 16.2754 3.50893 16.6993 3.82149 17.0118C4.13405 17.3244 4.55797 17.5 5 17.5H15C15.442 17.5 15.866 17.3244 16.1785 17.0118C16.4911 16.6993 16.6667 16.2754 16.6667 15.8333V6.66667",
253
- "M8.33333 10H11.6667"
254
- ],
255
- tasks: [
256
- "M15.75 7.41667C15.75 8.58344 15.75 9.16683 15.5229 9.61248C15.3232 10.0045 15.0045 10.3232 14.6125 10.5229C14.1668 10.75 13.5834 10.75 12.4167 10.75H4.08333C2.91656 10.75 2.33317 10.75 1.88752 10.5229C1.49552 10.3232 1.17681 10.0045 0.977071 9.61248C0.750001 9.16683 0.750001 8.58344 0.750001 7.41667",
257
- "M3.25 7.41667H13.25M3.25 4.08333H13.25M3.25 0.75H13.25"
258
- ],
259
- panel: [
260
- "M2.08333 10C2.08333 6.26805 2.08333 4.40207 3.2427 3.2427C4.40207 2.08333 6.26805 2.08333 10 2.08333C13.7319 2.08333 15.5979 2.08333 16.7573 3.2427C17.9167 4.40207 17.9167 6.26805 17.9167 10C17.9167 13.7319 17.9167 15.5979 16.7573 16.7573C15.5979 17.9167 13.7319 17.9167 10 17.9167C6.26805 17.9167 4.40207 17.9167 3.2427 16.7573C2.08333 15.5979 2.08333 13.7319 2.08333 10Z",
261
- "M7.06381 6.69231L7.09951 13.3523"
262
- ],
263
- favorite: [
264
- "M0.600003 5.73835V11.2539C0.600003 12.7911 0.600003 13.5597 1.11523 13.8349C2.11298 14.3676 3.98454 12.5901 4.87334 12.0549C5.38881 11.7446 5.64654 11.5894 5.93334 11.5894C6.22013 11.5894 6.47787 11.7446 6.99333 12.0549C7.88214 12.5901 9.75369 14.3676 10.7514 13.8349C11.2667 13.5597 11.2667 12.7911 11.2667 11.2539V5.73835C11.2667 3.31611 11.2667 2.10499 10.4856 1.3525C9.70457 0.600001 8.44749 0.600001 5.93334 0.600001C3.41918 0.600001 2.1621 0.600001 1.38105 1.3525C0.600003 2.10499 0.600003 3.31611 0.600003 5.73835Z"
265
- ]
266
- };
267
- function StudioGlyph({ name }) {
268
- return /* @__PURE__ */ jsx(
269
- "svg",
270
- {
271
- className: "studio-glyph",
272
- "aria-hidden": "true",
273
- width: "20",
274
- height: "20",
275
- viewBox: name === "tasks" ? "0 0 16.5 11.5" : name === "favorite" ? "0 0 11.8667 14.5333" : "0 0 20 20",
276
- fill: "none",
277
- stroke: "currentColor",
278
- strokeWidth: name === "favorite" ? 1.2 : 1.5,
279
- strokeLinecap: "round",
280
- strokeLinejoin: "round",
281
- children: paths[name].map((d, index) => /* @__PURE__ */ jsx("path", { d }, index))
282
- }
283
- );
284
- }
285
-
286
- // packages/studio-workbench/src/dashboard-card.tsx
287
- import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
288
- var Config = z2.object({ studioInstance: z2.string().min(1).nullable().default(null) });
289
- var dashboardAssetsSql = `SELECT a.* FROM studio_assets AS a
290
- ORDER BY (json_extract(a.metadata, '$.homeFeatured') IS NOT NULL) DESC,
291
- ROW_NUMBER() OVER (
292
- PARTITION BY a.projectId, a.kind, a.purpose ORDER BY a.createdAt DESC, a.rowId ASC
293
- ), a.createdAt DESC, a.rowId ASC`;
294
- function featuredRole(row) {
295
- const metadata = row?.metadata;
296
- return metadata && typeof metadata === "object" && "homeFeatured" in metadata ? metadata.homeFeatured : void 0;
297
- }
298
- function sampleAssets(items) {
299
- const chosen = /* @__PURE__ */ new Set();
300
- for (const [role, kind, purpose] of [
301
- ["character", "image", "reference"],
302
- ["video", "video", "shot"],
303
- ["scene", "image", "shot"],
304
- ["script", "text", "script"],
305
- ["audio", "audio", "voice"]
306
- ]) {
307
- const asset = items.find((row) => featuredRole(row) === role && row.kind === kind) ?? items.find((row) => row.kind === kind && row.purpose === purpose && !chosen.has(row));
308
- if (asset) chosen.add(asset);
309
- }
310
- for (const row of items) if (row.kind !== "text" || row.purpose === "script") chosen.add(row);
311
- return [...chosen].slice(0, 5);
312
- }
313
390
  var projectTypes = [
314
391
  {
315
392
  value: "short-drama",
316
393
  label: "Short Drama",
317
394
  preset: "@vivix-labs/short-drama-workbench:short-drama"
318
395
  },
319
- { value: "ads", label: "Product Ad", preset: "@vivix-labs/studio-workbench:ads" },
320
- { value: "table", label: "Other", preset: "@vivix-labs/studio-workbench:table" }
396
+ { value: "ads", label: "Product Ad", preset: "@vivix-labs/ads-workbench:ads" },
397
+ { value: "table", label: "Others", preset: "@vivix-labs/studio-workbench:table" }
321
398
  ];
322
- function NewProjectDialog({ close }) {
323
- const [type, setType] = React2.useState(projectTypes[0].value);
324
- const [name, setName] = React2.useState("");
325
- const [status, setStatus] = React2.useState("");
399
+ function NewProjectDialog({
400
+ client,
401
+ close,
402
+ onCreated
403
+ }) {
404
+ const [type, setType] = React.useState(projectTypes[0].value);
405
+ const [name, setName] = React.useState("");
406
+ const [status, setStatus] = React.useState("");
407
+ const [presets, setPresets] = React.useState();
408
+ const [busy, setBusy] = React.useState(false);
409
+ const request = React.useRef(void 0);
410
+ React.useEffect(() => {
411
+ let active = true;
412
+ if (!client.projects?.presets || !client.projects.create) {
413
+ setStatus("Update Studio CLI to create projects from Home.");
414
+ return;
415
+ }
416
+ void client.projects.presets().then(
417
+ (items) => {
418
+ if (active) setPresets(items);
419
+ },
420
+ (error) => {
421
+ if (active) setStatus(error.message);
422
+ }
423
+ );
424
+ return () => {
425
+ active = false;
426
+ };
427
+ }, [client]);
326
428
  const selection = projectTypes.find((item) => item.value === type);
327
429
  const placeholder = type === "table" ? "Untitled Project" : "Untitled " + selection.label;
328
- const prompt = [
329
- `Create a local Vivix Studio project named ${JSON.stringify(name.trim() || placeholder)} from the installed ${selection.preset} preset.`,
330
- "Use the profile of my current Studio workbench. Run vivix-studio preset list --json and check vivix-studio project init --help. Create it with project init --preset in a new empty local folder, then open the project in Studio."
331
- ].join("\n");
332
- return /* @__PURE__ */ jsx2(
430
+ const [packageName, presetId] = selection.preset.split(":");
431
+ const preset = presets?.find(
432
+ (item) => item.spec.startsWith(packageName + "@") && item.spec.endsWith(":" + presetId)
433
+ );
434
+ async function create() {
435
+ if (!preset || !client.projects?.create || busy) return;
436
+ const input = {
437
+ name: name.trim() || placeholder,
438
+ preset: preset.spec,
439
+ trust: true,
440
+ allowAccess: [...preset.requiredAccess]
441
+ };
442
+ const intent = JSON.stringify(input);
443
+ if (request.current?.intent !== intent) request.current = { intent, id: crypto.randomUUID() };
444
+ setBusy(true);
445
+ setStatus("");
446
+ try {
447
+ const project = await client.projects.create({ ...input, requestId: request.current.id });
448
+ onCreated(project);
449
+ close();
450
+ } catch (error) {
451
+ setStatus(error instanceof Error ? error.message : String(error));
452
+ } finally {
453
+ setBusy(false);
454
+ }
455
+ }
456
+ return /* @__PURE__ */ jsx(
333
457
  Dialog,
334
458
  {
335
- title: "Create Project",
459
+ title: "Create Projects",
336
460
  open: true,
461
+ variant: "create-project",
337
462
  className: "studio-home-dialog",
338
- onOpenChange: (open) => !open && close(),
463
+ onOpenChange: (open) => !open && !busy && close(),
339
464
  actions: /* @__PURE__ */ jsxs(Fragment, { children: [
340
- /* @__PURE__ */ jsx2(Button, { label: "Cancel", variant: "text-tonal-sm", onClick: close }),
341
- /* @__PURE__ */ jsx2(
465
+ /* @__PURE__ */ jsx(
342
466
  Button,
343
467
  {
344
- label: "Copy Prompt",
345
- onClick: async () => {
346
- try {
347
- await navigator.clipboard.writeText(prompt);
348
- setStatus("Prompt copied. Paste it into your Agent chat.");
349
- } catch {
350
- setStatus("Select and copy the prompt below.");
351
- }
352
- }
468
+ label: "Cancel",
469
+ variant: "text-tonal-lg",
470
+ width: "hug",
471
+ disabled: busy,
472
+ onClick: close
473
+ }
474
+ ),
475
+ /* @__PURE__ */ jsx(
476
+ Button,
477
+ {
478
+ label: busy ? "Creating\u2026" : "Create Project",
479
+ variant: "text-filled-lg",
480
+ width: "hug",
481
+ disabled: busy || !preset,
482
+ onClick: () => void create()
353
483
  }
354
484
  )
355
485
  ] }),
356
486
  children: /* @__PURE__ */ jsxs("div", { className: "studio-home-create-form", children: [
357
- /* @__PURE__ */ jsx2("strong", { children: "Project type" }),
358
- /* @__PURE__ */ jsx2(
359
- SegmentedControl,
360
- {
361
- label: "Project type",
362
- value: type,
363
- items: projectTypes,
364
- onValueChange: setType
365
- }
366
- ),
367
- /* @__PURE__ */ jsx2(
487
+ /* @__PURE__ */ jsxs("div", { className: "studio-home-create-field", children: [
488
+ /* @__PURE__ */ jsx("span", { children: "Project type" }),
489
+ /* @__PURE__ */ jsx(
490
+ SegmentedControl,
491
+ {
492
+ label: "Project type",
493
+ size: "large",
494
+ width: "full",
495
+ value: type,
496
+ items: projectTypes.map((item) => ({ ...item, disabled: busy })),
497
+ onValueChange: setType
498
+ }
499
+ )
500
+ ] }),
501
+ /* @__PURE__ */ jsx(
368
502
  TextInput,
369
503
  {
370
504
  label: "Project name",
505
+ size: "large",
371
506
  value: name,
372
507
  onValueChange: setName,
373
508
  maxLength: 100,
374
- placeholder
509
+ disabled: busy,
510
+ placeholder: "Enter project name"
375
511
  }
376
512
  ),
377
- /* @__PURE__ */ jsx2("p", { children: "Copy a prompt for your agent to create and open the project." }),
378
- status && /* @__PURE__ */ jsx2("p", { role: "status", children: status }),
379
- status.startsWith("Select") && /* @__PURE__ */ jsx2("textarea", { "aria-label": "Project prompt", readOnly: true, value: prompt })
513
+ presets && !preset && /* @__PURE__ */ jsxs("p", { role: "alert", children: [
514
+ "Install the ",
515
+ selection.label,
516
+ " preset to create this project."
517
+ ] }),
518
+ status && /* @__PURE__ */ jsx("p", { role: "alert", children: status })
380
519
  ] })
381
520
  }
382
521
  );
383
522
  }
384
- function Cover({ row, kind }) {
385
- const [failed, setFailed] = React2.useState(false);
523
+ function ProjectCover({ row }) {
524
+ const [failed, setFailed] = React.useState(false);
386
525
  const source = typeof row?.previewUrl === "string" && !failed ? row.previewUrl : void 0;
387
- const script = kind === "assets" && row?.kind === "text" && row?.purpose === "script";
388
- const [excerpt, setExcerpt] = React2.useState("");
389
- React2.useEffect(() => {
390
- if (!script || !source) return;
391
- const controller = new AbortController();
392
- if (new URL(source, window.location.origin).origin !== window.location.origin) return;
393
- void fetch(source, { signal: controller.signal }).then((response) => readTextPreview(response, controller.signal, 1024)).then(({ text }) => setExcerpt(text.trim())).catch(() => void 0);
394
- return () => controller.abort();
395
- }, [script, source]);
396
- return /* @__PURE__ */ jsx2("span", { className: "studio-home-cover", "aria-hidden": "true", children: source && (kind === "projects" ? row?.previewKind : row?.kind) === "video" ? /* @__PURE__ */ jsx2("video", { src: source, muted: true, playsInline: true, preload: "auto", onError: () => setFailed(true) }) : source && (kind === "projects" || row?.kind === "image") ? /* @__PURE__ */ jsx2("img", { src: source, alt: "", loading: "lazy", onError: () => setFailed(true) }) : excerpt ? /* @__PURE__ */ jsx2("span", { className: "studio-home-script-preview", children: excerpt }) : row?.kind === "audio" ? /* @__PURE__ */ jsx2(Icon, { name: "sound-file", size: 32 }) : /* @__PURE__ */ jsx2(StudioGlyph, { name: kind }) });
526
+ return /* @__PURE__ */ jsx("span", { className: "studio-home-cover", "aria-hidden": "true", children: source && row?.previewKind === "video" ? /* @__PURE__ */ jsx("video", { src: source, muted: true, playsInline: true, preload: "auto", onError: () => setFailed(true) }) : source ? /* @__PURE__ */ jsx("img", { src: source, alt: "", loading: "lazy", onError: () => setFailed(true) }) : null });
397
527
  }
398
- function DataCard({
528
+ function ProjectsCard({
399
529
  client,
400
530
  projects,
401
531
  ready,
402
- source,
403
- title,
404
532
  openProject,
405
533
  openProjects,
406
- openAssets
534
+ onProjectCreated
407
535
  }) {
408
- const [state, setState] = React2.useState();
409
- const [creating, setCreating] = React2.useState(false);
536
+ const [rows, setRows] = React.useState();
537
+ const [creating, setCreating] = React.useState(false);
410
538
  const catalogKey = JSON.stringify(projects);
411
- const view = React2.useMemo(() => defaultView(source).view, [source]);
412
- React2.useEffect(() => {
539
+ React.useEffect(() => {
413
540
  if (!ready || !client.config.studioInstance) return;
414
541
  let active = true;
415
542
  void client.invoke(
416
543
  { instanceId: client.config.studioInstance, operationId: "global.query" },
417
544
  {
418
- source,
419
- sql: source === "assets" ? dashboardAssetsSql : view.sql,
420
- params: view.params,
545
+ source: "projects",
546
+ sql: projectsSql,
547
+ params: [],
421
548
  catalog: JSON.parse(catalogKey),
422
- limit: source === "assets" ? 24 : 5,
549
+ limit: 5,
423
550
  timeoutMs: 8e3,
424
551
  offset: 0
425
552
  }
426
553
  ).then(
427
554
  async ({ items }) => {
428
- const rows2 = source === "projects" ? await Promise.all(
555
+ const next = await Promise.all(
429
556
  items.map(async (row) => {
430
557
  const ref = decodeRef(row.previewRef ?? row.coverRef);
431
558
  if (!ref || !row.available) return row;
@@ -443,20 +570,20 @@ function DataCard({
443
570
  return row;
444
571
  }
445
572
  })
446
- ) : sampleAssets(items);
447
- if (active) setState({ rows: rows2 });
573
+ );
574
+ if (active) setRows(next);
448
575
  },
449
576
  () => {
450
- if (active) setState({ rows: [], error: true });
577
+ if (active) setRows([]);
451
578
  }
452
579
  );
453
580
  return () => {
454
581
  active = false;
455
582
  };
456
- }, [client, ready, catalogKey, source, view]);
457
- const rows = state?.rows ?? [];
458
- const entries = source === "projects" ? (rows.length ? rows.map((row) => projects.find(({ id }) => id === row.projectId)).filter((entry) => !!entry) : projects.slice(0, 5)).map((project) => {
459
- const row = rows.find((entry) => entry.projectId === project.id);
583
+ }, [client, ready, catalogKey]);
584
+ const list = rows ?? [];
585
+ const entries = (list.length ? list.map((row) => projects.find(({ id }) => id === row.projectId)).filter((entry) => !!entry) : projects.slice(0, 5)).map((project) => {
586
+ const row = list.find((entry) => entry.projectId === project.id);
460
587
  return {
461
588
  key: project.id,
462
589
  row,
@@ -465,42 +592,32 @@ function DataCard({
465
592
  enabled: project.available,
466
593
  open: () => openProject(project.id)
467
594
  };
468
- }) : rows.map((row) => {
469
- const ref = rowRef(row, view);
470
- return {
471
- key: String(row.rowId),
472
- row,
473
- name: String(row.name ?? "Asset"),
474
- note: featuredRole(row) === "character" ? "Character \xB7 Turnaround" : row.purpose === "script" ? "Script" : String(row.kind ?? "").replace(/^./, (first) => first.toUpperCase()),
475
- enabled: !!ref,
476
- open: () => ref && openAssets(ref)
477
- };
478
595
  });
479
- return /* @__PURE__ */ jsxs("section", { className: "studio-home-panel", "aria-label": title, children: [
596
+ return /* @__PURE__ */ jsxs("section", { className: "studio-home-panel", "aria-label": "Project List", children: [
480
597
  /* @__PURE__ */ jsxs("header", { children: [
481
- /* @__PURE__ */ jsx2("h2", { children: title }),
482
- /* @__PURE__ */ jsx2(
598
+ /* @__PURE__ */ jsx("h2", { children: "Project List" }),
599
+ /* @__PURE__ */ jsx(
483
600
  Button,
484
601
  {
485
602
  label: "View all",
486
- "aria-label": "View all " + title.toLowerCase(),
603
+ "aria-label": "View all project list",
487
604
  className: "studio-home-view-all",
488
605
  variant: "text-tonal-sm",
489
- onClick: source === "projects" ? openProjects : () => openAssets()
606
+ onClick: openProjects
490
607
  }
491
608
  )
492
609
  ] }),
493
- entries.length || source === "projects" ? /* @__PURE__ */ jsxs("div", { className: "studio-home-grid", children: [
494
- source === "projects" && /* @__PURE__ */ jsxs(
610
+ /* @__PURE__ */ jsxs("div", { className: "studio-home-grid", children: [
611
+ /* @__PURE__ */ jsxs(
495
612
  "button",
496
613
  {
497
614
  type: "button",
498
615
  className: "studio-home-tile studio-home-create",
499
616
  onClick: () => setCreating(true),
500
617
  children: [
501
- /* @__PURE__ */ jsx2("span", { className: "studio-home-cover", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(Icon, { name: "add" }) }) }),
502
- /* @__PURE__ */ jsx2("strong", { children: "Create Project" }),
503
- /* @__PURE__ */ jsx2("small", { children: "Create a local project" })
618
+ /* @__PURE__ */ jsx("span", { className: "studio-home-cover", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Icon, { name: "add" }) }) }),
619
+ /* @__PURE__ */ jsx("strong", { children: "Create Project" }),
620
+ /* @__PURE__ */ jsx("small", { children: "Create a local project" })
504
621
  ]
505
622
  }
506
623
  ),
@@ -512,27 +629,33 @@ function DataCard({
512
629
  onClick: open,
513
630
  disabled: !enabled,
514
631
  children: [
515
- /* @__PURE__ */ jsx2(Cover, { row, kind: source }, String(row?.previewUrl ?? "")),
516
- /* @__PURE__ */ jsx2("strong", { title: name, children: name }),
517
- note && /* @__PURE__ */ jsx2("small", { children: note })
632
+ /* @__PURE__ */ jsx(ProjectCover, { row }, String(row?.previewUrl ?? "")),
633
+ /* @__PURE__ */ jsx("strong", { title: name, children: name }),
634
+ note && /* @__PURE__ */ jsx("small", { children: note })
518
635
  ]
519
636
  },
520
637
  key
521
638
  ))
522
- ] }) : /* @__PURE__ */ jsx2("p", { className: "studio-home-empty", role: "status", children: !client.config.studioInstance || state?.error ? `${title} unavailable.` : !state ? "Loading\u2026" : "No assets yet." }),
523
- creating && /* @__PURE__ */ jsx2(NewProjectDialog, { close: () => setCreating(false) })
639
+ ] }),
640
+ creating && /* @__PURE__ */ jsx(
641
+ NewProjectDialog,
642
+ {
643
+ client,
644
+ close: () => setCreating(false),
645
+ onCreated: (project) => {
646
+ if (onProjectCreated) onProjectCreated(project);
647
+ else openProject(project.id);
648
+ }
649
+ }
650
+ )
524
651
  ] });
525
652
  }
526
-
527
- // packages/dashboard-projects/src/client.tsx
528
- import { jsx as jsx3 } from "react/jsx-runtime";
529
- var dependencies = (config) => config.studioInstance ? [config.studioInstance] : [];
530
653
  function activate(client) {
531
654
  client.registerUI({
532
655
  id: "projects",
533
656
  title: "Project List",
534
657
  kind: "component",
535
- component: (props) => /* @__PURE__ */ jsx3(DataCard, { ...props, client, source: "projects", title: "Project List" })
658
+ component: (props) => /* @__PURE__ */ jsx(ProjectsCard, { ...props, client })
536
659
  });
537
660
  }
538
661
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vivix-labs/dashboard-projects",
3
- "version": "1.0.0-beta",
3
+ "version": "1.0.0-beta.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -15,6 +15,7 @@
15
15
  "./client": "./dist/client.js"
16
16
  },
17
17
  "peerDependencies": {
18
+ "vivix-studio": ">=2.2.0",
18
19
  "react": "^19.0.0",
19
20
  "react-dom": "^19.0.0"
20
21
  }
Binary file
File without changes