@instructure/ui-calendar 11.6.0 → 11.6.1-snapshot-129

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 (95) hide show
  1. package/CHANGELOG.md +36 -286
  2. package/es/Calendar/{Day → v1/Day}/index.js +2 -2
  3. package/es/Calendar/{index.js → v1/index.js} +4 -4
  4. package/es/Calendar/v2/Day/index.js +148 -0
  5. package/{src/index.ts → es/Calendar/v2/Day/props.js} +2 -4
  6. package/es/Calendar/v2/Day/styles.js +78 -0
  7. package/es/Calendar/v2/index.js +407 -0
  8. package/es/Calendar/v2/props.js +26 -0
  9. package/es/Calendar/v2/styles.js +66 -0
  10. package/es/{index.js → exports/a.js} +2 -2
  11. package/es/exports/b.js +25 -0
  12. package/lib/Calendar/{Day → v1/Day}/index.js +4 -4
  13. package/lib/Calendar/{index.js → v1/index.js} +12 -12
  14. package/lib/Calendar/v2/Day/index.js +155 -0
  15. package/lib/Calendar/v2/Day/props.js +31 -0
  16. package/lib/Calendar/v2/Day/styles.js +84 -0
  17. package/lib/Calendar/v2/index.js +416 -0
  18. package/lib/Calendar/v2/props.js +31 -0
  19. package/lib/Calendar/v2/styles.js +72 -0
  20. package/lib/{index.js → exports/a.js} +3 -3
  21. package/lib/exports/b.js +19 -0
  22. package/package.json +45 -23
  23. package/src/Calendar/{Day → v1/Day}/index.tsx +3 -3
  24. package/src/Calendar/{Day → v1/Day}/props.ts +1 -1
  25. package/src/Calendar/{index.tsx → v1/index.tsx} +4 -4
  26. package/src/Calendar/v2/Day/index.tsx +176 -0
  27. package/src/Calendar/v2/Day/props.ts +126 -0
  28. package/src/Calendar/v2/Day/styles.ts +96 -0
  29. package/src/Calendar/v2/README.md +255 -0
  30. package/src/Calendar/v2/index.tsx +560 -0
  31. package/src/Calendar/v2/props.ts +207 -0
  32. package/src/Calendar/v2/styles.ts +75 -0
  33. package/src/exports/a.ts +28 -0
  34. package/src/exports/b.ts +28 -0
  35. package/tsconfig.build.tsbuildinfo +1 -1
  36. package/types/Calendar/{Day → v1/Day}/index.d.ts +1 -1
  37. package/types/Calendar/v1/Day/index.d.ts.map +1 -0
  38. package/types/Calendar/{Day → v1/Day}/props.d.ts +1 -1
  39. package/types/Calendar/v1/Day/props.d.ts.map +1 -0
  40. package/types/Calendar/v1/Day/styles.d.ts.map +1 -0
  41. package/types/Calendar/v1/Day/theme.d.ts.map +1 -0
  42. package/types/Calendar/{index.d.ts → v1/index.d.ts} +1 -1
  43. package/types/Calendar/v1/index.d.ts.map +1 -0
  44. package/types/Calendar/v1/props.d.ts.map +1 -0
  45. package/types/Calendar/v1/styles.d.ts.map +1 -0
  46. package/types/Calendar/v1/theme.d.ts.map +1 -0
  47. package/types/Calendar/v2/Day/index.d.ts +49 -0
  48. package/types/Calendar/v2/Day/index.d.ts.map +1 -0
  49. package/types/Calendar/v2/Day/props.d.ts +76 -0
  50. package/types/Calendar/v2/Day/props.d.ts.map +1 -0
  51. package/types/Calendar/v2/Day/styles.d.ts +15 -0
  52. package/types/Calendar/v2/Day/styles.d.ts.map +1 -0
  53. package/types/Calendar/v2/index.d.ts +84 -0
  54. package/types/Calendar/v2/index.d.ts.map +1 -0
  55. package/types/Calendar/v2/props.d.ts +135 -0
  56. package/types/Calendar/v2/props.d.ts.map +1 -0
  57. package/types/Calendar/v2/styles.d.ts +13 -0
  58. package/types/Calendar/v2/styles.d.ts.map +1 -0
  59. package/types/exports/a.d.ts +5 -0
  60. package/types/exports/a.d.ts.map +1 -0
  61. package/types/exports/b.d.ts +5 -0
  62. package/types/exports/b.d.ts.map +1 -0
  63. package/types/Calendar/Day/index.d.ts.map +0 -1
  64. package/types/Calendar/Day/props.d.ts.map +0 -1
  65. package/types/Calendar/Day/styles.d.ts.map +0 -1
  66. package/types/Calendar/Day/theme.d.ts.map +0 -1
  67. package/types/Calendar/index.d.ts.map +0 -1
  68. package/types/Calendar/props.d.ts.map +0 -1
  69. package/types/Calendar/styles.d.ts.map +0 -1
  70. package/types/Calendar/theme.d.ts.map +0 -1
  71. package/types/index.d.ts +0 -5
  72. package/types/index.d.ts.map +0 -1
  73. /package/es/Calendar/{Day → v1/Day}/props.js +0 -0
  74. /package/es/Calendar/{Day → v1/Day}/styles.js +0 -0
  75. /package/es/Calendar/{Day → v1/Day}/theme.js +0 -0
  76. /package/es/Calendar/{props.js → v1/props.js} +0 -0
  77. /package/es/Calendar/{styles.js → v1/styles.js} +0 -0
  78. /package/es/Calendar/{theme.js → v1/theme.js} +0 -0
  79. /package/lib/Calendar/{Day → v1/Day}/props.js +0 -0
  80. /package/lib/Calendar/{Day → v1/Day}/styles.js +0 -0
  81. /package/lib/Calendar/{Day → v1/Day}/theme.js +0 -0
  82. /package/lib/Calendar/{props.js → v1/props.js} +0 -0
  83. /package/lib/Calendar/{styles.js → v1/styles.js} +0 -0
  84. /package/lib/Calendar/{theme.js → v1/theme.js} +0 -0
  85. /package/src/Calendar/{Day → v1/Day}/styles.ts +0 -0
  86. /package/src/Calendar/{Day → v1/Day}/theme.ts +0 -0
  87. /package/src/Calendar/{README.md → v1/README.md} +0 -0
  88. /package/src/Calendar/{props.ts → v1/props.ts} +0 -0
  89. /package/src/Calendar/{styles.ts → v1/styles.ts} +0 -0
  90. /package/src/Calendar/{theme.ts → v1/theme.ts} +0 -0
  91. /package/types/Calendar/{Day → v1/Day}/styles.d.ts +0 -0
  92. /package/types/Calendar/{Day → v1/Day}/theme.d.ts +0 -0
  93. /package/types/Calendar/{props.d.ts → v1/props.d.ts} +0 -0
  94. /package/types/Calendar/{styles.d.ts → v1/styles.d.ts} +0 -0
  95. /package/types/Calendar/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,207 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type {
26
+ AsElementType,
27
+ CalendarTheme,
28
+ OtherHTMLAttributes
29
+ } from '@instructure/shared-types'
30
+ import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
31
+ import { ReactElement } from 'react'
32
+ import type { CalendarDayProps } from './Day/props'
33
+ import { Renderable } from '@instructure/shared-types'
34
+ import type { Moment } from '@instructure/ui-i18n'
35
+ import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
36
+
37
+ type CalendarOwnProps = {
38
+ /**
39
+ * The element to render as the `Calendar` root, `span` by default
40
+ */
41
+ as?: AsElementType
42
+ /**
43
+ * children of type `<Calendar.Day />` There should be exactly 42 provided (6
44
+ * weeks).
45
+ */
46
+ children?: ReactElement<CalendarDayProps>[]
47
+ /**
48
+ * ISO date string for the current date if necessary. Defaults to the current
49
+ * date in the user's timezone.
50
+ */
51
+ currentDate?: string
52
+ /*
53
+ * Specify which date(s) will be shown as disabled in the calendar.
54
+ * You can either supply an array of ISO8601 timeDate strings or
55
+ * a function that will be called for each date shown in the calendar.
56
+ */
57
+ disabledDates?: string[] | ((isoDateToCheck: string) => boolean)
58
+ /**
59
+ * A standard language identifier.
60
+ *
61
+ * See [Moment.js](https://momentjs.com/timezone/docs/#/using-timezones/parsing-in-zone/) for
62
+ * more details.
63
+ *
64
+ * This property can also be set via a context property and if both are set
65
+ * then the component property takes precedence over the context property.
66
+ *
67
+ * The web browser's locale will be used if no value is set via a component
68
+ * property or a context property.
69
+ **/
70
+ locale?: string
71
+ /**
72
+ * Callback fired when a day has been selected.
73
+ */
74
+ onDateSelected?: (
75
+ dateString: string,
76
+ momentDate: Moment,
77
+ e: React.MouseEvent
78
+ ) => void
79
+ /**
80
+ * Callback fired when the next month button is clicked in the navigation
81
+ * header, requesting to render the next month.
82
+ */
83
+ onRequestRenderNextMonth?: (
84
+ e: React.MouseEvent,
85
+ requestedMonth: string
86
+ ) => void
87
+ /**
88
+ * Callback fired when the previous month button is clicked in the navigation
89
+ * header, requesting to render the previous month.
90
+ */
91
+ onRequestRenderPrevMonth?: (
92
+ e: React.MouseEvent,
93
+ requestedMonth: string
94
+ ) => void
95
+ /**
96
+ * Content to render in the navigation header. The recommendation is to include
97
+ * the name of the current rendered month along with the year.
98
+ */
99
+ renderNavigationLabel?: Renderable
100
+ /**
101
+ * A button to render in the navigation header. The recommendation is to
102
+ * compose it with the [IconButton](IconButton) component by setting the `size`
103
+ * prop to `small`, `withBorder` and `withBackground` to `false`, and setting
104
+ * `renderIcon` to [IconArrowOpenEnd](icons).
105
+ */
106
+ renderNextMonthButton?: Renderable
107
+ /**
108
+ * A button to render in the navigation header. The recommendation is to
109
+ * compose it with the [IconButton](Button) component by setting the `size`
110
+ * prop to `small`, `withBorder` and `withBackground` to `false`, and setting
111
+ * `renderIcon` to [IconArrowOpenStart](icons).
112
+ */
113
+ renderPrevMonthButton?: Renderable
114
+ /**
115
+ * An array of labels containing the name of each day of the week. The visible
116
+ * portion of the label should be abbreviated (no longer than three characters).
117
+ * Note that screen readers will read this content preceding each date as the
118
+ * `<Calendar />` is navigated. Consider using
119
+ * [AccessibleContent](AccessibleContent) with the `alt` prop containing the
120
+ * full day name for assistive technologies and the children containing the
121
+ * abbreviation. ex. `[<AccessibleContent alt="Sunday">Sun</AccessibleContent>, ...]`
122
+ */
123
+ renderWeekdayLabels?: Renderable[]
124
+ /**
125
+ * The role of the underlying table. This can be set to 'listbox' when
126
+ * assistive technologies need to read the `<Calendar.Day />` children as a list.
127
+ */
128
+ role?: 'table' | 'listbox'
129
+ /**
130
+ * ISO date string for the selected date. It needs onDateSelected to be specified too.
131
+ */
132
+ selectedDate?: string
133
+ /**
134
+ * A timezone identifier in the format: *Area/Location*
135
+ *
136
+ * See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for the list
137
+ * of possible options.
138
+ *
139
+ * This property can also be set via a context property and if both are set
140
+ * then the component property takes precedence over the context property.
141
+ *
142
+ * The web browser's timezone will be used if no value is set via a component
143
+ * property or a context property.
144
+ */
145
+ timezone?: string
146
+ /**
147
+ * Visible month for the rendered calendar. Formatted as an ISO date string.
148
+ */
149
+ visibleMonth?: string
150
+
151
+ /**
152
+ * If set, years can be picked from a dropdown.
153
+ * It accepts an object.
154
+ * screenReaderLabel: string // e.g.: i18n("pick a year")
155
+ *
156
+ * onRequestYearChange?:(e: React.MouseEvent,requestedYear: number): void // if set, on year change, only this will be called and no internal change will take place
157
+ *
158
+ * startYear: number // e.g.: 2001, sets the start year of the selectable list
159
+ *
160
+ * endYear: number // e.g.: 2030, sets the end year of the selectable list
161
+ */
162
+ withYearPicker?: {
163
+ screenReaderLabel: string
164
+ onRequestYearChange?: (e: any, requestedYear: number) => void
165
+ startYear: number
166
+ endYear: number
167
+ }
168
+ }
169
+
170
+ type PropKeys = keyof CalendarOwnProps
171
+
172
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
173
+
174
+ type CalendarProps = CalendarOwnProps &
175
+ WithStyleProps<CalendarTheme, CalendarStyle> &
176
+ OtherHTMLAttributes<CalendarOwnProps> &
177
+ WithDeterministicIdProps
178
+
179
+ type CalendarStyle = ComponentStyle<
180
+ 'navigation' | 'navigationWithButtons' | 'weekdayHeader' | 'yearPicker'
181
+ >
182
+ const allowedProps: AllowedPropKeys = [
183
+ 'as',
184
+ 'children',
185
+ 'currentDate',
186
+ 'disabledDates',
187
+ 'locale',
188
+ 'onDateSelected',
189
+ 'onRequestRenderNextMonth',
190
+ 'onRequestRenderPrevMonth',
191
+ 'renderNavigationLabel',
192
+ 'renderNextMonthButton',
193
+ 'renderPrevMonthButton',
194
+ 'renderWeekdayLabels',
195
+ 'role',
196
+ 'selectedDate',
197
+ 'timezone',
198
+ 'visibleMonth'
199
+ ]
200
+
201
+ type CalendarState = {
202
+ visibleMonth: Moment
203
+ today: Moment
204
+ }
205
+
206
+ export type { CalendarProps, CalendarStyle, CalendarState }
207
+ export { allowedProps }
@@ -0,0 +1,75 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { NewComponentTypes } from '@instructure/ui-themes'
26
+ import type { CalendarStyle, CalendarProps } from './props'
27
+
28
+ /**
29
+ * ---
30
+ * private: true
31
+ * ---
32
+ * Generates the style object from the theme and provided additional information
33
+ * @param {Object} componentTheme The theme variable object.
34
+ * @return {Object} The final style object, which will be used in the component
35
+ */
36
+ const generateStyle = (
37
+ componentTheme: NewComponentTypes['Calendar'],
38
+ props: CalendarProps
39
+ ): CalendarStyle => {
40
+ const { withYearPicker } = props
41
+ return {
42
+ navigation: {
43
+ label: 'calendar__navigation',
44
+ textAlign: 'center',
45
+ color: componentTheme.color,
46
+ background: componentTheme.background,
47
+ fontFamily: componentTheme.fontFamily,
48
+ fontSize: componentTheme.fontSize,
49
+ fontWeight: componentTheme.fontWeight,
50
+ marginBottom: withYearPicker
51
+ ? componentTheme.navWithYearMargin
52
+ : componentTheme.navMargin
53
+ },
54
+ navigationWithButtons: {
55
+ label: 'calendar__navigation--withButtons',
56
+ display: 'flex',
57
+ alignItems: 'center',
58
+ justifyContent: 'space-between'
59
+ },
60
+ weekdayHeader: {
61
+ label: 'calendar__weekdayHeader',
62
+ textAlign: 'center',
63
+ maxWidth: componentTheme.maxHeaderWidth,
64
+ lineHeight: componentTheme.lineHeight
65
+ },
66
+ yearPicker: {
67
+ display: 'flex',
68
+ justifyContent: 'center',
69
+ alignItems: 'center',
70
+ marginBottom: componentTheme.yearPickerMargin
71
+ }
72
+ }
73
+ }
74
+
75
+ export default generateStyle
@@ -0,0 +1,28 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ export { Calendar } from '../Calendar/v1'
25
+ export { Day as CalendarDay } from '../Calendar/v1/Day'
26
+
27
+ export type { CalendarProps } from '../Calendar/v1/props'
28
+ export type { CalendarDayProps } from '../Calendar/v1/Day/props'
@@ -0,0 +1,28 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ export { Calendar } from '../Calendar/v2'
25
+ export { Day as CalendarDay } from '../Calendar/v2/Day'
26
+
27
+ export type { CalendarProps } from '../Calendar/v2/props'
28
+ export type { CalendarDayProps } from '../Calendar/v2/Day/props'