dce-reactkit 4.0.0-beta-date-and-time.1 → 4.0.0-beta.1

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 (43) hide show
  1. package/.vscode/settings.json +1 -3
  2. package/README.md +20 -0
  3. package/dist/cjs/index.js +1408 -2867
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/types/components/ItemPicker/index.d.ts +0 -1
  6. package/dist/cjs/types/components/ItemPicker/index.test.d.ts +1 -0
  7. package/dist/cjs/types/components/LoadingSpinner.d.ts +2 -2
  8. package/dist/cjs/types/components/Modal/ModalProps.d.ts +0 -2
  9. package/dist/cjs/types/components/SimpleDateChooser.d.ts +1 -3
  10. package/dist/cjs/types/components/TabBox.d.ts +0 -1
  11. package/dist/cjs/types/components/Tooltip.d.ts +1 -1
  12. package/dist/cjs/types/index.d.ts +1 -6
  13. package/dist/cjs/types/types/ReactKitErrorCode.d.ts +1 -3
  14. package/dist/esm/index.js +1423 -2878
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/types/components/ItemPicker/index.d.ts +0 -1
  17. package/dist/esm/types/components/ItemPicker/index.test.d.ts +1 -0
  18. package/dist/esm/types/components/LoadingSpinner.d.ts +2 -2
  19. package/dist/esm/types/components/Modal/ModalProps.d.ts +0 -2
  20. package/dist/esm/types/components/SimpleDateChooser.d.ts +1 -3
  21. package/dist/esm/types/components/TabBox.d.ts +0 -1
  22. package/dist/esm/types/components/Tooltip.d.ts +1 -1
  23. package/dist/esm/types/index.d.ts +1 -6
  24. package/dist/esm/types/types/ReactKitErrorCode.d.ts +1 -3
  25. package/dist/index.d.ts +19 -77
  26. package/package.json +10 -6
  27. package/src/components/IntelliTable.tsx +1 -1
  28. package/src/components/ItemPicker/NestableItemList.tsx +0 -1
  29. package/src/components/ItemPicker/index.tsx +0 -96
  30. package/src/components/LogReviewer.tsx +2 -2
  31. package/src/components/Modal/ModalProps.ts +0 -4
  32. package/src/components/Modal/index.tsx +20 -59
  33. package/src/components/SimpleDateChooser.tsx +26 -62
  34. package/src/components/TabBox.tsx +9 -27
  35. package/src/components/Tooltip.tsx +1 -1
  36. package/src/index.ts +0 -10
  37. package/src/types/ReactKitErrorCode.tsx +1 -3
  38. package/dist/cjs/types/components/SimpleTimeChooser.d.ts +0 -20
  39. package/dist/cjs/types/helpers/getWordCount.d.ts +0 -10
  40. package/dist/esm/types/components/SimpleTimeChooser.d.ts +0 -20
  41. package/dist/esm/types/helpers/getWordCount.d.ts +0 -10
  42. package/src/components/SimpleTimeChooser.tsx +0 -195
  43. package/src/helpers/getWordCount.ts +0 -26
