@telus-uds/components-web 1.2.0 → 1.4.0

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 (140) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/lib/Breadcrumbs/Breadcrumbs.js +247 -0
  3. package/lib/Breadcrumbs/Item/Item.js +165 -0
  4. package/lib/Breadcrumbs/index.js +15 -0
  5. package/lib/Callout/Callout.js +121 -0
  6. package/lib/Callout/index.js +13 -0
  7. package/lib/DatePicker/CalendarContainer.js +221 -0
  8. package/lib/DatePicker/DatePicker.js +329 -0
  9. package/lib/DatePicker/dictionary.js +134 -0
  10. package/lib/DatePicker/index.js +13 -0
  11. package/lib/DatePicker/reactDatesCss.js +12 -0
  12. package/lib/ExpandCollapseMini/ExpandCollapseMini.js +75 -0
  13. package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +95 -0
  14. package/lib/ExpandCollapseMini/index.js +13 -0
  15. package/lib/Footnote/Footnote.js +571 -0
  16. package/lib/Footnote/FootnoteLink.js +149 -0
  17. package/lib/Footnote/dictionary.js +19 -0
  18. package/lib/Footnote/index.js +16 -0
  19. package/lib/OrderedList/Item.js +162 -0
  20. package/lib/OrderedList/ItemBase.js +42 -0
  21. package/lib/OrderedList/OrderedList.js +94 -0
  22. package/lib/OrderedList/OrderedListBase.js +68 -0
  23. package/lib/OrderedList/constants.js +9 -0
  24. package/lib/OrderedList/index.js +16 -0
  25. package/lib/PreviewCard/AuthorDate.js +64 -0
  26. package/lib/PreviewCard/PreviewCard.js +236 -0
  27. package/lib/PreviewCard/index.js +13 -0
  28. package/lib/PriceLockup/PriceLockup.js +237 -0
  29. package/lib/PriceLockup/index.js +13 -0
  30. package/lib/PriceLockup/tokens.js +131 -0
  31. package/lib/ResponsiveImage/ResponsiveImage.js +115 -0
  32. package/lib/ResponsiveImage/index.js +13 -0
  33. package/lib/Ribbon/Ribbon.js +0 -1
  34. package/lib/Span/Span.js +88 -0
  35. package/lib/Span/index.js +13 -0
  36. package/lib/index.js +91 -1
  37. package/lib/shared/FullBleedContent/FullBleedContent.js +121 -0
  38. package/lib/shared/FullBleedContent/getFullBleedBorderRadius.js +73 -0
  39. package/lib/shared/FullBleedContent/index.js +29 -0
  40. package/lib/shared/FullBleedContent/useFullBleedContentProps.js +73 -0
  41. package/lib/utils/index.js +32 -0
  42. package/lib/utils/logger.js +31 -0
  43. package/lib/utils/media.js +54 -0
  44. package/lib/utils/renderStructuredContent.js +89 -0
  45. package/lib/utils/useTypographyTheme.js +32 -0
  46. package/lib-module/Breadcrumbs/Breadcrumbs.js +228 -0
  47. package/lib-module/Breadcrumbs/Item/Item.js +141 -0
  48. package/lib-module/Breadcrumbs/index.js +1 -0
  49. package/lib-module/Callout/Callout.js +106 -0
  50. package/lib-module/Callout/index.js +2 -0
  51. package/lib-module/DatePicker/CalendarContainer.js +208 -0
  52. package/lib-module/DatePicker/DatePicker.js +302 -0
  53. package/lib-module/DatePicker/dictionary.js +127 -0
  54. package/lib-module/DatePicker/index.js +2 -0
  55. package/lib-module/DatePicker/reactDatesCss.js +3 -0
  56. package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +56 -0
  57. package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +80 -0
  58. package/lib-module/ExpandCollapseMini/index.js +2 -0
  59. package/lib-module/Footnote/Footnote.js +541 -0
  60. package/lib-module/Footnote/FootnoteLink.js +130 -0
  61. package/lib-module/Footnote/dictionary.js +12 -0
  62. package/lib-module/Footnote/index.js +4 -0
  63. package/lib-module/OrderedList/Item.js +139 -0
  64. package/lib-module/OrderedList/ItemBase.js +28 -0
  65. package/lib-module/OrderedList/OrderedList.js +71 -0
  66. package/lib-module/OrderedList/OrderedListBase.js +48 -0
  67. package/lib-module/OrderedList/constants.js +2 -0
  68. package/lib-module/OrderedList/index.js +4 -0
  69. package/lib-module/PreviewCard/AuthorDate.js +53 -0
  70. package/lib-module/PreviewCard/PreviewCard.js +211 -0
  71. package/lib-module/PreviewCard/index.js +2 -0
  72. package/lib-module/PriceLockup/PriceLockup.js +213 -0
  73. package/lib-module/PriceLockup/index.js +2 -0
  74. package/lib-module/PriceLockup/tokens.js +120 -0
  75. package/lib-module/ResponsiveImage/ResponsiveImage.js +100 -0
  76. package/lib-module/ResponsiveImage/index.js +2 -0
  77. package/lib-module/Ribbon/Ribbon.js +1 -2
  78. package/lib-module/Span/Span.js +70 -0
  79. package/lib-module/Span/index.js +2 -0
  80. package/lib-module/index.js +10 -0
  81. package/lib-module/shared/FullBleedContent/FullBleedContent.js +106 -0
  82. package/lib-module/shared/FullBleedContent/getFullBleedBorderRadius.js +65 -0
  83. package/lib-module/shared/FullBleedContent/index.js +4 -0
  84. package/lib-module/shared/FullBleedContent/useFullBleedContentProps.js +65 -0
  85. package/lib-module/utils/index.js +5 -1
  86. package/lib-module/utils/logger.js +18 -0
  87. package/lib-module/utils/media.js +46 -0
  88. package/lib-module/utils/renderStructuredContent.js +77 -0
  89. package/lib-module/utils/useTypographyTheme.js +24 -0
  90. package/package.json +9 -4
  91. package/src/Breadcrumbs/Breadcrumbs.jsx +222 -0
  92. package/src/Breadcrumbs/Item/Item.jsx +127 -0
  93. package/src/Breadcrumbs/index.js +1 -0
  94. package/src/Callout/Callout.jsx +76 -0
  95. package/src/Callout/index.js +3 -0
  96. package/src/DatePicker/CalendarContainer.jsx +210 -0
  97. package/src/DatePicker/DatePicker.jsx +303 -0
  98. package/src/DatePicker/dictionary.js +92 -0
  99. package/src/DatePicker/index.js +3 -0
  100. package/src/DatePicker/reactDatesCss.js +892 -0
  101. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +48 -0
  102. package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +67 -0
  103. package/src/ExpandCollapseMini/index.js +3 -0
  104. package/src/Footnote/Footnote.jsx +468 -0
  105. package/src/Footnote/FootnoteLink.jsx +120 -0
  106. package/src/Footnote/dictionary.js +12 -0
  107. package/src/Footnote/index.js +6 -0
  108. package/src/OrderedList/Item.jsx +121 -0
  109. package/src/OrderedList/ItemBase.jsx +18 -0
  110. package/src/OrderedList/OrderedList.jsx +61 -0
  111. package/src/OrderedList/OrderedListBase.jsx +38 -0
  112. package/src/OrderedList/constants.js +2 -0
  113. package/src/OrderedList/index.js +6 -0
  114. package/src/PreviewCard/AuthorDate.jsx +31 -0
  115. package/src/PreviewCard/PreviewCard.jsx +201 -0
  116. package/src/PreviewCard/index.js +3 -0
  117. package/src/PriceLockup/PriceLockup.jsx +210 -0
  118. package/src/PriceLockup/index.js +3 -0
  119. package/src/PriceLockup/tokens.js +58 -0
  120. package/src/ResponsiveImage/ResponsiveImage.jsx +77 -0
  121. package/src/ResponsiveImage/index.js +3 -0
  122. package/src/Ribbon/Ribbon.jsx +0 -1
  123. package/src/Span/Span.jsx +66 -0
  124. package/src/Span/index.js +3 -0
  125. package/src/index.js +10 -0
  126. package/src/shared/FullBleedContent/FullBleedContent.jsx +90 -0
  127. package/src/shared/FullBleedContent/getFullBleedBorderRadius.js +55 -0
  128. package/src/shared/FullBleedContent/index.js +6 -0
  129. package/src/shared/FullBleedContent/useFullBleedContentProps.js +63 -0
  130. package/src/utils/index.js +5 -1
  131. package/src/utils/logger.js +20 -0
  132. package/src/utils/media.js +40 -0
  133. package/src/utils/renderStructuredContent.jsx +73 -0
  134. package/src/utils/useTypographyTheme.js +14 -0
  135. package/types/Callout.d.ts +13 -0
  136. package/types/DatePicker.d.ts +21 -0
  137. package/types/Footnote.d.ts +21 -0
  138. package/types/FootnoteLink.d.ts +20 -0
  139. package/types/PriceLockup.d.ts +22 -0
  140. package/types/common.d.ts +14 -0
