@indico-data/design-system 3.0.7 → 3.0.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.
Files changed (30) hide show
  1. package/lib/components/floatUI/FloatUI.d.ts +1 -1
  2. package/lib/components/floatUI/types.d.ts +1 -0
  3. package/lib/components/forms/date/datePicker/types.d.ts +4 -0
  4. package/lib/components/forms/date/inputDatePicker/SingleInputDatePicker.d.ts +4 -0
  5. package/lib/components/forms/date/inputDateRangePicker/InputDateRangePicker.d.ts +6 -0
  6. package/lib/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.d.ts +6 -0
  7. package/lib/components/forms/input/Input.d.ts +1 -0
  8. package/lib/components/forms/textarea/Textarea.d.ts +1 -0
  9. package/lib/components/forms/timePicker/TimePicker.d.ts +7 -1
  10. package/lib/index.d.ts +56 -3
  11. package/lib/index.esm.js +67 -22
  12. package/lib/index.esm.js.map +1 -1
  13. package/lib/index.js +67 -21
  14. package/lib/index.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/components/floatUI/FloatUI.tsx +2 -1
  17. package/src/components/floatUI/types.ts +1 -0
  18. package/src/components/forms/date/datePicker/DatePicker.tsx +11 -1
  19. package/src/components/forms/date/datePicker/types.ts +4 -0
  20. package/src/components/forms/date/inputDatePicker/SingleInputDatePicker.stories.tsx +28 -0
  21. package/src/components/forms/date/inputDatePicker/SingleInputDatePicker.tsx +12 -0
  22. package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.stories.tsx +56 -0
  23. package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.tsx +20 -0
  24. package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.stories.tsx +44 -0
  25. package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.tsx +28 -6
  26. package/src/components/forms/input/Input.tsx +3 -0
  27. package/src/components/forms/textarea/Textarea.tsx +3 -0
  28. package/src/components/forms/timePicker/TimePicker.tsx +18 -0
  29. package/src/index.ts +1 -0
  30. package/src/storybook/formArgTypes.ts +14 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "3.0.7",
