dce-reactkit 5.0.2 → 5.0.4
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/dist/cjs/index.js +37 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/SimpleDateChooser.d.ts +1 -0
- package/dist/cjs/types/components/SimpleMonthChooser.d.ts +23 -0
- package/dist/cjs/types/index.d.ts +3 -2
- package/dist/esm/index.js +34 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/SimpleDateChooser.d.ts +1 -0
- package/dist/esm/types/components/SimpleMonthChooser.d.ts +23 -0
- package/dist/esm/types/index.d.ts +3 -2
- package/dist/index.d.ts +40 -16
- package/package.json +2 -2
- package/src/components/SimpleDateChooser.tsx +31 -22
- package/src/components/SimpleMonthChooser.tsx +98 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A very simple, lightweight month chooser
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
type Props = {
|
|
7
|
+
ariaLabel: string;
|
|
8
|
+
name: string;
|
|
9
|
+
month: number;
|
|
10
|
+
year: number;
|
|
11
|
+
/**
|
|
12
|
+
* Handler for when month changes
|
|
13
|
+
* @param month new 1-indexed month number
|
|
14
|
+
* @param year new full year number
|
|
15
|
+
*/
|
|
16
|
+
onChange: (month: number, year: number) => void;
|
|
17
|
+
numMonthsToShow?: number;
|
|
18
|
+
dontAllowPast?: boolean;
|
|
19
|
+
dontAllowFuture?: boolean;
|
|
20
|
+
isDisabled?: boolean;
|
|
21
|
+
};
|
|
22
|
+
declare const SimpleMonthChooser: React.FC<Props>;
|
|
23
|
+
export default SimpleMonthChooser;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, LOG_REVIEW_GET_LOGS_ROUTE, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, validateEmail, validatePhoneNumber, validateString, idify, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, ParamType, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, CommonKitErrorCode, LogReviewerFilterState } from 'dce-commonkit';
|
|
1
|
+
import { ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, LOG_REVIEW_GET_LOGS_ROUTE, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, validateEmail, validatePhoneNumber, validateString, idify, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, spaceAtCapitals, ParamType, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, CommonKitErrorCode, LogReviewerFilterState } from 'dce-commonkit';
|
|
2
2
|
import AppWrapper, { alert, prompt, confirm, showFatalError, addFatalErrorHandler, leaveToURL } from './components/AppWrapper';
|
|
3
3
|
import LoadingSpinner from './components/LoadingSpinner';
|
|
4
4
|
import ErrorBox from './components/ErrorBox';
|
|
@@ -8,6 +8,7 @@ import RadioButton from './components/RadioButton';
|
|
|
8
8
|
import CheckboxButton from './components/CheckboxButton';
|
|
9
9
|
import ButtonInputGroup from './components/ButtonInputGroup';
|
|
10
10
|
import SimpleDateChooser from './components/SimpleDateChooser';
|
|
11
|
+
import SimpleMonthChooser from './components/SimpleMonthChooser';
|
|
11
12
|
import SimpleTimeChooser from './components/SimpleTimeChooser';
|
|
12
13
|
import Drawer from './components/Drawer';
|
|
13
14
|
import PopSuccessMark from './components/PopSuccessMark';
|
|
@@ -48,4 +49,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
|
48
49
|
import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
|
|
49
50
|
import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
|
|
50
51
|
import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
|
|
51
|
-
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, SimpleTimeChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, ProgressBar, FakeProgressBar, alert, prompt, confirm, showFatalError, DynamicWord, stubServerEndpoint, canReviewLogs, isMobileOrTablet, makeLinksClickable, isSelectAdmin, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, ModalButtonType, ModalSize, ModalType, Variant, IntelliTableColumn, DropdownItemType, LogReviewerFilterState, ProgressBarSize, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, LOG_REVIEW_GET_LOGS_ROUTE, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, validateEmail, validatePhoneNumber, validateString, idify, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, ParamType, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, CommonKitErrorCode, };
|
|
52
|
+
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, SimpleMonthChooser, SimpleTimeChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, ProgressBar, FakeProgressBar, alert, prompt, confirm, showFatalError, DynamicWord, stubServerEndpoint, canReviewLogs, isMobileOrTablet, makeLinksClickable, isSelectAdmin, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, ModalButtonType, ModalSize, ModalType, Variant, IntelliTableColumn, DropdownItemType, LogReviewerFilterState, ProgressBarSize, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, LOG_REVIEW_GET_LOGS_ROUTE, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, validateEmail, validatePhoneNumber, validateString, idify, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, spaceAtCapitals, ParamType, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, CommonKitErrorCode, };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LogMetadataType, ParamType, LogFunction } from 'dce-commonkit';
|
|
3
|
-
export { CommonKitErrorCode, DAY_IN_MS, DayOfWeek, ErrorWithCode, HOUR_IN_MS, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, Log, LogAction, LogBuiltInMetadata, LogFunction, LogLevel, LogMainInfo, LogMetadataType, LogReviewerFilterState, LogSource, LogSourceSpecificInfo, LogType, LogTypeSpecificInfo, MINUTE_IN_MS, ParamType, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, capitalize, ceilToNumDecimals, cloneDeep, compareArraysByProp, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getTimestampFromTimeInfoInET, getWordCount, idify, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, sum, validateEmail, validatePhoneNumber, validateString, waitMs } from 'dce-commonkit';
|
|
3
|
+
export { CommonKitErrorCode, DAY_IN_MS, DayOfWeek, ErrorWithCode, HOUR_IN_MS, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, Log, LogAction, LogBuiltInMetadata, LogFunction, LogLevel, LogMainInfo, LogMetadataType, LogReviewerFilterState, LogSource, LogSourceSpecificInfo, LogType, LogTypeSpecificInfo, MINUTE_IN_MS, ParamType, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, capitalize, ceilToNumDecimals, cloneDeep, compareArraysByProp, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getTimestampFromTimeInfoInET, getWordCount, idify, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, shuffleArray, someAsync, spaceAtCapitals, startMinWait, stringsToHumanReadableList, sum, validateEmail, validatePhoneNumber, validateString, waitMs } from 'dce-commonkit';
|
|
4
4
|
import React$1 from 'react';
|
|
5
5
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@ declare enum Variant {
|
|
|
25
25
|
* @author Gabe Abrams
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
type Props$
|
|
28
|
+
type Props$p = {
|
|
29
29
|
children: React$1.ReactNode;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
@@ -108,7 +108,7 @@ declare const showFatalError: (error: any, errorTitle?: string) => Promise<void>
|
|
|
108
108
|
* @author Gabe Abrams
|
|
109
109
|
*/
|
|
110
110
|
declare const addFatalErrorHandler: (handler: () => void) => void;
|
|
111
|
-
declare const AppWrapper: React$1.FC<Props$
|
|
111
|
+
declare const AppWrapper: React$1.FC<Props$p>;
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
114
|
* Loading spinner/indicator
|
|
@@ -122,14 +122,14 @@ declare const LoadingSpinner: () => React$1.JSX.Element;
|
|
|
122
122
|
* @author Gabe Abrams
|
|
123
123
|
*/
|
|
124
124
|
|
|
125
|
-
type Props$
|
|
125
|
+
type Props$o = {
|
|
126
126
|
error: any;
|
|
127
127
|
title?: string;
|
|
128
128
|
onClose?: () => void;
|
|
129
129
|
variant?: Variant;
|
|
130
130
|
icon?: IconProp;
|
|
131
131
|
};
|
|
132
|
-
declare const ErrorBox: React$1.FC<Props$
|
|
132
|
+
declare const ErrorBox: React$1.FC<Props$o>;
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* Types of buttons in the modal
|
|
@@ -228,7 +228,7 @@ declare const Modal: React$1.FC<ModalProps>;
|
|
|
228
228
|
* @author Gabe Abrams
|
|
229
229
|
*/
|
|
230
230
|
|
|
231
|
-
type Props$
|
|
231
|
+
type Props$n = {
|
|
232
232
|
title: React$1.ReactNode;
|
|
233
233
|
children: React$1.ReactNode;
|
|
234
234
|
topRightChildren?: React$1.ReactNode;
|
|
@@ -236,14 +236,14 @@ type Props$m = {
|
|
|
236
236
|
noBottomPadding?: boolean;
|
|
237
237
|
minTitleWidth?: string;
|
|
238
238
|
};
|
|
239
|
-
declare const TabBox: React$1.FC<Props$
|
|
239
|
+
declare const TabBox: React$1.FC<Props$n>;
|
|
240
240
|
|
|
241
241
|
/**
|
|
242
242
|
* A radio selection button
|
|
243
243
|
* @author Gabe Abrams
|
|
244
244
|
*/
|
|
245
245
|
|
|
246
|
-
type Props$
|
|
246
|
+
type Props$m = {
|
|
247
247
|
text: React$1.ReactNode;
|
|
248
248
|
onSelected: () => void;
|
|
249
249
|
ariaLabel: string;
|
|
@@ -257,14 +257,14 @@ type Props$l = {
|
|
|
257
257
|
small?: boolean;
|
|
258
258
|
useComplexFormatting?: boolean;
|
|
259
259
|
};
|
|
260
|
-
declare const RadioButton: React$1.FC<Props$
|
|
260
|
+
declare const RadioButton: React$1.FC<Props$m>;
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
263
|
* A checkbox button
|
|
264
264
|
* @author Gabe Abrams
|
|
265
265
|
*/
|
|
266
266
|
|
|
267
|
-
type Props$
|
|
267
|
+
type Props$l = {
|
|
268
268
|
text: React$1.ReactNode;
|
|
269
269
|
onChanged: (checked: boolean) => void;
|
|
270
270
|
ariaLabel: string;
|
|
@@ -279,14 +279,14 @@ type Props$k = {
|
|
|
279
279
|
dashed?: boolean;
|
|
280
280
|
useComplexFormatting?: boolean;
|
|
281
281
|
};
|
|
282
|
-
declare const CheckboxButton: React$1.FC<Props$
|
|
282
|
+
declare const CheckboxButton: React$1.FC<Props$l>;
|
|
283
283
|
|
|
284
284
|
/**
|
|
285
285
|
* Input group with a title and space for buttons
|
|
286
286
|
* @author Gabe Abrams
|
|
287
287
|
*/
|
|
288
288
|
|
|
289
|
-
type Props$
|
|
289
|
+
type Props$k = {
|
|
290
290
|
label: React$1.ReactNode;
|
|
291
291
|
minLabelWidth?: string;
|
|
292
292
|
children: React$1.ReactNode;
|
|
@@ -295,7 +295,7 @@ type Props$j = {
|
|
|
295
295
|
isAdminFeature?: boolean;
|
|
296
296
|
noMarginOnBottom?: boolean;
|
|
297
297
|
};
|
|
298
|
-
declare const ButtonInputGroup: React$1.FC<Props$
|
|
298
|
+
declare const ButtonInputGroup: React$1.FC<Props$k>;
|
|
299
299
|
|
|
300
300
|
/**
|
|
301
301
|
* A very simple, lightweight date chooser
|
|
@@ -303,7 +303,7 @@ declare const ButtonInputGroup: React$1.FC<Props$j>;
|
|
|
303
303
|
* @author Gardenia Liu
|
|
304
304
|
*/
|
|
305
305
|
|
|
306
|
-
type Props$
|
|
306
|
+
type Props$j = {
|
|
307
307
|
ariaLabel: string;
|
|
308
308
|
name: string;
|
|
309
309
|
month: number;
|
|
@@ -320,8 +320,32 @@ type Props$i = {
|
|
|
320
320
|
dontAllowPast?: boolean;
|
|
321
321
|
dontAllowFuture?: boolean;
|
|
322
322
|
isDisabled?: boolean;
|
|
323
|
+
hideDay?: boolean;
|
|
324
|
+
};
|
|
325
|
+
declare const SimpleDateChooser: React$1.FC<Props$j>;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* A very simple, lightweight month chooser
|
|
329
|
+
* @author Gabe Abrams
|
|
330
|
+
*/
|
|
331
|
+
|
|
332
|
+
type Props$i = {
|
|
333
|
+
ariaLabel: string;
|
|
334
|
+
name: string;
|
|
335
|
+
month: number;
|
|
336
|
+
year: number;
|
|
337
|
+
/**
|
|
338
|
+
* Handler for when month changes
|
|
339
|
+
* @param month new 1-indexed month number
|
|
340
|
+
* @param year new full year number
|
|
341
|
+
*/
|
|
342
|
+
onChange: (month: number, year: number) => void;
|
|
343
|
+
numMonthsToShow?: number;
|
|
344
|
+
dontAllowPast?: boolean;
|
|
345
|
+
dontAllowFuture?: boolean;
|
|
346
|
+
isDisabled?: boolean;
|
|
323
347
|
};
|
|
324
|
-
declare const
|
|
348
|
+
declare const SimpleMonthChooser: React$1.FC<Props$i>;
|
|
325
349
|
|
|
326
350
|
/**
|
|
327
351
|
* A very simple, lightweight time chooser
|
|
@@ -941,4 +965,4 @@ declare const useForceRender: (useReducer: any) => () => void;
|
|
|
941
965
|
*/
|
|
942
966
|
declare const isSelectAdmin: () => Promise<boolean>;
|
|
943
967
|
|
|
944
|
-
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, FakeProgressBar, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, LogReviewer, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, ProgressBar, ProgressBarSize, RadioButton, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, Variant, addFatalErrorHandler, alert, canReviewLogs, combineClassNames, confirm, initClient, isMobileOrTablet, isSelectAdmin, leaveToURL, logClientEvent, makeLinksClickable, prompt, setClientEventMetadataPopulator, showFatalError, stubServerEndpoint, useForceRender, visitServerEndpoint };
|
|
968
|
+
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, FakeProgressBar, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, LogReviewer, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, ProgressBar, ProgressBarSize, RadioButton, SimpleDateChooser, SimpleMonthChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, Variant, addFatalErrorHandler, alert, canReviewLogs, combineClassNames, confirm, initClient, isMobileOrTablet, isSelectAdmin, leaveToURL, logClientEvent, makeLinksClickable, prompt, setClientEventMetadataPopulator, showFatalError, stubServerEndpoint, useForceRender, visitServerEndpoint };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dce-reactkit",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "Shared components for Harvard DCE apps",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/harvard-edtech/dce-reactkit#readme",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"dce-commonkit": "^5.0.
|
|
27
|
+
"dce-commonkit": "^5.0.1",
|
|
28
28
|
"react-select": "^5.7.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
@@ -51,6 +51,8 @@ type Props = {
|
|
|
51
51
|
dontAllowFuture?: boolean,
|
|
52
52
|
// If true, the chooser is disabled
|
|
53
53
|
isDisabled?: boolean,
|
|
54
|
+
// If true, hide the "day" dropdown and just show the month and year
|
|
55
|
+
hideDay?: boolean,
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
/*------------------------------------------------------------------------*/
|
|
@@ -292,6 +294,7 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
|
|
|
292
294
|
day,
|
|
293
295
|
year,
|
|
294
296
|
isDisabled = false,
|
|
297
|
+
hideDay,
|
|
295
298
|
} = props;
|
|
296
299
|
|
|
297
300
|
// Get choices
|
|
@@ -442,24 +445,26 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
|
|
|
442
445
|
</select>
|
|
443
446
|
|
|
444
447
|
{/* Day Chooser */}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
448
|
+
{!hideDay && (
|
|
449
|
+
<select
|
|
450
|
+
aria-label={`day for ${ariaLabel}`}
|
|
451
|
+
className="custom-select form-select d-inline-block"
|
|
452
|
+
style={{ width: 'auto' }}
|
|
453
|
+
id={`SimpleDateChooser-${name}-day`}
|
|
454
|
+
value={day}
|
|
455
|
+
onChange={(e) => {
|
|
456
|
+
// Only change the day
|
|
457
|
+
onChange(
|
|
458
|
+
month,
|
|
459
|
+
Number.parseInt(e.target.value, 10),
|
|
460
|
+
year,
|
|
461
|
+
);
|
|
462
|
+
}}
|
|
463
|
+
disabled={isDisabled}
|
|
464
|
+
>
|
|
465
|
+
{dayOptions}
|
|
466
|
+
</select>
|
|
467
|
+
)}
|
|
463
468
|
</div>
|
|
464
469
|
);
|
|
465
470
|
}
|
|
@@ -476,10 +481,14 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
|
|
|
476
481
|
aria-label={`edit date for ${ariaLabel}`}
|
|
477
482
|
>
|
|
478
483
|
{getMonthName(month).full}
|
|
479
|
-
{
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
484
|
+
{!hideDay && (
|
|
485
|
+
<>
|
|
486
|
+
{' '}
|
|
487
|
+
{day}
|
|
488
|
+
{getOrdinal(day)}
|
|
489
|
+
,
|
|
490
|
+
</>
|
|
491
|
+
)}
|
|
483
492
|
{' '}
|
|
484
493
|
{year}
|
|
485
494
|
</button>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A very simple, lightweight month chooser
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Import React
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
// Import other components
|
|
10
|
+
import SimpleDateChooser from './SimpleDateChooser';
|
|
11
|
+
|
|
12
|
+
/*------------------------------------------------------------------------*/
|
|
13
|
+
/* -------------------------------- Types ------------------------------- */
|
|
14
|
+
/*------------------------------------------------------------------------*/
|
|
15
|
+
|
|
16
|
+
type Props = {
|
|
17
|
+
// Aria label
|
|
18
|
+
ariaLabel: string,
|
|
19
|
+
// Name of the chooser (machine-readable, hyphenated)
|
|
20
|
+
name: string,
|
|
21
|
+
// Currently selected month
|
|
22
|
+
month: number,
|
|
23
|
+
// Currently selected year
|
|
24
|
+
year: number,
|
|
25
|
+
/**
|
|
26
|
+
* Handler for when month changes
|
|
27
|
+
* @param month new 1-indexed month number
|
|
28
|
+
* @param year new full year number
|
|
29
|
+
*/
|
|
30
|
+
onChange: (month: number, year: number) => void,
|
|
31
|
+
// Number of months in either the past or future to allow the user to choose from
|
|
32
|
+
// If we aren't allowing the past or the future, we will throw an error
|
|
33
|
+
// (max is 12, default is 6 in the past and 6 in the future)
|
|
34
|
+
numMonthsToShow?: number,
|
|
35
|
+
// If true, the user isn't allowed to select dates in the past
|
|
36
|
+
dontAllowPast?: boolean,
|
|
37
|
+
// If true, the user isn't allowed to select dates in the future
|
|
38
|
+
dontAllowFuture?: boolean,
|
|
39
|
+
// If true, the chooser is disabled
|
|
40
|
+
isDisabled?: boolean,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/*------------------------------------------------------------------------*/
|
|
44
|
+
/* ------------------------------ Component ----------------------------- */
|
|
45
|
+
/*------------------------------------------------------------------------*/
|
|
46
|
+
|
|
47
|
+
const SimpleMonthChooser: React.FC<Props> = (props) => {
|
|
48
|
+
/*------------------------------------------------------------------------*/
|
|
49
|
+
/* -------------------------------- Setup ------------------------------- */
|
|
50
|
+
/*------------------------------------------------------------------------*/
|
|
51
|
+
|
|
52
|
+
/* -------------- Props ------------- */
|
|
53
|
+
|
|
54
|
+
const {
|
|
55
|
+
ariaLabel,
|
|
56
|
+
name,
|
|
57
|
+
dontAllowPast,
|
|
58
|
+
dontAllowFuture,
|
|
59
|
+
numMonthsToShow,
|
|
60
|
+
onChange,
|
|
61
|
+
month,
|
|
62
|
+
year,
|
|
63
|
+
isDisabled,
|
|
64
|
+
} = props;
|
|
65
|
+
|
|
66
|
+
/*------------------------------------------------------------------------*/
|
|
67
|
+
/* ------------------------------- Render ------------------------------- */
|
|
68
|
+
/*------------------------------------------------------------------------*/
|
|
69
|
+
|
|
70
|
+
/*----------------------------------------*/
|
|
71
|
+
/* --------------- Main UI -------------- */
|
|
72
|
+
/*----------------------------------------*/
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<SimpleDateChooser
|
|
76
|
+
ariaLabel={ariaLabel}
|
|
77
|
+
name={name}
|
|
78
|
+
month={month}
|
|
79
|
+
day={1}
|
|
80
|
+
year={year}
|
|
81
|
+
numMonthsToShow={numMonthsToShow}
|
|
82
|
+
dontAllowPast={dontAllowPast}
|
|
83
|
+
dontAllowFuture={dontAllowFuture}
|
|
84
|
+
isDisabled={isDisabled}
|
|
85
|
+
hideDay
|
|
86
|
+
onChange={(newMonth, newDay, newYear) => {
|
|
87
|
+
onChange(newMonth, newYear);
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/*------------------------------------------------------------------------*/
|
|
94
|
+
/* ------------------------------- Wrap Up ------------------------------ */
|
|
95
|
+
/*------------------------------------------------------------------------*/
|
|
96
|
+
|
|
97
|
+
// Export component
|
|
98
|
+
export default SimpleMonthChooser;
|
package/src/index.ts
CHANGED
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
getWordCount,
|
|
52
52
|
cloneDeep,
|
|
53
53
|
getTimestampFromTimeInfoInET,
|
|
54
|
+
spaceAtCapitals,
|
|
54
55
|
// Types
|
|
55
56
|
ParamType,
|
|
56
57
|
DayOfWeek,
|
|
@@ -86,6 +87,7 @@ import RadioButton from './components/RadioButton';
|
|
|
86
87
|
import CheckboxButton from './components/CheckboxButton';
|
|
87
88
|
import ButtonInputGroup from './components/ButtonInputGroup';
|
|
88
89
|
import SimpleDateChooser from './components/SimpleDateChooser';
|
|
90
|
+
import SimpleMonthChooser from './components/SimpleMonthChooser';
|
|
89
91
|
import SimpleTimeChooser from './components/SimpleTimeChooser';
|
|
90
92
|
import Drawer from './components/Drawer';
|
|
91
93
|
import PopSuccessMark from './components/PopSuccessMark';
|
|
@@ -147,6 +149,7 @@ export {
|
|
|
147
149
|
CheckboxButton,
|
|
148
150
|
ButtonInputGroup,
|
|
149
151
|
SimpleDateChooser,
|
|
152
|
+
SimpleMonthChooser,
|
|
150
153
|
SimpleTimeChooser,
|
|
151
154
|
Drawer,
|
|
152
155
|
PopSuccessMark,
|
|
@@ -253,6 +256,7 @@ export {
|
|
|
253
256
|
getWordCount,
|
|
254
257
|
cloneDeep,
|
|
255
258
|
getTimestampFromTimeInfoInET,
|
|
259
|
+
spaceAtCapitals,
|
|
256
260
|
// Types
|
|
257
261
|
ParamType,
|
|
258
262
|
DayOfWeek,
|