@manuscripts/style-guide 3.5.9 → 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.
@@ -12,6 +12,9 @@ const styled_components_1 = __importDefault(require("styled-components"));
12
12
  const icons_1 = require("./icons");
13
13
  const DatePicker = ({ id, originalDate, date, handleDateChange, placeholder, showTimeSelect, required, }) => {
14
14
  const [selectedDate, setSelectedDate] = (0, react_1.useState)(date || null);
15
+ (0, react_1.useEffect)(() => {
16
+ setSelectedDate(date ?? null);
17
+ }, [date]);
15
18
  const handleChange = (date) => {
16
19
  setSelectedDate(date);
17
20
  handleDateChange(date);
@@ -45,6 +45,7 @@ exports.TextWithGenerationWrapper = styled_components_1.default.div `
45
45
  `;
46
46
  exports.TextFieldError = styled_components_1.default.div `
47
47
  margin-top: 4px;
48
+ width: 100%;
48
49
  `;
49
50
  exports.TextFieldErrorItem = styled_components_1.default.div `
50
51
  font-family: ${(props) => props.theme.font.family.sans};
@@ -17,6 +17,7 @@ const FormFieldContainer = ({ label, error, info, id, children, }) => {
17
17
  };
18
18
  exports.FormFieldContainer = FormFieldContainer;
19
19
  const FormFieldInfo = styled_components_1.default.div `
20
+ width: 100%;
20
21
  font-family: ${(props) => props.theme.font.family.sans};
21
22
  font-size: ${(props) => props.theme.font.size.small};
22
23
  color: ${(props) => props.theme.colors.text.secondary};
@@ -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;
@@ -155,6 +155,7 @@ exports.TextFieldGroup = styled_components_1.default.div `
155
155
  `;
156
156
  exports.TextFieldLabel = styled_components_1.default.label `
157
157
  display: block;
158
+ width: 100%;
158
159
  font-family: ${(props) => props.theme.font.family.sans};
159
160
  color: ${(props) => props.theme.colors.text.primary};
160
161
  font-size: ${(props) => props.theme.font.size.normal};
@@ -1,11 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import 'react-datepicker/dist/react-datepicker.css';
3
- import { useState } from 'react';
3
+ import { useEffect, useState } from 'react';
4
4
  import ReactDatePicker from 'react-datepicker';
5
5
  import styled from 'styled-components';
6
6
  import { CalendarIcon } from './icons';
7
7
  export const DatePicker = ({ id, originalDate, date, handleDateChange, placeholder, showTimeSelect, required, }) => {
8
8
  const [selectedDate, setSelectedDate] = useState(date || null);
9
+ useEffect(() => {
10
+ setSelectedDate(date ?? null);
11
+ }, [date]);
9
12
  const handleChange = (date) => {
10
13
  setSelectedDate(date);
11
14
  handleDateChange(date);
@@ -37,6 +37,7 @@ export const TextWithGenerationWrapper = styled.div `
37
37
  `;
38
38
  export const TextFieldError = styled.div `
39
39
  margin-top: 4px;
40
+ width: 100%;
40
41
  `;
41
42
  export const TextFieldErrorItem = styled.div `
42
43
  font-family: ${(props) => props.theme.font.family.sans};
@@ -10,6 +10,7 @@ export const FormFieldContainer = ({ label, error, info, id, children, }) => {
10
10
  return (_jsxs(Fragment, { children: [label ? (_jsxs(TextFieldLabel, { htmlFor: id, children: [label, " ", childrenWithErrorProp] })) : (childrenWithErrorProp), info && !error && _jsx(FormFieldInfo, { children: info }), error && (_jsx(TextFieldError, { children: _jsx(TextFieldErrorItem, { children: error }) }))] }));
11
11
  };
12
12
  const FormFieldInfo = styled.div `
13
+ width: 100%;
13
14
  font-family: ${(props) => props.theme.font.family.sans};
14
15
  font-size: ${(props) => props.theme.font.size.small};
15
16
  color: ${(props) => props.theme.colors.text.secondary};
@@ -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;
@@ -119,6 +119,7 @@ export const TextFieldGroup = styled.div `
119
119
  `;
120
120
  export const TextFieldLabel = styled.label `
121
121
  display: block;
122
+ width: 100%;
122
123
  font-family: ${(props) => props.theme.font.family.sans};
123
124
  color: ${(props) => props.theme.colors.text.primary};
124
125
  font-size: ${(props) => props.theme.font.size.normal};
@@ -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.9",
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",