@@ -0,0 +1,106 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import { Icon, selectSystemProps, Typography, useThemeTokens } from '@telus-uds/components-base';
5
+ import { htmlAttrs } from '../utils';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
9
+
10
+ const verticalAlignToFlex = verticalAlign => {
11
+ switch (verticalAlign) {
12
+ case 'top':
13
+ return 'flex-start';
14
+
15
+ case 'middle':
16
+ return 'center';
17
+
18
+ case 'bottom':
19
+ return 'flex-end';
20
+
21
+ default:
22
+ return 'top';
23
+ }
24
+ };
25
+
26
+ const CalloutContainer = /*#__PURE__*/styled.div.withConfig({
27
+ displayName: "Callout__CalloutContainer",
28
+ componentId: "components-web__sc-1a7ptx-0"
29
+ })(_ref => {
30
+ let {
31
+ rounded,
32
+ verticalAlign = 'top',
33
+ background,
34
+ gap,
35
+ borderRadius,
36
+ padding
37
+ } = _ref;
38
+ return {
39
+ background,
40
+ display: 'flex',
41
+ gap,
42
+ borderRadius,
43
+ padding,
44
+ justifyContent: `${rounded ? 'center' : 'flex-start'}`,
45
+ alignItems: verticalAlignToFlex(verticalAlign)
46
+ };
47
+ });
48
+
49
+ const Callout = _ref2 => {
50
+ let {
51
+ icon,
52
+ children,
53
+ verticalAlign = 'top',
54
+ tokens,
55
+ variant = {},
56
+ ...rest
57
+ } = _ref2;
58
+ const {
59
+ background,
60
+ gap,
61
+ borderRadius,
62
+ paddingLeft,
63
+ paddingRight,
64
+ paddingTop,
65
+ paddingBottom,
66
+ color
67
+ } = useThemeTokens('Callout', tokens, variant);
68
+ const {
69
+ rounded = false,
70
+ size = 'medium'
71
+ } = variant;
72
+ return /*#__PURE__*/_jsxs(CalloutContainer, {
73
+ size: size,
74
+ rounded: rounded,
75
+ "data-testid": "callout-container",
76
+ verticalAlign: verticalAlign,
77
+ background: background,
78
+ gap: gap,
79
+ borderRadius: borderRadius,
80
+ padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
81
+ ...selectProps(rest),
82
+ children: [icon && /*#__PURE__*/_jsx(Icon, {
83
+ icon: icon,
84
+ variant: {
85
+ rank: 'primary',
86
+ size
87
+ }
88
+ }), /*#__PURE__*/_jsx(Typography, {
89
+ variant: {
90
+ size,
91
+ compact: size === 'small'
92
+ },
93
+ tokens: {
94
+ color
95
+ },
96
+ children: children
97
+ })]
98
+ });
99
+ };
100
+
101
+ Callout.propTypes = { ...selectedSystemPropTypes,
102
+ icon: PropTypes.elementType,
103
+ children: PropTypes.node.isRequired,
104
+ verticalAlign: PropTypes.oneOf(['top', 'middle', 'bottom'])
105
+ };
106
+ export default Callout;
@@ -0,0 +1,2 @@
1
+ import Callout from './Callout';
2
+ export default Callout;
@@ -0,0 +1,208 @@
1
+ import styled from 'styled-components';
2
+ import defaultReactDatesCss from './reactDatesCss';
3
+ const CalendarContainer = /*#__PURE__*/styled.div.withConfig({
4
+ displayName: "CalendarContainer",
5
+ componentId: "components-web__sc-qdc1tg-0"
6
+ })(_ref => {
7
+ let {
8
+ daySize,
9
+ validation,
10
+ remainingTokens,
11
+ calendarMonthFontTokens,
12
+ dayPickerNavigationButtonTokens,
13
+ defaultFontTokens
14
+ } = _ref;
15
+ return `
16
+ ${defaultReactDatesCss}
17
+ > div {
18
+ z-index: 3;
19
+ }
20
+ .SingleDatePicker,
21
+ .SingleDatePickerInput {
22
+ display: block;
23
+ }
24
+ .SingleDatePicker_picker {
25
+ box-shadow: none;
26
+ border: 1px solid ${remainingTokens.singleDatePickerBorderColor};
27
+ border-radius: ${remainingTokens.singleDatePickerRadius};
28
+ padding: ${remainingTokens.singleDatePickerPaddingTopBottom}px ${remainingTokens.singleDatePickerLeftRight}px;
29
+ z-index: 3;
30
+ }
31
+ .DateInput {
32
+ width: 100%;
33
+ border: 2px solid ${remainingTokens.dateInputBorderColor};
34
+ border-radius: ${remainingTokens.dateInputBorderRadius};
35
+ ${validation === 'error' && `input { border-color: ${remainingTokens.invalidInputMixin}; }`};
36
+ ${validation === 'success' && `input { border-color: ${remainingTokens.validInputMixin}; }`};
37
+ }
38
+ .DateInput:hover {
39
+ border: 2px solid ${remainingTokens.dateInputHoverBorderColor};
40
+ }
41
+ .DateInput:focus {
42
+ border: 2px solid ${remainingTokens.dateInputFocusBorderColor};
43
+ }
44
+ .SingleDatePickerInput__withBorder {
45
+ border: 0 !important;
46
+ }
47
+ .DateInput_input {
48
+ box-sizing: border-box;
49
+ padding: 1rem;
50
+ border: 1px solid ${remainingTokens.dateInputInsideBorderColor};
51
+ border-radius: 4px;
52
+ min-height: 3.25rem;
53
+ color: ${remainingTokens.dateInputInsideColor};
54
+ font-weight: 400;
55
+ font-size: 1rem;
56
+ box-shadow: 0 1px 8px rgba(0, 0, 0, 0.05);
57
+ }
58
+ .DateInput_fang {
59
+ transform: translateY(2px);
60
+ z-index: 4;
61
+ left: ${(daySize * 8.5 - 20) / 2}px;
62
+ }
63
+ .DateInput_fangStroke {
64
+ stroke: ${remainingTokens.dateInputStrokeColor};
65
+ }
66
+ .CalendarMonth_caption {
67
+ color: ${remainingTokens.calendarMonthCaptionColor};
68
+ font-family: ${calendarMonthFontTokens.fontFamily};
69
+ font-size: ${remainingTokens.calendarMonthCaptionFontSize};
70
+ font-weight: ${calendarMonthFontTokens.fontWeight};
71
+ line-height: ${remainingTokens.calendarMonthCaptionLineHeight};
72
+ padding-bottom: ${remainingTokens.calendarMonthCaptionPaddingBottom}px;
73
+ }
74
+ .DayPicker__withBorder {
75
+ box-shadow: none;
76
+ }
77
+ .DayPickerNavigation_button {
78
+ align-items: center;
79
+ display: flex;
80
+ justify-content: center;
81
+ border: 1px solid ${remainingTokens.dayPickerNavigationButtonBorderColor};
82
+ background-color: ${remainingTokens.dayPickerNavigationButtonBackgroundColor};
83
+ border-radius: 50%;
84
+ box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
85
+ max-height: ${remainingTokens.dayPickerNavigationButtonMaxHeight}px;
86
+ max-width: ${remainingTokens.dayPickerNavigationButtonMaxWidth}px;
87
+ position: absolute;
88
+ top: 18px;
89
+ line-height: 0.78;
90
+ padding: ${remainingTokens.dayPickerNavigationButtonPadding}px;
91
+ cursor: pointer;
92
+ user-select: none;
93
+ &:nth-child(1) {
94
+ left: ${remainingTokens.dayPickerNavigationButtonChildLeft}px;
95
+ }
96
+ &:nth-child(2) {
97
+ right: ${remainingTokens.dayPickerNavigationButtonChildRight}px;
98
+ i {
99
+ font-family: 'TELUS Core Icons';
100
+ display: inline-block;
101
+ font-weight: normal;
102
+ font-style: normal;
103
+ speak: none;
104
+ text-decoration: inherit;
105
+ text-transform: none;
106
+ text-rendering: auto;
107
+ -webkit-font-smoothing: antialiased;
108
+ -moz-osx-font-smoothing: grayscale;
109
+ line-height: 1;
110
+ vertical-align: middle;
111
+ &:before {
112
+ content: '\\F107';
113
+ display: inline-block;
114
+ }
115
+ }
116
+ }
117
+ & svg {
118
+ fill: ${remainingTokens.dayPickerNavigationButtonChildSvgFill};
119
+ }
120
+ }
121
+ .DayPickerNavigation_button__default:focus,
122
+ .DayPickerNavigation_button__default:hover {
123
+ border: 1px solid ${remainingTokens.dayPickerNavigationButtonDefaultHoverBorderColor};
124
+ }
125
+ .DayPickerNavigation_svg__horizontal {
126
+ fill: ${remainingTokens.dayPickerNavigationSVGHorizontalFill};
127
+ }
128
+ .DayPicker_weekHeader {
129
+ color: ${remainingTokens.dayPickerWeekHeaderColor};
130
+ font-family: ${dayPickerNavigationButtonTokens.fontFamily};
131
+ font-weight: ${dayPickerNavigationButtonTokens.fontWeight};
132
+ font-feature-settings: 'ss01' on, 'ss03' on, 'ss08' on;
133
+ line-height: ${remainingTokens.dayPickerWeekHeaderLineHeight};
134
+ & small {
135
+ font-size: ${remainingTokens.dayPickerWeekHeaderSmall};
136
+ }
137
+ & li {
138
+ max-width: ${daySize}px !important;
139
+ }
140
+ }
141
+ .CalendarDay__default {
142
+ padding: 0px;
143
+ position: relative;
144
+ background-clip: padding-box;
145
+ border: ${remainingTokens.calendarDayDefaultBorder} solid ${remainingTokens.calendarDayDefaultBorderColor};
146
+ vertical-align: middle;
147
+ font-family: ${defaultFontTokens.fontFamily};
148
+ font-weight: ${defaultFontTokens.fontWeight}
149
+ font-feature-settings: 'ss01' on, 'ss03' on, 'ss08' on;
150
+ font-size: ${remainingTokens.calendarDayDefaultFontSize};
151
+ line-height: ${daySize - 3}px !important;
152
+ color: ${remainingTokens.calendarDayDefaultColor};
153
+ text-decoration: none;
154
+ transition: all 0.3s;
155
+ &:before {
156
+ content: '';
157
+ position: absolute;
158
+ top: 50%;
159
+ left: 50%;
160
+ transform: translate(-50%, -50%);
161
+ height: ${remainingTokens.calendarDayDefaultBeforeHeight}px;
162
+ width: ${remainingTokens.calendarDayDefaultBeforeWidth}px;
163
+ border-radius: 50%;
164
+ background: transparent;
165
+ transition: all 0.3s;
166
+ z-index: -1;
167
+ }
168
+ }
169
+ .CalendarDay__default:hover,
170
+ .CalendarDay__selected,
171
+ .CalendarDay__selected:active,
172
+ .CalendarDay__selected:hover {
173
+ background: none;
174
+ border: 1px solid ${remainingTokens.calendarDaySelectedHoverBorderColor};
175
+ color: ${remainingTokens.calendarDaySelectedHoverColor};
176
+ text-decoration: none;
177
+ z-index: 0;
178
+ &:before {
179
+ background: ${remainingTokens.calendarDaySelectedHoverBeforeBackground};
180
+ }
181
+ }
182
+ .CalendarDay__default.CalendarDay__selected,
183
+ .CalendarDay__default.CalendarDay__selected:active
184
+ .CalendarDay__default.CalendarDay__selected:hover {
185
+ color: ${remainingTokens.calendarDayDefaultCalendarDaySelectedHoverColor};
186
+ text-decoration: none;
187
+ &:before {
188
+ background: ${remainingTokens.calendarDayDefaultCalendarDaySelectedHoverBackground};
189
+ }
190
+ }
191
+ .CalendarDay__blocked_out_of_range,
192
+ .CalendarDay__blocked_out_of_range:active,
193
+ .CalendarDay__blocked_out_of_range:hover,
194
+ .CalendarDay__blocked_calendar,
195
+ .CalendarDay__blocked_calendar:active,
196
+ .CalendarDay__blocked_calendar:hover {
197
+ font-weight: 300;
198
+ background: ${remainingTokens.calendarDayBlockedCalendarHoverBackground};
199
+ background-clip: padding-box;
200
+ color: ${remainingTokens.calendarDayBlockedCalendarHoverColor};
201
+ text-decoration: none;
202
+ &:before {
203
+ content: none;
204
+ }
205
+ }
206
+ `;
207
+ });
208
+ export default CalendarContainer;
@@ -0,0 +1,302 @@
1
+ import React, { forwardRef, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import momentPropTypes from 'react-moment-proptypes';
5
+ import 'react-dates/initialize';
6
+ import SingleDatePicker from 'react-dates/lib/components/SingleDatePicker';
7
+ import DayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';
8
+ import { Icon, InputSupports, selectSystemProps, useCopy, useViewport, useThemeTokens, applyTextStyles } from '@telus-uds/components-base';
9
+ import CalendarContainer from './CalendarContainer';
10
+ import dictionary from './dictionary';
11
+ import { htmlAttrs } from '../utils';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Fragment as _Fragment } from "react/jsx-runtime";
15
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
16
+
17
+ const getResponsiveDaySize = function () {
18
+ let inline = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
19
+ let viewport = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'md';
20
+ let responsiveDaySize;
21
+
22
+ if (viewport === 'xs') {
23
+ responsiveDaySize = inline ? undefined : 36;
24
+ } else {
25
+ responsiveDaySize = inline ? 60 : 44;
26
+ }
27
+
28
+ return responsiveDaySize;
29
+ };
30
+
31
+ const getIcon = icon => /*#__PURE__*/_jsx(Icon, {
32
+ icon: icon,
33
+ variant: {
34
+ size: 'small'
35
+ }
36
+ });
37
+
38
+ const MonthCenterContainer = /*#__PURE__*/styled.div.withConfig({
39
+ displayName: "DatePicker__MonthCenterContainer",
40
+ componentId: "components-web__sc-mz8fi3-0"
41
+ })({
42
+ display: 'flex',
43
+ justifyContent: 'center'
44
+ });
45
+ /**
46
+ * Use DatePicker to select a date on a calendar.
47
+ *
48
+ * ## Usage Criteria
49
+ *
50
+ * - Use DatePicker to select a date on a calendar
51
+ * - Available in 2 formats: Overlay and Inline
52
+ *
53
+ * ### Overlay DatePicker
54
+ * - Use Overlay to display in a modal container
55
+ * - Use Overlay whenever possible as it is the most accessible solution; the input form field is type-accessible and optimized for mobile customers
56
+ * - Includes an input form field to allow manual key-in of dates
57
+ * - Opens the modal when the input form field receives focus
58
+ * - Width expands 100% until max-width of 340px
59
+ *
60
+ * ### Inline DatePicker
61
+ * - Use Inline to display the DatePicker in a larger vieweable area; allows the customer to quickly and easily date availability
62
+ * - Does not include an input form field
63
+ * - Optimized for keyboard interaction and tablet touch
64
+ * - Recommended for viewports greater than or equal to 576px
65
+ */
66
+
67
+ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
68
+ var _dictionary$copy;
69
+
70
+ let {
71
+ copy = 'en',
72
+ id,
73
+ date,
74
+ feedback,
75
+ inline,
76
+ isDayDisabled,
77
+ label,
78
+ onDateChange,
79
+ hint,
80
+ hintPosition = 'inline',
81
+ tooltip,
82
+ tokens,
83
+ variant = {},
84
+ validation,
85
+ ...rest
86
+ } = _ref;
87
+ const [inputDate, setInputDate] = useState(date);
88
+ const [isFocused, setIsFocused] = useState(false);
89
+ const getCopy = useCopy({
90
+ dictionary,
91
+ copy
92
+ });
93
+
94
+ const onFocusChange = _ref2 => {
95
+ let {
96
+ focused
97
+ } = _ref2;
98
+ setIsFocused(focused);
99
+ };
100
+
101
+ const onChange = value => {
102
+ setInputDate(value);
103
+ if (onDateChange) onDateChange(value);
104
+ };
105
+
106
+ const viewport = useViewport();
107
+ const daySize = getResponsiveDaySize(inline, viewport);
108
+ const value = date ?? inputDate;
109
+ const HiddenInputFieldContainer = /*#__PURE__*/styled.div.withConfig({
110
+ displayName: "DatePicker__HiddenInputFieldContainer",
111
+ componentId: "components-web__sc-mz8fi3-1"
112
+ })(["height:", ";width:", ";overflow:hidden;"], props => props.height, props => props.width);
113
+ const {
114
+ hiddenInputFieldContainerHeight,
115
+ hiddenInputFieldContainerWidth,
116
+ previousIcon,
117
+ nextIcon,
118
+ ...remainingTokens
119
+ } = useThemeTokens('DatePicker', tokens, variant, {
120
+ viewport
121
+ });
122
+ const defaultFontTokens = applyTextStyles({
123
+ fontName: remainingTokens.calendarDayDefaultFontName,
124
+ fontWeight: remainingTokens.calendarDayDefaultFontWeight
125
+ });
126
+ const calendarMonthFontTokens = applyTextStyles({
127
+ fontName: remainingTokens.calendarMonthCaptionFontName,
128
+ fontWeight: remainingTokens.calendarMonthCaptionFontWeight
129
+ });
130
+ const dayPickerNavigationButtonTokens = applyTextStyles({
131
+ fontName: remainingTokens.dayPickerWeekHeaderFontName,
132
+ fontWeight: remainingTokens.dayPickerWeekHeaderFontWeight
133
+ });
134
+ return /*#__PURE__*/_jsx(CalendarContainer, { ...selectProps(rest),
135
+ daySize: daySize,
136
+ validation: validation,
137
+ remainingTokens: remainingTokens,
138
+ calendarMonthFontTokens: calendarMonthFontTokens,
139
+ dayPickerNavigationButtonTokens: dayPickerNavigationButtonTokens,
140
+ defaultFontTokens: defaultFontTokens,
141
+ children: /*#__PURE__*/_jsx(InputSupports, {
142
+ copy: copy,
143
+ feedback: feedback,
144
+ hint: hint,
145
+ hintPosition: hintPosition,
146
+ label: ((_dictionary$copy = dictionary[copy]) === null || _dictionary$copy === void 0 ? void 0 : _dictionary$copy.roleDescription) ?? label,
147
+ nativeID: id,
148
+ tooltip: tooltip,
149
+ validation: validation,
150
+ children: inline ? /*#__PURE__*/_jsxs(_Fragment, {
151
+ children: [/*#__PURE__*/_jsx(HiddenInputFieldContainer, {
152
+ height: hiddenInputFieldContainerHeight,
153
+ width: hiddenInputFieldContainerWidth,
154
+ children: /*#__PURE__*/_jsx("input", {
155
+ ref: ref,
156
+ id: id,
157
+ type: "text",
158
+ value: (value === null || value === void 0 ? void 0 : value.format('YYYY-MM-DD')) ?? '',
159
+ readOnly: true
160
+ })
161
+ }), /*#__PURE__*/_jsx(DayPickerSingleDateController, {
162
+ date: value,
163
+ onDateChange: onChange,
164
+ focused: isFocused,
165
+ onFocusChange: onFocusChange,
166
+ numberOfMonths: 1,
167
+ hideKeyboardShortcutsPanel: true,
168
+ keepOpenOnDateSelect: false,
169
+ daySize: daySize,
170
+ navPrev: getIcon(previousIcon),
171
+ navNext: getIcon(nextIcon),
172
+ isOutsideRange: isDayDisabled,
173
+ phrases: getCopy(),
174
+ renderMonthElement: _ref3 => {
175
+ let {
176
+ month
177
+ } = _ref3;
178
+ return /*#__PURE__*/_jsx(MonthCenterContainer, {
179
+ children: /*#__PURE__*/_jsxs("div", {
180
+ children: [dictionary[copy] ? dictionary[copy].months[month.month()] : month.format('MMMM'), ' ', month.year()]
181
+ })
182
+ });
183
+ },
184
+ renderWeekHeaderElement: day => /*#__PURE__*/_jsx("div", {
185
+ children: dictionary[copy] ? dictionary[copy].weekDays[day] : day
186
+ })
187
+ })]
188
+ }) : /*#__PURE__*/_jsx(SingleDatePicker, {
189
+ ref: ref,
190
+ id: id,
191
+ date: value,
192
+ onDateChange: onChange,
193
+ focused: isFocused,
194
+ onFocusChange: onFocusChange,
195
+ numberOfMonths: 1,
196
+ hideKeyboardShortcutsPanel: true,
197
+ displayFormat: "DD / MM / YYYY",
198
+ placeholder: "DD / MM / YYYY",
199
+ keepOpenOnDateSelect: false,
200
+ daySize: daySize,
201
+ navPrev: getIcon(previousIcon),
202
+ navNext: getIcon(nextIcon),
203
+ isOutsideRange: isDayDisabled,
204
+ phrases: getCopy(),
205
+ renderMonthElement: _ref4 => {
206
+ let {
207
+ month
208
+ } = _ref4;
209
+ return /*#__PURE__*/_jsx(MonthCenterContainer, {
210
+ children: /*#__PURE__*/_jsxs("div", {
211
+ children: [dictionary[copy] ? dictionary[copy].months[month.month()] : month.format('MMMM'), ' ', month.year()]
212
+ })
213
+ });
214
+ },
215
+ renderWeekHeaderElement: day => /*#__PURE__*/_jsx("div", {
216
+ children: dictionary[copy] ? dictionary[copy].weekDays[day] : day
217
+ })
218
+ })
219
+ })
220
+ });
221
+ });
222
+ DatePicker.displayName = 'DatePicker';
223
+ DatePicker.propTypes = { ...selectedSystemPropTypes,
224
+
225
+ /**
226
+ * A unique identifier.
227
+ */
228
+ id: PropTypes.string.isRequired,
229
+
230
+ /**
231
+ * Whether the English or French copy will be used (e.g. for accessibility labels).
232
+ */
233
+ copy: PropTypes.oneOf(['en', 'fr']),
234
+
235
+ /**
236
+ * A Moment instance representing the currently selected date, i.e. `moment()`
237
+ */
238
+ date: momentPropTypes.momentObj,
239
+
240
+ /**
241
+ * A detailed description of validation error/success or additional instructions.
242
+ * Visual variant is determined based on the `validation` prop.
243
+ */
244
+ feedback: PropTypes.string,
245
+
246
+ /**
247
+ * Event triggered every time a new date is clicked on
248
+ * @param {Moment} date The new date that was selected
249
+ */
250
+ onDateChange: PropTypes.func,
251
+
252
+ /**
253
+ * A function determining whether a given date should be disabled
254
+ * @param {Moment} date The date to optionally disable
255
+ * @returns {bool}
256
+ */
257
+ isDayDisabled: PropTypes.func,
258
+
259
+ /**
260
+ * The field label to be displayed above the calendar
261
+ */
262
+ label: PropTypes.string,
263
+
264
+ /**
265
+ * A flag determining if the calendar picker is standalone or an input with overlay
266
+ */
267
+ inline: PropTypes.bool,
268
+
269
+ /**
270
+ * A short description of the expected input.
271
+ */
272
+ hint: PropTypes.string,
273
+
274
+ /**
275
+ * Position of the hint relative to label. Use `below` to display a larger hint below the label.
276
+ */
277
+ hintPosition: PropTypes.oneOf(['inline', 'below']),
278
+
279
+ /**
280
+ * Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
281
+ */
282
+ tooltip: PropTypes.string,
283
+
284
+ /**
285
+ * Use to visually mark an input as valid or invalid.
286
+ */
287
+ validation: PropTypes.oneOf(['error', 'success'])
288
+ };
289
+ DatePicker.defaultProps = {
290
+ copy: 'en',
291
+ date: undefined,
292
+ feedback: undefined,
293
+ inline: false,
294
+ isDayDisabled: undefined,
295
+ label: undefined,
296
+ hint: undefined,
297
+ hintPosition: 'inline',
298
+ tooltip: undefined,
299
+ onDateChange: () => {},
300
+ validation: undefined
301
+ };
302
+ export default DatePicker;