@neo4j-ndl/react 4.14.5 → 4.15.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.
- package/lib/cjs/ai/preview/Preview.js +5 -0
- package/lib/cjs/ai/preview/Preview.js.map +1 -1
- package/lib/cjs/ai/preview/stories/index.js +9 -1
- package/lib/cjs/ai/preview/stories/index.js.map +1 -1
- package/lib/cjs/ai/preview/stories/preview-simple-with-content.story.js +34 -0
- package/lib/cjs/ai/preview/stories/preview-simple-with-content.story.js.map +1 -0
- package/lib/cjs/ai/preview/stories/preview-simple.story.js +33 -0
- package/lib/cjs/ai/preview/stories/preview-simple.story.js.map +1 -0
- package/lib/cjs/ai/prompt/Prompt.js +4 -14
- package/lib/cjs/ai/prompt/Prompt.js.map +1 -1
- package/lib/cjs/ai/prompt/stories/index.js +5 -1
- package/lib/cjs/ai/prompt/stories/index.js.map +1 -1
- package/lib/cjs/ai/prompt/stories/prompt-advanced.story.js +1 -1
- package/lib/cjs/ai/prompt/stories/prompt-advanced.story.js.map +1 -1
- package/lib/cjs/ai/prompt/stories/prompt-header.story.js +39 -0
- package/lib/cjs/ai/prompt/stories/prompt-header.story.js.map +1 -0
- package/lib/cjs/ai/response/Response.js +23 -22
- package/lib/cjs/ai/response/Response.js.map +1 -1
- package/lib/cjs/ai/response/stories/response-all-components.story.js +2 -0
- package/lib/cjs/ai/response/stories/response-all-components.story.js.map +1 -1
- package/lib/cjs/data-grid/Components.js +25 -10
- package/lib/cjs/data-grid/Components.js.map +1 -1
- package/lib/cjs/data-grid/datagrid-types.js.map +1 -1
- package/lib/cjs/data-grid/stories/datagrid-in-dialog.story.js +1 -0
- package/lib/cjs/data-grid/stories/datagrid-in-dialog.story.js.map +1 -1
- package/lib/cjs/data-grid/stories/datagrid-using-editable-cells.story.js +145 -52
- package/lib/cjs/data-grid/stories/datagrid-using-editable-cells.story.js.map +1 -1
- package/lib/esm/ai/preview/Preview.js +5 -0
- package/lib/esm/ai/preview/Preview.js.map +1 -1
- package/lib/esm/ai/preview/stories/index.js +6 -0
- package/lib/esm/ai/preview/stories/index.js.map +1 -1
- package/lib/esm/ai/preview/stories/preview-simple-with-content.story.js +32 -0
- package/lib/esm/ai/preview/stories/preview-simple-with-content.story.js.map +1 -0
- package/lib/esm/ai/preview/stories/preview-simple.story.js +31 -0
- package/lib/esm/ai/preview/stories/preview-simple.story.js.map +1 -0
- package/lib/esm/ai/prompt/Prompt.js +6 -16
- package/lib/esm/ai/prompt/Prompt.js.map +1 -1
- package/lib/esm/ai/prompt/stories/index.js +3 -0
- package/lib/esm/ai/prompt/stories/index.js.map +1 -1
- package/lib/esm/ai/prompt/stories/prompt-advanced.story.js +1 -1
- package/lib/esm/ai/prompt/stories/prompt-advanced.story.js.map +1 -1
- package/lib/esm/ai/prompt/stories/prompt-header.story.js +37 -0
- package/lib/esm/ai/prompt/stories/prompt-header.story.js.map +1 -0
- package/lib/esm/ai/response/Response.js +23 -22
- package/lib/esm/ai/response/Response.js.map +1 -1
- package/lib/esm/ai/response/stories/response-all-components.story.js +2 -0
- package/lib/esm/ai/response/stories/response-all-components.story.js.map +1 -1
- package/lib/esm/data-grid/Components.js +25 -10
- package/lib/esm/data-grid/Components.js.map +1 -1
- package/lib/esm/data-grid/datagrid-types.js.map +1 -1
- package/lib/esm/data-grid/stories/datagrid-in-dialog.story.js +1 -0
- package/lib/esm/data-grid/stories/datagrid-in-dialog.story.js.map +1 -1
- package/lib/esm/data-grid/stories/datagrid-using-editable-cells.story.js +147 -54
- package/lib/esm/data-grid/stories/datagrid-using-editable-cells.story.js.map +1 -1
- package/lib/types/ai/preview/Preview.d.ts +4 -0
- package/lib/types/ai/preview/Preview.d.ts.map +1 -1
- package/lib/types/ai/preview/stories/index.d.ts +4 -0
- package/lib/types/ai/preview/stories/index.d.ts.map +1 -1
- package/lib/types/ai/preview/stories/preview-simple-with-content.story.d.ts +24 -0
- package/lib/types/ai/preview/stories/preview-simple-with-content.story.d.ts.map +1 -0
- package/lib/types/ai/preview/stories/preview-simple.story.d.ts +24 -0
- package/lib/types/ai/preview/stories/preview-simple.story.d.ts.map +1 -0
- package/lib/types/ai/prompt/Prompt.d.ts +6 -2
- package/lib/types/ai/prompt/Prompt.d.ts.map +1 -1
- package/lib/types/ai/prompt/stories/index.d.ts +2 -0
- package/lib/types/ai/prompt/stories/index.d.ts.map +1 -1
- package/lib/types/ai/prompt/stories/prompt-advanced.story.d.ts.map +1 -1
- package/lib/types/ai/prompt/stories/prompt-header.story.d.ts +24 -0
- package/lib/types/ai/prompt/stories/prompt-header.story.d.ts.map +1 -0
- package/lib/types/ai/response/Response.d.ts.map +1 -1
- package/lib/types/ai/response/stories/response-all-components.story.d.ts.map +1 -1
- package/lib/types/data-grid/Components.d.ts +16 -1
- package/lib/types/data-grid/Components.d.ts.map +1 -1
- package/lib/types/data-grid/DataGrid.d.ts +10 -1
- package/lib/types/data-grid/DataGrid.d.ts.map +1 -1
- package/lib/types/data-grid/datagrid-types.d.ts +11 -1
- package/lib/types/data-grid/datagrid-types.d.ts.map +1 -1
- package/lib/types/data-grid/stories/datagrid-in-dialog.story.d.ts.map +1 -1
- package/lib/types/data-grid/stories/datagrid-pinned-columns.stories.d.ts +10 -1
- package/lib/types/data-grid/stories/datagrid-pinned-columns.stories.d.ts.map +1 -1
- package/lib/types/data-grid/stories/datagrid-search-and-filters.stories.d.ts +10 -1
- package/lib/types/data-grid/stories/datagrid-search-and-filters.stories.d.ts.map +1 -1
- package/lib/types/data-grid/stories/datagrid-using-editable-cells.story.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -22,93 +22,186 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
22
22
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
23
|
*/
|
|
24
24
|
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const base_1 = require("@neo4j-ndl/base");
|
|
25
26
|
const react_1 = require("@neo4j-ndl/react");
|
|
27
|
+
const icons_1 = require("@neo4j-ndl/react/icons");
|
|
26
28
|
const react_table_1 = require("@tanstack/react-table");
|
|
27
29
|
const react_2 = require("react");
|
|
28
|
-
const
|
|
30
|
+
const ROLE_OPTIONS = [
|
|
31
|
+
{ label: 'Admin', value: 'admin' },
|
|
32
|
+
{ label: 'Editor', value: 'editor' },
|
|
33
|
+
{ label: 'Viewer', value: 'viewer' },
|
|
34
|
+
];
|
|
35
|
+
const PERMISSION_OPTIONS = [
|
|
36
|
+
{ label: 'Read', value: 'read' },
|
|
37
|
+
{ label: 'Write', value: 'write' },
|
|
38
|
+
{ label: 'Delete', value: 'delete' },
|
|
39
|
+
];
|
|
40
|
+
const LABEL_OPTIONS = [
|
|
41
|
+
{ label: 'Person', value: 'person' },
|
|
42
|
+
{ label: 'Movie', value: 'movie' },
|
|
43
|
+
{ label: 'Director', value: 'director' },
|
|
44
|
+
{ label: 'Actor', value: 'actor' },
|
|
45
|
+
];
|
|
46
|
+
const STATUS_OPTIONS = [
|
|
47
|
+
{ label: 'Active', value: 'active' },
|
|
48
|
+
{ label: 'Inactive', value: 'inactive' },
|
|
49
|
+
{ label: 'Pending', value: 'pending' },
|
|
50
|
+
];
|
|
51
|
+
const VALID_STATUSES = STATUS_OPTIONS.map((option) => option.value);
|
|
52
|
+
const LABEL_COLORS = {
|
|
53
|
+
actor: base_1.tokens.graph['7'],
|
|
54
|
+
director: base_1.tokens.graph['4'],
|
|
55
|
+
movie: base_1.tokens.graph['3'],
|
|
56
|
+
person: base_1.tokens.graph['1'],
|
|
57
|
+
};
|
|
58
|
+
// Render each selected value as a non-interactive GraphLabel (as a span)
|
|
59
|
+
// instead of the default Tag chip, demonstrating the components override.
|
|
60
|
+
const LabelMultiValue = (props) => ((0, jsx_runtime_1.jsx)(react_1.GraphLabel, { as: "span", type: "node", size: "small", color: LABEL_COLORS[props.data.value], children: props.data.label }));
|
|
61
|
+
// The "Dallas Kuhn" row has a status that is not part of the available
|
|
62
|
+
// options, so its dropdown cell renders in the error state.
|
|
63
|
+
const DEMO_DATA = [
|
|
64
|
+
{
|
|
65
|
+
labels: ['person', 'actor'],
|
|
66
|
+
name: 'Alicia Sanford',
|
|
67
|
+
permissions: ['read', 'write'],
|
|
68
|
+
role: 'admin',
|
|
69
|
+
status: 'active',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
labels: ['movie'],
|
|
73
|
+
name: 'Dallas Kuhn',
|
|
74
|
+
permissions: ['read'],
|
|
75
|
+
role: 'editor',
|
|
76
|
+
status: 'unknown',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
labels: ['director'],
|
|
80
|
+
name: 'Susan Daugherty MD',
|
|
81
|
+
permissions: ['read', 'write', 'delete'],
|
|
82
|
+
role: 'viewer',
|
|
83
|
+
status: 'pending',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
labels: ['person'],
|
|
87
|
+
name: 'Karen Huel',
|
|
88
|
+
permissions: ['read'],
|
|
89
|
+
role: 'editor',
|
|
90
|
+
status: 'inactive',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
labels: ['movie', 'director'],
|
|
94
|
+
name: 'Ken Kessler',
|
|
95
|
+
permissions: ['write', 'delete'],
|
|
96
|
+
role: 'admin',
|
|
97
|
+
status: 'active',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
labels: [],
|
|
101
|
+
name: 'Courtney McClure',
|
|
102
|
+
permissions: [],
|
|
103
|
+
role: 'viewer',
|
|
104
|
+
status: 'pending',
|
|
105
|
+
},
|
|
106
|
+
];
|
|
29
107
|
const columnHelper = (0, react_table_1.createColumnHelper)();
|
|
30
108
|
const Component = () => {
|
|
31
|
-
const [data, setData] = (0, react_2.useState)(
|
|
109
|
+
const [data, setData] = (0, react_2.useState)(DEMO_DATA);
|
|
110
|
+
const updateRow = (name, update) => {
|
|
111
|
+
setData((oldData) => oldData.map((row) => (row.name === name ? Object.assign(Object.assign({}, row), update) : row)));
|
|
112
|
+
};
|
|
32
113
|
const COMMON_COLUMNS = [
|
|
114
|
+
// Editable inline text cell.
|
|
33
115
|
columnHelper.accessor('name', {
|
|
34
116
|
cell: (cell) => ((0, jsx_runtime_1.jsx)(react_1.DataGrid.InlineEditCell, { cell: cell, value: cell.getValue(), ariaLabel: "edit name" })),
|
|
35
117
|
meta: {
|
|
36
118
|
isInlineEditCell: {
|
|
37
119
|
onEditChange: (newValue, cell) => {
|
|
38
|
-
|
|
39
|
-
return oldData.map((row) => {
|
|
40
|
-
if (row.name === cell.row.original.name) {
|
|
41
|
-
return Object.assign(Object.assign({}, row), { name: newValue });
|
|
42
|
-
}
|
|
43
|
-
return row;
|
|
44
|
-
});
|
|
45
|
-
});
|
|
120
|
+
updateRow(cell.row.original.name, { name: newValue });
|
|
46
121
|
},
|
|
47
122
|
},
|
|
48
123
|
},
|
|
49
124
|
minSize: 180,
|
|
50
125
|
size: 220,
|
|
51
126
|
}),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
label: '37',
|
|
64
|
-
value: '37',
|
|
127
|
+
// Default single-select dropdown.
|
|
128
|
+
columnHelper.accessor('role', {
|
|
129
|
+
cell: (info) => ((0, jsx_runtime_1.jsx)(react_1.DataGrid.DropDownCell, { cell: info, options: ROLE_OPTIONS, ariaLabel: "select role" })),
|
|
130
|
+
meta: {
|
|
131
|
+
isDropDownCell: {
|
|
132
|
+
onChange: (newValue, cell) => {
|
|
133
|
+
if (newValue === undefined) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
updateRow(cell.row.original.name, { role: newValue });
|
|
65
137
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
minSize: 160,
|
|
141
|
+
size: 180,
|
|
142
|
+
}),
|
|
143
|
+
// Default multi-select dropdown (default Tag chips).
|
|
144
|
+
columnHelper.accessor('permissions', {
|
|
145
|
+
cell: (info) => ((0, jsx_runtime_1.jsx)(react_1.DataGrid.DropDownCell, { cell: info, options: PERMISSION_OPTIONS, ariaLabel: "select permissions" })),
|
|
146
|
+
enableSorting: false,
|
|
147
|
+
meta: {
|
|
148
|
+
isDropDownCell: {
|
|
149
|
+
isMulti: true,
|
|
150
|
+
onChange: (newValue, cell) => {
|
|
151
|
+
updateRow(cell.row.original.name, { permissions: newValue });
|
|
69
152
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
minSize: 220,
|
|
156
|
+
size: 260,
|
|
157
|
+
}),
|
|
158
|
+
// Multi-select dropdown with a custom MultiValue (GraphLabel chips).
|
|
159
|
+
columnHelper.accessor('labels', {
|
|
160
|
+
cell: (info) => ((0, jsx_runtime_1.jsx)(react_1.DataGrid.DropDownCell, { cell: info, options: LABEL_OPTIONS, ariaLabel: "select labels", components: { MultiValue: LabelMultiValue } })),
|
|
161
|
+
enableSorting: false,
|
|
162
|
+
meta: {
|
|
163
|
+
isDropDownCell: {
|
|
164
|
+
isMulti: true,
|
|
165
|
+
onChange: (newValue, cell) => {
|
|
166
|
+
updateRow(cell.row.original.name, { labels: newValue });
|
|
73
167
|
},
|
|
74
|
-
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
minSize: 240,
|
|
171
|
+
size: 280,
|
|
172
|
+
}),
|
|
173
|
+
// Single-select dropdown in an error state.
|
|
174
|
+
columnHelper.accessor('status', {
|
|
175
|
+
cell: (info) => {
|
|
176
|
+
const isInvalid = !VALID_STATUSES.includes(info.getValue());
|
|
177
|
+
const isPending = info.getValue() === 'pending';
|
|
178
|
+
const isInactive = info.getValue() === 'inactive';
|
|
179
|
+
const warningHelpText = ((0, jsx_runtime_1.jsxs)("span", { className: "n-flex n-items-center n-gap-token-2 n-text-warning-text", children: [(0, jsx_runtime_1.jsx)(icons_1.ExclamationTriangleIconSolid, { className: "n-size-token-16 n-text-warning-icon" }), "Inactive users cannot sign in"] }));
|
|
180
|
+
return ((0, jsx_runtime_1.jsx)(react_1.DataGrid.DropDownCell, { cell: info, options: STATUS_OPTIONS, ariaLabel: "select status", errorText: isInvalid ? 'Please select a valid status' : undefined, helpText: isInactive
|
|
181
|
+
? warningHelpText
|
|
182
|
+
: isPending
|
|
183
|
+
? 'Waiting for admin approval'
|
|
184
|
+
: undefined }));
|
|
185
|
+
},
|
|
75
186
|
meta: {
|
|
76
187
|
isDropDownCell: {
|
|
77
188
|
onChange: (newValue, cell) => {
|
|
78
189
|
if (newValue === undefined) {
|
|
79
|
-
// No change
|
|
80
190
|
return;
|
|
81
191
|
}
|
|
82
|
-
|
|
83
|
-
if (isNaN(parsedValue)) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
setData((oldData) => {
|
|
87
|
-
return oldData.map((row) => {
|
|
88
|
-
if (row.name === cell.row.original.name) {
|
|
89
|
-
return Object.assign(Object.assign({}, row), { age: parsedValue });
|
|
90
|
-
}
|
|
91
|
-
return row;
|
|
92
|
-
});
|
|
93
|
-
});
|
|
192
|
+
updateRow(cell.row.original.name, { status: newValue });
|
|
94
193
|
},
|
|
95
194
|
},
|
|
96
195
|
},
|
|
97
|
-
minSize:
|
|
98
|
-
|
|
99
|
-
columnHelper.accessor('cypherCommand', {
|
|
100
|
-
cell: (info) => info.getValue(),
|
|
101
|
-
minSize: 400,
|
|
102
|
-
size: 400,
|
|
196
|
+
minSize: 200,
|
|
197
|
+
size: 240,
|
|
103
198
|
}),
|
|
104
199
|
];
|
|
105
200
|
const table = (0, react_table_1.useReactTable)({
|
|
201
|
+
autoResetPageIndex: false,
|
|
106
202
|
columnResizeMode: 'onChange',
|
|
107
203
|
columns: COMMON_COLUMNS,
|
|
108
204
|
data: data,
|
|
109
|
-
debugColumns: true,
|
|
110
|
-
debugHeaders: true,
|
|
111
|
-
debugTable: true,
|
|
112
205
|
defaultColumn: {
|
|
113
206
|
maxSize: 800,
|
|
114
207
|
minSize: 80,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datagrid-using-editable-cells.story.js","sourceRoot":"","sources":["../../../../src/data-grid/stories/datagrid-using-editable-cells.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAA4C;AAC5C,uDAM+B;AAC/B,iCAAiC;AAEjC,6CAA+C;AAQ/C,MAAM,YAAY,GAAG,IAAA,gCAAkB,GAAkB,CAAC;AAE1D,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAC,4BAAe,CAAC,CAAC;IAElD,MAAM,cAAc,GAAG;QACrB,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE;YAC5B,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CACd,uBAAC,gBAAQ,CAAC,cAAc,IACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EACtB,SAAS,EAAC,WAAW,GACrB,CACH;YACD,IAAI,EAAE;gBACJ,gBAAgB,EAAE;oBAChB,YAAY,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE;wBAC/B,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;4BAClB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;gCACzB,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;oCACxC,uCACK,GAAG,KACN,IAAI,EAAE,QAAQ,IACd;gCACJ,CAAC;gCACD,OAAO,GAAG,CAAC;4BACb,CAAC,CAAC,CAAC;wBACL,CAAC,CAAC,CAAC;oBACL,CAAC;iBACF;aACF;YACD,OAAO,EAAE,GAAG;YACZ,IAAI,EAAE,GAAG;SACV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,YAAY,CAAC,QAAQ,CAAC,eAAe,EAAE;YACrC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE;YAC/B,OAAO,EAAE,GAAG;YACZ,IAAI,EAAE,GAAG;SACV,CAAC;KACH,CAAC;IACF,MAAM,KAAK,GAAG,IAAA,2BAAa,EAAC;QAC1B,gBAAgB,EAAE,UAAU;QAC5B,OAAO,EAAE,cAAc;QACvB,IAAI,EAAE,IAAI;QACV,YAAY,EAAE,IAAI;QAClB,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE;YACb,OAAO,EAAE,GAAG;YACZ,OAAO,EAAE,EAAE;SACZ;QACD,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAA,6BAAe,GAAE;QAClC,qBAAqB,EAAE,IAAA,mCAAqB,GAAE;QAC9C,iBAAiB,EAAE,IAAA,+BAAiB,GAAE;QACtC,YAAY,EAAE;YACZ,UAAU,EAAE;gBACV,QAAQ,EAAE,CAAC;aACZ;SACF;KACF,CAAC,CAAC;IAEH,OAAO,CACL,gCAAK,SAAS,EAAC,0CAA0C,YACvD,uBAAC,gBAAQ,IACP,mBAAmB,EAAE,IAAI,EACzB,WAAW,EAAE,IAAI,EACjB,OAAO,EAAE;gBACP,WAAW,EAAE,WAAW;gBACxB,gBAAgB,EAAE,KAAK;aACxB,EACD,aAAa,EAAE,KAAK,GACpB,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { DataGrid } from '@neo4j-ndl/react';\nimport {\n createColumnHelper,\n getCoreRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n useReactTable,\n} from '@tanstack/react-table';\nimport { useState } from 'react';\n\nimport { TABLE_DEMO_DATA } from './staticData';\n\ntype TestDataFormat = {\n name: string;\n age: number;\n cypherCommand: string;\n};\n\nconst columnHelper = createColumnHelper<TestDataFormat>();\n\nconst Component = () => {\n const [data, setData] = useState(TABLE_DEMO_DATA);\n\n const COMMON_COLUMNS = [\n columnHelper.accessor('name', {\n cell: (cell) => (\n <DataGrid.InlineEditCell\n cell={cell}\n value={cell.getValue()}\n ariaLabel=\"edit name\"\n />\n ),\n meta: {\n isInlineEditCell: {\n onEditChange: (newValue, cell) => {\n setData((oldData) => {\n return oldData.map((row) => {\n if (row.name === cell.row.original.name) {\n return {\n ...row,\n name: newValue,\n };\n }\n return row;\n });\n });\n },\n },\n },\n minSize: 180,\n size: 220,\n }),\n columnHelper.accessor('age', {\n cell: (info) => (\n <DataGrid.DropDownCell\n cell={info}\n options={[\n {\n label: '12',\n value: '12',\n },\n {\n label: '32',\n value: '32',\n },\n {\n label: '37',\n value: '37',\n },\n {\n label: '39',\n value: '39',\n },\n {\n label: '51',\n value: '51',\n },\n ]}\n ariaLabel=\"select age\"\n />\n ),\n meta: {\n isDropDownCell: {\n onChange: (newValue, cell) => {\n if (newValue === undefined) {\n // No change\n return;\n }\n\n const parsedValue = parseInt(newValue, 10);\n\n if (isNaN(parsedValue)) {\n return;\n }\n\n setData((oldData) => {\n return oldData.map((row) => {\n if (row.name === cell.row.original.name) {\n return {\n ...row,\n age: parsedValue,\n };\n }\n return row;\n });\n });\n },\n },\n },\n minSize: 80,\n }),\n columnHelper.accessor('cypherCommand', {\n cell: (info) => info.getValue(),\n minSize: 400,\n size: 400,\n }),\n ];\n const table = useReactTable({\n columnResizeMode: 'onChange',\n columns: COMMON_COLUMNS,\n data: data,\n debugColumns: true,\n debugHeaders: true,\n debugTable: true,\n defaultColumn: {\n maxSize: 800,\n minSize: 80,\n },\n enableSorting: true,\n getCoreRowModel: getCoreRowModel(),\n getPaginationRowModel: getPaginationRowModel(),\n getSortedRowModel: getSortedRowModel(),\n initialState: {\n pagination: {\n pageSize: 5,\n },\n },\n });\n\n return (\n <div className=\"n-w-full n-bg-light-neutral-text-weakest\">\n <DataGrid\n isKeyboardNavigable={true}\n isResizable={true}\n styling={{\n borderStyle: 'all-sides',\n hasZebraStriping: false,\n }}\n tableInstance={table}\n />\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
1
|
+
{"version":3,"file":"datagrid-using-editable-cells.story.js","sourceRoot":"","sources":["../../../../src/data-grid/stories/datagrid-using-editable-cells.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,0CAAyC;AACzC,4CAAwD;AACxD,kDAAsE;AACtE,uDAM+B;AAC/B,iCAAiC;AAWjC,MAAM,YAAY,GAAG;IACnB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IAClC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;CACrC,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACzB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAChC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IAClC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;CACrC,CAAC;AAEF,MAAM,aAAa,GAAG;IACpB,EAAE,KAAK,EAAE,QAAQ,EAAE,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AC;QAC1B,kBAAkB,EAAE,KAAK;QACzB,gBAAgB,EAAE,UAAU;QAC5B,OAAO,EAAE,cAAc;QACvB,IAAI,EAAE,IAAI;QACV,aAAa,EAAE;YACb,OAAO,EAAE,GAAG;YACZ,OAAO,EAAE,EAAE;SACZ;QACD,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAA,6BAAe,GAAE;QAClC,qBAAqB,EAAE,IAAA,mCAAqB,GAAE;QAC9C,iBAAiB,EAAE,IAAA,+BAAiB,GAAE;QACtC,YAAY,EAAE;YACZ,UAAU,EAAE;gBACV,QAAQ,EAAE,CAAC;aACZ;SACF;KACF,CAAC,CAAC;IAEH,OAAO,CACL,gCAAK,SAAS,EAAC,0CAA0C,YACvD,uBAAC,gBAAQ,IACP,mBAAmB,EAAE,IAAI,EACzB,WAAW,EAAE,IAAI,EACjB,OAAO,EAAE;gBACP,WAAW,EAAE,WAAW;gBACxB,gBAAgB,EAAE,KAAK;aACxB,EACD,aAAa,EAAE,KAAK,GACpB,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { tokens } from '@neo4j-ndl/base';\nimport { DataGrid, GraphLabel } from '@neo4j-ndl/react';\nimport { ExclamationTriangleIconSolid } from '@neo4j-ndl/react/icons';\nimport {\n createColumnHelper,\n getCoreRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n useReactTable,\n} from '@tanstack/react-table';\nimport { useState } from 'react';\nimport { type MultiValueProps } from 'react-select';\n\ntype TestDataFormat = {\n name: string;\n role: string;\n permissions: string[];\n labels: string[];\n status: string;\n};\n\nconst ROLE_OPTIONS = [\n { label: 'Admin', value: 'admin' },\n { label: 'Editor', value: 'editor' },\n { label: 'Viewer', value: 'viewer' },\n];\n\nconst PERMISSION_OPTIONS = [\n { label: 'Read', value: 'read' },\n { label: 'Write', value: 'write' },\n { label: 'Delete', value: 'delete' },\n];\n\nconst LABEL_OPTIONS = [\n { label: 'Person', value: 'person' },\n { label: 'Movie', value: 'movie' },\n { label: 'Director', value: 'director' },\n { label: 'Actor', value: 'actor' },\n];\n\nconst STATUS_OPTIONS = [\n { label: 'Active', value: 'active' },\n { label: 'Inactive', value: 'inactive' },\n { label: 'Pending', value: 'pending' },\n];\n\nconst VALID_STATUSES = STATUS_OPTIONS.map((option) => option.value);\n\ntype DropDownOption = { value: string; label: string };\n\nconst LABEL_COLORS: Record<string, string> = {\n actor: tokens.graph['7'],\n director: tokens.graph['4'],\n movie: tokens.graph['3'],\n person: tokens.graph['1'],\n};\n\n// Render each selected value as a non-interactive GraphLabel (as a span)\n// instead of the default Tag chip, demonstrating the components override.\nconst LabelMultiValue = (props: MultiValueProps<DropDownOption, boolean>) => (\n <GraphLabel\n as=\"span\"\n type=\"node\"\n size=\"small\"\n color={LABEL_COLORS[props.data.value]}\n >\n {props.data.label}\n </GraphLabel>\n);\n\n// The \"Dallas Kuhn\" row has a status that is not part of the available\n// options, so its dropdown cell renders in the error state.\nconst DEMO_DATA: TestDataFormat[] = [\n {\n labels: ['person', 'actor'],\n name: 'Alicia Sanford',\n permissions: ['read', 'write'],\n role: 'admin',\n status: 'active',\n },\n {\n labels: ['movie'],\n name: 'Dallas Kuhn',\n permissions: ['read'],\n role: 'editor',\n status: 'unknown',\n },\n {\n labels: ['director'],\n name: 'Susan Daugherty MD',\n permissions: ['read', 'write', 'delete'],\n role: 'viewer',\n status: 'pending',\n },\n {\n labels: ['person'],\n name: 'Karen Huel',\n permissions: ['read'],\n role: 'editor',\n status: 'inactive',\n },\n {\n labels: ['movie', 'director'],\n name: 'Ken Kessler',\n permissions: ['write', 'delete'],\n role: 'admin',\n status: 'active',\n },\n {\n labels: [],\n name: 'Courtney McClure',\n permissions: [],\n role: 'viewer',\n status: 'pending',\n },\n];\n\nconst columnHelper = createColumnHelper<TestDataFormat>();\n\nconst Component = () => {\n const [data, setData] = useState(DEMO_DATA);\n\n const updateRow = (name: string, update: Partial<TestDataFormat>): void => {\n setData((oldData) =>\n oldData.map((row) => (row.name === name ? { ...row, ...update } : row)),\n );\n };\n\n const COMMON_COLUMNS = [\n // Editable inline text cell.\n columnHelper.accessor('name', {\n cell: (cell) => (\n <DataGrid.InlineEditCell\n cell={cell}\n value={cell.getValue()}\n ariaLabel=\"edit name\"\n />\n ),\n meta: {\n isInlineEditCell: {\n onEditChange: (newValue, cell) => {\n updateRow(cell.row.original.name, { name: newValue });\n },\n },\n },\n minSize: 180,\n size: 220,\n }),\n // Default single-select dropdown.\n columnHelper.accessor('role', {\n cell: (info) => (\n <DataGrid.DropDownCell\n cell={info}\n options={ROLE_OPTIONS}\n ariaLabel=\"select role\"\n />\n ),\n meta: {\n isDropDownCell: {\n onChange: (newValue, cell) => {\n if (newValue === undefined) {\n return;\n }\n updateRow(cell.row.original.name, { role: newValue });\n },\n },\n },\n minSize: 160,\n size: 180,\n }),\n // Default multi-select dropdown (default Tag chips).\n columnHelper.accessor('permissions', {\n cell: (info) => (\n <DataGrid.DropDownCell\n cell={info}\n options={PERMISSION_OPTIONS}\n ariaLabel=\"select permissions\"\n />\n ),\n enableSorting: false,\n meta: {\n isDropDownCell: {\n isMulti: true,\n onChange: (newValue, cell) => {\n updateRow(cell.row.original.name, { permissions: newValue });\n },\n },\n },\n minSize: 220,\n size: 260,\n }),\n // Multi-select dropdown with a custom MultiValue (GraphLabel chips).\n columnHelper.accessor('labels', {\n cell: (info) => (\n <DataGrid.DropDownCell\n cell={info}\n options={LABEL_OPTIONS}\n ariaLabel=\"select labels\"\n components={{ MultiValue: LabelMultiValue }}\n />\n ),\n enableSorting: false,\n meta: {\n isDropDownCell: {\n isMulti: true,\n onChange: (newValue, cell) => {\n updateRow(cell.row.original.name, { labels: newValue });\n },\n },\n },\n minSize: 240,\n size: 280,\n }),\n // Single-select dropdown in an error state.\n columnHelper.accessor('status', {\n cell: (info) => {\n const isInvalid = !VALID_STATUSES.includes(info.getValue());\n\n const isPending = info.getValue() === 'pending';\n const isInactive = info.getValue() === 'inactive';\n\n const warningHelpText = (\n <span className=\"n-flex n-items-center n-gap-token-2 n-text-warning-text\">\n <ExclamationTriangleIconSolid className=\"n-size-token-16 n-text-warning-icon\" />\n Inactive users cannot sign in\n </span>\n );\n\n return (\n <DataGrid.DropDownCell\n cell={info}\n options={STATUS_OPTIONS}\n ariaLabel=\"select status\"\n errorText={isInvalid ? 'Please select a valid status' : undefined}\n helpText={\n isInactive\n ? warningHelpText\n : isPending\n ? 'Waiting for admin approval'\n : undefined\n }\n />\n );\n },\n meta: {\n isDropDownCell: {\n onChange: (newValue, cell) => {\n if (newValue === undefined) {\n return;\n }\n updateRow(cell.row.original.name, { status: newValue });\n },\n },\n },\n minSize: 200,\n size: 240,\n }),\n ];\n const table = useReactTable({\n autoResetPageIndex: false,\n columnResizeMode: 'onChange',\n columns: COMMON_COLUMNS,\n data: data,\n defaultColumn: {\n maxSize: 800,\n minSize: 80,\n },\n enableSorting: true,\n getCoreRowModel: getCoreRowModel(),\n getPaginationRowModel: getPaginationRowModel(),\n getSortedRowModel: getSortedRowModel(),\n initialState: {\n pagination: {\n pageSize: 5,\n },\n },\n });\n\n return (\n <div className=\"n-w-full n-bg-light-neutral-text-weakest\">\n <DataGrid\n isKeyboardNavigable={true}\n isResizable={true}\n styling={{\n borderStyle: 'all-sides',\n hasZebraStriping: false,\n }}\n tableInstance={table}\n />\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -97,9 +97,14 @@ const PreviewCode = (_a) => {
|
|
|
97
97
|
// wrapLongLines
|
|
98
98
|
codeTagProps: { className: 'n-ai-preview-code' }, showLineNumbers: false, children: code }) })] }))] })));
|
|
99
99
|
};
|
|
100
|
+
const PreviewContent = (_a) => {
|
|
101
|
+
var { children, ref, style, className, htmlAttributes } = _a, restProps = __rest(_a, ["children", "ref", "style", "className", "htmlAttributes"]);
|
|
102
|
+
return (_jsx("div", Object.assign({ ref: ref, style: style, className: classNames('ndl-ai-preview-content', className) }, restProps, htmlAttributes, { children: children })));
|
|
103
|
+
};
|
|
100
104
|
export const Preview = Object.assign(PreviewComponent, {
|
|
101
105
|
Code: PreviewCode,
|
|
102
106
|
Confirmation: PreviewConfirmation,
|
|
107
|
+
Content: PreviewContent,
|
|
103
108
|
Header: PreviewHeader,
|
|
104
109
|
});
|
|
105
110
|
//# sourceMappingURL=Preview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Preview.js","sourceRoot":"","sources":["../../../../src/ai/preview/Preview.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,eAAe,EAEf,cAAc,EACd,WAAW,EACX,UAAU,EACV,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG3E,OAAO,EAEL,SAAS,EACT,YAAY,GACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,WAAW,MAAM,uCAAuC,CAAC;AAChE,OAAO,YAAY,MAAM,wCAAwC,CAAC;AAMl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,EAChB,IAAI,EAAC,mBAAmB,EACxB,IAAI,EAAC,OAAO,GACZ,EACD,aAAa,IACb,aAGJ,QAAQ,OAAG,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAC7D,KAAK,IAAI,CACR,KAAC,WAAW,IACV,OAAO,EAAE,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAC/C,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,aAAa,YAEjB,KAAK,CAAC,WAAW,EAAE,GACR,CACf,IACa,EAChB,cAAK,SAAS,EAAC,6BAA6B,YAC1C,KAAC,iBAAiB,IAChB,QAAQ,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,MAAM,EAClC,KAAK,kCACA,QAAQ,EAAE,KACb,yBAAyB,EAAE;oCACzB,MAAM,EAAE,CAAC;oCACT,KAAK,EAAE,yCAAyC;oCAChD,UAAU,EAAE,GAAG;oCACf,SAAS,EAAE,MAAM;oCACjB,OAAO,EAAE,iBAAiB;oCAC1B,KAAK,EAAE,aAAa;iCACrB;4BAEH,2FAA2F;4BAC3F,kFAAkF;4BAClF,gBAAgB;4BAChB,YAAY,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAChD,eAAe,EAAE,KAAK,YAErB,IAAI,GACa,GAChB,IACL,CACJ,KACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IACrD,IAAI,EAAE,WAAW;IACjB,YAAY,EAAE,mBAAmB;IACjC,MAAM,EAAE,aAAa;CACtB,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n ClipboardButton,\n type CodeBlock,\n LoadingSpinner,\n StatusLabel,\n Typography,\n useNeedleTheme,\n} from '@neo4j-ndl/react';\nimport { CheckIconOutline, XMarkIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { useEffect, useState } from 'react';\nimport { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';\n\nimport { type CommonProps } from '../../_common/types';\nimport {\n type LanguageProp,\n Languages,\n loadLanguage,\n} from '../../code-block/code-languages';\nimport ndlCodeDark from '../../code-block/themes/ndl-code-dark';\nimport ndlCodeLight from '../../code-block/themes/ndl-code-light';\n\ntype PreviewProps = {\n children: React.ReactNode;\n};\n\n/**\n * Component to use for previewing certain content in AI chat applications.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PreviewComponent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\ntype PreviewHeaderProps = {\n children?: React.ReactNode;\n actions?: React.ReactNode;\n};\n\nconst PreviewHeader = ({\n children,\n actions,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewHeaderProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-header', className)}\n {...restProps}\n {...htmlAttributes}\n >\n <Typography\n variant=\"code\"\n as=\"div\"\n className=\"ndl-ai-preview-header-leading-content\"\n >\n {children}\n </Typography>\n\n {actions && (\n <div className=\"ndl-ai-preview-header-actions\">{actions}</div>\n )}\n </div>\n );\n};\n\ntype PreviewConfirmationProps = {\n /** The content to display in the confirmation */\n children?: React.ReactNode;\n /** The actions to display in the confirmation, usually two buttons; one for confirming and one for rejecting. */\n actions: React.ReactNode;\n /** Whether the confirmation is used as a footer */\n isFooter?: boolean;\n /** The status of the confirmation */\n status?: 'pending' | 'confirmed' | 'rejected';\n /** The text to display for the confirmed status */\n confirmedActionText?: string;\n /** The text to display for the rejected status */\n rejectedActionText?: string;\n};\n\nconst PreviewConfirmation = ({\n children,\n actions,\n isFooter = false,\n status = 'pending',\n confirmedActionText = 'Action confirmed',\n rejectedActionText = 'Action rejected',\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewConfirmationProps>) => {\n const classes = classNames('ndl-ai-preview-confirmation', className, {\n 'ndl-ai-preview-confirmation-footer': isFooter,\n });\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {!(isFooter && status !== 'pending') && (\n <Typography\n as=\"div\"\n variant={isFooter ? 'subheading-small' : 'body-medium'}\n className=\"ndl-ai-preview-confirmation-content\"\n >\n {children}\n </Typography>\n )}\n <Typography\n variant=\"body-medium\"\n as=\"div\"\n className=\"ndl-ai-preview-confirmation-actions\"\n >\n {status === 'pending' && actions}\n {status === 'confirmed' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <CheckIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {confirmedActionText}\n </div>\n )}\n {status === 'rejected' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <XMarkIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {rejectedActionText}\n </div>\n )}\n </Typography>\n </div>\n );\n};\n\ntype PreviewCodeProps = {\n /** The code content to display */\n code: string;\n /** The language of the code (e.g., 'cypher', 'python', 'javascript') */\n language: React.ComponentProps<typeof CodeBlock>['language'];\n /** The current state of the code block */\n label?: 'read' | 'write';\n /** Whether the code block is loading */\n isLoading?: boolean;\n /** The actions to display in the header. Should be small buttons or icon buttons only. */\n headerActions?: React.ReactNode;\n /** The theme of the code block */\n theme?: 'ndl-code-dark' | 'ndl-code-light';\n};\n\nconst PreviewCode = ({\n code,\n language,\n label,\n isLoading = false,\n headerActions,\n theme,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewCodeProps>) => {\n const [loadedLanguage, setLoadedLanguage] = useState<\n PreviewCodeProps['language'] | null\n >(null);\n const { theme: ndlTheme } = useNeedleTheme();\n\n useEffect(() => {\n if (!language || !(Languages as readonly string[]).includes(language)) {\n setLoadedLanguage('text');\n return;\n }\n\n loadLanguage(language as LanguageProp)\n .then((module) => {\n SyntaxHighlighter.registerLanguage(language, module.default);\n setLoadedLanguage(language);\n })\n .catch((err) => console.error(err));\n }, [language]);\n\n const getTheme = () => {\n switch (theme) {\n case 'ndl-code-dark':\n return ndlCodeDark;\n case 'ndl-code-light':\n return ndlCodeLight;\n default:\n return ndlTheme === 'light' ? ndlCodeLight : ndlCodeDark;\n }\n };\n\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-code', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {isLoading && (\n <div className=\"ndl-ai-preview-code-loading\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"code\">\n WRITING {language.toUpperCase()}\n </Typography>\n </div>\n )}\n {!isLoading && (\n <>\n <PreviewHeader\n className=\"ndl-ai-preview-code-header\"\n actions={\n <>\n <ClipboardButton\n textToCopy={code}\n type=\"clean-icon-button\"\n size=\"small\"\n />\n {headerActions}\n </>\n }\n >\n {language} {language.toLowerCase() === 'cypher' ? 'QUERY' : ''}\n {label && (\n <StatusLabel\n variant={label === 'write' ? 'warning' : 'info'}\n size=\"small\"\n fill=\"semi-filled\"\n >\n {label.toUpperCase()}\n </StatusLabel>\n )}\n </PreviewHeader>\n <div className=\"ndl-ai-preview-code-content\">\n <SyntaxHighlighter\n language={loadedLanguage ?? 'text'}\n style={{\n ...getTheme(),\n 'pre[class*=\"language-\"]': {\n border: 0,\n color: 'var(--theme-color-neutral-text-default)',\n lineHeight: '1',\n overflowX: 'auto',\n padding: 'var(--space-12)',\n width: 'fit-content',\n },\n }}\n // Turn on 'shouldShowLineNumbers' & 'wrapLongLines' at the same time, the display is wrong\n // https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/402\n // wrapLongLines\n codeTagProps={{ className: 'n-ai-preview-code' }}\n showLineNumbers={false}\n >\n {code}\n </SyntaxHighlighter>\n </div>\n </>\n )}\n </div>\n );\n};\n\nexport const Preview = Object.assign(PreviewComponent, {\n Code: PreviewCode,\n Confirmation: PreviewConfirmation,\n Header: PreviewHeader,\n});\n"]}
|
|
1
|
+
{"version":3,"file":"Preview.js","sourceRoot":"","sources":["../../../../src/ai/preview/Preview.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,eAAe,EAEf,cAAc,EACd,WAAW,EACX,UAAU,EACV,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG3E,OAAO,EAEL,SAAS,EACT,YAAY,GACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,WAAW,MAAM,uCAAuC,CAAC;AAChE,OAAO,YAAY,MAAM,wCAAwC,CAAC;AAMlE;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,EAOS,EAAE,EAAE;QAPb,EACxB,QAAQ,EACR,GAAG,EACH,KAAK,EACL,SAAS,EACT,cAAc,OAEmB,EAD9B,SAAS,cANY,2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IACjC,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;CACtB,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n ClipboardButton,\n type CodeBlock,\n LoadingSpinner,\n StatusLabel,\n Typography,\n useNeedleTheme,\n} from '@neo4j-ndl/react';\nimport { CheckIconOutline, XMarkIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { useEffect, useState } from 'react';\nimport { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';\n\nimport { type CommonProps } from '../../_common/types';\nimport {\n type LanguageProp,\n Languages,\n loadLanguage,\n} from '../../code-block/code-languages';\nimport ndlCodeDark from '../../code-block/themes/ndl-code-dark';\nimport ndlCodeLight from '../../code-block/themes/ndl-code-light';\n\ntype PreviewProps = {\n children: React.ReactNode;\n};\n\n/**\n * Component to use for previewing certain content in AI chat applications.\n *\n * @alpha - Changes to this component may be breaking.\n */\nconst PreviewComponent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\ntype PreviewHeaderProps = {\n children?: React.ReactNode;\n actions?: React.ReactNode;\n};\n\nconst PreviewHeader = ({\n children,\n actions,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewHeaderProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-header', className)}\n {...restProps}\n {...htmlAttributes}\n >\n <Typography\n variant=\"code\"\n as=\"div\"\n className=\"ndl-ai-preview-header-leading-content\"\n >\n {children}\n </Typography>\n\n {actions && (\n <div className=\"ndl-ai-preview-header-actions\">{actions}</div>\n )}\n </div>\n );\n};\n\ntype PreviewConfirmationProps = {\n /** The content to display in the confirmation */\n children?: React.ReactNode;\n /** The actions to display in the confirmation, usually two buttons; one for confirming and one for rejecting. */\n actions: React.ReactNode;\n /** Whether the confirmation is used as a footer */\n isFooter?: boolean;\n /** The status of the confirmation */\n status?: 'pending' | 'confirmed' | 'rejected';\n /** The text to display for the confirmed status */\n confirmedActionText?: string;\n /** The text to display for the rejected status */\n rejectedActionText?: string;\n};\n\nconst PreviewConfirmation = ({\n children,\n actions,\n isFooter = false,\n status = 'pending',\n confirmedActionText = 'Action confirmed',\n rejectedActionText = 'Action rejected',\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewConfirmationProps>) => {\n const classes = classNames('ndl-ai-preview-confirmation', className, {\n 'ndl-ai-preview-confirmation-footer': isFooter,\n });\n\n return (\n <div\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {!(isFooter && status !== 'pending') && (\n <Typography\n as=\"div\"\n variant={isFooter ? 'subheading-small' : 'body-medium'}\n className=\"ndl-ai-preview-confirmation-content\"\n >\n {children}\n </Typography>\n )}\n <Typography\n variant=\"body-medium\"\n as=\"div\"\n className=\"ndl-ai-preview-confirmation-actions\"\n >\n {status === 'pending' && actions}\n {status === 'confirmed' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <CheckIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {confirmedActionText}\n </div>\n )}\n {status === 'rejected' && (\n <div className=\"ndl-ai-preview-confirmation-confirm-reject\">\n <XMarkIconOutline className=\"ndl-ai-preview-confirmation-action-icon\" />\n {rejectedActionText}\n </div>\n )}\n </Typography>\n </div>\n );\n};\n\ntype PreviewCodeProps = {\n /** The code content to display */\n code: string;\n /** The language of the code (e.g., 'cypher', 'python', 'javascript') */\n language: React.ComponentProps<typeof CodeBlock>['language'];\n /** The current state of the code block */\n label?: 'read' | 'write';\n /** Whether the code block is loading */\n isLoading?: boolean;\n /** The actions to display in the header. Should be small buttons or icon buttons only. */\n headerActions?: React.ReactNode;\n /** The theme of the code block */\n theme?: 'ndl-code-dark' | 'ndl-code-light';\n};\n\nconst PreviewCode = ({\n code,\n language,\n label,\n isLoading = false,\n headerActions,\n theme,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewCodeProps>) => {\n const [loadedLanguage, setLoadedLanguage] = useState<\n PreviewCodeProps['language'] | null\n >(null);\n const { theme: ndlTheme } = useNeedleTheme();\n\n useEffect(() => {\n if (!language || !(Languages as readonly string[]).includes(language)) {\n setLoadedLanguage('text');\n return;\n }\n\n loadLanguage(language as LanguageProp)\n .then((module) => {\n SyntaxHighlighter.registerLanguage(language, module.default);\n setLoadedLanguage(language);\n })\n .catch((err) => console.error(err));\n }, [language]);\n\n const getTheme = () => {\n switch (theme) {\n case 'ndl-code-dark':\n return ndlCodeDark;\n case 'ndl-code-light':\n return ndlCodeLight;\n default:\n return ndlTheme === 'light' ? ndlCodeLight : ndlCodeDark;\n }\n };\n\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-code', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {isLoading && (\n <div className=\"ndl-ai-preview-code-loading\">\n <LoadingSpinner size=\"medium\" />\n <Typography variant=\"code\">\n WRITING {language.toUpperCase()}\n </Typography>\n </div>\n )}\n {!isLoading && (\n <>\n <PreviewHeader\n className=\"ndl-ai-preview-code-header\"\n actions={\n <>\n <ClipboardButton\n textToCopy={code}\n type=\"clean-icon-button\"\n size=\"small\"\n />\n {headerActions}\n </>\n }\n >\n {language} {language.toLowerCase() === 'cypher' ? 'QUERY' : ''}\n {label && (\n <StatusLabel\n variant={label === 'write' ? 'warning' : 'info'}\n size=\"small\"\n fill=\"semi-filled\"\n >\n {label.toUpperCase()}\n </StatusLabel>\n )}\n </PreviewHeader>\n <div className=\"ndl-ai-preview-code-content\">\n <SyntaxHighlighter\n language={loadedLanguage ?? 'text'}\n style={{\n ...getTheme(),\n 'pre[class*=\"language-\"]': {\n border: 0,\n color: 'var(--theme-color-neutral-text-default)',\n lineHeight: '1',\n overflowX: 'auto',\n padding: 'var(--space-12)',\n width: 'fit-content',\n },\n }}\n // Turn on 'shouldShowLineNumbers' & 'wrapLongLines' at the same time, the display is wrong\n // https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/402\n // wrapLongLines\n codeTagProps={{ className: 'n-ai-preview-code' }}\n showLineNumbers={false}\n >\n {code}\n </SyntaxHighlighter>\n </div>\n </>\n )}\n </div>\n );\n};\n\ntype PreviewContentProps = {\n children?: React.ReactNode;\n};\n\nconst PreviewContent = ({\n children,\n ref,\n style,\n className,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', PreviewContentProps>) => {\n return (\n <div\n ref={ref}\n style={style}\n className={classNames('ndl-ai-preview-content', className)}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nexport const Preview = Object.assign(PreviewComponent, {\n Code: PreviewCode,\n Confirmation: PreviewConfirmation,\n Content: PreviewContent,\n Header: PreviewHeader,\n});\n"]}
|
|
@@ -25,6 +25,8 @@ export { default as PreviewCodeLoading } from './preview-code-loading.story';
|
|
|
25
25
|
export { default as PreviewCodeRead } from './preview-code-read.story';
|
|
26
26
|
export { default as PreviewCodeWrite } from './preview-code-write.story';
|
|
27
27
|
export { default as PreviewCodeLanguages } from './preview-code-languages.story';
|
|
28
|
+
export { default as PreviewSimple } from './preview-simple.story';
|
|
29
|
+
export { default as PreviewSimpleWithContent } from './preview-simple-with-content.story';
|
|
28
30
|
import { removeLicenseHeader } from '../../../_common/export-stories-utils';
|
|
29
31
|
import PreviewCodeConfirmationSrcRaw from './preview-code-confirmation.story?raw';
|
|
30
32
|
import PreviewCodeLanguagesSrcRaw from './preview-code-languages.story?raw';
|
|
@@ -33,6 +35,8 @@ import PreviewCodeReadSrcRaw from './preview-code-read.story?raw';
|
|
|
33
35
|
import PreviewCodeWriteSrcRaw from './preview-code-write.story?raw';
|
|
34
36
|
import PreviewConfirmationStandaloneSrcRaw from './preview-confirmation-standalone.story?raw';
|
|
35
37
|
import PreviewDataGridSrcRaw from './preview-data-grid.story?raw';
|
|
38
|
+
import PreviewSimpleSrcRaw from './preview-simple.story?raw';
|
|
39
|
+
import PreviewSimpleWithContentSrcRaw from './preview-simple-with-content.story?raw';
|
|
36
40
|
export const PreviewDataGridSrc = removeLicenseHeader(PreviewDataGridSrcRaw);
|
|
37
41
|
export const PreviewConfirmationStandaloneSrc = removeLicenseHeader(PreviewConfirmationStandaloneSrcRaw);
|
|
38
42
|
export const PreviewCodeConfirmationSrc = removeLicenseHeader(PreviewCodeConfirmationSrcRaw);
|
|
@@ -40,4 +44,6 @@ export const PreviewCodeLoadingSrc = removeLicenseHeader(PreviewCodeLoadingSrcRa
|
|
|
40
44
|
export const PreviewCodeReadSrc = removeLicenseHeader(PreviewCodeReadSrcRaw);
|
|
41
45
|
export const PreviewCodeWriteSrc = removeLicenseHeader(PreviewCodeWriteSrcRaw);
|
|
42
46
|
export const PreviewCodeLanguagesSrc = removeLicenseHeader(PreviewCodeLanguagesSrcRaw);
|
|
47
|
+
export const PreviewSimpleSrc = removeLicenseHeader(PreviewSimpleSrcRaw);
|
|
48
|
+
export const PreviewSimpleWithContentSrc = removeLicenseHeader(PreviewSimpleWithContentSrcRaw);
|
|
43
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ai/preview/stories/index.ts"],"names":[],"mappings":"AAA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AC;AAC5E,OAAO,6BAA6B,MAAM,uCAAuC,CAAC;AAClF,OAAO,0BAA0B,MAAM,oCAAoC,CAAC;AAC5E,OAAO,wBAAwB,MAAM,kCAAkC,CAAC;AACxE,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAClE,OAAO,sBAAsB,MAAM,gCAAgC,CAAC;AACpE,OAAO,mCAAmC,MAAM,6CAA6C,CAAC;AAC9F,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAClE,OAAO,mBAAmB,MAAM,4BAA4B,CAAC;AAC7D,OAAO,8BAA8B,MAAM,yCAAyC,CAAC;AAErF,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,gCAAgC,GAAG,mBAAmB,CACjE,mCAAmC,CACpC,CAAC;AACF,MAAM,CAAC,MAAM,0BAA0B,GAAG,mBAAmB,CAC3D,6BAA6B,CAC9B,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CACtD,wBAAwB,CACzB,CAAC;AACF,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,CAAC;AAC/E,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CACxD,0BAA0B,CAC3B,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;AACzE,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAC5D,8BAA8B,CAC/B,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { default as PreviewDataGrid } from './preview-data-grid.story';\nexport { default as PreviewConfirmationStandalone } from './preview-confirmation-standalone.story';\nexport { default as PreviewCodeConfirmation } from './preview-code-confirmation.story';\nexport { default as PreviewCodeLoading } from './preview-code-loading.story';\nexport { default as PreviewCodeRead } from './preview-code-read.story';\nexport { default as PreviewCodeWrite } from './preview-code-write.story';\nexport { default as PreviewCodeLanguages } from './preview-code-languages.story';\nexport { default as PreviewSimple } from './preview-simple.story';\nexport { default as PreviewSimpleWithContent } from './preview-simple-with-content.story';\n\nimport { removeLicenseHeader } from '../../../_common/export-stories-utils';\nimport PreviewCodeConfirmationSrcRaw from './preview-code-confirmation.story?raw';\nimport PreviewCodeLanguagesSrcRaw from './preview-code-languages.story?raw';\nimport PreviewCodeLoadingSrcRaw from './preview-code-loading.story?raw';\nimport PreviewCodeReadSrcRaw from './preview-code-read.story?raw';\nimport PreviewCodeWriteSrcRaw from './preview-code-write.story?raw';\nimport PreviewConfirmationStandaloneSrcRaw from './preview-confirmation-standalone.story?raw';\nimport PreviewDataGridSrcRaw from './preview-data-grid.story?raw';\nimport PreviewSimpleSrcRaw from './preview-simple.story?raw';\nimport PreviewSimpleWithContentSrcRaw from './preview-simple-with-content.story?raw';\n\nexport const PreviewDataGridSrc = removeLicenseHeader(PreviewDataGridSrcRaw);\nexport const PreviewConfirmationStandaloneSrc = removeLicenseHeader(\n PreviewConfirmationStandaloneSrcRaw,\n);\nexport const PreviewCodeConfirmationSrc = removeLicenseHeader(\n PreviewCodeConfirmationSrcRaw,\n);\nexport const PreviewCodeLoadingSrc = removeLicenseHeader(\n PreviewCodeLoadingSrcRaw,\n);\nexport const PreviewCodeReadSrc = removeLicenseHeader(PreviewCodeReadSrcRaw);\nexport const PreviewCodeWriteSrc = removeLicenseHeader(PreviewCodeWriteSrcRaw);\nexport const PreviewCodeLanguagesSrc = removeLicenseHeader(\n PreviewCodeLanguagesSrcRaw,\n);\nexport const PreviewSimpleSrc = removeLicenseHeader(PreviewSimpleSrcRaw);\nexport const PreviewSimpleWithContentSrc = removeLicenseHeader(\n PreviewSimpleWithContentSrcRaw,\n);\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
23
|
+
import { FilledButton, OutlinedButton, ReadOnlyTag } from '@neo4j-ndl/react';
|
|
24
|
+
import { Preview } from '@neo4j-ndl/react/ai';
|
|
25
|
+
import { DeploymentsIcon } from '@neo4j-ndl/react/icons';
|
|
26
|
+
import { useState } from 'react';
|
|
27
|
+
const Component = () => {
|
|
28
|
+
const [status, setStatus] = useState('pending');
|
|
29
|
+
return (_jsxs(Preview, { children: [_jsx(Preview.Header, { children: "CONNECT TO INSTANCE" }), _jsx(Preview.Content, { children: _jsx(ReadOnlyTag, { size: "small", leadingVisual: _jsx(DeploymentsIcon, {}), children: "Instance 1" }) }), _jsx(Preview.Confirmation, { status: status, isFooter: true, confirmedActionText: "Allowed action", rejectedActionText: "Skipped action", actions: _jsxs(_Fragment, { children: [_jsx(OutlinedButton, { variant: "neutral", size: "small", onClick: () => setStatus('rejected'), children: "Skip" }), _jsx(FilledButton, { variant: "primary", size: "small", onClick: () => setStatus('confirmed'), children: "Allow" })] }) })] }));
|
|
30
|
+
};
|
|
31
|
+
export default Component;
|
|
32
|
+
//# sourceMappingURL=preview-simple-with-content.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-simple-with-content.story.js","sourceRoot":"","sources":["../../../../../src/ai/preview/stories/preview-simple-with-content.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACvB,QAAQ,CACN,SAAS,CACV,CAAC;IAEJ,OAAO,CACL,MAAC,OAAO,eACN,KAAC,OAAO,CAAC,MAAM,sCAAqC,EACpD,KAAC,OAAO,CAAC,OAAO,cACd,KAAC,WAAW,IAAC,IAAI,EAAC,OAAO,EAAC,aAAa,EAAE,KAAC,eAAe,KAAG,2BAE9C,GACE,EAClB,KAAC,OAAO,CAAC,YAAY,IACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,IAAI,EACd,mBAAmB,EAAC,gBAAgB,EACpC,kBAAkB,EAAC,gBAAgB,EACnC,OAAO,EACL,8BACE,KAAC,cAAc,IACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,qBAGrB,EACjB,KAAC,YAAY,IACX,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,sBAGxB,IACd,GAEiB,IAChB,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { FilledButton, OutlinedButton, ReadOnlyTag } from '@neo4j-ndl/react';\nimport { Preview } from '@neo4j-ndl/react/ai';\nimport { DeploymentsIcon } from '@neo4j-ndl/react/icons';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [status, setStatus] =\n useState<React.ComponentProps<typeof Preview.Confirmation>['status']>(\n 'pending',\n );\n\n return (\n <Preview>\n <Preview.Header>CONNECT TO INSTANCE</Preview.Header>\n <Preview.Content>\n <ReadOnlyTag size=\"small\" leadingVisual={<DeploymentsIcon />}>\n Instance 1\n </ReadOnlyTag>\n </Preview.Content>\n <Preview.Confirmation\n status={status}\n isFooter={true}\n confirmedActionText=\"Allowed action\"\n rejectedActionText=\"Skipped action\"\n actions={\n <>\n <OutlinedButton\n variant=\"neutral\"\n size=\"small\"\n onClick={() => setStatus('rejected')}\n >\n Skip\n </OutlinedButton>\n <FilledButton\n variant=\"primary\"\n size=\"small\"\n onClick={() => setStatus('confirmed')}\n >\n Allow\n </FilledButton>\n </>\n }\n ></Preview.Confirmation>\n </Preview>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
23
|
+
import { FilledButton, OutlinedButton } from '@neo4j-ndl/react';
|
|
24
|
+
import { Preview } from '@neo4j-ndl/react/ai';
|
|
25
|
+
import { useState } from 'react';
|
|
26
|
+
const Component = () => {
|
|
27
|
+
const [status, setStatus] = useState('pending');
|
|
28
|
+
return (_jsxs(Preview, { children: [_jsx(Preview.Header, { children: "CONNECT TO INSTANCE" }), _jsx(Preview.Confirmation, { status: status, isFooter: true, confirmedActionText: "Instance selected", rejectedActionText: "Skipped", actions: _jsxs(_Fragment, { children: [_jsx(OutlinedButton, { variant: "neutral", size: "small", onClick: () => setStatus('rejected'), children: "Skip" }), _jsx(FilledButton, { variant: "primary", size: "small", onClick: () => setStatus('confirmed'), children: "Select instance" })] }) })] }));
|
|
29
|
+
};
|
|
30
|
+
export default Component;
|
|
31
|
+
//# sourceMappingURL=preview-simple.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-simple.story.js","sourceRoot":"","sources":["../../../../../src/ai/preview/stories/preview-simple.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACvB,QAAQ,CACN,SAAS,CACV,CAAC;IAEJ,OAAO,CACL,MAAC,OAAO,eACN,KAAC,OAAO,CAAC,MAAM,sCAAqC,EACpD,KAAC,OAAO,CAAC,YAAY,IACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,IAAI,EACd,mBAAmB,EAAC,mBAAmB,EACvC,kBAAkB,EAAC,SAAS,EAC5B,OAAO,EACL,8BACE,KAAC,cAAc,IACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,qBAGrB,EACjB,KAAC,YAAY,IACX,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,gCAGxB,IACd,GAEiB,IAChB,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { FilledButton, OutlinedButton } from '@neo4j-ndl/react';\nimport { Preview } from '@neo4j-ndl/react/ai';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [status, setStatus] =\n useState<React.ComponentProps<typeof Preview.Confirmation>['status']>(\n 'pending',\n );\n\n return (\n <Preview>\n <Preview.Header>CONNECT TO INSTANCE</Preview.Header>\n <Preview.Confirmation\n status={status}\n isFooter={true}\n confirmedActionText=\"Instance selected\"\n rejectedActionText=\"Skipped\"\n actions={\n <>\n <OutlinedButton\n variant=\"neutral\"\n size=\"small\"\n onClick={() => setStatus('rejected')}\n >\n Skip\n </OutlinedButton>\n <FilledButton\n variant=\"primary\"\n size=\"small\"\n onClick={() => setStatus('confirmed')}\n >\n Select instance\n </FilledButton>\n </>\n }\n ></Preview.Confirmation>\n </Preview>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -30,8 +30,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
30
30
|
* You should have received a copy of the GNU General Public License
|
|
31
31
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
32
|
*/
|
|
33
|
-
import { CleanIconButton, DropdownButton,
|
|
34
|
-
import { ArrowSendIcon, ArrowSmallUpIconOutline,
|
|
33
|
+
import { CleanIconButton, DropdownButton, Menu, Tooltip, Typography, } from '@neo4j-ndl/react';
|
|
34
|
+
import { ArrowSendIcon, ArrowSmallUpIconOutline, StopCircleIconOutline, XMarkIconOutline, } from '@neo4j-ndl/react/icons';
|
|
35
35
|
import classNames from 'classnames';
|
|
36
36
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
37
37
|
/**
|
|
@@ -42,7 +42,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
42
42
|
* @alpha - Changes to this component may be breaking.
|
|
43
43
|
*/
|
|
44
44
|
const PromptComponent = (_a) => {
|
|
45
|
-
var { value, onChange, maxRows = 5, isDisabled = false, isRunningPrompt = false, onSubmitPrompt, onCancelPrompt, isSubmitDisabled = false, topContent, bottomContent, disclaimer = 'All information should be verified.', className, style, htmlAttributes, ref, textareaProps } = _a, restProps = __rest(_a, ["value", "onChange", "maxRows", "isDisabled", "isRunningPrompt", "onSubmitPrompt", "onCancelPrompt", "isSubmitDisabled", "topContent", "bottomContent", "disclaimer", "className", "style", "htmlAttributes", "ref", "textareaProps"]);
|
|
45
|
+
var { value, onChange, maxRows = 5, isDisabled = false, isRunningPrompt = false, onSubmitPrompt, onCancelPrompt, isSubmitDisabled = false, headerContent, topContent, bottomContent, bottomTrailingContent, disclaimer = 'All information should be verified.', className, style, htmlAttributes, ref, textareaProps } = _a, restProps = __rest(_a, ["value", "onChange", "maxRows", "isDisabled", "isRunningPrompt", "onSubmitPrompt", "onCancelPrompt", "isSubmitDisabled", "headerContent", "topContent", "bottomContent", "bottomTrailingContent", "disclaimer", "className", "style", "htmlAttributes", "ref", "textareaProps"]);
|
|
46
46
|
const classes = classNames('ndl-ai-prompt', className, {
|
|
47
47
|
'ndl-disabled': isDisabled,
|
|
48
48
|
});
|
|
@@ -121,9 +121,7 @@ const PromptComponent = (_a) => {
|
|
|
121
121
|
adjustTextareaHeight();
|
|
122
122
|
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
123
123
|
};
|
|
124
|
-
return (_jsxs("div", Object.assign({ ref: ref, className: classes, style: style }, restProps, htmlAttributes, { children: [_jsxs("div", { className: "ndl-ai-prompt-wrapper", children: [_jsx("div", { className:
|
|
125
|
-
'ndl-expanded': isRunningPrompt,
|
|
126
|
-
}), "aria-hidden": !isRunningPrompt, inert: !isRunningPrompt, children: _jsx("div", { className: "ndl-ai-prompt-loading-shell", children: _jsxs("div", { className: "ndl-ai-prompt-loading-content", children: [_jsx(LoadingSpinner, { size: "medium" }), _jsxs(Typography, { variant: "body-medium", children: ["Working", _jsxs("span", { className: "ndl-ai-prompt-loading-dots", children: [_jsx("span", { children: "." }), _jsx("span", { children: "." }), _jsx("span", { children: "." })] })] })] }) }) }), _jsxs("div", { className: "ndl-ai-prompt-wrapper-inner", children: [Boolean(topContent) && (_jsx("div", { className: "ndl-ai-prompt-textarea-above", ref: textareaAboveRef, children: topContent })), _jsx("textarea", Object.assign({ placeholder: "Ask anything", className: "ndl-ai-prompt-textarea", rows: 1, onChange: handleInput, value: value, ref: textareaRef, disabled: isDisabled, onKeyDown: (e) => {
|
|
124
|
+
return (_jsxs("div", Object.assign({ ref: ref, className: classes, style: style }, restProps, htmlAttributes, { children: [_jsxs("div", { className: "ndl-ai-prompt-wrapper", children: [Boolean(headerContent) && (_jsx("div", { className: "ndl-ai-prompt-header", children: headerContent })), _jsxs("div", { className: "ndl-ai-prompt-wrapper-inner", children: [Boolean(topContent) && (_jsx("div", { className: "ndl-ai-prompt-textarea-above", ref: textareaAboveRef, children: topContent })), _jsx("textarea", Object.assign({ placeholder: "Ask anything", className: "ndl-ai-prompt-textarea", rows: 1, onChange: handleInput, value: value, ref: textareaRef, disabled: isDisabled, onKeyDown: (e) => {
|
|
127
125
|
if (e.key === 'Enter' &&
|
|
128
126
|
!e.shiftKey &&
|
|
129
127
|
isSubmitDisabled !== true) {
|
|
@@ -132,18 +130,10 @@ const PromptComponent = (_a) => {
|
|
|
132
130
|
onSubmitPrompt === null || onSubmitPrompt === void 0 ? void 0 : onSubmitPrompt(e);
|
|
133
131
|
}
|
|
134
132
|
}
|
|
135
|
-
} }, textareaProps)),
|
|
133
|
+
} }, textareaProps)), _jsxs("div", { className: "ndl-ai-prompt-textarea-below", children: [Boolean(bottomContent) && (_jsx("div", { className: "ndl-ai-prompt-textarea-below-leading", children: bottomContent })), _jsxs("div", { className: "ndl-ai-prompt-textarea-below-trailing", children: [bottomTrailingContent, _jsx(SubmitPromptButton, { isDisabled: isSubmitDisabled, isRunningPrompt: isRunningPrompt, onSubmit: onSubmitPrompt, onCancel: onCancelPrompt })] })] })] })] }), Boolean(disclaimer) && (_jsx(Typography, { variant: "body-small", className: "ndl-ai-prompt-footer", children: disclaimer }))] })));
|
|
136
134
|
};
|
|
137
135
|
const SubmitPromptButton = ({ onSubmit, onCancel, isDisabled, isRunningPrompt, }) => {
|
|
138
|
-
return (_jsx(
|
|
139
|
-
'ndl-in-loading': isRunningPrompt,
|
|
140
|
-
}), children: _jsxs(Tooltip, { type: "simple", isDisabled: isDisabled || isRunningPrompt, hoverDelay: { close: 0, open: 500 }, shouldCloseOnReferenceClick: true, children: [_jsx(Tooltip.Trigger, { hasButtonWrapper: true, children: _jsx("button", { type: "button", style: {
|
|
141
|
-
borderRadius: isRunningPrompt
|
|
142
|
-
? 'var(--border-radius-sm)'
|
|
143
|
-
: 'var(--border-radius-lg)',
|
|
144
|
-
}, onClick: isRunningPrompt ? onCancel : onSubmit, disabled: isDisabled, "aria-label": isRunningPrompt ? 'Stop' : 'Send', children: isRunningPrompt === true ? (_jsx(OutlinedButton, { as: "div", variant: "neutral", className: "ndl-ai-prompt-stop-button", size: "small", leadingVisual: _jsx(StopIconOutline, {}), children: "Stop" })) : (_jsx(CleanIconButton, { description: "Send", as: "div", className: "ndl-ai-prompt-submit-button", size: "medium", isDisabled: isDisabled, htmlAttributes: {
|
|
145
|
-
'aria-pressed': undefined,
|
|
146
|
-
}, children: _jsx(ArrowSmallUpIconOutline, {}) })) }) }), _jsx(Tooltip.Content, { children: "Send" })] }) }));
|
|
136
|
+
return (_jsx(CleanIconButton, { className: "ndl-ai-prompt-submit-button", description: isRunningPrompt === true ? 'Stop' : 'Send', size: "small", isDisabled: isDisabled, onClick: isRunningPrompt === true ? onCancel : onSubmit, children: isRunningPrompt === true ? (_jsx(StopCircleIconOutline, {})) : (_jsx(ArrowSmallUpIconOutline, {})) }));
|
|
147
137
|
};
|
|
148
138
|
const AgentSelect = ({ value, options = [], onChange }) => {
|
|
149
139
|
var _a, _b, _c;
|