@guardian/stand 0.0.53 → 0.0.55
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/TagPicker.cjs +1 -1
- package/dist/TagPicker.d.cts +1 -1
- package/dist/TagPicker.d.ts +1 -1
- package/dist/TagPicker.js +1 -1
- package/dist/components/TagPicker/Autocomplete.cjs +3 -3
- package/dist/components/TagPicker/Autocomplete.js +3 -3
- package/dist/components/TagPicker/TagPicker.cjs +15 -10
- package/dist/components/TagPicker/TagPicker.d.cts +21 -5
- package/dist/components/TagPicker/TagPicker.d.ts +21 -5
- package/dist/components/TagPicker/TagPicker.js +15 -10
- package/dist/components/TagPicker/TagSearchWithFilters.cjs +6 -3
- package/dist/components/TagPicker/TagSearchWithFilters.js +6 -3
- package/dist/components/TagPicker/styles.cjs +18 -142
- package/dist/components/TagPicker/styles.js +19 -135
- package/dist/components/{TagPicker → TagTable}/TagTable.cjs +25 -7
- package/dist/components/{TagPicker → TagTable}/TagTable.d.cts +18 -4
- package/dist/components/{TagPicker → TagTable}/TagTable.d.ts +18 -4
- package/dist/components/{TagPicker → TagTable}/TagTable.js +26 -8
- package/dist/components/TagTable/styles.cjs +170 -0
- package/dist/components/TagTable/styles.js +160 -0
- package/dist/styleD/build/css/base/colors.css +1 -1
- package/dist/styleD/build/css/component/autocomplete.css +13 -6
- package/dist/styleD/build/css/component/avatar.css +1 -1
- package/dist/styleD/build/css/component/datePicker.css +2 -2
- package/dist/styleD/build/css/component/tagPicker.css +1 -0
- package/dist/styleD/build/css/component/tagTable.css +9 -5
- package/dist/styleD/build/css/semantic/colors.css +6 -1
- package/dist/styleD/build/css/semantic/sizing.css +1 -0
- package/dist/styleD/build/typescript/base/colors.cjs +1 -1
- package/dist/styleD/build/typescript/base/colors.d.cts +1 -1
- package/dist/styleD/build/typescript/base/colors.d.ts +1 -1
- package/dist/styleD/build/typescript/base/colors.js +1 -1
- package/dist/styleD/build/typescript/component/autocomplete.cjs +17 -6
- package/dist/styleD/build/typescript/component/autocomplete.d.cts +14 -1
- package/dist/styleD/build/typescript/component/autocomplete.d.ts +14 -1
- package/dist/styleD/build/typescript/component/autocomplete.js +17 -6
- package/dist/styleD/build/typescript/component/avatar.cjs +1 -1
- package/dist/styleD/build/typescript/component/avatar.js +1 -1
- package/dist/styleD/build/typescript/component/datePicker.cjs +2 -2
- package/dist/styleD/build/typescript/component/datePicker.js +2 -2
- package/dist/styleD/build/typescript/component/intendedAudienceSignifier.cjs +1 -4
- package/dist/styleD/build/typescript/component/intendedAudienceSignifier.d.cts +0 -1
- package/dist/styleD/build/typescript/component/intendedAudienceSignifier.d.ts +0 -1
- package/dist/styleD/build/typescript/component/intendedAudienceSignifier.js +1 -4
- package/dist/styleD/build/typescript/component/tagPicker.cjs +1 -0
- package/dist/styleD/build/typescript/component/tagPicker.d.cts +3 -0
- package/dist/styleD/build/typescript/component/tagPicker.d.ts +3 -0
- package/dist/styleD/build/typescript/component/tagPicker.js +1 -0
- package/dist/styleD/build/typescript/component/tagTable.cjs +11 -3
- package/dist/styleD/build/typescript/component/tagTable.d.cts +10 -2
- package/dist/styleD/build/typescript/component/tagTable.d.ts +10 -2
- package/dist/styleD/build/typescript/component/tagTable.js +11 -3
- package/dist/styleD/build/typescript/semantic/colors.cjs +6 -1
- package/dist/styleD/build/typescript/semantic/colors.d.cts +5 -0
- package/dist/styleD/build/typescript/semantic/colors.d.ts +5 -0
- package/dist/styleD/build/typescript/semantic/colors.js +6 -1
- package/dist/styleD/build/typescript/semantic/sizing.cjs +2 -1
- package/dist/styleD/build/typescript/semantic/sizing.d.cts +3 -0
- package/dist/styleD/build/typescript/semantic/sizing.d.ts +3 -0
- package/dist/styleD/build/typescript/semantic/sizing.js +2 -1
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { mergeDeep } from "../../util/mergeDeep.js";
|
|
2
2
|
import { componentAutocomplete } from "../../styleD/build/typescript/component/autocomplete.js";
|
|
3
|
-
import { componentTagTable } from "../../styleD/build/typescript/component/tagTable.js";
|
|
4
3
|
import { componentTagPicker } from "../../styleD/build/typescript/component/tagPicker.js";
|
|
5
4
|
import { css } from "@emotion/react";
|
|
6
5
|
//#region src/components/TagPicker/styles.ts
|
|
@@ -15,13 +14,27 @@ const autocompleteInputStyles = (hasIcon, partialTheme = {}) => {
|
|
|
15
14
|
border-color: ${theme.input.borderColor};
|
|
16
15
|
border-width: ${theme.input.borderWidth};
|
|
17
16
|
border-style: ${theme.input.borderStyle};
|
|
17
|
+
border-radius: ${theme.input.borderRadius};
|
|
18
|
+
|
|
18
19
|
${hasIcon && `
|
|
19
20
|
padding-right: calc(${theme.icon.paddingX} + ${theme.icon.size} + ${theme.icon.paddingX});
|
|
20
21
|
min-height: calc(${theme.icon.size});
|
|
21
22
|
`}
|
|
22
23
|
|
|
24
|
+
&[data-hovered] {
|
|
25
|
+
background-color: ${theme.input.hover.backgroundColor};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&[data-focus-visible] {
|
|
29
|
+
outline: ${theme.input.focused.outline};
|
|
30
|
+
outline-offset: ${theme.input.focused.outlineOffset};
|
|
31
|
+
}
|
|
32
|
+
|
|
23
33
|
&[data-disabled] {
|
|
24
|
-
|
|
34
|
+
cursor: ${theme.input.disabled.cursor};
|
|
35
|
+
background-color: ${theme.input.disabled.backgroundColor};
|
|
36
|
+
color: ${theme.input.disabled.color};
|
|
37
|
+
border: ${theme.input.disabled.border};
|
|
25
38
|
}
|
|
26
39
|
`;
|
|
27
40
|
};
|
|
@@ -59,137 +72,6 @@ const listboxInfoStyles = (partialTheme = {}) => {
|
|
|
59
72
|
padding: ${theme.listbox.item.paddingY} ${theme.listbox.item.paddingX};
|
|
60
73
|
`;
|
|
61
74
|
};
|
|
62
|
-
const tagTableHeadingStyles = (partialTheme = {}) => {
|
|
63
|
-
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
64
|
-
return css`
|
|
65
|
-
background-color: ${theme.heading.backgroundColor};
|
|
66
|
-
font-weight: ${theme.heading.fontWeight};
|
|
67
|
-
padding: ${theme.heading.paddingTop} ${theme.heading.paddingRight}
|
|
68
|
-
${theme.heading.paddingBottom} ${theme.heading.paddingLeft};
|
|
69
|
-
`;
|
|
70
|
-
};
|
|
71
|
-
const tagTableCellStyles = (partialTheme = {}) => {
|
|
72
|
-
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
73
|
-
return css`
|
|
74
|
-
padding: ${theme.cell.paddingY} ${theme.cell.paddingX};
|
|
75
|
-
vertical-align: middle;
|
|
76
|
-
|
|
77
|
-
:first-of-type {
|
|
78
|
-
padding-left: ${theme.cell.firstCellPaddingLeft};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
:not(:last-child) {
|
|
82
|
-
border-right-width: ${theme.cell.borderBetweenCells.borderWidth};
|
|
83
|
-
border-right-style: ${theme.cell.borderBetweenCells.borderStyle};
|
|
84
|
-
border-right-color: ${theme.cell.borderBetweenCells.borderColor};
|
|
85
|
-
}
|
|
86
|
-
`;
|
|
87
|
-
};
|
|
88
|
-
const tagTableRowStyles = (canDrag, highlightFirstRow, partialTheme = {}) => {
|
|
89
|
-
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
90
|
-
return css`
|
|
91
|
-
background-color: ${theme.row.backgroundColor};
|
|
92
|
-
height: ${theme.row.height};
|
|
93
|
-
&:not(:last-child) {
|
|
94
|
-
border-bottom-color: ${theme.row.borderBottom.borderColor};
|
|
95
|
-
border-bottom-style: ${theme.row.borderBottom.borderStyle};
|
|
96
|
-
border-bottom-width: ${theme.row.borderBottom.borderWidth};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
:hover {
|
|
100
|
-
background-color: ${theme.row.backgroundHoverColor};
|
|
101
|
-
${canDrag ? "cursor: grab;" : null}
|
|
102
|
-
button[slot='drag'] {
|
|
103
|
-
opacity: 1;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
${highlightFirstRow && `:first-of-type {
|
|
107
|
-
background-color: ${theme.row.firstRowBackgroundColor};
|
|
108
|
-
|
|
109
|
-
:hover {
|
|
110
|
-
background-color: ${theme.row.firstRowBackgroundHoverColor};
|
|
111
|
-
}
|
|
112
|
-
}`}
|
|
113
|
-
`;
|
|
114
|
-
};
|
|
115
|
-
const tagTableStyles = (canRemoveTag, partialTheme = {}) => {
|
|
116
|
-
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
117
|
-
return css`
|
|
118
|
-
width: 100%;
|
|
119
|
-
border-collapse: collapse;
|
|
120
|
-
|
|
121
|
-
.react-aria-DropIndicator[data-drop-target] {
|
|
122
|
-
height: ${theme.row.height};
|
|
123
|
-
|
|
124
|
-
${canRemoveTag ? `&:first-child {
|
|
125
|
-
background-color: ${theme.row.firstRowBackgroundColor};
|
|
126
|
-
}` : ""}
|
|
127
|
-
}
|
|
128
|
-
`;
|
|
129
|
-
};
|
|
130
|
-
const tagTableRemoveButtonStyles = css`
|
|
131
|
-
background: none;
|
|
132
|
-
border: none;
|
|
133
|
-
padding: 0;
|
|
134
|
-
:hover {
|
|
135
|
-
cursor: pointer;
|
|
136
|
-
}
|
|
137
|
-
`;
|
|
138
|
-
const tagTableAddButtonStyles = (partialTheme = {}) => {
|
|
139
|
-
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
140
|
-
return css`
|
|
141
|
-
:hover {
|
|
142
|
-
cursor: pointer;
|
|
143
|
-
background-color: ${theme.addButton.backgroundHoverColor};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
color: ${theme.addButton.color};
|
|
147
|
-
-webkit-text-decoration: none;
|
|
148
|
-
text-decoration: none;
|
|
149
|
-
padding: ${theme.addButton.paddingY} ${theme.addButton.paddingX};
|
|
150
|
-
position: relative;
|
|
151
|
-
border: 0;
|
|
152
|
-
border-radius: 0;
|
|
153
|
-
cursor: pointer;
|
|
154
|
-
justify-content: center;
|
|
155
|
-
align-items: center;
|
|
156
|
-
font-weight: ${theme.addButton.fontWeight};
|
|
157
|
-
font-size: ${theme.addButton.fontSize};
|
|
158
|
-
height: 24px;
|
|
159
|
-
width: fit-content;
|
|
160
|
-
line-height: 1;
|
|
161
|
-
flex-direction: row;
|
|
162
|
-
gap: 8px;
|
|
163
|
-
background-color: ${theme.addButton.backgroundColor};
|
|
164
|
-
display: inline-flex;
|
|
165
|
-
`;
|
|
166
|
-
};
|
|
167
|
-
const tagTableDragButtonStyles = css`
|
|
168
|
-
background: none;
|
|
169
|
-
border: none;
|
|
170
|
-
padding: 0;
|
|
171
|
-
padding-left: 5px;
|
|
172
|
-
margin: 0;
|
|
173
|
-
display: flex;
|
|
174
|
-
align-items: center;
|
|
175
|
-
opacity: 0;
|
|
176
|
-
|
|
177
|
-
&:focus {
|
|
178
|
-
opacity: 1;
|
|
179
|
-
}
|
|
180
|
-
`;
|
|
181
|
-
const tagTableTypeBadgeStyles = (partialTheme = {}) => {
|
|
182
|
-
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
183
|
-
return css`
|
|
184
|
-
white-space: nowrap;
|
|
185
|
-
text-transform: uppercase;
|
|
186
|
-
color: ${theme.typeBadge.color};
|
|
187
|
-
background-color: ${theme.typeBadge.backgroundColor};
|
|
188
|
-
padding: ${theme.typeBadge.paddingY} ${theme.typeBadge.paddingX};
|
|
189
|
-
font-size: ${theme.typeBadge.fontSize};
|
|
190
|
-
font-weight: ${theme.typeBadge.fontWeight};
|
|
191
|
-
`;
|
|
192
|
-
};
|
|
193
75
|
const iconStyles = (partialTheme = {}) => {
|
|
194
76
|
const theme = mergeDeep(componentAutocomplete, partialTheme);
|
|
195
77
|
return css`
|
|
@@ -219,9 +101,11 @@ const offlineSectionStyles = (partialTheme = {}) => {
|
|
|
219
101
|
`;
|
|
220
102
|
};
|
|
221
103
|
const tagSearchWithFilterStyles = (partialTheme = {}) => {
|
|
104
|
+
const theme = mergeDeep(componentTagPicker, partialTheme);
|
|
222
105
|
return css`
|
|
106
|
+
width: ${theme.search.width};
|
|
223
107
|
display: flex;
|
|
224
|
-
gap: ${
|
|
108
|
+
gap: ${theme.shared.gap};
|
|
225
109
|
`;
|
|
226
110
|
};
|
|
227
111
|
const filterSelectCssOverrides = (partialTheme = {}) => {
|
|
@@ -240,4 +124,4 @@ const modifyFilterSelectTheme = (selectTheme) => {
|
|
|
240
124
|
} }, selectTheme);
|
|
241
125
|
};
|
|
242
126
|
//#endregion
|
|
243
|
-
export { autocompleteInputStyles, filterSelectCssOverrides, iconStyles, listboxInfoStyles, listboxItemStyles, listboxStyles, modifyFilterSelectTheme, offlineSectionStyles, tagPickerStyles, tagSearchWithFilterStyles
|
|
127
|
+
export { autocompleteInputStyles, filterSelectCssOverrides, iconStyles, listboxInfoStyles, listboxItemStyles, listboxStyles, modifyFilterSelectTheme, offlineSectionStyles, tagPickerStyles, tagSearchWithFilterStyles };
|
|
@@ -3,7 +3,7 @@ let react = require("react");
|
|
|
3
3
|
let _emotion_react = require("@emotion/react");
|
|
4
4
|
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
5
5
|
let react_aria_components = require("react-aria-components");
|
|
6
|
-
//#region src/components/
|
|
6
|
+
//#region src/components/TagTable/TagTable.tsx
|
|
7
7
|
const rowToTag = (row) => "tag" in row ? row.tag : row;
|
|
8
8
|
const TypeBadge = (type, theme) => {
|
|
9
9
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
|
|
@@ -59,7 +59,7 @@ const defaultCanRemove = () => true;
|
|
|
59
59
|
*
|
|
60
60
|
* This is currently still in testing phase, so a production implementation is not yet available.
|
|
61
61
|
*/
|
|
62
|
-
function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName, highlightFirstRow = false, removeAction: removeTag, addAction: addTag, onReorder, canRemove = defaultCanRemove, "data-testid": dataTestId, removeIcon, gripIcon, theme, cssOverrides }) {
|
|
62
|
+
function TagTable({ rows, filterRows, heading, subHeading, showTagType, showTagSectionName, highlightFirstRow = false, removeAction: removeTag, addAction: addTag, onReorder, canRemove = defaultCanRemove, "data-testid": dataTestId, removeIcon, gripIcon = /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", { children: "⣿" }), renderCustomControl, renderWhenEmpty, headerContent, theme, cssOverrides }) {
|
|
63
63
|
const canDrag = !!onReorder;
|
|
64
64
|
const [localRows, setLocalRows] = (0, react.useState)(() => [...rows]);
|
|
65
65
|
const localRowsRef = (0, react.useRef)(localRows);
|
|
@@ -87,14 +87,23 @@ function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName,
|
|
|
87
87
|
onReorder?.(localList);
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
if (filtered.length === 0) return null;
|
|
90
|
+
if (filtered.length === 0 && !renderWhenEmpty) return null;
|
|
91
91
|
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
92
92
|
css: cssOverrides,
|
|
93
|
-
children: [heading && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.
|
|
94
|
-
css: require_styles.
|
|
95
|
-
children: heading
|
|
93
|
+
children: [(!!heading || !!subHeading || !!headerContent) && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
94
|
+
css: require_styles.tagTableHeaderStyles(theme),
|
|
95
|
+
children: [(!!heading || !!subHeading) && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
96
|
+
css: require_styles.tagTableHeaderTextStyles(theme),
|
|
97
|
+
children: [heading && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
|
|
98
|
+
css: require_styles.tagTableHeadingStyles(theme),
|
|
99
|
+
children: heading
|
|
100
|
+
}), subHeading && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
|
|
101
|
+
css: require_styles.tagTableSubHeadingStyles(theme),
|
|
102
|
+
children: subHeading
|
|
103
|
+
})]
|
|
104
|
+
}), headerContent]
|
|
96
105
|
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(react_aria_components.Table, {
|
|
97
|
-
css: require_styles.tagTableStyles(!!
|
|
106
|
+
css: require_styles.tagTableStyles(!!highlightFirstRow, theme),
|
|
98
107
|
"aria-label": "Tag Table",
|
|
99
108
|
"data-testid": dataTestId,
|
|
100
109
|
dragAndDropHooks: onReorder && dragAndDropHooks,
|
|
@@ -107,6 +116,7 @@ function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName,
|
|
|
107
116
|
isRowHeader: true,
|
|
108
117
|
children: "Name"
|
|
109
118
|
}),
|
|
119
|
+
renderCustomControl && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Column, {}),
|
|
110
120
|
showTagSectionName && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Column, { children: "Section" }),
|
|
111
121
|
removeTag && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Column, {}),
|
|
112
122
|
addTag && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Column, {})
|
|
@@ -122,6 +132,7 @@ function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName,
|
|
|
122
132
|
onReorder && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Cell, {
|
|
123
133
|
css: [_emotion_react.css`
|
|
124
134
|
width: 1%;
|
|
135
|
+
vertical-align: middle;
|
|
125
136
|
`],
|
|
126
137
|
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Button, {
|
|
127
138
|
slot: "drag",
|
|
@@ -143,6 +154,13 @@ function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName,
|
|
|
143
154
|
"data-testid": `tags-table-item-${filtered.indexOf(item)}-name`,
|
|
144
155
|
children: rowToTag(item).name
|
|
145
156
|
}),
|
|
157
|
+
renderCustomControl && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Cell, {
|
|
158
|
+
css: [require_styles.tagTableCellStyles(theme), _emotion_react.css`
|
|
159
|
+
text-align: center;
|
|
160
|
+
width: 10%;
|
|
161
|
+
`],
|
|
162
|
+
children: renderCustomControl(item)
|
|
163
|
+
}),
|
|
146
164
|
showTagSectionName && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Cell, {
|
|
147
165
|
css: [require_styles.tagTableCellStyles(theme), _emotion_react.css`
|
|
148
166
|
width: 20%;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DeepPartial } from "../../util/types.cjs";
|
|
2
2
|
import { ComponentTagTable } from "../../styleD/build/typescript/component/tagTable.cjs";
|
|
3
|
-
import { TagRow } from "
|
|
3
|
+
import { TagRow } from "../TagPicker/types.cjs";
|
|
4
4
|
import { SerializedStyles } from "@emotion/react";
|
|
5
|
-
import { ReactElement } from "react";
|
|
5
|
+
import { ReactElement, ReactNode } from "react";
|
|
6
6
|
|
|
7
|
-
//#region src/components/
|
|
7
|
+
//#region src/components/TagTable/TagTable.d.ts
|
|
8
8
|
type Row = TagRow | {
|
|
9
9
|
tag: TagRow;
|
|
10
10
|
};
|
|
@@ -13,8 +13,12 @@ interface TagTableProps<R extends Row> {
|
|
|
13
13
|
rows: R[];
|
|
14
14
|
/** `filterRows` - Function to filter rows from `rows` prop from appearing in the table */
|
|
15
15
|
filterRows?: (row: R) => boolean;
|
|
16
|
+
/** `renderWhenEmpty` - Whether to render the header and the empty table if there are no rows to display after filtering */
|
|
17
|
+
renderWhenEmpty?: boolean;
|
|
16
18
|
/** `heading` - The table heading */
|
|
17
|
-
heading?:
|
|
19
|
+
heading?: ReactNode;
|
|
20
|
+
/** `subHeading` - The table subHeading */
|
|
21
|
+
subHeading?: string;
|
|
18
22
|
/** `showTagType` - Whether to show tags' type in table */
|
|
19
23
|
showTagType?: boolean;
|
|
20
24
|
/** `showTagSectionName` - Whether to show tags' section name in table */
|
|
@@ -34,6 +38,12 @@ interface TagTableProps<R extends Row> {
|
|
|
34
38
|
removeIcon?: ReactElement;
|
|
35
39
|
/** `gripIcon` - Icon to indicate that a row can be dragged, used in the accessible drag button */
|
|
36
40
|
gripIcon?: ReactElement;
|
|
41
|
+
/** `renderCustomControl` - Function to render a custom component in the tag row */
|
|
42
|
+
renderCustomControl?: (tag: R) => ReactNode;
|
|
43
|
+
/** `customActionDescription` - a string of the verb describing what the custom action does eg "Flag" */
|
|
44
|
+
customActionDescription?: string;
|
|
45
|
+
/** `headerContent` - the content to render in the table's header. */
|
|
46
|
+
headerContent?: ReactNode;
|
|
37
47
|
/** `theme` - Used to customise the look and feel of the TagTable component */
|
|
38
48
|
theme?: DeepPartial<ComponentTagTable>;
|
|
39
49
|
/** `cssOverrides` - Escape hatch for styling that doesn't fall into the theme */
|
|
@@ -90,6 +100,7 @@ declare function TagTable<R extends Row>({
|
|
|
90
100
|
rows,
|
|
91
101
|
filterRows,
|
|
92
102
|
heading,
|
|
103
|
+
subHeading,
|
|
93
104
|
showTagType,
|
|
94
105
|
showTagSectionName,
|
|
95
106
|
highlightFirstRow,
|
|
@@ -100,6 +111,9 @@ declare function TagTable<R extends Row>({
|
|
|
100
111
|
'data-testid': dataTestId,
|
|
101
112
|
removeIcon,
|
|
102
113
|
gripIcon,
|
|
114
|
+
renderCustomControl,
|
|
115
|
+
renderWhenEmpty,
|
|
116
|
+
headerContent,
|
|
103
117
|
theme,
|
|
104
118
|
cssOverrides
|
|
105
119
|
}: TagTableProps<R>): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DeepPartial } from "../../util/types.js";
|
|
2
2
|
import { ComponentTagTable } from "../../styleD/build/typescript/component/tagTable.js";
|
|
3
|
-
import { TagRow } from "
|
|
4
|
-
import { ReactElement } from "react";
|
|
3
|
+
import { TagRow } from "../TagPicker/types.js";
|
|
4
|
+
import { ReactElement, ReactNode } from "react";
|
|
5
5
|
import { SerializedStyles } from "@emotion/react";
|
|
6
6
|
|
|
7
|
-
//#region src/components/
|
|
7
|
+
//#region src/components/TagTable/TagTable.d.ts
|
|
8
8
|
type Row = TagRow | {
|
|
9
9
|
tag: TagRow;
|
|
10
10
|
};
|
|
@@ -13,8 +13,12 @@ interface TagTableProps<R extends Row> {
|
|
|
13
13
|
rows: R[];
|
|
14
14
|
/** `filterRows` - Function to filter rows from `rows` prop from appearing in the table */
|
|
15
15
|
filterRows?: (row: R) => boolean;
|
|
16
|
+
/** `renderWhenEmpty` - Whether to render the header and the empty table if there are no rows to display after filtering */
|
|
17
|
+
renderWhenEmpty?: boolean;
|
|
16
18
|
/** `heading` - The table heading */
|
|
17
|
-
heading?:
|
|
19
|
+
heading?: ReactNode;
|
|
20
|
+
/** `subHeading` - The table subHeading */
|
|
21
|
+
subHeading?: string;
|
|
18
22
|
/** `showTagType` - Whether to show tags' type in table */
|
|
19
23
|
showTagType?: boolean;
|
|
20
24
|
/** `showTagSectionName` - Whether to show tags' section name in table */
|
|
@@ -34,6 +38,12 @@ interface TagTableProps<R extends Row> {
|
|
|
34
38
|
removeIcon?: ReactElement;
|
|
35
39
|
/** `gripIcon` - Icon to indicate that a row can be dragged, used in the accessible drag button */
|
|
36
40
|
gripIcon?: ReactElement;
|
|
41
|
+
/** `renderCustomControl` - Function to render a custom component in the tag row */
|
|
42
|
+
renderCustomControl?: (tag: R) => ReactNode;
|
|
43
|
+
/** `customActionDescription` - a string of the verb describing what the custom action does eg "Flag" */
|
|
44
|
+
customActionDescription?: string;
|
|
45
|
+
/** `headerContent` - the content to render in the table's header. */
|
|
46
|
+
headerContent?: ReactNode;
|
|
37
47
|
/** `theme` - Used to customise the look and feel of the TagTable component */
|
|
38
48
|
theme?: DeepPartial<ComponentTagTable>;
|
|
39
49
|
/** `cssOverrides` - Escape hatch for styling that doesn't fall into the theme */
|
|
@@ -90,6 +100,7 @@ declare function TagTable<R extends Row>({
|
|
|
90
100
|
rows,
|
|
91
101
|
filterRows,
|
|
92
102
|
heading,
|
|
103
|
+
subHeading,
|
|
93
104
|
showTagType,
|
|
94
105
|
showTagSectionName,
|
|
95
106
|
highlightFirstRow,
|
|
@@ -100,6 +111,9 @@ declare function TagTable<R extends Row>({
|
|
|
100
111
|
'data-testid': dataTestId,
|
|
101
112
|
removeIcon,
|
|
102
113
|
gripIcon,
|
|
114
|
+
renderCustomControl,
|
|
115
|
+
renderWhenEmpty,
|
|
116
|
+
headerContent,
|
|
103
117
|
theme,
|
|
104
118
|
cssOverrides
|
|
105
119
|
}: TagTableProps<R>): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { tagTableAddButtonStyles, tagTableCellStyles, tagTableDragButtonStyles, tagTableHeadingStyles, tagTableRemoveButtonStyles, tagTableRowStyles, tagTableStyles, tagTableTypeBadgeStyles } from "./styles.js";
|
|
1
|
+
import { tagTableAddButtonStyles, tagTableCellStyles, tagTableDragButtonStyles, tagTableHeaderStyles, tagTableHeaderTextStyles, tagTableHeadingStyles, tagTableRemoveButtonStyles, tagTableRowStyles, tagTableStyles, tagTableSubHeadingStyles, tagTableTypeBadgeStyles } from "./styles.js";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { css } from "@emotion/react";
|
|
4
4
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
5
5
|
import { Button, Cell, Column, Row, Table, TableBody, TableHeader, useDragAndDrop } from "react-aria-components";
|
|
6
|
-
//#region src/components/
|
|
6
|
+
//#region src/components/TagTable/TagTable.tsx
|
|
7
7
|
const rowToTag = (row) => "tag" in row ? row.tag : row;
|
|
8
8
|
const TypeBadge = (type, theme) => {
|
|
9
9
|
return /* @__PURE__ */ jsx("span", {
|
|
@@ -59,7 +59,7 @@ const defaultCanRemove = () => true;
|
|
|
59
59
|
*
|
|
60
60
|
* This is currently still in testing phase, so a production implementation is not yet available.
|
|
61
61
|
*/
|
|
62
|
-
function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName, highlightFirstRow = false, removeAction: removeTag, addAction: addTag, onReorder, canRemove = defaultCanRemove, "data-testid": dataTestId, removeIcon, gripIcon, theme, cssOverrides }) {
|
|
62
|
+
function TagTable({ rows, filterRows, heading, subHeading, showTagType, showTagSectionName, highlightFirstRow = false, removeAction: removeTag, addAction: addTag, onReorder, canRemove = defaultCanRemove, "data-testid": dataTestId, removeIcon, gripIcon = /* @__PURE__ */ jsx("span", { children: "⣿" }), renderCustomControl, renderWhenEmpty, headerContent, theme, cssOverrides }) {
|
|
63
63
|
const canDrag = !!onReorder;
|
|
64
64
|
const [localRows, setLocalRows] = useState(() => [...rows]);
|
|
65
65
|
const localRowsRef = useRef(localRows);
|
|
@@ -87,14 +87,23 @@ function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName,
|
|
|
87
87
|
onReorder?.(localList);
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
if (filtered.length === 0) return null;
|
|
90
|
+
if (filtered.length === 0 && !renderWhenEmpty) return null;
|
|
91
91
|
return /* @__PURE__ */ jsxs("div", {
|
|
92
92
|
css: cssOverrides,
|
|
93
|
-
children: [heading && /* @__PURE__ */
|
|
94
|
-
css:
|
|
95
|
-
children: heading
|
|
93
|
+
children: [(!!heading || !!subHeading || !!headerContent) && /* @__PURE__ */ jsxs("div", {
|
|
94
|
+
css: tagTableHeaderStyles(theme),
|
|
95
|
+
children: [(!!heading || !!subHeading) && /* @__PURE__ */ jsxs("div", {
|
|
96
|
+
css: tagTableHeaderTextStyles(theme),
|
|
97
|
+
children: [heading && /* @__PURE__ */ jsx("span", {
|
|
98
|
+
css: tagTableHeadingStyles(theme),
|
|
99
|
+
children: heading
|
|
100
|
+
}), subHeading && /* @__PURE__ */ jsx("span", {
|
|
101
|
+
css: tagTableSubHeadingStyles(theme),
|
|
102
|
+
children: subHeading
|
|
103
|
+
})]
|
|
104
|
+
}), headerContent]
|
|
96
105
|
}), /* @__PURE__ */ jsxs(Table, {
|
|
97
|
-
css: tagTableStyles(!!
|
|
106
|
+
css: tagTableStyles(!!highlightFirstRow, theme),
|
|
98
107
|
"aria-label": "Tag Table",
|
|
99
108
|
"data-testid": dataTestId,
|
|
100
109
|
dragAndDropHooks: onReorder && dragAndDropHooks,
|
|
@@ -107,6 +116,7 @@ function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName,
|
|
|
107
116
|
isRowHeader: true,
|
|
108
117
|
children: "Name"
|
|
109
118
|
}),
|
|
119
|
+
renderCustomControl && /* @__PURE__ */ jsx(Column, {}),
|
|
110
120
|
showTagSectionName && /* @__PURE__ */ jsx(Column, { children: "Section" }),
|
|
111
121
|
removeTag && /* @__PURE__ */ jsx(Column, {}),
|
|
112
122
|
addTag && /* @__PURE__ */ jsx(Column, {})
|
|
@@ -122,6 +132,7 @@ function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName,
|
|
|
122
132
|
onReorder && /* @__PURE__ */ jsx(Cell, {
|
|
123
133
|
css: [css`
|
|
124
134
|
width: 1%;
|
|
135
|
+
vertical-align: middle;
|
|
125
136
|
`],
|
|
126
137
|
children: /* @__PURE__ */ jsx(Button, {
|
|
127
138
|
slot: "drag",
|
|
@@ -143,6 +154,13 @@ function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName,
|
|
|
143
154
|
"data-testid": `tags-table-item-${filtered.indexOf(item)}-name`,
|
|
144
155
|
children: rowToTag(item).name
|
|
145
156
|
}),
|
|
157
|
+
renderCustomControl && /* @__PURE__ */ jsx(Cell, {
|
|
158
|
+
css: [tagTableCellStyles(theme), css`
|
|
159
|
+
text-align: center;
|
|
160
|
+
width: 10%;
|
|
161
|
+
`],
|
|
162
|
+
children: renderCustomControl(item)
|
|
163
|
+
}),
|
|
146
164
|
showTagSectionName && /* @__PURE__ */ jsx(Cell, {
|
|
147
165
|
css: [tagTableCellStyles(theme), css`
|
|
148
166
|
width: 20%;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const require_mergeDeep = require("../../util/mergeDeep.cjs");
|
|
2
|
+
const require_tagTable = require("../../styleD/build/typescript/component/tagTable.cjs");
|
|
3
|
+
let _emotion_react = require("@emotion/react");
|
|
4
|
+
//#region src/components/TagTable/styles.ts
|
|
5
|
+
const tagTableHeaderStyles = (partialTheme = {}) => {
|
|
6
|
+
const theme = require_mergeDeep.mergeDeep(require_tagTable.componentTagTable, partialTheme);
|
|
7
|
+
return _emotion_react.css`
|
|
8
|
+
background-color: ${theme.header.backgroundColor};
|
|
9
|
+
padding: ${theme.header.paddingTop} ${theme.header.paddingRight}
|
|
10
|
+
${theme.header.paddingBottom} ${theme.header.paddingLeft};
|
|
11
|
+
display: flex;
|
|
12
|
+
gap: ${theme.header.gap};
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
align-items: center;
|
|
15
|
+
`;
|
|
16
|
+
};
|
|
17
|
+
const tagTableHeaderTextStyles = (partialTheme = {}) => {
|
|
18
|
+
return _emotion_react.css`
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: ${require_mergeDeep.mergeDeep(require_tagTable.componentTagTable, partialTheme).header.gap};
|
|
22
|
+
`;
|
|
23
|
+
};
|
|
24
|
+
const tagTableHeadingStyles = (partialTheme = {}) => {
|
|
25
|
+
const theme = require_mergeDeep.mergeDeep(require_tagTable.componentTagTable, partialTheme);
|
|
26
|
+
return _emotion_react.css`
|
|
27
|
+
font-weight: ${theme.heading.fontWeight};
|
|
28
|
+
font-size: ${theme.heading.fontSize};
|
|
29
|
+
`;
|
|
30
|
+
};
|
|
31
|
+
const tagTableSubHeadingStyles = (partialTheme = {}) => {
|
|
32
|
+
const theme = require_mergeDeep.mergeDeep(require_tagTable.componentTagTable, partialTheme);
|
|
33
|
+
return _emotion_react.css`
|
|
34
|
+
font-weight: ${theme.subHeading.fontWeight};
|
|
35
|
+
font-size: ${theme.subHeading.fontSize};
|
|
36
|
+
`;
|
|
37
|
+
};
|
|
38
|
+
const tagTableCellStyles = (partialTheme = {}) => {
|
|
39
|
+
const theme = require_mergeDeep.mergeDeep(require_tagTable.componentTagTable, partialTheme);
|
|
40
|
+
return _emotion_react.css`
|
|
41
|
+
padding: ${theme.cell.paddingY} ${theme.cell.paddingX};
|
|
42
|
+
vertical-align: middle;
|
|
43
|
+
|
|
44
|
+
:first-of-type {
|
|
45
|
+
padding-left: ${theme.cell.firstCellPaddingLeft};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:not(:last-child) {
|
|
49
|
+
border-right-width: ${theme.cell.borderBetweenCells.borderWidth};
|
|
50
|
+
border-right-style: ${theme.cell.borderBetweenCells.borderStyle};
|
|
51
|
+
border-right-color: ${theme.cell.borderBetweenCells.borderColor};
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
};
|
|
55
|
+
const tagTableRowStyles = (canDrag, highlightFirstRow, partialTheme = {}) => {
|
|
56
|
+
const theme = require_mergeDeep.mergeDeep(require_tagTable.componentTagTable, partialTheme);
|
|
57
|
+
return _emotion_react.css`
|
|
58
|
+
background-color: ${theme.row.backgroundColor};
|
|
59
|
+
height: ${theme.row.height};
|
|
60
|
+
&:not(:last-child) {
|
|
61
|
+
border-bottom-color: ${theme.row.borderBottom.borderColor};
|
|
62
|
+
border-bottom-style: ${theme.row.borderBottom.borderStyle};
|
|
63
|
+
border-bottom-width: ${theme.row.borderBottom.borderWidth};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:hover {
|
|
67
|
+
background-color: ${theme.row.backgroundHoverColor};
|
|
68
|
+
${canDrag ? "cursor: grab;" : null}
|
|
69
|
+
button[slot='drag'] {
|
|
70
|
+
opacity: 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
${highlightFirstRow && `:first-of-type {
|
|
74
|
+
background-color: ${theme.row.firstRowBackgroundColor};
|
|
75
|
+
|
|
76
|
+
:hover {
|
|
77
|
+
background-color: ${theme.row.firstRowBackgroundHoverColor};
|
|
78
|
+
}
|
|
79
|
+
}`}
|
|
80
|
+
`;
|
|
81
|
+
};
|
|
82
|
+
const tagTableStyles = (highlightFirstRow, partialTheme = {}) => {
|
|
83
|
+
const theme = require_mergeDeep.mergeDeep(require_tagTable.componentTagTable, partialTheme);
|
|
84
|
+
return _emotion_react.css`
|
|
85
|
+
width: 100%;
|
|
86
|
+
border-collapse: collapse;
|
|
87
|
+
|
|
88
|
+
.react-aria-DropIndicator[data-drop-target] {
|
|
89
|
+
height: ${theme.row.height};
|
|
90
|
+
|
|
91
|
+
${highlightFirstRow ? `&:first-child {
|
|
92
|
+
background-color: ${theme.row.firstRowBackgroundColor};
|
|
93
|
+
}` : ""}
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
};
|
|
97
|
+
const tagTableRemoveButtonStyles = _emotion_react.css`
|
|
98
|
+
background: none;
|
|
99
|
+
border: none;
|
|
100
|
+
padding: 0;
|
|
101
|
+
:hover {
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
const tagTableAddButtonStyles = (partialTheme = {}) => {
|
|
106
|
+
const theme = require_mergeDeep.mergeDeep(require_tagTable.componentTagTable, partialTheme);
|
|
107
|
+
return _emotion_react.css`
|
|
108
|
+
:hover {
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
background-color: ${theme.addButton.backgroundHoverColor};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
color: ${theme.addButton.color};
|
|
114
|
+
-webkit-text-decoration: none;
|
|
115
|
+
text-decoration: none;
|
|
116
|
+
padding: ${theme.addButton.paddingY} ${theme.addButton.paddingX};
|
|
117
|
+
position: relative;
|
|
118
|
+
border: 0;
|
|
119
|
+
border-radius: 0;
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
align-items: center;
|
|
123
|
+
font-weight: ${theme.addButton.fontWeight};
|
|
124
|
+
font-size: ${theme.addButton.fontSize};
|
|
125
|
+
height: 24px;
|
|
126
|
+
width: fit-content;
|
|
127
|
+
line-height: 1;
|
|
128
|
+
flex-direction: row;
|
|
129
|
+
gap: 8px;
|
|
130
|
+
background-color: ${theme.addButton.backgroundColor};
|
|
131
|
+
display: inline-flex;
|
|
132
|
+
`;
|
|
133
|
+
};
|
|
134
|
+
const tagTableDragButtonStyles = _emotion_react.css`
|
|
135
|
+
background: none;
|
|
136
|
+
border: none;
|
|
137
|
+
padding: 5px;
|
|
138
|
+
margin: 0;
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
opacity: 0;
|
|
142
|
+
|
|
143
|
+
&:focus {
|
|
144
|
+
opacity: 1;
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
const tagTableTypeBadgeStyles = (partialTheme = {}) => {
|
|
148
|
+
const theme = require_mergeDeep.mergeDeep(require_tagTable.componentTagTable, partialTheme);
|
|
149
|
+
return _emotion_react.css`
|
|
150
|
+
white-space: nowrap;
|
|
151
|
+
text-transform: uppercase;
|
|
152
|
+
color: ${theme.typeBadge.color};
|
|
153
|
+
background-color: ${theme.typeBadge.backgroundColor};
|
|
154
|
+
padding: ${theme.typeBadge.paddingY} ${theme.typeBadge.paddingX};
|
|
155
|
+
font-size: ${theme.typeBadge.fontSize};
|
|
156
|
+
font-weight: ${theme.typeBadge.fontWeight};
|
|
157
|
+
`;
|
|
158
|
+
};
|
|
159
|
+
//#endregion
|
|
160
|
+
exports.tagTableAddButtonStyles = tagTableAddButtonStyles;
|
|
161
|
+
exports.tagTableCellStyles = tagTableCellStyles;
|
|
162
|
+
exports.tagTableDragButtonStyles = tagTableDragButtonStyles;
|
|
163
|
+
exports.tagTableHeaderStyles = tagTableHeaderStyles;
|
|
164
|
+
exports.tagTableHeaderTextStyles = tagTableHeaderTextStyles;
|
|
165
|
+
exports.tagTableHeadingStyles = tagTableHeadingStyles;
|
|
166
|
+
exports.tagTableRemoveButtonStyles = tagTableRemoveButtonStyles;
|
|
167
|
+
exports.tagTableRowStyles = tagTableRowStyles;
|
|
168
|
+
exports.tagTableStyles = tagTableStyles;
|
|
169
|
+
exports.tagTableSubHeadingStyles = tagTableSubHeadingStyles;
|
|
170
|
+
exports.tagTableTypeBadgeStyles = tagTableTypeBadgeStyles;
|