@transferwise/components 0.0.0-experimental-0df72a3 → 0.0.0-experimental-fe160ab

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.
Files changed (158) hide show
  1. package/build/Calendar/Calendar.constants.js +10 -0
  2. package/build/Calendar/Calendar.constants.js.map +1 -0
  3. package/build/Calendar/Calendar.constants.mjs +8 -0
  4. package/build/Calendar/Calendar.constants.mjs.map +1 -0
  5. package/build/Calendar/Calendar.js +116 -16
  6. package/build/Calendar/Calendar.js.map +1 -1
  7. package/build/Calendar/Calendar.messages.js +12 -0
  8. package/build/Calendar/Calendar.messages.js.map +1 -1
  9. package/build/Calendar/Calendar.messages.mjs +12 -0
  10. package/build/Calendar/Calendar.messages.mjs.map +1 -1
  11. package/build/Calendar/Calendar.mjs +117 -17
  12. package/build/Calendar/Calendar.mjs.map +1 -1
  13. package/build/Calendar/DateHeader/DateHeader.js +5 -1
  14. package/build/Calendar/DateHeader/DateHeader.js.map +1 -1
  15. package/build/Calendar/DateHeader/DateHeader.mjs +5 -1
  16. package/build/Calendar/DateHeader/DateHeader.mjs.map +1 -1
  17. package/build/Calendar/DayCalendar/DayCalendar.js +20 -2
  18. package/build/Calendar/DayCalendar/DayCalendar.js.map +1 -1
  19. package/build/Calendar/DayCalendar/DayCalendar.mjs +20 -2
  20. package/build/Calendar/DayCalendar/DayCalendar.mjs.map +1 -1
  21. package/build/Calendar/DayCalendar/Table/DayCalendarTable.js +60 -19
  22. package/build/Calendar/DayCalendar/Table/DayCalendarTable.js.map +1 -1
  23. package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs +60 -19
  24. package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs.map +1 -1
  25. package/build/Calendar/MonthCalendar/MonthCalendar.js +6 -0
  26. package/build/Calendar/MonthCalendar/MonthCalendar.js.map +1 -1
  27. package/build/Calendar/MonthCalendar/MonthCalendar.mjs +6 -0
  28. package/build/Calendar/MonthCalendar/MonthCalendar.mjs.map +1 -1
  29. package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.js +8 -3
  30. package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.js.map +1 -1
  31. package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.mjs +8 -3
  32. package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.mjs.map +1 -1
  33. package/build/Calendar/TableLink/TableLink.js +91 -0
  34. package/build/Calendar/TableLink/TableLink.js.map +1 -0
  35. package/build/Calendar/TableLink/TableLink.mjs +87 -0
  36. package/build/Calendar/TableLink/TableLink.mjs.map +1 -0
  37. package/build/Calendar/YearCalendar/Table/YearCalendarTable.js +8 -3
  38. package/build/Calendar/YearCalendar/Table/YearCalendarTable.js.map +1 -1
  39. package/build/Calendar/YearCalendar/Table/YearCalendarTable.mjs +8 -3
  40. package/build/Calendar/YearCalendar/Table/YearCalendarTable.mjs.map +1 -1
  41. package/build/Calendar/YearCalendar/YearCalendar.js +7 -0
  42. package/build/Calendar/YearCalendar/YearCalendar.js.map +1 -1
  43. package/build/Calendar/YearCalendar/YearCalendar.mjs +7 -0
  44. package/build/Calendar/YearCalendar/YearCalendar.mjs.map +1 -1
  45. package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js +33 -0
  46. package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js.map +1 -0
  47. package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs +31 -0
  48. package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs.map +1 -0
  49. package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.js +40 -0
  50. package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.js.map +1 -0
  51. package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.mjs +38 -0
  52. package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.mjs.map +1 -0
  53. package/build/DateLookup/DateLookup.js +20 -9
  54. package/build/DateLookup/DateLookup.js.map +1 -1
  55. package/build/DateLookup/DateLookup.mjs +20 -9
  56. package/build/DateLookup/DateLookup.mjs.map +1 -1
  57. package/build/i18n/en.json +4 -0
  58. package/build/i18n/en.json.js +4 -0
  59. package/build/i18n/en.json.js.map +1 -1
  60. package/build/i18n/en.json.mjs +4 -0
  61. package/build/i18n/en.json.mjs.map +1 -1
  62. package/build/i18n/hu.json +1 -1
  63. package/build/i18n/hu.json.js +1 -1
  64. package/build/i18n/hu.json.mjs +1 -1
  65. package/build/index.js +2 -2
  66. package/build/index.mjs +1 -1
  67. package/build/main.css +123 -43
  68. package/build/styles/Calendar/Calendar.css +112 -37
  69. package/build/styles/Calendar/TableLink/TableLink.css +115 -0
  70. package/build/styles/main.css +123 -43
  71. package/build/types/Calendar/Calendar.constants.d.ts +2 -0
  72. package/build/types/Calendar/Calendar.constants.d.ts.map +1 -0
  73. package/build/types/Calendar/Calendar.d.ts +16 -3
  74. package/build/types/Calendar/Calendar.d.ts.map +1 -1
  75. package/build/types/Calendar/Calendar.messages.d.ts +20 -0
  76. package/build/types/Calendar/Calendar.messages.d.ts.map +1 -1
  77. package/build/types/Calendar/Calendar.types.d.ts +32 -0
  78. package/build/types/Calendar/Calendar.types.d.ts.map +1 -0
  79. package/build/types/Calendar/DateHeader/DateHeader.d.ts +2 -0
  80. package/build/types/Calendar/DateHeader/DateHeader.d.ts.map +1 -1
  81. package/build/types/Calendar/DayCalendar/DayCalendar.d.ts +7 -1
  82. package/build/types/Calendar/DayCalendar/DayCalendar.d.ts.map +1 -1
  83. package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts +6 -0
  84. package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts.map +1 -1
  85. package/build/types/Calendar/MonthCalendar/MonthCalendar.d.ts +1 -0
  86. package/build/types/Calendar/MonthCalendar/MonthCalendar.d.ts.map +1 -1
  87. package/build/types/Calendar/MonthCalendar/Table/MonthCalendarTable.d.ts +2 -1
  88. package/build/types/Calendar/MonthCalendar/Table/MonthCalendarTable.d.ts.map +1 -1
  89. package/build/types/Calendar/{tableLink → TableLink}/TableLink.d.ts +5 -1
  90. package/build/types/Calendar/TableLink/TableLink.d.ts.map +1 -0
  91. package/build/types/Calendar/TableLink/index.d.ts.map +1 -0
  92. package/build/types/Calendar/YearCalendar/Table/YearCalendarTable.d.ts +2 -1
  93. package/build/types/Calendar/YearCalendar/Table/YearCalendarTable.d.ts.map +1 -1
  94. package/build/types/Calendar/YearCalendar/YearCalendar.d.ts +1 -0
  95. package/build/types/Calendar/YearCalendar/YearCalendar.d.ts.map +1 -1
  96. package/build/types/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.d.ts +3 -0
  97. package/build/types/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.d.ts.map +1 -0
  98. package/build/types/Calendar/_helpers/index.d.ts +3 -0
  99. package/build/types/Calendar/_helpers/index.d.ts.map +1 -0
  100. package/build/types/Calendar/_helpers/isDateDisabled/isDateDisabled.d.ts +3 -0
  101. package/build/types/Calendar/_helpers/isDateDisabled/isDateDisabled.d.ts.map +1 -0
  102. package/build/types/Calendar/index.d.ts +1 -0
  103. package/build/types/Calendar/index.d.ts.map +1 -1
  104. package/build/types/DateLookup/DateLookup.d.ts +24 -5
  105. package/build/types/DateLookup/DateLookup.d.ts.map +1 -1
  106. package/build/types/DateLookup/index.d.ts +1 -0
  107. package/build/types/DateLookup/index.d.ts.map +1 -1
  108. package/build/types/index.d.ts +3 -2
  109. package/build/types/index.d.ts.map +1 -1
  110. package/build/types/test-utils/index.d.ts +8 -0
  111. package/build/types/test-utils/index.d.ts.map +1 -1
  112. package/package.json +1 -1
  113. package/src/Calendar/Calendar.constants.ts +5 -0
  114. package/src/Calendar/Calendar.css +112 -37
  115. package/src/Calendar/Calendar.disabledDates.test.tsx +593 -0
  116. package/src/Calendar/Calendar.less +5 -35
  117. package/src/Calendar/Calendar.messages.ts +21 -0
  118. package/src/Calendar/Calendar.test.tsx +310 -28
  119. package/src/Calendar/Calendar.tsx +159 -18
  120. package/src/Calendar/Calendar.types.ts +35 -0
  121. package/src/Calendar/DateHeader/DateHeader.tsx +6 -0
  122. package/src/Calendar/DayCalendar/DayCalendar.tsx +39 -1
  123. package/src/Calendar/DayCalendar/Table/DayCalendarTable.tsx +67 -27
  124. package/src/Calendar/MonthCalendar/MonthCalendar.tsx +8 -0
  125. package/src/Calendar/MonthCalendar/Table/MonthCalendarTable.tsx +15 -3
  126. package/src/Calendar/TableLink/TableLink.css +115 -0
  127. package/src/Calendar/TableLink/TableLink.less +68 -0
  128. package/src/Calendar/TableLink/TableLink.tsx +112 -0
  129. package/src/Calendar/YearCalendar/Table/YearCalendarTable.tsx +15 -3
  130. package/src/Calendar/YearCalendar/YearCalendar.tsx +9 -0
  131. package/src/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.test.ts +98 -0
  132. package/src/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.ts +45 -0
  133. package/src/Calendar/_helpers/index.ts +2 -0
  134. package/src/Calendar/_helpers/isDateDisabled/isDateDisabled.test.ts +169 -0
  135. package/src/Calendar/_helpers/isDateDisabled/isDateDisabled.ts +59 -0
  136. package/src/Calendar/_stories/Calendar.accessibility.docs.mdx +118 -0
  137. package/src/Calendar/_stories/Calendar.story.tsx +138 -4
  138. package/src/Calendar/_stories/Calendar.test.story.tsx +114 -0
  139. package/src/Calendar/index.ts +7 -0
  140. package/src/DateLookup/DateLookup.disabledDates.test.tsx +293 -0
  141. package/src/DateLookup/DateLookup.test.tsx +34 -37
  142. package/src/DateLookup/DateLookup.tsx +37 -13
  143. package/src/DateLookup/_stories/DateLookup.accessibility.docs.mdx +108 -0
  144. package/src/DateLookup/_stories/DateLookup.story.tsx +124 -2
  145. package/src/DateLookup/index.ts +6 -0
  146. package/src/i18n/en.json +4 -0
  147. package/src/i18n/hu.json +1 -1
  148. package/src/index.ts +3 -2
  149. package/src/main.css +123 -43
  150. package/build/Calendar/tableLink/TableLink.js +0 -61
  151. package/build/Calendar/tableLink/TableLink.js.map +0 -1
  152. package/build/Calendar/tableLink/TableLink.mjs +0 -57
  153. package/build/Calendar/tableLink/TableLink.mjs.map +0 -1
  154. package/build/types/Calendar/tableLink/TableLink.d.ts.map +0 -1
  155. package/build/types/Calendar/tableLink/index.d.ts.map +0 -1
  156. package/src/Calendar/tableLink/TableLink.tsx +0 -77
  157. /package/build/types/Calendar/{tableLink → TableLink}/index.d.ts +0 -0
  158. /package/src/Calendar/{tableLink → TableLink}/index.ts +0 -0
