@ndlib/component-library 1.0.16 → 1.0.17

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.
@@ -16,7 +16,7 @@ export const Checkbox = (_a) => {
16
16
  const theme = useTheme();
17
17
  return (_jsx("input", Object.assign({ type: "checkbox", onChange: (e) => {
18
18
  onChange(e.target.checked);
19
- }, checked: checked, sx: Object.assign({ margin: '0px', height: '1.25rem', width: '1.25rem', cursor: disabled ? 'not-allowed' : 'pointer', ':hover': {
19
+ }, checked: checked, sx: Object.assign({ margin: '0px', height: '1rem', width: '1rem', cursor: disabled ? 'not-allowed' : 'pointer', ':hover': {
20
20
  boxShadow: theme.boxShadow,
21
21
  } }, sx), disabled: disabled }, rest)));
22
22
  };
@@ -18,14 +18,34 @@ export const Default = {
18
18
  render: () => (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulDatePicker, { placeholder: "test" }) }))),
19
19
  };
20
20
  export const Inline = {
21
- render: () => (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulDatePicker, { inline: true }) }))),
21
+ argTypes: {
22
+ backgroundColor: {
23
+ options: ['blue', 'gold', 'green', 'red'],
24
+ control: {
25
+ type: 'select',
26
+ },
27
+ },
28
+ },
29
+ render: (args) => {
30
+ const { backgroundColor } = args;
31
+ return (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulDatePicker, { backgroundColor: backgroundColor, inline: true }) })));
32
+ },
22
33
  };
23
34
  export const HighlightedDates = {
24
- render: () => {
35
+ argTypes: {
36
+ backgroundColor: {
37
+ options: ['blue', 'gold', 'green', 'red'],
38
+ control: {
39
+ type: 'select',
40
+ },
41
+ },
42
+ },
43
+ render: (args) => {
44
+ const { backgroundColor } = args;
25
45
  const highlightedDate1 = new Date();
26
46
  highlightedDate1.setDate(highlightedDate1.getDate() + 1);
27
47
  const highlightedDate2 = new Date();
28
48
  highlightedDate2.setDate(highlightedDate2.getDate() - 1);
29
- return (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulDatePicker, { inline: true, highlightDates: [highlightedDate1, highlightedDate2] }) })));
49
+ return (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulDatePicker, { inline: true, backgroundColor: backgroundColor, highlightDates: [highlightedDate1, highlightedDate2] }) })));
30
50
  },
31
51
  };
@@ -9,12 +9,14 @@ export declare const InputWrapper: React.ForwardRefExoticComponent<{
9
9
  children: React.ReactElement;
10
10
  } & React.RefAttributes<any>>;
11
11
  export declare const areDatesEqual: (d1: Date, d2: Date) => boolean;
