colibri-ui 0.8.92 → 0.8.94

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 (65) hide show
  1. package/Datepicker/components/DatePicker/index.js +18 -8
  2. package/Datepicker/components/DatePicker/index.props.d.ts +1 -0
  3. package/Datepicker/index.d.ts +1 -1
  4. package/Datepicker/index.js +3 -1
  5. package/Datepicker/index.props.d.ts +1 -0
  6. package/MultiSelect/index.js +14 -2
  7. package/MultiSelect/index.props.d.ts +3 -1
  8. package/Pagination/Pagination.d.ts +3 -0
  9. package/Pagination/Pagination.js +162 -0
  10. package/Pagination/Pagination.module.css +118 -0
  11. package/Pagination/helpers.d.ts +5 -0
  12. package/Pagination/helpers.js +36 -0
  13. package/Pagination/index.d.ts +3 -0
  14. package/Pagination/index.js +9 -0
  15. package/Pagination/index.props.d.ts +31 -0
  16. package/Pagination/package.json +9 -0
  17. package/README.md +51 -0
  18. package/Select/index.d.ts +1 -1
  19. package/Select/index.js +14 -2
  20. package/Select/index.props.d.ts +3 -1
  21. package/Theme/index.d.ts +10 -0
  22. package/Theme/themes/buenos_aires.d.ts +5 -0
  23. package/Theme/themes/buenos_aires.js +5 -0
  24. package/Theme/themes/jaipur.d.ts +5 -0
  25. package/Theme/themes/jaipur.js +5 -0
  26. package/TimeSelect/index.js +3 -1
  27. package/base/FormField/index.d.ts +1 -1
  28. package/base/FormField/index.js +3 -1
  29. package/base/FormField/index.props.d.ts +2 -0
  30. package/esm/Datepicker/components/DatePicker/index.js +18 -8
  31. package/esm/Datepicker/components/DatePicker/index.props.d.ts +1 -0
  32. package/esm/Datepicker/index.d.ts +1 -1
  33. package/esm/Datepicker/index.js +3 -1
  34. package/esm/Datepicker/index.props.d.ts +1 -0
  35. package/esm/MultiSelect/index.js +15 -3
  36. package/esm/MultiSelect/index.props.d.ts +3 -1
  37. package/esm/Pagination/Pagination.d.ts +3 -0
  38. package/esm/Pagination/Pagination.js +154 -0
  39. package/esm/Pagination/Pagination.module.css +118 -0
  40. package/esm/Pagination/helpers.d.ts +5 -0
  41. package/esm/Pagination/helpers.js +31 -0
  42. package/esm/Pagination/index.d.ts +3 -0
  43. package/esm/Pagination/index.js +2 -0
  44. package/esm/Pagination/index.props.d.ts +31 -0
  45. package/esm/Select/index.d.ts +1 -1
  46. package/esm/Select/index.js +15 -3
  47. package/esm/Select/index.props.d.ts +3 -1
  48. package/esm/Theme/index.d.ts +10 -0
  49. package/esm/Theme/themes/buenos_aires.d.ts +5 -0
  50. package/esm/Theme/themes/buenos_aires.js +5 -0
  51. package/esm/Theme/themes/jaipur.d.ts +5 -0
  52. package/esm/Theme/themes/jaipur.js +5 -0
  53. package/esm/TimeSelect/index.js +3 -1
  54. package/esm/base/FormField/index.d.ts +1 -1
  55. package/esm/base/FormField/index.js +3 -1
  56. package/esm/base/FormField/index.props.d.ts +2 -0
  57. package/esm/index.d.ts +2 -0
  58. package/esm/index.js +2 -0
  59. package/esm/theme_ba_variables.css +5 -0
  60. package/esm/theme_jaipur_variables.css +5 -0
  61. package/index.d.ts +2 -0
  62. package/index.js +5 -0
  63. package/package.json +1 -1
  64. package/theme_ba_variables.css +5 -0
  65. package/theme_jaipur_variables.css +5 -0
