@uipath/apollo-wind 0.10.0 → 0.11.0-pr295.af4e744
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/dist/components/custom/canvas-studio.cjs +133 -0
- package/dist/components/custom/canvas-studio.d.ts +99 -0
- package/dist/components/custom/canvas-studio.js +93 -0
- package/dist/components/custom/canvas.cjs +44 -0
- package/dist/components/custom/canvas.d.ts +14 -0
- package/dist/components/custom/canvas.js +10 -0
- package/dist/components/custom/chat-composer.cjs +105 -0
- package/dist/components/custom/chat-composer.d.ts +15 -0
- package/dist/components/custom/chat-composer.js +71 -0
- package/dist/components/custom/chat-first-experience.cjs +87 -0
- package/dist/components/custom/chat-first-experience.d.ts +24 -0
- package/dist/components/custom/chat-first-experience.js +53 -0
- package/dist/components/custom/chat-prompt-suggestions.cjs +49 -0
- package/dist/components/custom/chat-prompt-suggestions.d.ts +18 -0
- package/dist/components/custom/chat-prompt-suggestions.js +15 -0
- package/dist/components/custom/chat-steps-view.cjs +308 -0
- package/dist/components/custom/chat-steps-view.d.ts +38 -0
- package/dist/components/custom/chat-steps-view.js +274 -0
- package/dist/components/custom/flow-node.cjs +76 -0
- package/dist/components/custom/flow-node.d.ts +20 -0
- package/dist/components/custom/flow-node.js +42 -0
- package/dist/components/custom/flow-properties-bar.cjs +103 -0
- package/dist/components/custom/flow-properties-bar.d.ts +21 -0
- package/dist/components/custom/flow-properties-bar.js +69 -0
- package/dist/components/custom/flow-properties-expanded.cjs +328 -0
- package/dist/components/custom/flow-properties-expanded.d.ts +21 -0
- package/dist/components/custom/flow-properties-expanded.js +294 -0
- package/dist/components/custom/flow-properties-simple.cjs +364 -0
- package/dist/components/custom/flow-properties-simple.d.ts +62 -0
- package/dist/components/custom/flow-properties-simple.js +330 -0
- package/dist/components/custom/flow-properties.cjs +56 -0
- package/dist/components/custom/flow-properties.d.ts +28 -0
- package/dist/components/custom/flow-properties.js +22 -0
- package/dist/components/custom/global-header.cjs +422 -0
- package/dist/components/custom/global-header.d.ts +38 -0
- package/dist/components/custom/global-header.js +388 -0
- package/dist/components/custom/grid-maestro.cjs +62 -0
- package/dist/components/custom/grid-maestro.d.ts +19 -0
- package/dist/components/custom/grid-maestro.js +22 -0
- package/dist/components/custom/page-header.cjs +92 -0
- package/dist/components/custom/page-header.d.ts +43 -0
- package/dist/components/custom/page-header.js +58 -0
- package/dist/components/custom/panel-delegate.cjs +285 -0
- package/dist/components/custom/panel-delegate.d.ts +34 -0
- package/dist/components/custom/panel-delegate.js +251 -0
- package/dist/components/custom/panel-flow.cjs +262 -0
- package/dist/components/custom/panel-flow.d.ts +38 -0
- package/dist/components/custom/panel-flow.js +225 -0
- package/dist/components/custom/panel-maestro.cjs +74 -0
- package/dist/components/custom/panel-maestro.d.ts +30 -0
- package/dist/components/custom/panel-maestro.js +40 -0
- package/dist/components/custom/panel-studio.cjs +122 -0
- package/dist/components/custom/panel-studio.d.ts +48 -0
- package/dist/components/custom/panel-studio.js +85 -0
- package/dist/components/custom/toolbar-canvas.cjs +124 -0
- package/dist/components/custom/toolbar-canvas.d.ts +15 -0
- package/dist/components/custom/toolbar-canvas.js +90 -0
- package/dist/components/custom/toolbar-view.cjs +121 -0
- package/dist/components/custom/toolbar-view.d.ts +14 -0
- package/dist/components/custom/toolbar-view.js +87 -0
- package/dist/components/custom/viewport-guard.cjs +92 -0
- package/dist/components/custom/viewport-guard.d.ts +23 -0
- package/dist/components/custom/viewport-guard.js +55 -0
- package/dist/components/forms/field-renderer.cjs +3 -1
- package/dist/components/forms/field-renderer.js +3 -1
- package/dist/components/forms/form-designer.cjs +13 -2
- package/dist/components/forms/form-designer.js +13 -2
- package/dist/components/forms/rules-engine.d.ts +1 -1
- package/dist/components/ui/breadcrumb.cjs +1 -2
- package/dist/components/ui/breadcrumb.js +1 -2
- package/dist/components/ui/button-group.cjs +5 -3
- package/dist/components/ui/button-group.d.ts +2 -2
- package/dist/components/ui/button-group.js +5 -3
- package/dist/components/ui/button.cjs +3 -3
- package/dist/components/ui/button.js +3 -3
- package/dist/components/ui/chart.cjs +223 -0
- package/dist/components/ui/chart.d.ts +40 -0
- package/dist/components/ui/chart.js +174 -0
- package/dist/components/ui/code-block.cjs +258 -0
- package/dist/components/ui/code-block.d.ts +48 -0
- package/dist/components/ui/code-block.js +207 -0
- package/dist/components/ui/data-table.cjs +22 -4
- package/dist/components/ui/data-table.d.ts +5 -2
- package/dist/components/ui/data-table.js +23 -5
- package/dist/components/ui/editable-cell.cjs +3 -10
- package/dist/components/ui/editable-cell.js +3 -10
- package/dist/components/ui/empty-state.cjs +17 -6
- package/dist/components/ui/empty-state.d.ts +7 -0
- package/dist/components/ui/empty-state.js +17 -6
- package/dist/components/ui/file-upload.cjs +8 -0
- package/dist/components/ui/file-upload.js +8 -0
- package/dist/components/ui/index.cjs +289 -149
- package/dist/components/ui/index.d.ts +2 -3
- package/dist/components/ui/index.js +2 -3
- package/dist/components/ui/multi-select.cjs +3 -10
- package/dist/components/ui/multi-select.js +3 -10
- package/dist/components/ui/pagination.cjs +0 -1
- package/dist/components/ui/pagination.js +0 -1
- package/dist/components/ui/resizable.d.ts +1 -1
- package/dist/components/ui/tree-view.cjs +1117 -0
- package/dist/components/ui/tree-view.d.ts +95 -0
- package/dist/components/ui/tree-view.js +1083 -0
- package/dist/foundation/Future/colors.cjs +92 -0
- package/dist/foundation/Future/colors.d.ts +132 -0
- package/dist/foundation/Future/colors.js +43 -0
- package/dist/foundation/Future/radius.cjs +46 -0
- package/dist/foundation/Future/radius.d.ts +33 -0
- package/dist/foundation/Future/radius.js +12 -0
- package/dist/foundation/Future/responsive.cjs +49 -0
- package/dist/foundation/Future/responsive.d.ts +40 -0
- package/dist/foundation/Future/responsive.js +12 -0
- package/dist/foundation/Future/shadows.cjs +48 -0
- package/dist/foundation/Future/shadows.d.ts +29 -0
- package/dist/foundation/Future/shadows.js +11 -0
- package/dist/foundation/Future/spacing.cjs +71 -0
- package/dist/foundation/Future/spacing.d.ts +80 -0
- package/dist/foundation/Future/spacing.js +31 -0
- package/dist/foundation/Future/strokes.cjs +59 -0
- package/dist/foundation/Future/strokes.d.ts +49 -0
- package/dist/foundation/Future/strokes.js +19 -0
- package/dist/foundation/Future/types.cjs +18 -0
- package/dist/foundation/Future/types.d.ts +25 -0
- package/dist/foundation/Future/types.js +0 -0
- package/dist/foundation/Future/typography.cjs +79 -0
- package/dist/foundation/Future/typography.d.ts +86 -0
- package/dist/foundation/Future/typography.js +33 -0
- package/dist/index.cjs +131 -221
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -4
- package/dist/src/foundation/Future/themes.css +279 -0
- package/dist/styles.css +1941 -605
- package/dist/tailwind.css +874 -87
- package/dist/templates/Admin/settings-admin.d.ts +5 -0
- package/dist/templates/Admin/template-admin.d.ts +86 -0
- package/dist/templates/Delegate/template-delegate.d.ts +26 -0
- package/dist/templates/EmptyErrors/error-components.d.ts +3 -0
- package/dist/templates/Experiments/ideas-AnimatedGradientText.d.ts +23 -0
- package/dist/templates/Flow/template-flow.d.ts +57 -0
- package/dist/templates/Maestro/template-maestro.d.ts +52 -0
- package/dist/templates/Studio/template-studio.d.ts +102 -0
- package/dist/templates/{vscode-example.d.ts → VisualStudio/shell.d.ts} +1 -1
- package/package.json +12 -1
- package/dist/components/ui/menubar.cjs +0 -210
- package/dist/components/ui/menubar.d.ts +0 -28
- package/dist/components/ui/menubar.js +0 -131
- package/dist/components/ui/navigation-menu.cjs +0 -122
- package/dist/components/ui/navigation-menu.d.ts +0 -12
- package/dist/components/ui/navigation-menu.js +0 -64
- package/dist/examples/admin-layout-example.cjs +0 -490
- package/dist/examples/admin-layout-example.d.ts +0 -92
- package/dist/examples/admin-layout-example.js +0 -411
- package/dist/examples/app-shell-example.cjs +0 -452
- package/dist/examples/app-shell-example.d.ts +0 -52
- package/dist/examples/app-shell-example.js +0 -418
- package/dist/examples/dashboard-example.cjs +0 -590
- package/dist/examples/dashboard-example.d.ts +0 -11
- package/dist/examples/dashboard-example.js +0 -556
- package/dist/examples/data-management-example.cjs +0 -584
- package/dist/examples/data-management-example.d.ts +0 -1
- package/dist/examples/data-management-example.js +0 -550
- package/dist/examples/flow-editor-layout-example.cjs +0 -309
- package/dist/examples/flow-editor-layout-example.d.ts +0 -22
- package/dist/examples/flow-editor-layout-example.js +0 -269
- package/dist/examples/flow-start-example.cjs +0 -467
- package/dist/examples/flow-start-example.d.ts +0 -30
- package/dist/examples/flow-start-example.js +0 -433
- package/dist/examples/form-builder-example.cjs +0 -674
- package/dist/examples/form-builder-example.js +0 -640
- package/dist/examples/new-project-example.cjs +0 -550
- package/dist/examples/new-project-example.d.ts +0 -30
- package/dist/examples/new-project-example.js +0 -516
- package/dist/examples/settings-example.cjs +0 -864
- package/dist/examples/settings-example.d.ts +0 -1
- package/dist/examples/settings-example.js +0 -830
- package/dist/examples/vscode-example.cjs +0 -340
- package/dist/examples/vscode-example.d.ts +0 -80
- package/dist/examples/vscode-example.js +0 -270
- package/dist/templates/admin-layout-example.d.ts +0 -92
- package/dist/templates/app-shell-example.d.ts +0 -52
- package/dist/templates/dashboard-example.d.ts +0 -11
- package/dist/templates/data-management-example.d.ts +0 -1
- package/dist/templates/flow-editor-layout-example.d.ts +0 -22
- package/dist/templates/flow-start-example.d.ts +0 -30
- package/dist/templates/form-builder-example.d.ts +0 -1
- package/dist/templates/new-project-example.d.ts +0 -30
- package/dist/templates/settings-example.d.ts +0 -1
- /package/dist/{examples → templates/Forms}/form-builder-example.d.ts +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
CodeBlock: ()=>CodeBlock
|
|
37
|
+
});
|
|
38
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
39
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
40
|
+
const external_react_namespaceObject = require("react");
|
|
41
|
+
const external_react_syntax_highlighter_namespaceObject = require("react-syntax-highlighter");
|
|
42
|
+
const atom_dark_js_namespaceObject = require("react-syntax-highlighter/dist/esm/styles/prism/atom-dark.js");
|
|
43
|
+
var atom_dark_js_default = /*#__PURE__*/ __webpack_require__.n(atom_dark_js_namespaceObject);
|
|
44
|
+
const night_owl_js_namespaceObject = require("react-syntax-highlighter/dist/esm/styles/prism/night-owl.js");
|
|
45
|
+
var night_owl_js_default = /*#__PURE__*/ __webpack_require__.n(night_owl_js_namespaceObject);
|
|
46
|
+
const nord_js_namespaceObject = require("react-syntax-highlighter/dist/esm/styles/prism/nord.js");
|
|
47
|
+
var nord_js_default = /*#__PURE__*/ __webpack_require__.n(nord_js_namespaceObject);
|
|
48
|
+
const one_dark_js_namespaceObject = require("react-syntax-highlighter/dist/esm/styles/prism/one-dark.js");
|
|
49
|
+
var one_dark_js_default = /*#__PURE__*/ __webpack_require__.n(one_dark_js_namespaceObject);
|
|
50
|
+
const one_light_js_namespaceObject = require("react-syntax-highlighter/dist/esm/styles/prism/one-light.js");
|
|
51
|
+
var one_light_js_default = /*#__PURE__*/ __webpack_require__.n(one_light_js_namespaceObject);
|
|
52
|
+
const prism_js_namespaceObject = require("react-syntax-highlighter/dist/esm/styles/prism/prism.js");
|
|
53
|
+
var prism_js_default = /*#__PURE__*/ __webpack_require__.n(prism_js_namespaceObject);
|
|
54
|
+
const vs_js_namespaceObject = require("react-syntax-highlighter/dist/esm/styles/prism/vs.js");
|
|
55
|
+
var vs_js_default = /*#__PURE__*/ __webpack_require__.n(vs_js_namespaceObject);
|
|
56
|
+
const vs_dark_js_namespaceObject = require("react-syntax-highlighter/dist/esm/styles/prism/vs-dark.js");
|
|
57
|
+
var vs_dark_js_default = /*#__PURE__*/ __webpack_require__.n(vs_dark_js_namespaceObject);
|
|
58
|
+
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
59
|
+
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
60
|
+
const THEME_CONFIG = {
|
|
61
|
+
dark: {
|
|
62
|
+
prismStyle: nord_js_default(),
|
|
63
|
+
bg: '#182027',
|
|
64
|
+
headerBg: '#111920',
|
|
65
|
+
labelColor: '#8ea1b1',
|
|
66
|
+
iconColor: '#6b8899',
|
|
67
|
+
lineNumberColor: '#2e3f4c'
|
|
68
|
+
},
|
|
69
|
+
light: {
|
|
70
|
+
prismStyle: vs_js_default(),
|
|
71
|
+
bg: '#ffffff',
|
|
72
|
+
headerBg: '#f0f4f8',
|
|
73
|
+
labelColor: '#374151',
|
|
74
|
+
iconColor: '#6b7280',
|
|
75
|
+
lineNumberColor: '#c8d4de'
|
|
76
|
+
},
|
|
77
|
+
'future-dark': {
|
|
78
|
+
prismStyle: vs_dark_js_default(),
|
|
79
|
+
bg: '#18181b',
|
|
80
|
+
headerBg: '#09090b',
|
|
81
|
+
labelColor: '#a1a1aa',
|
|
82
|
+
iconColor: '#71717a',
|
|
83
|
+
lineNumberColor: '#3f3f46'
|
|
84
|
+
},
|
|
85
|
+
'future-light': {
|
|
86
|
+
prismStyle: vs_js_default(),
|
|
87
|
+
bg: '#fafafa',
|
|
88
|
+
headerBg: '#f4f4f5',
|
|
89
|
+
labelColor: '#52525b',
|
|
90
|
+
iconColor: '#71717a',
|
|
91
|
+
lineNumberColor: '#d4d4d8'
|
|
92
|
+
},
|
|
93
|
+
wireframe: {
|
|
94
|
+
prismStyle: prism_js_default(),
|
|
95
|
+
bg: '#f9fafb',
|
|
96
|
+
headerBg: '#f3f4f6',
|
|
97
|
+
labelColor: '#6b7280',
|
|
98
|
+
iconColor: '#9ca3af',
|
|
99
|
+
lineNumberColor: '#d1d5db'
|
|
100
|
+
},
|
|
101
|
+
vertex: {
|
|
102
|
+
prismStyle: night_owl_js_default(),
|
|
103
|
+
bg: 'oklch(0.21 0.03 258.5)',
|
|
104
|
+
headerBg: 'oklch(0.188 0.028 258.5)',
|
|
105
|
+
labelColor: '#a6b5c9',
|
|
106
|
+
iconColor: '#7a90a8',
|
|
107
|
+
lineNumberColor: 'oklch(0.32 0.03 258.5)'
|
|
108
|
+
},
|
|
109
|
+
canvas: {
|
|
110
|
+
prismStyle: atom_dark_js_default(),
|
|
111
|
+
bg: '#182027',
|
|
112
|
+
headerBg: '#111920',
|
|
113
|
+
labelColor: '#8ea1b1',
|
|
114
|
+
iconColor: '#6b8899',
|
|
115
|
+
lineNumberColor: '#2e3f4c'
|
|
116
|
+
},
|
|
117
|
+
'dark-hc': {
|
|
118
|
+
prismStyle: one_dark_js_default(),
|
|
119
|
+
bg: '#0a0a0a',
|
|
120
|
+
headerBg: '#141414',
|
|
121
|
+
labelColor: '#e4e4e4',
|
|
122
|
+
iconColor: '#c8c8c8',
|
|
123
|
+
lineNumberColor: '#505050'
|
|
124
|
+
},
|
|
125
|
+
'light-hc': {
|
|
126
|
+
prismStyle: one_light_js_default(),
|
|
127
|
+
bg: '#ffffff',
|
|
128
|
+
headerBg: '#e8e8e8',
|
|
129
|
+
labelColor: '#111827',
|
|
130
|
+
iconColor: '#374151',
|
|
131
|
+
lineNumberColor: '#9ca3af'
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const BODY_CLASS_PRIORITY = [
|
|
135
|
+
'future-dark',
|
|
136
|
+
'future-light',
|
|
137
|
+
'dark-hc',
|
|
138
|
+
'light-hc',
|
|
139
|
+
'dark',
|
|
140
|
+
'light',
|
|
141
|
+
'wireframe',
|
|
142
|
+
'vertex',
|
|
143
|
+
'canvas'
|
|
144
|
+
];
|
|
145
|
+
function getBodyTheme() {
|
|
146
|
+
if ('undefined' == typeof document) return 'dark';
|
|
147
|
+
const bodyClasses = document.body.classList;
|
|
148
|
+
const htmlClasses = document.documentElement.classList;
|
|
149
|
+
return BODY_CLASS_PRIORITY.find((t)=>bodyClasses.contains(t) || htmlClasses.contains(t)) ?? 'future-dark';
|
|
150
|
+
}
|
|
151
|
+
function useApolloTheme() {
|
|
152
|
+
const [theme, setTheme] = (0, external_react_namespaceObject.useState)(getBodyTheme);
|
|
153
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
154
|
+
if ('undefined' == typeof document) return;
|
|
155
|
+
const observer = new MutationObserver(()=>setTheme(getBodyTheme()));
|
|
156
|
+
const targets = [
|
|
157
|
+
document.body,
|
|
158
|
+
document.documentElement
|
|
159
|
+
];
|
|
160
|
+
targets.forEach((target)=>{
|
|
161
|
+
if (target) observer.observe(target, {
|
|
162
|
+
attributes: true,
|
|
163
|
+
attributeFilter: [
|
|
164
|
+
'class'
|
|
165
|
+
]
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
return ()=>observer.disconnect();
|
|
169
|
+
}, []);
|
|
170
|
+
return theme;
|
|
171
|
+
}
|
|
172
|
+
function CodeBlock({ children, language = 'tsx', showLineNumbers = true, showCopyButton = true, fileName, theme, wrapLines = false, className }) {
|
|
173
|
+
const [copied, setCopied] = (0, external_react_namespaceObject.useState)(false);
|
|
174
|
+
const timeoutRef = (0, external_react_namespaceObject.useRef)(null);
|
|
175
|
+
const detectedTheme = useApolloTheme();
|
|
176
|
+
const activeTheme = theme ?? detectedTheme;
|
|
177
|
+
const config = THEME_CONFIG[activeTheme];
|
|
178
|
+
const code = children.trim();
|
|
179
|
+
async function handleCopy() {
|
|
180
|
+
try {
|
|
181
|
+
await navigator.clipboard.writeText(code);
|
|
182
|
+
setCopied(true);
|
|
183
|
+
timeoutRef.current = setTimeout(()=>setCopied(false), 1500);
|
|
184
|
+
} catch {}
|
|
185
|
+
}
|
|
186
|
+
(0, external_react_namespaceObject.useEffect)(()=>()=>{
|
|
187
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
188
|
+
}, []);
|
|
189
|
+
const showHeader = !!(fileName || language || showCopyButton);
|
|
190
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
191
|
+
className: (0, index_cjs_namespaceObject.cn)('overflow-hidden rounded-lg border border-border font-mono text-sm', className),
|
|
192
|
+
style: {
|
|
193
|
+
background: config.bg
|
|
194
|
+
},
|
|
195
|
+
children: [
|
|
196
|
+
showHeader && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
197
|
+
className: "flex items-center justify-between px-4 py-2 border-b border-border",
|
|
198
|
+
style: {
|
|
199
|
+
background: config.headerBg
|
|
200
|
+
},
|
|
201
|
+
children: [
|
|
202
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
203
|
+
className: "text-xs font-medium",
|
|
204
|
+
style: {
|
|
205
|
+
color: config.labelColor
|
|
206
|
+
},
|
|
207
|
+
children: fileName ?? language
|
|
208
|
+
}),
|
|
209
|
+
showCopyButton && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
|
|
210
|
+
size: "icon",
|
|
211
|
+
variant: "ghost",
|
|
212
|
+
className: "h-7 w-7 [&_svg]:size-3.5 transition-colors",
|
|
213
|
+
style: {
|
|
214
|
+
color: config.iconColor
|
|
215
|
+
},
|
|
216
|
+
onClick: handleCopy,
|
|
217
|
+
"aria-label": copied ? 'Copied!' : 'Copy code',
|
|
218
|
+
children: copied ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Check, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Copy, {})
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
}),
|
|
222
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_syntax_highlighter_namespaceObject.Prism, {
|
|
223
|
+
language: language,
|
|
224
|
+
style: config.prismStyle,
|
|
225
|
+
showLineNumbers: showLineNumbers,
|
|
226
|
+
wrapLines: wrapLines,
|
|
227
|
+
wrapLongLines: wrapLines,
|
|
228
|
+
customStyle: {
|
|
229
|
+
margin: 0,
|
|
230
|
+
borderRadius: 0,
|
|
231
|
+
background: 'transparent',
|
|
232
|
+
padding: '1rem',
|
|
233
|
+
fontSize: 13,
|
|
234
|
+
lineHeight: 1.6
|
|
235
|
+
},
|
|
236
|
+
lineNumberStyle: {
|
|
237
|
+
color: config.lineNumberColor,
|
|
238
|
+
minWidth: '2.5em',
|
|
239
|
+
paddingRight: '1.25em',
|
|
240
|
+
userSelect: 'none'
|
|
241
|
+
},
|
|
242
|
+
codeTagProps: {
|
|
243
|
+
style: {
|
|
244
|
+
fontFamily: 'inherit'
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
children: code
|
|
248
|
+
})
|
|
249
|
+
]
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
exports.CodeBlock = __webpack_exports__.CodeBlock;
|
|
253
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
254
|
+
"CodeBlock"
|
|
255
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
256
|
+
Object.defineProperty(exports, '__esModule', {
|
|
257
|
+
value: true
|
|
258
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All Apollo theme variants supported by CodeBlock.
|
|
3
|
+
*
|
|
4
|
+
* Standard (apollo-core):
|
|
5
|
+
* - `'dark'` / `'light'` — Default dark / light
|
|
6
|
+
* - `'dark-hc'` / `'light-hc'` — High contrast variants
|
|
7
|
+
*
|
|
8
|
+
* Future / Demo themes:
|
|
9
|
+
* - `'future-dark'` / `'future-light'` — Future zinc palette, cyan brand
|
|
10
|
+
* - `'wireframe'` — Greyscale / prototyping
|
|
11
|
+
* - `'vertex'` — Deep blue-grey, teal brand
|
|
12
|
+
* - `'canvas'` — Apollo MUI dark, orange brand
|
|
13
|
+
*
|
|
14
|
+
* When no theme is passed the component auto-detects from the Apollo
|
|
15
|
+
* `<body>` class and switches live when the theme changes.
|
|
16
|
+
*/
|
|
17
|
+
export type CodeBlockTheme = 'dark' | 'light' | 'dark-hc' | 'light-hc' | 'future-dark' | 'future-light' | 'wireframe' | 'vertex' | 'canvas';
|
|
18
|
+
export interface CodeBlockProps {
|
|
19
|
+
/** The code string to display */
|
|
20
|
+
children: string;
|
|
21
|
+
/** Programming language for syntax highlighting (e.g. 'tsx', 'python', 'sql') */
|
|
22
|
+
language?: string;
|
|
23
|
+
/** Show line numbers on the left */
|
|
24
|
+
showLineNumbers?: boolean;
|
|
25
|
+
/** Show copy-to-clipboard button in the header */
|
|
26
|
+
showCopyButton?: boolean;
|
|
27
|
+
/** Optional file name displayed in the header */
|
|
28
|
+
fileName?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Color scheme. When omitted the component auto-follows the active Apollo
|
|
31
|
+
* page theme by watching the class on `<body>` — switches live.
|
|
32
|
+
*/
|
|
33
|
+
theme?: CodeBlockTheme;
|
|
34
|
+
/** Wrap long lines instead of scrolling horizontally */
|
|
35
|
+
wrapLines?: boolean;
|
|
36
|
+
className?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Syntax-highlighted code block built on react-syntax-highlighter (Prism engine).
|
|
40
|
+
*
|
|
41
|
+
* Supports 200+ languages, optional line numbers, a filename header, and a
|
|
42
|
+
* one-click copy button. Automatically follows the active Apollo theme by
|
|
43
|
+
* watching the body class — or accept an explicit `theme` prop to override.
|
|
44
|
+
*
|
|
45
|
+
* Supported themes: dark, light, dark-hc, light-hc, future-dark,
|
|
46
|
+
* future-light, wireframe, vertex, canvas.
|
|
47
|
+
*/
|
|
48
|
+
export declare function CodeBlock({ children, language, showLineNumbers, showCopyButton, fileName, theme, wrapLines, className, }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check, Copy } from "lucide-react";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Prism } from "react-syntax-highlighter";
|
|
5
|
+
import atom_dark from "react-syntax-highlighter/dist/esm/styles/prism/atom-dark.js";
|
|
6
|
+
import night_owl from "react-syntax-highlighter/dist/esm/styles/prism/night-owl.js";
|
|
7
|
+
import nord from "react-syntax-highlighter/dist/esm/styles/prism/nord.js";
|
|
8
|
+
import one_dark from "react-syntax-highlighter/dist/esm/styles/prism/one-dark.js";
|
|
9
|
+
import one_light from "react-syntax-highlighter/dist/esm/styles/prism/one-light.js";
|
|
10
|
+
import prism from "react-syntax-highlighter/dist/esm/styles/prism/prism.js";
|
|
11
|
+
import vs from "react-syntax-highlighter/dist/esm/styles/prism/vs.js";
|
|
12
|
+
import vs_dark from "react-syntax-highlighter/dist/esm/styles/prism/vs-dark.js";
|
|
13
|
+
import { Button } from "./button.js";
|
|
14
|
+
import { cn } from "../../lib/index.js";
|
|
15
|
+
const THEME_CONFIG = {
|
|
16
|
+
dark: {
|
|
17
|
+
prismStyle: nord,
|
|
18
|
+
bg: '#182027',
|
|
19
|
+
headerBg: '#111920',
|
|
20
|
+
labelColor: '#8ea1b1',
|
|
21
|
+
iconColor: '#6b8899',
|
|
22
|
+
lineNumberColor: '#2e3f4c'
|
|
23
|
+
},
|
|
24
|
+
light: {
|
|
25
|
+
prismStyle: vs,
|
|
26
|
+
bg: '#ffffff',
|
|
27
|
+
headerBg: '#f0f4f8',
|
|
28
|
+
labelColor: '#374151',
|
|
29
|
+
iconColor: '#6b7280',
|
|
30
|
+
lineNumberColor: '#c8d4de'
|
|
31
|
+
},
|
|
32
|
+
'future-dark': {
|
|
33
|
+
prismStyle: vs_dark,
|
|
34
|
+
bg: '#18181b',
|
|
35
|
+
headerBg: '#09090b',
|
|
36
|
+
labelColor: '#a1a1aa',
|
|
37
|
+
iconColor: '#71717a',
|
|
38
|
+
lineNumberColor: '#3f3f46'
|
|
39
|
+
},
|
|
40
|
+
'future-light': {
|
|
41
|
+
prismStyle: vs,
|
|
42
|
+
bg: '#fafafa',
|
|
43
|
+
headerBg: '#f4f4f5',
|
|
44
|
+
labelColor: '#52525b',
|
|
45
|
+
iconColor: '#71717a',
|
|
46
|
+
lineNumberColor: '#d4d4d8'
|
|
47
|
+
},
|
|
48
|
+
wireframe: {
|
|
49
|
+
prismStyle: prism,
|
|
50
|
+
bg: '#f9fafb',
|
|
51
|
+
headerBg: '#f3f4f6',
|
|
52
|
+
labelColor: '#6b7280',
|
|
53
|
+
iconColor: '#9ca3af',
|
|
54
|
+
lineNumberColor: '#d1d5db'
|
|
55
|
+
},
|
|
56
|
+
vertex: {
|
|
57
|
+
prismStyle: night_owl,
|
|
58
|
+
bg: 'oklch(0.21 0.03 258.5)',
|
|
59
|
+
headerBg: 'oklch(0.188 0.028 258.5)',
|
|
60
|
+
labelColor: '#a6b5c9',
|
|
61
|
+
iconColor: '#7a90a8',
|
|
62
|
+
lineNumberColor: 'oklch(0.32 0.03 258.5)'
|
|
63
|
+
},
|
|
64
|
+
canvas: {
|
|
65
|
+
prismStyle: atom_dark,
|
|
66
|
+
bg: '#182027',
|
|
67
|
+
headerBg: '#111920',
|
|
68
|
+
labelColor: '#8ea1b1',
|
|
69
|
+
iconColor: '#6b8899',
|
|
70
|
+
lineNumberColor: '#2e3f4c'
|
|
71
|
+
},
|
|
72
|
+
'dark-hc': {
|
|
73
|
+
prismStyle: one_dark,
|
|
74
|
+
bg: '#0a0a0a',
|
|
75
|
+
headerBg: '#141414',
|
|
76
|
+
labelColor: '#e4e4e4',
|
|
77
|
+
iconColor: '#c8c8c8',
|
|
78
|
+
lineNumberColor: '#505050'
|
|
79
|
+
},
|
|
80
|
+
'light-hc': {
|
|
81
|
+
prismStyle: one_light,
|
|
82
|
+
bg: '#ffffff',
|
|
83
|
+
headerBg: '#e8e8e8',
|
|
84
|
+
labelColor: '#111827',
|
|
85
|
+
iconColor: '#374151',
|
|
86
|
+
lineNumberColor: '#9ca3af'
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const BODY_CLASS_PRIORITY = [
|
|
90
|
+
'future-dark',
|
|
91
|
+
'future-light',
|
|
92
|
+
'dark-hc',
|
|
93
|
+
'light-hc',
|
|
94
|
+
'dark',
|
|
95
|
+
'light',
|
|
96
|
+
'wireframe',
|
|
97
|
+
'vertex',
|
|
98
|
+
'canvas'
|
|
99
|
+
];
|
|
100
|
+
function getBodyTheme() {
|
|
101
|
+
if ('undefined' == typeof document) return 'dark';
|
|
102
|
+
const bodyClasses = document.body.classList;
|
|
103
|
+
const htmlClasses = document.documentElement.classList;
|
|
104
|
+
return BODY_CLASS_PRIORITY.find((t)=>bodyClasses.contains(t) || htmlClasses.contains(t)) ?? 'future-dark';
|
|
105
|
+
}
|
|
106
|
+
function useApolloTheme() {
|
|
107
|
+
const [theme, setTheme] = useState(getBodyTheme);
|
|
108
|
+
useEffect(()=>{
|
|
109
|
+
if ('undefined' == typeof document) return;
|
|
110
|
+
const observer = new MutationObserver(()=>setTheme(getBodyTheme()));
|
|
111
|
+
const targets = [
|
|
112
|
+
document.body,
|
|
113
|
+
document.documentElement
|
|
114
|
+
];
|
|
115
|
+
targets.forEach((target)=>{
|
|
116
|
+
if (target) observer.observe(target, {
|
|
117
|
+
attributes: true,
|
|
118
|
+
attributeFilter: [
|
|
119
|
+
'class'
|
|
120
|
+
]
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
return ()=>observer.disconnect();
|
|
124
|
+
}, []);
|
|
125
|
+
return theme;
|
|
126
|
+
}
|
|
127
|
+
function CodeBlock({ children, language = 'tsx', showLineNumbers = true, showCopyButton = true, fileName, theme, wrapLines = false, className }) {
|
|
128
|
+
const [copied, setCopied] = useState(false);
|
|
129
|
+
const timeoutRef = useRef(null);
|
|
130
|
+
const detectedTheme = useApolloTheme();
|
|
131
|
+
const activeTheme = theme ?? detectedTheme;
|
|
132
|
+
const config = THEME_CONFIG[activeTheme];
|
|
133
|
+
const code = children.trim();
|
|
134
|
+
async function handleCopy() {
|
|
135
|
+
try {
|
|
136
|
+
await navigator.clipboard.writeText(code);
|
|
137
|
+
setCopied(true);
|
|
138
|
+
timeoutRef.current = setTimeout(()=>setCopied(false), 1500);
|
|
139
|
+
} catch {}
|
|
140
|
+
}
|
|
141
|
+
useEffect(()=>()=>{
|
|
142
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
143
|
+
}, []);
|
|
144
|
+
const showHeader = !!(fileName || language || showCopyButton);
|
|
145
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
146
|
+
className: cn('overflow-hidden rounded-lg border border-border font-mono text-sm', className),
|
|
147
|
+
style: {
|
|
148
|
+
background: config.bg
|
|
149
|
+
},
|
|
150
|
+
children: [
|
|
151
|
+
showHeader && /*#__PURE__*/ jsxs("div", {
|
|
152
|
+
className: "flex items-center justify-between px-4 py-2 border-b border-border",
|
|
153
|
+
style: {
|
|
154
|
+
background: config.headerBg
|
|
155
|
+
},
|
|
156
|
+
children: [
|
|
157
|
+
/*#__PURE__*/ jsx("span", {
|
|
158
|
+
className: "text-xs font-medium",
|
|
159
|
+
style: {
|
|
160
|
+
color: config.labelColor
|
|
161
|
+
},
|
|
162
|
+
children: fileName ?? language
|
|
163
|
+
}),
|
|
164
|
+
showCopyButton && /*#__PURE__*/ jsx(Button, {
|
|
165
|
+
size: "icon",
|
|
166
|
+
variant: "ghost",
|
|
167
|
+
className: "h-7 w-7 [&_svg]:size-3.5 transition-colors",
|
|
168
|
+
style: {
|
|
169
|
+
color: config.iconColor
|
|
170
|
+
},
|
|
171
|
+
onClick: handleCopy,
|
|
172
|
+
"aria-label": copied ? 'Copied!' : 'Copy code',
|
|
173
|
+
children: copied ? /*#__PURE__*/ jsx(Check, {}) : /*#__PURE__*/ jsx(Copy, {})
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
}),
|
|
177
|
+
/*#__PURE__*/ jsx(Prism, {
|
|
178
|
+
language: language,
|
|
179
|
+
style: config.prismStyle,
|
|
180
|
+
showLineNumbers: showLineNumbers,
|
|
181
|
+
wrapLines: wrapLines,
|
|
182
|
+
wrapLongLines: wrapLines,
|
|
183
|
+
customStyle: {
|
|
184
|
+
margin: 0,
|
|
185
|
+
borderRadius: 0,
|
|
186
|
+
background: 'transparent',
|
|
187
|
+
padding: '1rem',
|
|
188
|
+
fontSize: 13,
|
|
189
|
+
lineHeight: 1.6
|
|
190
|
+
},
|
|
191
|
+
lineNumberStyle: {
|
|
192
|
+
color: config.lineNumberColor,
|
|
193
|
+
minWidth: '2.5em',
|
|
194
|
+
paddingRight: '1.25em',
|
|
195
|
+
userSelect: 'none'
|
|
196
|
+
},
|
|
197
|
+
codeTagProps: {
|
|
198
|
+
style: {
|
|
199
|
+
fontFamily: 'inherit'
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
children: code
|
|
203
|
+
})
|
|
204
|
+
]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
export { CodeBlock };
|
|
@@ -38,11 +38,22 @@ const external_editable_cell_cjs_namespaceObject = require("./editable-cell.cjs"
|
|
|
38
38
|
const external_input_cjs_namespaceObject = require("./input.cjs");
|
|
39
39
|
const external_table_cjs_namespaceObject = require("./table.cjs");
|
|
40
40
|
const react_table_namespaceObject = require("@tanstack/react-table");
|
|
41
|
-
function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...', showColumnToggle = true, showPagination = true, pageSize = 10, editable = false, onCellUpdate, resizable = false, compact = false, columnToggleText = 'Columns' }) {
|
|
41
|
+
function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...', showColumnToggle = true, showPagination = true, pageSize = 10, editable = false, onCellUpdate, resizable = false, compact = false, columnToggleText = 'Columns', rowSelection: controlledRowSelection, onRowSelectionChange: controlledOnRowSelectionChange, toolbarContent }) {
|
|
42
42
|
const [sorting, setSorting] = external_react_namespaceObject.useState([]);
|
|
43
43
|
const [columnFilters, setColumnFilters] = external_react_namespaceObject.useState([]);
|
|
44
44
|
const [columnVisibility, setColumnVisibility] = external_react_namespaceObject.useState({});
|
|
45
|
-
const [
|
|
45
|
+
const [internalRowSelection, setInternalRowSelection] = external_react_namespaceObject.useState({});
|
|
46
|
+
const isControlled = void 0 !== controlledRowSelection;
|
|
47
|
+
const rowSelection = isControlled ? controlledRowSelection : internalRowSelection;
|
|
48
|
+
const setRowSelection = external_react_namespaceObject.useCallback((updater)=>{
|
|
49
|
+
const next = 'function' == typeof updater ? updater(rowSelection) : updater;
|
|
50
|
+
if (!isControlled) setInternalRowSelection(next);
|
|
51
|
+
controlledOnRowSelectionChange?.(next);
|
|
52
|
+
}, [
|
|
53
|
+
isControlled,
|
|
54
|
+
rowSelection,
|
|
55
|
+
controlledOnRowSelectionChange
|
|
56
|
+
]);
|
|
46
57
|
const processedColumns = external_react_namespaceObject.useMemo(()=>{
|
|
47
58
|
if (!editable || !onCellUpdate) return columns;
|
|
48
59
|
return columns.map((col)=>{
|
|
@@ -100,6 +111,7 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
100
111
|
onChange: (event)=>table.getColumn(searchKey)?.setFilterValue(event.target.value),
|
|
101
112
|
className: "max-w-sm"
|
|
102
113
|
}),
|
|
114
|
+
toolbarContent,
|
|
103
115
|
showColumnToggle && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenu, {
|
|
104
116
|
children: [
|
|
105
117
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuTrigger, {
|
|
@@ -142,7 +154,7 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
142
154
|
children: headerGroup.headers.map((header)=>{
|
|
143
155
|
const { column } = header;
|
|
144
156
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_table_cjs_namespaceObject.TableHead, {
|
|
145
|
-
className: compact ? 'relative h-8 px-2 py-
|
|
157
|
+
className: compact ? 'relative h-8 px-2 py-0' : 'relative py-0',
|
|
146
158
|
style: {
|
|
147
159
|
width: resizable ? header.getSize() : 150 !== column.getSize() ? column.getSize() : void 0,
|
|
148
160
|
minWidth: column.columnDef.minSize,
|
|
@@ -151,6 +163,12 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
151
163
|
children: [
|
|
152
164
|
header.isPlaceholder ? null : (0, react_table_namespaceObject.flexRender)(header.column.columnDef.header, header.getContext()),
|
|
153
165
|
resizable && header.column.getCanResize() && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
166
|
+
role: "separator",
|
|
167
|
+
"aria-label": "Resize column",
|
|
168
|
+
"aria-valuenow": header.column.getSize(),
|
|
169
|
+
"aria-valuemin": header.column.columnDef.minSize ?? 40,
|
|
170
|
+
"aria-valuemax": header.column.columnDef.maxSize ?? 1000,
|
|
171
|
+
tabIndex: 0,
|
|
154
172
|
onMouseDown: header.getResizeHandler(),
|
|
155
173
|
onTouchStart: header.getResizeHandler(),
|
|
156
174
|
className: "absolute -right-1 top-0 z-10 h-full w-2 cursor-col-resize select-none touch-none group",
|
|
@@ -169,7 +187,7 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
169
187
|
children: row.getVisibleCells().map((cell)=>{
|
|
170
188
|
const { column } = cell;
|
|
171
189
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_table_cjs_namespaceObject.TableCell, {
|
|
172
|
-
className: compact ? 'truncate px-2 py-
|
|
190
|
+
className: compact ? 'h-8 truncate px-2 py-0' : 'h-12 truncate px-4 py-0',
|
|
173
191
|
style: {
|
|
174
192
|
width: resizable ? cell.column.getSize() : 150 !== column.getSize() ? column.getSize() : void 0,
|
|
175
193
|
minWidth: column.columnDef.minSize,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Column, ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { Column, ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
3
3
|
export interface DataTableProps<TData, TValue> {
|
|
4
4
|
columns: ColumnDef<TData, TValue>[];
|
|
5
5
|
data: TData[];
|
|
@@ -13,8 +13,11 @@ export interface DataTableProps<TData, TValue> {
|
|
|
13
13
|
resizable?: boolean;
|
|
14
14
|
compact?: boolean;
|
|
15
15
|
columnToggleText?: string;
|
|
16
|
+
rowSelection?: RowSelectionState;
|
|
17
|
+
onRowSelectionChange?: (selection: RowSelectionState) => void;
|
|
18
|
+
toolbarContent?: React.ReactNode;
|
|
16
19
|
}
|
|
17
|
-
export declare function DataTable<TData, TValue>({ columns, data, searchKey, searchPlaceholder, showColumnToggle, showPagination, pageSize, editable, onCellUpdate, resizable, compact, columnToggleText, }: DataTableProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function DataTable<TData, TValue>({ columns, data, searchKey, searchPlaceholder, showColumnToggle, showPagination, pageSize, editable, onCellUpdate, resizable, compact, columnToggleText, rowSelection: controlledRowSelection, onRowSelectionChange: controlledOnRowSelectionChange, toolbarContent, }: DataTableProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
18
21
|
export declare function DataTableColumnHeader<TData, TValue>({ column, title, children, }: {
|
|
19
22
|
column: Column<TData, TValue>;
|
|
20
23
|
title: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
2
|
+
import { useCallback, useMemo, useState } from "react";
|
|
3
3
|
import { ArrowDown, ArrowUp, ArrowUpDown, ChevronDown } from "lucide-react";
|
|
4
4
|
import { Button } from "./button.js";
|
|
5
5
|
import { Checkbox } from "./checkbox.js";
|
|
@@ -8,11 +8,22 @@ import { EditableCell } from "./editable-cell.js";
|
|
|
8
8
|
import { Input } from "./input.js";
|
|
9
9
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "./table.js";
|
|
10
10
|
import { flexRender, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
11
|
-
function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...', showColumnToggle = true, showPagination = true, pageSize = 10, editable = false, onCellUpdate, resizable = false, compact = false, columnToggleText = 'Columns' }) {
|
|
11
|
+
function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...', showColumnToggle = true, showPagination = true, pageSize = 10, editable = false, onCellUpdate, resizable = false, compact = false, columnToggleText = 'Columns', rowSelection: controlledRowSelection, onRowSelectionChange: controlledOnRowSelectionChange, toolbarContent }) {
|
|
12
12
|
const [sorting, setSorting] = useState([]);
|
|
13
13
|
const [columnFilters, setColumnFilters] = useState([]);
|
|
14
14
|
const [columnVisibility, setColumnVisibility] = useState({});
|
|
15
|
-
const [
|
|
15
|
+
const [internalRowSelection, setInternalRowSelection] = useState({});
|
|
16
|
+
const isControlled = void 0 !== controlledRowSelection;
|
|
17
|
+
const rowSelection = isControlled ? controlledRowSelection : internalRowSelection;
|
|
18
|
+
const setRowSelection = useCallback((updater)=>{
|
|
19
|
+
const next = 'function' == typeof updater ? updater(rowSelection) : updater;
|
|
20
|
+
if (!isControlled) setInternalRowSelection(next);
|
|
21
|
+
controlledOnRowSelectionChange?.(next);
|
|
22
|
+
}, [
|
|
23
|
+
isControlled,
|
|
24
|
+
rowSelection,
|
|
25
|
+
controlledOnRowSelectionChange
|
|
26
|
+
]);
|
|
16
27
|
const processedColumns = useMemo(()=>{
|
|
17
28
|
if (!editable || !onCellUpdate) return columns;
|
|
18
29
|
return columns.map((col)=>{
|
|
@@ -70,6 +81,7 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
70
81
|
onChange: (event)=>table.getColumn(searchKey)?.setFilterValue(event.target.value),
|
|
71
82
|
className: "max-w-sm"
|
|
72
83
|
}),
|
|
84
|
+
toolbarContent,
|
|
73
85
|
showColumnToggle && /*#__PURE__*/ jsxs(DropdownMenu, {
|
|
74
86
|
children: [
|
|
75
87
|
/*#__PURE__*/ jsx(DropdownMenuTrigger, {
|
|
@@ -112,7 +124,7 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
112
124
|
children: headerGroup.headers.map((header)=>{
|
|
113
125
|
const { column } = header;
|
|
114
126
|
return /*#__PURE__*/ jsxs(TableHead, {
|
|
115
|
-
className: compact ? 'relative h-8 px-2 py-
|
|
127
|
+
className: compact ? 'relative h-8 px-2 py-0' : 'relative py-0',
|
|
116
128
|
style: {
|
|
117
129
|
width: resizable ? header.getSize() : 150 !== column.getSize() ? column.getSize() : void 0,
|
|
118
130
|
minWidth: column.columnDef.minSize,
|
|
@@ -121,6 +133,12 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
121
133
|
children: [
|
|
122
134
|
header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()),
|
|
123
135
|
resizable && header.column.getCanResize() && /*#__PURE__*/ jsx("div", {
|
|
136
|
+
role: "separator",
|
|
137
|
+
"aria-label": "Resize column",
|
|
138
|
+
"aria-valuenow": header.column.getSize(),
|
|
139
|
+
"aria-valuemin": header.column.columnDef.minSize ?? 40,
|
|
140
|
+
"aria-valuemax": header.column.columnDef.maxSize ?? 1000,
|
|
141
|
+
tabIndex: 0,
|
|
124
142
|
onMouseDown: header.getResizeHandler(),
|
|
125
143
|
onTouchStart: header.getResizeHandler(),
|
|
126
144
|
className: "absolute -right-1 top-0 z-10 h-full w-2 cursor-col-resize select-none touch-none group",
|
|
@@ -139,7 +157,7 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
139
157
|
children: row.getVisibleCells().map((cell)=>{
|
|
140
158
|
const { column } = cell;
|
|
141
159
|
return /*#__PURE__*/ jsx(TableCell, {
|
|
142
|
-
className: compact ? 'truncate px-2 py-
|
|
160
|
+
className: compact ? 'h-8 truncate px-2 py-0' : 'h-12 truncate px-4 py-0',
|
|
143
161
|
style: {
|
|
144
162
|
width: resizable ? cell.column.getSize() : 150 !== column.getSize() ? column.getSize() : void 0,
|
|
145
163
|
minWidth: column.columnDef.minSize,
|