@spaced-out/ui-design-system 0.1.100 → 0.1.101

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.
@@ -90,6 +90,8 @@ senseai
90
90
  Stapleton
91
91
  storysource
92
92
  superrover
93
+ sharad
94
+ kushwah
93
95
  Syowa
94
96
  systemjs
95
97
  tablist
@@ -22,7 +22,7 @@ jobs:
22
22
  - name: Check Permissions
23
23
  id: check-permissions
24
24
  env:
25
- ALLOWED_USERS: superrover, Anant-Raj, ashwini-sensehq, vish-sah, VishalBarnawal, sanskar-s, VivekJangid
25
+ ALLOWED_USERS: superrover, Anant-Raj, ashwini-sensehq, vish-sah, VishalBarnawal, sanskar-s, VivekJangid, sharad-kushwah
26
26
  if: ${{ !contains(env.ALLOWED_USERS, github.actor) }}
27
27
  run: |
28
28
  echo "You don't have correct permissions to do this release"
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.101](https://github.com/spaced-out/ui-design-system/compare/v0.1.100...v0.1.101) (2024-06-21)
6
+
7
+
8
+ ### Features
9
+
10
+ * [GDS-413] tz offset in dateRangePicker prop ([#230](https://github.com/spaced-out/ui-design-system/issues/230)) ([e155e85](https://github.com/spaced-out/ui-design-system/commit/e155e85779589fd0a3c31dbeb5818f212415bf48))
11
+ * timeZone changed to timezone ([#231](https://github.com/spaced-out/ui-design-system/issues/231)) ([1a680f0](https://github.com/spaced-out/ui-design-system/commit/1a680f02d49095cc53a6c1d7a785e05cb6648f65))
12
+
5
13
  ### [0.1.100](https://github.com/spaced-out/ui-design-system/compare/v0.1.99...v0.1.100) (2024-06-13)
6
14
 
7
15
 
@@ -21,16 +21,17 @@ const DateRangePicker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
21
21
  onApply,
22
22
  onCancel,
23
23
  classNames,
24
- initialDateRange = {}
24
+ selectedDateRange = {},
25
+ hideTimezone = false
25
26
  } = _ref;
26
27
  const today = (0, _utils.formatIsoDate)();
27
- const currentTimezone = _momentTimezone.default.tz.guess();
28
28
  const {
29
+ timezone: initialTimezone,
29
30
  dateRange: initialRange,
30
31
  monthRange
31
- } = (0, _utils.getInitialDates)(initialDateRange);
32
+ } = (0, _utils.getInitialDates)(selectedDateRange);
32
33
  const [dateRange, setDateRange] = React.useState(initialRange);
33
- const [timeZone, setTimeZone] = React.useState(currentTimezone);
34
+ const [timezone, setTimezone] = React.useState(initialTimezone);
34
35
  const [rangeStartMonth, setRangeStartMonth] = React.useState(monthRange.rangeStartMonth);
35
36
  const [rangeEndMonth, setRangeEndMonth] = React.useState(monthRange.rangeEndMonth);
36
37
  const [hoverDay, setHoverDay] = React.useState('');
@@ -92,14 +93,15 @@ const DateRangePicker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
92
93
  handlers: handlers,
93
94
  hoverDay: hoverDay,
94
95
  onCancel: onCancel,
95
- timeZone: timeZone,
96
+ timezone: timezone,
96
97
  dateRange: dateRange,
97
- setTimeZone: setTimeZone,
98
+ setTimezone: setTimezone,
98
99
  rangeStartMonth: rangeStartMonth,
99
100
  rangeEndMonth: rangeEndMonth,
100
101
  inHoverRange: inHoverRange,
101
102
  setRangeStartMonth: setRangeStartMonthValidated,
102
103
  setRangeEndMonth: setRangeEndMonthValidated,
104
+ hideTimezone: hideTimezone,
103
105
  cardWrapperClass: (0, _classify.default)(_DateRangePickerModule.default.container, classNames?.wrapper)
104
106
  });
105
107
  });
@@ -25,9 +25,10 @@ type ClassNames = $ReadOnly<{wrapper?: string}>;
25
25
 
