@guardian/stand 0.0.4 → 0.0.6
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/README.md +394 -7
- package/dist/{byline → components/byline}/Byline.cjs +5 -5
- package/dist/{byline → components/byline}/Byline.js +5 -5
- package/dist/components/byline/styles.cjs +266 -0
- package/dist/components/byline/styles.js +256 -0
- package/dist/components/tag-picker/TagAutocomplete.cjs +107 -0
- package/dist/components/tag-picker/TagAutocomplete.js +26 -0
- package/dist/components/tag-picker/TagTable.cjs +203 -0
- package/dist/components/tag-picker/TagTable.js +91 -0
- package/dist/components/tag-picker/styles.cjs +198 -0
- package/dist/components/tag-picker/styles.js +185 -0
- package/dist/components/util.cjs +19 -0
- package/dist/components/util.js +17 -0
- package/dist/index.cjs +15 -1
- package/dist/index.js +8 -1
- package/dist/styleD/build/css/css/base/colors.css +122 -0
- package/dist/styleD/build/css/css/base/typography.css +43 -0
- package/dist/styleD/build/css/css/component/byline.css +36 -0
- package/dist/styleD/build/css/css/component/tagAutocomplete.css +23 -0
- package/dist/styleD/build/css/css/component/tagTable.css +39 -0
- package/dist/styleD/build/css/css/semantic/colors.css +27 -0
- package/dist/styleD/build/css/css/semantic/typography.css +138 -0
- package/dist/styleD/build/typescript/base/colors.cjs +144 -0
- package/dist/styleD/build/typescript/base/colors.js +142 -0
- package/dist/styleD/build/typescript/base/typography.cjs +65 -0
- package/dist/styleD/build/typescript/base/typography.js +63 -0
- package/dist/styleD/build/typescript/component/byline.cjs +42 -0
- package/dist/styleD/build/typescript/component/byline.js +40 -0
- package/dist/styleD/build/typescript/component/tagAutocomplete.cjs +29 -0
- package/dist/styleD/build/typescript/component/tagAutocomplete.js +27 -0
- package/dist/styleD/build/typescript/component/tagTable.cjs +53 -0
- package/dist/styleD/build/typescript/component/tagTable.js +51 -0
- package/dist/styleD/build/typescript/semantic/colors.cjs +37 -0
- package/dist/styleD/build/typescript/semantic/colors.js +35 -0
- package/dist/styleD/build/typescript/semantic/typography.cjs +462 -0
- package/dist/styleD/build/typescript/semantic/typography.js +460 -0
- package/dist/styleD/utils/semantic/typography.cjs +17 -0
- package/dist/styleD/utils/semantic/typography.js +15 -0
- package/dist/types/components/byline/Byline.d.ts +83 -0
- package/dist/types/components/byline/styles.d.ts +13 -0
- package/dist/types/components/byline/theme.d.ts +3 -0
- package/dist/types/components/tag-picker/TagAutocomplete.d.ts +117 -0
- package/dist/types/components/tag-picker/TagTable.d.ts +126 -0
- package/dist/types/components/tag-picker/example-tags.d.ts +2 -0
- package/dist/types/components/tag-picker/styles.d.ts +16 -0
- package/dist/types/components/tag-picker/types.d.ts +65 -0
- package/dist/types/{byline → components}/util.d.ts +1 -0
- package/dist/types/index.d.ts +26 -2
- package/dist/types/styleD/build/typescript/base/colors.d.ts +144 -0
- package/dist/types/styleD/build/typescript/base/typography.d.ts +65 -0
- package/dist/types/styleD/build/typescript/component/byline.d.ts +42 -0
- package/dist/types/styleD/build/typescript/component/tagAutocomplete.d.ts +29 -0
- package/dist/types/styleD/build/typescript/component/tagTable.d.ts +53 -0
- package/dist/types/styleD/build/typescript/semantic/colors.d.ts +37 -0
- package/dist/types/styleD/build/typescript/semantic/typography.d.ts +462 -0
- package/dist/types/styleD/stories/base/Typography.d.ts +1 -0
- package/dist/types/styleD/stories/base/storybookColorPalette.d.ts +19 -0
- package/dist/types/styleD/stories/semantic/TypographyPresets.d.ts +1 -0
- package/dist/types/styleD/utils/semantic/typography.d.ts +15 -0
- package/dist/types/styleD/utils/semantic/typography.test.d.ts +1 -0
- package/package.json +67 -22
- package/dist/byline/styles.cjs +0 -244
- package/dist/byline/styles.js +0 -234
- package/dist/types/byline/Byline.d.ts +0 -17
- package/dist/types/byline/styles.d.ts +0 -11
- package/dist/types/byline/theme.d.ts +0 -44
- /package/dist/{byline → components/byline}/Preview.cjs +0 -0
- /package/dist/{byline → components/byline}/Preview.js +0 -0
- /package/dist/{byline → components/byline}/lib.cjs +0 -0
- /package/dist/{byline → components/byline}/lib.js +0 -0
- /package/dist/{byline → components/byline}/placeholder.cjs +0 -0
- /package/dist/{byline → components/byline}/placeholder.js +0 -0
- /package/dist/{byline → components/byline}/plugins.cjs +0 -0
- /package/dist/{byline → components/byline}/plugins.js +0 -0
- /package/dist/{byline → components/byline}/schema.cjs +0 -0
- /package/dist/{byline → components/byline}/schema.js +0 -0
- /package/dist/types/{byline → components/byline}/Preview.d.ts +0 -0
- /package/dist/types/{byline → components/byline}/contributors-fixture.d.ts +0 -0
- /package/dist/types/{byline → components/byline}/lib.d.ts +0 -0
- /package/dist/types/{byline → components/byline}/lib.test.d.ts +0 -0
- /package/dist/types/{byline → components/byline}/placeholder.d.ts +0 -0
- /package/dist/types/{byline → components/byline}/plugins.d.ts +0 -0
- /package/dist/types/{byline → components/byline}/schema.d.ts +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
4
|
+
var react$1 = require('@emotion/react');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var styles = require('./styles.cjs');
|
|
8
|
+
|
|
9
|
+
const rowToTag = (row) => "tag" in row ? row.tag : row;
|
|
10
|
+
const TypeBadge = (type, theme) => {
|
|
11
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { css: styles.tagTableTypeBadgeStyles(theme), children: type });
|
|
12
|
+
};
|
|
13
|
+
const defaultCanRemove = () => true;
|
|
14
|
+
function TagTable({
|
|
15
|
+
rows,
|
|
16
|
+
filterRows,
|
|
17
|
+
heading,
|
|
18
|
+
showTagType,
|
|
19
|
+
showTagSectionName,
|
|
20
|
+
removeAction: removeTag,
|
|
21
|
+
addAction: addTag,
|
|
22
|
+
onReorder,
|
|
23
|
+
canRemove = defaultCanRemove,
|
|
24
|
+
"data-testid": dataTestId,
|
|
25
|
+
removeIcon,
|
|
26
|
+
gripIcon,
|
|
27
|
+
theme,
|
|
28
|
+
cssOverrides
|
|
29
|
+
}) {
|
|
30
|
+
const canDrag = !!onReorder;
|
|
31
|
+
const [localRows, setLocalRows] = react.useState(() => [...rows]);
|
|
32
|
+
const localRowsRef = react.useRef(localRows);
|
|
33
|
+
localRowsRef.current = localRows;
|
|
34
|
+
react.useEffect(() => {
|
|
35
|
+
setLocalRows([...rows]);
|
|
36
|
+
}, [rows]);
|
|
37
|
+
const filtered = localRows.filter(filterRows);
|
|
38
|
+
const { dragAndDropHooks } = reactAriaComponents.useDragAndDrop({
|
|
39
|
+
getItems: (_keys, items) => {
|
|
40
|
+
return items.map((item) => ({
|
|
41
|
+
"text/plain": rowToTag(item).id.toString()
|
|
42
|
+
}));
|
|
43
|
+
},
|
|
44
|
+
onReorder(e) {
|
|
45
|
+
const draggedElementKey = [...e.keys].at(0);
|
|
46
|
+
if (draggedElementKey === e.target.key) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const localList = [...localRows];
|
|
50
|
+
const draggedElementIndex = localList.findIndex(
|
|
51
|
+
(i) => rowToTag(i).id === draggedElementKey
|
|
52
|
+
);
|
|
53
|
+
const draggedElement = localList.at(draggedElementIndex);
|
|
54
|
+
if (!draggedElement) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
localList.splice(draggedElementIndex, 1);
|
|
58
|
+
const targetElementIndex = localList.findIndex(
|
|
59
|
+
(i) => rowToTag(i).id === e.target.key
|
|
60
|
+
);
|
|
61
|
+
if (e.target.dropPosition === "before") {
|
|
62
|
+
localList.splice(targetElementIndex, 0, draggedElement);
|
|
63
|
+
} else if (e.target.dropPosition === "after") {
|
|
64
|
+
localList.splice(targetElementIndex + 1, 0, draggedElement);
|
|
65
|
+
}
|
|
66
|
+
setLocalRows(localList);
|
|
67
|
+
onReorder?.(localList);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (filtered.length === 0) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { css: cssOverrides, children: [
|
|
74
|
+
heading && /* @__PURE__ */ jsxRuntime.jsx("div", { css: styles.tagTableHeadingStyles(theme), children: heading }),
|
|
75
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
76
|
+
reactAriaComponents.Table,
|
|
77
|
+
{
|
|
78
|
+
css: styles.tagTableStyles(!!removeTag, theme),
|
|
79
|
+
"aria-label": "Tag Table",
|
|
80
|
+
"data-testid": dataTestId,
|
|
81
|
+
dragAndDropHooks: onReorder && dragAndDropHooks,
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactAriaComponents.TableHeader, { hidden: true, children: [
|
|
84
|
+
onReorder && /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Column, {}),
|
|
85
|
+
showTagType && /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Column, { children: "Type" }),
|
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Column, { isRowHeader: true, children: "Name" }),
|
|
87
|
+
showTagSectionName && /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Column, { children: "Section" }),
|
|
88
|
+
removeTag && /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Column, {}),
|
|
89
|
+
addTag && /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Column, {})
|
|
90
|
+
] }),
|
|
91
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.TableBody, { items: filtered, dependencies: [localRows], children: (item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
92
|
+
reactAriaComponents.Row,
|
|
93
|
+
{
|
|
94
|
+
id: rowToTag(item).id,
|
|
95
|
+
css: styles.tagTableRowStyles(canDrag, theme),
|
|
96
|
+
textValue: rowToTag(item).internalName,
|
|
97
|
+
children: [
|
|
98
|
+
onReorder && /* @__PURE__ */ jsxRuntime.jsx(
|
|
99
|
+
reactAriaComponents.Cell,
|
|
100
|
+
{
|
|
101
|
+
css: [
|
|
102
|
+
react$1.css`
|
|
103
|
+
width: 1%;
|
|
104
|
+
`
|
|
105
|
+
],
|
|
106
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Button, { slot: "drag", css: styles.tagTableDragButtonStyles, children: gripIcon })
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
showTagType && /* @__PURE__ */ jsxRuntime.jsx(
|
|
110
|
+
reactAriaComponents.Cell,
|
|
111
|
+
{
|
|
112
|
+
css: [
|
|
113
|
+
styles.tagTableCellStyles(theme),
|
|
114
|
+
react$1.css`
|
|
115
|
+
position: relative;
|
|
116
|
+
width: 15%;
|
|
117
|
+
`
|
|
118
|
+
],
|
|
119
|
+
children: TypeBadge(rowToTag(item).type)
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
123
|
+
reactAriaComponents.Cell,
|
|
124
|
+
{
|
|
125
|
+
css: [
|
|
126
|
+
styles.tagTableCellStyles(theme),
|
|
127
|
+
react$1.css`
|
|
128
|
+
width: 50%;
|
|
129
|
+
`
|
|
130
|
+
],
|
|
131
|
+
"data-testid": `tags-table-item-${filtered.indexOf(item)}-name`,
|
|
132
|
+
children: rowToTag(item).internalName
|
|
133
|
+
}
|
|
134
|
+
),
|
|
135
|
+
showTagSectionName && /* @__PURE__ */ jsxRuntime.jsx(
|
|
136
|
+
reactAriaComponents.Cell,
|
|
137
|
+
{
|
|
138
|
+
css: [
|
|
139
|
+
styles.tagTableCellStyles(theme),
|
|
140
|
+
react$1.css`
|
|
141
|
+
width: 20%;
|
|
142
|
+
`
|
|
143
|
+
],
|
|
144
|
+
children: rowToTag(item).section.name
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
removeTag && /* @__PURE__ */ jsxRuntime.jsx(
|
|
148
|
+
reactAriaComponents.Cell,
|
|
149
|
+
{
|
|
150
|
+
css: [
|
|
151
|
+
styles.tagTableCellStyles(theme),
|
|
152
|
+
react$1.css`
|
|
153
|
+
text-align: center;
|
|
154
|
+
width: 10%;
|
|
155
|
+
`
|
|
156
|
+
],
|
|
157
|
+
children: canRemove(item) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
158
|
+
reactAriaComponents.Button,
|
|
159
|
+
{
|
|
160
|
+
css: styles.tagTableRemoveButtonStyles,
|
|
161
|
+
onPress: () => {
|
|
162
|
+
removeTag(item);
|
|
163
|
+
},
|
|
164
|
+
"aria-label": `Remove ${rowToTag(item).internalName}`,
|
|
165
|
+
children: removeIcon ?? "Remove"
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
addTag && /* @__PURE__ */ jsxRuntime.jsx(
|
|
171
|
+
reactAriaComponents.Cell,
|
|
172
|
+
{
|
|
173
|
+
css: [
|
|
174
|
+
styles.tagTableCellStyles(theme),
|
|
175
|
+
react$1.css`
|
|
176
|
+
text-align: center;
|
|
177
|
+
width: 10%;
|
|
178
|
+
`
|
|
179
|
+
],
|
|
180
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
181
|
+
reactAriaComponents.Button,
|
|
182
|
+
{
|
|
183
|
+
css: styles.tagTableAddButtonStyles(theme),
|
|
184
|
+
onPress: () => {
|
|
185
|
+
addTag(item);
|
|
186
|
+
},
|
|
187
|
+
"aria-label": `Add ${rowToTag(item).internalName}`,
|
|
188
|
+
children: "Add"
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
)
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
rowToTag(item).id
|
|
196
|
+
) })
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] });
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
exports.TagTable = TagTable;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import { useDragAndDrop, Table, TableHeader, Column, TableBody, Row, Cell, Button } from 'react-aria-components';
|
|
5
|
+
import { tagTableHeadingStyles, tagTableStyles, tagTableRowStyles, tagTableDragButtonStyles, tagTableCellStyles, tagTableRemoveButtonStyles, tagTableAddButtonStyles, tagTableTypeBadgeStyles } from './styles.js';
|
|
6
|
+
|
|
7
|
+
const rowToTag = (row) => "tag" in row ? row.tag : row;
|
|
8
|
+
const TypeBadge = (type, theme) => {
|
|
9
|
+
return jsx("span", { css: tagTableTypeBadgeStyles(theme), children: type });
|
|
10
|
+
};
|
|
11
|
+
const defaultCanRemove = () => true;
|
|
12
|
+
function TagTable({ rows, filterRows, heading, showTagType, showTagSectionName, removeAction: removeTag, addAction: addTag, onReorder, canRemove = defaultCanRemove, "data-testid": dataTestId, removeIcon, gripIcon, theme, cssOverrides }) {
|
|
13
|
+
const canDrag = !!onReorder;
|
|
14
|
+
const [localRows, setLocalRows] = useState(() => [...rows]);
|
|
15
|
+
const localRowsRef = useRef(localRows);
|
|
16
|
+
localRowsRef.current = localRows;
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setLocalRows([...rows]);
|
|
19
|
+
}, [rows]);
|
|
20
|
+
const filtered = localRows.filter(filterRows);
|
|
21
|
+
const { dragAndDropHooks } = useDragAndDrop({
|
|
22
|
+
getItems: (_keys, items) => {
|
|
23
|
+
return items.map((item) => ({
|
|
24
|
+
"text/plain": rowToTag(item).id.toString()
|
|
25
|
+
}));
|
|
26
|
+
},
|
|
27
|
+
onReorder(e) {
|
|
28
|
+
const draggedElementKey = [...e.keys].at(0);
|
|
29
|
+
if (draggedElementKey === e.target.key) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const localList = [...localRows];
|
|
33
|
+
const draggedElementIndex = localList.findIndex((i) => rowToTag(i).id === draggedElementKey);
|
|
34
|
+
const draggedElement = localList.at(draggedElementIndex);
|
|
35
|
+
if (!draggedElement) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
localList.splice(draggedElementIndex, 1);
|
|
39
|
+
const targetElementIndex = localList.findIndex((i) => rowToTag(i).id === e.target.key);
|
|
40
|
+
if (e.target.dropPosition === "before") {
|
|
41
|
+
localList.splice(targetElementIndex, 0, draggedElement);
|
|
42
|
+
} else if (e.target.dropPosition === "after") {
|
|
43
|
+
localList.splice(targetElementIndex + 1, 0, draggedElement);
|
|
44
|
+
}
|
|
45
|
+
setLocalRows(localList);
|
|
46
|
+
onReorder?.(localList);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (filtered.length === 0) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return jsxs("div", { css: cssOverrides, children: [heading && jsx("div", { css: tagTableHeadingStyles(theme), children: heading }), jsxs(Table, { css: tagTableStyles(!!removeTag, theme), "aria-label": "Tag Table", "data-testid": dataTestId, dragAndDropHooks: onReorder && dragAndDropHooks, children: [jsxs(TableHeader, { hidden: true, children: [onReorder && jsx(Column, {}), showTagType && jsx(Column, { children: "Type" }), jsx(Column, { isRowHeader: true, children: "Name" }), showTagSectionName && jsx(Column, { children: "Section" }), removeTag && jsx(Column, {}), addTag && jsx(Column, {})] }), jsx(TableBody, { items: filtered, dependencies: [localRows], children: (item) => jsxs(Row, { id: rowToTag(item).id, css: tagTableRowStyles(canDrag, theme), textValue: rowToTag(item).internalName, children: [onReorder && jsx(Cell, { css: [
|
|
53
|
+
css`
|
|
54
|
+
width: 1%;
|
|
55
|
+
`
|
|
56
|
+
], children: jsx(Button, { slot: "drag", css: tagTableDragButtonStyles, children: gripIcon }) }), showTagType && jsx(Cell, { css: [
|
|
57
|
+
tagTableCellStyles(theme),
|
|
58
|
+
css`
|
|
59
|
+
position: relative;
|
|
60
|
+
width: 15%;
|
|
61
|
+
`
|
|
62
|
+
], children: TypeBadge(rowToTag(item).type) }), jsx(Cell, { css: [
|
|
63
|
+
tagTableCellStyles(theme),
|
|
64
|
+
css`
|
|
65
|
+
width: 50%;
|
|
66
|
+
`
|
|
67
|
+
], "data-testid": `tags-table-item-${filtered.indexOf(item)}-name`, children: rowToTag(item).internalName }), showTagSectionName && jsx(Cell, { css: [
|
|
68
|
+
tagTableCellStyles(theme),
|
|
69
|
+
css`
|
|
70
|
+
width: 20%;
|
|
71
|
+
`
|
|
72
|
+
], children: rowToTag(item).section.name }), removeTag && jsx(Cell, { css: [
|
|
73
|
+
tagTableCellStyles(theme),
|
|
74
|
+
css`
|
|
75
|
+
text-align: center;
|
|
76
|
+
width: 10%;
|
|
77
|
+
`
|
|
78
|
+
], children: canRemove(item) && jsx(Button, { css: tagTableRemoveButtonStyles, onPress: () => {
|
|
79
|
+
removeTag(item);
|
|
80
|
+
}, "aria-label": `Remove ${rowToTag(item).internalName}`, children: removeIcon ?? "Remove" }) }), addTag && jsx(Cell, { css: [
|
|
81
|
+
tagTableCellStyles(theme),
|
|
82
|
+
css`
|
|
83
|
+
text-align: center;
|
|
84
|
+
width: 10%;
|
|
85
|
+
`
|
|
86
|
+
], children: jsx(Button, { css: tagTableAddButtonStyles(theme), onPress: () => {
|
|
87
|
+
addTag(item);
|
|
88
|
+
}, "aria-label": `Add ${rowToTag(item).internalName}`, children: "Add" }) })] }, rowToTag(item).id) })] })] });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { TagTable };
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('@emotion/react');
|
|
4
|
+
var tagAutocomplete = require('../../styleD/build/typescript/component/tagAutocomplete.cjs');
|
|
5
|
+
var tagTable = require('../../styleD/build/typescript/component/tagTable.cjs');
|
|
6
|
+
var util = require('../util.cjs');
|
|
7
|
+
|
|
8
|
+
const tagAutocompleteInputStyles = (partialTheme = {}) => {
|
|
9
|
+
const theme = util.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
|
|
10
|
+
return react.css`
|
|
11
|
+
width: 100%;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
padding: ${theme.input.padding};
|
|
14
|
+
color: ${theme.input.color};
|
|
15
|
+
background-color: ${theme.input.backgroundColor};
|
|
16
|
+
border-color: ${theme.input.borderColor};
|
|
17
|
+
border-width: ${theme.input.borderWidth};
|
|
18
|
+
border-style: ${theme.input.borderStyle};
|
|
19
|
+
|
|
20
|
+
&[data-disabled] {
|
|
21
|
+
background-color: ${theme.input.disabledBackgroundColor};
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
};
|
|
25
|
+
const listboxStyles = (partialTheme = {}) => {
|
|
26
|
+
const theme = util.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
|
|
27
|
+
return react.css`
|
|
28
|
+
padding: ${theme.listbox.paddingY} ${theme.listbox.paddingX};
|
|
29
|
+
max-height: 320px;
|
|
30
|
+
overflow-y: auto;
|
|
31
|
+
background-color: ${theme.listbox.backgroundColor};
|
|
32
|
+
border-color: ${theme.listbox.borderColor};
|
|
33
|
+
border-width: ${theme.listbox.borderWidth};
|
|
34
|
+
border-style: ${theme.listbox.borderStyle};
|
|
35
|
+
`;
|
|
36
|
+
};
|
|
37
|
+
const listboxItemStyles = (partialTheme = {}) => {
|
|
38
|
+
const theme = util.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
|
|
39
|
+
return react.css`
|
|
40
|
+
padding: ${theme.listbox.item.paddingY} ${theme.listbox.item.paddingX};
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
&:hover {
|
|
43
|
+
background-color: ${theme.listbox.item.backgroundHoverColor};
|
|
44
|
+
}
|
|
45
|
+
&[data-focused] {
|
|
46
|
+
background-color: ${theme.listbox.item.backgroundFocusedColor};
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
};
|
|
50
|
+
const listboxInfoStyles = (partialTheme = {}) => {
|
|
51
|
+
const theme = util.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
|
|
52
|
+
return react.css`
|
|
53
|
+
padding: ${theme.listbox.item.paddingY} ${theme.listbox.item.paddingX};
|
|
54
|
+
`;
|
|
55
|
+
};
|
|
56
|
+
const tagTableHeadingStyles = (partialTheme = {}) => {
|
|
57
|
+
const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
|
|
58
|
+
return react.css`
|
|
59
|
+
background-color: ${theme.heading.backgroundColor};
|
|
60
|
+
font-weight: ${theme.heading.fontWeight};
|
|
61
|
+
padding: ${theme.heading.paddingTop} ${theme.heading.paddingRight}
|
|
62
|
+
${theme.heading.paddingBottom} ${theme.heading.paddingLeft};
|
|
63
|
+
`;
|
|
64
|
+
};
|
|
65
|
+
const tagTableCellStyles = (partialTheme = {}) => {
|
|
66
|
+
const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
|
|
67
|
+
return react.css`
|
|
68
|
+
padding: ${theme.cell.paddingY} ${theme.cell.paddingX};
|
|
69
|
+
|
|
70
|
+
:first-of-type {
|
|
71
|
+
padding-left: ${theme.cell.firstCellPaddingLeft};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
:not(:last-child) {
|
|
75
|
+
border-right-width: ${theme.cell.borderBetweenCells.borderWidth};
|
|
76
|
+
border-right-style: ${theme.cell.borderBetweenCells.borderStyle};
|
|
77
|
+
border-right-color: ${theme.cell.borderBetweenCells.borderColor};
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
};
|
|
81
|
+
const tagTableRowStyles = (canDrag, partialTheme = {}) => {
|
|
82
|
+
const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
|
|
83
|
+
return react.css`
|
|
84
|
+
background-color: ${theme.row.backgroundColor};
|
|
85
|
+
height: ${theme.row.height};
|
|
86
|
+
&:not(:last-child) {
|
|
87
|
+
border-bottom-color: ${theme.row.borderBottom.borderColor};
|
|
88
|
+
border-bottom-style: ${theme.row.borderBottom.borderStyle};
|
|
89
|
+
border-bottom-width: ${theme.row.borderBottom.borderWidth};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:hover {
|
|
93
|
+
background-color: ${theme.row.backgroundHoverColor};
|
|
94
|
+
${canDrag ? "cursor: grab;" : null}
|
|
95
|
+
button[slot='drag'] {
|
|
96
|
+
opacity: 1;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
${canDrag && `:first-of-type {
|
|
100
|
+
background-color: ${theme.row.firstRowBackgroundColor};
|
|
101
|
+
|
|
102
|
+
:hover {
|
|
103
|
+
background-color: ${theme.row.firstRowBackgroundHoverColor};
|
|
104
|
+
}
|
|
105
|
+
}`}
|
|
106
|
+
`;
|
|
107
|
+
};
|
|
108
|
+
const tagTableStyles = (canRemoveTag, partialTheme = {}) => {
|
|
109
|
+
const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
|
|
110
|
+
return react.css`
|
|
111
|
+
width: 100%;
|
|
112
|
+
border-collapse: collapse;
|
|
113
|
+
|
|
114
|
+
.react-aria-DropIndicator[data-drop-target] {
|
|
115
|
+
height: ${theme.row.height};
|
|
116
|
+
|
|
117
|
+
${canRemoveTag ? `&:first-child {
|
|
118
|
+
background-color: ${theme.row.firstRowBackgroundColor};
|
|
119
|
+
}` : ""}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
};
|
|
123
|
+
const tagTableRemoveButtonStyles = react.css`
|
|
124
|
+
background: none;
|
|
125
|
+
border: none;
|
|
126
|
+
padding: 0;
|
|
127
|
+
:hover {
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
131
|
+
const tagTableAddButtonStyles = (partialTheme = {}) => {
|
|
132
|
+
const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
|
|
133
|
+
return react.css`
|
|
134
|
+
:hover {
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
background-color: ${theme.addButton.backgroundHoverColor};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
color: ${theme.addButton.color};
|
|
140
|
+
-webkit-text-decoration: none;
|
|
141
|
+
text-decoration: none;
|
|
142
|
+
padding: ${theme.addButton.paddingY} ${theme.addButton.paddingX};
|
|
143
|
+
position: relative;
|
|
144
|
+
border: 0;
|
|
145
|
+
border-radius: 0;
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
justify-content: center;
|
|
148
|
+
align-items: center;
|
|
149
|
+
font-weight: ${theme.addButton.fontWeight};
|
|
150
|
+
font-size: ${theme.addButton.fontSize};
|
|
151
|
+
height: 24px;
|
|
152
|
+
width: fit-content;
|
|
153
|
+
line-height: 1;
|
|
154
|
+
flex-direction: row;
|
|
155
|
+
gap: 8px;
|
|
156
|
+
background-color: ${theme.addButton.backgroundColor};
|
|
157
|
+
display: inline-flex;
|
|
158
|
+
`;
|
|
159
|
+
};
|
|
160
|
+
const tagTableDragButtonStyles = react.css`
|
|
161
|
+
background: none;
|
|
162
|
+
border: none;
|
|
163
|
+
padding: 0;
|
|
164
|
+
padding-left: 5px;
|
|
165
|
+
margin: 0;
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
opacity: 0;
|
|
169
|
+
|
|
170
|
+
&:focus {
|
|
171
|
+
opacity: 1;
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
const tagTableTypeBadgeStyles = (partialTheme = {}) => {
|
|
175
|
+
const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
|
|
176
|
+
return react.css`
|
|
177
|
+
white-space: nowrap;
|
|
178
|
+
text-transform: uppercase;
|
|
179
|
+
color: ${theme.typeBadge.color};
|
|
180
|
+
background-color: ${theme.typeBadge.backgroundColor};
|
|
181
|
+
padding: ${theme.typeBadge.paddingY} ${theme.typeBadge.paddingX};
|
|
182
|
+
font-size: ${theme.typeBadge.fontSize};
|
|
183
|
+
font-weight: ${theme.typeBadge.fontWeight};
|
|
184
|
+
`;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
exports.listboxInfoStyles = listboxInfoStyles;
|
|
188
|
+
exports.listboxItemStyles = listboxItemStyles;
|
|
189
|
+
exports.listboxStyles = listboxStyles;
|
|
190
|
+
exports.tagAutocompleteInputStyles = tagAutocompleteInputStyles;
|
|
191
|
+
exports.tagTableAddButtonStyles = tagTableAddButtonStyles;
|
|
192
|
+
exports.tagTableCellStyles = tagTableCellStyles;
|
|
193
|
+
exports.tagTableDragButtonStyles = tagTableDragButtonStyles;
|
|
194
|
+
exports.tagTableHeadingStyles = tagTableHeadingStyles;
|
|
195
|
+
exports.tagTableRemoveButtonStyles = tagTableRemoveButtonStyles;
|
|
196
|
+
exports.tagTableRowStyles = tagTableRowStyles;
|
|
197
|
+
exports.tagTableStyles = tagTableStyles;
|
|
198
|
+
exports.tagTableTypeBadgeStyles = tagTableTypeBadgeStyles;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { componentTagAutocomplete } from '../../styleD/build/typescript/component/tagAutocomplete.js';
|
|
3
|
+
import { componentTagTable } from '../../styleD/build/typescript/component/tagTable.js';
|
|
4
|
+
import { mergeDeep } from '../util.js';
|
|
5
|
+
|
|
6
|
+
const tagAutocompleteInputStyles = (partialTheme = {}) => {
|
|
7
|
+
const theme = mergeDeep(componentTagAutocomplete, partialTheme);
|
|
8
|
+
return css`
|
|
9
|
+
width: 100%;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
padding: ${theme.input.padding};
|
|
12
|
+
color: ${theme.input.color};
|
|
13
|
+
background-color: ${theme.input.backgroundColor};
|
|
14
|
+
border-color: ${theme.input.borderColor};
|
|
15
|
+
border-width: ${theme.input.borderWidth};
|
|
16
|
+
border-style: ${theme.input.borderStyle};
|
|
17
|
+
|
|
18
|
+
&[data-disabled] {
|
|
19
|
+
background-color: ${theme.input.disabledBackgroundColor};
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
};
|
|
23
|
+
const listboxStyles = (partialTheme = {}) => {
|
|
24
|
+
const theme = mergeDeep(componentTagAutocomplete, partialTheme);
|
|
25
|
+
return css`
|
|
26
|
+
padding: ${theme.listbox.paddingY} ${theme.listbox.paddingX};
|
|
27
|
+
max-height: 320px;
|
|
28
|
+
overflow-y: auto;
|
|
29
|
+
background-color: ${theme.listbox.backgroundColor};
|
|
30
|
+
border-color: ${theme.listbox.borderColor};
|
|
31
|
+
border-width: ${theme.listbox.borderWidth};
|
|
32
|
+
border-style: ${theme.listbox.borderStyle};
|
|
33
|
+
`;
|
|
34
|
+
};
|
|
35
|
+
const listboxItemStyles = (partialTheme = {}) => {
|
|
36
|
+
const theme = mergeDeep(componentTagAutocomplete, partialTheme);
|
|
37
|
+
return css`
|
|
38
|
+
padding: ${theme.listbox.item.paddingY} ${theme.listbox.item.paddingX};
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
&:hover {
|
|
41
|
+
background-color: ${theme.listbox.item.backgroundHoverColor};
|
|
42
|
+
}
|
|
43
|
+
&[data-focused] {
|
|
44
|
+
background-color: ${theme.listbox.item.backgroundFocusedColor};
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
};
|
|
48
|
+
const listboxInfoStyles = (partialTheme = {}) => {
|
|
49
|
+
const theme = mergeDeep(componentTagAutocomplete, partialTheme);
|
|
50
|
+
return css`
|
|
51
|
+
padding: ${theme.listbox.item.paddingY} ${theme.listbox.item.paddingX};
|
|
52
|
+
`;
|
|
53
|
+
};
|
|
54
|
+
const tagTableHeadingStyles = (partialTheme = {}) => {
|
|
55
|
+
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
56
|
+
return css`
|
|
57
|
+
background-color: ${theme.heading.backgroundColor};
|
|
58
|
+
font-weight: ${theme.heading.fontWeight};
|
|
59
|
+
padding: ${theme.heading.paddingTop} ${theme.heading.paddingRight}
|
|
60
|
+
${theme.heading.paddingBottom} ${theme.heading.paddingLeft};
|
|
61
|
+
`;
|
|
62
|
+
};
|
|
63
|
+
const tagTableCellStyles = (partialTheme = {}) => {
|
|
64
|
+
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
65
|
+
return css`
|
|
66
|
+
padding: ${theme.cell.paddingY} ${theme.cell.paddingX};
|
|
67
|
+
|
|
68
|
+
:first-of-type {
|
|
69
|
+
padding-left: ${theme.cell.firstCellPaddingLeft};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
:not(:last-child) {
|
|
73
|
+
border-right-width: ${theme.cell.borderBetweenCells.borderWidth};
|
|
74
|
+
border-right-style: ${theme.cell.borderBetweenCells.borderStyle};
|
|
75
|
+
border-right-color: ${theme.cell.borderBetweenCells.borderColor};
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
};
|
|
79
|
+
const tagTableRowStyles = (canDrag, partialTheme = {}) => {
|
|
80
|
+
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
81
|
+
return css`
|
|
82
|
+
background-color: ${theme.row.backgroundColor};
|
|
83
|
+
height: ${theme.row.height};
|
|
84
|
+
&:not(:last-child) {
|
|
85
|
+
border-bottom-color: ${theme.row.borderBottom.borderColor};
|
|
86
|
+
border-bottom-style: ${theme.row.borderBottom.borderStyle};
|
|
87
|
+
border-bottom-width: ${theme.row.borderBottom.borderWidth};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
:hover {
|
|
91
|
+
background-color: ${theme.row.backgroundHoverColor};
|
|
92
|
+
${canDrag ? "cursor: grab;" : null}
|
|
93
|
+
button[slot='drag'] {
|
|
94
|
+
opacity: 1;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
${canDrag && `:first-of-type {
|
|
98
|
+
background-color: ${theme.row.firstRowBackgroundColor};
|
|
99
|
+
|
|
100
|
+
:hover {
|
|
101
|
+
background-color: ${theme.row.firstRowBackgroundHoverColor};
|
|
102
|
+
}
|
|
103
|
+
}`}
|
|
104
|
+
`;
|
|
105
|
+
};
|
|
106
|
+
const tagTableStyles = (canRemoveTag, partialTheme = {}) => {
|
|
107
|
+
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
108
|
+
return css`
|
|
109
|
+
width: 100%;
|
|
110
|
+
border-collapse: collapse;
|
|
111
|
+
|
|
112
|
+
.react-aria-DropIndicator[data-drop-target] {
|
|
113
|
+
height: ${theme.row.height};
|
|
114
|
+
|
|
115
|
+
${canRemoveTag ? `&:first-child {
|
|
116
|
+
background-color: ${theme.row.firstRowBackgroundColor};
|
|
117
|
+
}` : ""}
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
};
|
|
121
|
+
const tagTableRemoveButtonStyles = css`
|
|
122
|
+
background: none;
|
|
123
|
+
border: none;
|
|
124
|
+
padding: 0;
|
|
125
|
+
:hover {
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
129
|
+
const tagTableAddButtonStyles = (partialTheme = {}) => {
|
|
130
|
+
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
131
|
+
return css`
|
|
132
|
+
:hover {
|
|
133
|
+
cursor: pointer;
|
|
134
|
+
background-color: ${theme.addButton.backgroundHoverColor};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
color: ${theme.addButton.color};
|
|
138
|
+
-webkit-text-decoration: none;
|
|
139
|
+
text-decoration: none;
|
|
140
|
+
padding: ${theme.addButton.paddingY} ${theme.addButton.paddingX};
|
|
141
|
+
position: relative;
|
|
142
|
+
border: 0;
|
|
143
|
+
border-radius: 0;
|
|
144
|
+
cursor: pointer;
|
|
145
|
+
justify-content: center;
|
|
146
|
+
align-items: center;
|
|
147
|
+
font-weight: ${theme.addButton.fontWeight};
|
|
148
|
+
font-size: ${theme.addButton.fontSize};
|
|
149
|
+
height: 24px;
|
|
150
|
+
width: fit-content;
|
|
151
|
+
line-height: 1;
|
|
152
|
+
flex-direction: row;
|
|
153
|
+
gap: 8px;
|
|
154
|
+
background-color: ${theme.addButton.backgroundColor};
|
|
155
|
+
display: inline-flex;
|
|
156
|
+
`;
|
|
157
|
+
};
|
|
158
|
+
const tagTableDragButtonStyles = css`
|
|
159
|
+
background: none;
|
|
160
|
+
border: none;
|
|
161
|
+
padding: 0;
|
|
162
|
+
padding-left: 5px;
|
|
163
|
+
margin: 0;
|
|
164
|
+
display: flex;
|
|
165
|
+
align-items: center;
|
|
166
|
+
opacity: 0;
|
|
167
|
+
|
|
168
|
+
&:focus {
|
|
169
|
+
opacity: 1;
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
const tagTableTypeBadgeStyles = (partialTheme = {}) => {
|
|
173
|
+
const theme = mergeDeep(componentTagTable, partialTheme);
|
|
174
|
+
return css`
|
|
175
|
+
white-space: nowrap;
|
|
176
|
+
text-transform: uppercase;
|
|
177
|
+
color: ${theme.typeBadge.color};
|
|
178
|
+
background-color: ${theme.typeBadge.backgroundColor};
|
|
179
|
+
padding: ${theme.typeBadge.paddingY} ${theme.typeBadge.paddingX};
|
|
180
|
+
font-size: ${theme.typeBadge.fontSize};
|
|
181
|
+
font-weight: ${theme.typeBadge.fontWeight};
|
|
182
|
+
`;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export { listboxInfoStyles, listboxItemStyles, listboxStyles, tagAutocompleteInputStyles, tagTableAddButtonStyles, tagTableCellStyles, tagTableDragButtonStyles, tagTableHeadingStyles, tagTableRemoveButtonStyles, tagTableRowStyles, tagTableStyles, tagTableTypeBadgeStyles };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const isObject = (obj) => obj && typeof obj === "object";
|
|
4
|
+
function mergeDeep(obj1, obj2) {
|
|
5
|
+
return [obj1, obj2].reduce((prev, obj) => {
|
|
6
|
+
Object.keys(obj).forEach((key) => {
|
|
7
|
+
const pVal = prev[key];
|
|
8
|
+
const oVal = obj[key];
|
|
9
|
+
if (isObject(pVal) && isObject(oVal)) {
|
|
10
|
+
prev[key] = mergeDeep(pVal, oVal);
|
|
11
|
+
} else {
|
|
12
|
+
prev[key] = oVal;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return prev;
|
|
16
|
+
}, {});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.mergeDeep = mergeDeep;
|