dash-core-components 4.0.0-rc2 → 4.0.0-rc4

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 (71) hide show
  1. package/dash_core_components/async-datepicker.js +1 -1
  2. package/dash_core_components/async-datepicker.js.map +1 -1
  3. package/dash_core_components/async-dropdown.js +1 -2
  4. package/dash_core_components/async-dropdown.js.map +1 -1
  5. package/dash_core_components/async-graph.js +1 -1
  6. package/dash_core_components/async-graph.js.map +1 -1
  7. package/dash_core_components/async-highlight.js +1 -1
  8. package/dash_core_components/async-highlight.js.map +1 -1
  9. package/dash_core_components/async-markdown.js +1 -1
  10. package/dash_core_components/async-markdown.js.map +1 -1
  11. package/dash_core_components/async-mathjax.js +1 -1
  12. package/dash_core_components/async-slider.js +1 -1
  13. package/dash_core_components/async-slider.js.map +1 -1
  14. package/dash_core_components/async-upload.js +1 -1
  15. package/dash_core_components/async-upload.js.map +1 -1
  16. package/dash_core_components/dash_core_components-shared.js +1 -1
  17. package/dash_core_components/dash_core_components-shared.js.map +1 -1
  18. package/dash_core_components/dash_core_components.js +1 -1
  19. package/dash_core_components/dash_core_components.js.map +1 -1
  20. package/dash_core_components/proptypes.js +153 -14
  21. package/lib/components/Button.tsx +48 -0
  22. package/lib/components/Clipboard.react.js +1 -1
  23. package/lib/components/DatePickerRange.tsx +70 -0
  24. package/lib/components/DatePickerSingle.tsx +72 -0
  25. package/lib/components/Input.tsx +12 -233
  26. package/lib/components/RadioItems.tsx +3 -1
  27. package/lib/components/Tab.tsx +19 -0
  28. package/lib/components/Tabs.tsx +311 -0
  29. package/lib/components/css/button.css +55 -0
  30. package/lib/components/css/calendar.css +66 -0
  31. package/lib/components/css/datepickers.css +239 -0
  32. package/lib/components/css/dcc.css +1 -0
  33. package/lib/components/css/dropdown.css +19 -6
  34. package/lib/components/css/input.css +9 -3
  35. package/lib/components/css/sliders.css +41 -1
  36. package/lib/components/css/tabs.css +113 -0
  37. package/lib/fragments/DatePickerRange.tsx +448 -0
  38. package/lib/fragments/DatePickerSingle.tsx +248 -0
  39. package/lib/fragments/Dropdown.tsx +44 -19
  40. package/lib/fragments/Graph.react.js +18 -45
  41. package/lib/fragments/RangeSlider.tsx +24 -66
  42. package/lib/index.ts +6 -6
  43. package/lib/types.ts +660 -28
  44. package/lib/utils/DatePickerPersistence.ts +14 -0
  45. package/lib/utils/LazyLoader/datePickerRange.ts +4 -0
  46. package/lib/utils/LazyLoader/datePickerSingle.ts +4 -0
  47. package/lib/utils/calendar/Calendar.tsx +382 -0
  48. package/lib/utils/calendar/CalendarDay.tsx +75 -0
  49. package/lib/utils/calendar/CalendarDayPadding.tsx +15 -0
  50. package/lib/utils/calendar/CalendarMonth.tsx +247 -0
  51. package/lib/utils/calendar/CalendarMonthHeader.tsx +23 -0
  52. package/lib/utils/calendar/createMonthGrid.ts +28 -0
  53. package/lib/utils/calendar/helpers.ts +272 -0
  54. package/lib/utils/computeSliderMarkers.ts +71 -116
  55. package/lib/utils/optionRendering.tsx +22 -15
  56. package/lib/utils/sliderRendering.tsx +40 -2
  57. package/package.json +16 -13
  58. package/lib/components/DatePickerRange.react.js +0 -244
  59. package/lib/components/DatePickerSingle.react.js +0 -209
  60. package/lib/components/Dropdown.react.js.old +0 -228
  61. package/lib/components/Tab.react.js +0 -80
  62. package/lib/components/Tab.react.js.old +0 -79
  63. package/lib/components/Tabs.react.js +0 -295
  64. package/lib/components/Textarea.react.js.old +0 -287
  65. package/lib/fragments/DatePickerRange.react.js +0 -188
  66. package/lib/fragments/DatePickerSingle.react.js +0 -132
  67. package/lib/utils/DatePickerPersistence.js +0 -18
  68. package/lib/utils/LazyLoader/datePickerRange.js +0 -8
  69. package/lib/utils/LazyLoader/datePickerSingle.js +0 -8
  70. package/lib/utils/convertToMoment.js +0 -30
  71. package/lib/utils/optionTypes.js +0 -39
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-magic-numbers */
1
2
  import {pickBy, isEmpty, isNil} from 'ramda';