26
26
  export type DateRangePickerProps = {
27
27
  classNames?: ClassNames,
28
- initialDateRange?: DateRange,
28
+ selectedDateRange?: DateRangeWithTimezone,
29
29
  onApply: (datePickerSelectedRange: DateRangeWithTimezone) => void,
30
30
  onCancel: () => void,
31
+ hideTimezone?: boolean,
31
32
  };
32
33
 
33
34
  export const DateRangePicker: React$AbstractComponent<
@@ -39,18 +40,21 @@ export const DateRangePicker: React$AbstractComponent<
39
40
  onApply,
40
41
  onCancel,
41
42
  classNames,
42
- initialDateRange = {},
43
+ selectedDateRange = {},
44
+ hideTimezone = false,
43
45
  }: DateRangePickerProps,
44
46
  ref,
45
47
  ): React.Node => {
46
48
  const today = formatIsoDate();
47
- const currentTimezone = moment.tz.guess();
48
49
 
49
- const {dateRange: initialRange, monthRange} =
50
- getInitialDates(initialDateRange);
50
+ const {
51
+ timezone: initialTimezone,
52
+ dateRange: initialRange,
53
+ monthRange,
54
+ } = getInitialDates(selectedDateRange);
51
55
 
52
56
  const [dateRange, setDateRange] = React.useState<DateRange>(initialRange);
53
- const [timeZone, setTimeZone] = React.useState<string>(currentTimezone);
57
+ const [timezone, setTimezone] = React.useState<string>(initialTimezone);
54
58
  const [rangeStartMonth, setRangeStartMonth] = React.useState<string>(
55
59
  monthRange.rangeStartMonth,
56
60
  );
@@ -156,14 +160,15 @@ export const DateRangePicker: React$AbstractComponent<
156
160
  handlers={handlers}
157
161
  hoverDay={hoverDay}
158
162
  onCancel={onCancel}
159
- timeZone={timeZone}
163
+ timezone={timezone}
160
164
  dateRange={dateRange}
161
- setTimeZone={setTimeZone}
165
+ setTimezone={setTimezone}
162
166
  rangeStartMonth={rangeStartMonth}
163
167
  rangeEndMonth={rangeEndMonth}
164
168
  inHoverRange={inHoverRange}
165
169
  setRangeStartMonth={setRangeStartMonthValidated}
166
170
  setRangeEndMonth={setRangeEndMonthValidated}
171
+ hideTimezone={hideTimezone}
167
172
  cardWrapperClass={classify(css.container, classNames?.wrapper)}
168
173
  />
169
174
  );
@@ -81,15 +81,16 @@ const DateRangeWrapper = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
81
81
  onCancel,
82
82
  handlers,
83
83
  hoverDay,
84
- timeZone,
84
+ timezone,
85
85
  dateRange,
86
86
  rangeStartMonth,
87
- setTimeZone,
87
+ setTimezone,
88
88
  rangeEndMonth,
89
89
  inHoverRange,
90
90
  setRangeStartMonth,
91
91
  setRangeEndMonth,
92
- cardWrapperClass
92
+ cardWrapperClass,
93
+ hideTimezone
93
94
  } = _ref2;
94
95
  const canNavigateCloser = (0, _momentTimezone.default)(rangeStartMonth).year() !== (0, _momentTimezone.default)(rangeEndMonth).year() || Math.abs((0, _momentTimezone.default)(rangeStartMonth).month() - (0, _momentTimezone.default)(rangeEndMonth).month()) > 1;
95
96
  const handleApplyClick = () => {
@@ -97,14 +98,14 @@ const DateRangeWrapper = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
97
98
  startDate,
98
99
  endDate
99
100
  } = dateRange;
100
- const startDateUTC = startDate && (0, _utils.addTimeZone)(startDate, timeZone);
101
- const endDateUTC = endDate && (0, _utils.addTimeZone)(endDate, timeZone);
101
+ const startDateUTC = startDate && (0, _utils.addTimezone)(startDate, timezone);
102
+ const endDateUTC = endDate && (0, _utils.addTimezone)(endDate, timezone);
102
103
  onApply({
103
104
  startDate,
104
105
  endDate,
105
106
  startDateUTC,
106
107
  endDateUTC,
107
- timeZone
108
+ timezone
108
109
  });
