@dxos/plugin-stack 0.8.4-main.d05673bc65 → 0.8.4-main.dfabb4ec29

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 (90) hide show
  1. package/dist/lib/neutral/StackContainer-KZ5Q5YKJ.mjs +126 -0
  2. package/dist/lib/neutral/StackContainer-KZ5Q5YKJ.mjs.map +7 -0
  3. package/dist/lib/neutral/StackPlugin.mjs +22 -0
  4. package/dist/lib/neutral/StackPlugin.mjs.map +7 -0
  5. package/dist/lib/neutral/capabilities/index.mjs +7 -0
  6. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  7. package/dist/lib/{browser/chunk-G4CLPE5A.mjs → neutral/chunk-3ISQZKGO.mjs} +2 -2
  8. package/dist/lib/neutral/chunk-3ISQZKGO.mjs.map +7 -0
  9. package/dist/lib/{browser/chunk-YPQYUBQP.mjs → neutral/chunk-IPU3C6TT.mjs} +2 -2
  10. package/dist/lib/{browser/chunk-YPQYUBQP.mjs.map → neutral/chunk-IPU3C6TT.mjs.map} +3 -3
  11. package/dist/lib/{browser/StackContainer-OLHE5F4E.mjs → neutral/components/index.mjs} +36 -148
  12. package/dist/lib/neutral/components/index.mjs.map +7 -0
  13. package/dist/lib/neutral/containers/index.mjs +7 -0
  14. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  15. package/dist/lib/neutral/index.mjs +15 -0
  16. package/dist/lib/neutral/meta.json +1 -0
  17. package/dist/lib/neutral/meta.mjs +9 -0
  18. package/dist/lib/neutral/plugin.mjs +11 -0
  19. package/dist/lib/neutral/plugin.mjs.map +7 -0
  20. package/dist/lib/{browser/react-surface-JS4ERDMQ.mjs → neutral/react-surface-4ZA44TMR.mjs} +6 -16
  21. package/dist/lib/neutral/react-surface-4ZA44TMR.mjs.map +7 -0
  22. package/dist/lib/neutral/translations.mjs +37 -0
  23. package/dist/lib/neutral/translations.mjs.map +7 -0
  24. package/dist/lib/{browser → neutral}/types/index.mjs +1 -1
  25. package/dist/lib/neutral/types/index.mjs.map +7 -0
  26. package/dist/types/src/StackPlugin.d.ts +1 -0
  27. package/dist/types/src/StackPlugin.d.ts.map +1 -1
  28. package/dist/types/src/capabilities/index.d.ts +2 -1
  29. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  30. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  31. package/dist/types/src/components/StackContext/StackContext.d.ts +1 -1
  32. package/dist/types/src/components/StackContext/StackContext.d.ts.map +1 -1
  33. package/dist/types/src/components/StackSection/CaretDownUp.d.ts +1 -1
  34. package/dist/types/src/components/StackSection/CaretDownUp.d.ts.map +1 -1
  35. package/dist/types/src/components/StackSection/StackSection.d.ts +1 -1
  36. package/dist/types/src/components/StackSection/StackSection.d.ts.map +1 -1
  37. package/dist/types/src/components/StackSettings/StackSettings.d.ts +1 -1
  38. package/dist/types/src/components/StackSettings/StackSettings.d.ts.map +1 -1
  39. package/dist/types/src/containers/StackContainer/StackContainer.d.ts +2 -2
  40. package/dist/types/src/containers/StackContainer/StackContainer.d.ts.map +1 -1
  41. package/dist/types/src/containers/StackContainer/index.d.ts +1 -2
  42. package/dist/types/src/containers/StackContainer/index.d.ts.map +1 -1
  43. package/dist/types/src/index.d.ts +1 -1
  44. package/dist/types/src/index.d.ts.map +1 -1
  45. package/dist/types/src/meta.d.ts +1 -1
  46. package/dist/types/src/meta.d.ts.map +1 -1
  47. package/dist/types/src/plugin.d.ts +3 -0
  48. package/dist/types/src/plugin.d.ts.map +1 -0
  49. package/dist/types/src/translations.d.ts +30 -30
  50. package/dist/types/src/translations.d.ts.map +1 -1
  51. package/dist/types/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +77 -43
  53. package/src/StackPlugin.ts +6 -22
  54. package/src/capabilities/index.ts +3 -1
  55. package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +4 -7
  56. package/src/components/StackContext/StackContext.tsx +1 -1
  57. package/src/components/StackSection/StackSection.tsx +19 -18
  58. package/src/components/StackSettings/StackSettings.tsx +13 -15
  59. package/src/containers/StackContainer/StackContainer.tsx +14 -15
  60. package/src/containers/StackContainer/index.ts +1 -3
  61. package/src/index.ts +1 -1
  62. package/src/meta.ts +1 -1
  63. package/src/plugin.ts +9 -0
  64. package/src/translations.ts +23 -22
  65. package/src/types/stack.ts +1 -1
  66. package/dist/lib/browser/StackContainer-OLHE5F4E.mjs.map +0 -7
  67. package/dist/lib/browser/chunk-G4CLPE5A.mjs.map +0 -7
  68. package/dist/lib/browser/index.mjs +0 -84
  69. package/dist/lib/browser/index.mjs.map +0 -7
  70. package/dist/lib/browser/meta.json +0 -1
  71. package/dist/lib/browser/react-surface-JS4ERDMQ.mjs.map +0 -7
  72. package/dist/lib/node-esm/StackContainer-W3M7BKLT.mjs +0 -295
  73. package/dist/lib/node-esm/StackContainer-W3M7BKLT.mjs.map +0 -7
  74. package/dist/lib/node-esm/chunk-LELGTQAL.mjs +0 -29
  75. package/dist/lib/node-esm/chunk-LELGTQAL.mjs.map +0 -7
  76. package/dist/lib/node-esm/chunk-LOZ6GH5A.mjs +0 -23
  77. package/dist/lib/node-esm/chunk-LOZ6GH5A.mjs.map +0 -7
  78. package/dist/lib/node-esm/index.mjs +0 -85
  79. package/dist/lib/node-esm/index.mjs.map +0 -7
  80. package/dist/lib/node-esm/meta.json +0 -1
  81. package/dist/lib/node-esm/react-surface-YKS4OHR3.mjs +0 -34
  82. package/dist/lib/node-esm/react-surface-YKS4OHR3.mjs.map +0 -7
  83. package/dist/lib/node-esm/types/index.mjs +0 -10
  84. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  85. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  86. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  87. package/src/capabilities/react-surface/index.ts +0 -7
  88. /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
  89. /package/dist/lib/{node-esm/types/index.mjs.map → neutral/meta.mjs.map} +0 -0
  90. /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