2
3
  import {formatPrefix} from 'd3-format';
3
4
  import {SliderMarks} from '../types';
@@ -32,86 +33,75 @@ const alignDecimalValue = (v: number, d: number) =>
32
33
  const alignValue = (v: number, d: number) =>
33
34
  decimalCount(d) < 1 ? alignIntValue(v, d) : alignDecimalValue(v, d);
34
35
 
36
+ export const applyD3Format = (mark: number, min: number, max: number) => {
37
+ const mu_ten_factor = -3;
38
+ const k_ten_factor = 4; // values < 10000 don't get formatted
39
+
40
+ const ten_factor = Math.log10(Math.abs(mark));
41
+ if (
42
+ mark === 0 ||
43
+ (ten_factor > mu_ten_factor && ten_factor < k_ten_factor)
44
+ ) {
45
+ return String(mark);
46
+ }
47
+ const max_min_mean = (Math.abs(max) + Math.abs(min)) / 2;
48
+ const si_formatter = formatPrefix(',.0', max_min_mean);
49
+ return String(si_formatter(mark));
50
+ };
51
+
35
52
  const estimateBestSteps = (
36
53
  minValue: number,
37
54
  maxValue: number,
38
55
  stepValue: number,
39
56
  sliderWidth?: number | null
40
57
  ) => {
41
- // Base desired count for 330px slider with 0-100 scale (10 marks = 11 total including endpoints)
42
- let targetMarkCount = 11; // Default baseline
43
-
44
- // Scale mark density based on slider width
45
- if (sliderWidth) {
46
- const baselineWidth = 330;
47
- const baselineMarkCount = 11; // 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100
48
-
49
- // Calculate density multiplier based on width
50
- const widthMultiplier = sliderWidth / baselineWidth;
51
-
52
- // Target mark count scales with width but maintains consistent density
53
- // The range adjustment should be removed - we want consistent mark density based on width
54
- targetMarkCount = Math.round(baselineMarkCount * widthMultiplier);
55
-
56
- // Ensure reasonable bounds
57
- const UPPER_BOUND = 50;
58
- targetMarkCount = Math.max(3, Math.min(targetMarkCount, UPPER_BOUND));
59
-
60
- // Adjust density based on maximum character width of mark labels
61
- // Estimate the maximum characters in any mark label
62
- const maxValueChars = Math.max(
63
- String(minValue).length,
64
- String(maxValue).length,
65
- String(Math.abs(minValue)).length,
66
- String(Math.abs(maxValue)).length
67
- );
68
-
69
- // Baseline: 3-4 characters (like "100", "250") work well with baseline density
70
- // For longer labels, reduce density to prevent overlap
71
- const baselineChars = 3.5;
72
- if (maxValueChars > baselineChars) {
73
- const charReductionFactor = baselineChars / maxValueChars;
74
- targetMarkCount = Math.round(targetMarkCount * charReductionFactor);
75
- targetMarkCount = Math.max(2, targetMarkCount); // Ensure minimum of 2 marks
76
- }
77
- }
78
-
79
- // Calculate the ideal interval between marks based on target count
80
- const range = maxValue - minValue;
81
- let idealInterval = range / (targetMarkCount - 1);
82
-
83
- // Check if the step value is fractional and adjust density
84
- if (stepValue % 1 !== 0) {
85
- // For fractional steps, reduce mark density by half to avoid clutter
86
- targetMarkCount = Math.max(3, Math.round(targetMarkCount / 2));
87
- idealInterval = range / (targetMarkCount - 1);
88
- }
58
+ // Use formatted label length to account for SI formatting
59
+ // (e.g. labels that look like "100M" vs "100000000")
60
+ const formattedMin = applyD3Format(minValue, minValue, maxValue);
61
+ const formattedMax = applyD3Format(maxValue, minValue, maxValue);
62
+ const maxValueChars = Math.max(formattedMin.length, formattedMax.length);
89
63
 
90
- // Find the best interval that's a multiple of stepValue
91
- // Start with multiples of stepValue and find the one closest to idealInterval
92
- const stepMultipliers = [
93
- // eslint-disable-next-line no-magic-numbers
94
- 1, 2, 2.5, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000,
95
- ];
64
+ // Calculate required spacing based on label width
65
+ // Estimate: 10px per character + 20px margin for spacing between labels
66
+ // This provides comfortable spacing to prevent overlap
67
+ const pixelsPerChar = 10;
68
+ const spacingMargin = 20;
69
+ const minPixelsPerMark = maxValueChars * pixelsPerChar + spacingMargin;
96
70
 
97
- let bestInterval = stepValue;
98
- let bestDifference = Math.abs(idealInterval - stepValue);
71
+ const effectiveWidth = sliderWidth || 330;
99
72
 
100
- for (const multiplier of stepMultipliers) {
101
- const candidateInterval = stepValue * multiplier;
102
- const difference = Math.abs(idealInterval - candidateInterval);
73
+ // Calculate maximum number of marks that can fit without overlap
74
+ let targetMarkCount = Math.floor(effectiveWidth / minPixelsPerMark) + 1;
75
+ targetMarkCount = Math.max(3, Math.min(targetMarkCount, 50));
103
76
 
104
- if (difference < bestDifference) {
105
- bestInterval = candidateInterval;
106
- bestDifference = difference;
107
- }
108
-
109
- // Stop if we've gone too far beyond the ideal
110
- if (candidateInterval > idealInterval * 2) {
111
- break;
112
- }
77
+ // Calculate the ideal interval between marks based on target count
78
+ const range = maxValue - minValue;
79
+ const idealInterval = range / (targetMarkCount - 1);
80
+
81
+ // Calculate the multiplier needed to get close to idealInterval
82
+ // Round to a "nice" number for cleaner mark placement
83
+ const rawMultiplier = idealInterval / stepValue;
84
+
85
+ // Round to nearest nice multiplier (1, 2, 2.5, 5, or power of 10 multiple)
86
+ const magnitude = Math.pow(10, Math.floor(Math.log10(rawMultiplier)));
87
+ const normalized = rawMultiplier / magnitude; // Now between 1 and 10
88
+
89
+ let niceMultiplier;
90
+ if (normalized <= 1.5) {
91
+ niceMultiplier = 1;
92
+ } else if (normalized <= 2.25) {
93
+ niceMultiplier = 2;
94
+ } else if (normalized <= 3.5) {
95
+ niceMultiplier = 2.5;
96
+ } else if (normalized <= 5) {
97
+ niceMultiplier = 5;
98
+ } else {
99
+ niceMultiplier = 10;
113
100
  }
114
101
 
102
+ const bestMultiplier = Math.max(1, niceMultiplier * magnitude);
103
+ const bestInterval = stepValue * bestMultiplier;
104
+
115
105
  // All marks must be at valid step positions: minValue + (n * stepValue)
116
106
  // Find the first mark after minValue that fits our desired interval
117
107
  const stepsInInterval = Math.round(bestInterval / stepValue);
@@ -175,22 +165,6 @@ export const setUndefined = (
175
165
  return definedMarks;
176
166
  };
177
167
 
178
- export const applyD3Format = (mark: number, min: number, max: number) => {
179
- const mu_ten_factor = -3;
180
- const k_ten_factor = 3;
181
-
182
- const ten_factor = Math.log10(Math.abs(mark));
183
- if (
184
- mark === 0 ||
185
- (ten_factor > mu_ten_factor && ten_factor < k_ten_factor)
186
- ) {
187
- return String(mark);
188
- }
189
- const max_min_mean = (Math.abs(max) + Math.abs(min)) / 2;
190
- const si_formatter = formatPrefix(',.0', max_min_mean);
191
- return String(si_formatter(mark));
192
- };
193
-
194
168
  export const autoGenerateMarks = (
195
169
  min: number,
196
170
  max: number,
@@ -198,8 +172,9 @@ export const autoGenerateMarks = (
198
172
  sliderWidth?: number | null
199
173
  ) => {
200
174
  const marks = [];
201
- // Always use dynamic logic, but pass the provided step as a constraint
202
- const effectiveStep = step || calcStep(min, max, 0);
175
+
176
+ const effectiveStep = step ?? 1;
177
+
203
178
  const [start, interval, chosenStep] = estimateBestSteps(
204
179
  min,
205
180
  max,
@@ -208,38 +183,18 @@ export const autoGenerateMarks = (
208
183
  );
209
184
  let cursor = start;
210
185
 
211
- // Apply a safety cap to prevent excessive mark generation while preserving existing behavior
212
- // Only restrict when marks would be truly excessive (much higher than the existing UPPER_BOUND)
213
- const MARK_WIDTH_PX = 20; // More generous spacing for width-based calculation
214
- const FALLBACK_MAX_MARKS = 200; // High fallback to preserve existing behavior when no width
215
- const ABSOLUTE_MAX_MARKS = 200; // Safety cap against extreme cases
216
-
217
- const widthBasedMax = sliderWidth
218
- ? Math.max(10, Math.floor(sliderWidth / MARK_WIDTH_PX))
219
- : FALLBACK_MAX_MARKS;
220
-
221
- const maxAutoGeneratedMarks = Math.min(widthBasedMax, ABSOLUTE_MAX_MARKS);
222
-
223
- // Calculate how many marks would be generated with current interval
224
- const estimatedMarkCount = Math.floor((max - start) / interval) + 1;
225
-
226
- // If we would exceed the limit, increase the interval to fit within the limit
227
- let actualInterval = interval;
228
- if (estimatedMarkCount > maxAutoGeneratedMarks) {
229
- // Recalculate interval to fit exactly within the limit
230
- actualInterval = (max - start) / (maxAutoGeneratedMarks - 1);
231
- // Round to a reasonable step multiple to keep marks clean
232
- const stepMultiple = Math.ceil(actualInterval / chosenStep);
233
- actualInterval = stepMultiple * chosenStep;
234
- }
235
-
236
- if ((max - cursor) / actualInterval > 0) {
237
- do {
186
+ if ((max - cursor) / interval > 0) {
187
+ while (cursor < max) {
238
188
  marks.push(alignValue(cursor, chosenStep));
239
- cursor += actualInterval;
240
- } while (cursor < max && marks.length < maxAutoGeneratedMarks);
189
+ const prevCursor = cursor;
190
+ cursor += interval;
191
+
192
+ // Safety check: floating point precision could impact this loop
193
+ if (cursor <= prevCursor) {
194
+ break;
195
+ }
196
+ }
241
197
 
242
- // do some cosmetic
243
198
  const discardThreshold = 1.5;
244
199
  if (
245
200
  marks.length >= 2 &&
@@ -92,21 +92,28 @@ export const Option: React.FC<OptionProps> = ({
92
92
  aria-selected={isSelected}
93
93
  style={optionStyle}
94
94
  >
95
- <input
96
- type={inputType}
97
- checked={isSelected}
98
- name={id}
99
- value={
100
- typeof option.value === 'boolean'
101
- ? `${option.value}`
102
- : option.value
103
- }
104
- disabled={!!option.disabled}
105
- onChange={() => onChange(option)}
106
- readOnly
107
- className={inputClassNames.join(' ')}
108
- style={inputStyle}
109
- />
95
+ <span className="dash-options-list-option-wrapper">
96
+ <input
97
+ type={inputType}
98
+ checked={isSelected}
99
+ name={id}
100
+ value={
101
+ typeof option.value === 'boolean'
102
+ ? `${option.value}`
103
+ : option.value
104
+ }
105
+ disabled={!!option.disabled}
106
+ onChange={() => onChange(option)}
107
+ onKeyUp={e => {
108
+ if (e.key === 'Enter') {
109
+ onChange(option);
110
+ }
111
+ }}
112
+ readOnly
113
+ className={inputClassNames.join(' ')}
114
+ style={inputStyle}
115
+ />
116
+ </span>
110
117
  <span
111
118
  className={labelClassNames.join(' ')}
112
119
  style={labelStyle}
@@ -58,6 +58,7 @@ export const renderSliderMarks = (
58
58
  renderedMarks: SliderMarks,
59
59
  vertical: boolean,
60
60
  minMaxValues: {min_mark: number; max_mark: number},
61
+ selectedValues: number[] = [],
61
62
  dots: boolean,
62
63
  reverse = false
63
64
  ) => {
@@ -83,10 +84,30 @@ export const renderSliderMarks = (
83
84
  transform: 'translateX(-50%)',
84
85
  };
85
86
 
87
+ // Determine if mark is outside the selected range
88
+ let isOutsideSelection = false;
89
+ if (selectedValues.length === 1) {
90
+ isOutsideSelection = pos > selectedValues[0];
91
+ } else if (selectedValues.length > 1) {
92
+ const [minValue, maxValue] = [
93
+ selectedValues[0],
94
+ selectedValues[selectedValues.length - 1],
95
+ ];
96
+ isOutsideSelection = pos < minValue || pos > maxValue;
97
+ }
98
+
99
+ const outsideClassName = isOutsideSelection
100
+ ? 'dash-slider-mark-outside-selection'
101
+ : '';
102
+
103
+ const className = `dash-slider-mark ${
104
+ dots ? 'with-dots' : ''
105
+ } ${outsideClassName}`.trim();
106
+
86
107
  return (
87
108
  <div
88
109
  key={position}
89
- className={`dash-slider-mark ${dots ? 'with-dots' : ''}`}
110
+ className={className}
90
111
  style={{
91
112
  ...style,
92
113
  ...(typeof mark === 'object' && mark.style
@@ -103,6 +124,7 @@ export const renderSliderMarks = (
103
124
  export const renderSliderDots = (
104
125
  stepValue: number,
105
126
  minMaxValues: {min_mark: number; max_mark: number},
127
+ selectedValues: number[] = [],
106
128
  vertical: boolean,
107
129
  reverse = false
108
130
  ) => {
@@ -149,10 +171,26 @@ export const renderSliderDots = (
149
171
  transform: 'translate(-50%, 50%)',
150
172
  };
151
173
 
174
+ // Determine if dot is outside the selected range
175
+ let isOutsideSelection = false;
176
+ if (selectedValues.length === 1) {
177
+ isOutsideSelection = dotValue > selectedValues[0];
178
+ } else if (selectedValues.length > 1) {
179
+ const [minValue, maxValue] = [
180
+ selectedValues[0],
181
+ selectedValues[selectedValues.length - 1],
182
+ ];
183
+ isOutsideSelection = dotValue < minValue || dotValue > maxValue;
184
+ }
185
+
186
+ const className = isOutsideSelection
187
+ ? 'dash-slider-dot dash-slider-dot-outside-selection'
188
+ : 'dash-slider-dot';
189
+
152
190
  return (
153
191
  <div
154
192
  key={i}
155
- className="dash-slider-dot"
193
+ className={className}
156
194
  style={{
157
195
  ...dotStyle,
158
196
  }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dash-core-components",
3
- "version": "4.0.0-rc2",
3
+ "version": "4.0.0-rc4",
4
4
  "description": "Core component suite for Dash",
5
5
  "repository": {
6
6
  "type": "git",
@@ -52,37 +52,40 @@
52
52
  "highlight.js": "^11.8.0",
53
53
  "js-search": "^2.0.1",
54
54
  "mathjax": "^3.2.2",
55
- "moment": "^2.29.4",
55
+ "date-fns": "^4.1.0",
56
56
  "node-polyfill-webpack-plugin": "^2.0.1",
57
57
  "prop-types": "^15.8.1",
58
58
  "ramda": "^0.30.1",
59
59
  "react-addons-shallow-compare": "^15.6.3",
60
- "react-dates": "^21.8.0",
61
60
  "react-docgen": "^5.4.3",
62
61
  "react-dropzone": "^4.1.2",
63
62
  "react-fast-compare": "^3.2.2",
63
+ "react-input-autosize": "^3.0.0",
64
64
  "react-markdown": "^4.3.1",
65
65
  "react-virtualized-select": "^3.1.3",
66
66
  "remark-math": "^3.0.1",
67
67
  "uniqid": "^5.4.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@babel/cli": "^7.28.0",
71
- "@babel/core": "^7.28.0",
72
- "@babel/eslint-parser": "^7.28.0",
70
+ "@babel/cli": "^7.28.3",
71
+ "@babel/core": "^7.28.5",
72
+ "@babel/eslint-parser": "^7.28.5",
73
73
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
74
- "@babel/preset-env": "^7.28.0",
75
- "@babel/preset-react": "^7.27.1",
76
- "@babel/preset-typescript": "^7.27.1",
74
+ "@babel/preset-env": "^7.28.5",
75
+ "@babel/preset-react": "^7.28.5",
76
+ "@babel/preset-typescript": "^7.28.5",
77
77
  "@plotly/dash-component-plugins": "^1.2.3",
78
78
  "@plotly/webpack-dash-dynamic-import": "^1.3.0",
79
+ "@testing-library/jest-dom": "^6.9.1",
80
+ "@testing-library/react": "^12.1.5",
79
81
  "@types/d3-format": "^3.0.4",
80
82
  "@types/fast-isnumeric": "^1.1.2",
81
- "@types/jest": "^29.5.0",
83
+ "@types/jest": "^29.5.14",
82
84
  "@types/js-search": "^1.4.4",
83
85
  "@types/ramda": "^0.31.0",
84
86
  "@types/react": "^16.14.8",
85
87
  "@types/react-dom": "^16.9.13",
88
+ "@types/react-input-autosize": "^2.2.4",
86
89
  "@types/uniqid": "^5.3.4",
87
90
  "@typescript-eslint/eslint-plugin": "^5.59.7",
88
91
  "@typescript-eslint/parser": "^5.59.7",
@@ -96,6 +99,7 @@
96
99
  "eslint-plugin-react": "^7.32.2",
97
100
  "identity-obj-proxy": "^3.0.0",
98
101
  "jest": "^29.5.0",
102
+ "jest-environment-jsdom": "^30.2.0",
99
103
  "npm-run-all": "^4.1.5",
100
104
  "prettier": "^2.8.8",
101
105
  "react": "^16.14.0",
@@ -106,7 +110,7 @@
106
110
  "styled-jsx": "^5.1.7",
107
111
  "ts-jest": "^29.1.0",
108
112
  "typescript": "^5.8.3",
109
- "webpack": "^5.101.0",
113
+ "webpack": "^5.102.1",
110
114
  "webpack-cli": "^5.1.4"
111
115
  },
112
116
  "optionalDependencies": {
@@ -122,6 +126,5 @@
122
126
  },
123
127
  "browserslist": [
124
128
  "last 9 years and not dead"
125
- ],
126
- "gitHead": "fdbd6e0b8dc2448175dad301ed9004c918332d34"
129
+ ]
127
130
  }
@@ -1,244 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.propTypes = exports.defaultProps = exports.default = void 0;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
8
- var _react = _interopRequireWildcard(require("react"));
9
- var _datePickerRange = _interopRequireDefault(require("../utils/LazyLoader/datePickerRange"));
10
- var _DatePickerPersistence = _interopRequireDefault(require("../utils/DatePickerPersistence"));
11
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- var RealDatePickerRange = /*#__PURE__*/(0, _react.lazy)(_datePickerRange.default);
14
-
15
- /**
16
- * DatePickerRange is a tailor made component designed for selecting
17
- * timespan across multiple days off of a calendar.
18
- *
19
- * The DatePicker integrates well with the Python datetime module with the
20
- * startDate and endDate being returned in a string format suitable for
21
- * creating datetime objects.
22
- *
23
- * This component is based off of Airbnb's react-dates react component
24
- * which can be found here: https://github.com/airbnb/react-dates
25
- */
26
- class DatePickerRange extends _react.Component {
27
- render() {
28
- return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
29
- fallback: null
30
- }, /*#__PURE__*/_react.default.createElement(RealDatePickerRange, this.props));
31
- }
32
- }
33
- exports.default = DatePickerRange;
34
- DatePickerRange.propTypes = {
35
- /**
36
- * Specifies the starting date for the component.
37
- * Accepts datetime.datetime objects or strings
38
- * in the format 'YYYY-MM-DD'
39
- */
40
- start_date: _propTypes.default.string,
41
- /**
42
- * Specifies the ending date for the component.
43
- * Accepts datetime.datetime objects or strings
44
- * in the format 'YYYY-MM-DD'
45
- */
46
- end_date: _propTypes.default.string,
47
- /**
48
- * Specifies the lowest selectable date for the component.
49
- * Accepts datetime.datetime objects or strings
50
- * in the format 'YYYY-MM-DD'
51
- */
52
- min_date_allowed: _propTypes.default.string,
53
- /**
54
- * Specifies the highest selectable date for the component.
55
- * Accepts datetime.datetime objects or strings
56
- * in the format 'YYYY-MM-DD'
57
- */
58
- max_date_allowed: _propTypes.default.string,
59
- /**
60
- * Specifies additional days between min_date_allowed and max_date_allowed
61
- * that should be disabled. Accepted datetime.datetime objects or strings
62
- * in the format 'YYYY-MM-DD'
63
- */
64
- disabled_days: _propTypes.default.arrayOf(_propTypes.default.string),
65
- /**
66
- * Specifies a minimum number of nights that must be selected between
67
- * the startDate and the endDate
68
- */
69
- minimum_nights: _propTypes.default.number,
70
- /**
71
- * Determines when the component should update
72
- * its value. If `bothdates`, then the DatePicker
73
- * will only trigger its value when the user has
74
- * finished picking both dates. If `singledate`, then
75
- * the DatePicker will update its value
76
- * as one date is picked.
77
- */
78
- updatemode: _propTypes.default.oneOf(['singledate', 'bothdates']),
79
- /**
80
- * Text that will be displayed in the first input
81
- * box of the date picker when no date is selected. Default value is 'Start Date'
82
- */
83
- start_date_placeholder_text: _propTypes.default.string,
84
- /**
85
- * Text that will be displayed in the second input
86
- * box of the date picker when no date is selected. Default value is 'End Date'
87
- */
88
- end_date_placeholder_text: _propTypes.default.string,
89
- /**
90
- * Specifies the month that is initially presented when the user
91
- * opens the calendar. Accepts datetime.datetime objects or strings
92
- * in the format 'YYYY-MM-DD'
93
- *
94
- */
95
- initial_visible_month: _propTypes.default.string,
96
- /**
97
- * Whether or not the dropdown is "clearable", that is, whether or
98
- * not a small "x" appears on the right of the dropdown that removes
99
- * the selected value.
100
- */
101
- clearable: _propTypes.default.bool,
102
- /**
103
- * If True, the calendar will automatically open when cleared
104
- */
105
- reopen_calendar_on_clear: _propTypes.default.bool,
106
- /**
107
- * Specifies the format that the selected dates will be displayed
108
- * valid formats are variations of "MM YY DD". For example:
109
- * "MM YY DD" renders as '05 10 97' for May 10th 1997
110
- * "MMMM, YY" renders as 'May, 1997' for May 10th 1997
111
- * "M, D, YYYY" renders as '07, 10, 1997' for September 10th 1997
112
- * "MMMM" renders as 'May' for May 10 1997
113
- */
114
- display_format: _propTypes.default.string,
115
- /**
116
- * Specifies the format that the month will be displayed in the calendar,
117
- * valid formats are variations of "MM YY". For example:
118
- * "MM YY" renders as '05 97' for May 1997
119
- * "MMMM, YYYY" renders as 'May, 1997' for May 1997
120
- * "MMM, YY" renders as 'Sep, 97' for September 1997
121
- */
122
- month_format: _propTypes.default.string,
123
- /**
124
- * Specifies what day is the first day of the week, values must be
125
- * from [0, ..., 6] with 0 denoting Sunday and 6 denoting Saturday
126
- */
127
- first_day_of_week: _propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6]),
128
- /**
129
- * If True the calendar will display days that rollover into
130
- * the next month
131
- */
132
- show_outside_days: _propTypes.default.bool,
133
- /**
134
- * If True the calendar will not close when the user has selected a value
135
- * and will wait until the user clicks off the calendar
136
- */
137
- stay_open_on_select: _propTypes.default.bool,
138
- /**
139
- * Orientation of calendar, either vertical or horizontal.
140
- * Valid options are 'vertical' or 'horizontal'.
141
- */
142
- calendar_orientation: _propTypes.default.oneOf(['vertical', 'horizontal']),
143
- /**
144
- * Number of calendar months that are shown when calendar is opened
145
- */
146
- number_of_months_shown: _propTypes.default.number,
147
- /**
148
- * If True, calendar will open in a screen overlay portal,
149
- * not supported on vertical calendar
150
- */
151
- with_portal: _propTypes.default.bool,
152
- /**
153
- * If True, calendar will open in a full screen overlay portal, will
154
- * take precedent over 'withPortal' if both are set to true,
155
- * not supported on vertical calendar
156
- */
157
- with_full_screen_portal: _propTypes.default.bool,
158
- /**
159
- * Size of rendered calendar days, higher number
160
- * means bigger day size and larger calendar overall
161
- */
162
- day_size: _propTypes.default.number,
163
- /**
164
- * Determines whether the calendar and days operate
165
- * from left to right or from right to left
166
- */
167
- is_RTL: _propTypes.default.bool,
168
- /**
169
- * If True, no dates can be selected.
170
- */
171
- disabled: _propTypes.default.bool,
172
- /**
173
- * The HTML element ID of the start date input field.
174
- * Not used by Dash, only by CSS.
175
- */
176
- start_date_id: _propTypes.default.string,
177
- /**
178
- * The HTML element ID of the end date input field.
179
- * Not used by Dash, only by CSS.
180
- */
181
- end_date_id: _propTypes.default.string,
182
- /**
183
- * CSS styles appended to wrapper div
184
- */
185
- style: _propTypes.default.object,
186
- /**
187
- * Appends a CSS class to the wrapper div component.
188
- */
189
- className: _propTypes.default.string,
190
- /**
191
- * The ID of this component, used to identify dash components
192
- * in callbacks. The ID needs to be unique across all of the
193
- * components in an app.
194
- */
195
- id: _propTypes.default.string,
196
- /**
197
- * Dash-assigned callback that gets fired when the value changes.
198
- */
199
- setProps: _propTypes.default.func,
200
- /**
201
- * Used to allow user interactions in this component to be persisted when
202
- * the component - or the page - is refreshed. If `persisted` is truthy and
203
- * hasn't changed from its previous value, any `persisted_props` that the
204
- * user has changed while using the app will keep those changes, as long as
205
- * the new prop value also matches what was given originally.
206
- * Used in conjunction with `persistence_type` and `persisted_props`.
207
- */
208
- persistence: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string, _propTypes.default.number]),
209
- /**
210
- * Properties whose user interactions will persist after refreshing the
211
- * component or the page.
212
- */
213
- persisted_props: _propTypes.default.arrayOf(_propTypes.default.oneOf(['start_date', 'end_date'])),
214
- /**
215
- * Where persisted user changes will be stored:
216
- * memory: only kept in memory, reset on page refresh.
217
- * local: window.localStorage, data is kept after the browser quit.
218
- * session: window.sessionStorage, data is cleared once the browser quit.
219
- */
220
- persistence_type: _propTypes.default.oneOf(['local', 'session', 'memory'])
221
- };
222
- DatePickerRange.persistenceTransforms = {
223
- end_date: _DatePickerPersistence.default,
224
- start_date: _DatePickerPersistence.default
225
- };
226
- DatePickerRange.defaultProps = {
227
- calendar_orientation: 'horizontal',
228
- is_RTL: false,
229
- day_size: 39,
230
- with_portal: false,
231
- with_full_screen_portal: false,
232
- first_day_of_week: 0,
233
- number_of_months_shown: 1,
234
- stay_open_on_select: false,
235
- reopen_calendar_on_clear: false,
236
- clearable: false,
237
- disabled: false,
238
- updatemode: 'singledate',
239
- persisted_props: ['start_date', 'end_date'],
240
- persistence_type: 'local',
241
- disabled_days: []
242
- };
243
- var propTypes = exports.propTypes = DatePickerRange.propTypes;
244
- var defaultProps = exports.defaultProps = DatePickerRange.defaultProps;