@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,137 @@
|
|
|
1
|
+
# TimePicker
|
|
2
|
+
|
|
3
|
+
Import: `import { TimePicker } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### TimePicker
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
|
|
12
|
+
| `errorText` | `string` | | | Manually set the error text |
|
|
13
|
+
| `floatingStrategy` | `'absolute' \| 'fixed'` | | | Strategy for the dropdown floating element. By default it is absolute, but if the component is inside of a needle Dialog, it is set to fixed. If this prop is set, no auto-detection of Dialog is done. |
|
|
14
|
+
| `format` | `'hh:mm aa' \| 'hh:mm:ss aa' \| 'hh:mm:ss' \| 'hh:mm'` | | `hh:mm` | The format of the time picker |
|
|
15
|
+
| `isDisabled` | `boolean` | | | Whether the time picker is disabled |
|
|
16
|
+
| `isFluid` | `boolean` | | | Whether the time picker is fluid |
|
|
17
|
+
| `isPortaled` | `boolean` | | | Whether the dropdown element is rendered in a portal. |
|
|
18
|
+
| `isReadOnly` | `boolean` | | | Whether the time picker is read only |
|
|
19
|
+
| `isRequired` | `boolean` | | | Whether the time picker is required |
|
|
20
|
+
| `label` | `string` | | | The label of the time picker |
|
|
21
|
+
| `onChange` | `((time: NeedleTime) => void)` | | | Callback function triggered when the time picker value changes |
|
|
22
|
+
| `onError` | `((error: string, time: NeedleTime) => void)` | | | Callback function triggered when the time picker encounters an error |
|
|
23
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
24
|
+
| `size` | `'large' \| 'medium' \| 'small'` | | `medium` | The size of the time picker |
|
|
25
|
+
| `timeInterval` | `number` | | `15` | The time interval of the time picker, in minutes |
|
|
26
|
+
| `value` | `NeedleTime` | | | The value of the time picker |
|
|
27
|
+
|
|
28
|
+
## Examples
|
|
29
|
+
|
|
30
|
+
### Default
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
34
|
+
|
|
35
|
+
import { type NeedleTime, TimePicker } from '@neo4j-ndl/react';
|
|
36
|
+
import { useState } from 'react';
|
|
37
|
+
|
|
38
|
+
const Component = () => {
|
|
39
|
+
const [selectedTime, setSelectedTime] = useState<NeedleTime>();
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div style={{ height: '600px', padding: '20px' }}>
|
|
43
|
+
<TimePicker
|
|
44
|
+
label="Select Time"
|
|
45
|
+
value={selectedTime}
|
|
46
|
+
onChange={(time) => setSelectedTime(time)}
|
|
47
|
+
htmlAttributes={{ id: 'time-picker-input' }}
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default Component;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Error
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
60
|
+
|
|
61
|
+
import { type NeedleTime, TimePicker } from '@neo4j-ndl/react';
|
|
62
|
+
import { useState } from 'react';
|
|
63
|
+
|
|
64
|
+
const Component = () => {
|
|
65
|
+
const [selectedTime, setSelectedTime] = useState<NeedleTime>();
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div style={{ height: '600px', padding: '20px' }}>
|
|
69
|
+
<TimePicker
|
|
70
|
+
label="Select Time"
|
|
71
|
+
value={selectedTime}
|
|
72
|
+
onChange={(time) => setSelectedTime(time)}
|
|
73
|
+
errorText="Please select a valid time"
|
|
74
|
+
htmlAttributes={{ id: 'time-picker-input' }}
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default Component;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### In Dialog
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
87
|
+
|
|
88
|
+
import { Dialog, type NeedleTime, TimePicker } from '@neo4j-ndl/react';
|
|
89
|
+
import { useState } from 'react';
|
|
90
|
+
|
|
91
|
+
const Component = () => {
|
|
92
|
+
const [selectedTime, setSelectedTime] = useState<NeedleTime>();
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<Dialog isOpen={true} aria-label="Dialog">
|
|
96
|
+
<Dialog.Header>Using Time Picker inside a dialog</Dialog.Header>
|
|
97
|
+
<Dialog.Content>
|
|
98
|
+
<TimePicker
|
|
99
|
+
label="Select Time"
|
|
100
|
+
value={selectedTime}
|
|
101
|
+
onChange={(time) => setSelectedTime(time)}
|
|
102
|
+
htmlAttributes={{ id: 'time-picker-input' }}
|
|
103
|
+
/>
|
|
104
|
+
</Dialog.Content>
|
|
105
|
+
</Dialog>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default Component;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### With Seconds
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
116
|
+
|
|
117
|
+
import { type NeedleTime, TimePicker } from '@neo4j-ndl/react';
|
|
118
|
+
import { useState } from 'react';
|
|
119
|
+
|
|
120
|
+
const Component = () => {
|
|
121
|
+
const [selectedTime, setSelectedTime] = useState<NeedleTime>();
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div style={{ height: '600px', padding: '20px' }}>
|
|
125
|
+
<TimePicker
|
|
126
|
+
label="Select Time (with seconds)"
|
|
127
|
+
format="hh:mm:ss"
|
|
128
|
+
value={selectedTime}
|
|
129
|
+
onChange={(time) => setSelectedTime(time)}
|
|
130
|
+
htmlAttributes={{ id: 'time-picker-input' }}
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default Component;
|
|
137
|
+
```
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
# TimeZonePicker
|
|
2
|
+
|
|
3
|
+
Import: `import { TimeZonePicker } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### TimeZonePicker
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `errorText` | `string` | | | Manually set the error text |
|
|
12
|
+
| `floatingStrategy` | `'absolute' \| 'fixed'` | | | Strategy for the dropdown floating element. By default it is absolute, but if the component is inside of a needle Dialog, it is set to fixed. If this prop is set, no auto-detection of Dialog is done. |
|
|
13
|
+
| `isDisabled` | `boolean` | | | Whether the timezone picker is disabled |
|
|
14
|
+
| `isFluid` | `boolean` | | | Whether the timezone picker is fluid |
|
|
15
|
+
| `isPortaled` | `boolean` | | | Whether the dropdown element is rendered in a portal. |
|
|
16
|
+
| `isReadOnly` | `boolean` | | | Whether the timezone picker is read only |
|
|
17
|
+
| `isRequired` | `boolean` | | | Whether the timezone picker is required |
|
|
18
|
+
| `label` | `string` | | | The label of the timezone picker |
|
|
19
|
+
| `mode` | `'both' \| 'city' \| 'utc'` | | `city` | Display mode: 'city', 'utc', or 'both' 'city' - shows city-based timezones, This should be used when the user needs to select a timezone for themselves or if they are selecting a timezone that's related to a date. 'utc' - shows UTC timezones, This should be used when the user needs to select a timezone for a database entry or a technical application. 'both' - shows both city-based and UTC timezones in separate sections, This should be used when the user needs to select a timezone for a database entry or a technical application, but also wants to see the city-based timezones for context for example a zoned date time. @example <TimeZonePicker mode="city" /> <TimeZonePicker mode="utc" /> <TimeZonePicker mode="both" /> |
|
|
20
|
+
| `onChange` | `((timezone: string) => void)` | | | Callback function triggered when the timezone picker value changes |
|
|
21
|
+
| `onError` | `((error: string, timezone: string) => void)` | | | Callback function triggered when the timezone picker encounters an error |
|
|
22
|
+
| `ref` | `Ref<HTMLInputElement>` | | | A ref to apply to the root element. |
|
|
23
|
+
| `referenceDate` | `Date` | | | Reference date for calculating timezone offsets (useful for DST-aware offset display) |
|
|
24
|
+
| `size` | `'large' \| 'medium' \| 'small'` | | `medium` | The size of the timezone picker |
|
|
25
|
+
| `value` | `string` | | | The value of the timezone picker (IANA timezone identifier) |
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
### Default
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
33
|
+
|
|
34
|
+
import { TimeZonePicker } from '@neo4j-ndl/react';
|
|
35
|
+
import { useState } from 'react';
|
|
36
|
+
|
|
37
|
+
const Component = () => {
|
|
38
|
+
const [selectedTimeZone, setSelectedTimeZone] = useState<string>('UTC');
|
|
39
|
+
|
|
40
|
+
const handleTimeZoneChange = (timezone: string) => {
|
|
41
|
+
setSelectedTimeZone(timezone);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div>
|
|
46
|
+
<TimeZonePicker
|
|
47
|
+
label="Select Timezone"
|
|
48
|
+
value={selectedTimeZone}
|
|
49
|
+
onChange={handleTimeZoneChange}
|
|
50
|
+
htmlAttributes={{ id: 'time-zone-input' }}
|
|
51
|
+
/>
|
|
52
|
+
<div style={{ marginTop: '1rem' }}>
|
|
53
|
+
<p>Selected Timezone: {selectedTimeZone}</p>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default Component;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Both Mode
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { useState } from 'react';
|
|
66
|
+
|
|
67
|
+
import { Typography } from '../../typography';
|
|
68
|
+
import { TimeZonePicker } from '../TimeZonePicker';
|
|
69
|
+
|
|
70
|
+
export const TimeZonePickerBothMode = () => {
|
|
71
|
+
const [selectedTimezone, setSelectedTimezone] =
|
|
72
|
+
useState<string>('America/New_York');
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div style={{ maxWidth: '400px', padding: '20px' }}>
|
|
76
|
+
<Typography variant="title-4" style={{ marginBottom: '16px' }}>
|
|
77
|
+
Both Mode - UTC and City-Based Timezones
|
|
78
|
+
</Typography>
|
|
79
|
+
<Typography variant="body-medium" style={{ marginBottom: '24px' }}>
|
|
80
|
+
This mode displays both UTC offsets and city-based timezones in separate
|
|
81
|
+
sections within the dropdown. Perfect for users who need flexibility in
|
|
82
|
+
choosing between precise UTC offsets or familiar city names.
|
|
83
|
+
</Typography>
|
|
84
|
+
|
|
85
|
+
<TimeZonePicker
|
|
86
|
+
label="Select Timezone"
|
|
87
|
+
mode="both"
|
|
88
|
+
value={selectedTimezone}
|
|
89
|
+
onChange={(tz) => {
|
|
90
|
+
setSelectedTimezone(tz);
|
|
91
|
+
}}
|
|
92
|
+
htmlAttributes={{ id: 'time-zone-input' }}
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
<div
|
|
96
|
+
style={{
|
|
97
|
+
backgroundColor: '#f5f5f5',
|
|
98
|
+
borderRadius: '4px',
|
|
99
|
+
marginTop: '24px',
|
|
100
|
+
padding: '16px',
|
|
101
|
+
}}
|
|
102
|
+
>
|
|
103
|
+
<Typography
|
|
104
|
+
variant="body-small"
|
|
105
|
+
style={{ fontWeight: 600, marginBottom: '8px' }}
|
|
106
|
+
>
|
|
107
|
+
Selected Timezone:
|
|
108
|
+
</Typography>
|
|
109
|
+
<Typography variant="body-medium">
|
|
110
|
+
{selectedTimezone || 'None'}
|
|
111
|
+
</Typography>
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
<div style={{ marginTop: '16px' }}>
|
|
115
|
+
<Typography variant="body-small" style={{ color: '#666' }}>
|
|
116
|
+
<strong>Features:</strong>
|
|
117
|
+
<ul style={{ marginTop: '8px', paddingLeft: '20px' }}>
|
|
118
|
+
<li>
|
|
119
|
+
Two separate sections: "UTC Offsets" and
|
|
120
|
+
"City-Based Timezones"
|
|
121
|
+
</li>
|
|
122
|
+
<li>Search across both sections simultaneously</li>
|
|
123
|
+
<li>Custom UTC input support (e.g., UTC+5:30)</li>
|
|
124
|
+
<li>All standard UTC offsets from UTC-12 to UTC+14</li>
|
|
125
|
+
<li>All IANA timezone identifiers with city names</li>
|
|
126
|
+
</ul>
|
|
127
|
+
</Typography>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default TimeZonePickerBothMode;
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Disabled
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
140
|
+
|
|
141
|
+
import { TimeZonePicker } from '@neo4j-ndl/react';
|
|
142
|
+
|
|
143
|
+
const Component = () => {
|
|
144
|
+
return (
|
|
145
|
+
<TimeZonePicker
|
|
146
|
+
isDisabled
|
|
147
|
+
label="Disabled Timezone Picker"
|
|
148
|
+
value="Asia/Tokyo"
|
|
149
|
+
htmlAttributes={{ id: 'time-zone-input' }}
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export default Component;
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Dst Aware
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
161
|
+
|
|
162
|
+
import { TimeZonePicker } from '@neo4j-ndl/react';
|
|
163
|
+
import { useState } from 'react';
|
|
164
|
+
|
|
165
|
+
const Component = () => {
|
|
166
|
+
const [selectedTimeZone, setSelectedTimeZone] =
|
|
167
|
+
useState<string>('Europe/Stockholm');
|
|
168
|
+
const [referenceDate, setReferenceDate] = useState<Date>(
|
|
169
|
+
new Date('2025-01-01'),
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
// Create summer and winter dates for DST demonstration
|
|
173
|
+
const summerDate = new Date('2024-07-15T12:00:00'); // July (DST in effect)
|
|
174
|
+
const winterDate = new Date('2024-01-15T12:00:00'); // January (Standard time)
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}>
|
|
178
|
+
<div>
|
|
179
|
+
<h3 style={{ marginBottom: '1rem' }}>DST-Aware Timezone Picker Demo</h3>
|
|
180
|
+
<p style={{ color: '#666', marginBottom: '1rem' }}>
|
|
181
|
+
The timezone offsets change based on the reference date to account for
|
|
182
|
+
Daylight Saving Time.
|
|
183
|
+
</p>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div style={{ display: 'flex', gap: '1rem', marginBottom: '1rem' }}>
|
|
187
|
+
<button
|
|
188
|
+
type="button"
|
|
189
|
+
onClick={() => setReferenceDate(summerDate)}
|
|
190
|
+
style={{
|
|
191
|
+
backgroundColor: referenceDate === summerDate ? '#0066cc' : 'white',
|
|
192
|
+
border: '1px solid #ccc',
|
|
193
|
+
borderRadius: '4px',
|
|
194
|
+
color: referenceDate === summerDate ? 'white' : 'black',
|
|
195
|
+
cursor: 'pointer',
|
|
196
|
+
padding: '0.5rem 1rem',
|
|
197
|
+
}}
|
|
198
|
+
>
|
|
199
|
+
Summer Date (July 15, 2024)
|
|
200
|
+
</button>
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
onClick={() => setReferenceDate(winterDate)}
|
|
204
|
+
style={{
|
|
205
|
+
backgroundColor: referenceDate === winterDate ? '#0066cc' : 'white',
|
|
206
|
+
border: '1px solid #ccc',
|
|
207
|
+
borderRadius: '4px',
|
|
208
|
+
color: referenceDate === winterDate ? 'white' : 'black',
|
|
209
|
+
cursor: 'pointer',
|
|
210
|
+
padding: '0.5rem 1rem',
|
|
211
|
+
}}
|
|
212
|
+
>
|
|
213
|
+
Winter Date (January 15, 2024)
|
|
214
|
+
</button>
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
<TimeZonePicker
|
|
218
|
+
label="Select Timezone"
|
|
219
|
+
value={selectedTimeZone}
|
|
220
|
+
onChange={setSelectedTimeZone}
|
|
221
|
+
referenceDate={referenceDate}
|
|
222
|
+
htmlAttributes={{ id: 'time-zone-input' }}
|
|
223
|
+
/>
|
|
224
|
+
|
|
225
|
+
<div
|
|
226
|
+
style={{
|
|
227
|
+
backgroundColor: '#f5f5f5',
|
|
228
|
+
borderRadius: '4px',
|
|
229
|
+
|
|
230
|
+
padding: '1rem',
|
|
231
|
+
}}
|
|
232
|
+
>
|
|
233
|
+
<p>
|
|
234
|
+
<strong>Selected Timezone:</strong> {selectedTimeZone}
|
|
235
|
+
</p>
|
|
236
|
+
<p>
|
|
237
|
+
<strong>Reference Date:</strong> {referenceDate.toLocaleDateString()}
|
|
238
|
+
</p>
|
|
239
|
+
<p>
|
|
240
|
+
<strong>Example:</strong> New York shows GMT-4 in summer (EDT) and
|
|
241
|
+
GMT-5 in winter (EST)
|
|
242
|
+
</p>
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export default Component;
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Error
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
255
|
+
|
|
256
|
+
import { TimeZonePicker } from '@neo4j-ndl/react';
|
|
257
|
+
import { useState } from 'react';
|
|
258
|
+
|
|
259
|
+
const Component = () => {
|
|
260
|
+
const [selectedTimeZone, setSelectedTimeZone] = useState<string>('UTC');
|
|
261
|
+
|
|
262
|
+
const handleTimeZoneChange = (timezone: string) => {
|
|
263
|
+
setSelectedTimeZone(timezone);
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
return (
|
|
267
|
+
<div>
|
|
268
|
+
<TimeZonePicker
|
|
269
|
+
label="Select Timezone"
|
|
270
|
+
value={selectedTimeZone}
|
|
271
|
+
onChange={handleTimeZoneChange}
|
|
272
|
+
errorText="Please select a valid timezone"
|
|
273
|
+
htmlAttributes={{ id: 'time-zone-input' }}
|
|
274
|
+
/>
|
|
275
|
+
</div>
|
|
276
|
+
);
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export default Component;
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Fluid
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
286
|
+
|
|
287
|
+
import { TimeZonePicker } from '@neo4j-ndl/react';
|
|
288
|
+
|
|
289
|
+
const Component = () => {
|
|
290
|
+
return (
|
|
291
|
+
<div style={{ maxWidth: '400px', width: '100%' }}>
|
|
292
|
+
<TimeZonePicker
|
|
293
|
+
isFluid
|
|
294
|
+
label="Select Timezone"
|
|
295
|
+
htmlAttributes={{ id: 'time-zone-input' }}
|
|
296
|
+
/>
|
|
297
|
+
</div>
|
|
298
|
+
);
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export default Component;
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### In Dialog
|
|
305
|
+
|
|
306
|
+
```tsx
|
|
307
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
308
|
+
|
|
309
|
+
import {
|
|
310
|
+
Dialog,
|
|
311
|
+
FilledButton,
|
|
312
|
+
OutlinedButton,
|
|
313
|
+
TimeZonePicker,
|
|
314
|
+
} from '@neo4j-ndl/react';
|
|
315
|
+
import { useRef, useState } from 'react';
|
|
316
|
+
|
|
317
|
+
const Component = () => {
|
|
318
|
+
const [isOpen, setIsOpen] = useState<boolean>(false);
|
|
319
|
+
const [selectedTimeZone, setSelectedTimeZone] = useState<string>('UTC');
|
|
320
|
+
const [tempTimeZone, setTempTimeZone] = useState<string>('UTC');
|
|
321
|
+
const ref = useRef<HTMLDivElement | null>(null);
|
|
322
|
+
|
|
323
|
+
const handleOpen = () => {
|
|
324
|
+
setTempTimeZone(selectedTimeZone);
|
|
325
|
+
setIsOpen(true);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
const handleClose = () => setIsOpen(false);
|
|
329
|
+
|
|
330
|
+
const handleSave = () => {
|
|
331
|
+
setSelectedTimeZone(tempTimeZone);
|
|
332
|
+
setIsOpen(false);
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
const handleTimeZoneChange = (timezone: string) => {
|
|
336
|
+
setTempTimeZone(timezone);
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
return (
|
|
340
|
+
<div
|
|
341
|
+
ref={ref}
|
|
342
|
+
className="n-flex n-flex-col n-items-center n-justify-center n-relative n-h-[500px] n-w-full"
|
|
343
|
+
>
|
|
344
|
+
<div className="n-flex n-flex-col n-items-center n-gap-4">
|
|
345
|
+
<FilledButton onClick={handleOpen}>Select Timezone</FilledButton>
|
|
346
|
+
<div>
|
|
347
|
+
<p>Selected Timezone: {selectedTimeZone}</p>
|
|
348
|
+
</div>
|
|
349
|
+
</div>
|
|
350
|
+
<Dialog
|
|
351
|
+
onClose={handleClose}
|
|
352
|
+
isOpen={isOpen}
|
|
353
|
+
container={ref?.current || undefined}
|
|
354
|
+
size="medium"
|
|
355
|
+
>
|
|
356
|
+
<Dialog.Header>Select Timezone</Dialog.Header>
|
|
357
|
+
<Dialog.Description>
|
|
358
|
+
Choose a timezone from the list below
|
|
359
|
+
</Dialog.Description>
|
|
360
|
+
<Dialog.Content>
|
|
361
|
+
<TimeZonePicker
|
|
362
|
+
isFluid
|
|
363
|
+
label="Timezone"
|
|
364
|
+
value={tempTimeZone}
|
|
365
|
+
onChange={handleTimeZoneChange}
|
|
366
|
+
htmlAttributes={{ id: 'time-zone-input' }}
|
|
367
|
+
/>
|
|
368
|
+
</Dialog.Content>
|
|
369
|
+
<Dialog.Actions>
|
|
370
|
+
<OutlinedButton onClick={handleClose} variant="neutral" size="medium">
|
|
371
|
+
Cancel
|
|
372
|
+
</OutlinedButton>
|
|
373
|
+
<FilledButton onClick={handleSave} size="medium">
|
|
374
|
+
Save
|
|
375
|
+
</FilledButton>
|
|
376
|
+
</Dialog.Actions>
|
|
377
|
+
</Dialog>
|
|
378
|
+
</div>
|
|
379
|
+
);
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
export default Component;
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Sizes
|
|
386
|
+
|
|
387
|
+
```tsx
|
|
388
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
389
|
+
|
|
390
|
+
import { TimeZonePicker } from '@neo4j-ndl/react';
|
|
391
|
+
import { useState } from 'react';
|
|
392
|
+
|
|
393
|
+
const Component = () => {
|
|
394
|
+
const [selectedTimeZone, setSelectedTimeZone] =
|
|
395
|
+
useState<string>('Europe/Stockholm');
|
|
396
|
+
|
|
397
|
+
return (
|
|
398
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
|
399
|
+
<TimeZonePicker
|
|
400
|
+
label="Small"
|
|
401
|
+
value={selectedTimeZone}
|
|
402
|
+
onChange={setSelectedTimeZone}
|
|
403
|
+
size="small"
|
|
404
|
+
htmlAttributes={{ id: 'time-zone-input-small' }}
|
|
405
|
+
/>
|
|
406
|
+
<TimeZonePicker
|
|
407
|
+
label="Medium (default)"
|
|
408
|
+
value={selectedTimeZone}
|
|
409
|
+
onChange={setSelectedTimeZone}
|
|
410
|
+
size="medium"
|
|
411
|
+
htmlAttributes={{ id: 'time-zone-input-medium' }}
|
|
412
|
+
/>
|
|
413
|
+
<TimeZonePicker
|
|
414
|
+
label="Large"
|
|
415
|
+
value={selectedTimeZone}
|
|
416
|
+
onChange={setSelectedTimeZone}
|
|
417
|
+
size="large"
|
|
418
|
+
htmlAttributes={{ id: 'time-zone-input-large' }}
|
|
419
|
+
/>
|
|
420
|
+
</div>
|
|
421
|
+
);
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
export default Component;
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Utc Only
|
|
428
|
+
|
|
429
|
+
```tsx
|
|
430
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
431
|
+
|
|
432
|
+
import { TimeZonePicker } from '@neo4j-ndl/react';
|
|
433
|
+
import { useState } from 'react';
|
|
434
|
+
|
|
435
|
+
const Component = () => {
|
|
436
|
+
const [selectedTimeZone, setSelectedTimeZone] = useState<string>('UTC');
|
|
437
|
+
|
|
438
|
+
const handleTimeZoneChange = (timezone: string) => {
|
|
439
|
+
setSelectedTimeZone(timezone);
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
return (
|
|
443
|
+
<div>
|
|
444
|
+
<TimeZonePicker
|
|
445
|
+
label="Select UTC Timezone"
|
|
446
|
+
value={selectedTimeZone}
|
|
447
|
+
onChange={handleTimeZoneChange}
|
|
448
|
+
mode="utc"
|
|
449
|
+
htmlAttributes={{ id: 'time-zone-input' }}
|
|
450
|
+
/>
|
|
451
|
+
<div style={{ marginTop: '1rem' }}>
|
|
452
|
+
<p>
|
|
453
|
+
<strong>Selected Timezone:</strong> {selectedTimeZone}
|
|
454
|
+
</p>
|
|
455
|
+
<div
|
|
456
|
+
style={{
|
|
457
|
+
backgroundColor: '#f5f5f5',
|
|
458
|
+
borderRadius: '4px',
|
|
459
|
+
|
|
460
|
+
marginTop: '1rem',
|
|
461
|
+
padding: '1rem',
|
|
462
|
+
}}
|
|
463
|
+
>
|
|
464
|
+
<p>
|
|
465
|
+
<strong>Features:</strong>
|
|
466
|
+
</p>
|
|
467
|
+
<ul
|
|
468
|
+
style={{
|
|
469
|
+
fontSize: '0.9em',
|
|
470
|
+
margin: 0,
|
|
471
|
+
paddingLeft: '1.5rem',
|
|
472
|
+
}}
|
|
473
|
+
>
|
|
474
|
+
<li>Select from common UTC offsets (UTC-12 to UTC+14)</li>
|
|
475
|
+
<li>Includes fractional offsets (UTC+5:30, UTC+9:30, etc.)</li>
|
|
476
|
+
<li>Type custom offsets: UTC+1:05, UTC-3:45, etc.</li>
|
|
477
|
+
<li>Ideal for database entries and technical applications</li>
|
|
478
|
+
</ul>
|
|
479
|
+
<p
|
|
480
|
+
style={{
|
|
481
|
+
color: '#999',
|
|
482
|
+
fontSize: '0.85em',
|
|
483
|
+
marginBottom: 0,
|
|
484
|
+
marginTop: '0.5rem',
|
|
485
|
+
}}
|
|
486
|
+
>
|
|
487
|
+
Try typing: UTC+5:30, UTC-7:15, or UTC+12:45
|
|
488
|
+
</p>
|
|
489
|
+
</div>
|
|
490
|
+
</div>
|
|
491
|
+
</div>
|
|
492
|
+
);
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
export default Component;
|
|
496
|
+
```
|