@@ -0,0 +1,126 @@
1
+ // src/containers/StackContainer/StackContainer.tsx
2
+ import { Atom, useAtomValue } from "@effect-atom/atom-react";
3
+ import * as Option from "effect/Option";
4
+ import React, { useCallback, useState } from "react";
5
+ import { useOperationInvoker } from "@dxos/app-framework/ui";
6
+ import { LayoutOperation } from "@dxos/app-toolkit";
7
+ import { useAppGraph } from "@dxos/app-toolkit/ui";
8
+ import { Annotation, Obj } from "@dxos/echo";
9
+ import { AtomObj } from "@dxos/echo-atom";
10
+ import { Graph } from "@dxos/plugin-graph";
11
+ import { SpaceOperation } from "@dxos/plugin-space";
12
+ import { Toolbar, toLocalizedString, useTranslation } from "@dxos/react-ui";
13
+ import { Stack, StackItem } from "@dxos/react-ui-stack";
14
+ import { isNonNullable } from "@dxos/util";
15
+ import { StackContext, StackSection } from "#components";
16
+ import { meta } from "#meta";
17
+ var collectionObjectsFamily = Atom.family((collection) => Atom.make((get) => {
18
+ const snapshot = get(AtomObj.make(collection));
19
+ return snapshot.objects.map((ref) => get(AtomObj.makeWithReactive(ref))).filter(isNonNullable);
20
+ }));
21
+ var StackContainer = ({ attendableId, subject: collection }) => {
22
+ const { invokePromise } = useOperationInvoker();
23
+ const { graph } = useAppGraph();
24
+ const { t } = useTranslation(meta.id);
25
+ const [collapsedSections, setCollapsedSections] = useState({});
26
+ const collectionObjects = useAtomValue(collectionObjectsFamily(collection));
27
+ const items = collectionObjects.map((object) => {
28
+ const schema = Obj.getSchema(object);
29
+ const iconAnnotation = schema ? Option.getOrUndefined(Annotation.IconAnnotation.get(schema)) : void 0;
30
+ const metadata = {
31
+ icon: iconAnnotation?.icon
32
+ };
33
+ const view = {
34
+ // ...stack.sections[object.id],
35
+ collapsed: collapsedSections[Obj.getDXN(object).toString()],
36
+ title: object?.title ?? // TODO(wittjosiah): `getNode` is not reactive.
37
+ toLocalizedString(Graph.getNode(graph, Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label, t)
38
+ };
39
+ return {
40
+ id: Obj.getDXN(object).toString(),
41
+ object,
42
+ metadata,
43
+ view
44
+ };
45
+ });
46
+ const handleDelete = useCallback(async (id) => {
47
+ const index = collection.objects.map((object2) => object2.target).filter(isNonNullable).findIndex((section) => Obj.getDXN(section).toString() === id);
48
+ const object = collection.objects[index].target;
49
+ if (Obj.isObject(object)) {
50
+ await invokePromise(SpaceOperation.RemoveObjects, {
51
+ objects: [
52
+ object
53
+ ],
54
+ target: collection
55
+ });
56
+ }
57
+ }, [
58
+ collection,
59
+ invokePromise
60
+ ]);
61
+ const handleAdd = useCallback(async (id, position) => {
62
+ await invokePromise(LayoutOperation.UpdateDialog, {
63
+ subject: `${meta.id}.AddSectionDialog`,
64
+ blockAlign: "start",
65
+ props: {
66
+ path: id,
67
+ position,
68
+ collection
69
+ }
70
+ });
71
+ }, [
72
+ collection,
73
+ invokePromise
74
+ ]);
75
+ const handleNavigate = useCallback(async (id) => {
76
+ await invokePromise(LayoutOperation.Open, {
77
+ subject: [
78
+ id
79
+ ]
80
+ });
81
+ }, [
82
+ invokePromise
83
+ ]);
84
+ const handleCollapse = useCallback((id, collapsed) => setCollapsedSections((prev) => ({
85
+ ...prev,
86
+ [id]: collapsed
87
+ })), []);
88
+ const handleAddSection = useCallback(() => invokePromise(SpaceOperation.OpenCreateObject, {
89
+ target: collection,
90
+ navigable: false
91
+ }), [
92
+ collection,
93
+ invokePromise
94
+ ]);
95
+ return /* @__PURE__ */ React.createElement(StackItem.Content, {
96
+ toolbar: true,
97
+ classNames: "dx-document"
98
+ }, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
99
+ icon: "ph--plus--regular",
100
+ iconOnly: true,
101
+ label: "Add section",
102
+ "data-testid": "stack.addSection",
103
+ onClick: handleAddSection
104
+ })), /* @__PURE__ */ React.createElement(StackContext.Provider, {
105
+ value: {
106
+ attendableId,
107
+ onCollapse: handleCollapse,
108
+ onNavigate: handleNavigate,
109
+ onDelete: handleDelete,
110
+ onAdd: handleAdd
111
+ }
112
+ }, /* @__PURE__ */ React.createElement(Stack, {
113
+ orientation: "vertical",
114
+ size: "intrinsic",
115
+ id: Obj.getDXN(collection).toString(),
116
+ "data-testid": "main.stack",
117
+ classNames: "overflow-y-auto"
118
+ }, items.map((item) => /* @__PURE__ */ React.createElement(StackSection, {
119
+ key: item.id,
120
+ ...item
121
+ })))));
122
+ };
123
+ export {
124
+ StackContainer as default
125
+ };
126
+ //# sourceMappingURL=StackContainer-KZ5Q5YKJ.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/containers/StackContainer/StackContainer.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Atom, useAtomValue } from '@effect-atom/atom-react';\nimport * as Option from 'effect/Option';\nimport React, { useCallback, useState } from 'react';\n\nimport { useOperationInvoker } from '@dxos/app-framework/ui';\nimport { LayoutOperation } from '@dxos/app-toolkit';\nimport { useAppGraph, type AppSurface } from '@dxos/app-toolkit/ui';\nimport { Annotation, Obj, type Ref } from '@dxos/echo';\nimport { type Collection } from '@dxos/echo';\nimport { AtomObj } from '@dxos/echo-atom';\nimport { Graph } from '@dxos/plugin-graph';\nimport { SpaceOperation } from '@dxos/plugin-space';\nimport { Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { Stack, StackItem } from '@dxos/react-ui-stack';\nimport { isNonNullable } from '@dxos/util';\n\nimport { StackContext, StackSection } from '#components';\nimport { meta } from '#meta';\nimport {\n type AddSectionPosition,\n type CollapsedSections,\n type StackSectionItem,\n type StackSectionMetadata,\n type StackSectionView,\n} from '#types';\n\nconst collectionObjectsFamily = Atom.family((collection: Collection.Collection) =>\n Atom.make((get) => {\n const snapshot = get(AtomObj.make(collection));\n return (\n snapshot.objects\n // TODO(wittjosiah): Why isn't this type inferred correctly?\n .map((ref: Ref.Ref<Obj.Unknown>) => get(AtomObj.makeWithReactive(ref)))\n .filter(isNonNullable)\n );\n }),\n);\n\ntype StackContainerProps = AppSurface.ObjectArticleProps<Collection.Collection>;\n\nexport const StackContainer = ({ attendableId, subject: collection }: StackContainerProps) => {\n const { invokePromise } = useOperationInvoker();\n const { graph } = useAppGraph();\n const { t } = useTranslation(meta.id);\n const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});\n\n // TODO(wittjosiah): Re-implement stack views with relations.\n // const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);\n // const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;\n // useEffect(() => {\n // if (!collection.views[StackViewType.typename]) {\n // collection.views[StackViewType.typename] = Ref.make(stack);\n // }\n // }, [collection, stack]);\n\n const collectionObjects = useAtomValue(collectionObjectsFamily(collection));\n const items = collectionObjects.map((object: Obj.Unknown) => {\n const schema = Obj.getSchema(object);\n const iconAnnotation = schema ? Option.getOrUndefined(Annotation.IconAnnotation.get(schema)) : undefined;\n const metadata: StackSectionMetadata = { icon: iconAnnotation?.icon };\n const view = {\n // ...stack.sections[object.id],\n collapsed: collapsedSections[Obj.getDXN(object).toString()],\n title:\n (object as any)?.title ??\n // TODO(wittjosiah): `getNode` is not reactive.\n toLocalizedString(\n Graph.getNode(graph, Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label,\n t,\n ),\n } as StackSectionView;\n return { id: Obj.getDXN(object).toString(), object, metadata, view } satisfies StackSectionItem;\n });\n\n const handleDelete = useCallback(\n async (id: string) => {\n const index = collection.objects\n .map((object) => object.target)\n .filter(isNonNullable)\n .findIndex((section) => Obj.getDXN(section).toString() === id);\n const object = collection.objects[index].target;\n if (Obj.isObject(object)) {\n await invokePromise(SpaceOperation.RemoveObjects, {\n objects: [object],\n target: collection,\n });\n\n // TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.\n // delete stack.sections[Path.last(path)];\n }\n },\n [collection, invokePromise],\n );\n\n const handleAdd = useCallback(\n async (id: string, position: AddSectionPosition) => {\n // TODO(wittjosiah): Use object creation dialog.\n await invokePromise(LayoutOperation.UpdateDialog, {\n subject: `${meta.id}.AddSectionDialog`,\n blockAlign: 'start',\n props: {\n path: id,\n position,\n collection,\n },\n });\n },\n [collection, invokePromise],\n );\n\n const handleNavigate = useCallback(\n async (id: string) => {\n await invokePromise(LayoutOperation.Open, { subject: [id] });\n },\n [invokePromise],\n );\n\n const handleCollapse = useCallback(\n (id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),\n [],\n );\n\n const handleAddSection = useCallback(\n () =>\n invokePromise(SpaceOperation.OpenCreateObject, {\n target: collection,\n navigable: false,\n }),\n [collection, invokePromise],\n );\n\n return (\n <StackItem.Content toolbar classNames='dx-document'>\n <Toolbar.Root>\n <Toolbar.IconButton\n icon='ph--plus--regular'\n iconOnly\n label='Add section'\n data-testid='stack.addSection'\n onClick={handleAddSection}\n />\n </Toolbar.Root>\n <StackContext.Provider\n value={{\n attendableId,\n onCollapse: handleCollapse,\n onNavigate: handleNavigate,\n onDelete: handleDelete,\n onAdd: handleAdd,\n }}\n >\n <Stack\n orientation='vertical'\n size='intrinsic'\n id={Obj.getDXN(collection).toString()}\n data-testid='main.stack'\n classNames='overflow-y-auto'\n >\n {items.map((item) => (\n <StackSection key={item.id} {...item} />\n ))}\n </Stack>\n </StackContext.Provider>\n </StackItem.Content>\n );\n};\n"],
5
+ "mappings": ";AAIA,SAASA,MAAMC,oBAAoB;AACnC,YAAYC,YAAY;AACxB,OAAOC,SAASC,aAAaC,gBAAgB;AAE7C,SAASC,2BAA2B;AACpC,SAASC,uBAAuB;AAChC,SAASC,mBAAoC;AAC7C,SAASC,YAAYC,WAAqB;AAE1C,SAASC,eAAe;AACxB,SAASC,aAAa;AACtB,SAASC,sBAAsB;AAC/B,SAASC,SAASC,mBAAmBC,sBAAsB;AAC3D,SAASC,OAAOC,iBAAiB;AACjC,SAASC,qBAAqB;AAE9B,SAASC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IACLoC,UAAAA;IACA1B,OAAM;IACN2B,eAAY;IACZC,SAASV;OAGb,sBAAA,cAAC7D,aAAawE,UAAQ;IACpBC,OAAO;MACL1D;MACA2D,YAAYf;MACZgB,YAAYlB;MACZmB,UAAUhC;MACViC,OAAO1B;IACT;KAEA,sBAAA,cAACtD,OAAAA;IACCiF,aAAY;IACZC,MAAK;IACL3D,IAAI9B,IAAI8C,OAAO/B,UAAAA,EAAYgC,SAAQ;IACnCiC,eAAY;IACZJ,YAAW;KAEV1C,MAAMd,IAAI,CAACsE,SACV,sBAAA,cAAC/E,cAAAA;IAAagF,KAAKD,KAAK5D;IAAK,GAAG4D;;AAM5C;",
6
+ "names": ["Atom", "useAtomValue", "Option", "React", "useCallback", "useState", "useOperationInvoker", "LayoutOperation", "useAppGraph", "Annotation", "Obj", "AtomObj", "Graph", "SpaceOperation", "Toolbar", "toLocalizedString", "useTranslation", "Stack", "StackItem", "isNonNullable", "StackContext", "StackSection", "meta", "collectionObjectsFamily", "family", "collection", "make", "get", "snapshot", "objects", "map", "ref", "makeWithReactive", "filter", "StackContainer", "attendableId", "subject", "invokePromise", "graph", "t", "id", "collapsedSections", "setCollapsedSections", "collectionObjects", "items", "object", "schema", "getSchema", "iconAnnotation", "getOrUndefined", "IconAnnotation", "undefined", "metadata", "icon", "view", "collapsed", "getDXN", "toString", "title", "getNode", "pipe", "getOrNull", "properties", "label", "handleDelete", "index", "target", "findIndex", "section", "isObject", "RemoveObjects", "handleAdd", "position", "UpdateDialog", "blockAlign", "props", "path", "handleNavigate", "Open", "handleCollapse", "prev", "handleAddSection", "OpenCreateObject", "navigable", "Content", "toolbar", "classNames", "Root", "IconButton", "iconOnly", "data-testid", "onClick", "Provider", "value", "onCollapse", "onNavigate", "onDelete", "onAdd", "orientation", "size", "item", "key"]
7
+ }
@@ -0,0 +1,22 @@
1
+ // src/StackPlugin.ts
2
+ import { Plugin } from "@dxos/app-framework";
3
+ import { AppPlugin } from "@dxos/app-toolkit";
4
+ import { ReactSurface } from "#capabilities";
5
+ import { meta } from "#meta";
6
+ import { translations } from "#translations";
7
+ import { StackViewType } from "#types";
8
+ var StackPlugin = Plugin.define(meta).pipe(AppPlugin.addSchemaModule({
9
+ schema: [
10
+ StackViewType
11
+ ]
12
+ }), AppPlugin.addSurfaceModule({
13
+ activate: ReactSurface
14
+ }), AppPlugin.addTranslationsModule({
15
+ translations
16
+ }), Plugin.make);
17
+ var StackPlugin_default = StackPlugin;
18
+ export {
19
+ StackPlugin,
20
+ StackPlugin_default as default
21
+ };
22
+ //# sourceMappingURL=StackPlugin.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/StackPlugin.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\n\nimport { ReactSurface } from '#capabilities';\nimport { meta } from '#meta';\nimport { translations } from '#translations';\nimport { StackViewType } from '#types';\n\nexport const StackPlugin = Plugin.define(meta).pipe(\n AppPlugin.addSchemaModule({ schema: [StackViewType] }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.make,\n);\n\nexport default StackPlugin;\n"],
5
+ "mappings": ";AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,oBAAoB;AAC7B,SAASC,YAAY;AACrB,SAASC,oBAAoB;AAC7B,SAASC,qBAAqB;AAEvB,IAAMC,cAAcN,OAAOO,OAAOJ,IAAAA,EAAMK,KAC7CP,UAAUQ,gBAAgB;EAAEC,QAAQ;IAACL;;AAAe,CAAA,GACpDJ,UAAUU,iBAAiB;EAAEC,UAAUV;AAAa,CAAA,GACpDD,UAAUY,sBAAsB;EAAET;AAAa,CAAA,GAC/CJ,OAAOc,IAAI;AAGb,IAAA,sBAAeR;",
6
+ "names": ["Plugin", "AppPlugin", "ReactSurface", "meta", "translations", "StackViewType", "StackPlugin", "define", "pipe", "addSchemaModule", "schema", "addSurfaceModule", "activate", "addTranslationsModule", "make"]
7
+ }
@@ -0,0 +1,7 @@
1
+ // src/capabilities/index.ts
2
+ import { Capability } from "@dxos/app-framework";
3
+ var ReactSurface = Capability.lazy("ReactSurface", () => import("../react-surface-4ZA44TMR.mjs"));
4
+ export {
5
+ ReactSurface
6
+ };
7
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/capabilities/index.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));\n"],
5
+ "mappings": ";AAIA,SAASA,kBAAkB;AAEpB,IAAMC,eAAeD,WAAWE,KAAK,gBAAgB,MAAM,OAAO,+BAAA,CAAA;",
6
+ "names": ["Capability", "ReactSurface", "lazy"]
7
+ }
@@ -1,6 +1,6 @@
1
1
  // src/meta.ts