@@ -1,195 +0,0 @@
1
- /**
2
- * A very simple, lightweight time chooser
3
- * @author Gardenia Liu
4
- */
5
-
6
- // Import React
7
- import React from 'react';
8
-
9
- // Import helpers
10
- import padZerosLeft from '../helpers/padZerosLeft';
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 hour of the day (24hr)
22
- hour: number,
23
- // Currently selected minute within the hour
24
- minute: number,
25
- /**
26
- * Handler for when time changes
27
- * @param hour new 24hr hour number
28
- * @param minute new minute number
29
- */
30
- onChange: (hour: number, minute: number) => void,
31
- // Interval in minutes between each choice
32
- // Allowed options: 15, 30, 60, defaults to 15
33
- // If an unsupported interval is passed in, it will default to 15
34
- intervalMin?: number,
35
- };
36
-
37
- /*------------------------------------------------------------------------*/
38
- /* ------------------------------ Constants ----------------------------- */
39
- /*------------------------------------------------------------------------*/
40
-
41
- // Allowed intervals between options
42
- const ALLOWED_INTERVALS = [15, 30, 60]; // min
43
-
44
- // Default interval to use if an unsupported interval is passed in
45
- const DEFAULT_INTERVAL = ALLOWED_INTERVALS[0]; // min
46
-
47
- /*------------------------------------------------------------------------*/
48
- /* ------------------------------ Component ----------------------------- */
49
- /*------------------------------------------------------------------------*/
50
-
51
- const SimpleTimeChooser: React.FC<Props> = (props) => {
52
- /*------------------------------------------------------------------------*/
53
- /* -------------------------------- Setup ------------------------------- */
54
- /*------------------------------------------------------------------------*/
55
-
56
- /* -------------- Props ------------- */
57
-
58
- const {
59
- ariaLabel,
60
- name,
61
- hour,
62
- minute,
63
- onChange,
64
- } = props;
65
- let {
66
- intervalMin = DEFAULT_INTERVAL,
67
- } = props;
68
-
69
- // Use default interval if not supported
70
- if (ALLOWED_INTERVALS.includes(intervalMin)) {
71
- intervalMin = DEFAULT_INTERVAL;
72
- }
73
-
74
- /*------------------------------------------------------------------------*/
75
- /* ------------------------- Component Functions ------------------------ */
76
- /*------------------------------------------------------------------------*/
77
-
78
- /**
79
- * Convert number of minutes since midnight into 24hour and minute format
80
- * @author Gabe Abrams
81
- * @param minSinceMidnight total minutes since midnight
82
- * @returns hours (24) and minutes
83
- */
84
- const convertMinSinceMidnightToHoursAndMin = (minSinceMidnight: number): {
85
- hours: number,
86
- minutes: number,
87
- } => {
88
- return {
89
- hours: Math.floor(minSinceMidnight / 60),
90
- minutes: minSinceMidnight % 60,
91
- };
92
- };
93
-
94
- /**
95
- * Convert time in minutes into HH:MM format
96
- * @author Gardenia Liu
97
- * @param totalMinutes total minutes since midnight
98
- * @returns formatted time string
99
- */
100
- const formatTime = (totalMinutes: number): string => {
101
- // Handle special cases
102
- if (totalMinutes === 0) {
103
- return '12:00 Midnight';
104
- }
105
- if (totalMinutes === 12 * 60) {
106
- return '12:00 Noon';
107
- }
108
-
109
- // All normal cases:
110
- const timeInfo = convertMinSinceMidnightToHoursAndMin(totalMinutes);
111
- let { hours } = timeInfo;
112
- const { minutes } = timeInfo;
113
-
114
- // Process 24hr -> 12hr
115
- const isAM = (hours < 12);
116
- if (hours === 0) {
117
- hours = 12;
118
- } else if (hours > 12) {
119
- hours %= 12;
120
- }
121
-
122
- // Pad with zeros
123
- const paddedMinutes = padZerosLeft(minutes, 2);
124
-
125
- // Assemble time string
126
- return `${hours}:${paddedMinutes} ${isAM ? 'AM' : 'PM'}`;
127
- };
128
-
129
- /*------------------------------------------------------------------------*/
130
- /* ------------------------------- Render ------------------------------- */
131
- /*------------------------------------------------------------------------*/
132
-
133
- /*----------------------------------------*/
134
- /* --------------- Main UI -------------- */
135
- /*----------------------------------------*/
136
-
137
- // Generate list of time options
138
- const times: string[] = [];
139
- for (let time = 0; time < 24 * 60; time += intervalMin) {
140
- times.push(formatTime(time));
141
- }
142
-
143
- // Create choice options
144
- const selectedTimeMin = hour * 60 + minute; // minutes since midnight
145
- const timeOptions: React.ReactNode[] = times.map((timeString, timeIndex) => {
146
- // Create time option
147
- const numMinutesForChoice = timeIndex * intervalMin;
148
-
149
- // Render the option
150
- return (
151
- <option
152
- key={numMinutesForChoice}
153
- value={numMinutesForChoice}
154
- aria-label={`choose ${timeString}`}
155
- >
156
- {timeString}
157
- </option>
158
- );
159
- });
160
-
161
- return (
162
- <div
163
- className="SimpleTimeChooser-container"
164
- aria-label={`time chooser with selected time: ${formatTime(selectedTimeMin)}`}
165
- >
166
- {/* Time Chooser */}
167
- <select
168
- aria-label={`time for ${ariaLabel}`}
169
- className="custom-select d-inline-block"
170
- style={{ width: 'auto' }}
171
- id={`SimpleTimeChooser-${name}-time`}
172
- value={selectedTimeMin}
173
- onChange={(e) => {
174
- // Parse selector value (string)
175
- const newTime = Number.parseInt(e.target.value, 10);
176
-
177
- // Convert minutes since midnight to hour and minute
178
- const timeInfo = convertMinSinceMidnightToHoursAndMin(newTime);
179
-
180
- // Notify parent of change
181
- onChange(timeInfo.hours, timeInfo.minutes);
182
- }}
183
- >
184
- {timeOptions}
185
- </select>
186
- </div>
187
- );
188
- };
189
-
190
- /*------------------------------------------------------------------------*/
191
- /* ------------------------------- Wrap Up ------------------------------ */
192
- /*------------------------------------------------------------------------*/
193
-
194
- // Export component
195
- export default SimpleTimeChooser;
@@ -1,26 +0,0 @@
1
- const punctuationRegex = /[!@#$%^&*(),.?\/;:'"\-\[\]]/g;
2
-
3
- /**
4
- * Get number of words in string
5
- * @author Gardenia Liu
6
- * @author Allison Zhang
7
- * @author Gabe Abrams
8
- * @param text the string to check
9
- * @returns number of words in the string
10
- */
11
- const getWordCount = (text: string): number => {
12
- const trimmedTextWithoutPunctuation = (
13
- text
14
- // Remove leading and trailing whitespace
15
- .trim()
16
- // Remove punctuation
17
- .replace(punctuationRegex, '')
18
- );
19
- if (trimmedTextWithoutPunctuation.length === 0) {
20
- return 0;
21
- }
22
-
23
- return trimmedTextWithoutPunctuation.split(/\s+/g).length;
24
- };
25
-
26
- export default getWordCount;