109
110
  };
110
111
  const {
@@ -155,13 +156,13 @@ const DateRangeWrapper = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
155
156
  value: rangeEndMonth
156
157
  }, commonProps))), /*#__PURE__*/React.createElement(_Card.CardFooter, null, /*#__PURE__*/React.createElement(_Card.CardTitle, {
157
158
  className: _DateRangeWrapperModule.default.timezoneDropdownContainer
158
- }, /*#__PURE__*/React.createElement(_Dropdown.SimpleDropdown, {
159
- options: (0, _utils.getTimeZones)(),
159
+ }, !hideTimezone && /*#__PURE__*/React.createElement(_Dropdown.SimpleDropdown, {
160
+ options: (0, _utils.getTimezones)(),
160
161
  classNames: {
161
162
  box: _DateRangeWrapperModule.default.timezoneDropdown
162
163
  },
163
- selectedKeys: [timeZone],
164
- onChange: event => setTimeZone(event.key),
164
+ selectedKeys: [timezone],
165
+ onChange: event => setTimezone(event.key),
165
166
  size: "small",
166
167
  menuVirtualization: {
167
168
  enable: true
@@ -21,12 +21,12 @@ import {ClickableIcon} from '../Icon';
21
21
  import {Calendar} from './Calendar.js';
22
22
  import type {DateRange, DateRangeWithTimezone} from './utils';
23
23
  import {
24
- addTimeZone,
24
+ addTimezone,
25
25
  generateAvailableYears,
26
26
  getAddedDate,
27
27
  getAvailableMonths,
28
28
  getMonthStartDate,
29
- getTimeZones,
29
+ getTimezones,
30
30
  MARKERS,
31
31
  MONTHS,
32
32
  NAVIGATION_ACTION,
@@ -55,11 +55,12 @@ type DateRangeWrapperProps = {
55
55
  cardWrapperClass: ?string,
56
56
  setRangeStartMonth: (string) => void,
57
57
  setRangeEndMonth: (string) => void,
58
- setTimeZone: (string) => void,
59
- timeZone: string,
58
+ setTimezone: (string) => void,
59
+ timezone: string,
60
60
  onApply: (datePickerSelectedRange: DateRangeWithTimezone) => void,
61
61
  onCancel: () => void,
62
62
  inHoverRange: (day: string) => boolean,
63
+ hideTimezone: boolean,
63
64
  handlers: {
64
65
  onDayClick: (day: string) => void,
65
66
  onDayHover: (day: string) => void,
@@ -149,15 +150,16 @@ export const DateRangeWrapper: React$AbstractComponent<
149
150
  onCancel,
150
151
  handlers,
151
152
  hoverDay,
152
- timeZone,
153
+ timezone,
153
154
  dateRange,
154
155
  rangeStartMonth,
155
- setTimeZone,
156
+ setTimezone,
156
157
  rangeEndMonth,
157
158
  inHoverRange,
158
159
  setRangeStartMonth,
159
160
  setRangeEndMonth,
160
161
  cardWrapperClass,
162
+ hideTimezone,
161
163
  }: DateRangeWrapperProps,
162
164
  ref,
163
165
  ): React.Node => {
@@ -169,14 +171,14 @@ export const DateRangeWrapper: React$AbstractComponent<
169
171
 
170
172
  const handleApplyClick = () => {
171
173
  const {startDate, endDate} = dateRange;
172
- const startDateUTC = startDate && addTimeZone(startDate, timeZone);
173
- const endDateUTC = endDate && addTimeZone(endDate, timeZone);
174
+ const startDateUTC = startDate && addTimezone(startDate, timezone);
175
+ const endDateUTC = endDate && addTimezone(endDate, timezone);
174
176
  onApply({
175
177
  startDate,
176
178
  endDate,
177
179
  startDateUTC,
178
180
  endDateUTC,
179
- timeZone,
181
+ timezone,
180
182
  });
181
183
  };
182
184
 
@@ -252,19 +254,21 @@ export const DateRangeWrapper: React$AbstractComponent<
252
254
  </CardContent>
253
255
  <CardFooter>
254
256
  <CardTitle className={css.timezoneDropdownContainer}>
255
- <SimpleDropdown
256
- options={getTimeZones()}
257
- classNames={{
258
- box: css.timezoneDropdown,
259
- }}
260
- selectedKeys={[timeZone]}
261
- onChange={(event) => setTimeZone(event.key)}
262
- size="small"
263
- menuVirtualization={{
264
- enable: true,
265
- }}
266
- allowSearch
267
- />
257
+ {!hideTimezone && (
258
+ <SimpleDropdown
259
+ options={getTimezones()}
260
+ classNames={{
261
+ box: css.timezoneDropdown,
262
+ }}
263
+ selectedKeys={[timezone]}
264
+ onChange={(event) => setTimezone(event.key)}
265
+ size="small"
266
+ menuVirtualization={{
267
+ enable: true,
268
+ }}
269
+ allowSearch
270
+ />
271
+ )}
268
272
  </CardTitle>
269
273
  <CardActions>
270
274
  <Button type="ghost" onClick={onCancel} size="small">
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.wrangleMoment = exports.isStartOfRange = exports.isStartDateEndDateSame = exports.isEndOfRange = exports.inDateRange = exports.getTimeZones = exports.getSubtractedDate = exports.getMonthStartDate = exports.getInitialDates = exports.getDaysInMonth = exports.getAvailableMonths = exports.getAddedDate = exports.generateAvailableYears = exports.formatIsoDate = exports.addTimeZone = exports.WEEKDAYS = exports.NAVIGATION_ACTION = exports.MONTHS = exports.MARKERS = void 0;
6
+ exports.wrangleMoment = exports.isStartOfRange = exports.isStartDateEndDateSame = exports.isEndOfRange = exports.inDateRange = exports.getTimezones = exports.getSubtractedDate = exports.getMonthStartDate = exports.getInitialDates = exports.getDaysInMonth = exports.getAvailableMonths = exports.getAddedDate = exports.generateAvailableYears = exports.formatIsoDate = exports.addTimezone = exports.WEEKDAYS = exports.NAVIGATION_ACTION = exports.MONTHS = exports.MARKERS = void 0;
7
7
  var _formatISO = _interopRequireDefault(require("date-fns/formatISO"));
8
8
  var _parseISO = _interopRequireDefault(require("date-fns/parseISO"));
9
9
  var _lodash = _interopRequireDefault(require("lodash"));
@@ -153,16 +153,16 @@ const getSubtractedDate = (date, subtractCount, timeUnit) => formatIsoDate((0, _
153
153
  exports.getSubtractedDate = getSubtractedDate;
154
154
  const getMonthStartDate = date => formatIsoDate((0, _momentTimezone.default)(date).startOf('M'));
155
155
  exports.getMonthStartDate = getMonthStartDate;
156
- const addTimeZone = (date, timeZone) => _momentTimezone.default.tz(date, timeZone).startOf('d').utc().toISOString();
157
- exports.addTimeZone = addTimeZone;
158
- const getTimeZones = () => Object.keys(_timezones.TIMEZONES).reduce((menuOptions, key) => {
156
+ const addTimezone = (date, timezone) => _momentTimezone.default.tz(date, timezone).startOf('d').utc().toISOString();
157
+ exports.addTimezone = addTimezone;
158
+ const getTimezones = () => Object.keys(_timezones.TIMEZONES).reduce((menuOptions, key) => {
159
159
  menuOptions.push({
160
160
  key,
161
161
  label: _timezones.TIMEZONES[key]
162
162
  });
163
163
  return menuOptions;
164
164
  }, []);
165
- exports.getTimeZones = getTimeZones;
165
+ exports.getTimezones = getTimezones;
166
166
  const generateAvailableYears = (count, firstCalendarDate, secondCalendarDate, marker) => {
167
167
  const startYear = (0, _momentTimezone.default)().year() - count + 1;
168
168
  const firstCalendarYear = (0, _momentTimezone.default)(firstCalendarDate).add(1, 'M').year();
@@ -201,12 +201,14 @@ const getAvailableMonths = (Months, first, second, marker) => {
201
201
  });
202
202
  };
203
203
  exports.getAvailableMonths = getAvailableMonths;
204
- const getInitialDates = initialDateRange => {
204
+ const getInitialDates = selectedDateRange => {
205
205
  const today = formatIsoDate();
206
+ const currentTimezone = _momentTimezone.default.tz.guess();
206
207
  const {
207
208
  startDate,
208
- endDate
209
- } = initialDateRange;
209
+ endDate,
210
+ timezone
211
+ } = selectedDateRange;
210
212
  const isStartDateValid = (0, _momentTimezone.default)(startDate).isSameOrBefore(today);
211
213
  const isEndDateValid = (0, _momentTimezone.default)(endDate).isSameOrBefore(today);
212
214
  const dateRange = startDate && endDate && isStartDateValid && isEndDateValid && (0, _momentTimezone.default)(endDate).isSameOrAfter(startDate) ? {
@@ -227,7 +229,8 @@ const getInitialDates = initialDateRange => {
227
229
  };
228
230
  return {
229
231
  dateRange,
230
- monthRange
232
+ monthRange,
233
+ timezone: timezone ?? currentTimezone
231
234
  };
232
235
  };
233
236
  exports.getInitialDates = getInitialDates;
@@ -19,13 +19,14 @@ export type DateRangeWithTimezone = {|
19
19
  ...DateRange,
20
20
  startDateUTC?: string,
21
21
  endDateUTC?: string,
22
- timeZone?: string,
22
+ timezone?: string,
23
23
  |};
24
24
 
25
25
  type MonthRange = {rangeStartMonth: string, rangeEndMonth: string};
26
- type InitialDateRanges = {
26
+ type SelectedDateRangeTimezone = {
27
27
  dateRange: DateRange,
28
28
  monthRange: MonthRange,
29
+ timezone: string,
29
30
  };
30
31
 
31
32
  export const NAVIGATION_ACTION = Object.freeze({
@@ -141,10 +142,10 @@ export const getSubtractedDate = (
141
142
  export const getMonthStartDate = (date: string): string =>
142
143
  formatIsoDate(moment(date).startOf('M'));
143
144
 
144
- export const addTimeZone = (date: string, timeZone: string): string =>
145
- moment.tz(date, timeZone).startOf('d').utc().toISOString();
145
+ export const addTimezone = (date: string, timezone: string): string =>
146
+ moment.tz(date, timezone).startOf('d').utc().toISOString();
146
147
 
147
- export const getTimeZones = (): Array<MenuOption> =>
148
+ export const getTimezones = (): Array<MenuOption> =>
148
149
  Object.keys(TIMEZONES).reduce((menuOptions, key) => {
149
150
  menuOptions.push({
150
151
  key,
@@ -206,10 +207,11 @@ export const getAvailableMonths = (
206
207
  };
207
208
 
208
209
  export const getInitialDates = (
209
- initialDateRange: DateRange,
210
- ): InitialDateRanges => {
210
+ selectedDateRange: DateRangeWithTimezone,
211
+ ): SelectedDateRangeTimezone => {
211
212
  const today = formatIsoDate();
212
- const {startDate, endDate} = initialDateRange;
213
+ const currentTimezone = moment.tz.guess();
214
+ const {startDate, endDate, timezone} = selectedDateRange;
213
215
 
214
216
  const isStartDateValid = moment(startDate).isSameOrBefore(today);
215
217
  const isEndDateValid = moment(endDate).isSameOrBefore(today);
@@ -235,5 +237,9 @@ export const getInitialDates = (
235
237
  }
236
238
 
237
239
  const monthRange = {rangeStartMonth: startMonth, rangeEndMonth: endMonth};
238
- return {dateRange, monthRange};
240
+ return {
241
+ dateRange,
242
+ monthRange,
243
+ timezone: timezone ?? currentTimezone,
244
+ };
239
245
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.100",
3
+ "version": "0.1.101",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {