@transferwise/components 0.0.0-experimental-75d5cd4 → 0.0.0-experimental-4990089
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/build/i18n/en.json +0 -1
- package/build/index.js +2380 -2514
- package/build/index.js.map +1 -1
- package/build/index.mjs +2383 -2516
- package/build/index.mjs.map +1 -1
- package/build/main.css +0 -33
- package/build/styles/main.css +0 -33
- package/build/types/common/panel/Panel.d.ts.map +1 -1
- package/build/types/common/responsivePanel/ResponsivePanel.d.ts.map +1 -1
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/build/types/index.d.ts +0 -2
- package/build/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common/panel/Panel.tsx +3 -8
- package/src/common/responsivePanel/ResponsivePanel.tsx +0 -2
- package/src/dateInput/DateInput.spec.tsx +245 -0
- package/src/dateInput/DateInput.story.tsx +3 -76
- package/src/dateInput/DateInput.tests.story.tsx +238 -0
- package/src/dateInput/DateInput.tsx +50 -53
- package/src/i18n/en.json +0 -1
- package/src/index.ts +0 -2
- package/src/main.css +0 -33
- package/src/main.less +0 -1
- package/src/ssr.spec.js +0 -1
- package/build/styles/selectOption/SelectOption.css +0 -33
- package/build/types/selectOption/SelectOption.d.ts +0 -21
- package/build/types/selectOption/SelectOption.d.ts.map +0 -1
- package/build/types/selectOption/SelectOption.messages.d.ts +0 -8
- package/build/types/selectOption/SelectOption.messages.d.ts.map +0 -1
- package/build/types/selectOption/index.d.ts +0 -3
- package/build/types/selectOption/index.d.ts.map +0 -1
- package/src/dateInput/DateInput.spec.js +0 -477
- package/src/selectOption/SelectOption.css +0 -33
- package/src/selectOption/SelectOption.less +0 -28
- package/src/selectOption/SelectOption.messages.ts +0 -8
- package/src/selectOption/SelectOption.story.tsx +0 -212
- package/src/selectOption/SelectOption.tsx +0 -154
- package/src/selectOption/index.ts +0 -2
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { userEvent, within, fn } from '@storybook/test';
|
|
3
|
+
|
|
4
|
+
import { DateInput, DateMode, Info, InlineAlert, Title, Typography } from '..';
|
|
5
|
+
import { lorem10, storyConfig } from '../test-utils';
|
|
6
|
+
|
|
7
|
+
import Provider from '../provider/Provider';
|
|
8
|
+
import translations from '../i18n';
|
|
9
|
+
|
|
10
|
+
const meta = {
|
|
11
|
+
component: DateInput,
|
|
12
|
+
title: 'Forms/DateInput/Tests',
|
|
13
|
+
args: {
|
|
14
|
+
dayLabel: 'Day input',
|
|
15
|
+
dayAutoComplete: 'bday-day',
|
|
16
|
+
monthLabel: 'Month select',
|
|
17
|
+
yearLabel: 'Year input',
|
|
18
|
+
yearAutoComplete: 'bday-year',
|
|
19
|
+
},
|
|
20
|
+
} satisfies Meta<typeof DateInput>;
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
|
|
24
|
+
type Story = StoryObj<typeof meta>;
|
|
25
|
+
|
|
26
|
+
const Basic = {
|
|
27
|
+
args: {
|
|
28
|
+
onChange: fn(),
|
|
29
|
+
},
|
|
30
|
+
play: async ({ canvasElement }) => {
|
|
31
|
+
const canvas = within(canvasElement);
|
|
32
|
+
await userEvent.click(canvas.getByRole('button'));
|
|
33
|
+
},
|
|
34
|
+
} satisfies Story;
|
|
35
|
+
|
|
36
|
+
export const WithLabel = {
|
|
37
|
+
args: {
|
|
38
|
+
onChange: fn(),
|
|
39
|
+
},
|
|
40
|
+
render: (args) => {
|
|
41
|
+
const id1 = 'date-input-group-label-1';
|
|
42
|
+
const label = 'Date of Birth';
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<Title type={Typography.TITLE_SUBSECTION}>
|
|
47
|
+
label (as <code>div</code> element) is linked with <code>DateInput</code> via{' '}
|
|
48
|
+
<code>aria-labelledby</code> prop
|
|
49
|
+
</Title>
|
|
50
|
+
<div className="control-label" id={id1}>
|
|
51
|
+
Date of Delivery
|
|
52
|
+
</div>
|
|
53
|
+
<DateInput {...args} aria-labelledby={id1} />
|
|
54
|
+
|
|
55
|
+
<br />
|
|
56
|
+
|
|
57
|
+
<Title type={Typography.TITLE_SUBSECTION}>
|
|
58
|
+
label (as <code>div</code> element) is detached but <code>DateInput</code> has same label
|
|
59
|
+
via <code>aria-label</code> attribute
|
|
60
|
+
</Title>
|
|
61
|
+
<div className="control-label">
|
|
62
|
+
{label}{' '}
|
|
63
|
+
<Info aria-label="Fast transfer hint" title="Fast transfer hint" content={lorem10} />
|
|
64
|
+
</div>
|
|
65
|
+
<DateInput {...args} aria-label={label} />
|
|
66
|
+
|
|
67
|
+
<br />
|
|
68
|
+
|
|
69
|
+
<Title type={Typography.TITLE_SUBSECTION}>
|
|
70
|
+
<code>DateInput</code> wrapped in <code>fieldset</code> + using <code>legend</code> as
|
|
71
|
+
label (rare use case)
|
|
72
|
+
</Title>
|
|
73
|
+
<fieldset>
|
|
74
|
+
<legend className="control-label">
|
|
75
|
+
Expiry Date for Credit Card (example of MONTH_YEAR mode)
|
|
76
|
+
</legend>
|
|
77
|
+
<DateInput {...args} mode={DateMode.MONTH_YEAR} />
|
|
78
|
+
</fieldset>
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
},
|
|
82
|
+
} satisfies Story;
|
|
83
|
+
|
|
84
|
+
export const InputError = {
|
|
85
|
+
...Basic,
|
|
86
|
+
render: (args) => (
|
|
87
|
+
<div className="form-group has-error">
|
|
88
|
+
<DateInput {...args} value={new Date('2010-04-05')} />
|
|
89
|
+
<InlineAlert type="error">{lorem10}</InlineAlert>
|
|
90
|
+
</div>
|
|
91
|
+
),
|
|
92
|
+
} satisfies Story;
|
|
93
|
+
|
|
94
|
+
export const CustomPlaceholders = {
|
|
95
|
+
...Basic,
|
|
96
|
+
args: {
|
|
97
|
+
placeholders: {
|
|
98
|
+
day: 'D',
|
|
99
|
+
month: 'M',
|
|
100
|
+
year: 'YY',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const SingleZero = storyConfig(Basic, {});
|
|
106
|
+
SingleZero.play = async ({ canvasElement, step }) => {
|
|
107
|
+
const canvas = within(canvasElement);
|
|
108
|
+
await step('can enter leading zero on day field', async () => {
|
|
109
|
+
const dayInput = await canvas.findByRole('textbox', { name: /day/i });
|
|
110
|
+
await userEvent.click(dayInput);
|
|
111
|
+
await userEvent.type(dayInput, '0');
|
|
112
|
+
});
|
|
113
|
+
await step('can enter 1 leading zero on year field', async () => {
|
|
114
|
+
const yearInput = await canvas.findByRole('textbox', { name: /year/i });
|
|
115
|
+
await userEvent.click(yearInput);
|
|
116
|
+
await userEvent.type(yearInput, '0');
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const ZeroesAsValue = storyConfig(Basic, {});
|
|
121
|
+
ZeroesAsValue.play = async ({ canvasElement, step }) => {
|
|
122
|
+
const canvas = within(canvasElement);
|
|
123
|
+
await step('can enter 2 leading zeroes on day field', async () => {
|
|
124
|
+
const dayInput = await canvas.findByRole('textbox', { name: /day/i });
|
|
125
|
+
await userEvent.click(dayInput);
|
|
126
|
+
await userEvent.type(dayInput, '00');
|
|
127
|
+
});
|
|
128
|
+
await step('can enter 4 leading zeroes on year field', async () => {
|
|
129
|
+
const yearInput = await canvas.findByRole('textbox', { name: /year/i });
|
|
130
|
+
await userEvent.click(yearInput);
|
|
131
|
+
await userEvent.type(yearInput, '0000');
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const ZeroesBeforeValue = storyConfig(Basic, {});
|
|
136
|
+
ZeroesBeforeValue.play = async ({ canvasElement, step }) => {
|
|
137
|
+
const canvas = within(canvasElement);
|
|
138
|
+
await step('can enter leading zeroes on day followed by day', async () => {
|
|
139
|
+
const dayInput = await canvas.findByRole('textbox', { name: /day/i });
|
|
140
|
+
await userEvent.click(dayInput);
|
|
141
|
+
await userEvent.type(dayInput, '01');
|
|
142
|
+
});
|
|
143
|
+
await step('can enter leading zeroes on year followed by year', async () => {
|
|
144
|
+
const yearInput = await canvas.findByRole('textbox', { name: /year/i });
|
|
145
|
+
await userEvent.click(yearInput);
|
|
146
|
+
await userEvent.type(yearInput, '0001');
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const MaxLengthRespected = storyConfig(Basic, {});
|
|
151
|
+
MaxLengthRespected.play = async ({ canvasElement, step }) => {
|
|
152
|
+
const canvas = within(canvasElement);
|
|
153
|
+
await step('can only enter 4 digits in the year field', async () => {
|
|
154
|
+
const yearInput = await canvas.findByRole('textbox', { name: /year/i });
|
|
155
|
+
await userEvent.click(yearInput);
|
|
156
|
+
await userEvent.type(yearInput, '11111111');
|
|
157
|
+
});
|
|
158
|
+
await step('can only enter 2 digits in the day field', async () => {
|
|
159
|
+
const dayInput = await canvas.findByRole('textbox', { name: /day/i });
|
|
160
|
+
await userEvent.click(dayInput);
|
|
161
|
+
await userEvent.type(dayInput, '11111111');
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const LocalizationWorks: Story = {
|
|
166
|
+
...Basic,
|
|
167
|
+
decorators: [
|
|
168
|
+
(Story) => {
|
|
169
|
+
const locale = 'zh-HK';
|
|
170
|
+
return (
|
|
171
|
+
<Provider i18n={{ locale, messages: translations[locale] }}>
|
|
172
|
+
<Story />
|
|
173
|
+
</Provider>
|
|
174
|
+
);
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const YearFirst: Story = {
|
|
180
|
+
...Basic,
|
|
181
|
+
decorators: [
|
|
182
|
+
(Story) => {
|
|
183
|
+
const locale = 'ja';
|
|
184
|
+
return (
|
|
185
|
+
<Provider i18n={{ locale, messages: translations[locale] }}>
|
|
186
|
+
<Story />
|
|
187
|
+
</Provider>
|
|
188
|
+
);
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export const MonthFirst: Story = {
|
|
194
|
+
...Basic,
|
|
195
|
+
decorators: [
|
|
196
|
+
(Story) => {
|
|
197
|
+
const locale = 'en-US';
|
|
198
|
+
return (
|
|
199
|
+
<Provider i18n={{ locale, messages: translations[locale] }}>
|
|
200
|
+
<Story />
|
|
201
|
+
</Provider>
|
|
202
|
+
);
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export const DayFirst: Story = {
|
|
208
|
+
...Basic,
|
|
209
|
+
decorators: [
|
|
210
|
+
(Story) => {
|
|
211
|
+
const locale = 'en';
|
|
212
|
+
return (
|
|
213
|
+
<Provider i18n={{ locale, messages: translations[locale] }}>
|
|
214
|
+
<Story />
|
|
215
|
+
</Provider>
|
|
216
|
+
);
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export const NoNonDigitsAllowed = storyConfig(Basic, {});
|
|
222
|
+
NoNonDigitsAllowed.play = async ({ canvasElement, step }) => {
|
|
223
|
+
const canvas = within(canvasElement);
|
|
224
|
+
await step('can only enter digits in the day field', async () => {
|
|
225
|
+
const dayInput = await canvas.findByRole('textbox', { name: /day/i });
|
|
226
|
+
await userEvent.click(dayInput);
|
|
227
|
+
await userEvent.type(dayInput, 'abcd1');
|
|
228
|
+
});
|
|
229
|
+
await step('can only enter digits in the year field', async () => {
|
|
230
|
+
const yearInput = await canvas.findByRole('textbox', { name: /year/i });
|
|
231
|
+
await userEvent.click(yearInput);
|
|
232
|
+
await userEvent.type(yearInput, 'abcd2');
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export const BasicMobile = storyConfig(Basic, { variants: ['mobile'] });
|
|
237
|
+
|
|
238
|
+
export const InputErrorMobile = storyConfig(InputError, { variants: ['mobile'] });
|
|
@@ -2,8 +2,16 @@ import classNames from 'classnames';
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
4
|
|
|
5
|
-
import { Input, SelectInput, SelectInputOptionContent, SelectInputProps } from '..';
|
|
6
|
-
import {
|
|
5
|
+
import { Body, Input, SelectInput, SelectInputOptionContent, SelectInputProps } from '..';
|
|
6
|
+
import {
|
|
7
|
+
DateMode,
|
|
8
|
+
MonthFormat,
|
|
9
|
+
Size,
|
|
10
|
+
SizeLarge,
|
|
11
|
+
SizeMedium,
|
|
12
|
+
SizeSmall,
|
|
13
|
+
Typography,
|
|
14
|
+
} from '../common';
|
|
7
15
|
import { MDY, YMD, getMonthNames, isDateValid, isMonthAndYearFormat } from '../common/dateUtils';
|
|
8
16
|
import { useInputAttributes } from '../inputs/contexts';
|
|
9
17
|
import messages from './DateInput.messages';
|
|
@@ -93,8 +101,10 @@ const DateInput = ({
|
|
|
93
101
|
};
|
|
94
102
|
|
|
95
103
|
const [day, setDay] = useState(() => getInitialDate('day'));
|
|
104
|
+
const [displayDay, setDisplayDay] = useState(day?.toString());
|
|
96
105
|
const [month, setMonth] = useState(() => getInitialDate('month'));
|
|
97
106
|
const [year, setYear] = useState(() => getInitialDate('year'));
|
|
107
|
+
const [displayYear, setDisplayYear] = useState(year?.toString());
|
|
98
108
|
const [lastBroadcastedValue, setLastBroadcastedValue] = useState<Date | null | undefined>(
|
|
99
109
|
getDateObject,
|
|
100
110
|
);
|
|
@@ -129,7 +139,7 @@ const DateInput = ({
|
|
|
129
139
|
const getSelectElement = () => {
|
|
130
140
|
return (
|
|
131
141
|
<label className="d-flex flex-column">
|
|
132
|
-
<
|
|
142
|
+
<Body type={Typography.BODY_DEFAULT}>{monthLabel}</Body>
|
|
133
143
|
<SelectInput
|
|
134
144
|
name="month"
|
|
135
145
|
disabled={disabled}
|
|
@@ -147,13 +157,25 @@ const DateInput = ({
|
|
|
147
157
|
);
|
|
148
158
|
};
|
|
149
159
|
|
|
160
|
+
const isDayValid = (newDay: number, newMonth: number, newYear: number) => {
|
|
161
|
+
const maxDay = new Date(newYear, newMonth + 1, 0).getDate();
|
|
162
|
+
return newDay <= maxDay;
|
|
163
|
+
};
|
|
164
|
+
|
|
150
165
|
const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {
|
|
151
|
-
if (newDay == null || newMonth == null || newYear == null) {
|
|
166
|
+
if (newDay == null || newDay === 0 || newMonth == null || newYear == null || newYear === 0) {
|
|
167
|
+
broadcastNewValue(null);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (!isDayValid(newDay, newMonth, newYear)) {
|
|
152
171
|
broadcastNewValue(null);
|
|
153
172
|
return;
|
|
154
173
|
}
|
|
155
174
|
|
|
156
175
|
const dateValue = new Date(newYear, newMonth, newDay);
|
|
176
|
+
if (newYear < 100) {
|
|
177
|
+
dateValue.setFullYear(newYear);
|
|
178
|
+
}
|
|
157
179
|
|
|
158
180
|
if (!isDateValid(dateValue)) {
|
|
159
181
|
broadcastNewValue(null);
|
|
@@ -170,9 +192,12 @@ const DateInput = ({
|
|
|
170
192
|
};
|
|
171
193
|
|
|
172
194
|
const handleDayChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
195
|
+
const newDayString = event.target.value.replace(/\D/g, '');
|
|
196
|
+
const newDayNumber = Number.parseInt(newDayString, 10);
|
|
197
|
+
|
|
198
|
+
setDay(newDayNumber);
|
|
199
|
+
setDisplayDay(newDayString);
|
|
200
|
+
handleInternalValue(newDayNumber, month, year);
|
|
176
201
|
};
|
|
177
202
|
|
|
178
203
|
const handleMonthChange = (selectedMonth: number | null) => {
|
|
@@ -181,30 +206,21 @@ const DateInput = ({
|
|
|
181
206
|
handleInternalValue(day, null, year);
|
|
182
207
|
return;
|
|
183
208
|
}
|
|
184
|
-
const { checkedDay } = checkDate(day, selectedMonth, year);
|
|
185
209
|
setMonth(selectedMonth);
|
|
186
|
-
|
|
187
|
-
setDay(checkedDay);
|
|
188
|
-
}
|
|
189
|
-
handleInternalValue(checkedDay, selectedMonth, year);
|
|
210
|
+
handleInternalValue(day, selectedMonth, year);
|
|
190
211
|
};
|
|
191
212
|
|
|
192
213
|
const handleYearChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
if (slicedYear.toString().length === 4) {
|
|
197
|
-
// Correct day based on year and month.
|
|
198
|
-
const { checkedDay } = checkDate(day, month, Number.parseInt(newValue, 10));
|
|
199
|
-
|
|
200
|
-
if (day && checkedDay !== day) {
|
|
201
|
-
setDay(checkedDay);
|
|
202
|
-
}
|
|
214
|
+
const newYearString = event.target.value.replace(/\D/g, '');
|
|
215
|
+
const newYearNumber = Number.parseInt(newYearString, 10);
|
|
203
216
|
|
|
204
|
-
|
|
205
|
-
|
|
217
|
+
if (newYearString.length === 4) {
|
|
218
|
+
setYear(newYearNumber);
|
|
219
|
+
setDisplayYear(newYearString);
|
|
220
|
+
handleInternalValue(day, month, newYearNumber);
|
|
206
221
|
} else {
|
|
207
|
-
setYear(
|
|
222
|
+
setYear(null);
|
|
223
|
+
setDisplayYear(newYearString);
|
|
208
224
|
handleInternalValue(day, month, null);
|
|
209
225
|
}
|
|
210
226
|
};
|
|
@@ -216,29 +232,6 @@ const DateInput = ({
|
|
|
216
232
|
}
|
|
217
233
|
};
|
|
218
234
|
|
|
219
|
-
const checkDate = (
|
|
220
|
-
newDay: number | null = null,
|
|
221
|
-
newMonth: number | null = 0,
|
|
222
|
-
newYear: number | null = null,
|
|
223
|
-
) => {
|
|
224
|
-
let checkedDay = newDay;
|
|
225
|
-
const maxDay = new Date(newYear || 2000, newMonth != null ? newMonth + 1 : 1, 0).getDate();
|
|
226
|
-
|
|
227
|
-
if (!newDay) {
|
|
228
|
-
checkedDay = null;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (newDay && newDay < 0) {
|
|
232
|
-
checkedDay = 1;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if ((newDay && newMonth) || (newDay && newDay > 31)) {
|
|
236
|
-
checkedDay = newDay > maxDay ? maxDay : newDay;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return { checkedDay, checkedMonth: newMonth, checkedYear: newYear };
|
|
240
|
-
};
|
|
241
|
-
|
|
242
235
|
const monthYearOnly = mode === DateMode.MONTH_YEAR;
|
|
243
236
|
|
|
244
237
|
const monthWidth = classNames({
|
|
@@ -254,7 +247,7 @@ const DateInput = ({
|
|
|
254
247
|
return (
|
|
255
248
|
<div className="col-sm-3">
|
|
256
249
|
<label>
|
|
257
|
-
<
|
|
250
|
+
<Body type={Typography.BODY_DEFAULT}>{dayLabel}</Body>
|
|
258
251
|
<div className={`input-group input-group-${size}`}>
|
|
259
252
|
<Input
|
|
260
253
|
type="text"
|
|
@@ -262,10 +255,12 @@ const DateInput = ({
|
|
|
262
255
|
pattern="[0-9]*"
|
|
263
256
|
name="day"
|
|
264
257
|
autoComplete={dayAutoComplete}
|
|
265
|
-
value={
|
|
258
|
+
value={displayDay || ''}
|
|
266
259
|
placeholder={placeholders?.day}
|
|
267
260
|
disabled={disabled}
|
|
268
261
|
min={1}
|
|
262
|
+
max={31}
|
|
263
|
+
maxLength={2}
|
|
269
264
|
onChange={(event) => handleDayChange(event)}
|
|
270
265
|
/>
|
|
271
266
|
</div>
|
|
@@ -278,7 +273,7 @@ const DateInput = ({
|
|
|
278
273
|
return (
|
|
279
274
|
<div className="col-sm-4">
|
|
280
275
|
<label>
|
|
281
|
-
<
|
|
276
|
+
<Body type={Typography.BODY_DEFAULT}>{yearLabel}</Body>
|
|
282
277
|
<div className={`input-group input-group-${size}`}>
|
|
283
278
|
<Input
|
|
284
279
|
type="text"
|
|
@@ -287,9 +282,11 @@ const DateInput = ({
|
|
|
287
282
|
name="year"
|
|
288
283
|
autoComplete={yearAutoComplete}
|
|
289
284
|
placeholder={placeholders?.year}
|
|
290
|
-
value={
|
|
285
|
+
value={displayYear || ''}
|
|
291
286
|
disabled={disabled}
|
|
292
|
-
min={
|
|
287
|
+
min={0}
|
|
288
|
+
max={9999}
|
|
289
|
+
maxLength={4}
|
|
293
290
|
onChange={(event) => handleYearChange(event)}
|
|
294
291
|
/>
|
|
295
292
|
</div>
|
package/src/i18n/en.json
CHANGED
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"neptune.PhoneNumberInput.SelectInput.placeholder": "Select an option...",
|
|
24
24
|
"neptune.Select.searchPlaceholder": "Search...",
|
|
25
25
|
"neptune.SelectInput.noResultsFound": "No results found",
|
|
26
|
-
"neptune.SelectOption.action.label": "Choose",
|
|
27
26
|
"neptune.Summary.statusDone": "Item done",
|
|
28
27
|
"neptune.Summary.statusNotDone": "Item to do",
|
|
29
28
|
"neptune.Summary.statusPending": "Item pending",
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export type { AccordionItem, AccordionProps } from './accordion';
|
|
5
5
|
export type { ActionOptionProps } from './actionOption';
|
|
6
|
-
export type { SelectOptionProps, SelectOptionValue, SelectOptiopsSection } from './selectOption';
|
|
7
6
|
export type { AlertAction, AlertProps, AlertType } from './alert';
|
|
8
7
|
export type { AvatarProps } from './avatar';
|
|
9
8
|
export type { BadgeProps } from './badge';
|
|
@@ -87,7 +86,6 @@ export type { UploadError, UploadResponse, UploadedFile } from './uploadInput/ty
|
|
|
87
86
|
export { default as Accordion } from './accordion';
|
|
88
87
|
export { default as ActionButton } from './actionButton';
|
|
89
88
|
export { default as ActionOption } from './actionOption';
|
|
90
|
-
export { default as SelectOption } from './selectOption';
|
|
91
89
|
export { default as Alert } from './alert';
|
|
92
90
|
export { default as Avatar } from './avatar';
|
|
93
91
|
export { default as AvatarWrapper } from './avatarWrapper';
|
package/src/main.css
CHANGED
|
@@ -1484,39 +1484,6 @@ button.np-option {
|
|
|
1484
1484
|
border-radius: var(--radius-small);
|
|
1485
1485
|
}
|
|
1486
1486
|
}
|
|
1487
|
-
.np-select-option {
|
|
1488
|
-
border-radius: 10px;
|
|
1489
|
-
border-radius: var(--radius-small);
|
|
1490
|
-
background-color: rgba(134,167,189,0.10196);
|
|
1491
|
-
background-color: var(--color-background-neutral);
|
|
1492
|
-
}
|
|
1493
|
-
.np-select-option-selected {
|
|
1494
|
-
background-color: #ffffff;
|
|
1495
|
-
background-color: var(--color-background-screen);
|
|
1496
|
-
border: 1px solid #c9cbce;
|
|
1497
|
-
border: 1px solid var(--color-interactive-secondary);
|
|
1498
|
-
}
|
|
1499
|
-
.np-select-option-list {
|
|
1500
|
-
max-height: 350px;
|
|
1501
|
-
overflow-y: auto;
|
|
1502
|
-
}
|
|
1503
|
-
.np-select-option-section {
|
|
1504
|
-
margin-top: 0 !important;
|
|
1505
|
-
}
|
|
1506
|
-
.has-error * .np-select-option {
|
|
1507
|
-
--ring-outline-color: var(--color-sentiment-negative);
|
|
1508
|
-
--ring-outline-offset: 0;
|
|
1509
|
-
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
1510
|
-
outline-offset: 0;
|
|
1511
|
-
outline-offset: var(--ring-outline-offset);
|
|
1512
|
-
}
|
|
1513
|
-
.has-error * .np-select-option:focus {
|
|
1514
|
-
outline: none;
|
|
1515
|
-
}
|
|
1516
|
-
.has-error * .np-select-option:focus-visible {
|
|
1517
|
-
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
1518
|
-
outline-offset: var(--ring-outline-offset);
|
|
1519
|
-
}
|
|
1520
1487
|
.np-panel__content {
|
|
1521
1488
|
opacity: 0;
|
|
1522
1489
|
visibility: hidden;
|
package/src/main.less
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
@import "./common/card/Card.less";
|
|
14
14
|
@import "./common/closeButton/CloseButton.less";
|
|
15
15
|
@import "./common/Option/Option.less";
|
|
16
|
-
@import "./selectOption/SelectOption.less";
|
|
17
16
|
@import "./common/panel/Panel.less";
|
|
18
17
|
@import "./common/RadioButton/RadioButton.less";
|
|
19
18
|
@import "./dateInput/DateInput.less";
|
package/src/ssr.spec.js
CHANGED
|
@@ -226,7 +226,6 @@ describe('Server side rendering', () => {
|
|
|
226
226
|
DateLookup: { value: new Date() },
|
|
227
227
|
Link: { size: 16 },
|
|
228
228
|
Tooltip: { children: <>yo</> },
|
|
229
|
-
SelectOption: { placeholder: { media: <img alt="img" /> } },
|
|
230
229
|
};
|
|
231
230
|
|
|
232
231
|
const { Provider } = exposedLibraryItems;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
.np-select-option {
|
|
2
|
-
border-radius: 10px;
|
|
3
|
-
border-radius: var(--radius-small);
|
|
4
|
-
background-color: rgba(134,167,189,0.10196);
|
|
5
|
-
background-color: var(--color-background-neutral);
|
|
6
|
-
}
|
|
7
|
-
.np-select-option-selected {
|
|
8
|
-
background-color: #ffffff;
|
|
9
|
-
background-color: var(--color-background-screen);
|
|
10
|
-
border: 1px solid #c9cbce;
|
|
11
|
-
border: 1px solid var(--color-interactive-secondary);
|
|
12
|
-
}
|
|
13
|
-
.np-select-option-list {
|
|
14
|
-
max-height: 350px;
|
|
15
|
-
overflow-y: auto;
|
|
16
|
-
}
|
|
17
|
-
.np-select-option-section {
|
|
18
|
-
margin-top: 0 !important;
|
|
19
|
-
}
|
|
20
|
-
.has-error * .np-select-option {
|
|
21
|
-
--ring-outline-color: var(--color-sentiment-negative);
|
|
22
|
-
--ring-outline-offset: 0;
|
|
23
|
-
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
24
|
-
outline-offset: 0;
|
|
25
|
-
outline-offset: var(--ring-outline-offset);
|
|
26
|
-
}
|
|
27
|
-
.has-error * .np-select-option:focus {
|
|
28
|
-
outline: none;
|
|
29
|
-
}
|
|
30
|
-
.has-error * .np-select-option:focus-visible {
|
|
31
|
-
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
32
|
-
outline-offset: var(--ring-outline-offset);
|
|
33
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ActionButtonProps } from '../actionButton';
|
|
2
|
-
import type { OptionProps } from '../common/Option/Option';
|
|
3
|
-
import { HeaderProps } from '../header/Header';
|
|
4
|
-
export type SelectOptiopsSection<T = unknown> = {
|
|
5
|
-
title?: HeaderProps['title'];
|
|
6
|
-
options: SelectOptionValue<T>[];
|
|
7
|
-
};
|
|
8
|
-
export type SelectOptionValue<T = unknown> = Pick<OptionProps, 'media' | 'title' | 'content' | 'disabled'> & {
|
|
9
|
-
value?: T;
|
|
10
|
-
};
|
|
11
|
-
export type SelectOptionPlaceholder = Pick<OptionProps, 'media' | 'title' | 'content'> & {
|
|
12
|
-
actionLabel?: ActionButtonProps['children'];
|
|
13
|
-
};
|
|
14
|
-
export type SelectOptionProps<T> = {
|
|
15
|
-
onChange: (selected: SelectOptionValue<T>) => void;
|
|
16
|
-
selected?: SelectOptionValue<T>;
|
|
17
|
-
options: SelectOptiopsSection<T>[];
|
|
18
|
-
placeholder: SelectOptionPlaceholder;
|
|
19
|
-
} & Omit<OptionProps, 'as' | 'title' | 'media' | 'content' | 'onClick' | 'onChange' | 'showMediaAtAllSizes' | 'decision'>;
|
|
20
|
-
export default function SelectOption<T>({ selected: selectedValueProp, options, onChange, placeholder, disabled, ...props }: SelectOptionProps<T>): import("react").JSX.Element;
|
|
21
|
-
//# sourceMappingURL=SelectOption.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectOption.d.ts","sourceRoot":"","sources":["../../../src/selectOption/SelectOption.tsx"],"names":[],"mappings":"AACA,OAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAI3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAU/C,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,OAAO,IAAI;IAC9C,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,OAAO,IAAI,IAAI,CAC/C,WAAW,EACX,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAC3C,GAAG;IACF,KAAK,CAAC,EAAE,CAAC,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC,GAAG;IACvF,WAAW,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,QAAQ,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACnD,QAAQ,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;IACnC,WAAW,EAAE,uBAAuB,CAAC;CACtC,GAAG,IAAI,CACN,WAAW,EACX,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,qBAAqB,GAAG,UAAU,CACnG,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,EACtC,QAAQ,EAAE,iBAA6B,EACvC,OAAO,EACP,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,iBAAiB,CAAC,CAAC,CAAC,+BAqGtB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectOption.messages.d.ts","sourceRoot":"","sources":["../../../src/selectOption/SelectOption.messages.ts"],"names":[],"mappings":";;;;;;AAEA,wBAKG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/selectOption/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|