2
2
  import { trim } from "@dxos/util";
3
- var SECTION_IDENTIFIER = "org.dxos.type.stack-section";
3
+ var SECTION_IDENTIFIER = "org.dxos.type.stackSection";
4
4
  var meta = {
5
5
  id: "org.dxos.plugin.stack",
6
6
  // TODO(wittjosiah): Prevents "stacks" language from being exposed to users in settings panel.
@@ -18,4 +18,4 @@ export {
18
18
  SECTION_IDENTIFIER,
19
19
  meta
20
20
  };
21
- //# sourceMappingURL=chunk-G4CLPE5A.mjs.map
21
+ //# sourceMappingURL=chunk-3ISQZKGO.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const SECTION_IDENTIFIER = 'org.dxos.type.stackSection';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.stack',\n // TODO(wittjosiah): Prevents \"stacks\" language from being exposed to users in settings panel.\n // Conside renaming this to the collection plugin and trying to factor more collections logic from the space plugin.\n name: 'Collections',\n description: trim`\n Organize and view curated collections of workspace objects in customizable layouts.\n Group related items together and manage collections with sections and filtering.\n `,\n icon: 'ph--stack-simple--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-stack',\n};\n"],
5
+ "mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,qBAAqB;AAE3B,IAAMC,OAAoB;EAC/BC,IAAI;;;EAGJC,MAAM;EACNC,aAAaL;;;;EAIbM,MAAM;EACNC,QAAQ;AACV;",
6
+ "names": ["trim", "SECTION_IDENTIFIER", "meta", "id", "name", "description", "icon", "source"]
7
+ }
@@ -16,7 +16,7 @@ var StackViewType = Schema.Struct({
16
16
  value: SectionSchema
17
17
  })