@@ -1,16 +1,23 @@
1
1
  import { useState } from 'react';
2
2
  import { StoryObj } from '@storybook/react-webpack5';
3
+ import { fn } from 'storybook/test';
4
+ import { action } from 'storybook/actions';
3
5
  import {
4
6
  createSandboxStory,
5
7
  globalScope,
6
8
  } from '../../../.storybook/components/sandbox/SandboxEditor';
9
+ import { storySourceWithoutNoise } from '../../../.storybook/helpers';
7
10
  import { Size } from '../../common';
8
- import DateLookup, { type DateLookupProps } from '..';
9
11
  import Field from '../../Field';
12
+ import DateLookup, { type DateLookupProps } from '..';
10
13
 
11
14
  export default {
12
15
  component: DateLookup,
13
16
  title: 'Forms/DateLookup',
17
+ args: {
18
+ onFocus: fn(),
19
+ onBlur: fn(),
20
+ },
14
21
  argTypes: {
15
22
  size: { control: 'select', options: [Size.SMALL, Size.MEDIUM, Size.LARGE] },
16
23
  disabled: { control: 'boolean' },
@@ -34,7 +41,7 @@ thePast.setUTCDate(epoch.getUTCDate() - 10);
34
41
 
35
42
  export const Sandbox = createSandboxStory({
36
43
  code: `const App = () => {
37
- const [value, setValue] = React.useState(new Date('2024-06-15'));
44
+ const [value, setValue] = React.useState(new Date(2024, 5, 14));
38
45
 
39
46
  return (
40
47
  <DateLookup
@@ -44,6 +51,11 @@ export const Sandbox = createSandboxStory({
44
51
  placeholder="Choose date"
45
52
  clearable
46
53
  value={value}
54
+ disabledRules={{
55
+ weekdays: ['sat', 'sun'],
56
+ dates: [new Date(2024, 5, 19)],
57
+ reason: 'Weekends and holidays are unavailable.',
58
+ }}
47
59
  onChange={(date) => setValue(date)}
48
60
  />
49
61
  );
@@ -120,3 +132,113 @@ export const RightAligned: Story = {
120
132
  );
121
133
  },
122
134
  };
135
+
136
+ /**
137
+ * Use `disabledRules` to disable specific weekdays, individual dates, or date ranges.
138
+ * Disabled dates remain focusable and keyboard-navigable — clicking or focusing one
139
+ * keeps the panel open, fires `onDateSelect` with `isEnabled: false`, and shows a
140
+ * negative inline prompt with the `reason` text. `min`/`max` out-of-range dates show
141
+ * a built-in boundary prompt (e.g. "Please select a date between 9 December 2024 and
142
+ * 22 January 2025.").
143
+ *
144
+ * The `reason` field is **required for accessibility**: it renders as an InlinePrompt
145
+ * below the grid and is linked to every disabled cell via `aria-describedby`, so screen
146
+ * reader users understand why a date is unavailable. For per-date reason customisation
147
+ * see [DisabledDatesWithDynamicReason](#disabled-dates-with-dynamic-reason).
148
+ */
149
+ export const DisabledDates: Story = storySourceWithoutNoise({
150
+ args: {
151
+ size: Size.MEDIUM,
152
+ label: 'Select a date',
153
+ placeholder: 'Choose date',
154
+ monthFormat: 'long',
155
+ },
156
+ render: function Render(args: DateLookupProps) {
157
+ const min = new Date(2024, 11, 9);
158
+ const max = new Date(2025, 0, 22);
159
+ const bankHolidays = [new Date(2024, 11, 25), new Date(2024, 11, 26), new Date(2025, 0, 1)];
160
+ const [value, setValue] = useState<Date | null>(null);
161
+
162
+ return (
163
+ <DateLookup
164
+ {...args}
165
+ min={min}
166
+ max={max}
167
+ value={value}
168
+ disabledRules={{
169
+ weekdays: ['sat', 'sun'],
170
+ dates: bankHolidays,
171
+ ranges: [{ start: new Date(2024, 11, 23), end: new Date(2024, 11, 24) }],
172
+ reason: 'Some dates are unavailable for this service.',
173
+ }}
174
+ onChange={(date) => {
175
+ action('onChange')(date);
176
+ setValue(date);
177
+ }}
178
+ onDateSelect={({ date, isEnabled }) => {
179
+ action('onDateSelect')({ date, isEnabled });
180
+ }}
181
+ />
182
+ );
183
+ },
184
+ });
185
+
186
+ /**
187
+ * When different disabled dates warrant different explanations, drive the `reason`
188
+ * dynamically from `onDateSelect`. The `isEnabled` flag tells you whether the focused
189
+ * date is selectable; from there you can look up the specific reason and update state.
190
+ *
191
+ * `min`/`max` out-of-range dates are handled automatically — the component shows a
192
+ * built-in prompt with the boundary dates, so `determineReason` only needs to cover
193
+ * rule-disabled dates.
194
+ */
195
+ export const DisabledDatesWithDynamicReason: Story = storySourceWithoutNoise({
196
+ args: {
197
+ size: Size.MEDIUM,
198
+ label: 'Select a date',
199
+ placeholder: 'Choose date',
200
+ monthFormat: 'long',
201
+ },
202
+ render: function Render(args: DateLookupProps) {
203
+ const DEFAULT_REASON = 'Some dates are unavailable for this service.';
204
+ const min = new Date(2024, 11, 9);
205
+ const max = new Date(2025, 0, 22);
206
+ const bankHolidays = [new Date(2024, 11, 25), new Date(2024, 11, 26), new Date(2025, 0, 1)];
207
+ const [value, setValue] = useState<Date | null>(null);
208
+ const [reason, setReason] = useState(DEFAULT_REASON);
209
+
210
+ function determineReason(date: Date, isEnabled: boolean): string {
211
+ if (isEnabled) return DEFAULT_REASON;
212
+ if (bankHolidays.some((holiday) => holiday.toDateString() === date.toDateString())) {
213
+ return 'This date is a bank holiday.';
214
+ }
215
+ if (date.getDay() === 0 || date.getDay() === 6) {
216
+ return 'We do not operate on weekends.';
217
+ }
218
+ return 'This date is unavailable due to scheduled maintenance.';
219
+ }
220
+
221
+ return (
222
+ <DateLookup
223
+ {...args}
224
+ min={min}
225
+ max={max}
226
+ value={value}
227
+ disabledRules={{
228
+ weekdays: ['sat', 'sun'],
229
+ dates: bankHolidays,
230
+ ranges: [{ start: new Date(2024, 11, 23), end: new Date(2024, 11, 24) }],
231
+ reason,
232
+ }}
233
+ onChange={(date) => {
234
+ action('onChange')(date);
235
+ setValue(date);
236
+ }}
237
+ onDateSelect={({ date, isEnabled }) => {
238
+ action('onDateSelect')({ date, isEnabled });
239
+ setReason(determineReason(date, isEnabled));
240
+ }}
241
+ />
242
+ );
243
+ },
244
+ });
@@ -1,2 +1,8 @@
1
1
  export { default } from './DateLookup';
2
2
  export type { DateLookupProps } from './DateLookup';
3
+ export type {
4
+ DisabledRules,
5
+ DisabledDateRange,
6
+ WeekDayType,
7
+ OnDateSelectParams,
8
+ } from '../Calendar/Calendar.types';
package/src/i18n/en.json CHANGED
@@ -12,6 +12,10 @@
12
12
  "neptune.DateLookup.goTo20YearView": "Go to 20 year view",
13
13
  "neptune.DateLookup.month": "month",
14
14
  "neptune.DateLookup.next": "next",
15
+ "neptune.DateLookup.notAvailable": "not available",
16
+ "neptune.DateLookup.outOfRangeAfter": "Please enter {min} or a later date.",
17
+ "neptune.DateLookup.outOfRangeBefore": "Please enter {max} or an earlier date.",
18
+ "neptune.DateLookup.outOfRangeBetween": "Please select a date between {min} and {max}.",
15
19
  "neptune.DateLookup.previous": "previous",
16
20
  "neptune.DateLookup.selected": "selected",
17
21
  "neptune.DateLookup.twentyYears": "20 years",
package/src/i18n/hu.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "neptune.Field.characterCount": "Felhasználva {current}/{max} karakter",
24
24
  "neptune.FlowNavigation.back": "vissza az előző lépéshez",
25
25
  "neptune.Info.ariaLabel": "További információ",
26
- "neptune.Label.optional": "(Választható)",
26
+ "neptune.Label.optional": "(Válaszható)",
27
27
  "neptune.Link.opensInNewTab": "(új lapon nyílik meg)",
28
28
  "neptune.MoneyInput.Select.placeholder": "Válassz ki egy lehetőséget...",
29
29
  "neptune.MoneyInput.Select.searchPlaceholder": "Írj be egy pénznemet vagy országot",
package/src/index.ts CHANGED
@@ -26,6 +26,8 @@ export type {
26
26
  AnchorElementProps,
27
27
  } from './Button';
28
28
  export type { BodyProps } from './Body';
29
+ export type { CalendarProps } from './Calendar';
30
+ export type { DisabledRules, WeekDayType, DisabledDateRange } from './Calendar';
29
31
  export type { CardProps } from './_deprecated/Card';
30
32
  export type {
31
33
  CarouselProps,
@@ -56,7 +58,6 @@ export type {
56
58
  export type { BottomSheetProps } from './common/BottomSheet';
57
59
  export type { DateInputProps } from './DateInput';
58
60
  export type { DateLookupProps } from './DateLookup';
59
- export type { CalendarProps } from './Calendar';
60
61
  export type { DecisionProps } from './Decision';
61
62
  export type {
62
63
  DefinitionListProps,
@@ -205,6 +206,7 @@ export { default as Badge, BadgeAssets } from './_deprecated/Badge';
205
206
  export { default as Body } from './Body';
206
207
  export { default as Button } from './Button';
207
208
  export { default as IconButton } from './IconButton';
209
+ export { default as Calendar } from './Calendar';
208
210
  export { default as Carousel } from './Carousel';
209
211
  export { default as Card } from './_deprecated/Card';
210
212
  export { default as Checkbox } from './Checkbox';
@@ -220,7 +222,6 @@ export { default as BaseCard } from './common/BaseCard';
220
222
  export { default as CriticalCommsBanner } from './_deprecated/CriticalBanner';
221
223
  export { default as DateInput } from './DateInput';
222
224
  export { default as DateLookup } from './DateLookup';
223
- export { default as Calendar } from './Calendar';
224
225
  export { default as Decision } from './Decision';
225
226
  export { default as DefinitionList } from './DefinitionList';
226
227
  export { default as Dimmer } from './Dimmer';
package/src/main.css CHANGED
@@ -27269,46 +27269,12 @@ a[data-toggle="tooltip"] {
27269
27269
  pointer-events: auto;
27270
27270
  }
27271
27271
 
27272
- .tw-date-lookup-calendar {
27273
- min-width: 300px;
27274
- text-align: center;
27275
- table-layout: fixed;
27276
- border: none;
27277
- background-color: inherit;
27278
- }
27279
-
27280
- .tw-date-lookup-calendar thead {
27281
- background-color: transparent;
27282
- background-color: initial;
27283
- }
27284
-
27285
- .tw-date-lookup-calendar > tbody > tr > td.weekend button {
27286
- color: #5d7079;
27287
- color: var(--color-content-secondary);
27288
- }
27289
-
27290
- .tw-date-lookup-calendar > tbody > tr > td {
27291
- border: none;
27292
- padding: 4px;
27293
- padding: var(--size-4);
27294
- }
27295
-
27296
- @media (max-width: 320px) {
27297
- .tw-date-lookup-calendar > tbody > tr > td {
27298
- padding: 0;
27299
- }
27300
- }
27301
-
27302
- .tw-date-lookup-calendar > tbody > tr > td:has(.tw-date-lookup-day-option) {
27303
- padding: 1px;
27304
- }
27305
-
27306
- .tw-date-lookup-calendar > tbody > tr > td button {
27272
+ .wds-Calendar__option--day,
27273
+ .wds-Calendar__option--month,
27274
+ .wds-Calendar__option--year {
27307
27275
  width: 100%;
27308
27276
  padding: 4px 0;
27309
27277
  padding: var(--size-4) 0;
27310
- color: #0097c7;
27311
- color: var(--color-content-accent);
27312
27278
  border: transparent;
27313
27279
  border-radius: 10px;
27314
27280
  border-radius: var(--radius-small);
@@ -27320,12 +27286,92 @@ a[data-toggle="tooltip"] {
27320
27286
  }
27321
27287
 
27322
27288
  @media (max-width: 320px) {
27323
- .tw-date-lookup-calendar > tbody > tr > td button {
27289
+ .wds-Calendar__option--day,
27290
+ .wds-Calendar__option--month,
27291
+ .wds-Calendar__option--year {
27324
27292
  padding: 0;
27325
27293
  }
27326
27294
  }
27327
27295
 
27328
- .tw-date-lookup-calendar > tbody > tr > td button.tw-date-lookup-day-option {
27296
+ .wds-Calendar__option--day:focus,
27297
+ .wds-Calendar__option--month:focus,
27298
+ .wds-Calendar__option--year:focus {
27299
+ background-color: var(--color-background-screen-hover);
27300
+ }
27301
+
27302
+ .wds-Calendar__option--day.disabled,
27303
+ .wds-Calendar__option--month.disabled,
27304
+ .wds-Calendar__option--year.disabled,
27305
+ .wds-Calendar__option--day[aria-disabled="true"],
27306
+ .wds-Calendar__option--month[aria-disabled="true"],
27307
+ .wds-Calendar__option--year[aria-disabled="true"] {
27308
+ --ring-outline-color: var(--color-sentiment-content-primary);
27309
+ color: #768e9c;
27310
+ color: var(--color-content-tertiary);
27311
+ cursor: not-allowed;
27312
+ }
27313
+
27314
+ .wds-Calendar__option--day.disabled:hover,
27315
+ .wds-Calendar__option--month.disabled:hover,
27316
+ .wds-Calendar__option--year.disabled:hover,
27317
+ .wds-Calendar__option--day[aria-disabled="true"]:hover,
27318
+ .wds-Calendar__option--month[aria-disabled="true"]:hover,
27319
+ .wds-Calendar__option--year[aria-disabled="true"]:hover,
27320
+ .wds-Calendar__option--day.disabled:focus,
27321
+ .wds-Calendar__option--month.disabled:focus,
27322
+ .wds-Calendar__option--year.disabled:focus,
27323
+ .wds-Calendar__option--day[aria-disabled="true"]:focus,
27324
+ .wds-Calendar__option--month[aria-disabled="true"]:focus,
27325
+ .wds-Calendar__option--year[aria-disabled="true"]:focus {
27326
+ filter: initial;
27327
+ opacity: 1;
27328
+ opacity: initial;
27329
+ background-color: var(--color-sentiment-background-surface);
27330
+ color: var(--color-sentiment-content-primary);
27331
+ }
27332
+
27333
+ .wds-Calendar__option--day.disabled.active,
27334
+ .wds-Calendar__option--month.disabled.active,
27335
+ .wds-Calendar__option--year.disabled.active,
27336
+ .wds-Calendar__option--day[aria-disabled="true"].active,
27337
+ .wds-Calendar__option--month[aria-disabled="true"].active,
27338
+ .wds-Calendar__option--year[aria-disabled="true"].active,
27339
+ .wds-Calendar__option--day.disabled.active:hover,
27340
+ .wds-Calendar__option--month.disabled.active:hover,
27341
+ .wds-Calendar__option--year.disabled.active:hover,
27342
+ .wds-Calendar__option--day[aria-disabled="true"].active:hover,
27343
+ .wds-Calendar__option--month[aria-disabled="true"].active:hover,
27344
+ .wds-Calendar__option--year[aria-disabled="true"].active:hover,
27345
+ .wds-Calendar__option--day.disabled.active:active,
27346
+ .wds-Calendar__option--month.disabled.active:active,
27347
+ .wds-Calendar__option--year.disabled.active:active,
27348
+ .wds-Calendar__option--day[aria-disabled="true"].active:active,
27349
+ .wds-Calendar__option--month[aria-disabled="true"].active:active,
27350
+ .wds-Calendar__option--year[aria-disabled="true"].active:active,
27351
+ .wds-Calendar__option--day.disabled.active:focus,
27352
+ .wds-Calendar__option--month.disabled.active:focus,
27353
+ .wds-Calendar__option--year.disabled.active:focus,
27354
+ .wds-Calendar__option--day[aria-disabled="true"].active:focus,
27355
+ .wds-Calendar__option--month[aria-disabled="true"].active:focus,
27356
+ .wds-Calendar__option--year[aria-disabled="true"].active:focus {
27357
+ filter: initial;
27358
+ opacity: 1;
27359
+ opacity: initial;
27360
+ background-color: var(--color-sentiment-interactive-primary);
27361
+ color: var(--color-sentiment-interactive-secondary);
27362
+ }
27363
+
27364
+ .wds-Calendar__option--day.disabled.today,
27365
+ .wds-Calendar__option--month.disabled.today,
27366
+ .wds-Calendar__option--year.disabled.today,
27367
+ .wds-Calendar__option--day[aria-disabled="true"].today,
27368
+ .wds-Calendar__option--month[aria-disabled="true"].today,
27369
+ .wds-Calendar__option--year[aria-disabled="true"].today {
27370
+ text-decoration-color: #768e9c;
27371
+ text-decoration-color: var(--color-content-tertiary);
27372
+ }
27373
+
27374
+ .wds-Calendar__option--day {
27329
27375
  height: 40px;
27330
27376
  height: var(--size-40);
27331
27377
  border-radius: 9999px;
@@ -27340,19 +27386,53 @@ a[data-toggle="tooltip"] {
27340
27386
  justify-content: center;
27341
27387
  }
27342
27388
 
27343
- .tw-date-lookup-calendar > tbody > tr > td button.tw-date-lookup-day-option.today {
27389
+ .wds-Calendar__option--day.today {
27344
27390
  -webkit-text-decoration: underline;
27345
27391
  text-decoration: underline;
27346
27392
  text-decoration-thickness: 2px;
27347
27393
  text-underline-offset: 4px;
27348
27394
  }
27349
27395
 
27350
- .tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.show-focus,
27351
- .tw-date-lookup-calendar > tbody > tr > td:hover button:not(.disabled):not(:disabled) {
27396
+ .tw-date-lookup-calendar {
27397
+ min-width: 300px;
27398
+ text-align: center;
27399
+ table-layout: fixed;
27400
+ border: none;
27401
+ background-color: inherit;
27402
+ }
27403
+
27404
+ .tw-date-lookup-calendar thead {
27405
+ background-color: transparent;
27406
+ background-color: initial;
27407
+ }
27408
+
27409
+ .tw-date-lookup-calendar > tbody > tr > td.weekend button {
27410
+ color: #5d7079;
27411
+ color: var(--color-content-secondary);
27412
+ }
27413
+
27414
+ .tw-date-lookup-calendar > tbody > tr > td {
27415
+ border: none;
27416
+ padding: 4px;
27417
+ padding: var(--size-4);
27418
+ }
27419
+
27420
+ @media (max-width: 320px) {
27421
+ .tw-date-lookup-calendar > tbody > tr > td {
27422
+ padding: 0;
27423
+ }
27424
+ }
27425
+
27426
+ .tw-date-lookup-calendar > tbody > tr > td:has(.wds-Calendar__option--day) {
27427
+ padding: 1px;
27428
+ }
27429
+
27430
+ .tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.show-focus:not(.disabled):not([aria-disabled="true"]),
27431
+ .tw-date-lookup-calendar > tbody > tr > td:hover button:not(.disabled):not(:disabled):not([aria-disabled="true"]) {
27352
27432
  background-color: var(--color-background-screen-hover);
27353
27433
  }
27354
27434
 
27355
- .tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.active {
27435
+ .tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.active:not([aria-disabled="true"]) {
27356
27436
  background-color: var(--color-interactive-primary);
27357
27437
  color: var(--color-interactive-contrast);
27358
27438
  }
@@ -1,61 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var clsx = require('clsx');
6
- var React = require('react');
7
- var reactIntl = require('react-intl');
8
- var Calendar_messages = require('../Calendar.messages.js');
9
- var jsxRuntime = require('react/jsx-runtime');
10
-
11
- const TableLink = ({
12
- item,
13
- type,
14
- title,
15
- longTitle,
16
- active,
17
- disabled,
18
- today,
19
- autofocus,
20
- onClick
21
- }) => {
22
- const buttonRef = React.useRef(null);
23
- const intl = reactIntl.useIntl();
24
- React.useEffect(() => {
25
- if (autofocus) {
26
- setTimeout(() => {
27
- buttonRef.current?.focus();
28
- }, 0);
29
- }
30
- }, [autofocus]);
31
- const onCalendarClick = event => {
32
- event.preventDefault();
33
- if (!disabled) {
34
- onClick(item);
35
- }
36
- };
37
- const calculateAriaLabel = () => {
38
- if (active) {
39
- return `${longTitle || title || ''}, ${intl.formatMessage(Calendar_messages.default.selected)} ${intl.formatMessage(Calendar_messages.default[type])}`;
40
- }
41
- return longTitle || title;
42
- };
43
- return /*#__PURE__*/jsxRuntime.jsx("button", {
44
- ref: buttonRef,
45
- type: "button",
46
- className: clsx.clsx(`tw-date-lookup-${type}-option np-text-body-default-bold`, {
47
- active: !!active
48
- }, {
49
- today: !!today
50
- }),
51
- disabled: disabled,
52
- tabIndex: autofocus ? 0 : -1,
53
- "aria-label": calculateAriaLabel(),
54
- "aria-pressed": active,
55
- onClick: onCalendarClick,
56
- children: title || item
57
- });
58
- };
59
-
60
- exports.default = TableLink;
61
- //# sourceMappingURL=TableLink.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableLink.js","sources":["../../../src/Calendar/tableLink/TableLink.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport messages from '../Calendar.messages';\n\ninterface TableLinkProps {\n item: number;\n type: 'day' | 'month' | 'year';\n title?: string;\n longTitle?: string;\n active: boolean;\n disabled: boolean;\n today: boolean;\n autofocus?: boolean;\n onClick: (item: number) => void;\n}\n\nconst TableLink = ({\n item,\n type,\n title,\n longTitle,\n active,\n disabled,\n today,\n autofocus,\n onClick,\n}: TableLinkProps) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const intl = useIntl();\n\n useEffect(() => {\n if (autofocus) {\n setTimeout(() => {\n buttonRef.current?.focus();\n }, 0);\n }\n }, [autofocus]);\n\n const onCalendarClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n if (!disabled) {\n onClick(item);\n }\n };\n\n const calculateAriaLabel = () => {\n if (active) {\n return `${longTitle || title || ''}, ${intl.formatMessage(\n messages.selected,\n )} ${intl.formatMessage(messages[type])}`;\n }\n return longTitle || title;\n };\n\n return (\n <button\n ref={buttonRef}\n type=\"button\"\n className={clsx(\n `tw-date-lookup-${type}-option np-text-body-default-bold`,\n { active: !!active },\n { today: !!today },\n )}\n disabled={disabled}\n tabIndex={autofocus ? 0 : -1}\n aria-label={calculateAriaLabel()}\n aria-pressed={active}\n onClick={onCalendarClick}\n >\n {title || item}\n </button>\n );\n};\n\nexport default TableLink;\n"],"names":["TableLink","item","type","title","longTitle","active","disabled","today","autofocus","onClick","buttonRef","useRef","intl","useIntl","useEffect","setTimeout","current","focus","onCalendarClick","event","preventDefault","calculateAriaLabel","formatMessage","messages","selected","_jsx","ref","className","clsx","tabIndex","children"],"mappings":";;;;;;;;;;AAkBA,MAAMA,SAAS,GAAGA,CAAC;EACjBC,IAAI;EACJC,IAAI;EACJC,KAAK;EACLC,SAAS;EACTC,MAAM;EACNC,QAAQ;EACRC,KAAK;EACLC,SAAS;AACTC,EAAAA;AAAO,CACQ,KAAI;AACnB,EAAA,MAAMC,SAAS,GAAGC,YAAM,CAAoB,IAAI,CAAC;AACjD,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE;AAEtBC,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,IAAIN,SAAS,EAAE;AACbO,MAAAA,UAAU,CAAC,MAAK;AACdL,QAAAA,SAAS,CAACM,OAAO,EAAEC,KAAK,EAAE;MAC5B,CAAC,EAAE,CAAC,CAAC;AACP,IAAA;AACF,EAAA,CAAC,EAAE,CAACT,SAAS,CAAC,CAAC;EAEf,MAAMU,eAAe,GAAIC,KAA0C,IAAI;IACrEA,KAAK,CAACC,cAAc,EAAE;IACtB,IAAI,CAACd,QAAQ,EAAE;MACbG,OAAO,CAACR,IAAI,CAAC;AACf,IAAA;EACF,CAAC;EAED,MAAMoB,kBAAkB,GAAGA,MAAK;AAC9B,IAAA,IAAIhB,MAAM,EAAE;MACV,OAAO,CAAA,EAAGD,SAAS,IAAID,KAAK,IAAI,EAAE,CAAA,EAAA,EAAKS,IAAI,CAACU,aAAa,CACvDC,yBAAQ,CAACC,QAAQ,CAClB,CAAA,CAAA,EAAIZ,IAAI,CAACU,aAAa,CAACC,yBAAQ,CAACrB,IAAI,CAAC,CAAC,CAAA,CAAE;AAC3C,IAAA;IACA,OAAOE,SAAS,IAAID,KAAK;EAC3B,CAAC;AAED,EAAA,oBACEsB,cAAA,CAAA,QAAA,EAAA;AACEC,IAAAA,GAAG,EAAEhB,SAAU;AACfR,IAAAA,IAAI,EAAC,QAAQ;AACbyB,IAAAA,SAAS,EAAEC,SAAI,CACb,CAAA,eAAA,EAAkB1B,IAAI,mCAAmC,EACzD;MAAEG,MAAM,EAAE,CAAC,CAACA;AAAM,KAAE,EACpB;MAAEE,KAAK,EAAE,CAAC,CAACA;KAAO,CAClB;AACFD,IAAAA,QAAQ,EAAEA,QAAS;AACnBuB,IAAAA,QAAQ,EAAErB,SAAS,GAAG,CAAC,GAAG,EAAG;IAC7B,YAAA,EAAYa,kBAAkB,EAAG;AACjC,IAAA,cAAA,EAAchB,MAAO;AACrBI,IAAAA,OAAO,EAAES,eAAgB;IAAAY,QAAA,EAExB3B,KAAK,IAAIF;AAAI,GACR,CAAC;AAEb;;;;"}
@@ -1,57 +0,0 @@
1
- import { clsx } from 'clsx';
2
- import { useRef, useEffect } from 'react';
3
- import { useIntl } from 'react-intl';
4
- import messages from '../Calendar.messages.mjs';
5
- import { jsx } from 'react/jsx-runtime';
6
-
7
- const TableLink = ({
8
- item,
9
- type,
10
- title,
11
- longTitle,
12
- active,
13
- disabled,
14
- today,
15
- autofocus,
16
- onClick
17
- }) => {
18
- const buttonRef = useRef(null);
19
- const intl = useIntl();
20
- useEffect(() => {
21
- if (autofocus) {
22
- setTimeout(() => {
23
- buttonRef.current?.focus();
24
- }, 0);
25
- }
26
- }, [autofocus]);
27
- const onCalendarClick = event => {
28
- event.preventDefault();
29
- if (!disabled) {
30
- onClick(item);
31
- }
32
- };
33
- const calculateAriaLabel = () => {
34
- if (active) {
35
- return `${longTitle || title || ''}, ${intl.formatMessage(messages.selected)} ${intl.formatMessage(messages[type])}`;
36
- }
37
- return longTitle || title;
38
- };
39
- return /*#__PURE__*/jsx("button", {
40
- ref: buttonRef,
41
- type: "button",
42
- className: clsx(`tw-date-lookup-${type}-option np-text-body-default-bold`, {
43
- active: !!active
44
- }, {
45
- today: !!today
46
- }),
47
- disabled: disabled,
48
- tabIndex: autofocus ? 0 : -1,
49
- "aria-label": calculateAriaLabel(),
50
- "aria-pressed": active,
51
- onClick: onCalendarClick,
52
- children: title || item
53
- });
54
- };
55
-
56
- export { TableLink as default };
57
- //# sourceMappingURL=TableLink.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableLink.mjs","sources":["../../../src/Calendar/tableLink/TableLink.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport messages from '../Calendar.messages';\n\ninterface TableLinkProps {\n item: number;\n type: 'day' | 'month' | 'year';\n title?: string;\n longTitle?: string;\n active: boolean;\n disabled: boolean;\n today: boolean;\n autofocus?: boolean;\n onClick: (item: number) => void;\n}\n\nconst TableLink = ({\n item,\n type,\n title,\n longTitle,\n active,\n disabled,\n today,\n autofocus,\n onClick,\n}: TableLinkProps) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const intl = useIntl();\n\n useEffect(() => {\n if (autofocus) {\n setTimeout(() => {\n buttonRef.current?.focus();\n }, 0);\n }\n }, [autofocus]);\n\n const onCalendarClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n if (!disabled) {\n onClick(item);\n }\n };\n\n const calculateAriaLabel = () => {\n if (active) {\n return `${longTitle || title || ''}, ${intl.formatMessage(\n messages.selected,\n )} ${intl.formatMessage(messages[type])}`;\n }\n return longTitle || title;\n };\n\n return (\n <button\n ref={buttonRef}\n type=\"button\"\n className={clsx(\n `tw-date-lookup-${type}-option np-text-body-default-bold`,\n { active: !!active },\n { today: !!today },\n )}\n disabled={disabled}\n tabIndex={autofocus ? 0 : -1}\n aria-label={calculateAriaLabel()}\n aria-pressed={active}\n onClick={onCalendarClick}\n >\n {title || item}\n </button>\n );\n};\n\nexport default TableLink;\n"],"names":["TableLink","item","type","title","longTitle","active","disabled","today","autofocus","onClick","buttonRef","useRef","intl","useIntl","useEffect","setTimeout","current","focus","onCalendarClick","event","preventDefault","calculateAriaLabel","formatMessage","messages","selected","_jsx","ref","className","clsx","tabIndex","children"],"mappings":";;;;;;AAkBA,MAAMA,SAAS,GAAGA,CAAC;EACjBC,IAAI;EACJC,IAAI;EACJC,KAAK;EACLC,SAAS;EACTC,MAAM;EACNC,QAAQ;EACRC,KAAK;EACLC,SAAS;AACTC,EAAAA;AAAO,CACQ,KAAI;AACnB,EAAA,MAAMC,SAAS,GAAGC,MAAM,CAAoB,IAAI,CAAC;AACjD,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE;AAEtBC,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,IAAIN,SAAS,EAAE;AACbO,MAAAA,UAAU,CAAC,MAAK;AACdL,QAAAA,SAAS,CAACM,OAAO,EAAEC,KAAK,EAAE;MAC5B,CAAC,EAAE,CAAC,CAAC;AACP,IAAA;AACF,EAAA,CAAC,EAAE,CAACT,SAAS,CAAC,CAAC;EAEf,MAAMU,eAAe,GAAIC,KAA0C,IAAI;IACrEA,KAAK,CAACC,cAAc,EAAE;IACtB,IAAI,CAACd,QAAQ,EAAE;MACbG,OAAO,CAACR,IAAI,CAAC;AACf,IAAA;EACF,CAAC;EAED,MAAMoB,kBAAkB,GAAGA,MAAK;AAC9B,IAAA,IAAIhB,MAAM,EAAE;MACV,OAAO,CAAA,EAAGD,SAAS,IAAID,KAAK,IAAI,EAAE,CAAA,EAAA,EAAKS,IAAI,CAACU,aAAa,CACvDC,QAAQ,CAACC,QAAQ,CAClB,CAAA,CAAA,EAAIZ,IAAI,CAACU,aAAa,CAACC,QAAQ,CAACrB,IAAI,CAAC,CAAC,CAAA,CAAE;AAC3C,IAAA;IACA,OAAOE,SAAS,IAAID,KAAK;EAC3B,CAAC;AAED,EAAA,oBACEsB,GAAA,CAAA,QAAA,EAAA;AACEC,IAAAA,GAAG,EAAEhB,SAAU;AACfR,IAAAA,IAAI,EAAC,QAAQ;AACbyB,IAAAA,SAAS,EAAEC,IAAI,CACb,CAAA,eAAA,EAAkB1B,IAAI,mCAAmC,EACzD;MAAEG,MAAM,EAAE,CAAC,CAACA;AAAM,KAAE,EACpB;MAAEE,KAAK,EAAE,CAAC,CAACA;KAAO,CAClB;AACFD,IAAAA,QAAQ,EAAEA,QAAS;AACnBuB,IAAAA,QAAQ,EAAErB,SAAS,GAAG,CAAC,GAAG,EAAG;IAC7B,YAAA,EAAYa,kBAAkB,EAAG;AACjC,IAAA,cAAA,EAAchB,MAAO;AACrBI,IAAAA,OAAO,EAAES,eAAgB;IAAAY,QAAA,EAExB3B,KAAK,IAAIF;AAAI,GACR,CAAC;AAEb;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableLink.d.ts","sourceRoot":"","sources":["../../../../src/Calendar/tableLink/TableLink.tsx"],"names":[],"mappings":"AAMA,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,QAAA,MAAM,SAAS,GAAI,gFAUhB,cAAc,gCA8ChB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Calendar/tableLink/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
@@ -1,77 +0,0 @@
1
- import { clsx } from 'clsx';
2
- import { useEffect, useRef } from 'react';
3
- import { useIntl } from 'react-intl';
4
-
5
- import messages from '../Calendar.messages';
6
-
7
- interface TableLinkProps {
8
- item: number;
9
- type: 'day' | 'month' | 'year';
10
- title?: string;
11
- longTitle?: string;
12
- active: boolean;
13
- disabled: boolean;
14
- today: boolean;
15
- autofocus?: boolean;
16
- onClick: (item: number) => void;
17
- }
18
-
19
- const TableLink = ({
20
- item,
21
- type,
22
- title,
23
- longTitle,
24
- active,
25
- disabled,
26
- today,
27
- autofocus,
28
- onClick,
29
- }: TableLinkProps) => {
30
- const buttonRef = useRef<HTMLButtonElement>(null);
31
- const intl = useIntl();
32
-
33
- useEffect(() => {
34
- if (autofocus) {
35
- setTimeout(() => {
36
- buttonRef.current?.focus();
37
- }, 0);
38
- }
39
- }, [autofocus]);
40
-
41
- const onCalendarClick = (event: React.MouseEvent<HTMLButtonElement>) => {
42
- event.preventDefault();
43
- if (!disabled) {
44
- onClick(item);
45
- }
46
- };
47
-
48
- const calculateAriaLabel = () => {
49
- if (active) {
50
- return `${longTitle || title || ''}, ${intl.formatMessage(
51
- messages.selected,
52
- )} ${intl.formatMessage(messages[type])}`;
53
- }
54
- return longTitle || title;
55
- };
56
-
57
- return (
58
- <button
59
- ref={buttonRef}
60
- type="button"
61
- className={clsx(
62
- `tw-date-lookup-${type}-option np-text-body-default-bold`,
63
- { active: !!active },
64
- { today: !!today },
65
- )}
66
- disabled={disabled}
67
- tabIndex={autofocus ? 0 : -1}
68
- aria-label={calculateAriaLabel()}
69
- aria-pressed={active}
70
- onClick={onCalendarClick}
71
- >
72
- {title || item}
73
- </button>
74
- );
75
- };
76
-
77
- export default TableLink;
File without changes