Skip to content

Commit feab86a

Browse files
authored
Merge branch 'v4' into v4-update-tooltip
2 parents aaf54a1 + 9e5d7c5 commit feab86a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1918
-511
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
All notable changes to `dash` will be documented in this file.
33
This project adheres to [Semantic Versioning](https://semver.org/).
44

5-
## UNRELEASED
5+
## [4.0.0rc4] - 2025-12-04
66

77
## Added
8+
- New `dcc.Button` component that mirrors `html.Button` but with default styles applied
9+
10+
## [4.0.0rc3] - 2025-11-27
811
- Modernized `dcc.Tabs`
912
- Modernized `dcc.DatePickerSingle` and `dcc.DatePickerRange`
1013
- DatePicker calendars can now accept translations as an external script, either with Dash's `external_scripts` or from the assets folder. See [documentation](https://date-fns.org/v4.1.0/docs/CDN) for the underlying library that supports this.
@@ -44,6 +47,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
4447
## [3.3.0] - 2025-11-12
4548

4649
## Added
50+
- [#3464](https://github.com/plotly/dash/issues/3464) Add folder upload functionality to `dcc.Upload` component. When `multiple=True`, users can now select and upload entire folders in addition to individual files. The folder hierarchy is preserved in filenames (e.g., `folder/subfolder/file.txt`). Files within folders are filtered according to the `accept` prop. Folder support is available in Chrome, Edge, and Opera; other browsers gracefully fall back to file-only mode. The uploaded files use the same output API as multiple file uploads.
4751
- [#3395](https://github.com/plotly/dash/pull/3396) Add position argument to hooks.devtool
4852
- [#3403](https://github.com/plotly/dash/pull/3403) Add app_context to get_app, allowing to get the current app in routes.
4953
- [#3407](https://github.com/plotly/dash/pull/3407) Add `hidden` to callback arguments, hiding the callback from appearing in the devtool callback graph.

components/dash-core-components/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ module.exports = {
3333
// Disable caching to ensure TypeScript type changes are always picked up
3434
cache: false,
3535
// Limit workers in CI to prevent out-of-memory errors
36-
maxWorkers: process.env.CI ? 2 : undefined,
36+
maxWorkers: 2,
3737
};

components/dash-core-components/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/dash-core-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-core-components",
3-
"version": "4.0.0-rc3",
3+
"version": "4.0.0-rc4",
44
"description": "Core component suite for Dash",
55
"repository": {
66
"type": "git",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react';
2+
import {ButtonProps} from '../types';
3+
import './css/button.css';
4+
5+
/**
6+
* Similar to dash.html.Button, but with theming and styles applied.
7+
*/
8+
const Button = ({
9+
setProps,
10+
n_blur = 0,
11+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
12+
n_blur_timestamp = -1,
13+
n_clicks = 0,
14+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
15+
n_clicks_timestamp = -1,
16+
type = 'button',
17+
className,
18+
children,
19+
...props
20+
}: ButtonProps) => {
21+
const ctx = window.dash_component_api.useDashContext();
22+
const isLoading = ctx.useLoading();
23+
24+
return (
25+
<button
26+
data-dash-is-loading={isLoading || undefined}
27+
className={'dash-button ' + (className ?? '')}
28+
onBlur={() => {
29+
setProps({
30+
n_blur: n_blur + 1,
31+
n_blur_timestamp: Date.now(),
32+
});
33+
}}
34+
onClick={() => {
35+
setProps({
36+
n_clicks: n_clicks + 1,
37+
n_clicks_timestamp: Date.now(),
38+
});
39+
}}
40+
type={type}
41+
{...props}
42+
>
43+
{children}
44+
</button>
45+
);
46+
};
47+
48+
export default Button;

components/dash-core-components/src/components/Input.tsx

Lines changed: 13 additions & 234 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import React, {
1111
import uniqid from 'uniqid';
1212
import fastIsNumeric from 'fast-isnumeric';
1313
import LoadingElement from '../utils/_LoadingElement';
14-
import {PersistedProps, PersistenceTypes} from '../types';
14+
import {
15+
HTMLInputTypes,
16+
InputProps,
17+
PersistedProps,
18+
PersistenceTypes,
19+
} from '../types';
1520
import './css/input.css';
1621

1722
const isNumeric = (val: unknown): val is number => fastIsNumeric(val);
@@ -20,238 +25,6 @@ const convert = (val: unknown) => (isNumeric(val) ? +val : NaN);
2025
const isEquivalent = (v1: number, v2: number) =>
2126
v1 === v2 || (isNaN(v1) && isNaN(v2));
2227

23-
export enum HTMLInputTypes {
24-
// Only allowing the input types with wide browser compatibility
25-
'text' = 'text',
26-
'number' = 'number',
27-
'password' = 'password',
28-
'email' = 'email',
29-
'range' = 'range',
30-
'search' = 'search',
31-
'tel' = 'tel',
32-
'url' = 'url',
33-
'hidden' = 'hidden',
34-
}
35-
36-
type InputProps = {
37-
/**
38-
* The value of the input
39-
*/
40-
value?: string | number;
41-
/**
42-
* If true, changes to input will be sent back to the Dash server only on enter or when losing focus.
43-
* If it's false, it will send the value back on every change.
44-
* If a number, it will not send anything back to the Dash server until the user has stopped
45-
* typing for that number of seconds.
46-
*/
47-
debounce?: boolean | number;
48-
/**
49-
* A hint to the user of what can be entered in the control . The placeholder text must not contain carriage returns or line-feeds. Note: Do not use the placeholder attribute instead of a <label> element, their purposes are different. The <label> attribute describes the role of the form element (i.e. it indicates what kind of information is expected), and the placeholder attribute is a hint about the format that the content should take. There are cases in which the placeholder attribute is never displayed to the user, so the form must be understandable without it.
50-
*/
51-
placeholder?: string | number;
52-
/**
53-
* Number of times the `Enter` key was pressed while the input had focus.
54-
*/
55-
n_submit?: number;
56-
/**
57-
* Last time that `Enter` was pressed.
58-
*/
59-
n_submit_timestamp?: number;
60-
/**
61-
* Provides a hint to the browser as to the type of data that might be
62-
* entered by the user while editing the element or its contents.
63-
*/
64-
inputMode?: /**
65-
* Alphanumeric, non-prose content such as usernames and passwords.
66-
*/
67-
| 'verbatim'
68-
/**
69-
* Latin-script input in the user's preferred language with typing aids such as text prediction enabled. For human-to-computer communication such as search boxes.
70-
*/
71-
| 'latin'
72-
/**
73-
* As latin, but for human names.
74-
*/
75-
| 'latin-name'
76-
/**
77-
* As latin, but with more aggressive typing aids. For human-to-human communication such as instant messaging or email.
78-
*/
79-
| 'latin-prose'
80-
/**
81-
* As latin-prose, but for the user's secondary languages.
82-
*/
83-
| 'full-width-latin'
84-
/**
85-
* Kana or romaji input, typically hiragana input, using full-width characters, with support for converting to kanji. Intended for Japanese text input.
86-
*/
87-
| 'kana'
88-
/**
89-
* Katakana input, using full-width characters, with support for converting to kanji. Intended for Japanese text input.
90-
*/
91-
| 'katakana'
92-
/**
93-
* Numeric input, including keys for the digits 0 to 9, the user's preferred thousands separator character, and the character for indicating negative numbers. Intended for numeric codes (e.g. credit card numbers). For actual numbers, prefer using type="number"
94-
*/
95-
| 'numeric'
96-
/**
97-
* Telephone input, including asterisk and pound key. Use type="tel" if possible instead.
98-
*/
99-
| 'tel'
100-
/**
101-
* Email input. Use type="email" if possible instead.
102-
*/
103-
| 'email'
104-
/**
105-
* URL input. Use type="url" if possible instead.
106-
*/
107-
| 'url';
108-
/**
109-
* This attribute indicates whether the value of the control can be automatically completed by the browser.
110-
*/
111-
autoComplete?: string;
112-
/**
113-
* This attribute indicates that the user cannot modify the value of the control. The value of the attribute is irrelevant. If you need read-write access to the input value, do not add the "readonly" attribute. It is ignored if the value of the type attribute is hidden, range, color, checkbox, radio, file, or a button type (such as button or submit).
114-
* readOnly is an HTML boolean attribute - it is enabled by a boolean or
115-
* 'readOnly'. Alternative capitalizations `readonly` & `READONLY`
116-
* are also acccepted.
117-
*/
118-
readOnly?: boolean | 'readOnly' | 'readonly' | 'READONLY';
119-
/**
120-
* This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS pseudo-classes will be applied to the field as appropriate.
121-
* required is an HTML boolean attribute - it is enabled by a boolean or
122-
* 'required'. Alternative capitalizations `REQUIRED`
123-
* are also acccepted.
124-
*/
125-
required?: boolean | 'required' | 'REQUIRED';
126-
/**
127-
* The element should be automatically focused after the page loaded.
128-
* autoFocus is an HTML boolean attribute - it is enabled by a boolean or
129-
* 'autoFocus'. Alternative capitalizations `autofocus` & `AUTOFOCUS`
130-
* are also acccepted.
131-
*/
132-
autoFocus?: boolean | 'autoFocus' | 'autofocus' | 'AUTOFOCUS';
133-
/**
134-
* If true, the input is disabled and can't be clicked on.
135-
* disabled is an HTML boolean attribute - it is enabled by a boolean or
136-
* 'disabled'. Alternative capitalizations `DISABLED`
137-
*/
138-
disabled?: boolean | 'disabled' | 'DISABLED';
139-
/**
140-
* Identifies a list of pre-defined options to suggest to the user.
141-
* The value must be the id of a <datalist> element in the same document.
142-
* The browser displays only options that are valid values for this
143-
* input element.
144-
* This attribute is ignored when the type attribute's value is
145-
* hidden, checkbox, radio, file, or a button type.
146-
*/
147-
list?: string;
148-
/**
149-
* This Boolean attribute indicates whether the user can enter more than one value. This attribute applies when the type attribute is set to email or file, otherwise it is ignored.
150-
*/
151-
multiple?: boolean;
152-
/**
153-
* Setting the value of this attribute to true indicates that the element needs to have its spelling and grammar checked. The value default indicates that the element is to act according to a default behavior, possibly based on the parent element's own spellcheck value. The value false indicates that the element should not be checked.
154-
*/
155-
spellCheck?: boolean | 'true' | 'false';
156-
/**
157-
* The name of the control, which is submitted with the form data.
158-
*/
159-
name?: string;
160-
/**
161-
* The minimum (numeric or date-time) value for this item, which must not be greater than its maximum (max attribute) value.
162-
*/
163-
min?: string | number;
164-
/**
165-
* The maximum (numeric or date-time) value for this item, which must not be less than its minimum (min attribute) value.
166-
*/
167-
max?: string | number;
168-
/**
169-
* Works with the min and max attributes to limit the increments at which a numeric or date-time value can be set. It can be the string any or a positive floating point number. If this attribute is not set to any, the control accepts only values at multiples of the step value greater than the minimum.
170-
*/
171-
step?: string | number;
172-
/**
173-
* If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the minimum number of characters (in Unicode code points) that the user can enter. For other control types, it is ignored.
174-
*/
175-
minLength?: string | number;
176-
/**
177-
* If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum number of characters (in UTF-16 code units) that the user can enter. For other control types, it is ignored. It can exceed the value of the size attribute. If it is not specified, the user can enter an unlimited number of characters. Specifying a negative number results in the default behavior (i.e. the user can enter an unlimited number of characters). The constraint is evaluated only when the value of the attribute has been changed.
178-
*/
179-
maxLength?: string | number;
180-
/**
181-
* A regular expression that the control's value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is text, search, tel, url, email, or password, otherwise it is ignored. The regular expression language is the same as JavaScript RegExp algorithm, with the 'u' parameter that makes it treat the pattern as a sequence of unicode code points. The pattern is not surrounded by forward slashes.
182-
*/
183-
pattern?: string;
184-
/**
185-
* The offset into the element's text content of the first selected character. If there's no selection, this value indicates the offset to the character following the current text input cursor position (that is, the position the next character typed would occupy).
186-
*/
187-
selectionStart?: string;
188-
/**
189-
* The offset into the element's text content of the last selected character. If there's no selection, this value indicates the offset to the character following the current text input cursor position (that is, the position the next character typed would occupy).
190-
*/
191-
selectionEnd?: string;
192-
/**
193-
* The direction in which selection occurred. This is "forward" if the selection was made from left-to-right in an LTR locale or right-to-left in an RTL locale, or "backward" if the selection was made in the opposite direction. On platforms on which it's possible this value isn't known, the value can be "none"; for example, on macOS, the default direction is "none", then as the user begins to modify the selection using the keyboard, this will change to reflect the direction in which the selection is expanding.
194-
*/
195-
selectionDirection?: string;
196-
/**
197-
* Number of times the input lost focus.
198-
*/
199-
n_blur?: number;
200-
/**
201-
* Last time the input lost focus.
202-
*/
203-
n_blur_timestamp?: number;
204-
/**
205-
* The initial size of the control. This value is in pixels unless the value of the type attribute is text or password, in which case it is an integer number of characters. Starting in, this attribute applies only when the type attribute is set to text, search, tel, url, email, or password, otherwise it is ignored. In addition, the size must be greater than zero. If you do not specify a size, a default value of 20 is used.' simply states "the user agent should ensure that at least that many characters are visible", but different characters can have different widths in certain fonts. In some browsers, a certain string with x characters will not be entirely visible even if size is defined to at least x.
206-
*/
207-
size?: string;
208-
/**
209-
* The input's inline styles
210-
*/
211-
style?: React.CSSProperties;
212-
/**
213-
* The class of the input element
214-
*/
215-
className?: string;
216-
/**
217-
* The ID of this component, used to identify dash components
218-
* in callbacks. The ID needs to be unique across all of the
219-
* components in an app.
220-
*/
221-
id?: string;
222-
/**
223-
* Dash-assigned callback that gets fired when the value changes.
224-
*/
225-
setProps: (props: Partial<InputProps>) => void;
226-
/**
227-
* Used to allow user interactions in this component to be persisted when
228-
* the component - or the page - is refreshed. If `persisted` is truthy and
229-
* hasn't changed from its previous value, a `value` that the user has
230-
* changed while using the app will keep that change, as long as
231-
* the new `value` also matches what was given originally.
232-
* Used in conjunction with `persistence_type`.
233-
*/
234-
persistence?: boolean | string | number;
235-
/**
236-
* Properties whose user interactions will persist after refreshing the
237-
* component or the page. Since only `value` is allowed this prop can
238-
* normally be ignored.
239-
*/
240-
persisted_props?: PersistedProps[];
241-
/**
242-
* Where persisted user changes will be stored:
243-
* memory: only kept in memory, reset on page refresh.
244-
* local: window.localStorage, data is kept after the browser quit.
245-
* session: window.sessionStorage, data is cleared once the browser quit.
246-
*/
247-
persistence_type?: PersistenceTypes;
248-
249-
/**
250-
* The type of control to render.
251-
*/
252-
type?: HTMLInputTypes;
253-
};
254-
25528
const inputProps = [
25629
'type',
25730
'placeholder',
@@ -289,12 +62,17 @@ function Input({
28962
type = HTMLInputTypes.text,
29063
inputMode = 'verbatim',
29164
n_blur = 0,
65+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
29266
n_blur_timestamp = -1,
29367
n_submit = 0,
68+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
29469
n_submit_timestamp = -1,
29570
debounce = false,
29671
step = 'any',
72+
autoComplete = 'off',
73+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
29774
persisted_props = [PersistedProps.value],
75+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
29876
persistence_type = PersistenceTypes.local,
29977
disabled,
30078
...props
@@ -470,11 +248,12 @@ function Input({
470248
type,
471249
inputMode,
472250
step,
251+
autoComplete,
473252
disabled: disabledAsBool,
474253
}) as Pick<InputHTMLAttributes<HTMLInputElement>, HTMLInputProps>;
475254

476255
const isNumberInput = type === HTMLInputTypes.number;
477-
const currentNumericValue = convert(input.current.value || '0');
256+
const currentNumericValue = parseFloat(String(value ?? 0)) || 0;
478257
const minValue = convert(props.min);
479258
const maxValue = convert(props.max);
480259
const isDecrementDisabled =

components/dash-core-components/src/components/RadioItems.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export default function RadioItems({
5454
options={sanitizedOptions}
5555
selected={isNil(value) ? [] : [value]}
5656
onSelectionChange={selection => {
57-
setProps({value: selection[selection.length - 1]});
57+
if (selection.length) {
58+
setProps({value: selection[selection.length - 1]});
59+
}
5860
}}
5961
{...stylingProps}
6062
/>

0 commit comments

Comments
 (0)