12
+ export declare const isDateInThePast: (d1: Date, d2: Date) => boolean;
12
13
  export declare const DatePicker: React.FC<{
13
14
  value: Date;
14
15
  onChange: (date: Date) => void;
15
16
  minDate?: Date;
16
17
  maxDate?: Date;
17
18
  inline?: boolean;
19
+ backgroundColor?: string;
18
20
  highlightDates?: Date[];
19
21
  wrapperProps?: BoxProps;
20
22
  inputProps?: Partial<TextInputProps>;
@@ -33,13 +33,22 @@ export const areDatesEqual = (d1, d2) => {
33
33
  const serializeDate = (d) => `${d.getFullYear()} ${d.getMonth()} ${d.getDate()}`;
34
34
  return serializeDate(d1) === serializeDate(d2);
35
35
  };
36
+ export const isDateInThePast = (d1, d2) => {
37
+ const serializeDate = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
38
+ return serializeDate(d1) < serializeDate(d2);
39
+ };
36
40
  export const DatePicker = (_a) => {
37
- var { value, wrapperProps, inputProps, highlightDates } = _a, rest = __rest(_a, ["value", "wrapperProps", "inputProps", "highlightDates"]);
41
+ var { value, wrapperProps, inputProps, backgroundColor, highlightDates } = _a, rest = __rest(_a, ["value", "wrapperProps", "inputProps", "backgroundColor", "highlightDates"]);
38
42
  const highlightDateSet = new Set(highlightDates === null || highlightDates === void 0 ? void 0 : highlightDates.map((d) => d.toDateString()));
39
- return (_jsx(Box, Object.assign({}, wrapperProps, { children: _jsx(ReactDatePicker, Object.assign({ calendarClassName: "ndlib-date-picker", selected: value, dayClassName: (date) => {
43
+ if (!backgroundColor)
44
+ backgroundColor = 'blue';
45
+ return (_jsx(Box, Object.assign({}, wrapperProps, { children: _jsx(ReactDatePicker, Object.assign({ calendarClassName: `ndlib-date-picker ndlib-date-picker-${backgroundColor}`, selected: value, dayClassName: (date) => {
40
46
  if (areDatesEqual(date, value)) {
41
47
  return '';
42
48
  }
49
+ if (isDateInThePast(date, value)) {
50
+ return 'ndlib-date-picker-pastdate';
51
+ }
43
52
  if (highlightDateSet.has(date.toDateString())) {
44
53
  return 'ndlib-date-picker-highlight';
45
54
  }
@@ -16,5 +16,16 @@ export const Default = {
16
16
  render: () => (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulMonthPicker, {}) }))),
17
17
  };
18
18
  export const Inline = {
19
- render: () => (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulMonthPicker, { inline: true }) }))),
19
+ argTypes: {
20
+ backgroundColor: {
21
+ options: ['blue', 'gold', 'green', 'red'],
22
+ control: {
23
+ type: 'select',
24
+ },
25
+ },
26
+ },
27
+ render: (args) => {
28
+ const { backgroundColor } = args;
29
+ return (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulMonthPicker, { backgroundColor: backgroundColor, inline: true }) })));
30
+ },
20
31
  };
@@ -8,6 +8,7 @@ export declare const MonthPicker: React.FC<{
8
8
  minDate?: Date;
9
9
  maxDate?: Date;
10
10
  inline?: boolean;
11
+ backgroundColor?: string;
11
12
  inputProps?: Partial<TextInputProps>;
12
13
  wrapperProps?: BoxProps;
13
14
  }>;
@@ -19,6 +19,8 @@ import { importedDefaultComponentShim } from '../../../../utils/misc';
19
19
  const ReactDatePicker = importedDefaultComponentShim(_ReactDatePicker);
20
20
  const PermissiveTextInput = TextInput;
21
21
  export const MonthPicker = (_a) => {
22
- var { value, inputProps, wrapperProps } = _a, rest = __rest(_a, ["value", "inputProps", "wrapperProps"]);
23
- return (_jsx(Box, Object.assign({}, wrapperProps, { children: _jsx(ReactDatePicker, Object.assign({ calendarClassName: "ndlib-date-picker", selected: value, customInput: _jsx(InputWrapper, { children: _jsx(PermissiveTextInput, Object.assign({}, inputProps)) }), showMonthYearPicker: true }, rest)) })));
22
+ var { value, inputProps, backgroundColor, wrapperProps } = _a, rest = __rest(_a, ["value", "inputProps", "backgroundColor", "wrapperProps"]);
23
+ if (!backgroundColor)
24
+ backgroundColor = 'blue';
25
+ return (_jsx(Box, Object.assign({}, wrapperProps, { children: _jsx(ReactDatePicker, Object.assign({ calendarClassName: `ndlib-date-picker ndlib-date-picker-${backgroundColor}`, selected: value, customInput: _jsx(InputWrapper, { children: _jsx(PermissiveTextInput, Object.assign({}, inputProps)) }), showMonthYearPicker: true }, rest)) })));
24
26
  };
@@ -34,6 +34,7 @@ const colors = [
34
34
  { color: COLOR.ND_GREEN, label: 'ND_GREEN' },
35
35
  { color: COLOR.ND_GREEN_LIGHT, label: 'ND_GREEN_LIGHT' },
36
36
  { color: COLOR.ND_METALLIC_GOLD, label: 'ND_METALLIC_GOLD' },
37
+ { color: COLOR.ND_METALLIC_GOLD_LIGHT, label: 'ND_METALLIC_GOLD_LIGHT' },
37
38
  { color: COLOR.ND_PROVOST_BLUE, label: 'ND_PROVOST_BLUE' },
38
39
  { color: COLOR.ND_SECONDARY_1, label: 'ND_SECONDARY_1' },
39
40
  { color: COLOR.ND_SECONDARY_2, label: 'ND_SECONDARY_2' },
@@ -137,14 +137,42 @@ const globalStyles = css `
137
137
  border-spacing: 0;
138
138
  }
139
139
 
140
- .ndlib-date-picker .react-datepicker__header,
141
- .ndlib-date-picker .react-datepicker__header * {
142
- color: white;
140
+ .react-datepicker {
141
+ border: 0 !important;
142
+ border-radius: 0 !important;
143
+ }
144
+
145
+ .ndlib-date-picker-blue .react-datepicker__header,
146
+ .ndlib-date-picker-blue .react-datepicker__header * {
143
147
  background-color: ${colors.primary};
148
+ color: white;
149
+ }
150
+
151
+ .ndlib-date-picker-gold .react-datepicker__header,
152
+ .ndlib-date-picker-gold .react-datepicker__header * {
153
+ background-color: ${colors.ndMetallicGold};
154
+ color: white;
155
+ }
156
+
157
+ .ndlib-date-picker-green .react-datepicker__header,
158
+ .ndlib-date-picker-green .react-datepicker__header * {
159
+ background-color: ${colors.ndGreem};
160
+ color: white;
161
+ }
162
+
163
+ .ndlib-date-picker-red .react-datepicker__header,
164
+ .ndlib-date-picker-red .react-datepicker__header * {
165
+ background-color: ${colors.ndTertiary4};
166
+ color: white;
167
+ }
168
+
169
+ .react-datepicker__header:not(.react-datepicker__header--has-time-select) {
170
+ border-top-right-radius: 0 !important;
144
171
  }
145
172
 
146
173
  .ndlib-date-picker .react-datepicker__header {
147
174
  width: 280px;
175
+ border-radius: 0;
148
176
  }
149
177
 
150
178
  .ndlib-date-picker .react-datepicker__day-names {
@@ -157,8 +185,12 @@ const globalStyles = css `
157
185
 
158
186
  .ndlib-date-picker .ndlib-date-picker-highlight {
159
187
  background-color: ${colors.ndTertiary1};
160
- border-radius: 0.3rem;
161
188
  color: ${colors.background};
189
+ border-radius: 0.3rem;
190
+ }
191
+
192
+ .ndlib-date-picker .ndlib-date-picker-pastdate {
193
+ color: ${colors.lightGray};
162
194
  }
163
195
 
164
196
  @font-face {
@@ -32,6 +32,7 @@ export declare enum COLOR {
32
32
  ND_SKY_BLUE_DARK = "ndSkyBlueDark",
33
33
  ND_SKY_BLUE_LIGHT = "ndSkyBlueLight",
34
34
  ND_METALLIC_GOLD = "ndMetallicGold",
35
+ ND_METALLIC_GOLD_LIGHT = "ndMetallicGoldLight",
35
36
  ND_PROVOST_BLUE = "ndProvostBlue",
36
37
  ND_SECONDARY_1 = "ndSecondary1",
37
38
  ND_SECONDARY_2 = "ndSecondary2",
@@ -33,6 +33,7 @@ export var COLOR;
33
33
  COLOR["ND_SKY_BLUE_DARK"] = "ndSkyBlueDark";
34
34
  COLOR["ND_SKY_BLUE_LIGHT"] = "ndSkyBlueLight";
35
35
  COLOR["ND_METALLIC_GOLD"] = "ndMetallicGold";
36
+ COLOR["ND_METALLIC_GOLD_LIGHT"] = "ndMetallicGoldLight";
36
37
  COLOR["ND_PROVOST_BLUE"] = "ndProvostBlue";
37
38
  COLOR["ND_SECONDARY_1"] = "ndSecondary1";
38
39
  COLOR["ND_SECONDARY_2"] = "ndSecondary2";
@@ -88,6 +89,7 @@ export const colors = {
88
89
  [COLOR.ND_SKY_BLUE_DARK]: '#c1cddd',
89
90
  [COLOR.ND_SKY_BLUE_LIGHT]: '#edf2f9',
90
91
  [COLOR.ND_METALLIC_GOLD]: '#ae9142',
92
+ [COLOR.ND_METALLIC_GOLD_LIGHT]: '#CEBE8E',
91
93
  [COLOR.ND_PROVOST_BLUE]: '#002a5d',
92
94
  [COLOR.ND_SECONDARY_1]: '#5aabbc',
93
95
  [COLOR.ND_SECONDARY_2]: '#999623',
@@ -50,6 +50,7 @@ export declare const theme: {
50
50
  ndSkyBlueDark: string;
51
51
  ndSkyBlueLight: string;
52
52
  ndMetallicGold: string;
53
+ ndMetallicGoldLight: string;
53
54
  ndProvostBlue: string;
54
55
  ndSecondary1: string;
55
56
  ndSecondary2: string;
@@ -154,6 +155,7 @@ export declare const useTheme: () => {
154
155
  ndSkyBlueDark: string;
155
156
  ndSkyBlueLight: string;
156
157
  ndMetallicGold: string;
158
+ ndMetallicGoldLight: string;
157
159
  ndProvostBlue: string;
158
160
  ndSecondary1: string;
159
161
  ndSecondary2: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [