dash-core-components 4.0.0-rc1 → 4.0.0-rc3

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 (103) 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 +209 -6
  21. package/lib/components/Checklist.tsx +67 -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/Dropdown.tsx +19 -3
  26. package/lib/components/Input.tsx +1 -1
  27. package/lib/components/Loading.tsx +185 -0
  28. package/lib/components/RadioItems.tsx +69 -0
  29. package/lib/components/RangeSlider.tsx +5 -1
  30. package/lib/components/Slider.tsx +12 -1
  31. package/lib/components/Tab.tsx +19 -0
  32. package/lib/components/Tabs.tsx +311 -0
  33. package/lib/components/Textarea.tsx +79 -0
  34. package/lib/components/Tooltip.tsx +66 -0
  35. package/lib/components/css/calendar.css +66 -0
  36. package/lib/components/css/checklist.css +4 -0
  37. package/lib/components/css/datepickers.css +233 -0
  38. package/lib/components/css/dcc.css +3 -0
  39. package/lib/components/css/dropdown.css +34 -50
  40. package/lib/components/css/input.css +29 -7
  41. package/lib/components/css/optionslist.css +34 -0
  42. package/lib/components/css/radioitems.css +4 -0
  43. package/lib/components/css/sliders.css +33 -7
  44. package/lib/components/css/tabs.css +113 -0
  45. package/lib/components/css/textarea.css +21 -0
  46. package/lib/components/css/tooltip.css +127 -0
  47. package/lib/fragments/DatePickerRange.tsx +444 -0
  48. package/lib/fragments/DatePickerSingle.tsx +249 -0
  49. package/lib/fragments/Dropdown.tsx +212 -272
  50. package/lib/fragments/Graph.react.js +18 -45
  51. package/lib/fragments/Loading/spinners/CircleSpinner.tsx +185 -0
  52. package/lib/fragments/Loading/spinners/CubeSpinner.tsx +193 -0
  53. package/lib/fragments/Loading/spinners/DebugTitle.tsx +11 -0
  54. package/lib/fragments/Loading/spinners/DefaultSpinner.tsx +110 -0
  55. package/lib/fragments/Loading/spinners/DotSpinner.tsx +96 -0
  56. package/lib/fragments/Loading/spinners/GraphSpinner.tsx +332 -0
  57. package/lib/fragments/Loading/types.ts +13 -0
  58. package/lib/fragments/RangeSlider.tsx +195 -63
  59. package/lib/index.ts +9 -11
  60. package/lib/types.ts +797 -132
  61. package/lib/utils/DatePickerPersistence.ts +14 -0
  62. package/lib/utils/LazyLoader/datePickerRange.ts +4 -0
  63. package/lib/utils/LazyLoader/datePickerSingle.ts +4 -0
  64. package/lib/utils/calendar/Calendar.tsx +382 -0
  65. package/lib/utils/calendar/CalendarDay.tsx +75 -0
  66. package/lib/utils/calendar/CalendarDayPadding.tsx +15 -0
  67. package/lib/utils/calendar/CalendarMonth.tsx +247 -0
  68. package/lib/utils/calendar/CalendarMonthHeader.tsx +23 -0
  69. package/lib/utils/calendar/createMonthGrid.ts +28 -0
  70. package/lib/utils/calendar/helpers.ts +272 -0
  71. package/lib/utils/computeSliderMarkers.ts +71 -116
  72. package/lib/utils/dropdownSearch.ts +4 -4
  73. package/lib/utils/optionRendering.tsx +175 -0
  74. package/lib/utils/optionTypes.ts +5 -5
  75. package/lib/utils/sliderRendering.tsx +63 -6
  76. package/package.json +16 -14
  77. package/lib/components/Checklist.react.js +0 -193
  78. package/lib/components/DatePickerRange.react.js +0 -244
  79. package/lib/components/DatePickerSingle.react.js +0 -209
  80. package/lib/components/Dropdown.react.js.old +0 -228
  81. package/lib/components/Input.react.js.old +0 -507
  82. package/lib/components/Loading.react.js +0 -254
  83. package/lib/components/RadioItems.react.js +0 -192
  84. package/lib/components/Slider.react.js.old +0 -214
  85. package/lib/components/Tab.react.js +0 -80
  86. package/lib/components/Tabs.react.js +0 -295
  87. package/lib/components/Textarea.react.js +0 -223
  88. package/lib/components/Textarea.react.js.old +0 -287
  89. package/lib/components/Tooltip.react.js +0 -120
  90. package/lib/components/css/Dropdown.css +0 -8
  91. package/lib/fragments/DatePickerRange.react.js +0 -188
  92. package/lib/fragments/DatePickerSingle.react.js +0 -132
  93. package/lib/fragments/Loading/spinners/CircleSpinner.js +0 -68
  94. package/lib/fragments/Loading/spinners/CubeSpinner.js +0 -57
  95. package/lib/fragments/Loading/spinners/DebugTitle.js +0 -15
  96. package/lib/fragments/Loading/spinners/DefaultSpinner.js +0 -54
  97. package/lib/fragments/Loading/spinners/DotSpinner.js +0 -50
  98. package/lib/fragments/Loading/spinners/GraphSpinner.js +0 -68
  99. package/lib/utils/DatePickerPersistence.js +0 -18
  100. package/lib/utils/LazyLoader/datePickerRange.js +0 -8
  101. package/lib/utils/LazyLoader/datePickerSingle.js +0 -8
  102. package/lib/utils/convertToMoment.js +0 -30
  103. 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 &&
@@ -5,7 +5,7 @@ import {
5
5
  UnorderedSearchIndex,
6
6
  } from 'js-search';
7
7
  import {sanitizeOptions} from './optionTypes';
8
- import {DetailedDropdownOption, DropdownProps} from '../types';
8
+ import {DetailedOption, DropdownProps} from '../types';
9
9
 
10
10
  // Custom tokenizer, see https://github.com/bvaughn/js-search/issues/43
11
11
  // Split on spaces
@@ -20,8 +20,8 @@ const TOKENIZER = {
20
20
  };
21
21
 
22
22
  interface FilteredOptionsResult {
23
- sanitizedOptions: DetailedDropdownOption[];
24
- filteredOptions: DetailedDropdownOption[];
23
+ sanitizedOptions: DetailedOption[];
24
+ filteredOptions: DetailedOption[];
25
25
  }
26
26
 
27
27
  /**
@@ -83,7 +83,7 @@ export function createFilteredOptions(
83
83
  search.addDocuments(sanitized);
84
84
  }
85
85
 
86
- const filtered = search.search(searchValue) as DetailedDropdownOption[];
86
+ const filtered = search.search(searchValue) as DetailedOption[];
87
87
 
88
88
  return {
89
89
  sanitizedOptions: sanitized || [],
@@ -0,0 +1,175 @@
1
+ import React from 'react';
2
+ import {append, includes, without} from 'ramda';
3
+ import {DetailedOption, OptionValue} from 'src/types';
4
+ import '../components/css/optionslist.css';
5
+
6
+ interface StylingProps {
7
+ id?: string;
8
+ className?: string;
9
+ style?: React.CSSProperties;
10
+ optionClassName?: string;
11
+ optionStyle?: React.CSSProperties;
12
+ inputType?: 'checkbox' | 'radio';
13
+ inputClassName?: string;
14
+ inputStyle?: React.CSSProperties;
15
+ labelClassName?: string;
16
+ labelStyle?: React.CSSProperties;
17
+ }
18
+
19
+ interface OptionLabelProps extends DetailedOption {
20
+ index: string | number;
21
+ }
22
+
23
+ export const OptionLabel: React.FC<OptionLabelProps> = ({
24
+ index,
25
+ label,
26
+ title,
27
+ value,
28
+ }) => {
29
+ const ctx = window.dash_component_api.useDashContext();
30
+ const ExternalWrapper = window.dash_component_api.ExternalWrapper;
31
+
32
+ if (typeof label === 'object') {
33
+ const labels = label instanceof Array ? label : [label];
34
+ return (
35
+ <>
36
+ {labels.map((label, i) => (
37
+ <ExternalWrapper
38
+ key={i}
39
+ component={label}
40
+ componentPath={[...ctx.componentPath, index, i]}
41
+ />
42
+ ))}
43
+ </>
44
+ );
45
+ }
46
+
47
+ const displayLabel = `${label ?? value}`;
48
+ return <span title={title}>{displayLabel}</span>;
49
+ };
50
+
51
+ interface OptionProps extends StylingProps {
52
+ index: number;
53
+ option: DetailedOption;
54
+ isSelected: boolean;
55
+ onChange: (option: DetailedOption) => void;
56
+ }
57
+
58
+ export const Option: React.FC<OptionProps> = ({
59
+ option,
60
+ isSelected,
61
+ onChange,
62
+ optionClassName,
63
+ optionStyle,
64
+ inputType = 'checkbox',
65
+ inputClassName,
66
+ inputStyle,
67
+ labelClassName,
68
+ labelStyle,
69
+ index,
70
+ id,
71
+ }) => {
72
+ const classNames = [
73
+ 'dash-options-list-option',
74
+ isSelected ? 'selected' : '',
75
+ optionClassName,
76
+ ].filter(Boolean);
77
+
78
+ const inputClassNames = [
79
+ 'dash-options-list-option-checkbox',
80
+ inputClassName,
81
+ ].filter(Boolean);
82
+
83
+ const labelClassNames = [
84
+ 'dash-options-list-option-text',
85
+ labelClassName,
86
+ ].filter(Boolean);
87
+
88
+ return (
89
+ <label
90
+ className={classNames.join(' ')}
91
+ role="option"
92
+ aria-selected={isSelected}
93
+ style={optionStyle}
94
+ >
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' && inputType === 'checkbox') {
109
+ onChange(option);
110
+ }
111
+ }}
112
+ readOnly
113
+ className={inputClassNames.join(' ')}
114
+ style={inputStyle}
115
+ />
116
+ </span>
117
+ <span
118
+ className={labelClassNames.join(' ')}
119
+ style={labelStyle}
120
+ title={option.title}
121
+ >
122
+ <OptionLabel {...option} index={index} />
123
+ </span>
124
+ </label>
125
+ );
126
+ };
127
+
128
+ interface OptionsListProps extends StylingProps {
129
+ options: DetailedOption[];
130
+ selected: OptionValue[];
131
+ onSelectionChange: (selected: OptionValue[]) => void;
132
+ }
133
+
134
+ export const OptionsList: React.FC<OptionsListProps> = ({
135
+ options,
136
+ selected,
137
+ onSelectionChange,
138
+ id,
139
+ className,
140
+ style,
141
+ ...passThruProps
142
+ }) => {
143
+ const classNames = ['dash-options-list', className].filter(Boolean);
144
+ return (
145
+ <div
146
+ id={id}
147
+ className={classNames.join(' ')}
148
+ style={style}
149
+ role="listbox"
150
+ >
151
+ {options.map((option, i) => {
152
+ const isSelected = includes(option.value, selected);
153
+ return (
154
+ <Option
155
+ id={id}
156
+ key={i}
157
+ index={i}
158
+ option={option}
159
+ isSelected={isSelected}
160
+ onChange={option => {
161
+ let newValue: OptionValue[];
162
+ if (includes(option.value, selected)) {
163
+ newValue = without([option.value], selected);
164
+ } else {
165
+ newValue = append(option.value, selected);
166
+ }
167
+ onSelectionChange(newValue);
168
+ }}
169
+ {...passThruProps}
170
+ />
171
+ );
172
+ })}
173
+ </div>
174
+ );
175
+ };
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
- import {DetailedDropdownOption, DropdownProps, DropdownValue} from '../types';
2
+ import {DetailedOption, DropdownProps, OptionValue} from '../types';
3
3
 
4
- const isDropdownValue = (option: unknown): option is DropdownValue => {
4
+ const isOptionValue = (option: unknown): option is OptionValue => {
5
5
  return ['string', 'number', 'boolean'].includes(typeof option);
6
6
  };
7
7
 
8
8
  export const sanitizeOptions = (
9
9
  options: DropdownProps['options']
10
- ): DetailedDropdownOption[] => {
10
+ ): DetailedOption[] => {
11
11
  if (typeof options === 'object' && !(options instanceof Array)) {
12
12
  return Object.entries(options).map(([value, label]) => ({
13
13
  label: React.isValidElement(label) ? label : String(label),
@@ -17,11 +17,11 @@ export const sanitizeOptions = (
17
17
 
18
18
  if (options instanceof Array) {
19
19
  return options.map(option => {
20
- return isDropdownValue(option)
20
+ return isOptionValue(option)
21
21
  ? {label: String(option), value: option}
22
22
  : option;
23
23
  });
24
24
  }
25
25
 
26
- return options;
26
+ return [];
27
27
  };
@@ -58,11 +58,20 @@ export const renderSliderMarks = (
58
58
  renderedMarks: SliderMarks,
59
59
  vertical: boolean,
60
60
  minMaxValues: {min_mark: number; max_mark: number},
61
- dots: boolean
61
+ selectedValues: number[] = [],
62
+ dots: boolean,
63
+ reverse = false
62
64
  ) => {
63
65
  return Object.entries(renderedMarks).map(([position, mark]) => {
64
66
  const pos = parseFloat(position);
65
- const thumbPosition = getRadixThumbPosition(pos, minMaxValues);
67
+
68
+ // When reversed, use the inverted value for positioning
69
+ const displayPos = reverse
70
+ ? minMaxValues.max_mark - pos + minMaxValues.min_mark
71
+ : pos;
72
+
73
+ const thumbPosition = getRadixThumbPosition(displayPos, minMaxValues);
74
+
66
75
  const style = vertical
67
76
  ? {
68
77
  bottom: `calc(${thumbPosition.percentage}% + ${thumbPosition.offset}px - 13px)`,
@@ -75,10 +84,30 @@ export const renderSliderMarks = (
75
84
  transform: 'translateX(-50%)',
76
85
  };
77
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
+
78
107
  return (
79
108
  <div
80
109
  key={position}
81
- className={`dash-slider-mark ${dots ? 'with-dots' : ''}`}
110
+ className={className}
82
111
  style={{
83
112
  ...style,
84
113
  ...(typeof mark === 'object' && mark.style
@@ -95,7 +124,9 @@ export const renderSliderMarks = (
95
124
  export const renderSliderDots = (
96
125
  stepValue: number,
97
126
  minMaxValues: {min_mark: number; max_mark: number},
98
- vertical: boolean
127
+ selectedValues: number[] = [],
128
+ vertical: boolean,
129
+ reverse = false
99
130
  ) => {
100
131
  if (stepValue <= 1) {
101
132
  return null;
@@ -117,7 +148,17 @@ export const renderSliderDots = (
117
148
  },
118
149
  (_, i) => {
119
150
  const dotValue = minMaxValues.min_mark + i * stepValue;
120
- const thumbPosition = getRadixThumbPosition(dotValue, minMaxValues);
151
+
152
+ // When reversed, use the inverted value for positioning
153
+ const displayValue = reverse
154
+ ? minMaxValues.max_mark - dotValue + minMaxValues.min_mark
155
+ : dotValue;
156
+
157
+ const thumbPosition = getRadixThumbPosition(
158
+ displayValue,
159
+ minMaxValues
160
+ );
161
+
121
162
  const dotStyle = vertical
122
163
  ? {
123
164
  bottom: `calc(${thumbPosition.percentage}% + ${thumbPosition.offset}px)`,
@@ -130,10 +171,26 @@ export const renderSliderDots = (
130
171
  transform: 'translate(-50%, 50%)',
131
172
  };
132
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
+
133
190
  return (
134
191
  <div
135
192
  key={i}
136
- className="dash-slider-dot"
193
+ className={className}
137
194
  style={{
138
195
  ...dotStyle,
139
196
  }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dash-core-components",
3
- "version": "4.0.0-rc1",
3
+ "version": "4.0.0-rc3",
4
4
  "description": "Core component suite for Dash",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,44 +46,46 @@
46
46
  "@radix-ui/react-slider": "^1.3.6",
47
47
  "@radix-ui/react-tooltip": "^1.2.8",
48
48
  "base64-js": "^1.5.1",
49
- "color": "^4.2.3",
50
49
  "d3-format": "^1.4.5",
51
50
  "fast-isnumeric": "^1.1.4",
52
51
  "file-saver": "^2.0.5",
53
52
  "highlight.js": "^11.8.0",
54
53
  "js-search": "^2.0.1",
55
54
  "mathjax": "^3.2.2",
56
- "moment": "^2.29.4",
55
+ "date-fns": "^4.1.0",
57
56
  "node-polyfill-webpack-plugin": "^2.0.1",
58
57
  "prop-types": "^15.8.1",
59
58
  "ramda": "^0.30.1",
60
59
  "react-addons-shallow-compare": "^15.6.3",
61
- "react-dates": "^21.8.0",
62
60
  "react-docgen": "^5.4.3",
63
61
  "react-dropzone": "^4.1.2",
64
62
  "react-fast-compare": "^3.2.2",
63
+ "react-input-autosize": "^3.0.0",
65
64
  "react-markdown": "^4.3.1",
66
65
  "react-virtualized-select": "^3.1.3",
67
66
  "remark-math": "^3.0.1",
68
67
  "uniqid": "^5.4.0"
69
68
  },
70
69
  "devDependencies": {
71
- "@babel/cli": "^7.28.0",
72
- "@babel/core": "^7.28.0",
73
- "@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",
74
73
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
75
- "@babel/preset-env": "^7.28.0",
76
- "@babel/preset-react": "^7.27.1",
77
- "@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",
78
77
  "@plotly/dash-component-plugins": "^1.2.3",
79
78
  "@plotly/webpack-dash-dynamic-import": "^1.3.0",
79
+ "@testing-library/jest-dom": "^6.9.1",
80
+ "@testing-library/react": "^12.1.5",
80
81
  "@types/d3-format": "^3.0.4",
81
82
  "@types/fast-isnumeric": "^1.1.2",
82
- "@types/jest": "^29.5.0",
83
+ "@types/jest": "^29.5.14",
83
84
  "@types/js-search": "^1.4.4",
84
85
  "@types/ramda": "^0.31.0",
85
86
  "@types/react": "^16.14.8",
86
87
  "@types/react-dom": "^16.9.13",
88
+ "@types/react-input-autosize": "^2.2.4",
87
89
  "@types/uniqid": "^5.3.4",
88
90
  "@typescript-eslint/eslint-plugin": "^5.59.7",
89
91
  "@typescript-eslint/parser": "^5.59.7",
@@ -97,6 +99,7 @@
97
99
  "eslint-plugin-react": "^7.32.2",
98
100
  "identity-obj-proxy": "^3.0.0",
99
101
  "jest": "^29.5.0",
102
+ "jest-environment-jsdom": "^30.2.0",
100
103
  "npm-run-all": "^4.1.5",
101
104
  "prettier": "^2.8.8",
102
105
  "react": "^16.14.0",
@@ -107,7 +110,7 @@
107
110
  "styled-jsx": "^5.1.7",
108
111
  "ts-jest": "^29.1.0",
109
112
  "typescript": "^5.8.3",
110
- "webpack": "^5.101.0",
113
+ "webpack": "^5.102.1",
111
114
  "webpack-cli": "^5.1.4"
112
115
  },
113
116
  "optionalDependencies": {
@@ -123,6 +126,5 @@
123
126
  },
124
127
  "browserslist": [
125
128
  "last 9 years and not dead"
126
- ],
127
- "gitHead": "fdbd6e0b8dc2448175dad301ed9004c918332d34"
129
+ ]
128
130
  }