3
+ "version": "3.0.9",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -26,6 +26,7 @@ export function FloatUI({
26
26
  isPortal = false,
27
27
  portalOptions = {},
28
28
  floatingOptions = defaultOptions,
29
+ className,
29
30
  }: FloatUIProps) {
30
31
  const [internalIsOpen, setInternalIsOpen] = useState(false);
31
32
 
@@ -71,7 +72,7 @@ export function FloatUI({
71
72
  style={floatingStyles}
72
73
  role="dialog"
73
74
  aria-label={ariaLabel}
74
- className="floatui-container"
75
+ className={`floatui-container ${className}`}
75
76
  >
76
77
  <div ref={floatUIContentRef} className="floatui-content">
77
78
  {content}
@@ -6,6 +6,7 @@ export type FloatUIProps = {
6
6
  ariaLabel: string;
7
7
  floatingOptions?: UseFloatingOptions;
8
8
  isOpen?: boolean;
9
+ className?: string;
9
10
  isPortal?: boolean;
10
11
  portalOptions?: {
11
12
  rootId?: string;
@@ -34,6 +34,10 @@ export const DatePicker = (props: DatePickerProps) => {
34
34
  onNextClick,
35
35
  onPrevClick,
36
36
  onDayClick,
37
+ isReadOnly,
38
+ ref,
39
+ timeTabIndex,
40
+ dateTabIndex,
37
41
  ...rest
38
42
  } = props;
39
43
 
@@ -90,7 +94,13 @@ export const DatePicker = (props: DatePickerProps) => {
90
94
  <p className="ma-0">Select Time</p>
91
95
  </Col>
92
96
  <Col>
93
- <TimePicker timeValue={timeValue ?? ''} onTimeChange={handleTimeChange} />
97
+ <TimePicker
98
+ ref={ref}
99
+ timeValue={timeValue ?? ''}
100
+ onTimeChange={handleTimeChange}
101
+ readonly={isReadOnly}
102
+ tabIndex={timeTabIndex}
103
+ />
94
104
  </Col>
95
105
  </Row>
96
106
  </div>
@@ -10,6 +10,7 @@ import {
10
10
  } from 'react-day-picker';
11
11
 
12
12
  export interface DatePickerProps {
13
+ ref?: React.LegacyRef<HTMLInputElement>;
13
14
  selected?: Date | DateRange | undefined;
14
15
  onSelect?: OnSelectHandler<Date> | OnSelectHandler<DateRange>;
15
16
  mode?: Mode;
@@ -37,6 +38,9 @@ export interface DatePickerProps {
37
38
  onNextClick?: MonthChangeEventHandler;
38
39
  onPrevClick?: MonthChangeEventHandler;
39
40
  onDayClick?: DayEventHandler<React.MouseEvent>;
41
+ isReadOnly?: boolean;
42
+ timeTabIndex?: number;
43
+ dateTabIndex?: number;
40
44
  }
41
45
 
42
46
  export interface CommonProps {
@@ -13,6 +13,34 @@ const meta: Meta<typeof SingleInputDatePicker> = {
13
13
  ),
14
14
  ],
15
15
  argTypes: {
16
+ tabIndex: {
17
+ control: 'number',
18
+ description: 'The tab index of the input field.',
19
+ table: {
20
+ category: 'Props',
21
+ },
22
+ },
23
+ ref: {
24
+ control: false,
25
+ description: 'The ref of the input field.',
26
+ table: {
27
+ category: 'Props',
28
+ },
29
+ },
30
+ isReadOnly: {
31
+ control: 'boolean',
32
+ description: 'Whether the date picker is read only.',
33
+ table: {
34
+ category: 'Props',
35
+ },
36
+ },
37
+ hasHiddenLabel: {
38
+ control: 'boolean',
39
+ description: 'Whether the label is hidden.',
40
+ table: {
41
+ category: 'Props',
42
+ },
43
+ },
16
44
  ariaLabel: {
17
45
  control: 'text',
18
46
  description: 'A label for assistive technologies.',
@@ -24,7 +24,11 @@ export interface SingleInputDatePickerProps {
24
24
  isClearable?: boolean;
25
25
  inputPlaceholder?: string;
26
26
  errorMessage?: string | undefined;
27
+ hasHiddenLabel?: boolean;
27
28
  'data-testid'?: string;
29
+ ref?: React.LegacyRef<HTMLInputElement>;
30
+ isReadOnly?: boolean;
31
+ tabIndex?: number;
28
32
  }
29
33
 
30
34
  export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
@@ -46,6 +50,10 @@ export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
46
50
  isClearable,
47
51
  errorMessage,
48
52
  onSelect,
53
+ hasHiddenLabel,
54
+ ref,
55
+ isReadOnly,
56
+ tabIndex,
49
57
  ...rest
50
58
  } = props;
51
59
 
@@ -97,12 +105,16 @@ export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
97
105
  value={localTextValue}
98
106
  placeholder={inputPlaceholder}
99
107
  isDisabled={isDisabled}
108
+ hasHiddenLabel={hasHiddenLabel}
100
109
  iconName={inputIconName}
101
110
  isClearable={isClearable}
102
111
  onChange={handleInputChange}
103
112
  errorMessage={errorMessage}
104
113
  label={'Single Date Picker'}
114
+ tabIndex={tabIndex}
105
115
  name={'Date Picker'}
116
+ ref={ref}
117
+ readonly={isReadOnly}
106
118
  />
107
119
  <DatePicker
108
120
  captionLayout={captionLayout}
@@ -15,6 +15,62 @@ const meta: Meta<typeof InputDateRangePicker> = {
15
15
  ),
16
16
  ],
17
17
  argTypes: {
18
+ toTabIndex: {
19
+ control: 'number',
20
+ description: 'The tab index of the to input field.',
21
+ table: {
22
+ category: 'Props',
23
+ },
24
+ },
25
+ fromTabIndex: {
26
+ control: 'number',
27
+ description: 'The tab index of the from input field.',
28
+ table: {
29
+ category: 'Props',
30
+ },
31
+ },
32
+ ref: {
33
+ control: false,
34
+ description: 'The ref of the input field.',
35
+ table: {
36
+ category: 'Props',
37
+ },
38
+ },
39
+ isFromReadOnly: {
40
+ control: 'boolean',
41
+ description: 'Whether the from input is read only.',
42
+ table: {
43
+ category: 'Props',
44
+ },
45
+ },
46
+ isToReadOnly: {
47
+ control: 'boolean',
48
+ description: 'Whether the to input is read only.',
49
+ table: {
50
+ category: 'Props',
51
+ },
52
+ },
53
+ hasHiddenLabel: {
54
+ control: 'boolean',
55
+ description: 'Whether the label is hidden.',
56
+ table: {
57
+ category: 'Props',
58
+ },
59
+ },
60
+ gutterWidth: {
61
+ control: 'number',
62
+ description: 'The gutter width for the date picker.',
63
+ table: {
64
+ category: 'Props',
65
+ },
66
+ },
67
+ setIsOpen: {
68
+ control: 'boolean',
69
+ description: 'Whether the date picker is open.',
70
+ table: {
71
+ category: 'Props',
72
+ },
73
+ },
18
74
  ariaLabel: {
19
75
  control: 'text',
20
76
  description: 'A label for assistive technologies.',
@@ -32,6 +32,12 @@ interface InputDateRangePickerProps {
32
32
  toLabel?: string;
33
33
  closeOnSelect?: boolean;
34
34
  clearOnClose?: boolean;
35
+ hasHiddenLabel?: boolean;
36
+ ref?: React.LegacyRef<HTMLInputElement>;
37
+ isFromReadOnly?: boolean;
38
+ isToReadOnly?: boolean;
39
+ toTabIndex?: number;
40
+ fromTabIndex?: number;
35
41
  }
36
42
 
37
43
  export function InputDateRangePicker(props: InputDateRangePickerProps) {
@@ -57,6 +63,12 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
57
63
  toLabel,
58
64
  closeOnSelect,
59
65
  clearOnClose,
66
+ hasHiddenLabel,
67
+ ref,
68
+ isFromReadOnly,
69
+ isToReadOnly,
70
+ toTabIndex,
71
+ fromTabIndex,
60
72
  ...rest
61
73
  } = props;
62
74
 
@@ -151,6 +163,10 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
151
163
  label={fromLabel}
152
164
  name={'From Date'}
153
165
  data-testid="date-picker-from"
166
+ hasHiddenLabel={hasHiddenLabel}
167
+ ref={ref}
168
+ readonly={isFromReadOnly}
169
+ tabIndex={fromTabIndex}
154
170
  />
155
171
  </Col>
156
172
  <Col>
@@ -165,6 +181,10 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
165
181
  label={toLabel}
166
182
  name={'To Date'}
167
183
  data-testid="date-picker-to"
184
+ hasHiddenLabel={hasHiddenLabel}
185
+ ref={ref}
186
+ readonly={isToReadOnly}
187
+ tabIndex={toTabIndex}
168
188
  />
169
189
  </Col>
170
190
  </Row>
@@ -20,6 +20,50 @@ const meta: Meta<typeof SingleInputDateTimePicker> = {
20
20
  ),
21
21
  ],
22
22
  argTypes: {
23
+ dateTabIndex: {
24
+ control: 'number',
25
+ description: 'The tab index of the date input field.',
26
+ table: {
27
+ category: 'Props',
28
+ },
29
+ },
30
+ timeTabIndex: {
31
+ control: 'number',
32
+ description: 'The tab index of the time input field.',
33
+ table: {
34
+ category: 'Props',
35
+ },
36
+ },
37
+ ref: {
38
+ control: false,
39
+ description: 'The ref of the input field.',
40
+ table: {
41
+ category: 'Props',
42
+ },
43
+ },
44
+ timePickerRef: {
45
+ control: false,
46
+ description: 'The ref of the time picker input field.',
47
+ table: {
48
+ category: 'Props',
49
+ },
50
+ },
51
+ isReadOnly: {
52
+ control: 'boolean',
53
+ description: 'Whether the date picker is read only.',
54
+ table: {
55
+ category: 'Props',
56
+ },
57
+ },
58
+
59
+ hasHiddenLabel: {
60
+ control: 'boolean',
61
+ description: 'Whether the label is hidden.',
62
+ table: {
63
+ category: 'Props',
64
+ },
65
+ },
66
+
23
67
  timeValue: {
24
68
  control: 'text',
25
69
  description: 'The time value to display.',
@@ -27,8 +27,14 @@ export interface SingleInputDateTimePickerProps {
27
27
  inputPlaceholder?: string;
28
28
  errorMessage?: string | undefined;
29
29
  'data-testid'?: string;
30
+ hasHiddenLabel?: boolean;
30
31
  timeValue?: string;
31
32
  onTimeChange?: (time: string) => void;
33
+ isReadOnly?: boolean;
34
+ ref?: React.LegacyRef<HTMLInputElement>;
35
+ timePickerRef?: React.LegacyRef<HTMLInputElement>;
36
+ dateTabIndex?: number;
37
+ timeTabIndex?: number;
32
38
  }
33
39
 
34
40
  export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps) {
@@ -52,6 +58,12 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
52
58
  onSelect,
53
59
  timeValue,
54
60
  onTimeChange,
61
+ hasHiddenLabel,
62
+ isReadOnly,
63
+ timePickerRef,
64
+ dateTabIndex,
65
+ timeTabIndex,
66
+ ref,
55
67
  ...rest
56
68
  } = props;
57
69
 
@@ -101,21 +113,25 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
101
113
  };
102
114
 
103
115
  return (
104
- <Row>
105
- <Col>
106
- <FloatUI isOpen={isOpen} ariaLabel={ariaLabel}>
116
+ <Row className="date-time-picker-row">
117
+ <Col className="date-picker-col">
118
+ <FloatUI className="date-picker-float-ui" isOpen={isOpen} ariaLabel={ariaLabel}>
107
119
  <Input
120
+ ref={ref}
121
+ className={`date-picker-input`}
108
122
  id={inputId}
109
123
  value={localTextValue}
110
124
  placeholder={inputPlaceholder}
111
- isDisabled={isDisabled}
125
+ isDisabled={isReadOnly || isDisabled}
126
+ readonly={isReadOnly}
112
127
  iconName={inputIconName}
113
128
  isClearable={isClearable}
114
129
  onChange={handleInputChange}
115
130
  errorMessage={errorMessage}
116
- hasHiddenLabel
131
+ hasHiddenLabel={hasHiddenLabel}
117
132
  label={'Single Date Picker'}
118
133
  name={`${id}-date-picker`}
134
+ tabIndex={dateTabIndex}
119
135
  />
120
136
  <DatePicker
121
137
  captionLayout={captionLayout}
@@ -124,16 +140,22 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
124
140
  onSelect={handleDayPickerSelect}
125
141
  month={localMonth}
126
142
  onMonthChange={setLocalMonth}
143
+ isReadOnly={isReadOnly}
127
144
  {...rest}
128
145
  />
129
146
  </FloatUI>
130
147
  </Col>
131
- <Col xs="content">
148
+ <Col xs="content" className="time-picker-col">
132
149
  <TimePicker
150
+ ref={timePickerRef}
151
+ className={`time-picker-input`}
133
152
  timeValue={timeValue}
134
153
  name={`${id}-time-picker`}
135
154
  hasHiddenLabel
136
155
  onTimeChange={handleTimeChange}
156
+ isReadOnly={isReadOnly}
157
+ isDisabled={isDisabled}
158
+ tabIndex={timeTabIndex}
137
159
  />
138
160
  </Col>
139
161
  </Row>
@@ -22,6 +22,7 @@ export interface BaseInputProps {
22
22
  isClearable?: boolean;
23
23
  className?: string;
24
24
  defaultValue?: string;
25
+ tabIndex?: number;
25
26
  }
26
27
 
27
28
  export interface InputProps extends BaseInputProps, LabelProps {}
@@ -40,6 +41,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
40
41
  helpText,
41
42
  maxLength,
42
43
  iconName,
44
+ tabIndex,
43
45
  onChange,
44
46
  onBlur,
45
47
  onKeyDown,
@@ -71,6 +73,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
71
73
  )}
72
74
  <input
73
75
  ref={ref}
76
+ tabIndex={tabIndex}
74
77
  id={id}
75
78
  data-testid={`form-input-${name}`}
76
79
  name={name}
@@ -21,6 +21,7 @@ export interface TextareaProps extends LabelProps {
21
21
  maxLength?: number;
22
22
  autofocus?: boolean;
23
23
  defaultValue?: string;
24
+ tabIndex?: number;
24
25
  }
25
26
  const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
26
27
  (
@@ -44,6 +45,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
44
45
  maxLength,
45
46
  autofocus,
46
47
  defaultValue,
48
+ tabIndex,
47
49
  ...rest
48
50
  },
49
51
  ref,
@@ -76,6 +78,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
76
78
  aria-required={isRequired}
77
79
  value={value}
78
80
  defaultValue={defaultValue}
81
+ tabIndex={tabIndex}
79
82
  {...rest}
80
83
  />
81
84
  </div>
@@ -3,19 +3,31 @@ import { Input } from '../input/Input';
3
3
  import { formatTimeValue, validateInputValue } from './helpers';
4
4
 
5
5
  interface TimePickerProps {
6
+ ref?: React.LegacyRef<HTMLInputElement>;
6
7
  timeValue?: string;
7
8
  label?: string;
8
9
  name?: string;
9
10
  hasHiddenLabel?: boolean;
10
11
  onTimeChange?: (time: string) => void;
12
+ className?: string;
13
+ isReadOnly?: boolean;
14
+ isDisabled?: boolean;
15
+ tabIndex?: number;
16
+ [key: string]: unknown;
11
17
  }
12
18
 
13
19
  export const TimePicker = ({
20
+ ref,
14
21
  timeValue = '',
15
22
  label = 'Time Picker',
16
23
  name = 'time-picker',
17
24
  hasHiddenLabel = false,
18
25
  onTimeChange,
26
+ className,
27
+ isDisabled,
28
+ isReadOnly,
29
+ tabIndex,
30
+ ...rest
19
31
  }: TimePickerProps) => {
20
32
  const [validationError, setValidationError] = useState('');
21
33
  const [inputValue, setInputValue] = useState(timeValue);
@@ -46,6 +58,9 @@ export const TimePicker = ({
46
58
  return (
47
59
  <div className="time-input-wrapper">
48
60
  <Input
61
+ ref={ref}
62
+ tabIndex={tabIndex}
63
+ className={className}
49
64
  data-testid={`${name}-input`}
50
65
  label={label}
51
66
  hasHiddenLabel={hasHiddenLabel}
@@ -55,6 +70,9 @@ export const TimePicker = ({
55
70
  onBlur={handleBlur}
56
71
  name={name}
57
72
  errorMessage={validationError}
73
+ readonly={isReadOnly}
74
+ isDisabled={isDisabled}
75
+ {...rest}
58
76
  />
59
77
  </div>
60
78
  );
package/src/index.ts CHANGED
@@ -20,6 +20,7 @@ export { TimePicker } from './components/forms/timePicker';
20
20
  export { IconTriggerDatePicker } from './components/forms/date/iconTriggerDatePicker';
21
21
  export { SingleInputDatePicker } from './components/forms/date/inputDatePicker';
22
22
  export { InputDateRangePicker } from './components/forms/date/inputDateRangePicker';
23
+ export { SingleInputDateTimePicker } from './components/forms/date/inputDateTimePicker';
23
24
  export { Form } from './components/forms/form';
24
25
  export { Skeleton } from './components/skeleton';
25
26
  export { Card } from './components/card';
@@ -49,6 +49,13 @@ const labelArgTypes: ArgTypes = {
49
49
  };
50
50
 
51
51
  const baseInputArgTypes: ArgTypes = {
52
+ readonly: {
53
+ control: 'boolean',
54
+ description: 'Whether the input is read only.',
55
+ table: {
56
+ category: 'Props',
57
+ },
58
+ },
52
59
  onChange: {
53
60
  control: false,
54
61
  description: 'onChange event handler',
@@ -148,6 +155,13 @@ const baseInputArgTypes: ArgTypes = {
148
155
 
149
156
  const inputArgTypes: ArgTypes = {
150
157
  ...baseInputArgTypes,
158
+ tabIndex: {
159
+ control: 'number',
160
+ description: 'The tab index of the input field.',
161
+ table: {
162
+ category: 'Props',
163
+ },
164
+ },
151
165
  iconName: {
152
166
  control: 'select',
153
167
  options: iconNames,