@indico-data/design-system 3.0.8 → 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 (29) 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 +3 -0
  5. package/lib/components/forms/date/inputDateRangePicker/InputDateRangePicker.d.ts +5 -0
  6. package/lib/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.d.ts +5 -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 +28 -2
  11. package/lib/index.esm.js +17 -16
  12. package/lib/index.esm.js.map +1 -1
  13. package/lib/index.js +17 -16
  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 +21 -0
  21. package/src/components/forms/date/inputDatePicker/SingleInputDatePicker.tsx +9 -0
  22. package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.stories.tsx +35 -0
  23. package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.tsx +16 -0
  24. package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.stories.tsx +36 -0
  25. package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.tsx +25 -5
  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/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.8",
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,27 @@ 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
+ },
16
37
  hasHiddenLabel: {
17
38
  control: 'boolean',
18
39
  description: 'Whether the label is hidden.',
@@ -26,6 +26,9 @@ export interface SingleInputDatePickerProps {
26
26
  errorMessage?: string | undefined;
27
27
  hasHiddenLabel?: boolean;
28
28
  'data-testid'?: string;
29
+ ref?: React.LegacyRef<HTMLInputElement>;
30
+ isReadOnly?: boolean;
31
+ tabIndex?: number;
29
32
  }
30
33
 
31
34
  export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
@@ -48,6 +51,9 @@ export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
48
51
  errorMessage,
49
52
  onSelect,
50
53
  hasHiddenLabel,
54
+ ref,
55
+ isReadOnly,
56
+ tabIndex,
51
57
  ...rest
52
58
  } = props;
53
59
 
@@ -105,7 +111,10 @@ export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
105
111
  onChange={handleInputChange}
106
112
  errorMessage={errorMessage}
107
113
  label={'Single Date Picker'}
114
+ tabIndex={tabIndex}
108
115
  name={'Date Picker'}
116
+ ref={ref}
117
+ readonly={isReadOnly}
109
118
  />
110
119
  <DatePicker
111
120
  captionLayout={captionLayout}
@@ -15,6 +15,41 @@ 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
+ },
18
53
  hasHiddenLabel: {
19
54
  control: 'boolean',
20
55
  description: 'Whether the label is hidden.',
@@ -33,6 +33,11 @@ interface InputDateRangePickerProps {
33
33
  closeOnSelect?: boolean;
34
34
  clearOnClose?: boolean;
35
35
  hasHiddenLabel?: boolean;
36
+ ref?: React.LegacyRef<HTMLInputElement>;
37
+ isFromReadOnly?: boolean;
38
+ isToReadOnly?: boolean;
39
+ toTabIndex?: number;
40
+ fromTabIndex?: number;
36
41
  }
37
42
 
38
43
  export function InputDateRangePicker(props: InputDateRangePickerProps) {
@@ -59,6 +64,11 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
59
64
  closeOnSelect,
60
65
  clearOnClose,
61
66
  hasHiddenLabel,
67
+ ref,
68
+ isFromReadOnly,
69
+ isToReadOnly,
70
+ toTabIndex,
71
+ fromTabIndex,
62
72
  ...rest
63
73
  } = props;
64
74
 
@@ -154,6 +164,9 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
154
164
  name={'From Date'}
155
165
  data-testid="date-picker-from"
156
166
  hasHiddenLabel={hasHiddenLabel}
167
+ ref={ref}
168
+ readonly={isFromReadOnly}
169
+ tabIndex={fromTabIndex}
157
170
  />
158
171
  </Col>
159
172
  <Col>
@@ -169,6 +182,9 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
169
182
  name={'To Date'}
170
183
  data-testid="date-picker-to"
171
184
  hasHiddenLabel={hasHiddenLabel}
185
+ ref={ref}
186
+ readonly={isToReadOnly}
187
+ tabIndex={toTabIndex}
172
188
  />
173
189
  </Col>
174
190
  </Row>
@@ -20,6 +20,42 @@ 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
+
23
59
  hasHiddenLabel: {
24
60
  control: 'boolean',
25
61
  description: 'Whether the label is hidden.',
@@ -30,6 +30,11 @@ export interface SingleInputDateTimePickerProps {
30
30
  hasHiddenLabel?: boolean;
31
31
  timeValue?: string;
32
32
  onTimeChange?: (time: string) => void;
33
+ isReadOnly?: boolean;
34
+ ref?: React.LegacyRef<HTMLInputElement>;
35
+ timePickerRef?: React.LegacyRef<HTMLInputElement>;
36
+ dateTabIndex?: number;
37
+ timeTabIndex?: number;
33
38
  }
34
39
 
35
40
  export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps) {
@@ -54,6 +59,11 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
54
59
  timeValue,
55
60
  onTimeChange,
56
61
  hasHiddenLabel,
62
+ isReadOnly,
63
+ timePickerRef,
64
+ dateTabIndex,
65
+ timeTabIndex,
66
+ ref,
57
67
  ...rest
58
68
  } = props;
59
69
 
@@ -103,14 +113,17 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
103
113
  };
104
114
 
105
115
  return (
106
- <Row>
107
- <Col>
108
- <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}>
109
119
  <Input
120
+ ref={ref}
121
+ className={`date-picker-input`}
110
122
  id={inputId}
111
123
  value={localTextValue}
112
124
  placeholder={inputPlaceholder}
113
- isDisabled={isDisabled}
125
+ isDisabled={isReadOnly || isDisabled}
126
+ readonly={isReadOnly}
114
127
  iconName={inputIconName}
115
128
  isClearable={isClearable}
116
129
  onChange={handleInputChange}
@@ -118,6 +131,7 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
118
131
  hasHiddenLabel={hasHiddenLabel}
119
132
  label={'Single Date Picker'}
120
133
  name={`${id}-date-picker`}
134
+ tabIndex={dateTabIndex}
121
135
  />
122
136
  <DatePicker
123
137
  captionLayout={captionLayout}
@@ -126,16 +140,22 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
126
140
  onSelect={handleDayPickerSelect}
127
141
  month={localMonth}
128
142
  onMonthChange={setLocalMonth}
143
+ isReadOnly={isReadOnly}
129
144
  {...rest}
130
145
  />
131
146
  </FloatUI>
132
147
  </Col>
133
- <Col xs="content">
148
+ <Col xs="content" className="time-picker-col">
134
149
  <TimePicker
150
+ ref={timePickerRef}
151
+ className={`time-picker-input`}
135
152
  timeValue={timeValue}
136
153
  name={`${id}-time-picker`}
137
154
  hasHiddenLabel
138
155
  onTimeChange={handleTimeChange}
156
+ isReadOnly={isReadOnly}
157
+ isDisabled={isDisabled}
158
+ tabIndex={timeTabIndex}
139
159
  />
140
160
  </Col>
141
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
  );
@@ -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,