@salilvnair/dui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +185 -0
  3. package/dist/chunks/EditorView.shell-BGH2VhWM.js +460 -0
  4. package/dist/chunks/EditorView.shell-BGH2VhWM.js.map +1 -0
  5. package/dist/chunks/daakia-icons-DxWnX_IQ.js +1726 -0
  6. package/dist/chunks/daakia-icons-DxWnX_IQ.js.map +1 -0
  7. package/dist/icons/daakia-icons.d.ts +304 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.js +17032 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/lib/components/button/AIButtonView.d.ts +20 -0
  12. package/dist/lib/components/button/ButtonView.d.ts +28 -0
  13. package/dist/lib/components/button/DropDownButtonView.d.ts +19 -0
  14. package/dist/lib/components/button/IconButtonView.d.ts +22 -0
  15. package/dist/lib/components/button/SegmentedView.d.ts +17 -0
  16. package/dist/lib/components/button/SplitButtonView.d.ts +23 -0
  17. package/dist/lib/components/chips/ChipView.d.ts +21 -0
  18. package/dist/lib/components/display/CodeBlockView.d.ts +11 -0
  19. package/dist/lib/components/display/ColoredTextView.d.ts +18 -0
  20. package/dist/lib/components/display/CopyButtonView.d.ts +11 -0
  21. package/dist/lib/components/display/DataTableView.d.ts +27 -0
  22. package/dist/lib/components/display/DottedCardView.d.ts +10 -0
  23. package/dist/lib/components/display/EmptyStateView.d.ts +14 -0
  24. package/dist/lib/components/display/ExpandableLogEntryView.d.ts +14 -0
  25. package/dist/lib/components/display/FeatureCategoryView.d.ts +18 -0
  26. package/dist/lib/components/display/HudView.d.ts +25 -0
  27. package/dist/lib/components/display/JsonTreeView.d.ts +11 -0
  28. package/dist/lib/components/display/LiveColorCustomizer.d.ts +21 -0
  29. package/dist/lib/components/display/LoaderView.d.ts +12 -0
  30. package/dist/lib/components/display/MarkdownView.d.ts +19 -0
  31. package/dist/lib/components/display/PromptCardView.d.ts +33 -0
  32. package/dist/lib/components/display/PromptLibraryEditorView.d.ts +32 -0
  33. package/dist/lib/components/display/PromptLibraryListView.d.ts +30 -0
  34. package/dist/lib/components/display/StageView.d.ts +26 -0
  35. package/dist/lib/components/display/StatsCardView.d.ts +15 -0
  36. package/dist/lib/components/display/StatusIndicatorView.d.ts +14 -0
  37. package/dist/lib/components/display/ToastView.d.ts +19 -0
  38. package/dist/lib/components/display/YamlKeyChip.d.ts +15 -0
  39. package/dist/lib/components/input/CheckboxView.d.ts +15 -0
  40. package/dist/lib/components/input/DebugEditorView.d.ts +26 -0
  41. package/dist/lib/components/input/DiffEditorView.d.ts +18 -0
  42. package/dist/lib/components/input/DiffEditorView.fallback.d.ts +2 -0
  43. package/dist/lib/components/input/DiffEditorView.monaco.d.ts +2 -0
  44. package/dist/lib/components/input/DurationInputView.d.ts +15 -0
  45. package/dist/lib/components/input/EditorView.d.ts +222 -0
  46. package/dist/lib/components/input/EditorView.fallback.d.ts +10 -0
  47. package/dist/lib/components/input/EditorView.monaco.d.ts +2 -0
  48. package/dist/lib/components/input/EditorView.shell.d.ts +13 -0
  49. package/dist/lib/components/input/FormDataTableView.d.ts +22 -0
  50. package/dist/lib/components/input/HiddenKeyValueItemView.d.ts +22 -0
  51. package/dist/lib/components/input/HighlightedInputView.d.ts +26 -0
  52. package/dist/lib/components/input/KeyValueTableRowView.d.ts +31 -0
  53. package/dist/lib/components/input/KeyValueTableView.d.ts +59 -0
  54. package/dist/lib/components/input/MergedInputView.d.ts +43 -0
  55. package/dist/lib/components/input/MultilineInputView.d.ts +15 -0
  56. package/dist/lib/components/input/SearchInputView.d.ts +17 -0
  57. package/dist/lib/components/input/SegmentedControlView.d.ts +23 -0
  58. package/dist/lib/components/input/SelectInputView.d.ts +31 -0
  59. package/dist/lib/components/input/SelectTextInputView.d.ts +44 -0
  60. package/dist/lib/components/input/SliderView.d.ts +15 -0
  61. package/dist/lib/components/input/TabView.d.ts +28 -0
  62. package/dist/lib/components/input/TagInputView.d.ts +10 -0
  63. package/dist/lib/components/input/TextInputView.d.ts +36 -0
  64. package/dist/lib/components/input/ThemeCardSelectorView.d.ts +18 -0
  65. package/dist/lib/components/input/ToggleSwitchView.d.ts +19 -0
  66. package/dist/lib/components/layout/BottomPanelView.d.ts +16 -0
  67. package/dist/lib/components/layout/CollapsibleSectionView.d.ts +14 -0
  68. package/dist/lib/components/layout/DebugView.d.ts +63 -0
  69. package/dist/lib/components/layout/FolderView.d.ts +85 -0
  70. package/dist/lib/components/layout/ResizablePanelView.d.ts +10 -0
  71. package/dist/lib/components/layout/SettingsNavView.d.ts +29 -0
  72. package/dist/lib/components/layout/SideNavView.d.ts +39 -0
  73. package/dist/lib/components/layout/SpacerView.d.ts +7 -0
  74. package/dist/lib/components/layout/SplitPanelView.d.ts +33 -0
  75. package/dist/lib/components/modal/ContextMenuView.d.ts +28 -0
  76. package/dist/lib/components/modal/InfoPopupView.d.ts +17 -0
  77. package/dist/lib/components/modal/ModalView.d.ts +41 -0
  78. package/dist/lib/components/rearrange/RearrangeView.d.ts +34 -0
  79. package/dist/lib/components/tabs/PilledTabView.d.ts +19 -0
  80. package/dist/lib/components/tabs/TabBarView.d.ts +28 -0
  81. package/dist/lib/components/tabs/TabView.d.ts +34 -0
  82. package/dist/lib/core/ButtonBase.d.ts +28 -0
  83. package/dist/lib/core/CardBase.d.ts +21 -0
  84. package/dist/lib/core/ChipBase.d.ts +21 -0
  85. package/dist/lib/core/DisplayBase.d.ts +21 -0
  86. package/dist/lib/core/DuiContext.d.ts +53 -0
  87. package/dist/lib/core/DuiTokens.d.ts +115 -0
  88. package/dist/lib/core/DuiTypes.d.ts +29 -0
  89. package/dist/lib/core/EditorBase.d.ts +13 -0
  90. package/dist/lib/core/InputBase.d.ts +25 -0
  91. package/dist/lib/core/MenuBase.d.ts +23 -0
  92. package/dist/lib/core/NavBase.d.ts +26 -0
  93. package/dist/lib/core/OverlayBase.d.ts +20 -0
  94. package/dist/lib/core/SelectBase.d.ts +22 -0
  95. package/dist/lib/core/TabBase.d.ts +25 -0
  96. package/dist/lib/core/TableBase.d.ts +19 -0
  97. package/dist/lib/core/ToggleBase.d.ts +19 -0
  98. package/dist/lib/core/index.d.ts +25 -0
  99. package/dist/lib/index.d.ts +159 -0
  100. package/dist/lib/monaco-runtime.d.ts +29 -0
  101. package/dist/lib/theme/core.d.ts +8 -0
  102. package/dist/lib/theme/editor.d.ts +11 -0
  103. package/dist/lib/theme/utils.d.ts +6 -0
  104. package/dist/monaco-setup.d.ts +4 -0
  105. package/dist/monaco-setup.js +883 -0
  106. package/dist/monaco-setup.js.map +1 -0
  107. package/dist/style.css +1 -0
  108. package/dist/style.js +2 -0
  109. package/dist/style.js.map +1 -0
  110. package/dist/theme/core.js +191 -0
  111. package/dist/theme/core.js.map +1 -0
  112. package/dist/theme/editor.js +104 -0
  113. package/dist/theme/editor.js.map +1 -0
  114. package/dist/theme/utils.js +67 -0
  115. package/dist/theme/utils.js.map +1 -0
  116. package/package.json +81 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Salil V Nair
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,185 @@
1
+ # @salilvnair/dui
2
+
3
+ Daakia UI — a React component library shared across ck8t and daakia. Ships as
4
+ a compiled ESM bundle with generated `.d.ts` types; peer dependencies are
5
+ `react`, `react-dom`, and `zustand`.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @salilvnair/dui react react-dom zustand
11
+ ```
12
+
13
+ Import the stylesheet once in your app's entry point:
14
+
15
+ ```ts
16
+ import '@salilvnair/dui/style.css';
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```tsx
22
+ import { ButtonView, TabView, DuiProvider } from '@salilvnair/dui';
23
+
24
+ function App() {
25
+ return (
26
+ <DuiProvider size="md">
27
+ <ButtonView>Click me</ButtonView>
28
+ </DuiProvider>
29
+ );
30
+ }
31
+ ```
32
+
33
+ ## Monaco is optional
34
+
35
+ `EditorView`, `DiffEditorView`, and `DebugEditorView` render a lightweight
36
+ plain-text fallback by default — **`@monaco-editor/react` and `monaco-editor`
37
+ are not required dependencies.** If you don't use these three components,
38
+ you never need to install them.
39
+
40
+ To get the real Monaco-backed editor:
41
+
42
+ ```bash
43
+ npm install @monaco-editor/react monaco-editor
44
+ ```
45
+
46
+ ```ts
47
+ // once, at app bootstrap
48
+ import '@salilvnair/dui/monaco-setup';
49
+ ```
50
+
51
+ This self-hosts Monaco (inline workers, no CDN — works under strict CSP,
52
+ e.g. VS Code webviews) and registers the real editor implementation.
53
+ Skipping this import is fine; `EditorView` keeps working as a plain textarea.
54
+
55
+ ### Why not just install Monaco automatically?
56
+
57
+ `@monaco-editor/react` doesn't depend on `monaco-editor` itself — it lazy-loads
58
+ Monaco from a public CDN by default. If your environment blocks that CDN (most
59
+ VS Code extension webviews, offline apps, strict-CSP deployments do), the only
60
+ correct answer is genuine self-hosting via `monaco-setup`, which is why that
61
+ import is explicit rather than automatic.
62
+
63
+ ### Extending MarkdownView's language support
64
+
65
+ `MarkdownView`'s syntax highlighting registers a curated set of languages
66
+ (js/ts/json/xml/html/css/bash/yaml/python/sql/ruby/rust/csharp/kotlin/graphql/markdown)
67
+ via `highlight.js/lib/core` rather than the full ~190-language `highlight.js`
68
+ package, to keep the bundle small. Adding a language currently requires a
69
+ change in this repo and a version bump — there's no way to register
70
+ additional languages from a consuming app yet.
71
+
72
+ ## Theming
73
+
74
+ ```ts
75
+ import { SCHEMA } from '@salilvnair/dui/theme/core';
76
+ import { generateYaml } from '@salilvnair/dui/theme/utils';
77
+ import { ThemeVarEditor } from '@salilvnair/dui/theme/editor';
78
+ ```
79
+
80
+ All colors are CSS custom properties (`--color-*`) — override them on
81
+ `:root` or scope them to a container to retheme without recompiling.
82
+
83
+ ---
84
+
85
+ ## Publishing to npm
86
+
87
+ > This section is for library maintainers.
88
+
89
+ ### Prerequisites
90
+
91
+ 1. Node.js 18+ and npm 9+
92
+ 2. Publish access to the `@salilvnair` scope: `npm login`
93
+
94
+ ### Step 1 — Bump the version
95
+
96
+ ```bash
97
+ npm version patch # bug fix: 1.0.0 -> 1.0.1
98
+ npm version minor # new feature: 1.0.0 -> 1.1.0
99
+ npm version major # breaking: 1.0.0 -> 2.0.0
100
+ ```
101
+
102
+ ### Step 2 — Build
103
+
104
+ `prepublishOnly` runs this automatically on `npm publish`, but build first to
105
+ inspect the output:
106
+
107
+ ```bash
108
+ npm run build:lib
109
+ ```
110
+
111
+ Verify `dist/` contains (at minimum): `index.js`, `index.d.ts`,
112
+ `monaco-setup.js`, `monaco-setup.d.ts`, `style.css`, `theme/*.js`.
113
+
114
+ **Sanity-check the Monaco boundary** — this is the one thing worth manually
115
+ re-verifying after any build config change: `dist/index.js` must contain no
116
+ `@monaco-editor/react` or `monaco-editor` import. Only `dist/monaco-setup.js`
117
+ (and its `dist/chunks/*` dependency) should reference them:
118
+
119
+ ```bash
120
+ grep -l "monaco-editor" dist/*.js dist/chunks/*.js
121
+ # should list only monaco-setup.js and its chunk — never index.js
122
+ ```
123
+
124
+ ### Step 3 — Verify what will be published
125
+
126
+ ```bash
127
+ npm pack --dry-run
128
+ ```
129
+
130
+ Only `dist/`, `README.md`, `LICENSE`, and `package.json` should appear — no
131
+ `src/`.
132
+
133
+ ### Step 4 — Test the tarball locally
134
+
135
+ ```bash
136
+ npm pack
137
+ # creates salilvnair-dui-X.Y.Z.tgz
138
+
139
+ # in a consumer app:
140
+ npm install /path/to/salilvnair-dui-X.Y.Z.tgz
141
+ ```
142
+
143
+ Confirm both paths work: a component that never imports Monaco (build should
144
+ succeed with `@monaco-editor/react`/`monaco-editor` absent from
145
+ node_modules), and — with those installed plus `@salilvnair/dui/monaco-setup`
146
+ imported — a real Monaco-backed `EditorView`.
147
+
148
+ ### Step 5 — Publish
149
+
150
+ Scoped packages default to private, so `--access public` is required:
151
+
152
+ ```bash
153
+ npm publish --access public
154
+ # rehearsal first:
155
+ npm publish --dry-run --access public
156
+ ```
157
+
158
+ ### Step 6 — Push tags
159
+
160
+ ```bash
161
+ git push && git push --tags
162
+ ```
163
+
164
+ ### Release checklist
165
+
166
+ - [ ] `npm version` bumped
167
+ - [ ] `npm run build:lib` succeeds
168
+ - [ ] `npm pack --dry-run` shows only `dist/`, `README.md`, `LICENSE`
169
+ - [ ] Monaco boundary check: `@monaco-editor/react`/`monaco-editor` only referenced from `monaco-setup.js` + its chunk, never `index.js`
170
+ - [ ] Tarball tested in a consumer app, both without and with Monaco installed
171
+ - [ ] `npm publish --access public` completed
172
+ - [ ] `git push && git push --tags`
173
+
174
+ ### Troubleshooting
175
+
176
+ **Consumer's build fails resolving `@monaco-editor/react`even though they never use `EditorView`**
177
+ → Something reintroduced a static import of it into `index.js`. Re-run the
178
+ Monaco boundary grep in Step 2 — this is the one regression this package
179
+ must never ship.
180
+
181
+ **Consumer's Monaco editor works in dev but hits a blocked CDN in production**
182
+ → They installed the Monaco packages but never imported
183
+ `@salilvnair/dui/monaco-setup`. `EditorView` never falls back to the CDN
184
+ loader on its own — it only ever renders the plain-text fallback or the
185
+ self-hosted Monaco registered by `monaco-setup`.
@@ -0,0 +1,460 @@
1
+ import { jsx as d, Fragment as A, jsxs as I } from "react/jsx-runtime";
2
+ import { useMemo as S, useContext as P, createContext as T, useRef as _, useEffect as v, useState as E, useSyncExternalStore as $ } from "react";
3
+ import { createPortal as C } from "react-dom";
4
+ import { g as F } from "./daakia-icons-DxWnX_IQ.js";
5
+ const et = {
6
+ /** Standard form controls: text input, select, duration, search, highlighted input */
7
+ input: { xxs: 16, xs: 20, sm: 24, md: 28, lg: 36, xl: 40, xxl: 48, xxxl: 56 },
8
+ /** Push buttons (primary, secondary, ghost, danger) */
9
+ button: { xxs: 16, xs: 20, sm: 24, md: 28, lg: 36, xl: 40, xxl: 48, xxxl: 56 },
10
+ /** Pill tabs, segment controls */
11
+ tab: { xxs: 16, xs: 20, sm: 24, md: 28, lg: 36, xl: 40, xxl: 48, xxxl: 56 },
12
+ /** Sidebar nav items, settings nav links */
13
+ nav: { xxs: 20, xs: 24, sm: 28, md: 32, lg: 36, xl: 44, xxl: 52, xxxl: 60 },
14
+ /** Context-menu items, dropdown options, sub-menu rows */
15
+ menu: { xxs: 14, xs: 18, sm: 22, md: 26, lg: 30, xl: 36, xxl: 42, xxxl: 48 },
16
+ /** Table / KV-table rows */
17
+ table: { xxs: 18, xs: 22, sm: 26, md: 30, lg: 36, xl: 40, xxl: 46, xxxl: 54 },
18
+ /** Card container min-height (loosely applied) */
19
+ card: { xxs: 28, xs: 36, sm: 48, md: 64, lg: 80, xl: 96, xxl: 112, xxxl: 128 }
20
+ }, nt = {
21
+ xxs: 10,
22
+ xs: 12,
23
+ sm: 16,
24
+ md: 20,
25
+ lg: 24,
26
+ xl: 28,
27
+ xxl: 32,
28
+ xxxl: 38
29
+ }, rt = {
30
+ xxs: { trackW: 18, trackH: 10, thumb: 8 },
31
+ xs: { trackW: 24, trackH: 14, thumb: 10 },
32
+ sm: { trackW: 28, trackH: 16, thumb: 12 },
33
+ md: { trackW: 36, trackH: 20, thumb: 16 },
34
+ lg: { trackW: 44, trackH: 24, thumb: 20 },
35
+ xl: { trackW: 52, trackH: 28, thumb: 24 },
36
+ xxl: { trackW: 60, trackH: 32, thumb: 28 },
37
+ xxxl: { trackW: 68, trackH: 36, thumb: 32 }
38
+ }, ot = {
39
+ xxs: { box: 10, icon: 6 },
40
+ xs: { box: 12, icon: 8 },
41
+ sm: { box: 14, icon: 9 },
42
+ md: { box: 16, icon: 11 },
43
+ lg: { box: 18, icon: 13 },
44
+ xl: { box: 20, icon: 15 },
45
+ xxl: { box: 22, icon: 17 },
46
+ xxxl: { box: 26, icon: 20 }
47
+ }, xt = {
48
+ xxs: 8,
49
+ xs: 10,
50
+ sm: 11,
51
+ md: 12,
52
+ lg: 14,
53
+ xl: 16,
54
+ xxl: 18,
55
+ xxxl: 20
56
+ }, st = {
57
+ xxs: "8px",
58
+ xs: "9px",
59
+ sm: "10px",
60
+ md: "11px",
61
+ lg: "12px",
62
+ xl: "13px",
63
+ xxl: "14px",
64
+ xxxl: "16px"
65
+ }, it = {
66
+ xxs: "2px",
67
+ xs: "3px",
68
+ sm: "4px",
69
+ md: "5px",
70
+ lg: "7px",
71
+ xl: "9px",
72
+ xxl: "11px",
73
+ xxxl: "14px"
74
+ }, O = {
75
+ xxs: 10,
76
+ xs: 11,
77
+ sm: 11,
78
+ md: 12,
79
+ lg: 13,
80
+ xl: 14,
81
+ xxl: 15,
82
+ xxxl: 16
83
+ }, lt = {
84
+ xxs: "4px",
85
+ xs: "6px",
86
+ sm: "8px",
87
+ md: "10px",
88
+ lg: "12px",
89
+ xl: "16px",
90
+ xxl: "20px",
91
+ xxxl: "24px"
92
+ }, ct = {
93
+ xxs: "2px",
94
+ xs: "3px",
95
+ sm: "4px",
96
+ md: "5px",
97
+ lg: "6px",
98
+ xl: "8px",
99
+ xxl: "10px",
100
+ xxxl: "12px"
101
+ }, z = {
102
+ none: "0px",
103
+ sm: "3px",
104
+ md: "4px",
105
+ lg: "6px",
106
+ full: "999px"
107
+ }, at = {
108
+ xxs: "2px",
109
+ xs: "3px",
110
+ // DUI_RADIUS_MAP.sm
111
+ sm: "4px",
112
+ // DUI_RADIUS_MAP.md
113
+ md: "4px",
114
+ // DUI_RADIUS_MAP.md
115
+ lg: "6px",
116
+ // DUI_RADIUS_MAP.lg
117
+ xl: "6px",
118
+ // DUI_RADIUS_MAP.lg
119
+ xxl: "8px",
120
+ xxxl: "10px"
121
+ }, B = {
122
+ sm: "80px",
123
+ md: "120px",
124
+ default: "auto",
125
+ lg: "200px",
126
+ fullWidth: "100%",
127
+ maxContent: "max-content",
128
+ fw: "100%",
129
+ mx: "max-content"
130
+ }, G = { size: "md" }, R = T(G);
131
+ function ut({
132
+ size: t = "md",
133
+ width: e,
134
+ borderRadius: r,
135
+ color: o,
136
+ defaultColor: p,
137
+ activeColor: i,
138
+ fontStyle: a,
139
+ children: x
140
+ }) {
141
+ const f = S(
142
+ () => ({ size: t, width: e, borderRadius: r, color: o, defaultColor: p, activeColor: i, fontStyle: a }),
143
+ [t, e, r, o, p, i, a]
144
+ );
145
+ return /* @__PURE__ */ d(R.Provider, { value: f, children: x });
146
+ }
147
+ function W() {
148
+ return P(R);
149
+ }
150
+ function N(t, e) {
151
+ return t === void 0 ? e : typeof t == "number" ? `${t}px` : z[t];
152
+ }
153
+ function j(t) {
154
+ return t ? B[t] : "auto";
155
+ }
156
+ function dt(t) {
157
+ const e = W();
158
+ return S(
159
+ () => ({
160
+ borderRadius: N(e.borderRadius, t),
161
+ width: j(e.width),
162
+ color: e.color,
163
+ defaultColor: e.defaultColor,
164
+ activeColor: e.activeColor,
165
+ fontStyle: e.fontStyle
166
+ }),
167
+ [e, t]
168
+ );
169
+ }
170
+ function pt(t, e = {}) {
171
+ const r = W(), o = t ?? r.size;
172
+ return {
173
+ fontSize: O[o]
174
+ };
175
+ }
176
+ const q = { auto: "max-content", sm: "140px", md: "180px", lg: "220px" };
177
+ function X(t) {
178
+ return !t || t === "auto" ? "max-content" : typeof t == "number" ? `${t}px` : q[t] || "max-content";
179
+ }
180
+ function H({
181
+ items: t,
182
+ onClose: e,
183
+ rounded: r
184
+ }) {
185
+ const [o, p] = E(null);
186
+ return /* @__PURE__ */ d(A, { children: t.map((i) => /* @__PURE__ */ d(
187
+ Z,
188
+ {
189
+ item: i,
190
+ onClose: e,
191
+ rounded: r,
192
+ activeSubId: o,
193
+ onSubOpen: p
194
+ },
195
+ i.id
196
+ )) });
197
+ }
198
+ function Z({
199
+ item: t,
200
+ onClose: e,
201
+ rounded: r,
202
+ activeSubId: o,
203
+ onSubOpen: p
204
+ }) {
205
+ const i = _(null), a = _(null);
206
+ if (t.separator)
207
+ return /* @__PURE__ */ d("div", { style: { height: "1px", background: "var(--color-surface-border)", margin: "4px 0" } });
208
+ const x = !!(t.children && t.children.length > 0), f = t.danger, m = x && o === t.id, y = () => {
209
+ p(x ? t.id : null);
210
+ }, u = (n) => {
211
+ var c;
212
+ if (n.stopPropagation(), !t.disabled) {
213
+ if (x) {
214
+ p(t.id);
215
+ return;
216
+ }
217
+ (c = t.onClick) == null || c.call(t), e();
218
+ }
219
+ };
220
+ return v(() => {
221
+ if (!m || !i.current || !a.current) return;
222
+ const n = a.current;
223
+ n.style.visibility = "hidden";
224
+ const c = requestAnimationFrame(() => {
225
+ if (!i.current || !a.current) return;
226
+ const l = i.current.getBoundingClientRect();
227
+ n.style.top = `${l.top - 4}px`, n.style.left = `${l.right + 4}px`;
228
+ const s = n.getBoundingClientRect();
229
+ s.right > window.innerWidth - 8 && (n.style.left = `${l.left - s.width - 4}px`), s.bottom > window.innerHeight - 8 && (n.style.top = `${window.innerHeight - s.height - 8}px`), n.style.visibility = "visible";
230
+ });
231
+ return () => cancelAnimationFrame(c);
232
+ }, [m]), /* @__PURE__ */ I(
233
+ "div",
234
+ {
235
+ ref: i,
236
+ onMouseEnter: y,
237
+ style: { position: "relative" },
238
+ children: [
239
+ /* @__PURE__ */ I(
240
+ "div",
241
+ {
242
+ onClick: u,
243
+ className: `dui_ctx-menu__item${f ? " dui_ctx-menu__item--danger" : ""}${t.disabled ? " dui_ctx-menu__item--disabled" : ""}`,
244
+ style: {
245
+ display: "flex",
246
+ alignItems: "center",
247
+ gap: "8px",
248
+ padding: "8px 10px",
249
+ borderRadius: r ? "5px" : "0px",
250
+ fontSize: "12px",
251
+ fontWeight: 500,
252
+ cursor: t.disabled ? "default" : "pointer",
253
+ opacity: t.disabled ? 0.45 : 1,
254
+ color: f ? "var(--color-error)" : "var(--color-text-secondary)",
255
+ userSelect: "none"
256
+ },
257
+ children: [
258
+ t.icon && /* @__PURE__ */ d("span", { style: { width: "14px", display: "flex", alignItems: "center", flexShrink: 0, color: t.iconColor ?? (f ? "var(--color-error)" : "var(--color-text-muted)") }, children: t.icon }),
259
+ /* @__PURE__ */ d("span", { style: { flex: 1, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: t.label }),
260
+ t.shortcut && !x && /* @__PURE__ */ d("span", { style: { fontSize: "10px", color: "var(--color-text-muted)", marginLeft: "12px", flexShrink: 0 }, children: t.shortcut }),
261
+ x && /* @__PURE__ */ d(F, { size: 10, style: { color: "var(--color-text-muted)", flexShrink: 0, marginLeft: "8px" } })
262
+ ]
263
+ }
264
+ ),
265
+ x && m && C(
266
+ /* @__PURE__ */ d(
267
+ "div",
268
+ {
269
+ ref: a,
270
+ "data-dui-ctx-menu": "true",
271
+ style: {
272
+ position: "fixed",
273
+ visibility: "hidden",
274
+ zIndex: 99999,
275
+ background: "var(--color-elevated, var(--color-surface-bg))",
276
+ border: "1px solid var(--color-surface-border)",
277
+ borderRadius: r ? "7px" : "0px",
278
+ padding: "4px",
279
+ minWidth: "200px",
280
+ width: "max-content",
281
+ boxShadow: "0 12px 40px rgba(0,0,0,.35)"
282
+ },
283
+ children: /* @__PURE__ */ d(H, { items: t.children, onClose: e, rounded: r })
284
+ }
285
+ ),
286
+ document.body
287
+ )
288
+ ]
289
+ }
290
+ );
291
+ }
292
+ function Y({
293
+ items: t,
294
+ anchorEl: e,
295
+ open: r,
296
+ onClose: o,
297
+ width: p = "auto",
298
+ rounded: i = !0,
299
+ matchAnchorWidth: a = !1,
300
+ position: x,
301
+ align: f = "auto"
302
+ }) {
303
+ const m = _(null);
304
+ if (v(() => {
305
+ if (!r) return;
306
+ const u = (n) => {
307
+ var l, s;
308
+ const c = n.target;
309
+ (l = m.current) != null && l.contains(c) || e != null && e.contains(c) || (s = c.closest) != null && s.call(c, "[data-dui-ctx-menu]") || o();
310
+ };
311
+ return document.addEventListener("mousedown", u), () => document.removeEventListener("mousedown", u);
312
+ }, [r, e, o]), v(() => {
313
+ if (!r) return;
314
+ const u = (n) => {
315
+ if (n.key === "Escape") {
316
+ o();
317
+ return;
318
+ }
319
+ const c = n.key.toUpperCase(), l = t.find((s) => s.disabled || s.separator || !s.shortcut || !s.onClick ? !1 : s.shortcut === "⌫" ? n.key === "Backspace" || n.key === "Delete" : s.shortcut.toUpperCase() === c);
320
+ l && (n.preventDefault(), l.onClick(), o());
321
+ };
322
+ return document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u);
323
+ }, [r, o, t]), v(() => {
324
+ if (!r || !m.current) return;
325
+ const u = m.current, n = () => {
326
+ const l = u.scrollWidth, s = u.scrollHeight;
327
+ let h, b, w = 0;
328
+ if (x)
329
+ h = x.x, b = x.y, w = x.y;
330
+ else if (e) {
331
+ const g = e.getBoundingClientRect();
332
+ f === "right" ? h = g.right - l : f === "left" ? h = g.left : h = g.left + l <= window.innerWidth - 8 ? g.left : g.right - l, b = g.bottom + 4, w = g.top, a && (u.style.width = g.width + "px");
333
+ } else
334
+ return;
335
+ h + l > window.innerWidth - 8 && (h = Math.max(8, window.innerWidth - l - 8)), h < 8 && (h = 8), b + s > window.innerHeight - 8 && (b = Math.max(8, w - s - 4)), u.style.left = h + "px", u.style.top = b + "px";
336
+ };
337
+ n();
338
+ const c = requestAnimationFrame(n);
339
+ return window.addEventListener("scroll", n, { passive: !0, capture: !0 }), window.addEventListener("resize", n, { passive: !0 }), () => {
340
+ cancelAnimationFrame(c), window.removeEventListener("scroll", n, { capture: !0 }), window.removeEventListener("resize", n);
341
+ };
342
+ }, [r, e, x, a, f]), !r) return null;
343
+ const y = X(p);
344
+ return C(
345
+ /* @__PURE__ */ d(
346
+ "div",
347
+ {
348
+ ref: m,
349
+ "data-dui-ctx-menu": "true",
350
+ style: {
351
+ position: "fixed",
352
+ zIndex: 99998,
353
+ width: y,
354
+ minWidth: "140px",
355
+ background: "var(--color-elevated, var(--color-surface-bg))",
356
+ border: "1px solid var(--color-surface-border)",
357
+ borderRadius: i ? "8px" : "0px",
358
+ padding: "4px",
359
+ boxShadow: "0 12px 40px rgba(0,0,0,.35), 0 0 0 1px var(--color-panel-border, rgba(255,255,255,.04))",
360
+ animation: "dui_menu-in 120ms ease-out"
361
+ },
362
+ children: /* @__PURE__ */ d(H, { items: t, onClose: o, rounded: i })
363
+ }
364
+ ),
365
+ document.body
366
+ );
367
+ }
368
+ let U = "idle", M = null, L = null;
369
+ const k = /* @__PURE__ */ new Set();
370
+ function K() {
371
+ for (const t of k) t();
372
+ }
373
+ function D() {
374
+ return U;
375
+ }
376
+ function ft(t) {
377
+ M = t;
378
+ }
379
+ function mt(t) {
380
+ L = t;
381
+ }
382
+ function ht() {
383
+ return M;
384
+ }
385
+ function gt() {
386
+ return L;
387
+ }
388
+ function bt() {
389
+ U = "ready", K();
390
+ }
391
+ function vt() {
392
+ return $(
393
+ (t) => (k.add(t), () => k.delete(t)),
394
+ D,
395
+ D
396
+ );
397
+ }
398
+ function yt({
399
+ bordered: t,
400
+ containerHeight: e,
401
+ children: r,
402
+ contextMenuMode: o = "native",
403
+ contextMenuItems: p,
404
+ accentColor: i
405
+ }) {
406
+ const [a, x] = E(null), f = o === "dui";
407
+ return /* @__PURE__ */ I(
408
+ "div",
409
+ {
410
+ className: `dui-editor-shell relative${t ? " rounded border border-[var(--color-surface-border)]" : ""}`,
411
+ style: { height: e, width: "100%", position: "relative", ...i ? { "--editor-accent": i } : {} },
412
+ onContextMenu: f ? (m) => {
413
+ m.preventDefault(), x({ x: m.clientX, y: m.clientY });
414
+ } : void 0,
415
+ children: [
416
+ r,
417
+ f && p && /* @__PURE__ */ d(
418
+ Y,
419
+ {
420
+ open: !!a,
421
+ anchorEl: null,
422
+ position: a ?? void 0,
423
+ items: p,
424
+ onClose: () => x(null)
425
+ }
426
+ )
427
+ ]
428
+ }
429
+ );
430
+ }
431
+ export {
432
+ Y as C,
433
+ at as D,
434
+ yt as E,
435
+ ct as a,
436
+ lt as b,
437
+ xt as c,
438
+ st as d,
439
+ et as e,
440
+ N as f,
441
+ nt as g,
442
+ z as h,
443
+ rt as i,
444
+ it as j,
445
+ pt as k,
446
+ vt as l,
447
+ ht as m,
448
+ gt as n,
449
+ ot as o,
450
+ O as p,
451
+ B as q,
452
+ j as r,
453
+ ut as s,
454
+ dt as t,
455
+ W as u,
456
+ bt as v,
457
+ ft as w,
458
+ mt as x
459
+ };
460
+ //# sourceMappingURL=EditorView.shell-BGH2VhWM.js.map