@neo4j-ndl/react 4.16.7 → 4.16.9
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.
- package/lib/cjs/color-picker/ColorPicker.js +3 -1
- package/lib/cjs/color-picker/ColorPicker.js.map +1 -1
- package/lib/cjs/color-picker/stories/color-picker-dialog.story.js +40 -0
- package/lib/cjs/color-picker/stories/color-picker-dialog.story.js.map +1 -0
- package/lib/cjs/color-picker/stories/color-picker-popover.story.js +32 -0
- package/lib/cjs/color-picker/stories/color-picker-popover.story.js.map +1 -0
- package/lib/cjs/color-picker/stories/index.js +9 -1
- package/lib/cjs/color-picker/stories/index.js.map +1 -1
- package/lib/cjs/popover/use-popover.js +1 -1
- package/lib/cjs/popover/use-popover.js.map +1 -1
- package/lib/cjs/select/Select.js +2 -0
- package/lib/cjs/select/Select.js.map +1 -1
- package/lib/esm/color-picker/ColorPicker.js +3 -1
- package/lib/esm/color-picker/ColorPicker.js.map +1 -1
- package/lib/esm/color-picker/stories/color-picker-dialog.story.js +38 -0
- package/lib/esm/color-picker/stories/color-picker-dialog.story.js.map +1 -0
- package/lib/esm/color-picker/stories/color-picker-popover.story.js +30 -0
- package/lib/esm/color-picker/stories/color-picker-popover.story.js.map +1 -0
- package/lib/esm/color-picker/stories/index.js +6 -0
- package/lib/esm/color-picker/stories/index.js.map +1 -1
- package/lib/esm/popover/use-popover.js +1 -1
- package/lib/esm/popover/use-popover.js.map +1 -1
- package/lib/esm/select/Select.js +2 -0
- package/lib/esm/select/Select.js.map +1 -1
- package/lib/types/color-picker/ColorPicker.d.ts +4 -0
- package/lib/types/color-picker/ColorPicker.d.ts.map +1 -1
- package/lib/types/color-picker/stories/color-picker-dialog.story.d.ts +24 -0
- package/lib/types/color-picker/stories/color-picker-dialog.story.d.ts.map +1 -0
- package/lib/types/color-picker/stories/color-picker-popover.story.d.ts +24 -0
- package/lib/types/color-picker/stories/color-picker-popover.story.d.ts.map +1 -0
- package/lib/types/color-picker/stories/index.d.ts +4 -0
- package/lib/types/color-picker/stories/index.d.ts.map +1 -1
- package/lib/types/select/Select.d.ts.map +1 -1
- package/package.json +5 -2
- package/skills/ndl-react/SKILL.md +152 -0
- package/skills/ndl-react/components/accordion.md +386 -0
- package/skills/ndl-react/components/ai/code-preview.md +128 -0
- package/skills/ndl-react/components/ai/file-tag.md +90 -0
- package/skills/ndl-react/components/ai/image-tag.md +91 -0
- package/skills/ndl-react/components/ai/more-files.md +73 -0
- package/skills/ndl-react/components/ai/presence.md +54 -0
- package/skills/ndl-react/components/ai/preview.md +498 -0
- package/skills/ndl-react/components/ai/prompt.md +362 -0
- package/skills/ndl-react/components/ai/reasoning.md +95 -0
- package/skills/ndl-react/components/ai/response.md +1109 -0
- package/skills/ndl-react/components/ai/suggestion.md +84 -0
- package/skills/ndl-react/components/ai/thinking.md +43 -0
- package/skills/ndl-react/components/ai/tool-call.md +43 -0
- package/skills/ndl-react/components/ai/user-bubble.md +187 -0
- package/skills/ndl-react/components/avatar.md +169 -0
- package/skills/ndl-react/components/banner.md +225 -0
- package/skills/ndl-react/components/box.md +39 -0
- package/skills/ndl-react/components/breadcrumbs.md +245 -0
- package/skills/ndl-react/components/checkbox.md +269 -0
- package/skills/ndl-react/components/clean-icon-button.md +294 -0
- package/skills/ndl-react/components/clipboard-button.md +154 -0
- package/skills/ndl-react/components/code-block.md +276 -0
- package/skills/ndl-react/components/code.md +68 -0
- package/skills/ndl-react/components/color-picker.md +131 -0
- package/skills/ndl-react/components/conditional-wrap.md +46 -0
- package/skills/ndl-react/components/data-grid.md +3121 -0
- package/skills/ndl-react/components/date-picker.md +652 -0
- package/skills/ndl-react/components/dialog.md +485 -0
- package/skills/ndl-react/components/dismissible-tag.md +136 -0
- package/skills/ndl-react/components/divider.md +96 -0
- package/skills/ndl-react/components/drawer.md +543 -0
- package/skills/ndl-react/components/dropdown-button.md +161 -0
- package/skills/ndl-react/components/dropzone.md +371 -0
- package/skills/ndl-react/components/filled-button.md +26 -0
- package/skills/ndl-react/components/flex.md +82 -0
- package/skills/ndl-react/components/graph-label.md +167 -0
- package/skills/ndl-react/components/icon-button-array.md +187 -0
- package/skills/ndl-react/components/icon-button.md +193 -0
- package/skills/ndl-react/components/inline-edit.md +209 -0
- package/skills/ndl-react/components/kbd.md +63 -0
- package/skills/ndl-react/components/loading-bar.md +43 -0
- package/skills/ndl-react/components/loading-spinner.md +57 -0
- package/skills/ndl-react/components/logo.md +57 -0
- package/skills/ndl-react/components/menu.md +993 -0
- package/skills/ndl-react/components/modal.md +27 -0
- package/skills/ndl-react/components/next/tree-view.md +966 -0
- package/skills/ndl-react/components/outlined-button.md +26 -0
- package/skills/ndl-react/components/popover.md +283 -0
- package/skills/ndl-react/components/progress-bar.md +70 -0
- package/skills/ndl-react/components/radio.md +150 -0
- package/skills/ndl-react/components/read-only-tag.md +96 -0
- package/skills/ndl-react/components/segmented-control.md +200 -0
- package/skills/ndl-react/components/select-icon-button.md +183 -0
- package/skills/ndl-react/components/select.md +530 -0
- package/skills/ndl-react/components/selectable-tag.md +203 -0
- package/skills/ndl-react/components/side-navigation.md +652 -0
- package/skills/ndl-react/components/skeleton.md +274 -0
- package/skills/ndl-react/components/slider.md +308 -0
- package/skills/ndl-react/components/spotlight.md +796 -0
- package/skills/ndl-react/components/status-indicator.md +57 -0
- package/skills/ndl-react/components/status-label.md +132 -0
- package/skills/ndl-react/components/switch.md +167 -0
- package/skills/ndl-react/components/tabs.md +433 -0
- package/skills/ndl-react/components/tag.md +91 -0
- package/skills/ndl-react/components/text-area.md +178 -0
- package/skills/ndl-react/components/text-button.md +25 -0
- package/skills/ndl-react/components/text-input.md +475 -0
- package/skills/ndl-react/components/text-link.md +119 -0
- package/skills/ndl-react/components/time-picker.md +137 -0
- package/skills/ndl-react/components/timezone-picker.md +496 -0
- package/skills/ndl-react/components/tooltip.md +478 -0
- package/skills/ndl-react/components/tree-view.md +545 -0
- package/skills/ndl-react/components/typography.md +72 -0
- package/skills/ndl-react/components/wizard.md +152 -0
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
# DatePicker
|
|
2
|
+
|
|
3
|
+
Import: `import { DatePicker } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### DatePicker
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `isClearable` | `boolean` | | `false` | Whether to show the clear button. |
|
|
12
|
+
| `isDisabled` | `boolean` | | | Whether the date picker is disabled. |
|
|
13
|
+
| `reactDatePickerProps` | `DatePickerProps` | ✅ | | Props forwarded to underlying `react-datepicker` component. |
|
|
14
|
+
| `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
|
|
15
|
+
| `textInputProps` | `(TextInputProps & BaseProps<"input">)` | | | Props for the embedded `TextInput` component. |
|
|
16
|
+
| `timePickerProps` | `TimePickerProps` | | | Props for the embedded `TimePicker` component. |
|
|
17
|
+
| `timeZonePickerProps` | `(TimeZonePickerProps & BaseProps<"input">)` | | | Props for the embedded `TimeZonePicker` component. |
|
|
18
|
+
|
|
19
|
+
The `reactDatePickerProps` prop is forwarded to the underlying `react-datepicker` component. See the [react-datepicker documentation](https://reactdatepicker.com/) for more information.
|
|
20
|
+
|
|
21
|
+
Where `TextInputProps` is defined in the `TextInput` component and `TimePickerProps` is defined in the `TimePicker` component.
|
|
22
|
+
|
|
23
|
+
## Accessibility
|
|
24
|
+
|
|
25
|
+
## Implementation guidelines
|
|
26
|
+
|
|
27
|
+
You must provide an `aria-label` or label via the `textInputProps` prop to the underlying input element for accessibility. Use the `htmlAttributes` prop in the `textInputProps` prop to add additional attributes to the input element, not the `htmlAttributes` prop on the root level of the DatePicker component.
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
### Default
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
35
|
+
|
|
36
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
37
|
+
import { useState } from 'react';
|
|
38
|
+
|
|
39
|
+
const Component = () => {
|
|
40
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
41
|
+
new Date('2023-05-27'),
|
|
42
|
+
);
|
|
43
|
+
const handleOnChange = (date: Date | null) => {
|
|
44
|
+
setSelectedDate(date);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<DatePicker
|
|
49
|
+
reactDatePickerProps={{
|
|
50
|
+
onChange: handleOnChange,
|
|
51
|
+
popperProps: {
|
|
52
|
+
strategy: 'fixed',
|
|
53
|
+
},
|
|
54
|
+
selected: selectedDate,
|
|
55
|
+
}}
|
|
56
|
+
textInputProps={{
|
|
57
|
+
htmlAttributes: {
|
|
58
|
+
'aria-label': 'Date picker input',
|
|
59
|
+
},
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default Component;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Clearable
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
72
|
+
|
|
73
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
74
|
+
import { useState } from 'react';
|
|
75
|
+
|
|
76
|
+
export const Component = () => {
|
|
77
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
78
|
+
new Date('2023-05-27'),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const handleOnChange = (date: Date | null) => {
|
|
82
|
+
setSelectedDate(date);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<DatePicker
|
|
87
|
+
isClearable
|
|
88
|
+
reactDatePickerProps={{
|
|
89
|
+
onChange: handleOnChange,
|
|
90
|
+
popperProps: {
|
|
91
|
+
strategy: 'fixed',
|
|
92
|
+
},
|
|
93
|
+
selected: selectedDate,
|
|
94
|
+
}}
|
|
95
|
+
textInputProps={{
|
|
96
|
+
htmlAttributes: {
|
|
97
|
+
'aria-label': 'Clearable date picker input',
|
|
98
|
+
},
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export default Component;
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Disabled
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
111
|
+
|
|
112
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
113
|
+
import { useState } from 'react';
|
|
114
|
+
|
|
115
|
+
const Component = () => {
|
|
116
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
117
|
+
new Date('2023-05-27'),
|
|
118
|
+
);
|
|
119
|
+
const handleOnChange = (date: Date | null) => {
|
|
120
|
+
setSelectedDate(date);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<DatePicker
|
|
125
|
+
isDisabled={true}
|
|
126
|
+
reactDatePickerProps={{
|
|
127
|
+
onChange: handleOnChange,
|
|
128
|
+
selected: selectedDate,
|
|
129
|
+
}}
|
|
130
|
+
textInputProps={{
|
|
131
|
+
htmlAttributes: {
|
|
132
|
+
'aria-label': 'Date picker input',
|
|
133
|
+
},
|
|
134
|
+
}}
|
|
135
|
+
/>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export default Component;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Full
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
146
|
+
|
|
147
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
148
|
+
import { useState } from 'react';
|
|
149
|
+
|
|
150
|
+
const Component = () => {
|
|
151
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
152
|
+
new Date('2023-05-27'),
|
|
153
|
+
);
|
|
154
|
+
const handleOnChange = (date: Date | null) => {
|
|
155
|
+
setSelectedDate(date);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<DatePicker
|
|
160
|
+
textInputProps={{
|
|
161
|
+
helpText: 'With help text',
|
|
162
|
+
isDisabled: false,
|
|
163
|
+
isFluid: false,
|
|
164
|
+
isReadOnly: false,
|
|
165
|
+
isRequired: false,
|
|
166
|
+
label: 'This one has a label',
|
|
167
|
+
moreInformationText: 'With information icon text',
|
|
168
|
+
showRequiredOrOptionalLabel: false,
|
|
169
|
+
}}
|
|
170
|
+
timePickerProps={{
|
|
171
|
+
format: 'hh:mm aa',
|
|
172
|
+
isDisabled: false,
|
|
173
|
+
isFluid: false,
|
|
174
|
+
isReadOnly: false,
|
|
175
|
+
isRequired: false,
|
|
176
|
+
timeInterval: 20,
|
|
177
|
+
}}
|
|
178
|
+
reactDatePickerProps={{
|
|
179
|
+
onChange: handleOnChange,
|
|
180
|
+
popperProps: {
|
|
181
|
+
strategy: 'fixed',
|
|
182
|
+
},
|
|
183
|
+
selected: selectedDate,
|
|
184
|
+
showTimeInput: true,
|
|
185
|
+
}}
|
|
186
|
+
/>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export default Component;
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### In Dialog
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
197
|
+
|
|
198
|
+
import { DatePicker, Dialog } from '@neo4j-ndl/react';
|
|
199
|
+
import { useState } from 'react';
|
|
200
|
+
|
|
201
|
+
const Component = () => {
|
|
202
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
203
|
+
new Date('2023-05-27'),
|
|
204
|
+
);
|
|
205
|
+
const handleOnChange = (date: Date | null) => {
|
|
206
|
+
setSelectedDate(date);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<Dialog isOpen={true} aria-label="Dialog">
|
|
211
|
+
<Dialog.Header>Using Date Picker inside a dialog</Dialog.Header>
|
|
212
|
+
<Dialog.Description className="n-flex n-flex-col n-gap-token-32">
|
|
213
|
+
<DatePicker
|
|
214
|
+
timePickerProps={{
|
|
215
|
+
timeInterval: 20,
|
|
216
|
+
}}
|
|
217
|
+
reactDatePickerProps={{
|
|
218
|
+
onChange: handleOnChange,
|
|
219
|
+
selected: selectedDate,
|
|
220
|
+
showTimeInput: true,
|
|
221
|
+
}}
|
|
222
|
+
textInputProps={{
|
|
223
|
+
htmlAttributes: {
|
|
224
|
+
'aria-label': 'Date picker input',
|
|
225
|
+
},
|
|
226
|
+
}}
|
|
227
|
+
/>
|
|
228
|
+
</Dialog.Description>
|
|
229
|
+
</Dialog>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export default Component;
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Min Max Date
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
240
|
+
|
|
241
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
242
|
+
import { addWeeks } from 'date-fns';
|
|
243
|
+
import { useState } from 'react';
|
|
244
|
+
|
|
245
|
+
const Component = () => {
|
|
246
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
247
|
+
new Date('1994-10-03'),
|
|
248
|
+
);
|
|
249
|
+
const handleOnChange = (date: Date | null) => {
|
|
250
|
+
setSelectedDate(date);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<DatePicker
|
|
255
|
+
reactDatePickerProps={{
|
|
256
|
+
maxDate: addWeeks(new Date('1994-10-01'), 1),
|
|
257
|
+
minDate: new Date('1994-10-01'),
|
|
258
|
+
onChange: handleOnChange,
|
|
259
|
+
openToDate: new Date('1994-10-01'),
|
|
260
|
+
popperProps: {
|
|
261
|
+
strategy: 'fixed',
|
|
262
|
+
},
|
|
263
|
+
selected: selectedDate,
|
|
264
|
+
}}
|
|
265
|
+
textInputProps={{
|
|
266
|
+
htmlAttributes: {
|
|
267
|
+
'aria-label': 'Date picker input',
|
|
268
|
+
},
|
|
269
|
+
}}
|
|
270
|
+
/>
|
|
271
|
+
);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export default Component;
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Opens To Date
|
|
278
|
+
|
|
279
|
+
```tsx
|
|
280
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
281
|
+
|
|
282
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
283
|
+
import { useState } from 'react';
|
|
284
|
+
|
|
285
|
+
const Component = () => {
|
|
286
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
287
|
+
new Date('2023-05-27'),
|
|
288
|
+
);
|
|
289
|
+
const handleOnChange = (date: Date | null) => {
|
|
290
|
+
setSelectedDate(date);
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<DatePicker
|
|
295
|
+
reactDatePickerProps={{
|
|
296
|
+
highlightDates: [new Date('2010-02-01')],
|
|
297
|
+
onChange: handleOnChange,
|
|
298
|
+
openToDate: new Date('2010-02-01'),
|
|
299
|
+
popperProps: {
|
|
300
|
+
strategy: 'fixed',
|
|
301
|
+
},
|
|
302
|
+
selected: selectedDate,
|
|
303
|
+
}}
|
|
304
|
+
textInputProps={{
|
|
305
|
+
htmlAttributes: {
|
|
306
|
+
'aria-label': 'Date picker input',
|
|
307
|
+
},
|
|
308
|
+
}}
|
|
309
|
+
/>
|
|
310
|
+
);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export default Component;
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Portaled
|
|
317
|
+
|
|
318
|
+
```tsx
|
|
319
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
320
|
+
|
|
321
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
322
|
+
import { useState } from 'react';
|
|
323
|
+
|
|
324
|
+
const Component = () => {
|
|
325
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
326
|
+
new Date('2023-05-27'),
|
|
327
|
+
);
|
|
328
|
+
const handleOnChange = (date: Date | null) => {
|
|
329
|
+
setSelectedDate(date);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
return (
|
|
333
|
+
<div id="datepicker-portal-root">
|
|
334
|
+
<DatePicker
|
|
335
|
+
reactDatePickerProps={{
|
|
336
|
+
onChange: handleOnChange,
|
|
337
|
+
popperProps: {
|
|
338
|
+
strategy: 'fixed',
|
|
339
|
+
},
|
|
340
|
+
portalId: 'datepicker-portal-root',
|
|
341
|
+
selected: selectedDate,
|
|
342
|
+
}}
|
|
343
|
+
textInputProps={{
|
|
344
|
+
htmlAttributes: {
|
|
345
|
+
'aria-label': 'Date picker input',
|
|
346
|
+
},
|
|
347
|
+
}}
|
|
348
|
+
/>
|
|
349
|
+
</div>
|
|
350
|
+
);
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
export default Component;
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Range
|
|
357
|
+
|
|
358
|
+
```tsx
|
|
359
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
360
|
+
|
|
361
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
362
|
+
import { useState } from 'react';
|
|
363
|
+
|
|
364
|
+
const Component = () => {
|
|
365
|
+
const [dates, setDates] = useState<[Date | null, Date | null]>([
|
|
366
|
+
new Date('2023-05-05'),
|
|
367
|
+
new Date('2023-05-08'),
|
|
368
|
+
]);
|
|
369
|
+
|
|
370
|
+
const handleOnChange = (dates: [Date | null, Date | null]) => {
|
|
371
|
+
setDates(dates);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
return (
|
|
375
|
+
<DatePicker
|
|
376
|
+
reactDatePickerProps={{
|
|
377
|
+
endDate: dates[1],
|
|
378
|
+
onChange: handleOnChange,
|
|
379
|
+
popperProps: {
|
|
380
|
+
strategy: 'fixed',
|
|
381
|
+
},
|
|
382
|
+
selectsRange: true,
|
|
383
|
+
startDate: dates[0],
|
|
384
|
+
}}
|
|
385
|
+
textInputProps={{
|
|
386
|
+
htmlAttributes: {
|
|
387
|
+
'aria-label': 'Date picker input',
|
|
388
|
+
},
|
|
389
|
+
}}
|
|
390
|
+
/>
|
|
391
|
+
);
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
export default Component;
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Starts On Monday
|
|
398
|
+
|
|
399
|
+
```tsx
|
|
400
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
401
|
+
|
|
402
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
403
|
+
import { useState } from 'react';
|
|
404
|
+
|
|
405
|
+
const Component = () => {
|
|
406
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
407
|
+
new Date('2023-05-27'),
|
|
408
|
+
);
|
|
409
|
+
const handleOnChange = (date: Date | null) => {
|
|
410
|
+
setSelectedDate(date);
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
return (
|
|
414
|
+
<DatePicker
|
|
415
|
+
reactDatePickerProps={{
|
|
416
|
+
calendarStartDay: 1,
|
|
417
|
+
onChange: handleOnChange,
|
|
418
|
+
popperProps: {
|
|
419
|
+
strategy: 'fixed',
|
|
420
|
+
},
|
|
421
|
+
selected: selectedDate,
|
|
422
|
+
}}
|
|
423
|
+
textInputProps={{
|
|
424
|
+
htmlAttributes: {
|
|
425
|
+
'aria-label': 'Date picker input',
|
|
426
|
+
},
|
|
427
|
+
}}
|
|
428
|
+
/>
|
|
429
|
+
);
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
export default Component;
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### Text Input Props
|
|
436
|
+
|
|
437
|
+
```tsx
|
|
438
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
439
|
+
|
|
440
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
441
|
+
import { useState } from 'react';
|
|
442
|
+
|
|
443
|
+
const Component = () => {
|
|
444
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
445
|
+
new Date('2023-05-27'),
|
|
446
|
+
);
|
|
447
|
+
const handleOnChange = (date: Date | null) => {
|
|
448
|
+
setSelectedDate(date);
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
return (
|
|
452
|
+
<DatePicker
|
|
453
|
+
textInputProps={{
|
|
454
|
+
helpText: 'With help text',
|
|
455
|
+
label: 'This one has a label',
|
|
456
|
+
}}
|
|
457
|
+
reactDatePickerProps={{
|
|
458
|
+
onChange: handleOnChange,
|
|
459
|
+
popperProps: {
|
|
460
|
+
strategy: 'fixed',
|
|
461
|
+
},
|
|
462
|
+
selected: selectedDate,
|
|
463
|
+
}}
|
|
464
|
+
/>
|
|
465
|
+
);
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
export default Component;
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### With Time Picker
|
|
472
|
+
|
|
473
|
+
```tsx
|
|
474
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
475
|
+
|
|
476
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
477
|
+
import { useState } from 'react';
|
|
478
|
+
|
|
479
|
+
const Component = () => {
|
|
480
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
481
|
+
new Date('2023-05-27'),
|
|
482
|
+
);
|
|
483
|
+
const handleOnChange = (date: Date | null) => {
|
|
484
|
+
setSelectedDate(date);
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
return (
|
|
488
|
+
<DatePicker
|
|
489
|
+
timePickerProps={{
|
|
490
|
+
format: 'hh:mm',
|
|
491
|
+
timeInterval: 20,
|
|
492
|
+
}}
|
|
493
|
+
reactDatePickerProps={{
|
|
494
|
+
dateFormat: 'yyyy-MM-dd hh:mm',
|
|
495
|
+
onChange: handleOnChange,
|
|
496
|
+
popperProps: {
|
|
497
|
+
strategy: 'fixed',
|
|
498
|
+
},
|
|
499
|
+
selected: selectedDate,
|
|
500
|
+
showTimeInput: true,
|
|
501
|
+
}}
|
|
502
|
+
textInputProps={{
|
|
503
|
+
htmlAttributes: {
|
|
504
|
+
'aria-label': 'Date picker input',
|
|
505
|
+
},
|
|
506
|
+
}}
|
|
507
|
+
/>
|
|
508
|
+
);
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
export default Component;
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### With Timezone
|
|
515
|
+
|
|
516
|
+
```tsx
|
|
517
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
518
|
+
|
|
519
|
+
import { DatePicker } from '@neo4j-ndl/react';
|
|
520
|
+
import { useState } from 'react';
|
|
521
|
+
|
|
522
|
+
const Component = () => {
|
|
523
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
524
|
+
new Date('2023-05-27T14:30:00'),
|
|
525
|
+
);
|
|
526
|
+
const [selectedTimeZone, setSelectedTimeZone] = useState<string>('UTC');
|
|
527
|
+
|
|
528
|
+
const handleOnChange = (date: Date | null) => {
|
|
529
|
+
setSelectedDate(date);
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
const handleTimeZoneChange = (timezone: string) => {
|
|
533
|
+
setSelectedTimeZone(timezone);
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
return (
|
|
537
|
+
<div>
|
|
538
|
+
<DatePicker
|
|
539
|
+
timePickerProps={{
|
|
540
|
+
format: 'hh:mm',
|
|
541
|
+
timeInterval: 15,
|
|
542
|
+
}}
|
|
543
|
+
timeZonePickerProps={{
|
|
544
|
+
onChange: handleTimeZoneChange,
|
|
545
|
+
value: selectedTimeZone,
|
|
546
|
+
}}
|
|
547
|
+
reactDatePickerProps={{
|
|
548
|
+
onChange: handleOnChange,
|
|
549
|
+
popperProps: {
|
|
550
|
+
strategy: 'fixed',
|
|
551
|
+
},
|
|
552
|
+
selected: selectedDate,
|
|
553
|
+
showTimeInput: true,
|
|
554
|
+
}}
|
|
555
|
+
textInputProps={{
|
|
556
|
+
htmlAttributes: {
|
|
557
|
+
'aria-label': 'Date picker input',
|
|
558
|
+
},
|
|
559
|
+
}}
|
|
560
|
+
/>
|
|
561
|
+
<div style={{ marginTop: '1rem' }}>
|
|
562
|
+
<p>
|
|
563
|
+
<strong>Selected Date:</strong>{' '}
|
|
564
|
+
{selectedDate ? selectedDate.toISOString() : 'None'}
|
|
565
|
+
</p>
|
|
566
|
+
<p>
|
|
567
|
+
<strong>Selected Timezone:</strong> {selectedTimeZone}
|
|
568
|
+
</p>
|
|
569
|
+
</div>
|
|
570
|
+
</div>
|
|
571
|
+
);
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
export default Component;
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### With Timezone Both Mode
|
|
578
|
+
|
|
579
|
+
```tsx
|
|
580
|
+
import { useState } from 'react';
|
|
581
|
+
|
|
582
|
+
import { Typography } from '../../typography';
|
|
583
|
+
import { DatePicker } from '../DatePicker';
|
|
584
|
+
|
|
585
|
+
export const DatePickerWithTimeZoneBothMode = () => {
|
|
586
|
+
const [selectedDate, setSelectedDate] = useState<Date | null>(
|
|
587
|
+
// Every day is Christmas in Needle :)
|
|
588
|
+
new Date('2025-12-24'),
|
|
589
|
+
);
|
|
590
|
+
const [selectedTimeZone, setSelectedTimeZone] =
|
|
591
|
+
useState<string>('America/New_York');
|
|
592
|
+
|
|
593
|
+
return (
|
|
594
|
+
<div style={{ maxWidth: '400px', padding: '20px' }}>
|
|
595
|
+
<Typography variant="title-4" style={{ marginBottom: '16px' }}>
|
|
596
|
+
DatePicker with TimeZone (Both Mode)
|
|
597
|
+
</Typography>
|
|
598
|
+
<Typography variant="body-medium" style={{ marginBottom: '24px' }}>
|
|
599
|
+
This example shows the DatePicker with the TimeZonePicker in
|
|
600
|
+
"both" mode, displaying both UTC offsets and city-based
|
|
601
|
+
timezones in separate sections.
|
|
602
|
+
</Typography>
|
|
603
|
+
|
|
604
|
+
<DatePicker
|
|
605
|
+
textInputProps={{
|
|
606
|
+
label: 'Select Date and Time with Timezone',
|
|
607
|
+
}}
|
|
608
|
+
timePickerProps={{
|
|
609
|
+
format: 'hh:mm',
|
|
610
|
+
}}
|
|
611
|
+
timeZonePickerProps={{
|
|
612
|
+
mode: 'both',
|
|
613
|
+
onChange: (tz) => {
|
|
614
|
+
setSelectedTimeZone(tz);
|
|
615
|
+
},
|
|
616
|
+
value: selectedTimeZone,
|
|
617
|
+
}}
|
|
618
|
+
reactDatePickerProps={{
|
|
619
|
+
dateFormat: 'yyyy-MM-dd hh:mm',
|
|
620
|
+
onChange: (date) => {
|
|
621
|
+
setSelectedDate(date);
|
|
622
|
+
},
|
|
623
|
+
selected: selectedDate,
|
|
624
|
+
showTimeInput: true,
|
|
625
|
+
}}
|
|
626
|
+
/>
|
|
627
|
+
|
|
628
|
+
<div
|
|
629
|
+
style={{
|
|
630
|
+
backgroundColor: 'var(--theme-color-neutral-bg-default)',
|
|
631
|
+
borderRadius: '4px',
|
|
632
|
+
display: 'flex',
|
|
633
|
+
flexDirection: 'column',
|
|
634
|
+
marginTop: '24px',
|
|
635
|
+
padding: '16px',
|
|
636
|
+
}}
|
|
637
|
+
>
|
|
638
|
+
<Typography variant="label">Selected Values:</Typography>
|
|
639
|
+
<Typography variant="body-small">
|
|
640
|
+
<strong>Date: </strong>
|
|
641
|
+
{selectedDate?.toISOString() ?? 'None'}
|
|
642
|
+
</Typography>
|
|
643
|
+
<Typography variant="body-small">
|
|
644
|
+
<strong>Timezone:</strong> {selectedTimeZone || 'None'}
|
|
645
|
+
</Typography>
|
|
646
|
+
</div>
|
|
647
|
+
</div>
|
|
648
|
+
);
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
export default DatePickerWithTimeZoneBothMode;
|
|
652
|
+
```
|