@manuscripts/style-guide 3.5.10 → 3.5.11

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.
@@ -140,6 +140,13 @@ function withListNavigation(Component) {
140
140
  if (!element) {
141
141
  return;
142
142
  }
143
+ if (element.hasAttribute('disabled')) {
144
+ const tabbedElement = element.querySelector('[data-list-item][tabindex="0"]');
145
+ if (tabbedElement) {
146
+ tabbedElement.tabIndex = -1;
147
+ }
148
+ return;
149
+ }
143
150
  const firstItem = element.querySelector('[data-list-item]');
144
151
  if (!firstItem) {
145
152
  return;
@@ -156,6 +163,13 @@ function withListNavigation(Component) {
156
163
  return ((0, jsx_runtime_1.jsx)(Component, { ref: mergeRefs(containerRef, forwardedRef), ...props, onKeyDown: handleKeyDown, onBlur: handelOnBlur }));
157
164
  })) `
158
165
  outline: none;
166
+ &[disabled] {
167
+ pointer-events: none;
168
+ user-select: none;
169
+ border-color: #e4e4e4;
170
+ color: #b3b3b3;
171
+ opacity: 0.5;
172
+ }
159
173
  `;
160
174
  }
161
175
  function withNavigableListItem(Component) {
@@ -126,6 +126,6 @@ const MultiValueInput = ({ id, inputType, placeholder = '', initialValues = [],
126
126
  : inputType === 'number'
127
127
  ? 'Enter number and press enter'
128
128
  : 'Enter text and press enter';
129
- return ((0, jsx_runtime_1.jsxs)(Container, { children: [values.map((value, index) => ((0, jsx_runtime_1.jsxs)(Chip, { children: [value, (0, jsx_runtime_1.jsx)(RemoveButton, { type: 'button', onClick: () => handleRemoveValue(index), children: "\u00D7" })] }, index))), (0, jsx_runtime_1.jsx)(Input, { id: id, type: inputType, value: currentValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onBlur: handleBlur, placeholder: xplaceholder })] }));
129
+ return ((0, jsx_runtime_1.jsxs)(Container, { className: 'multi-value-input', children: [values.map((value, index) => ((0, jsx_runtime_1.jsxs)(Chip, { className: 'chip', children: [value, (0, jsx_runtime_1.jsx)(RemoveButton, { type: 'button', onClick: () => handleRemoveValue(index), children: "\u00D7" })] }, index))), (0, jsx_runtime_1.jsx)(Input, { id: id, type: inputType, value: currentValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onBlur: handleBlur, placeholder: xplaceholder })] }));
130
130
  };
131
131
  exports.MultiValueInput = MultiValueInput;
@@ -12,6 +12,12 @@ const BoxContainer = styled_components_1.default.div `
12
12
  padding: 8px;
13
13
  min-height: 120px;
14
14
  background: ${(props) => props.theme.colors.background.primary};
15
+
16
+ &[disabled] {
17
+ color: #707070 !important;
18
+ background: #f5f5f5;
19
+ cursor: not-allowed;
20
+ }
15
21
  `;
16
22
  const ItemsList = styled_components_1.default.div `
17
23
  display: flex;
@@ -36,10 +42,10 @@ const Item = styled_components_1.default.div `
36
42
  display: flex;
37
43
  align-items: center;
38
44
  gap: 4px;
39
- background: #f2f2f2;
45
+ background: ${(props) => (props.disabled ? '#dddcdc' : '#f2f2f2')};
40
46
  border-radius: 6px;
41
47
  padding: 4px;
42
- color: ${(props) => props.theme.colors.text.primary};
48
+ color: ${(props) => props.disabled ? '#707070' : props.theme.colors.text.primary};
43
49
  font: ${(props) => props.theme.font.weight.normal}
44
50
  ${(props) => props.theme.font.size.small}
45
51
  ${(props) => props.theme.font.family.sans};
@@ -65,7 +71,7 @@ const RemoveButton = styled_components_1.default.button `
65
71
  }
66
72
  `;
67
73
  const SelectedItemsBox = ({ items, onRemove, placeholder = 'No items selected', ...props }) => {
68
- return ((0, jsx_runtime_1.jsx)(BoxContainer, { ...props, children: items.length > 0 ? ((0, jsx_runtime_1.jsx)(ItemsList, { children: items.map((item) => ((0, jsx_runtime_1.jsxs)(Item, { "data-cy": "item", children: [item.label, (0, jsx_runtime_1.jsx)(RemoveButton, { onClick: () => onRemove(item.id), "aria-label": `Remove ${item.label}`, children: "x" })] }, item.id))) })) : ((0, jsx_runtime_1.jsx)(EmptyContainer, { children: (0, jsx_runtime_1.jsx)(Placeholder, { children: placeholder }) })) }));
74
+ return ((0, jsx_runtime_1.jsx)(BoxContainer, { ...props, children: items.length > 0 ? ((0, jsx_runtime_1.jsx)(ItemsList, { children: items.map((item) => ((0, jsx_runtime_1.jsxs)(Item, { "data-cy": "item", disabled: !!props.disabled, children: [item.label, !props.disabled && ((0, jsx_runtime_1.jsx)(RemoveButton, { onClick: () => onRemove(item.id), "aria-label": `Remove ${item.label}`, children: "x" }))] }, item.id))) })) : ((0, jsx_runtime_1.jsx)(EmptyContainer, { children: (0, jsx_runtime_1.jsx)(Placeholder, { children: placeholder }) })) }));
69
75
  };
70
76
  exports.SelectedItemsBox = SelectedItemsBox;
71
77
  exports.default = exports.SelectedItemsBox;
@@ -132,6 +132,13 @@ export function withListNavigation(Component) {
132
132
  if (!element) {
133
133
  return;
134
134
  }
135
+ if (element.hasAttribute('disabled')) {
136
+ const tabbedElement = element.querySelector('[data-list-item][tabindex="0"]');
137
+ if (tabbedElement) {
138
+ tabbedElement.tabIndex = -1;
139
+ }
140
+ return;
141
+ }
135
142
  const firstItem = element.querySelector('[data-list-item]');
136
143
  if (!firstItem) {
137
144
  return;
@@ -148,6 +155,13 @@ export function withListNavigation(Component) {
148
155
  return (_jsx(Component, { ref: mergeRefs(containerRef, forwardedRef), ...props, onKeyDown: handleKeyDown, onBlur: handelOnBlur }));
149
156
  })) `
150
157
  outline: none;
158
+ &[disabled] {
159
+ pointer-events: none;
160
+ user-select: none;
161
+ border-color: #e4e4e4;
162
+ color: #b3b3b3;
163
+ opacity: 0.5;
164
+ }
151
165
  `;
152
166
  }
153
167
  export function withNavigableListItem(Component) {
@@ -120,5 +120,5 @@ export const MultiValueInput = ({ id, inputType, placeholder = '', initialValues
120
120
  : inputType === 'number'
121
121
  ? 'Enter number and press enter'
122
122
  : 'Enter text and press enter';
123
- return (_jsxs(Container, { children: [values.map((value, index) => (_jsxs(Chip, { children: [value, _jsx(RemoveButton, { type: 'button', onClick: () => handleRemoveValue(index), children: "\u00D7" })] }, index))), _jsx(Input, { id: id, type: inputType, value: currentValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onBlur: handleBlur, placeholder: xplaceholder })] }));
123
+ return (_jsxs(Container, { className: 'multi-value-input', children: [values.map((value, index) => (_jsxs(Chip, { className: 'chip', children: [value, _jsx(RemoveButton, { type: 'button', onClick: () => handleRemoveValue(index), children: "\u00D7" })] }, index))), _jsx(Input, { id: id, type: inputType, value: currentValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onBlur: handleBlur, placeholder: xplaceholder })] }));
124
124
  };
@@ -6,6 +6,12 @@ const BoxContainer = styled.div `
6
6
  padding: 8px;
7
7
  min-height: 120px;
8
8
  background: ${(props) => props.theme.colors.background.primary};
9
+
10
+ &[disabled] {
11
+ color: #707070 !important;
12
+ background: #f5f5f5;
13
+ cursor: not-allowed;
14
+ }
9
15
  `;
10
16
  const ItemsList = styled.div `
11
17
  display: flex;
@@ -30,10 +36,10 @@ const Item = styled.div `
30
36
  display: flex;
31
37
  align-items: center;
32
38
  gap: 4px;
33
- background: #f2f2f2;
39
+ background: ${(props) => (props.disabled ? '#dddcdc' : '#f2f2f2')};
34
40
  border-radius: 6px;
35
41
  padding: 4px;
36
- color: ${(props) => props.theme.colors.text.primary};
42
+ color: ${(props) => props.disabled ? '#707070' : props.theme.colors.text.primary};
37
43
  font: ${(props) => props.theme.font.weight.normal}
38
44
  ${(props) => props.theme.font.size.small}
39
45
  ${(props) => props.theme.font.family.sans};
@@ -59,6 +65,6 @@ const RemoveButton = styled.button `
59
65
  }
60
66
  `;
61
67
  export const SelectedItemsBox = ({ items, onRemove, placeholder = 'No items selected', ...props }) => {
62
- return (_jsx(BoxContainer, { ...props, children: items.length > 0 ? (_jsx(ItemsList, { children: items.map((item) => (_jsxs(Item, { "data-cy": "item", children: [item.label, _jsx(RemoveButton, { onClick: () => onRemove(item.id), "aria-label": `Remove ${item.label}`, children: "x" })] }, item.id))) })) : (_jsx(EmptyContainer, { children: _jsx(Placeholder, { children: placeholder }) })) }));
68
+ return (_jsx(BoxContainer, { ...props, children: items.length > 0 ? (_jsx(ItemsList, { children: items.map((item) => (_jsxs(Item, { "data-cy": "item", disabled: !!props.disabled, children: [item.label, !props.disabled && (_jsx(RemoveButton, { onClick: () => onRemove(item.id), "aria-label": `Remove ${item.label}`, children: "x" }))] }, item.id))) })) : (_jsx(EmptyContainer, { children: _jsx(Placeholder, { children: placeholder }) })) }));
63
69
  };
64
70
  export default SelectedItemsBox;
@@ -7,6 +7,7 @@ interface SelectedItemsBoxProps extends React.HTMLAttributes<HTMLElement> {
7
7
  items: SelectedItem[];
8
8
  onRemove: (id: string) => void;
9
9
  placeholder?: string;
10
+ disabled?: boolean;
10
11
  }
11
12
  export declare const SelectedItemsBox: React.FC<SelectedItemsBoxProps>;
12
13
  export default SelectedItemsBox;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/style-guide",
3
3
  "description": "Shared components for Manuscripts applications",
4
- "version": "3.5.10",
4
+ "version": "3.5.11",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",