baseui 0.0.0-alpha-752934d → 0.0.0-alpha-29a759d

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.
@@ -44,14 +44,29 @@ function MeasureColumn(_ref) {
44
44
  _useStyletron2 = _slicedToArray(_useStyletron, 1),
45
45
  css = _useStyletron2[0];
46
46
 
47
- var ref = (0, React.useRef)();
47
+ var _React$useState = React.useState(null),
48
+ _React$useState2 = _slicedToArray(_React$useState, 2),
49
+ node = _React$useState2[0],
50
+ setNode = _React$useState2[1];
51
+
52
+ var ref = React.useCallback(function (node) {
53
+ setNode(node);
54
+ }, []);
48
55
  React.useEffect(function () {
49
56
  if (typeof document !== 'undefined') {
50
- if (ref.current) {
51
- onLayout(columnIndex, ref.current.getBoundingClientRect());
57
+ if (node) {
58
+ onLayout(columnIndex, node.getBoundingClientRect());
52
59
  }
53
60
  }
54
- }, []);
61
+ }, [node, onLayout]); // const ref = React.useRef();
62
+ // React.useEffect(() => {
63
+ // if (__BROWSER__) {
64
+ // if (ref.current) {
65
+ // onLayout(columnIndex, ref.current.getBoundingClientRect());
66
+ // }
67
+ // }
68
+ // }, []);
69
+
55
70
  return /*#__PURE__*/React.createElement("div", {
56
71
  ref: ref,
57
72
  className: css({
@@ -139,6 +154,7 @@ function MeasureColumnWidths(_ref2) {
139
154
  return generateSampleIndices(0, rows.length - 1, sampleSize);
140
155
  }, [columns, rows, widths, sampleSize]);
141
156
  var handleDimensionsChange = React.useCallback(function (columnIndex, dimensions) {
157
+ console.log('handle dimensions change', columnIndex, dimensions);
142
158
  var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
143
159
 
144
160
  if (nextWidth !== widthMap.get(columnIndex)) {
@@ -25,15 +25,26 @@ function MeasureColumn({
25
25
  }) {
26
26
  const [css] = useStyletron();
27
27
 
28
- const ref = useRef();
29
-
28
+ const [node, setNode] = React.useState(null);
29
+ const ref = React.useCallback(node => {
30
+ setNode(node);
31
+ }, []);
30
32
  React.useEffect(() => {
31
33
  if (__BROWSER__) {
32
- if (ref.current) {
33
- onLayout(columnIndex, ref.current.getBoundingClientRect());
34
+ if (node) {
35
+ onLayout(columnIndex, node.getBoundingClientRect());
34
36
  }
35
37
  }
36
- }, []);
38
+ }, [node, onLayout]);
39
+
40
+ // const ref = React.useRef();
41
+ // React.useEffect(() => {
42
+ // if (__BROWSER__) {
43
+ // if (ref.current) {
44
+ // onLayout(columnIndex, ref.current.getBoundingClientRect());
45
+ // }
46
+ // }
47
+ // }, []);
37
48
 
38
49
  return (
39
50
  <div
@@ -134,6 +145,7 @@ export default function MeasureColumnWidths({
134
145
 
135
146
  const handleDimensionsChange = React.useCallback(
136
147
  (columnIndex, dimensions) => {
148
+ console.log('handle dimensions change', columnIndex, dimensions);
137
149
  const nextWidth = Math.min(
138
150
  Math.max(
139
151
  columns[columnIndex].minWidth || 0,
@@ -18,14 +18,25 @@ function MeasureColumn({
18
18
  onLayout
19
19
  }) {
20
20
  const [css] = useStyletron();
21
- const ref = useRef();
21
+ const [node, setNode] = React.useState(null);
22
+ const ref = React.useCallback(node => {
23
+ setNode(node);
24
+ }, []);
22
25
  React.useEffect(() => {
23
26
  if (typeof document !== 'undefined') {
24
- if (ref.current) {
25
- onLayout(columnIndex, ref.current.getBoundingClientRect());
27
+ if (node) {
28
+ onLayout(columnIndex, node.getBoundingClientRect());
26
29
  }
27
30
  }
28
- }, []);
31
+ }, [node, onLayout]); // const ref = React.useRef();
32
+ // React.useEffect(() => {
33
+ // if (__BROWSER__) {
34
+ // if (ref.current) {
35
+ // onLayout(columnIndex, ref.current.getBoundingClientRect());
36
+ // }
37
+ // }
38
+ // }, []);
39
+
29
40
  return /*#__PURE__*/React.createElement("div", {
30
41
  ref: ref,
31
42
  className: css({
@@ -107,6 +118,7 @@ export default function MeasureColumnWidths({
107
118
  return generateSampleIndices(0, rows.length - 1, sampleSize);
108
119
  }, [columns, rows, widths, sampleSize]);
109
120
  const handleDimensionsChange = React.useCallback((columnIndex, dimensions) => {
121
+ console.log('handle dimensions change', columnIndex, dimensions);
110
122
  const nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
111
123
 
112
124
  if (nextWidth !== widthMap.get(columnIndex)) {
@@ -44,10 +44,12 @@ class TimezonePicker extends React.Component {
44
44
  }
45
45
  }
46
46
 
47
+ const offsetMinutes = offset * 60;
47
48
  timezones.push({
48
49
  id: zoneName,
49
50
  label,
50
- offset
51
+ // offset output is in minutes, difference of UTC and this zone (negative for hours ahead of UTC, positive for hours behind)
52
+ offset: offsetMinutes === 0 ? 0 : offsetMinutes * -1
51
53
  });
52
54
  } catch (error) {
53
55
  // Ignores timezones that are not available within a user's browser/operating system
@@ -33,14 +33,29 @@ function MeasureColumn(_ref) {
33
33
  _useStyletron2 = _slicedToArray(_useStyletron, 1),
34
34
  css = _useStyletron2[0];
35
35
 
36
- var ref = useRef();
36
+ var _React$useState = React.useState(null),
37
+ _React$useState2 = _slicedToArray(_React$useState, 2),
38
+ node = _React$useState2[0],
39
+ setNode = _React$useState2[1];
40
+
41
+ var ref = React.useCallback(function (node) {
42
+ setNode(node);
43
+ }, []);
37
44
  React.useEffect(function () {
38
45
  if (typeof document !== 'undefined') {
39
- if (ref.current) {
40
- onLayout(columnIndex, ref.current.getBoundingClientRect());
46
+ if (node) {
47
+ onLayout(columnIndex, node.getBoundingClientRect());
41
48
  }
42
49
  }
43
- }, []);
50
+ }, [node, onLayout]); // const ref = React.useRef();
51
+ // React.useEffect(() => {
52
+ // if (__BROWSER__) {
53
+ // if (ref.current) {
54
+ // onLayout(columnIndex, ref.current.getBoundingClientRect());
55
+ // }
56
+ // }
57
+ // }, []);
58
+
44
59
  return /*#__PURE__*/React.createElement("div", {
45
60
  ref: ref,
46
61
  className: css({
@@ -128,6 +143,7 @@ export default function MeasureColumnWidths(_ref2) {
128
143
  return generateSampleIndices(0, rows.length - 1, sampleSize);
129
144
  }, [columns, rows, widths, sampleSize]);
130
145
  var handleDimensionsChange = React.useCallback(function (columnIndex, dimensions) {
146
+ console.log('handle dimensions change', columnIndex, dimensions);
131
147
  var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
132
148
 
133
149
  if (nextWidth !== widthMap.get(columnIndex)) {
@@ -98,10 +98,12 @@ var TimezonePicker = /*#__PURE__*/function (_React$Component) {
98
98
  }
99
99
  }
100
100
 
101
+ var offsetMinutes = offset * 60;
101
102
  timezones.push({
102
103
  id: zoneName,
103
104
  label: label,
104
- offset: offset
105
+ // offset output is in minutes, difference of UTC and this zone (negative for hours ahead of UTC, positive for hours behind)
106
+ offset: offsetMinutes === 0 ? 0 : offsetMinutes * -1
105
107
  });
106
108
  } catch (error) {
107
109
  // Ignores timezones that are not available within a user's browser/operating system
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baseui",
3
- "version": "0.0.0-alpha-752934d",
3
+ "version": "0.0.0-alpha-29a759d",
4
4
  "description": "A React Component library implementing the Base design language",
5
5
  "keywords": [
6
6
  "react",
@@ -107,10 +107,12 @@ var TimezonePicker = /*#__PURE__*/function (_React$Component) {
107
107
  }
108
108
  }
109
109
 
110
+ var offsetMinutes = offset * 60;
110
111
  timezones.push({
111
112
  id: zoneName,
112
113
  label: label,
113
- offset: offset
114
+ // offset output is in minutes, difference of UTC and this zone (negative for hours ahead of UTC, positive for hours behind)
115
+ offset: offsetMinutes === 0 ? 0 : offsetMinutes * -1
114
116
  });
115
117
  } catch (error) {
116
118
  // Ignores timezones that are not available within a user's browser/operating system
@@ -73,10 +73,13 @@ class TimezonePicker extends React.Component<
73
73
  }
74
74
  }
75
75
 
76
+ const offsetMinutes = offset * 60;
77
+
76
78
  timezones.push({
77
79
  id: zoneName,
78
80
  label,
79
- offset,
81
+ // offset output is in minutes, difference of UTC and this zone (negative for hours ahead of UTC, positive for hours behind)
82
+ offset: offsetMinutes === 0 ? 0 : offsetMinutes * -1,
80
83
  });
81
84
  } catch (error) {
82
85
  // Ignores timezones that are not available within a user's browser/operating system
@@ -22,6 +22,11 @@ export type TimezonePickerStateT = {
22
22
  export type TimezoneT = {
23
23
  id: string,
24
24
  label: string,
25
+ /**
26
+ * The difference, in minutes, between a UTC date, and a date in the indicated time zone.
27
+ * Positive values indicate hours behind UTC, negative values indicate hours ahead.
28
+ * This aligns with Date.getTimezoneOffset()
29
+ */
25
30
  offset: number,
26
31
  };
27
32
  export type TimezonePickerPropsT = {