18
18
  }).pipe(Type.object({
19
- typename: "org.dxos.type.stack-view",
19
+ typename: "org.dxos.type.stackView",
20
20
  version: "0.1.0"
21
21
  }));
22
22
 
@@ -24,4 +24,4 @@ export {
24
24
  SectionSchema,
25
25
  StackViewType
26
26
  };
27
- //# sourceMappingURL=chunk-YPQYUBQP.mjs.map
27
+ //# sourceMappingURL=chunk-IPU3C6TT.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/types/stack.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Type } from '@dxos/echo';\n\n// All section metadata needs to be optional/have defaults.\n// Any objects added to the collection will start with the section defaults.\n// If an object is removed from the collection without removing the section metadata this is fine.\n// Stack components should clean-up the superfluous data on future edits.\n\nexport const SectionSchema = Schema.Struct({\n height: Schema.optional(Schema.Number),\n // Space for data that isn't stack-specific but is specific to this view instance.\n // e.g. cover/fill for an image\n custom: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n});\n\n// TODO(wittjosiah): This needs a relation to be connected to a stack.\nexport const StackViewType = Schema.Struct({\n sections: Schema.Record({ key: Schema.String, value: SectionSchema }),\n}).pipe(\n Type.object({\n typename: 'org.dxos.type.stack-view',\n version: '0.1.0',\n }),\n);\n\nexport interface StackViewType extends Schema.Schema.Type<typeof StackViewType> {}\n"],
5
- "mappings": ";AAIA,YAAYA,YAAY;AAExB,SAASC,YAAY;AAOd,IAAMC,gBAAuBC,cAAO;EACzCC,QAAeC,gBAAgBC,aAAM;;;EAGrCC,QAAeF,gBAAgBG,cAAO;IAAEC,KAAYC;IAAQC,OAAcC;EAAI,CAAA,CAAA;AAChF,CAAA;AAGO,IAAMC,gBAAuBV,cAAO;EACzCW,UAAiBN,cAAO;IAAEC,KAAYC;IAAQC,OAAOT;EAAc,CAAA;AACrE,CAAA,EAAGa,KACDC,KAAKC,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;",
6
- "names": ["Schema", "Type", "SectionSchema", "Struct", "height", "optional", "Number", "custom", "Record", "key", "String", "value", "Any", "StackViewType", "sections", "pipe", "Type", "object", "typename", "version"]
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Type } from '@dxos/echo';\n\n// All section metadata needs to be optional/have defaults.\n// Any objects added to the collection will start with the section defaults.\n// If an object is removed from the collection without removing the section metadata this is fine.\n// Stack components should clean-up the superfluous data on future edits.\n\nexport const SectionSchema = Schema.Struct({\n height: Schema.optional(Schema.Number),\n // Space for data that isn't stack-specific but is specific to this view instance.\n // e.g. cover/fill for an image\n custom: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n});\n\n// TODO(wittjosiah): This needs a relation to be connected to a stack.\nexport const StackViewType = Schema.Struct({\n sections: Schema.Record({ key: Schema.String, value: SectionSchema }),\n}).pipe(\n Type.object({\n typename: 'org.dxos.type.stackView',\n version: '0.1.0',\n }),\n);\n\nexport interface StackViewType extends Schema.Schema.Type<typeof StackViewType> {}\n"],
5
+ "mappings": ";AAIA,YAAYA,YAAY;AAExB,SAASC,YAAY;AAOd,IAAMC,gBAAuBC,cAAO;EACzCC,QAAeC,gBAAgBC,aAAM;;;EAGrCC,QAAeF,gBAAgBG,cAAO;IAAEC,KAAYC;IAAQC,OAAcC;EAAI,CAAA,CAAA;AAChF,CAAA;AAGO,IAAMC,gBAAuBV,cAAO;EACzCW,UAAiBN,cAAO;IAAEC,KAAYC;IAAQC,OAAOT;EAAc,CAAA;AACrE,CAAA,EAAGa,KACDd,KAAKe,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;",
6
+ "names": ["Schema", "Type", "SectionSchema", "Struct", "height", "optional", "Number", "custom", "Record", "key", "String", "value", "Any", "StackViewType", "sections", "pipe", "object", "typename", "version"]
7
7
  }
@@ -1,22 +1,3 @@
1
- import {
2
- meta
3
- } from "./chunk-G4CLPE5A.mjs";
4
-
5
- // src/containers/StackContainer/StackContainer.tsx
6
- import { Atom, useAtomValue } from "@effect-atom/atom-react";
7
- import * as Option from "effect/Option";
8
- import React4, { useCallback, useState as useState2 } from "react";
9
- import { useCapabilities, useOperationInvoker } from "@dxos/app-framework/ui";
10
- import { AppCapabilities, LayoutOperation } from "@dxos/app-toolkit";
11
- import { useAppGraph } from "@dxos/app-toolkit/ui";
12
- import { Obj } from "@dxos/echo";
13
- import { AtomObj } from "@dxos/echo-atom";
14
- import { Graph } from "@dxos/plugin-graph";
15
- import { SpaceOperation } from "@dxos/plugin-space/types";
16
- import { Toolbar, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
17
- import { Stack, StackItem as StackItem2 } from "@dxos/react-ui-stack";
18
- import { isNonNullable } from "@dxos/util";
19
-
20
1
  // src/components/StackContext/StackContext.tsx
21
2
  import { createContext, useContext } from "react";
22
3
  var StackContext = /* @__PURE__ */ createContext({
@@ -36,10 +17,12 @@ var useStack = () => useContext(StackContext);
36
17
  import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
37
18
  import React2, { useMemo, useState } from "react";
38
19
  import { Surface } from "@dxos/app-framework/ui";
20
+ import { AppSurface } from "@dxos/app-toolkit/ui";
39
21
  import { DropdownMenu, Icon, IconButton, useTranslation } from "@dxos/react-ui";
40
22
  import { useAttentionAttributes } from "@dxos/react-ui-attention";
41
23
  import { StackItem } from "@dxos/react-ui-stack";
42
- import { getSize, mx, textBlockWidth } from "@dxos/ui-theme";
24
+ import { getSize, mx } from "@dxos/ui-theme";
25
+ import { meta } from "#meta";
43
26
 
44
27
  // src/components/StackSection/CaretDownUp.tsx
45
28
  import React from "react";
@@ -108,187 +91,92 @@ var StackSection = ({ id, view, object, metadata: { icon = "ph--placeholder--reg
108
91
  asChild: true
109
92
  }, /* @__PURE__ */ React2.createElement(StackItem.SigilButton, null, /* @__PURE__ */ React2.createElement(Icon, {
110
93
  icon,
111
- size: 5,
112
94
  classNames: "transition-opacity"
113
95
  }))), /* @__PURE__ */ React2.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Viewport, null, view.collapsed ? /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
114
96
  onClick: () => onNavigate(id),
115
97
  "data-testid": "section.navigate-to"
116
98
  }, /* @__PURE__ */ React2.createElement(Icon, {
117
- icon: "ph--arrow-right--regular",
118
- size: 5
99
+ icon: "ph--arrow-right--regular"
119
100
  }), /* @__PURE__ */ React2.createElement("span", {
120
101
  className: "ms-2 grow"
121
- }, t("navigate to section label"))) : /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
102
+ }, t("navigate-to-section.label"))) : /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
122
103
  asChild: true
