@krak-stack/assets 0.1.6 → 0.1.7
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.
- package/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/dist/components/asset-input/html.d.ts +4 -2
- package/dist/components/asset-input/html.js +301 -276
- package/dist/components/asset-input/index.d.ts +51 -0
- package/dist/components/asset-input/react.d.ts +1 -1
- package/dist/components/asset-input/react.js +61 -33
- package/dist/components/asset-input/schema.d.ts +15 -0
- package/dist/components/asset-table/html.js +903 -843
- package/dist/components/asset-table/index.d.ts +99 -0
- package/dist/components/asset-table/react.d.ts +3 -2
- package/dist/components/asset-table/react.js +191 -115
- package/dist/services/assets/library.d.ts +55 -0
- package/dist/services/assets/library.d.ts.map +1 -1
- package/dist/services/assets/library.js +37 -16
- package/dist/services/assets/library.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
// ../assets/src/components/asset-table/react.tsx
|
|
2
2
|
import { Download as Download2, Link2, RefreshCw as RefreshCw2, Trash2 as Trash22 } from "lucide-react";
|
|
3
|
-
import { Component as
|
|
3
|
+
import { Component as Component15 } from "effect/ui";
|
|
4
4
|
import { Layer } from "effect";
|
|
5
|
-
import {
|
|
5
|
+
import { AsyncResult as AsyncResult4 } from "effect/reactivity";
|
|
6
|
+
import { useMemo as useMemo5 } from "react";
|
|
6
7
|
|
|
7
8
|
// ../assets/src/components/asset-input/react.tsx
|
|
8
9
|
import { FolderOpen, X as X4 } from "lucide-react";
|
|
10
|
+
import { AsyncResult as AsyncResult2 } from "effect/reactivity";
|
|
11
|
+
import { Component as Component7 } from "effect/ui";
|
|
9
12
|
import {
|
|
10
13
|
useId as useId3,
|
|
11
14
|
useLayoutEffect as useLayoutEffect2,
|
|
15
|
+
useMemo as useMemo2,
|
|
12
16
|
useRef as useRef3,
|
|
13
17
|
useState as useState4
|
|
14
18
|
} from "react";
|
|
@@ -1398,7 +1402,7 @@ import {
|
|
|
1398
1402
|
DialogTitle,
|
|
1399
1403
|
DialogTrigger
|
|
1400
1404
|
} from "@/components/ui/dialog";
|
|
1401
|
-
import {
|
|
1405
|
+
import { React } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
1402
1406
|
|
|
1403
1407
|
// ../assets/src/components/asset-input/index.ts
|
|
1404
1408
|
import { Effect as Effect2, Queue, Redacted as Redacted2, Schema as Schema10, Stream } from "effect";
|
|
@@ -1407,6 +1411,7 @@ import { Command, Component as Component5, UiSchema as UiSchema5 } from "effect/
|
|
|
1407
1411
|
// ../assets/src/services/assets/library.ts
|
|
1408
1412
|
import {
|
|
1409
1413
|
Context,
|
|
1414
|
+
Effect,
|
|
1410
1415
|
Schema as Schema8
|
|
1411
1416
|
} from "effect";
|
|
1412
1417
|
import { AsyncResult } from "effect/reactivity";
|
|
@@ -1454,7 +1459,19 @@ class AssetList extends Query.Service()("@krak-stack/assets/AssetList", {
|
|
|
1454
1459
|
staleTime: "30 seconds"
|
|
1455
1460
|
}) {
|
|
1456
1461
|
}
|
|
1462
|
+
var disabledAssetListLayer = AssetList.toLayer(() => Effect.fail("unavailable"));
|
|
1457
1463
|
var assetListArgs = (scopeKey, permissions, query = {}) => permissions.includes("list") ? { ...query, scopeKey, showFiles: permissions.includes("read") } : undefined;
|
|
1464
|
+
var assetLibraryQuery = (getAccess) => ({
|
|
1465
|
+
query: AssetList,
|
|
1466
|
+
dropPrevious: true,
|
|
1467
|
+
args: ({ props }) => {
|
|
1468
|
+
const access = getAccess(props);
|
|
1469
|
+
return access && assetListArgs(access.scopeKey, access.permissions);
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
var AssetLibraryPropsSchema = Schema8.Struct({
|
|
1473
|
+
access: AssetLibraryAccessSchema
|
|
1474
|
+
}).annotate({ identifier: "AssetLibraryModelProps" });
|
|
1458
1475
|
var AssetLibrarySnapshot = Schema8.Struct({
|
|
1459
1476
|
data: Schema8.NullOr(AssetListSchema),
|
|
1460
1477
|
status: Schema8.Literals(["idle", "loading", "ready", "failed"])
|
|
@@ -1463,25 +1480,33 @@ var AssetLibraryMessage = UiSchema4.TaggedEnum({
|
|
|
1463
1480
|
LibraryChanged: { library: AssetLibrarySnapshot }
|
|
1464
1481
|
}).annotate({ identifier: "AssetLibraryMessage" });
|
|
1465
1482
|
var emptyAssetLibrary = { data: null, status: "idle" };
|
|
1466
|
-
var
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1483
|
+
var assetLibrarySnapshot = (result) => AsyncResult.isSuccess(result) ? { data: result.value, status: "ready" } : {
|
|
1484
|
+
data: null,
|
|
1485
|
+
status: AsyncResult.isFailure(result) ? "failed" : "loading"
|
|
1486
|
+
};
|
|
1487
|
+
var libraryQuery = (result) => AssetLibraryMessage.LibraryChanged({ library: assetLibrarySnapshot(result) });
|
|
1488
|
+
var assetLibraryOptions = {
|
|
1489
|
+
name: "AssetLibraryView",
|
|
1490
|
+
props: AssetLibraryPropsSchema,
|
|
1491
|
+
model: Schema8.Null,
|
|
1492
|
+
message: Schema8.Never,
|
|
1493
|
+
restore: false,
|
|
1494
|
+
queries: {
|
|
1495
|
+
library: assetLibraryQuery((props) => props.access)
|
|
1470
1496
|
}
|
|
1471
|
-
}
|
|
1497
|
+
};
|
|
1498
|
+
var assetLibraryBehaviours = {
|
|
1499
|
+
init: () => null,
|
|
1500
|
+
update: () => null
|
|
1501
|
+
};
|
|
1472
1502
|
var options = {
|
|
1503
|
+
...assetLibraryOptions,
|
|
1473
1504
|
name: "AssetLibraryModel",
|
|
1474
|
-
props: Schema8.Struct({ access: AssetLibraryAccessSchema }).annotate({
|
|
1475
|
-
identifier: "AssetLibraryModelProps"
|
|
1476
|
-
}),
|
|
1477
1505
|
model: AssetLibrarySnapshot,
|
|
1478
1506
|
message: AssetLibraryMessage,
|
|
1479
|
-
restore: false,
|
|
1480
1507
|
queries: {
|
|
1481
1508
|
library: {
|
|
1482
|
-
|
|
1483
|
-
dropPrevious: true,
|
|
1484
|
-
args: ({ props }) => assetListArgs(props.access.scopeKey, props.access.permissions),
|
|
1509
|
+
...assetLibraryOptions.queries.library,
|
|
1485
1510
|
onChange: libraryQuery
|
|
1486
1511
|
}
|
|
1487
1512
|
}
|
|
@@ -1560,6 +1585,7 @@ var AssetInputPropsSchema = Schema9.Struct({
|
|
|
1560
1585
|
}))),
|
|
1561
1586
|
uploader: Schema9.optionalKey(AssetUploadPropsSchema)
|
|
1562
1587
|
}).annotate({ identifier: "AssetInputProps" });
|
|
1588
|
+
var AssetInputPickerPropsSchema = AssetInputPropsSchema.mapFields(({ assets, access, value }) => ({ assets, access, value })).annotate({ identifier: "AssetInputPickerProps" });
|
|
1563
1589
|
var AssetUploadJobSchema = Schema9.Struct({
|
|
1564
1590
|
id: Schema9.Int,
|
|
1565
1591
|
file: Schema9.Redacted(Schema9.File),
|
|
@@ -1576,6 +1602,20 @@ var AssetUploadJobSchema = Schema9.Struct({
|
|
|
1576
1602
|
}).annotate({ identifier: "AssetUploadJob" });
|
|
1577
1603
|
|
|
1578
1604
|
// ../assets/src/components/asset-input/index.ts
|
|
1605
|
+
var assetInputPickerOptions = {
|
|
1606
|
+
name: "AssetInputPicker",
|
|
1607
|
+
props: AssetInputPickerPropsSchema,
|
|
1608
|
+
model: Schema10.Null,
|
|
1609
|
+
message: Schema10.Never,
|
|
1610
|
+
restore: false,
|
|
1611
|
+
queries: {
|
|
1612
|
+
library: assetLibraryQuery((props) => props.assets === undefined && props.value !== undefined ? props.access : undefined)
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
var assetInputPickerBehaviours = {
|
|
1616
|
+
init: () => null,
|
|
1617
|
+
update: () => null
|
|
1618
|
+
};
|
|
1579
1619
|
var inputCopy = {
|
|
1580
1620
|
en: {
|
|
1581
1621
|
placeholder: "Choose asset",
|
|
@@ -1891,7 +1931,7 @@ var UploadSession = ({
|
|
|
1891
1931
|
const {
|
|
1892
1932
|
model: { files, jobs, open },
|
|
1893
1933
|
send
|
|
1894
|
-
} =
|
|
1934
|
+
} = React.useView(binding.component, {
|
|
1895
1935
|
label: title,
|
|
1896
1936
|
multiple,
|
|
1897
1937
|
...kind === undefined ? {} : { kind },
|
|
@@ -2060,26 +2100,12 @@ var assetImage = (asset) => {
|
|
|
2060
2100
|
return { imageSrc };
|
|
2061
2101
|
};
|
|
2062
2102
|
|
|
2063
|
-
// ../assets/src/services/assets/use-library.ts
|
|
2064
|
-
import { useMemo as useMemo2 } from "react";
|
|
2065
|
-
import { Effect as Effect3 } from "effect";
|
|
2066
|
-
import { Component as Component7 } from "effect/ui";
|
|
2067
|
-
import { useModel as useModel2 } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
2068
|
-
var disabled = AssetLibraryModel.pipe(Component7.provide(AssetList.toLayer(() => Effect3.fail("unavailable"))));
|
|
2069
|
-
var noAccess = { scopeKey: "disabled", permissions: [] };
|
|
2070
|
-
var useAssetLibrary = (runtime, access) => {
|
|
2071
|
-
const scopeKey = access?.permissions.includes("list") ? access.scopeKey : undefined;
|
|
2072
|
-
const showFiles = access?.permissions.includes("read") ?? false;
|
|
2073
|
-
const model = useMemo2(() => runtime && scopeKey ? AssetLibraryModel.pipe(Component7.provide(runtime.layer)) : disabled, [runtime, scopeKey, showFiles]);
|
|
2074
|
-
const { model: snapshot } = useModel2(model, {
|
|
2075
|
-
access: runtime && scopeKey && access ? access : noAccess
|
|
2076
|
-
});
|
|
2077
|
-
return runtime && scopeKey ? snapshot : emptyAssetLibrary;
|
|
2078
|
-
};
|
|
2079
|
-
|
|
2080
2103
|
// ../assets/src/components/asset-input/react.tsx
|
|
2104
|
+
import { React as React2 } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
2081
2105
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2082
2106
|
"use client";
|
|
2107
|
+
var pickerModel = React2.component(assetInputPickerOptions).make(assetInputPickerBehaviours);
|
|
2108
|
+
var disabledPickerModel = pickerModel.pipe(Component7.provide(disabledAssetListLayer));
|
|
2083
2109
|
var AssetInput = (props) => /* @__PURE__ */ jsx5(AssetInputView, {
|
|
2084
2110
|
...props
|
|
2085
2111
|
}, props.access?.scopeKey);
|
|
@@ -2098,8 +2124,15 @@ var AssetInputView = (props) => {
|
|
|
2098
2124
|
uploadTrigger
|
|
2099
2125
|
} = props;
|
|
2100
2126
|
const { runtime, access, replaceId } = props;
|
|
2101
|
-
const
|
|
2102
|
-
const
|
|
2127
|
+
const listAccess = runtime && suppliedAssets === undefined && onChange && access?.permissions.includes("list") ? access : undefined;
|
|
2128
|
+
const listRuntime = listAccess ? runtime : undefined;
|
|
2129
|
+
const showFiles = listAccess?.permissions.includes("read");
|
|
2130
|
+
const component = useMemo2(() => listRuntime ? pickerModel.pipe(Component7.provide(listRuntime.layer)) : disabledPickerModel, [listRuntime, showFiles]);
|
|
2131
|
+
const { queries } = React2.useView(component, {
|
|
2132
|
+
...listAccess && props.value !== undefined ? { access: listAccess, value: props.value } : {}
|
|
2133
|
+
});
|
|
2134
|
+
const result = queries?.library ?? AsyncResult2.initial();
|
|
2135
|
+
const assets = suppliedAssets ?? (listAccess ? AsyncResult2.isSuccess(result) ? result.value.items : [] : undefined);
|
|
2103
2136
|
const id = useId3();
|
|
2104
2137
|
const [published, setPublished] = useState4([]);
|
|
2105
2138
|
const pendingIds = useRef3([]);
|
|
@@ -2272,14 +2305,14 @@ var AssetInputView = (props) => {
|
|
|
2272
2305
|
};
|
|
2273
2306
|
|
|
2274
2307
|
// ../../src/components/data-table/index.ts
|
|
2275
|
-
import { DateTime as DateTime3, Effect as
|
|
2308
|
+
import { DateTime as DateTime3, Effect as Effect4, Option as Option3, Redacted as Redacted4, Schema as Schema17, Stream as Stream2 } from "effect";
|
|
2276
2309
|
import { Csv } from "effect/encoding";
|
|
2277
2310
|
import { Command as Command2, Component as Component9, Subscription, UiSchema as UiSchema7 } from "effect/ui";
|
|
2278
2311
|
|
|
2279
2312
|
// ../../src/lib/query.ts
|
|
2280
2313
|
import {
|
|
2281
2314
|
DateTime,
|
|
2282
|
-
Effect as
|
|
2315
|
+
Effect as Effect3,
|
|
2283
2316
|
Option,
|
|
2284
2317
|
Schema as Schema13,
|
|
2285
2318
|
SchemaGetter,
|
|
@@ -2315,11 +2348,11 @@ var SortParamFromString = Schema13.String.pipe(Schema13.decodeTo(SortParam, Sche
|
|
|
2315
2348
|
decode: (sort) => {
|
|
2316
2349
|
const sortParam = parseSortParam(sort);
|
|
2317
2350
|
if (!sortParam) {
|
|
2318
|
-
return
|
|
2351
|
+
return Effect3.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field" or "-field"' }, sort));
|
|
2319
2352
|
}
|
|
2320
|
-
return
|
|
2353
|
+
return Effect3.succeed(sortParam);
|
|
2321
2354
|
},
|
|
2322
|
-
encode: (sort) =>
|
|
2355
|
+
encode: (sort) => Effect3.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
|
|
2323
2356
|
})), Schema13.annotate({
|
|
2324
2357
|
identifier: "SortParamFromString",
|
|
2325
2358
|
title: "Sort Parameter From String",
|
|
@@ -2329,19 +2362,19 @@ var SortParamFromString = Schema13.String.pipe(Schema13.decodeTo(SortParam, Sche
|
|
|
2329
2362
|
var SortParamsFromString = Schema13.String.pipe(Schema13.decodeTo(Schema13.Array(SortParam), SchemaTransformation.transformEffect({
|
|
2330
2363
|
decode: (sort) => {
|
|
2331
2364
|
if (sort === "")
|
|
2332
|
-
return
|
|
2365
|
+
return Effect3.succeed([]);
|
|
2333
2366
|
const parts = sort.split(",");
|
|
2334
2367
|
const sortParams = [];
|
|
2335
2368
|
for (const part of parts) {
|
|
2336
2369
|
const sortParam = parseSortParam(part);
|
|
2337
2370
|
if (!sortParam) {
|
|
2338
|
-
return
|
|
2371
|
+
return Effect3.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field,-otherField"' }, sort));
|
|
2339
2372
|
}
|
|
2340
2373
|
sortParams.push(sortParam);
|
|
2341
2374
|
}
|
|
2342
|
-
return
|
|
2375
|
+
return Effect3.succeed(sortParams);
|
|
2343
2376
|
},
|
|
2344
|
-
encode: (sort) =>
|
|
2377
|
+
encode: (sort) => Effect3.succeed(sort.map((part) => Schema13.encodeSync(SortParamFromString)(part)).join(","))
|
|
2345
2378
|
})), Schema13.annotate({
|
|
2346
2379
|
identifier: "SortParamsFromString",
|
|
2347
2380
|
title: "Sort Parameters From String",
|
|
@@ -2405,11 +2438,11 @@ var ColumnFilters = Schema13.declare(Schema13.is(ColumnFiltersArray), {
|
|
|
2405
2438
|
var DEFAULT_PAGE_SIZE = 100;
|
|
2406
2439
|
var Query2 = Schema13.Struct({
|
|
2407
2440
|
page: Schema13.optional(Schema13.Union([Schema13.Finite, Schema13.FiniteFromString]).check(Schema13.isInt(), Schema13.isGreaterThanOrEqualTo(0))).pipe(Schema13.decodeTo(Schema13.Int.check(Schema13.isGreaterThanOrEqualTo(0)), {
|
|
2408
|
-
decode: SchemaGetter.withDefault(
|
|
2441
|
+
decode: SchemaGetter.withDefault(Effect3.succeed(0)),
|
|
2409
2442
|
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
2410
2443
|
})),
|
|
2411
2444
|
pageSize: Schema13.optional(Schema13.Union([Schema13.Finite, Schema13.FiniteFromString]).check(Schema13.isInt(), Schema13.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema13.decodeTo(Schema13.Int.check(Schema13.isBetween({ minimum: 1, maximum: 100 })), {
|
|
2412
|
-
decode: SchemaGetter.withDefault(
|
|
2445
|
+
decode: SchemaGetter.withDefault(Effect3.succeed(DEFAULT_PAGE_SIZE)),
|
|
2413
2446
|
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== DEFAULT_PAGE_SIZE))
|
|
2414
2447
|
})),
|
|
2415
2448
|
globalFilter: Schema13.optional(Schema13.String),
|
|
@@ -2573,8 +2606,16 @@ var paginationNavigation = (page, pageCount) => ({
|
|
|
2573
2606
|
import { DateTime as DateTime2, Option as Option2, Predicate as Predicate2, Schema as Schema16, Struct as Struct5, Tuple } from "effect";
|
|
2574
2607
|
|
|
2575
2608
|
// ../../src/components/data-table/classes.ts
|
|
2609
|
+
var tableListEntryClasses = {
|
|
2610
|
+
menuItem: "min-h-0 px-2 py-1.5 text-sm leading-5",
|
|
2611
|
+
detail: "flex min-w-0 flex-1 items-center gap-2 text-left",
|
|
2612
|
+
avatar: "bg-secondary text-secondary-foreground flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full",
|
|
2613
|
+
image: "size-full object-cover"
|
|
2614
|
+
};
|
|
2576
2615
|
var booleanCellControl = "flex min-h-16 w-full items-center justify-start px-2 in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0 has-[:focus-visible]:outline-2 has-[:focus-visible]:-outline-offset-2 has-[:focus-visible]:outline-ring";
|
|
2577
2616
|
var cellTriggerFocus = "focus-visible:ring-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring";
|
|
2617
|
+
var tableSurfaceContext = "in-[[role=dialog]]:[--data-table-dialog-surface:var(--popover)]";
|
|
2618
|
+
var tableSurface = "bg-[color:var(--data-table-surface,var(--data-table-dialog-surface,var(--background)))]";
|
|
2578
2619
|
var tableBadgeTones = {
|
|
2579
2620
|
success: "border-emerald-200 bg-emerald-100 text-emerald-900 dark:border-emerald-900/50 dark:bg-emerald-950/50 dark:text-emerald-200",
|
|
2580
2621
|
info: "border-blue-200 bg-blue-100 text-blue-900 dark:border-blue-900/50 dark:bg-blue-950/50 dark:text-blue-200",
|
|
@@ -2592,11 +2633,11 @@ var tableClasses = {
|
|
|
2592
2633
|
cell: "overflow-hidden",
|
|
2593
2634
|
cellContent: "min-w-0 wrap-anywhere",
|
|
2594
2635
|
actionTrigger: `size-8 ${cellTriggerFocus}`,
|
|
2595
|
-
actionsCell:
|
|
2636
|
+
actionsCell: `sticky right-0 z-20 w-10 min-w-10 cursor-default p-0 transition-colors ${tableSurface} group-hover/row:bg-[color-mix(in_oklab,var(--muted)_50%,var(--data-table-surface,var(--data-table-dialog-surface,var(--background))))]`,
|
|
2596
2637
|
actionsAlign: "flex min-h-12 items-center justify-end pe-1",
|
|
2597
2638
|
row: "h-16 [&:where(:not(:last-child))>td]:border-b",
|
|
2598
2639
|
header: "relative h-12 p-0",
|
|
2599
|
-
stickyHeader:
|
|
2640
|
+
stickyHeader: `sticky top-0 z-30 ${tableSurface}`,
|
|
2600
2641
|
stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
|
|
2601
2642
|
headerTrigger: `absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 ${cellTriggerFocus}`,
|
|
2602
2643
|
resizeHandle: "absolute inset-y-0 right-0 z-10 w-2 cursor-col-resize touch-none outline-none after:absolute after:inset-y-3 after:right-0 after:w-px after:bg-border hover:after:w-0.5 hover:after:bg-primary/60 focus-visible:after:w-0.5 focus-visible:after:bg-ring",
|
|
@@ -2612,7 +2653,7 @@ var tableClasses = {
|
|
|
2612
2653
|
referenceName: "truncate font-medium",
|
|
2613
2654
|
referenceDescription: "text-muted-foreground truncate text-xs"
|
|
2614
2655
|
};
|
|
2615
|
-
var tableResultsFooterClass =
|
|
2656
|
+
var tableResultsFooterClass = `${tableSurface} text-muted-foreground sticky bottom-0 z-30 shrink-0 border-t px-2 py-2 text-sm`;
|
|
2616
2657
|
var resolveTableClasses = (overrides) => ({
|
|
2617
2658
|
...tableClasses,
|
|
2618
2659
|
...overrides
|
|
@@ -2659,7 +2700,8 @@ var PaginationSchema = Schema16.Union([
|
|
|
2659
2700
|
]);
|
|
2660
2701
|
var DataTableItemSchema = Schema16.Struct({
|
|
2661
2702
|
value: Schema16.NonEmptyString,
|
|
2662
|
-
label: Schema16.String
|
|
2703
|
+
label: Schema16.String,
|
|
2704
|
+
imageSrc: Schema16.optionalKey(Schema16.String)
|
|
2663
2705
|
}).annotate({ identifier: "DataTableItem" });
|
|
2664
2706
|
var TableIconSchema = Schema16.declare((value) => Predicate2.isFunction(value)).annotate({ identifier: "DataTableIcon" });
|
|
2665
2707
|
var DataTableReferenceSchema = Schema16.Struct({
|
|
@@ -2777,6 +2819,7 @@ var DataTableFieldSchema = Schema16.Union([
|
|
|
2777
2819
|
type: Schema16.Literal("reference"),
|
|
2778
2820
|
typeOptions: Schema16.optionalKey(Schema16.Struct({
|
|
2779
2821
|
imageVariant: Schema16.optionalKey(Schema16.Literals(["circle", "square"])),
|
|
2822
|
+
appearance: Schema16.optionalKey(Schema16.Literal("resource")),
|
|
2780
2823
|
fallbackIcons: Schema16.optionalKey(Schema16.Record(Schema16.String, TableIconSchema))
|
|
2781
2824
|
}).annotate({ identifier: "DataTableReferenceOptions" }))
|
|
2782
2825
|
}),
|
|
@@ -2807,6 +2850,7 @@ var DataTableFieldSchema = Schema16.Union([
|
|
|
2807
2850
|
options: Schema16.optionalKey(Schema16.Array(DataTableItemSchema)),
|
|
2808
2851
|
allowRemove: Schema16.optionalKey(Schema16.Boolean),
|
|
2809
2852
|
itemActions: Schema16.optionalKey(Schema16.Array(DataTableActionSchema)),
|
|
2853
|
+
itemActionIcons: Schema16.optionalKey(Schema16.Record(Schema16.String, TableIconSchema)),
|
|
2810
2854
|
display: Schema16.optionalKey(Schema16.Literals(["list", "icon", "badge"])),
|
|
2811
2855
|
visibleCount: Schema16.optionalKey(Schema16.Int.check(Schema16.isGreaterThanOrEqualTo(0))),
|
|
2812
2856
|
actionsLabel: Schema16.optionalKey(Schema16.String),
|
|
@@ -3600,8 +3644,8 @@ var dataTablePage = (props, model, locale) => {
|
|
|
3600
3644
|
pageSizes: pagination && pagination.pageSizes || defaultPageSizes
|
|
3601
3645
|
};
|
|
3602
3646
|
};
|
|
3603
|
-
var encodeTableCsv = (headers, data) =>
|
|
3604
|
-
` })), Stream2.runCollect,
|
|
3647
|
+
var encodeTableCsv = (headers, data) => Effect4.runSync(Stream2.fromIterable([headers, ...data]).pipe(Stream2.map((row) => row.map((value) => value == null ? "" : String(value))), Stream2.pipeThroughChannel(Csv.encodeString({ newline: `
|
|
3648
|
+
` })), Stream2.runCollect, Effect4.map((parts) => parts.join("").slice(0, -1))));
|
|
3605
3649
|
var tableExportFilename = (name, extension) => name.includes(".") ? name.replace(/\.[^/.]+$/, `.${extension}`) : `${name}.${extension}`;
|
|
3606
3650
|
var downloadTableBlob = (content, type, filename) => {
|
|
3607
3651
|
const url = window.URL.createObjectURL(new Blob([content], { type }));
|
|
@@ -3642,7 +3686,7 @@ var DownloadTable = Command2.make("DataTable/Download", {
|
|
|
3642
3686
|
content: Schema17.Redacted(Schema17.String, { disallowJsonEncode: true }),
|
|
3643
3687
|
type: Schema17.String
|
|
3644
3688
|
}
|
|
3645
|
-
}, ({ filename, content, type }) =>
|
|
3689
|
+
}, ({ filename, content, type }) => Effect4.try(() => downloadTableBlob(Redacted4.value(content), type, filename)).pipe(Effect4.match({
|
|
3646
3690
|
onSuccess: () => DataTableMessage.ExportFinished({ failed: false }),
|
|
3647
3691
|
onFailure: () => DataTableMessage.ExportFinished({ failed: true })
|
|
3648
3692
|
})));
|
|
@@ -4263,7 +4307,7 @@ import {
|
|
|
4263
4307
|
TooltipProvider,
|
|
4264
4308
|
TooltipTrigger
|
|
4265
4309
|
} from "@/components/ui/tooltip";
|
|
4266
|
-
import {
|
|
4310
|
+
import { React as React3 } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
4267
4311
|
import { useKrakstackLocale as useKrakstackLocale7 } from "@krak-stack/registry/krakstack-provider/react";
|
|
4268
4312
|
import { jsx as jsx8, jsxs as jsxs8, Fragment as Fragment4 } from "react/jsx-runtime";
|
|
4269
4313
|
var DataTableStylesContext = createContext(undefined);
|
|
@@ -6803,7 +6847,7 @@ var HydratedDataTable = (props) => {
|
|
|
6803
6847
|
props.state,
|
|
6804
6848
|
selection
|
|
6805
6849
|
]);
|
|
6806
|
-
const { model, send } =
|
|
6850
|
+
const { model, send } = React3.useView(ReactTableModel, modelProps, {
|
|
6807
6851
|
onEmit: (event) => {
|
|
6808
6852
|
if (event._tag === "StateChanged") {
|
|
6809
6853
|
props.onStateChange?.(queryFromState(event.state));
|
|
@@ -6885,7 +6929,7 @@ var HydratedDataTable = (props) => {
|
|
|
6885
6929
|
props
|
|
6886
6930
|
});
|
|
6887
6931
|
return /* @__PURE__ */ jsxs8("div", {
|
|
6888
|
-
className: cn("w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
6932
|
+
className: cn("w-full max-w-full min-w-0 rounded-md", tableSurfaceContext, getTableLayoutClass(props.features?.virtualization), props.className),
|
|
6889
6933
|
"data-table-root": "",
|
|
6890
6934
|
children: [
|
|
6891
6935
|
/* @__PURE__ */ jsx8(DataTableToolbar, {
|
|
@@ -7262,6 +7306,7 @@ var DataTableListMenu = ({
|
|
|
7262
7306
|
entries.map(({ item, visibleActions }, index) => visibleActions.length ? /* @__PURE__ */ jsxs8(DropdownMenuSub, {
|
|
7263
7307
|
children: [
|
|
7264
7308
|
/* @__PURE__ */ jsx8(DropdownMenuSubTrigger, {
|
|
7309
|
+
className: tableListEntryClasses.menuItem,
|
|
7265
7310
|
children: /* @__PURE__ */ jsx8(DataTableListEntry, {
|
|
7266
7311
|
item,
|
|
7267
7312
|
appearance: display === "icon" ? "detail" : "list"
|
|
@@ -7271,6 +7316,7 @@ var DataTableListMenu = ({
|
|
|
7271
7316
|
className: "w-max",
|
|
7272
7317
|
children: visibleActions.map((action) => /* @__PURE__ */ jsxs8(DropdownMenuItem, {
|
|
7273
7318
|
closeOnClick: action.closeOnClick,
|
|
7319
|
+
className: tableListEntryClasses.menuItem,
|
|
7274
7320
|
disabled: action.disabled?.(item),
|
|
7275
7321
|
onClick: (event) => {
|
|
7276
7322
|
event.stopPropagation();
|
|
@@ -7285,6 +7331,7 @@ var DataTableListMenu = ({
|
|
|
7285
7331
|
})
|
|
7286
7332
|
]
|
|
7287
7333
|
}, item.value ?? `${item.label}-${index}`) : /* @__PURE__ */ jsx8(DropdownMenuItem, {
|
|
7334
|
+
className: tableListEntryClasses.menuItem,
|
|
7288
7335
|
closeOnClick: Boolean(onItemClick),
|
|
7289
7336
|
onClick: (event) => {
|
|
7290
7337
|
event.stopPropagation();
|
|
@@ -7488,11 +7535,11 @@ var DataTableListEntry = ({
|
|
|
7488
7535
|
}) => {
|
|
7489
7536
|
const icon = /* @__PURE__ */ jsx8("span", {
|
|
7490
7537
|
"aria-hidden": "true",
|
|
7491
|
-
className:
|
|
7538
|
+
className: tableListEntryClasses.avatar,
|
|
7492
7539
|
children: item.imageSrc ? /* @__PURE__ */ jsx8("img", {
|
|
7493
7540
|
alt: "",
|
|
7494
7541
|
src: item.imageSrc,
|
|
7495
|
-
className:
|
|
7542
|
+
className: tableListEntryClasses.image
|
|
7496
7543
|
}) : item.icon ?? item.label.slice(0, 2).toUpperCase()
|
|
7497
7544
|
});
|
|
7498
7545
|
if (appearance === "list") {
|
|
@@ -7516,7 +7563,7 @@ var DataTableListEntry = ({
|
|
|
7516
7563
|
})
|
|
7517
7564
|
]
|
|
7518
7565
|
}) : /* @__PURE__ */ jsxs8("span", {
|
|
7519
|
-
className:
|
|
7566
|
+
className: tableListEntryClasses.detail,
|
|
7520
7567
|
children: [
|
|
7521
7568
|
icon,
|
|
7522
7569
|
/* @__PURE__ */ jsx8("span", {
|
|
@@ -7544,13 +7591,12 @@ import { Button as Button8 } from "@/components/ui/button";
|
|
|
7544
7591
|
import { Check as Check4, Copy, TriangleAlert as TriangleAlert2 } from "lucide-react";
|
|
7545
7592
|
import { Redacted as Redacted6 } from "effect";
|
|
7546
7593
|
import { Component as Component12 } from "effect/ui";
|
|
7547
|
-
import { useLayoutEffect as useLayoutEffect4, useRef as useRef5, useState as useState6 } from "react";
|
|
7548
7594
|
import { useKrakstackLocale as useKrakstackLocale8 } from "@krak-stack/registry/krakstack-provider/react";
|
|
7549
|
-
import {
|
|
7595
|
+
import { React as React4 } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
7550
7596
|
|
|
7551
7597
|
// ../../src/components/copy-button/index.ts
|
|
7552
|
-
import { Effect as
|
|
7553
|
-
import { Command as Command3, Component as Component11, UiSchema as UiSchema8
|
|
7598
|
+
import { Effect as Effect5, Redacted as Redacted5, Schema as Schema20 } from "effect";
|
|
7599
|
+
import { Command as Command3, Component as Component11, UiSchema as UiSchema8 } from "effect/ui";
|
|
7554
7600
|
|
|
7555
7601
|
// ../../src/components/copy-button/schema.ts
|
|
7556
7602
|
import { Schema as Schema19 } from "effect";
|
|
@@ -7568,6 +7614,9 @@ var copyButtonVariants = [
|
|
|
7568
7614
|
"destructive",
|
|
7569
7615
|
"link"
|
|
7570
7616
|
];
|
|
7617
|
+
var ClipboardFailureCause = Schema19.Redacted(Schema19.Unknown, {
|
|
7618
|
+
disallowJsonEncode: true
|
|
7619
|
+
}).annotate({ identifier: "ClipboardFailureCause" });
|
|
7571
7620
|
var CopyButtonModelProps = Schema19.Struct({
|
|
7572
7621
|
value: Schema19.Redacted(Schema19.String, { disallowJsonEncode: true }),
|
|
7573
7622
|
disabled: Schema19.optional(Schema19.Boolean),
|
|
@@ -7595,9 +7644,16 @@ var copyButtonMessages = (locale = "en", translations) => ({
|
|
|
7595
7644
|
var copyButtonLabel = (copy, description) => description ? `${copy} ${description}` : copy;
|
|
7596
7645
|
var CopyButtonMessage = UiSchema8.TaggedEnum({
|
|
7597
7646
|
Pressed: {},
|
|
7598
|
-
Finished: {
|
|
7647
|
+
Finished: {
|
|
7648
|
+
success: Schema20.Boolean,
|
|
7649
|
+
cause: Schema20.optionalKey(ClipboardFailureCause)
|
|
7650
|
+
},
|
|
7599
7651
|
Reset: {}
|
|
7600
7652
|
}).annotate({ identifier: "CopyButtonMessage" });
|
|
7653
|
+
var CopyButtonEvent = UiSchema8.TaggedEnum({
|
|
7654
|
+
Copied: {},
|
|
7655
|
+
CopyFailed: { cause: Schema20.optionalKey(ClipboardFailureCause) }
|
|
7656
|
+
}).annotate({ identifier: "CopyButtonEvent" });
|
|
7601
7657
|
|
|
7602
7658
|
class WriteClipboard extends Command3.Service()("copy-button/WriteClipboard", {
|
|
7603
7659
|
args: {
|
|
@@ -7605,13 +7661,16 @@ class WriteClipboard extends Command3.Service()("copy-button/WriteClipboard", {
|
|
|
7605
7661
|
},
|
|
7606
7662
|
success: CopyButtonMessage
|
|
7607
7663
|
}) {
|
|
7608
|
-
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) =>
|
|
7664
|
+
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect5.tryPromise({
|
|
7665
|
+
try: () => write(Redacted5.value(value)),
|
|
7666
|
+
catch: Redacted5.make
|
|
7667
|
+
}).pipe(Effect5.match({
|
|
7609
7668
|
onSuccess: () => CopyButtonMessage.Finished({ success: true }),
|
|
7610
|
-
onFailure: () => CopyButtonMessage.Finished({ success: false })
|
|
7669
|
+
onFailure: (cause) => CopyButtonMessage.Finished({ success: false, cause })
|
|
7611
7670
|
})));
|
|
7612
7671
|
static browser = WriteClipboard.layerFromWrite((value) => navigator.clipboard.writeText(value));
|
|
7613
7672
|
}
|
|
7614
|
-
var ResetClipboardFeedback = Command3.make("copy-button/ResetFeedback", { args: { delay: Schema20.Number }, mode: "switch" }, ({ delay }) =>
|
|
7673
|
+
var ResetClipboardFeedback = Command3.make("copy-button/ResetFeedback", { args: { delay: Schema20.Number }, mode: "switch" }, ({ delay }) => Effect5.sleep(Math.max(0, delay)).pipe(Effect5.as(CopyButtonMessage.Reset())));
|
|
7615
7674
|
var copyButtonOptions = {
|
|
7616
7675
|
name: "CopyButton",
|
|
7617
7676
|
props: CopyButtonModelProps,
|
|
@@ -7619,22 +7678,19 @@ var copyButtonOptions = {
|
|
|
7619
7678
|
status: Schema20.Literals(["idle", "copied", "failed"])
|
|
7620
7679
|
}).annotate({ identifier: "CopyButtonModel" }),
|
|
7621
7680
|
message: CopyButtonMessage,
|
|
7681
|
+
events: CopyButtonEvent,
|
|
7622
7682
|
restore: false
|
|
7623
7683
|
};
|
|
7624
7684
|
var Definition = Component11.define(copyButtonOptions);
|
|
7625
7685
|
var update6 = Definition.update({
|
|
7626
7686
|
Pressed: ($) => $.props.disabled ? $.model : $.run(WriteClipboard.make({ value: $.props.value })),
|
|
7627
|
-
Finished: ($, { success }) => $.evolve({ status: success ? "copied" : "failed" }).run(ResetClipboardFeedback.make({ delay: $.props.resetDelay ?? 1500 })),
|
|
7687
|
+
Finished: ($, { success, cause }) => $.evolve({ status: success ? "copied" : "failed" }).run(ResetClipboardFeedback.make({ delay: $.props.resetDelay ?? 1500 })).emit(success ? CopyButtonEvent.Copied() : CopyButtonEvent.CopyFailed(cause === undefined ? {} : { cause })),
|
|
7628
7688
|
Reset: ($) => $.evolve({ status: "idle" })
|
|
7629
7689
|
});
|
|
7630
7690
|
var copyButtonBehaviours = {
|
|
7631
7691
|
init: () => ({ status: "idle" }),
|
|
7632
7692
|
update: update6
|
|
7633
7693
|
};
|
|
7634
|
-
var CopyButtonModel = Definition.make({
|
|
7635
|
-
...copyButtonBehaviours,
|
|
7636
|
-
view: () => View4.text("")
|
|
7637
|
-
});
|
|
7638
7694
|
var copyButtonStatus = (status, copy, description) => {
|
|
7639
7695
|
if (status === "idle")
|
|
7640
7696
|
return "";
|
|
@@ -7645,6 +7701,7 @@ var copyButtonStatus = (status, copy, description) => {
|
|
|
7645
7701
|
// ../../src/components/copy-button/react.tsx
|
|
7646
7702
|
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
7647
7703
|
"use client";
|
|
7704
|
+
var CopyButtonModel = React4.component(copyButtonOptions).make(copyButtonBehaviours).pipe(Component12.provide(WriteClipboard.browser));
|
|
7648
7705
|
function CopyButton({
|
|
7649
7706
|
value,
|
|
7650
7707
|
valueDescription,
|
|
@@ -7661,35 +7718,18 @@ function CopyButton({
|
|
|
7661
7718
|
}) {
|
|
7662
7719
|
const locale = useKrakstackLocale8(localeOverride);
|
|
7663
7720
|
const labels = copyButtonMessages(locale, messages);
|
|
7664
|
-
const callbacks = useRef5({
|
|
7665
|
-
onCopied,
|
|
7666
|
-
onCopyError,
|
|
7667
|
-
failureLabel: labels.copyFailed
|
|
7668
|
-
});
|
|
7669
|
-
useLayoutEffect4(() => {
|
|
7670
|
-
callbacks.current = {
|
|
7671
|
-
onCopied,
|
|
7672
|
-
onCopyError,
|
|
7673
|
-
failureLabel: labels.copyFailed
|
|
7674
|
-
};
|
|
7675
|
-
}, [onCopied, onCopyError, labels.copyFailed]);
|
|
7676
|
-
const [component] = useState6(() => CopyButtonModel.pipe(Component12.provide(WriteClipboard.layerFromWrite(async (text) => {
|
|
7677
|
-
const { onCopied, onCopyError, failureLabel } = callbacks.current;
|
|
7678
|
-
try {
|
|
7679
|
-
await navigator.clipboard.writeText(text);
|
|
7680
|
-
onCopied?.();
|
|
7681
|
-
} catch (cause) {
|
|
7682
|
-
onCopyError?.(cause instanceof Error ? cause : new Error(failureLabel, { cause }));
|
|
7683
|
-
throw cause;
|
|
7684
|
-
}
|
|
7685
|
-
}))));
|
|
7686
7721
|
const {
|
|
7687
7722
|
model: { status },
|
|
7688
7723
|
send
|
|
7689
|
-
} =
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7724
|
+
} = React4.useView(CopyButtonModel, { value: Redacted6.make(value), disabled: disabled ?? false, resetDelay }, {
|
|
7725
|
+
onEmit: (event) => {
|
|
7726
|
+
if (event._tag === "Copied") {
|
|
7727
|
+
onCopied?.();
|
|
7728
|
+
} else {
|
|
7729
|
+
const cause = event.cause && Redacted6.value(event.cause);
|
|
7730
|
+
onCopyError?.(cause instanceof Error ? cause : new Error(labels.copyFailed, { cause }));
|
|
7731
|
+
}
|
|
7732
|
+
}
|
|
7693
7733
|
});
|
|
7694
7734
|
const accessibleLabel = ariaLabel ?? copyButtonLabel(labels.copy, valueDescription);
|
|
7695
7735
|
const isLarge = copyVariant === "large";
|
|
@@ -7724,10 +7764,10 @@ function CopyButton({
|
|
|
7724
7764
|
}
|
|
7725
7765
|
|
|
7726
7766
|
// ../assets/src/components/asset-table/react.tsx
|
|
7727
|
-
import {
|
|
7767
|
+
import { React as React6 } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
7728
7768
|
|
|
7729
7769
|
// ../assets/src/components/asset-table/index.ts
|
|
7730
|
-
import { Effect as
|
|
7770
|
+
import { Effect as Effect6, Redacted as Redacted7, Schema as Schema22 } from "effect";
|
|
7731
7771
|
import { Command as Command4, Component as Component13, UiSchema as UiSchema9 } from "effect/ui";
|
|
7732
7772
|
|
|
7733
7773
|
// ../assets/src/components/asset-table/schema.ts
|
|
@@ -7789,7 +7829,7 @@ class RemoveAssetRows extends Command4.Service()("asset-table/DeleteAssets", {
|
|
|
7789
7829
|
args: { ids: Schema22.Array(Schema22.String) },
|
|
7790
7830
|
success: Manage
|
|
7791
7831
|
}) {
|
|
7792
|
-
static layer = this.toLayer(
|
|
7832
|
+
static layer = this.toLayer(Effect6.map(AssetLibraryActions, (transport) => ({ ids }) => transport.remove(ids).pipe(Effect6.match({
|
|
7793
7833
|
onSuccess: (result) => Manage.Deleted({ failed: result.failures.length > 0 }),
|
|
7794
7834
|
onFailure: () => Manage.Deleted({ failed: true })
|
|
7795
7835
|
}))));
|
|
@@ -7808,6 +7848,20 @@ var assetTableManagementOptions = {
|
|
|
7808
7848
|
}),
|
|
7809
7849
|
restore: false
|
|
7810
7850
|
};
|
|
7851
|
+
var assetTableLibraryOptions = {
|
|
7852
|
+
name: "AssetTableLibraryRead",
|
|
7853
|
+
props: AssetTablePropsSchema,
|
|
7854
|
+
model: Schema22.Null,
|
|
7855
|
+
message: Schema22.Never,
|
|
7856
|
+
restore: false,
|
|
7857
|
+
queries: {
|
|
7858
|
+
library: assetLibraryQuery((props) => props.assets === undefined ? props.access : undefined)
|
|
7859
|
+
}
|
|
7860
|
+
};
|
|
7861
|
+
var assetTableLibraryBehaviours = {
|
|
7862
|
+
init: () => null,
|
|
7863
|
+
update: () => null
|
|
7864
|
+
};
|
|
7811
7865
|
var management = Component13.define(assetTableManagementOptions);
|
|
7812
7866
|
var managementUpdate = management.update({
|
|
7813
7867
|
Replace: ($, { id }) => $.evolve({ replaceId: id }),
|
|
@@ -7894,7 +7948,7 @@ var downloadAsset = Command4.make("asset-table/Download", {
|
|
|
7894
7948
|
url: Schema22.Redacted(Schema22.String, { disallowJsonEncode: true }),
|
|
7895
7949
|
name: Schema22.String
|
|
7896
7950
|
}
|
|
7897
|
-
}, ({ url, name }) =>
|
|
7951
|
+
}, ({ url, name }) => Effect6.sync(() => {
|
|
7898
7952
|
const link = document.createElement("a");
|
|
7899
7953
|
const href = Redacted7.value(url);
|
|
7900
7954
|
link.href = href;
|
|
@@ -7909,7 +7963,7 @@ var downloadAsset = Command4.make("asset-table/Download", {
|
|
|
7909
7963
|
} finally {
|
|
7910
7964
|
link.remove();
|
|
7911
7965
|
}
|
|
7912
|
-
}).pipe(
|
|
7966
|
+
}).pipe(Effect6.as(Component13.noop)));
|
|
7913
7967
|
var assetTableOptions = {
|
|
7914
7968
|
name: "AssetTable",
|
|
7915
7969
|
props: AssetTablePropsSchema,
|
|
@@ -7965,24 +8019,46 @@ var assetTableBehaviours = {
|
|
|
7965
8019
|
update: update7
|
|
7966
8020
|
};
|
|
7967
8021
|
|
|
8022
|
+
// ../assets/src/services/assets/use-library.ts
|
|
8023
|
+
import { useMemo as useMemo4 } from "react";
|
|
8024
|
+
import { AsyncResult as AsyncResult3 } from "effect/reactivity";
|
|
8025
|
+
import { Component as Component14 } from "effect/ui";
|
|
8026
|
+
import { React as React5 } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
8027
|
+
var AssetLibraryView = React5.component(assetLibraryOptions).make(assetLibraryBehaviours);
|
|
8028
|
+
var disabled = AssetLibraryView.pipe(Component14.provide(disabledAssetListLayer));
|
|
8029
|
+
var noAccess = { scopeKey: "disabled", permissions: [] };
|
|
8030
|
+
var useAssetLibrary = (runtime, access) => {
|
|
8031
|
+
const scopeKey = access?.permissions.includes("list") ? access.scopeKey : undefined;
|
|
8032
|
+
const showFiles = access?.permissions.includes("read") ?? false;
|
|
8033
|
+
const model = useMemo4(() => runtime && scopeKey ? AssetLibraryView.pipe(Component14.provide(runtime.layer)) : disabled, [runtime, scopeKey, showFiles]);
|
|
8034
|
+
const { queries } = React5.useView(model, {
|
|
8035
|
+
access: runtime && scopeKey && access ? access : noAccess
|
|
8036
|
+
});
|
|
8037
|
+
const result = queries?.library;
|
|
8038
|
+
const enabled = runtime !== undefined && scopeKey !== undefined;
|
|
8039
|
+
return useMemo4(() => enabled ? assetLibrarySnapshot(result ?? AsyncResult3.initial()) : emptyAssetLibrary, [enabled, result]);
|
|
8040
|
+
};
|
|
8041
|
+
|
|
7968
8042
|
// ../assets/src/components/asset-table/react.tsx
|
|
7969
8043
|
import { jsx as jsx10, jsxs as jsxs10, Fragment as Fragment5 } from "react/jsx-runtime";
|
|
7970
8044
|
"use client";
|
|
7971
|
-
var managementModel =
|
|
7972
|
-
|
|
7973
|
-
view: () => View5.text("")
|
|
7974
|
-
});
|
|
8045
|
+
var managementModel = React6.component(assetTableManagementOptions).make(assetTableManagementBehaviours);
|
|
8046
|
+
var libraryModel = React6.component(assetTableLibraryOptions).make(assetTableLibraryBehaviours);
|
|
7975
8047
|
var ConnectedAssetTable = ({
|
|
7976
8048
|
runtime,
|
|
7977
8049
|
access,
|
|
7978
8050
|
...props
|
|
7979
8051
|
}) => {
|
|
7980
|
-
const
|
|
7981
|
-
const
|
|
7982
|
-
const
|
|
8052
|
+
const canList = access.permissions.includes("list");
|
|
8053
|
+
const showFiles = access.permissions.includes("read");
|
|
8054
|
+
const library = useMemo5(() => libraryModel.pipe(Component15.provide(runtime.layer)), [runtime, canList, showFiles]);
|
|
8055
|
+
const component = useMemo5(() => managementModel.pipe(Component15.provide(RemoveAssetRows.layer.pipe(Layer.provideMerge(runtime.layer)))), [runtime]);
|
|
8056
|
+
const { queries } = React6.useView(library, { access });
|
|
8057
|
+
const { model, send } = React6.useView(component, {});
|
|
8058
|
+
const result = queries?.library ?? AsyncResult4.initial();
|
|
7983
8059
|
const locale = useKrakstackLocale9(props.locale);
|
|
7984
8060
|
const labels = assetTableMessages(locale, props.messages);
|
|
7985
|
-
const rows =
|
|
8061
|
+
const rows = canList && AsyncResult4.isSuccess(result) ? result.value.items : [];
|
|
7986
8062
|
const replacement = rows.find(({ id }) => id === model.replaceId);
|
|
7987
8063
|
const replace = (id) => send(Manage.Replace({ id }));
|
|
7988
8064
|
const remove = (ids) => send(Manage.Delete({ ids }));
|
|
@@ -8014,8 +8090,8 @@ var ConnectedAssetTable = ({
|
|
|
8014
8090
|
...props,
|
|
8015
8091
|
assets: rows,
|
|
8016
8092
|
status: {
|
|
8017
|
-
loading:
|
|
8018
|
-
error:
|
|
8093
|
+
loading: canList && AsyncResult4.isInitial(result),
|
|
8094
|
+
error: canList && AsyncResult4.isFailure(result) ? labels.loadFailed : undefined,
|
|
8019
8095
|
...props.status
|
|
8020
8096
|
},
|
|
8021
8097
|
onReplace: props.onReplace ?? (access.permissions.includes("update") ? ({ id }) => replace(id) : undefined),
|
|
@@ -8032,7 +8108,7 @@ function AssetTable(props) {
|
|
|
8032
8108
|
...props
|
|
8033
8109
|
});
|
|
8034
8110
|
}
|
|
8035
|
-
var tableModel =
|
|
8111
|
+
var tableModel = React6.component(assetTableOptions).make(assetTableBehaviours).pipe(Component15.provide(WriteClipboard.browser));
|
|
8036
8112
|
var AssetTableView = ({
|
|
8037
8113
|
assets,
|
|
8038
8114
|
status,
|
|
@@ -8047,7 +8123,7 @@ var AssetTableView = ({
|
|
|
8047
8123
|
}) => {
|
|
8048
8124
|
const locale = useKrakstackLocale9(localeOverride);
|
|
8049
8125
|
const labels = assetTableMessages(locale, messages);
|
|
8050
|
-
const { model, send } =
|
|
8126
|
+
const { model, send } = React6.useView(tableModel, { assets });
|
|
8051
8127
|
const dialogAsset = assets.find(({ id }) => id === model.copyLinkAssetId);
|
|
8052
8128
|
const url = dialogAsset && assetUrl(dialogAsset);
|
|
8053
8129
|
const dialogUrl = url && assetCopyUrl(url);
|