package/Select/index.js CHANGED
@@ -31,9 +31,14 @@ const Select = ({
31
31
  fullWidth = false,
32
32
  customInputRoot,
33
33
  className,
34
- onChange
34
+ onChange,
35
+ "aria-label": ariaLabel
35
36
  }) => {
36
37
  const [isOpen, setIsOpen] = React.useState(false);
38
+ const id = React.useId();
39
+ const labelId = label ? `${id}-label` : undefined;
40
+ const valueId = `${id}-value`;
41
+ const hintId = hint ? `${id}-hint` : undefined;
37
42
  const preparedOptions = React.useMemo(() => options.map(({
38
43
  value: lvalue,
39
44
  label: llabel,
@@ -56,7 +61,9 @@ const Select = ({
56
61
  }, className),
57
62
  required: required,
58
63
  label: label,
64
+ labelId: labelId,
59
65
  hint: hint,
66
+ hintId: hintId,
60
67
  hasError: hasError
61
68
  }, /*#__PURE__*/React__default.default.createElement(index$1.Dropdown, {
62
69
  placement: "bottom-start",
@@ -72,7 +79,11 @@ const Select = ({
72
79
  }),
73
80
  samewidth: true
74
81
  }, customInputRoot ? customInputRoot : (/*#__PURE__*/React__default.default.createElement("div", {
75
- tabIndex: 0,
82
+ "aria-describedby": hintId,
83
+ "aria-disabled": disabled || undefined,
84
+ "aria-label": labelId ? undefined : ariaLabel,
85
+ "aria-labelledby": labelId ? `${labelId} ${valueId}` : undefined,
86
+ tabIndex: disabled ? -1 : 0,
76
87
  role: "button",
77
88
  style: {
78
89
  width: fullWidth ? "100%" : "fit-content"
@@ -92,6 +103,7 @@ const Select = ({
92
103
  }),
93
104
  disabled: Boolean(disabled)
94
105
  }, /*#__PURE__*/React__default.default.createElement("div", {
106
+ id: valueId,
95
107
  className: styles__default.default["base-input"],
96
108
  "data-testid": "base-input"
97
109
  }, preparedLabel !== null && preparedLabel !== void 0 ? preparedLabel : (/*#__PURE__*/React__default.default.createElement("span", {
@@ -10,7 +10,9 @@ export interface IOption<T extends string> {
10
10
  label: ReactNode;
11
11
  value: T;
12
12
  }
13
- export interface SelectProps<T extends string> extends Omit<FormFieldProps, "children"> {
13
+ export interface SelectProps<T extends string> extends Omit<FormFieldProps, "children" | "labelId"> {
14
+ /** Accessible name of the trigger when no visible `label` is passed. */
15
+ "aria-label"?: string;
14
16
  className?: string;
15
17
  customInputRoot?: ReactNode;
16
18
  disabled?: boolean;
package/Theme/index.d.ts CHANGED
@@ -687,6 +687,11 @@ export declare const THEMES: {
687
687
  "component-calendar-fade-inline-size": string;
688
688
  "component-calendar-day-size": string;
689
689
  "component-calendar-day-radius": string;
690
+ "component-pagination-text": string;
691
+ "component-pagination-text-current": string;
692
+ "component-pagination-bg-current": string;
693
+ "component-pagination-bg-hover": string;
694
+ "component-pagination-focus-ring": string;
690
695
  "component-navigation-item-bg-selected": string;
691
696
  "component-chip-bg-selected": string;
692
697
  "component-chip-bg-selected-strong": string;
@@ -1526,6 +1531,11 @@ export declare const THEMES: {
1526
1531
  "component-calendar-fade-inline-size": string;
1527
1532
  "component-calendar-day-size": string;
1528
1533
  "component-calendar-day-radius": string;
1534
+ "component-pagination-text": string;
1535
+ "component-pagination-text-current": string;
1536
+ "component-pagination-bg-current": string;
1537
+ "component-pagination-bg-hover": string;
1538
+ "component-pagination-focus-ring": string;
1529
1539
  "component-navigation-item-bg-selected": string;
1530
1540
  "component-chip-bg-selected": string;
1531
1541
  "component-chip-bg-selected-strong": string;
@@ -608,6 +608,11 @@ declare const _default: {
608
608
  "component-calendar-fade-inline-size": string;
609
609
  "component-calendar-day-size": string;
610
610
  "component-calendar-day-radius": string;
611
+ "component-pagination-text": string;
612
+ "component-pagination-text-current": string;
613
+ "component-pagination-bg-current": string;
614
+ "component-pagination-bg-hover": string;
615
+ "component-pagination-focus-ring": string;
611
616
  "component-navigation-item-bg-selected": string;
612
617
  "component-chip-bg-selected": string;
613
618
  "component-chip-bg-selected-strong": string;
@@ -614,6 +614,11 @@ var THEME_BA = {
614
614
  "component-calendar-fade-inline-size": "2.5rem",
615
615
  "component-calendar-day-size": "2rem",
616
616
  "component-calendar-day-radius": "0.375rem",
617
+ "component-pagination-text": theme_buenos_aires.default.BRAND_BA_FOREST,
618
+ "component-pagination-text-current": theme_buenos_aires.default.BRAND_BA_LIME,
619
+ "component-pagination-bg-current": theme_buenos_aires.default.BRAND_BA_FOREST,
620
+ "component-pagination-bg-hover": theme_buenos_aires.default.NEUTRAL_BA_100,
621
+ "component-pagination-focus-ring": theme_buenos_aires.default.BRAND_BA_LIME,
617
622
  "component-navigation-item-bg-selected": theme_buenos_aires.default.BRAND_BA_FOREST,
618
623
  "component-chip-bg-selected": theme_buenos_aires.default.BRAND_BA_FOREST,
619
624
  "component-chip-bg-selected-strong": theme_buenos_aires.default.BRAND_BA_LIME,
@@ -608,6 +608,11 @@ declare const _default: {
608
608
  "component-calendar-fade-inline-size": string;
609
609
  "component-calendar-day-size": string;
610
610
  "component-calendar-day-radius": string;
611
+ "component-pagination-text": string;
612
+ "component-pagination-text-current": string;
613
+ "component-pagination-bg-current": string;
614
+ "component-pagination-bg-hover": string;
615
+ "component-pagination-focus-ring": string;
611
616
  "component-navigation-item-bg-selected": string;
612
617
  "component-chip-bg-selected": string;
613
618
  "component-chip-bg-selected-strong": string;
@@ -614,6 +614,11 @@ var theme_jaipur = {
614
614
  "component-calendar-fade-inline-size": "2.5rem",
615
615
  "component-calendar-day-size": "2rem",
616
616
  "component-calendar-day-radius": "0.375rem",
617
+ "component-pagination-text": theme_jaipur$1.default.BRAND_JP_EGGPLANT,
618
+ "component-pagination-text-current": theme_jaipur$1.default.BRAND_JP_PINK,
619
+ "component-pagination-bg-current": theme_jaipur$1.default.BRAND_JP_EGGPLANT,
620
+ "component-pagination-bg-hover": theme_jaipur$1.default.NEUTRAL_JP_100,
621
+ "component-pagination-focus-ring": theme_jaipur$1.default.BRAND_JP_PINK,
617
622
  "component-navigation-item-bg-selected": theme_jaipur$1.default.BRAND_JP_EGGPLANT,
618
623
  "component-chip-bg-selected": theme_jaipur$1.default.BRAND_JP_EGGPLANT,
619
624
  "component-chip-bg-selected-strong": theme_jaipur$1.default.BRAND_JP_PINK,
@@ -28,7 +28,8 @@ const TimeSelect = ({
28
28
  size,
29
29
  zIndex,
30
30
  hasError,
31
- hint
31
+ hint,
32
+ "aria-label": ariaLabel
32
33
  }) => {
33
34
  const baseOptions = React.useMemo(() => helpers.generateSuggest(interval).map(item => ({
34
35
  value: item.time,
@@ -43,6 +44,7 @@ const TimeSelect = ({
43
44
  });
44
45
  }), [baseOptions, currentDate, selectedDate, allowedTimeRange, interval]);
45
46
  return /*#__PURE__*/React__default.default.createElement(index$1.Select, {
47
+ "aria-label": ariaLabel,
46
48
  className: className,
47
49
  customInputRoot: customInputRoot,
48
50
  fontSize: fontSize,
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
2
  import type { FormFieldProps } from "./index.props";
3
- export declare const FormField: ({ label, hint, children, hasError, hintId, htmlFor, required, className, ref, }: FormFieldProps) => React.JSX.Element;
3
+ export declare const FormField: ({ label, hint, children, hasError, hintId, htmlFor, labelId, required, className, ref, }: FormFieldProps) => React.JSX.Element;
@@ -18,6 +18,7 @@ const FormField = ({
18
18
  hasError,
19
19
  hintId,
20
20
  htmlFor,
21
+ labelId,
21
22
  required,
22
23
  className,
23
24
  ref
@@ -29,7 +30,8 @@ const FormField = ({
29
30
  [styles__default.default.label_required]: Boolean(required)
30
31
  }),
31
32
  tag: "label",
32
- htmlFor: htmlFor
33
+ htmlFor: htmlFor,
34
+ id: labelId
33
35
  }, label)), children, hint && (/*#__PURE__*/React__default.default.createElement(index.Typography, {
34
36
  id: hintId,
35
37
  className: clsx__default.default({
@@ -9,6 +9,8 @@ export type FormFieldProps = PropsWithChildren<{
9
9
  /** Id of the control the label belongs to. */
10
10
  htmlFor?: string;
11
11
  label?: ReactNode;
12
+ /** Id of the label, referenced by the control's `aria-labelledby`. */
13
+ labelId?: string;
12
14
  ref?: React.Ref<HTMLDivElement>;
13
15
  required?: boolean;
14
16
  }>;
@@ -31,6 +31,7 @@ const DatePicker = _a => {
31
31
  var _b;
32
32
  var {
33
33
  className,
34
+ disabled = false,
34
35
  endPlaceholder,
35
36
  hasError,
36
37
  hint,
@@ -47,7 +48,7 @@ const DatePicker = _a => {
47
48
  onChangeDate,
48
49
  onChangeRange
49
50
  } = _a,
50
- calendarProps = __rest(_a, ["className", "endPlaceholder", "hasError", "hint", "label", "placeholder", "required", "selectedDate", "selectedRange", "selectionMode", "size", "defaultVisibleMonth", "monthsToShow", "startPlaceholder", "onChangeDate", "onChangeRange"]);
51
+ calendarProps = __rest(_a, ["className", "disabled", "endPlaceholder", "hasError", "hint", "label", "placeholder", "required", "selectedDate", "selectedRange", "selectionMode", "size", "defaultVisibleMonth", "monthsToShow", "startPlaceholder", "onChangeDate", "onChangeRange"]);
51
52
  const [date, setDate] = useState(selectedDate);
52
53
  const [range, setRange] = useState(selectedRange);
53
54
  const [isOpen, setIsOpen] = useState(false);
@@ -56,6 +57,7 @@ const DatePicker = _a => {
56
57
  const calendarSize = calendarSizeByDatepickerSize[size];
57
58
  const visibleMonth = (_b = calendarValue !== null && calendarValue !== void 0 ? calendarValue : calendarRangeValue[0]) !== null && _b !== void 0 ? _b : new Date();
58
59
  const isRangeMode = selectionMode === "range";
60
+ const isCalendarOpen = isOpen && !disabled;
59
61
  useEffect(() => {
60
62
  setDate(selectedDate);
61
63
  }, [selectedDate]);
@@ -65,12 +67,14 @@ const DatePicker = _a => {
65
67
  setRange([selectedRangeStart, selectedRangeEnd]);
66
68
  }, [isRangeMode, selectedRangeStart, selectedRangeEnd]);
67
69
  const handleDateChange = nextDate => {
70
+ if (disabled) return;
68
71
  const nextValue = toISODate(nextDate);
69
72
  setDate(nextValue);
70
73
  setIsOpen(false);
71
74
  onChangeDate === null || onChangeDate === void 0 ? void 0 : onChangeDate(nextValue);
72
75
  };
73
76
  const handleRangeChange = nextRange => {
77
+ if (disabled) return;
74
78
  const nextValue = [nextRange[0] ? toISODate(nextRange[0]) : "", nextRange[1] ? toISODate(nextRange[1]) : ""];
75
79
  setRange(nextValue);
76
80
  if (nextValue[0] && nextValue[1]) setIsOpen(false);
@@ -102,14 +106,15 @@ const DatePicker = _a => {
102
106
  className: styles["range-input"]
103
107
  }, /*#__PURE__*/React.createElement(InputRoot, {
104
108
  className: styles["range-control-start"],
105
- disabled: false,
109
+ disabled: disabled,
106
110
  hasError: hasError,
107
111
  size: size
108
112
  }, /*#__PURE__*/React.createElement(BaseInput, {
109
- "aria-expanded": isOpen,
113
+ "aria-expanded": isCalendarOpen,
110
114
  "aria-haspopup": "true",
111
115
  "aria-invalid": hasError,
112
116
  autoComplete: "off",
117
+ disabled: disabled,
113
118
  maxLength: 10,
114
119
  placeholder: startPlaceholder !== null && startPlaceholder !== void 0 ? startPlaceholder : placeholder,
115
120
  readOnly: true,
@@ -117,15 +122,16 @@ const DatePicker = _a => {
117
122
  value: toDMYDate(range[0])
118
123
  })), /*#__PURE__*/React.createElement(InputRoot, {
119
124
  className: styles["range-control-end"],
120
- disabled: false,
125
+ disabled: disabled,
121
126
  endIcon: /*#__PURE__*/React.createElement(CalendarIcon, null),
122
127
  hasError: hasError,
123
128
  size: size
124
129
  }, /*#__PURE__*/React.createElement(BaseInput, {
125
- "aria-expanded": isOpen,
130
+ "aria-expanded": isCalendarOpen,
126
131
  "aria-haspopup": "true",
127
132
  "aria-invalid": hasError,
128
133
  autoComplete: "off",
134
+ disabled: disabled,
129
135
  maxLength: 10,
130
136
  placeholder: endPlaceholder !== null && endPlaceholder !== void 0 ? endPlaceholder : placeholder,
131
137
  readOnly: true,
@@ -138,7 +144,8 @@ const DatePicker = _a => {
138
144
  hint: hint,
139
145
  hasError: hasError
140
146
  }, /*#__PURE__*/React.createElement(Dropdown, {
141
- visible: isOpen,
147
+ disabled: disabled,
148
+ visible: isCalendarOpen,
142
149
  onVisibleChange: setIsOpen,
143
150
  placement: "bottom",
144
151
  preventAutoClose: true,
@@ -147,13 +154,16 @@ const DatePicker = _a => {
147
154
  className: styles["calendar-popup"]
148
155
  }, renderCalendar())
149
156
  }, /*#__PURE__*/React.createElement("div", {
150
- className: styles.trigger
157
+ "aria-disabled": disabled || undefined,
158
+ className: styles.trigger,
159
+ tabIndex: disabled ? -1 : 0
151
160
  }, isRangeMode ? renderRangeInput() : (/*#__PURE__*/React.createElement(Input, {
152
161
  className: styles.input,
153
- "aria-expanded": isOpen,
162
+ "aria-expanded": isCalendarOpen,
154
163
  "aria-haspopup": "true",
155
164
  "aria-invalid": hasError,
156
165
  autoComplete: "off",
166
+ disabled: disabled,
157
167
  endIcon: /*#__PURE__*/React.createElement(CalendarIcon, null),
158
168
  hasError: hasError,
159
169
  maxLength: 10,
@@ -1,6 +1,7 @@
1
1
  import type { DatepickerSize, DatepickerCalendarProps, Props as DatepickerProps } from "../../index.props";
2
2
  export type DatePickerProps = DatepickerCalendarProps & {
3
3
  className?: string;
4
+ disabled?: boolean;
4
5
  endPlaceholder?: string;
5
6
  hasError?: boolean;
6
7
  hint?: DatepickerProps["hint"];
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
2
  import type { Props } from "./index.props";
3
- export declare const Datepicker: ({ className, endPlaceholder, hasError, hint, label, placeholder, required, selectedDate, selectedRange, selectionMode, size, startPlaceholder, onChangeDate, onChangeRange, ...calendarProps }: Props) => React.JSX.Element;
3
+ export declare const Datepicker: ({ className, disabled, endPlaceholder, hasError, hint, label, placeholder, required, selectedDate, selectedRange, selectionMode, size, startPlaceholder, onChangeDate, onChangeRange, ...calendarProps }: Props) => React.JSX.Element;
@@ -7,6 +7,7 @@ import { DatePicker } from './components/DatePicker/index.js';
7
7
  const Datepicker = _a => {
8
8
  var {
9
9
  className,
10
+ disabled,
10
11
  endPlaceholder,
11
12
  hasError,
12
13
  hint,
@@ -21,10 +22,11 @@ const Datepicker = _a => {
21
22
  onChangeDate,
22
23
  onChangeRange
23
24
  } = _a,
24
- calendarProps = __rest(_a, ["className", "endPlaceholder", "hasError", "hint", "label", "placeholder", "required", "selectedDate", "selectedRange", "selectionMode", "size", "startPlaceholder", "onChangeDate", "onChangeRange"]);
25
+ calendarProps = __rest(_a, ["className", "disabled", "endPlaceholder", "hasError", "hint", "label", "placeholder", "required", "selectedDate", "selectedRange", "selectionMode", "size", "startPlaceholder", "onChangeDate", "onChangeRange"]);
25
26
  return /*#__PURE__*/React.createElement("div", {
26
27
  className: clsx(styles.root, className)
27
28
  }, /*#__PURE__*/React.createElement(DatePicker, Object.assign({}, calendarProps, {
29
+ disabled: disabled,
28
30
  endPlaceholder: endPlaceholder,
29
31
  hasError: hasError,
30
32
  hint: hint,
@@ -6,6 +6,7 @@ export type DatepickerRangeValue = [string, string];
6
6
  export type DatepickerCalendarProps = Omit<CalendarCommonProps, "className" | "size">;
7
7
  export type Props = DatepickerCalendarProps & {
8
8
  className?: string;
9
+ disabled?: boolean;
9
10
  endPlaceholder?: string;
10
11
  hasError?: boolean;
11
12
  hint?: ReactNode;
@@ -1,4 +1,4 @@
1
- import React, { useState, useMemo, useCallback } from 'react';
1
+ import React, { useState, useId, useMemo, useCallback } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { Dropdown } from '../Dropdown/index.js';
4
4
  import { InputRoot } from '../base/InputRoot/index.js';
@@ -31,9 +31,14 @@ const MultiSelect = ({
31
31
  name,
32
32
  value = [],
33
33
  type,
34
- onChange
34
+ onChange,
35
+ "aria-label": ariaLabel
35
36
  }) => {
36
37
  const [isOpen, setIsOpen] = useState(false);
38
+ const id = useId();
39
+ const labelId = label ? `${id}-label` : undefined;
40
+ const valueId = `${id}-value`;
41
+ const hintId = hint ? `${id}-hint` : undefined;
37
42
  const internalSelectedKeys = useMemo(() => value.map(toKey), [value]);
38
43
  const preparedGroups = useMemo(() => groups.map(group => Object.assign(Object.assign({}, group), {
39
44
  options: group.options.map(option => Object.assign(Object.assign({}, option), {
@@ -72,7 +77,9 @@ const MultiSelect = ({
72
77
  }, className),
73
78
  required: required,
74
79
  label: label,
80
+ labelId: labelId,
75
81
  hint: hint,
82
+ hintId: hintId,
76
83
  hasError: hasError
77
84
  }, /*#__PURE__*/React.createElement(Dropdown, {
78
85
  placement: "bottom-start",
@@ -88,7 +95,11 @@ const MultiSelect = ({
88
95
  }),
89
96
  samewidth: true
90
97
  }, /*#__PURE__*/React.createElement("div", {
91
- tabIndex: 0,
98
+ "aria-describedby": hintId,
99
+ "aria-disabled": disabled || undefined,
100
+ "aria-label": labelId ? undefined : ariaLabel,
101
+ "aria-labelledby": labelId ? `${labelId} ${valueId}` : undefined,
102
+ tabIndex: disabled ? -1 : 0,
92
103
  role: "button",
93
104
  style: {
94
105
  width: fullWidth ? "100%" : "fit-content"
@@ -110,6 +121,7 @@ const MultiSelect = ({
110
121
  }),
111
122
  disabled: Boolean(disabled)
112
123
  }, /*#__PURE__*/React.createElement("div", {
124
+ id: valueId,
113
125
  className: clsx(styles["base-input"], styles[type === "chip" ? "base-input-flex" : "base-input-text"])
114
126
  }, preparedLabel.length ? type === "chip" ?
115
127
  // eslint-disable-next-line @typescript-eslint/no-shadow
@@ -20,7 +20,9 @@ export type SelectedItem = {
20
20
  group: string;
21
21
  option: string;
22
22
  };
23
- export interface MultiSelectProps extends Omit<FormFieldProps, "children"> {
23
+ export interface MultiSelectProps extends Omit<FormFieldProps, "children" | "labelId"> {
24
+ /** Accessible name of the trigger when no visible `label` is passed. */
25
+ "aria-label"?: string;
24
26
  groups: GroupProps[];
25
27
  className?: string;
26
28
  zIndex?: number;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import type { PaginationProps } from "./index.props";
3
+ export declare const Pagination: ({ totalPages, page, defaultPage, onPageChange, siblingCount, boundaryCount, disabledPages, disabled, mode, size, pageSize, defaultPageSize, pageSizeOptions, onPageSizeChange, showPageSize, showQuickJump, helperText, previousLabel, nextLabel, pageLabel, quickJumpLabel, pageSizeLabel, className, ref, "aria-label": ariaLabel, ...props }: PaginationProps) => React.JSX.Element;
@@ -0,0 +1,154 @@
1
+ import { __rest } from 'tslib';
2
+ import React, { useState, useMemo } from 'react';
3
+ import clsx from 'clsx';
4
+ import { Chevron } from '../Icons/Chevron.js';
5
+ import { Input } from '../Input/index.js';
6
+ import { Select } from '../Select/index.js';
7
+ import { clamp, getPaginationItems, findEnabledPage, toTotalPages } from './helpers.js';
8
+ import styles from './Pagination.module.css';
9
+
10
+ const NO_PAGES = [];
11
+ const DEFAULT_PAGE_SIZE_OPTIONS = [20, 50, 100];
12
+ const defaultPageLabel = page => `Page ${page}`;
13
+ const Pagination = _a => {
14
+ var {
15
+ totalPages,
16
+ page,
17
+ defaultPage = 1,
18
+ onPageChange,
19
+ siblingCount = 1,
20
+ boundaryCount = 1,
21
+ disabledPages = NO_PAGES,
22
+ disabled = false,
23
+ mode = "default",
24
+ size = "m",
25
+ pageSize,
26
+ defaultPageSize = 20,
27
+ pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,
28
+ onPageSizeChange,
29
+ showPageSize = false,
30
+ showQuickJump = false,
31
+ helperText,
32
+ previousLabel = "Previous page",
33
+ nextLabel = "Next page",
34
+ pageLabel = defaultPageLabel,
35
+ quickJumpLabel = "Go to page",
36
+ pageSizeLabel = "Per page",
37
+ className,
38
+ ref,
39
+ "aria-label": ariaLabel = "Pagination"
40
+ } = _a,
41
+ props = __rest(_a, ["totalPages", "page", "defaultPage", "onPageChange", "siblingCount", "boundaryCount", "disabledPages", "disabled", "mode", "size", "pageSize", "defaultPageSize", "pageSizeOptions", "onPageSizeChange", "showPageSize", "showQuickJump", "helperText", "previousLabel", "nextLabel", "pageLabel", "quickJumpLabel", "pageSizeLabel", "className", "ref", "aria-label"]);
42
+ const total = toTotalPages(totalPages);
43
+ const [internalPage, setInternalPage] = useState(() => clamp(defaultPage, 1, total));
44
+ const currentPage = clamp(page !== null && page !== void 0 ? page : internalPage, 1, total);
45
+ const [internalPageSize, setInternalPageSize] = useState(defaultPageSize);
46
+ const currentPageSize = pageSize !== null && pageSize !== void 0 ? pageSize : internalPageSize;
47
+ const [quickJumpDraft, setQuickJumpDraft] = useState(null);
48
+ const disabledSet = useMemo(() => new Set(disabledPages), [disabledPages]);
49
+ const items = useMemo(() => getPaginationItems(total, currentPage, siblingCount, boundaryCount), [total, currentPage, siblingCount, boundaryCount]);
50
+ const pageSizeSelectOptions = useMemo(() => pageSizeOptions.map(option => ({
51
+ value: String(option),
52
+ label: option
53
+ })), [pageSizeOptions]);
54
+ const previousPage = findEnabledPage(currentPage, -1, total, disabledSet);
55
+ const nextPage = findEnabledPage(currentPage, 1, total, disabledSet);
56
+ const changePage = nextValue => {
57
+ const next = clamp(Math.floor(nextValue), 1, total);
58
+ if (disabled || disabledSet.has(next) || next === currentPage) return;
59
+ if (page === undefined) setInternalPage(next);
60
+ onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange(next);
61
+ };
62
+ const commitQuickJump = () => {
63
+ if (quickJumpDraft === null) return;
64
+ const parsed = Number(quickJumpDraft);
65
+ if (quickJumpDraft.trim() !== "" && Number.isInteger(parsed)) {
66
+ changePage(parsed);
67
+ }
68
+ setQuickJumpDraft(null);
69
+ };
70
+ const changePageSize = next => {
71
+ if (pageSize === undefined) setInternalPageSize(next);
72
+ onPageSizeChange === null || onPageSizeChange === void 0 ? void 0 : onPageSizeChange(next);
73
+ };
74
+ const hasActions = showQuickJump || showPageSize || Boolean(helperText);
75
+ return /*#__PURE__*/React.createElement("nav", Object.assign({}, props, {
76
+ ref: ref,
77
+ "aria-label": ariaLabel,
78
+ className: clsx(styles.root, styles[`size_${size}`], {
79
+ [styles.root_disabled]: disabled
80
+ }, className)
81
+ }), /*#__PURE__*/React.createElement("div", {
82
+ className: styles.main
83
+ }, /*#__PURE__*/React.createElement("button", {
84
+ type: "button",
85
+ className: styles.arrow,
86
+ "aria-label": previousLabel,
87
+ disabled: disabled || previousPage === undefined,
88
+ onClick: () => {
89
+ if (previousPage !== undefined) changePage(previousPage);
90
+ }
91
+ }, /*#__PURE__*/React.createElement(Chevron, {
92
+ className: styles.arrow_previous,
93
+ width: 16,
94
+ height: 16,
95
+ "aria-hidden": "true"
96
+ })), mode === "compact" ? (/*#__PURE__*/React.createElement("span", {
97
+ className: styles.counter,
98
+ "aria-live": "polite"
99
+ }, /*#__PURE__*/React.createElement("strong", null, currentPage), /*#__PURE__*/React.createElement("span", null, "/"), total)) : (/*#__PURE__*/React.createElement("div", {
100
+ className: styles.pages
101
+ }, items.map(item => typeof item === "number" ? (/*#__PURE__*/React.createElement("button", {
102
+ type: "button",
103
+ key: item,
104
+ className: clsx(styles.page, {
105
+ [styles.page_current]: item === currentPage
106
+ }),
107
+ "aria-label": pageLabel(item),
108
+ "aria-current": item === currentPage ? "page" : undefined,
109
+ disabled: disabled || disabledSet.has(item),
110
+ onClick: () => changePage(item)
111
+ }, item)) : (/*#__PURE__*/React.createElement("span", {
112
+ key: item,
113
+ className: styles.ellipsis,
114
+ "aria-hidden": "true"
115
+ }, "\u2026"))))), /*#__PURE__*/React.createElement("button", {
116
+ type: "button",
117
+ className: styles.arrow,
118
+ "aria-label": nextLabel,
119
+ disabled: disabled || nextPage === undefined,
120
+ onClick: () => {
121
+ if (nextPage !== undefined) changePage(nextPage);
122
+ }
123
+ }, /*#__PURE__*/React.createElement(Chevron, {
124
+ className: styles.arrow_next,
125
+ width: 16,
126
+ height: 16,
127
+ "aria-hidden": "true"
128
+ }))), hasActions && (/*#__PURE__*/React.createElement("div", {
129
+ className: styles.actions
130
+ }, showQuickJump && (/*#__PURE__*/React.createElement(Input, {
131
+ className: styles.jump,
132
+ size: size,
133
+ label: quickJumpLabel,
134
+ inputMode: "numeric",
135
+ value: quickJumpDraft !== null && quickJumpDraft !== void 0 ? quickJumpDraft : String(currentPage),
136
+ disabled: disabled,
137
+ onChange: (_, value) => setQuickJumpDraft(value),
138
+ onBlur: commitQuickJump,
139
+ onKeyDown: event => {
140
+ if (event.key === "Enter") commitQuickJump();
141
+ }
142
+ })), showPageSize && (/*#__PURE__*/React.createElement(Select, {
143
+ size: size,
144
+ label: pageSizeLabel,
145
+ options: pageSizeSelectOptions,
146
+ value: String(currentPageSize),
147
+ disabled: disabled,
148
+ onChange: value => changePageSize(Number(value))
149
+ })), helperText && /*#__PURE__*/React.createElement("div", {
150
+ className: styles.helper
151
+ }, helperText))));
152
+ };
153
+
154
+ export { Pagination };