123
104
  }, /* @__PURE__ */ React2.createElement(DropdownMenu.Item, null, /* @__PURE__ */ React2.createElement(CaretDownUp, {
124
105
  className: getSize(5)
125
106
  }), /* @__PURE__ */ React2.createElement("span", {
126
107
  className: "ms-2 grow"
127
- }, t("collapse label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
108
+ }, t("collapse.label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
128
109
  onClick: () => onAdd(id, "before"),
129
110
  "data-testid": "section.add-before"
130
111
  }, /* @__PURE__ */ React2.createElement(Icon, {
131
- icon: "ph--arrow-line-up--regular",
132
- size: 5
112
+ icon: "ph--arrow-line-up--regular"
133
113
  }), /* @__PURE__ */ React2.createElement("span", {
134
114
  className: "ms-2 grow"
135
- }, t("add section before label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
115
+ }, t("add-section-before.label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
136
116
  onClick: () => onAdd(id, "after"),
137
117
  "data-testid": "section.add-after"
138
118
  }, /* @__PURE__ */ React2.createElement(Icon, {
139
- icon: "ph--arrow-line-down--regular",
140
- size: 5
119
+ icon: "ph--arrow-line-down--regular"
141
120
  }), /* @__PURE__ */ React2.createElement("span", {
142
121
  className: "ms-2 grow"
143
- }, t("add section after label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
122
+ }, t("add-section-after.label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
144
123
  onClick: () => onDelete(id),
145
124
  "data-testid": "section.remove"
146
125
  }, /* @__PURE__ */ React2.createElement(Icon, {
147
- icon: "ph--trash--regular",
148
- size: 5
126
+ icon: "ph--trash--regular"
149
127
  }), /* @__PURE__ */ React2.createElement("span", {
150
128
  className: "ms-2 grow"
151
- }, t("remove section label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null)))), view.collapsed ? /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
129
+ }, t("remove-section.label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null)))), view.collapsed ? /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
152
130
  asChild: true
153
131
  }, /* @__PURE__ */ React2.createElement(IconButton, {
154
132
  iconOnly: true,
155
133
  variant: "ghost",
156
- label: t("expand label"),
134
+ label: t("expand.label"),
157
135
  icon: "ph--caret-up-down--regular",
158
136
  classNames: sectionActionDimensions
159
137
  })) : /* @__PURE__ */ React2.createElement(IconButton, {
160
138
  iconOnly: true,
161
139
  variant: "ghost",
162
140
  onClick: () => onNavigate(id),
163
- label: t("navigate to section label"),
141
+ label: t("navigate-to-section.label"),
164
142
  icon: "ph--arrow-right--regular",
165
143
  "data-testid": "section.navigate-to",
166
144
  classNames: sectionActionDimensions
167
145
  }))), /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Content, null, /* @__PURE__ */ React2.createElement(Surface.Surface, {
168
- role: "section",
146
+ type: AppSurface.Section,
169
147
  data,
170
148
  limit: 1,
171
149
  placeholder: /* @__PURE__ */ React2.createElement(React2.Fragment, null)
172
150
  })), view.collapsed && /* @__PURE__ */ React2.createElement(StackItem.Content, {
173
151
  classNames: "dx-attention-surface"
174
152
  }, /* @__PURE__ */ React2.createElement("h2", {
175
- className: mx("flex items-center p-4 font-medium", textBlockWidth)
153
+ className: mx("flex items-center p-4 font-medium")
176
154
  }, view.title))));
177
155
  };
178
156
 
179
157
  // src/components/StackSettings/StackSettings.tsx
180
158
  import React3 from "react";
181
159
  import { Input, useTranslation as useTranslation2 } from "@dxos/react-ui";
182
- import { Settings } from "@dxos/react-ui-form";
183
-
184
- // src/containers/StackContainer/StackContainer.tsx
185
- var collectionObjectsFamily = Atom.family((collection) => Atom.make((get) => {
186
- const snapshot = get(AtomObj.make(collection));
187
- return snapshot.objects.map((ref) => get(AtomObj.makeWithReactive(ref))).filter(isNonNullable);
188
- }));
189
- var StackContainer = ({ attendableId, subject: collection }) => {
190
- const { invokePromise } = useOperationInvoker();
191
- const { graph } = useAppGraph();
192
- const { t } = useTranslation3(meta.id);
193
- const allMetadata = useCapabilities(AppCapabilities.Metadata);
194
- const [collapsedSections, setCollapsedSections] = useState2({});
195
- const collectionObjects = useAtomValue(collectionObjectsFamily(collection));
196
- const items = collectionObjects.map((object) => {
197
- const metadata = allMetadata.find((m) => m.id === (Obj.getTypename(object) ?? "never"))?.metadata;
198
- const view = {
199
- // ...stack.sections[object.id],
200
- collapsed: collapsedSections[Obj.getDXN(object).toString()],
201
- title: object?.title ?? // TODO(wittjosiah): `getNode` is not reactive.
202
- toLocalizedString(Graph.getNode(graph, Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label, t)
203
- };
204
- return {
205
- id: Obj.getDXN(object).toString(),
206
- object,
207
- metadata,
208
- view
209
- };
210
- });
211
- const handleDelete = useCallback(async (id) => {
212
- const index = collection.objects.map((object2) => object2.target).filter(isNonNullable).findIndex((section) => Obj.getDXN(section).toString() === id);
213
- const object = collection.objects[index].target;
214
- if (Obj.isObject(object)) {
215
- await invokePromise(SpaceOperation.RemoveObjects, {
216
- objects: [
217
- object
218
- ],
219
- target: collection
220
- });
221
- }
222
- }, [
223
- collection,
224
- invokePromise
225
- ]);
226
- const handleAdd = useCallback(async (id, position) => {
227
- await invokePromise(LayoutOperation.UpdateDialog, {
228
- subject: `${meta.id}.AddSectionDialog`,
229
- blockAlign: "start",
230
- props: {
231
- path: id,
232
- position,
233
- collection
234
- }
235
- });
236
- }, [
237
- collection,
238
- invokePromise
239
- ]);
240
- const handleNavigate = useCallback(async (id) => {
241
- await invokePromise(LayoutOperation.Open, {
242
- subject: [
243
- id
244
- ]
245
- });
246
- }, [
247
- invokePromise
248
- ]);
249
- const handleCollapse = useCallback((id, collapsed) => setCollapsedSections((prev) => ({
250
- ...prev,
251
- [id]: collapsed
252
- })), []);
253
- const handleAddSection = useCallback(() => invokePromise(SpaceOperation.OpenCreateObject, {
254
- target: collection,
255
- navigable: false
256
- }), [
257
- collection,
258
- invokePromise
259
- ]);
260
- return /* @__PURE__ */ React4.createElement(StackItem2.Content, {
261
- toolbar: true,
262
- classNames: "dx-article overflow-hidden border-l border-r border-subdued-separator"
263
- }, /* @__PURE__ */ React4.createElement(Toolbar.Root, null, /* @__PURE__ */ React4.createElement(Toolbar.IconButton, {
264
- icon: "ph--plus--regular",
265
- iconOnly: true,
266
- label: "Add section",
267
- "data-testid": "stack.addSection",
268
- onClick: handleAddSection
269
- })), /* @__PURE__ */ React4.createElement(StackContext.Provider, {
270
- value: {
271
- attendableId,
272
- onCollapse: handleCollapse,
273
- onNavigate: handleNavigate,
274
- onDelete: handleDelete,
275
- onAdd: handleAdd
276
- }
277
- }, /* @__PURE__ */ React4.createElement(Stack, {
278
- orientation: "vertical",
279
- size: "intrinsic",
280
- id: Obj.getDXN(collection).toString(),
281
- "data-testid": "main.stack",
282
- classNames: "overflow-y-auto"
283
- }, items.map((item) => /* @__PURE__ */ React4.createElement(StackSection, {
284
- key: item.id,
285
- ...item
286
- })))));
160
+ import { Settings as SettingsForm } from "@dxos/react-ui-form";
161
+ import { meta as meta2 } from "#meta";
162
+ var StackSettings = ({ settings }) => {
163
+ const { t } = useTranslation2(meta2.id);
164
+ return /* @__PURE__ */ React3.createElement(SettingsForm.Viewport, null, /* @__PURE__ */ React3.createElement(SettingsForm.Section, {
165
+ title: t("settings.title", {
166
+ ns: meta2.id
167
+ })
168
+ }, /* @__PURE__ */ React3.createElement(SettingsForm.Item, {
169
+ title: t("settings.separation.label"),
170
+ description: t("settings.separation.description")
171
+ }, /* @__PURE__ */ React3.createElement(Input.Switch, {
172
+ checked: settings.separation,
173
+ onCheckedChange: (checked) => settings.separation = !!checked
174
+ }))));
287
175
  };
288
-
289
- // src/containers/StackContainer/index.ts
290
- var StackContainer_default = StackContainer;
291
176
  export {
292
- StackContainer_default as default
177
+ StackContext,
178
+ StackSection,
179
+ StackSettings,
180
+ useStack
293
181
  };
294
- //# sourceMappingURL=StackContainer-OLHE5F4E.mjs.map
182
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/StackContext/StackContext.tsx", "../../../../src/components/StackSection/StackSection.tsx", "../../../../src/components/StackSection/CaretDownUp.tsx", "../../../../src/components/StackSettings/StackSettings.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { type AddSectionPosition } from '#types';\n\nexport type StackContextValue = {\n attendableId: string;\n onCollapse: (id: string, collapsed: boolean) => void;\n onNavigate: (id: string) => Promise<void>;\n onDelete: (id: string) => Promise<void>;\n onAdd: (id: string, position: AddSectionPosition) => void;\n};\n\nexport const StackContext = createContext<StackContextValue>({\n attendableId: '',\n onCollapse: () => {},\n onNavigate: async () => {},\n onDelete: async () => {},\n onAdd: () => {},\n});\n\nexport const useStack = () => useContext(StackContext);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as CollapsiblePrimitive from '@radix-ui/react-collapsible';\nimport React, { useMemo, useState } from 'react';\n\nimport { Surface } from '@dxos/app-framework/ui';\nimport { AppSurface } from '@dxos/app-toolkit/ui';\nimport { DropdownMenu, Icon, IconButton, useTranslation } from '@dxos/react-ui';\nimport { useAttentionAttributes } from '@dxos/react-ui-attention';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { getSize, mx } from '@dxos/ui-theme';\n\nimport { meta } from '#meta';\nimport { type StackSectionItem } from '#types';\n\nimport { useStack } from '../StackContext';\nimport { CaretDownUp } from './CaretDownUp';\n\nconst sectionActionDimensions = 'p-1 my-1 shrink-0 min-h-0 w-(--dx-rail-action) h-min';\n\nexport type StackSectionProps = StackSectionItem;\n\nexport const StackSection = ({\n id,\n view,\n object,\n metadata: { icon = 'ph--placeholder--regular' },\n}: StackSectionProps) => {\n const { t } = useTranslation(meta.id);\n const { attendableId: parentAttendableId, onNavigate, onAdd, onCollapse, onDelete } = useStack();\n const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);\n const attendableId = `${parentAttendableId}/${object.id}`;\n const attentionAttrs = useAttentionAttributes(attendableId);\n const stackItem = useMemo(() => ({ id }), [id]);\n const data = useMemo(() => ({ attendableId, subject: object }), [object, attendableId]);\n\n return (\n <CollapsiblePrimitive.Root asChild open={!view.collapsed} onOpenChange={(nextOpen) => onCollapse?.(id, !nextOpen)}>\n <StackItem.Root item={stackItem} role='section' {...attentionAttrs}>\n <StackItem.Heading classNames='dx-attention-surface'>\n <span className='sr-only'>{view.title}</span>\n <StackItem.HeadingStickyContent>\n <DropdownMenu.Root\n {...{\n open: optionsMenuOpen,\n onOpenChange: setOptionsMenuOpen,\n }}\n >\n <DropdownMenu.Trigger asChild>\n <StackItem.SigilButton>\n <Icon icon={icon} classNames='transition-opacity' />\n </StackItem.SigilButton>\n </DropdownMenu.Trigger>\n <DropdownMenu.Portal>\n <DropdownMenu.Content>\n <DropdownMenu.Viewport>\n {view.collapsed ? (\n <DropdownMenu.Item onClick={() => onNavigate(id)} data-testid='section.navigate-to'>\n <Icon icon='ph--arrow-right--regular' />\n <span className='ms-2 grow'>{t('navigate-to-section.label')}</span>\n </DropdownMenu.Item>\n ) : (\n <CollapsiblePrimitive.Trigger asChild>\n <DropdownMenu.Item>\n <CaretDownUp className={getSize(5)} />\n <span className='ms-2 grow'>{t('collapse.label')}</span>\n </DropdownMenu.Item>\n </CollapsiblePrimitive.Trigger>\n )}\n <DropdownMenu.Item onClick={() => onAdd(id, 'before')} data-testid='section.add-before'>\n <Icon icon='ph--arrow-line-up--regular' />\n <span className='ms-2 grow'>{t('add-section-before.label')}</span>\n </DropdownMenu.Item>\n <DropdownMenu.Item onClick={() => onAdd(id, 'after')} data-testid='section.add-after'>\n <Icon icon='ph--arrow-line-down--regular' />\n <span className='ms-2 grow'>{t('add-section-after.label')}</span>\n </DropdownMenu.Item>\n <DropdownMenu.Item onClick={() => onDelete(id)} data-testid='section.remove'>\n <Icon icon='ph--trash--regular' />\n <span className='ms-2 grow'>{t('remove-section.label')}</span>\n </DropdownMenu.Item>\n </DropdownMenu.Viewport>\n <DropdownMenu.Arrow />\n </DropdownMenu.Content>\n </DropdownMenu.Portal>\n </DropdownMenu.Root>\n {view.collapsed ? (\n <CollapsiblePrimitive.Trigger asChild>\n <IconButton\n iconOnly\n variant='ghost'\n label={t('expand.label')}\n icon='ph--caret-up-down--regular'\n classNames={sectionActionDimensions}\n />\n </CollapsiblePrimitive.Trigger>\n ) : (\n <IconButton\n iconOnly\n variant='ghost'\n onClick={() => onNavigate(id)}\n label={t('navigate-to-section.label')}\n icon='ph--arrow-right--regular'\n data-testid='section.navigate-to'\n classNames={sectionActionDimensions}\n />\n )}\n </StackItem.HeadingStickyContent>\n </StackItem.Heading>\n <CollapsiblePrimitive.Content>\n <Surface.Surface type={AppSurface.Section} data={data} limit={1} placeholder={<></>} />\n </CollapsiblePrimitive.Content>\n {view.collapsed && (\n <StackItem.Content classNames='dx-attention-surface'>\n <h2 className={mx('flex items-center p-4 font-medium')}>{view.title}</h2>\n </StackItem.Content>\n )}\n </StackItem.Root>\n </CollapsiblePrimitive.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type ComponentPropsWithoutRef } from 'react';\n\nexport const CaretDownUp = ({ children, ...props }: ComponentPropsWithoutRef<'svg'>) => {\n return (\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' {...props}>\n <rect width='256' height='256' fill='none' />\n <polyline\n points='80 224 128 176 176 224'\n fill='none'\n stroke='currentColor'\n strokeLinecap='round'\n strokeLinejoin='round'\n strokeWidth='16'\n />\n <polyline\n points='80 32 128 80 176 32'\n fill='none'\n stroke='currentColor'\n strokeLinecap='round'\n strokeLinejoin='round'\n strokeWidth='16'\n />\n {children}\n </svg>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Input, useTranslation } from '@dxos/react-ui';\nimport { Settings as SettingsForm } from '@dxos/react-ui-form';\n\nimport { meta } from '#meta';\nimport { type StackSettingsProps } from '#types';\n\nexport const StackSettings = ({ settings }: { settings: StackSettingsProps }) => {\n const { t } = useTranslation(meta.id);\n\n return (\n <SettingsForm.Viewport>\n <SettingsForm.Section title={t('settings.title', { ns: meta.id })}>\n <SettingsForm.Item title={t('settings.separation.label')} description={t('settings.separation.description')}>\n <Input.Switch\n checked={settings.separation}\n onCheckedChange={(checked) => (settings.separation = !!checked)}\n />\n </SettingsForm.Item>\n </SettingsForm.Section>\n </SettingsForm.Viewport>\n );\n};\n"],
5
+ "mappings": ";AAIA,SAASA,eAAeC,kBAAkB;AAYnC,IAAMC,eAAeF,8BAAiC;EAC3DG,cAAc;EACdC,YAAY,MAAA;EAAO;EACnBC,YAAY,YAAA;EAAa;EACzBC,UAAU,YAAA;EAAa;EACvBC,OAAO,MAAA;EAAO;AAChB,CAAA;AAEO,IAAMC,WAAW,MAAMP,WAAWC,YAAAA;;;ACpBzC,YAAYO,0BAA0B;AACtC,OAAOC,UAASC,SAASC,gBAAgB;AAEzC,SAASC,eAAe;AACxB,SAASC,kBAAkB;AAC3B,SAASC,cAAcC,MAAMC,YAAYC,sBAAsB;AAC/D,SAASC,8BAA8B;AACvC,SAASC,iBAAiB;AAC1B,SAASC,SAASC,UAAU;AAE5B,SAASC,YAAY;;;ACVrB,OAAOC,WAA8C;AAE9C,IAAMC,cAAc,CAAC,EAAEC,UAAU,GAAGC,MAAAA,MAAwC;AACjF,SACE,sBAAA,cAACC,OAAAA;IAAIC,OAAM;IAA6BC,SAAQ;IAAe,GAAGH;KAChE,sBAAA,cAACI,QAAAA;IAAKC,OAAM;IAAMC,QAAO;IAAMC,MAAK;MACpC,sBAAA,cAACC,YAAAA;IACCC,QAAO;IACPF,MAAK;IACLG,QAAO;IACPC,eAAc;IACdC,gBAAe;IACfC,aAAY;MAEd,sBAAA,cAACL,YAAAA;IACCC,QAAO;IACPF,MAAK;IACLG,QAAO;IACPC,eAAc;IACdC,gBAAe;IACfC,aAAY;MAEbd,QAAAA;AAGP;;;ADTA,IAAMe,0BAA0B;AAIzB,IAAMC,eAAe,CAAC,EAC3BC,IACAC,MACAC,QACAC,UAAU,EAAEC,OAAO,2BAA0B,EAAE,MAC7B;AAClB,QAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKP,EAAE;AACpC,QAA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ext", "attendableId", "onCollapse", "onNavigate", "onDelete", "onAdd", "useStack", "CollapsiblePrimitive", "React", "useMemo", "useState", "Surface", "AppSurface", "DropdownMenu", "Icon", "IconButton", "useTranslation", "useAttentionAttributes", "StackItem", "getSize", "mx", "meta", "React", "CaretDownUp", "children", "props", "svg", "xmlns", "viewBox", "rect", "width", "height", "fill", "polyline", "points", "stroke", "strokeLinecap", "strokeLinejoin", "strokeWidth", "sectionActionDimensions", "StackSection", "id", "view", "object", "metadata", "icon", "t", "useTranslation", "meta", "attendableId", "parentAttendableId", "onNavigate", "onAdd", "onCollapse", "onDelete", "useStack", "optionsMenuOpen", "setOptionsMenuOpen", "useState", "attentionAttrs", "useAttentionAttributes", "stackItem", "useMemo", "data", "subject", "React", "Root", "asChild", "open", "collapsed", "onOpenChange", "nextOpen", "StackItem", "item", "role", "Heading", "classNames", "span", "className", "title", "HeadingStickyContent", "DropdownMenu", "Trigger", "SigilButton", "Icon", "Portal", "Content", "Viewport", "Item", "onClick", "data-testid", "CaretDownUp", "getSize", "Arrow", "IconButton", "iconOnly", "variant", "label", "Surface", "type", "AppSurface", "Section", "limit", "placeholder", "h2", "mx", "React", "Input", "useTranslation", "Settings", "SettingsForm", "meta", "StackSettings", "settings", "t", "id", "Viewport", "Section", "title", "ns", "Item", "description", "Switch", "checked", "separation", "onCheckedChange"]
7
+ }
@@ -0,0 +1,7 @@
1
+ // src/containers/index.ts
2
+ import { lazy } from "react";
3
+ var StackContainer = lazy(() => import("../StackContainer-KZ5Q5YKJ.mjs"));
4
+ export {
5
+ StackContainer
6
+ };
7
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/containers/index.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type ComponentType, lazy } from 'react';\n\nexport const StackContainer: ComponentType<any> = lazy(() => import('./StackContainer'));\n"],
5
+ "mappings": ";AAIA,SAA6BA,YAAY;AAElC,IAAMC,iBAAqCD,KAAK,MAAM,OAAO,gCAAA,CAAA;",
6
+ "names": ["lazy", "StackContainer"]
7
+ }
@@ -0,0 +1,15 @@
1
+ import {
2
+ SectionSchema,
3
+ StackViewType
4
+ } from "./chunk-IPU3C6TT.mjs";
5
+ import {
6
+ SECTION_IDENTIFIER,
7
+ meta
8
+ } from "./chunk-3ISQZKGO.mjs";
9
+ export {
10
+ SECTION_IDENTIFIER,
11
+ SectionSchema,
12
+ StackViewType,
13
+ meta
14
+ };
15
+ //# sourceMappingURL=index.mjs.map