@bspk/ui 1.3.5 → 1.3.7

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 (140) hide show
  1. package/dist/components/AvatarGroup/AvatarGroup.d.ts +2 -2
  2. package/dist/components/AvatarGroup/Overflow.d.ts +1 -2
  3. package/dist/components/BadgeDot/BadgeDot.d.ts +1 -2
  4. package/dist/components/Breadcrumb/Breadcrumb.d.ts +1 -1
  5. package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
  6. package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
  7. package/dist/components/Breadcrumb/{BreadcumbDropdown.d.ts → BreadcrumbDropdown.d.ts} +1 -2
  8. package/dist/components/Breadcrumb/{BreadcumbDropdown.js → BreadcrumbDropdown.js} +1 -1
  9. package/dist/components/Breadcrumb/BreadcrumbDropdown.js.map +1 -0
  10. package/dist/components/Breadcrumb/index.d.ts +1 -0
  11. package/dist/components/Breadcrumb/index.js +1 -0
  12. package/dist/components/Breadcrumb/index.js.map +1 -1
  13. package/dist/components/Calendar/Calendar.d.ts +32 -0
  14. package/dist/components/Checkbox/Checkbox.d.ts +2 -2
  15. package/dist/components/Checkbox/Checkbox.js +2 -2
  16. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  17. package/dist/components/Checkbox/CheckboxExample.d.ts +3 -0
  18. package/dist/components/Checkbox/CheckboxExample.js +5 -0
  19. package/dist/components/Checkbox/CheckboxExample.js.map +1 -0
  20. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +4 -2
  21. package/dist/components/CheckboxGroup/CheckboxGroup.js +5 -4
  22. package/dist/components/CheckboxGroup/CheckboxGroup.js.map +1 -1
  23. package/dist/components/CheckboxGroup/CheckboxGroupExample.js +12 -0
  24. package/dist/components/CheckboxGroup/CheckboxGroupExample.js.map +1 -1
  25. package/dist/components/CheckboxGroupField/CheckboxGroupFieldExample.d.ts +4 -0
  26. package/dist/components/CheckboxGroupField/CheckboxGroupFieldExample.js +15 -0
  27. package/dist/components/CheckboxGroupField/CheckboxGroupFieldExample.js.map +1 -0
  28. package/dist/components/CheckboxOption/CheckboxOption.d.ts +1 -1
  29. package/dist/components/CheckboxOption/CheckboxOption.js +2 -2
  30. package/dist/components/CheckboxOption/CheckboxOption.js.map +1 -1
  31. package/dist/components/Chip/Chip.d.ts +1 -1
  32. package/dist/components/Field/field.css +2 -0
  33. package/dist/components/Field/field.css.js +2 -0
  34. package/dist/components/Field/utils.d.ts +1 -1
  35. package/dist/components/FormField/FormFieldExample.d.ts +1 -2
  36. package/dist/components/Input/InputElement.d.ts +1 -2
  37. package/dist/components/Input/InputExample.d.ts +1 -2
  38. package/dist/components/Modal/Modal.d.ts +0 -2
  39. package/dist/components/Modal/Modal.js +0 -2
  40. package/dist/components/Modal/Modal.js.map +1 -1
  41. package/dist/components/PageControl/PageControl.d.ts +3 -2
  42. package/dist/components/Pagination/PageInput.d.ts +1 -2
  43. package/dist/components/Portal/Portal.d.ts +1 -5
  44. package/dist/components/Portal/Portal.js.map +1 -1
  45. package/dist/components/Radio/RadioExample.js +1 -1
  46. package/dist/components/Radio/RadioExample.js.map +1 -1
  47. package/dist/components/Radio/radio.css +2 -1
  48. package/dist/components/Radio/radio.css.js +2 -1
  49. package/dist/components/RadioGroup/RadioGroup.d.ts +4 -2
  50. package/dist/components/RadioGroup/RadioGroup.js +3 -2
  51. package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
  52. package/dist/components/RadioGroup/RadioGroupExample.d.ts +2 -2
  53. package/dist/components/RadioGroup/RadioGroupExample.js +72 -4
  54. package/dist/components/RadioGroup/RadioGroupExample.js.map +1 -1
  55. package/dist/components/RadioGroupField/RadioGroupFieldExample.d.ts +4 -0
  56. package/dist/components/RadioGroupField/RadioGroupFieldExample.js +15 -0
  57. package/dist/components/RadioGroupField/RadioGroupFieldExample.js.map +1 -0
  58. package/dist/components/SearchBar/SearchBar.d.ts +2 -2
  59. package/dist/components/SearchBar/SearchBar.js +10 -12
  60. package/dist/components/SearchBar/SearchBar.js.map +1 -1
  61. package/dist/components/Slider/SliderIntervalDots.d.ts +1 -2
  62. package/dist/components/Switch/Switch.d.ts +1 -7
  63. package/dist/components/Switch/Switch.js +1 -2
  64. package/dist/components/Switch/Switch.js.map +1 -1
  65. package/dist/components/Switch/SwitchExample.d.ts +3 -0
  66. package/dist/components/Switch/SwitchExample.js +5 -0
  67. package/dist/components/Switch/SwitchExample.js.map +1 -0
  68. package/dist/components/Table/index.d.ts +1 -0
  69. package/dist/components/Table/index.js +1 -0
  70. package/dist/components/Table/index.js.map +1 -1
  71. package/dist/components/TimePicker/Listbox.d.ts +2 -3
  72. package/dist/components/TimePicker/Segment.d.ts +1 -2
  73. package/dist/components/ToggleOption/ToggleOption.d.ts +2 -2
  74. package/dist/components/ToggleOption/ToggleOption.js +2 -2
  75. package/dist/components/ToggleOption/ToggleOption.js.map +1 -1
  76. package/dist/hooks/useArrowNavigation.d.ts +2 -3
  77. package/dist/hooks/useDebounceCallback.d.ts +1 -2
  78. package/dist/hooks/useDebounceState.d.ts +0 -1
  79. package/dist/hooks/useDebounceState.js +0 -1
  80. package/dist/hooks/useDebounceState.js.map +1 -1
  81. package/dist/hooks/useOutsideClick.d.ts +4 -5
  82. package/dist/hooks/useOutsideClick.js +5 -5
  83. package/dist/hooks/useOutsideClick.js.map +1 -1
  84. package/dist/hooks/useTimeout.d.ts +1 -2
  85. package/dist/types/common.d.ts +5 -8
  86. package/dist/types/common.js.map +1 -1
  87. package/dist/utils/countryCodes.d.ts +1 -2
  88. package/dist/utils/createExampleChildElement.d.ts +1 -2
  89. package/dist/utils/demo.d.ts +1 -2
  90. package/package.json +1 -1
  91. package/src/components/AvatarGroup/AvatarGroup.tsx +2 -2
  92. package/src/components/AvatarGroup/Overflow.tsx +1 -1
  93. package/src/components/BadgeDot/BadgeDot.tsx +1 -1
  94. package/src/components/Breadcrumb/Breadcrumb.tsx +1 -1
  95. package/src/components/Breadcrumb/{BreadcumbDropdown.tsx → BreadcrumbDropdown.tsx} +1 -1
  96. package/src/components/Breadcrumb/index.tsx +1 -0
  97. package/src/components/Calendar/Calendar.tsx +3 -3
  98. package/src/components/Checkbox/Checkbox.tsx +3 -8
  99. package/src/components/Checkbox/CheckboxExample.tsx +8 -0
  100. package/src/components/CheckboxGroup/CheckboxGroup.tsx +4 -7
  101. package/src/components/CheckboxGroup/CheckboxGroupExample.tsx +12 -0
  102. package/src/components/CheckboxGroupField/CheckboxGroupFieldExample.tsx +18 -0
  103. package/src/components/CheckboxOption/CheckboxOption.tsx +1 -3
  104. package/src/components/Chip/Chip.tsx +1 -1
  105. package/src/components/Field/field.scss +2 -0
  106. package/src/components/Field/utils.ts +1 -1
  107. package/src/components/FormField/FormFieldExample.tsx +1 -1
  108. package/src/components/Input/InputElement.tsx +1 -1
  109. package/src/components/Input/InputExample.tsx +1 -1
  110. package/src/components/Modal/Modal.tsx +0 -2
  111. package/src/components/PageControl/PageControl.tsx +3 -3
  112. package/src/components/Pagination/PageInput.tsx +1 -1
  113. package/src/components/Portal/Portal.tsx +1 -5
  114. package/src/components/Radio/RadioExample.tsx +3 -1
  115. package/src/components/Radio/radio.scss +2 -1
  116. package/src/components/RadioGroup/RadioGroup.tsx +3 -3
  117. package/src/components/RadioGroup/RadioGroupExample.tsx +72 -5
  118. package/src/components/RadioGroupField/RadioGroupFieldExample.tsx +18 -0
  119. package/src/components/SearchBar/SearchBar.tsx +14 -12
  120. package/src/components/Slider/SliderIntervalDots.tsx +1 -1
  121. package/src/components/Switch/Switch.tsx +1 -9
  122. package/src/components/Switch/SwitchExample.tsx +6 -0
  123. package/src/components/Table/index.tsx +1 -0
  124. package/src/components/TimePicker/Listbox.tsx +2 -2
  125. package/src/components/TimePicker/Segment.tsx +1 -1
  126. package/src/components/ToggleOption/ToggleOption.tsx +3 -4
  127. package/src/hooks/useArrowNavigation.ts +2 -2
  128. package/src/hooks/useDebounceCallback.ts +1 -1
  129. package/src/hooks/useDebounceState.ts +0 -1
  130. package/src/hooks/useOutsideClick.ts +4 -8
  131. package/src/hooks/useTimeout.ts +1 -1
  132. package/src/types/common.ts +5 -7
  133. package/src/utils/countryCodes.ts +1 -1
  134. package/src/utils/createExampleChildElement.tsx +1 -1
  135. package/src/utils/demo.ts +1 -1
  136. package/dist/components/Breadcrumb/BreadcumbDropdown.js.map +0 -1
  137. package/dist/hooks/useModalState.d.ts +0 -22
  138. package/dist/hooks/useModalState.js +0 -34
  139. package/dist/hooks/useModalState.js.map +0 -1
  140. package/src/hooks/useModalState.ts +0 -37
@@ -35,8 +35,8 @@ export type AvatarGroupProps = CommonProps<'style'> & {
35
35
  * Recommended to set this to a value between 3 and 5 for optimal display.
36
36
  *
37
37
  * @default 5
38
- * @min 1
39
- * @max 5
38
+ * @minimum 1
39
+ * @maximum 5
40
40
  */
41
41
  max?: number;
42
42
  /**
@@ -9,7 +9,7 @@ import { handleKeyDown } from '-/utils/handleKeyDown';
9
9
  import { scrollListItemsStyle } from '-/utils/scrollListItemsStyle';
10
10
  import { useIds } from '-/utils/useIds';
11
11
 
12
- type AvatarGroupOverflowProps = {
12
+ export type AvatarGroupOverflowProps = {
13
13
  /** The number of overflow avatars */
14
14
  overflow: number;
15
15
  /** The size of the avatar group */
@@ -2,7 +2,7 @@ import './badge-dot.scss';
2
2
  import { ReactNode } from 'react';
3
3
  import { cssWithVars } from '-/utils/cwv';
4
4
 
5
- type BadgeDotSize = 6 | 8 | 10 | 12;
5
+ export type BadgeDotSize = 6 | 8 | 10 | 12;
6
6
 
7
7
  const OUTLINE_WIDTHS: Record<BadgeDotSize, number> = {
8
8
  6: 1,
@@ -1,6 +1,6 @@
1
1
  import './breadcrumb.scss';
2
2
  import { SvgChevronRight } from '@bspk/icons/ChevronRight';
3
- import { BreadcrumbDropdown, BreadcrumbItem } from './BreadcumbDropdown';
3
+ import { BreadcrumbDropdown, BreadcrumbItem } from './BreadcrumbDropdown';
4
4
  import { Link } from '-/components/Link';
5
5
  import { Txt } from '-/components/Txt';
6
6
  import { useId } from '-/hooks/useId';
@@ -32,7 +32,7 @@ export type BreadcrumbItem = {
32
32
  href: string;
33
33
  };
34
34
 
35
- type BreadcrumbDropdownProps = ScrollListItemsStyleProps & {
35
+ export type BreadcrumbDropdownProps = ScrollListItemsStyleProps & {
36
36
  items: BreadcrumbItem[];
37
37
  id: string;
38
38
  };
@@ -1 +1,2 @@
1
1
  export * from './Breadcrumb';
2
+ export * from './BreadcrumbDropdown';
@@ -28,10 +28,10 @@ import { useId } from '-/hooks/useId';
28
28
  import { getElementById } from '-/utils/dom';
29
29
  import { handleKeyDown } from '-/utils/handleKeyDown';
30
30
 
31
- type Direction = '<' | '<<' | '>' | '>>';
32
- type Kind = 'day' | 'month' | 'year';
31
+ export type Direction = '<' | '<<' | '>' | '>>';
32
+ export type Kind = 'day' | 'month' | 'year';
33
33
 
34
- type ConfigKind = {
34
+ export type ConfigKind = {
35
35
  header: Record<
36
36
  Direction,
37
37
  {
@@ -2,7 +2,7 @@ import './checkbox.scss';
2
2
  import { ChangeEvent, useEffect, useRef } from 'react';
3
3
  import { ElementProps, FieldControlProps } from '-/types/common';
4
4
 
5
- export type CheckboxProps = Omit<FieldControlProps, 'onChange' | 'value'> & {
5
+ export type CheckboxProps = Omit<FieldControlProps, 'onChange' | 'readOnly' | 'value'> & {
6
6
  /**
7
7
  * If the checkbox is partially checked or
8
8
  * [indeterminate](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes).
@@ -64,7 +64,6 @@ export function Checkbox({
64
64
  indeterminate: indeterminateProp,
65
65
  invalid,
66
66
  disabled,
67
- readOnly,
68
67
  required,
69
68
  ...props
70
69
  }: ElementProps<CheckboxProps, 'input'>) {
@@ -79,10 +78,7 @@ export function Checkbox({
79
78
  }, [indeterminate]);
80
79
 
81
80
  return (
82
- <span
83
- //
84
- data-bspk="checkbox"
85
- >
81
+ <span data-bspk="checkbox">
86
82
  <input
87
83
  {...props}
88
84
  aria-describedby={props['aria-describedby'] || undefined}
@@ -90,9 +86,8 @@ export function Checkbox({
90
86
  aria-invalid={invalid || undefined}
91
87
  checked={checked}
92
88
  data-indeterminate={indeterminate || undefined}
93
- disabled={disabled || readOnly || undefined}
89
+ disabled={disabled || undefined}
94
90
  onChange={(event) => props.onChange(!!event.target.checked, event)}
95
- readOnly={readOnly}
96
91
  ref={(node) => {
97
92
  if (!node) return;
98
93
  inputRef.current = node;
@@ -0,0 +1,8 @@
1
+ import { CheckboxProps } from '.';
2
+ import { ComponentExample } from '-/utils/demo';
3
+
4
+ export const CheckboxExample: ComponentExample<CheckboxProps> = {
5
+ render: ({ props, Component }) => (
6
+ <Component {...props} aria-label={props['aria-label'] || 'checkbox aria-label'} />
7
+ ),
8
+ };
@@ -9,7 +9,7 @@ const ALL_LABEL = 'All';
9
9
  export type CheckboxGroupOption = Pick<CheckboxProps, 'value'> &
10
10
  Pick<ToggleOptionProps, 'description' | 'disabled' | 'label'>;
11
11
 
12
- export type CheckboxGroupProps = FieldControlProps<string[]> & {
12
+ export type CheckboxGroupProps = Omit<FieldControlProps<string[]>, 'readOnly'> & {
13
13
  /**
14
14
  * The options for the checkboxes.
15
15
  *
@@ -37,6 +37,8 @@ export type CheckboxGroupProps = FieldControlProps<string[]> & {
37
37
  /**
38
38
  * A group of checkboxes that allows users to choose one or more items from a list or turn an feature on or off.
39
39
  *
40
+ * For a more complete example with field usage, see the CheckboxGroupField component.
41
+ *
40
42
  * @example
41
43
  * import { CheckboxGroup } from '@bspk/ui/CheckboxGroup';
42
44
  *
@@ -71,7 +73,6 @@ export function CheckboxGroup({
71
73
  selectAll,
72
74
  selectAllProps,
73
75
  disabled = false,
74
- readOnly,
75
76
  invalid: invalidProp,
76
77
  required,
77
78
  id: idProp,
@@ -83,7 +84,6 @@ export function CheckboxGroup({
83
84
  idProp,
84
85
  required,
85
86
  disabled,
86
- readOnly,
87
87
  invalidProp,
88
88
  });
89
89
 
@@ -96,7 +96,7 @@ export function CheckboxGroup({
96
96
  role="group"
97
97
  >
98
98
  {selectAll && (
99
- <ToggleOption label={selectAllProps?.label || ALL_LABEL} readOnly={readOnly}>
99
+ <ToggleOption label={selectAllProps?.label || ALL_LABEL}>
100
100
  <Checkbox
101
101
  aria-errormessage={ariaErrorMessageProp || ariaErrorMessage || undefined}
102
102
  aria-label={selectAllProps?.label || ALL_LABEL}
@@ -107,7 +107,6 @@ export function CheckboxGroup({
107
107
  invalid={invalid || undefined}
108
108
  name={name}
109
109
  onChange={(checked) => onChange(checked ? options.map((o) => o.value) : [])}
110
- readOnly={readOnly}
111
110
  value="all"
112
111
  />
113
112
  </ToggleOption>
@@ -118,7 +117,6 @@ export function CheckboxGroup({
118
117
  disabled={disabled || optionDisabled}
119
118
  key={optionValue}
120
119
  label={label}
121
- readOnly={readOnly}
122
120
  >
123
121
  <Checkbox
124
122
  aria-errormessage={ariaErrorMessageProp || ariaErrorMessage || undefined}
@@ -130,7 +128,6 @@ export function CheckboxGroup({
130
128
  onChange={(checked) => {
131
129
  onChange(checked ? [...value, optionValue] : value.filter((v) => v !== optionValue));
132
130
  }}
133
- readOnly={readOnly}
134
131
  value={optionValue}
135
132
  />
136
133
  </ToggleOption>
@@ -57,4 +57,16 @@ export const presets: Preset<CheckboxGroupProps>[] = [
57
57
 
58
58
  export const CheckboxGroupExample: ComponentExample<CheckboxGroupProps> = {
59
59
  presets,
60
+ defaultState: {
61
+ options: [
62
+ { label: 'Option 1', value: 'option1', description: 'Description for option 1' },
63
+ {
64
+ label: 'Option 2',
65
+ value: 'option2',
66
+ description: 'Description for option 2 (disabled)',
67
+ disabled: true,
68
+ },
69
+ { label: 'Option 3', value: 'option3', description: 'Description for option 3' },
70
+ ],
71
+ },
60
72
  };
@@ -0,0 +1,18 @@
1
+ import { CheckboxGroupFieldProps } from '.';
2
+ import { CheckboxGroupExample as checkboxGroupExample } from '-/components/CheckboxGroup/CheckboxGroupExample';
3
+ import { ComponentExample, Preset } from '-/utils/demo';
4
+
5
+ export const presets: Preset<CheckboxGroupFieldProps>[] = checkboxGroupExample.presets!.map((preset) => ({
6
+ ...preset,
7
+ propState: {
8
+ label: 'Checkbox Group Field',
9
+ ...preset.propState,
10
+ },
11
+ }));
12
+
13
+ export const CheckboxGroupFieldExample: ComponentExample<CheckboxGroupFieldProps> = {
14
+ presets,
15
+ defaultState: {
16
+ ...checkboxGroupExample.defaultState,
17
+ },
18
+ };
@@ -36,7 +36,6 @@ export function CheckboxOption({
36
36
  label: labelProp,
37
37
  description,
38
38
  disabled,
39
- readOnly,
40
39
  style,
41
40
  ...checkboxProps
42
41
  }: CheckboxOptionProps) {
@@ -49,10 +48,9 @@ export function CheckboxOption({
49
48
  description={description}
50
49
  disabled={disabled}
51
50
  label={label}
52
- readOnly={readOnly}
53
51
  style={style}
54
52
  >
55
- <Checkbox {...checkboxProps} aria-label={ariaLabel} disabled={disabled} readOnly={readOnly} />
53
+ <Checkbox {...checkboxProps} aria-label={ariaLabel} disabled={disabled} />
56
54
  </ToggleOption>
57
55
  )
58
56
  );
@@ -29,7 +29,7 @@ export type ChipProps = {
29
29
  /** The function to call when the chip is clicked. */
30
30
  onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
31
31
  /**
32
- * Whether the chip is currently selected.
32
+ * Visual indication of whether the chip is currently selected.
33
33
  *
34
34
  * @default false
35
35
  */
@@ -4,6 +4,8 @@
4
4
  flex-direction: column;
5
5
  gap: var(--spacing-sizing-01);
6
6
  border: none;
7
+ max-width: 100%;
8
+ min-inline-size: unset;
7
9
  }
8
10
 
9
11
  [data-bspk='field-label'] {
@@ -52,7 +52,7 @@ export function useFieldInit({
52
52
  idProp: string | undefined;
53
53
  required: boolean | undefined;
54
54
  disabled: boolean | undefined;
55
- readOnly: boolean | undefined;
55
+ readOnly?: boolean | undefined;
56
56
  invalidProp: boolean | undefined;
57
57
  }): Pick<FieldContext, 'ariaDescribedBy' | 'ariaErrorMessage'> & { invalid: boolean; id: string } {
58
58
  const context = useContext(fieldContext);
@@ -15,7 +15,7 @@ import { TimePicker } from '-/components/TimePicker';
15
15
  import { FieldControlProps } from '-/types/common';
16
16
  import { ComponentExample, Preset, Syntax } from '-/utils/demo';
17
17
 
18
- type ExampleProps = Partial<FieldControlProps & FormFieldProps>;
18
+ export type ExampleProps = Partial<FieldControlProps & FormFieldProps>;
19
19
 
20
20
  export const presets: Preset<Partial<ExampleProps>>[] = [
21
21
  {
@@ -13,7 +13,7 @@ export const DEFAULT = {
13
13
  autoComplete: 'off',
14
14
  } as const;
15
15
 
16
- type InputElementBaseProps = CommonProps<'owner' | 'size'> &
16
+ export type InputElementBaseProps = CommonProps<'owner' | 'size'> &
17
17
  FieldControlProps &
18
18
  Pick<FieldContextProps, 'ariaDescribedBy' | 'ariaErrorMessage'> & {
19
19
  /** The ref of the container. */
@@ -1,7 +1,7 @@
1
1
  import { InputProps } from '.';
2
2
  import { ComponentExample } from '-/utils/demo';
3
3
 
4
- type InputExampleProps = InputProps & { label: string; description?: string };
4
+ export type InputExampleProps = InputProps & { label: string; description?: string };
5
5
 
6
6
  export const InputExample: ComponentExample<InputExampleProps> = {
7
7
  defaultState: {
@@ -132,8 +132,6 @@ export type ModalProps = Pick<
132
132
  * );
133
133
  * }
134
134
  *
135
- * @ignoreRefs ButtonProps
136
- *
137
135
  * @name Modal
138
136
  * @phase UXReview
139
137
  */
@@ -9,7 +9,7 @@ export type PageControlProps = {
9
9
  * @example
10
10
  * 1;
11
11
  *
12
- * @min 1
12
+ * @minimum 1
13
13
  * @required
14
14
  */
15
15
  currentPage: number;
@@ -19,7 +19,7 @@ export type PageControlProps = {
19
19
  * @example
20
20
  * 5;
21
21
  *
22
- * @min 1
22
+ * @minimum 1
23
23
  * @required
24
24
  */
25
25
  numPages: number;
@@ -31,7 +31,7 @@ export type PageControlProps = {
31
31
  variant?: 'flat' | 'floating';
32
32
  };
33
33
 
34
- type DotSize = 'medium' | 'small' | 'x-small';
34
+ export type DotSize = 'medium' | 'small' | 'x-small';
35
35
 
36
36
  /**
37
37
  * A visual indicator that displays a series of dots representing the number of pages or elements within a moving
@@ -4,7 +4,7 @@ import { PaginationProps } from './Pagination';
4
4
  import { Input } from '-/components/Input';
5
5
  import { Txt } from '-/components/Txt';
6
6
 
7
- type PageInputProps = Pick<PaginationProps, 'numPages' | 'onChange' | 'value'>;
7
+ export type PageInputProps = Pick<PaginationProps, 'numPages' | 'onChange' | 'value'>;
8
8
 
9
9
  export const PageInput: FC<PageInputProps> = ({ numPages, onChange, value }) => {
10
10
  const [page, setPage] = useState<string>(String(value));
@@ -8,11 +8,7 @@ export type PortalProps = {
8
8
  * @required
9
9
  */
10
10
  children: ReactNode;
11
- /**
12
- * The container to render the portal in.
13
- *
14
- * @optional
15
- */
11
+ /** The container to render the portal in. */
16
12
  container?: HTMLElement;
17
13
  };
18
14
 
@@ -1,5 +1,7 @@
1
1
  import { ComponentExample, createUid } from '-/utils/demo';
2
2
 
3
3
  export const RadioExample: ComponentExample = {
4
- render: ({ props, Component }) => <Component {...props} name={createUid('radio')} />,
4
+ render: ({ props, Component }) => (
5
+ <Component {...props} aria-label={props['aria-label'] || 'radio aria-label'} name={createUid('radio')} />
6
+ ),
5
7
  };
@@ -36,7 +36,8 @@
36
36
  &::before {
37
37
  content: '';
38
38
  display: block;
39
- width: var(--spacing-sizing-03);
39
+ width: 100%;
40
+ scale: 0.7;
40
41
  aspect-ratio: 1/1;
41
42
  background: var(--inner);
42
43
  border-radius: var(--radius-full);
@@ -7,7 +7,7 @@ import { ElementProps, FieldControlProps } from '-/types/common';
7
7
  export type RadioGroupOption = Pick<RadioOptionProps, 'checked' | 'description' | 'disabled' | 'label'> &
8
8
  Pick<RadioProps, 'value'>;
9
9
 
10
- export type RadioGroupProps = FieldControlProps & {
10
+ export type RadioGroupProps = Omit<FieldControlProps, 'readOnly'> & {
11
11
  /**
12
12
  * The options for the radios.
13
13
  *
@@ -34,6 +34,8 @@ export type RadioGroupProps = FieldControlProps & {
34
34
  /**
35
35
  * A group of radios that allows users to choose one or more items from a list or turn an feature on or off.
36
36
  *
37
+ * For a more complete example with field usage, see the RadioGroupField component.
38
+ *
37
39
  * @example
38
40
  * import { useState } from 'react';
39
41
  * import { RadioGroup } from '@bspk/ui/RadioGroup';
@@ -68,7 +70,6 @@ export function RadioGroup({
68
70
  name,
69
71
  value: groupValue,
70
72
  disabled = false,
71
- readOnly,
72
73
  invalid: invalidProp,
73
74
  required,
74
75
  id: idProp,
@@ -80,7 +81,6 @@ export function RadioGroup({
80
81
  idProp,
81
82
  required,
82
83
  disabled,
83
- readOnly,
84
84
  invalidProp,
85
85
  });
86
86
 
@@ -1,11 +1,78 @@
1
1
  import { RadioGroupProps } from '.';
2
- import { CheckboxGroupExample } from '-/components/CheckboxGroup/CheckboxGroupExample';
3
- import { RadioExample } from '-/components/Radio/RadioExample';
4
- import { ComponentExample } from '-/utils/demo';
2
+ import { ComponentExample, Preset } from '-/utils/demo';
3
+ import { randomString } from '-/utils/random';
5
4
 
6
- export const presets = (CheckboxGroupExample.presets as ComponentExample<RadioGroupProps>['presets']) || [];
5
+ export const presets: Preset<RadioGroupProps>[] = [
6
+ {
7
+ label: 'With Descriptions',
8
+ propState: {
9
+ value: 'option2',
10
+ disabled: false,
11
+ options: [
12
+ { label: 'Option 1', value: 'option1', description: 'Description for option 1' },
13
+ {
14
+ label: 'Option 2',
15
+ value: 'option2',
16
+ description: 'Description for option 2 (disabled)',
17
+ disabled: true,
18
+ },
19
+ { label: 'Option 3', value: 'option3', description: 'Description for option 3' },
20
+ ],
21
+ ['aria-label']: 'Radio group',
22
+ name: 'Radio group',
23
+ },
24
+ },
25
+ {
26
+ label: 'Group disabled',
27
+ propState: {
28
+ value: 'option2',
29
+ disabled: true,
30
+ options: [
31
+ { label: 'Option 1', value: 'option1', description: 'Description for option 1' },
32
+ {
33
+ label: 'Option 2',
34
+ value: 'option2',
35
+ description: 'Description for option 2 (disabled)',
36
+ },
37
+ { label: 'Option 3', value: 'option3', description: 'Description for option 3' },
38
+ ],
39
+ ['aria-label']: 'Radio group',
40
+ name: 'Radio group',
41
+ },
42
+ },
43
+ {
44
+ label: 'Long labels',
45
+ propState: {
46
+ value: 'option2',
47
+ disabled: false,
48
+ options: [
49
+ { label: 'This is a very long label for option 1 that never seems to end', value: 'option1' },
50
+ { label: 'This is a very long label for option 2 that never seems to end', value: 'option2' },
51
+ { label: 'This is a very long label for option 3', value: 'option3' },
52
+ ],
53
+ ['aria-label']: 'Radio group',
54
+ name: 'Radio group',
55
+ },
56
+ },
57
+ ];
7
58
 
8
59
  export const RadioGroupExample: ComponentExample<RadioGroupProps> = {
9
- render: RadioExample.render,
10
60
  presets,
61
+ render: ({ props, Component }) => {
62
+ const id = randomString();
63
+ return <Component {...props} id={id} name={props.name + id} />;
64
+ },
65
+ defaultState: {
66
+ value: 'option3',
67
+ options: [
68
+ { label: 'Option 1', value: 'option1', description: 'Description for option 1' },
69
+ {
70
+ label: 'Option 2',
71
+ value: 'option2',
72
+ description: 'Description for option 2 (disabled)',
73
+ disabled: true,
74
+ },
75
+ { label: 'Option 3', value: 'option3', description: 'Description for option 3' },
76
+ ],
77
+ },
11
78
  };
@@ -0,0 +1,18 @@
1
+ import { RadioGroupFieldProps } from '.';
2
+ import { RadioGroupExample as radioGroupExample } from '-/components/RadioGroup/RadioGroupExample';
3
+ import { ComponentExample, Preset } from '-/utils/demo';
4
+
5
+ export const presets: Preset<RadioGroupFieldProps>[] = radioGroupExample.presets!.map((preset) => ({
6
+ ...preset,
7
+ propState: {
8
+ label: 'Radio Group Field',
9
+ ...preset.propState,
10
+ },
11
+ }));
12
+
13
+ export const RadioGroupFieldExample: ComponentExample<RadioGroupFieldProps> = {
14
+ presets,
15
+ defaultState: {
16
+ ...radioGroupExample.defaultState,
17
+ },
18
+ };
@@ -23,7 +23,10 @@ import { useIds } from '-/utils/useIds';
23
23
  */
24
24
  export type SearchBarOption = Pick<ListItemProps, 'label' | 'leading' | 'trailing'>;
25
25
 
26
- export type SearchBarProps<O extends SearchBarOption = SearchBarOption> = FieldControlProps<string, O> &
26
+ export type SearchBarProps<O extends SearchBarOption = SearchBarOption> = Omit<
27
+ FieldControlProps<string, O>,
28
+ 'invalid' | 'readOnly' | 'required'
29
+ > &
27
30
  Pick<InputProps, 'inputRef' | 'size' | 'trailing'> &
28
31
  ScrollListItemsStyleProps & {
29
32
  /**
@@ -111,9 +114,11 @@ export function SearchBar<O extends SearchBarOption>({
111
114
  disabled = false,
112
115
  scrollLimit,
113
116
  trailing,
117
+ 'aria-label': ariaLabel,
114
118
  }: SearchBarProps<O>) {
115
119
  const id = useId(idProp);
116
120
  const menuId = `${id}-menu`;
121
+ const noResultsId = `${id}-no-results`;
117
122
 
118
123
  const items = useIds(`search-bar-${id}`, itemsProp || []);
119
124
 
@@ -162,23 +167,20 @@ export function SearchBar<O extends SearchBarOption>({
162
167
  };
163
168
 
164
169
  useEffect(() => {
165
- if (!hasFocus) {
166
- setActiveElementId(null);
167
- return;
168
- }
170
+ if (!hasFocus) return setActiveElementId(null);
171
+
172
+ if (!filteredItems.length) return setActiveElementId(noResultsId);
169
173
 
170
174
  if (activeElementId) return;
171
175
 
172
- // If we have focus but no active element, set the first item as active (if there is one)
173
- if (filteredItems.length) {
174
- setActiveElementId(value?.trim().length ? filteredItems[0].id : null);
175
- }
176
- }, [hasFocus, filteredItems, activeElementId, setActiveElementId, value]);
176
+ setActiveElementId(value?.trim().length ? filteredItems[0].id : null);
177
+ }, [hasFocus, filteredItems, activeElementId, setActiveElementId, value, noResultsId]);
177
178
 
178
179
  return (
179
180
  <>
180
181
  <div data-bspk="search-bar">
181
182
  <Input
183
+ aria-label={ariaLabel}
182
184
  autoComplete="off"
183
185
  containerRef={elements.setReference}
184
186
  disabled={disabled}
@@ -242,8 +244,8 @@ export function SearchBar<O extends SearchBarOption>({
242
244
  }}
243
245
  tabIndex={-1}
244
246
  >
245
- {!!value?.length && !items?.length && (
246
- <div data-bspk="no-items-found">
247
+ {activeElementId === noResultsId && (
248
+ <div data-bspk="no-items-found" id={noResultsId}>
247
249
  <Txt as="div" variant="heading-h5">
248
250
  No results found
249
251
  </Txt>
@@ -1,6 +1,6 @@
1
1
  import { SliderProps, SliderValue } from './Slider';
2
2
 
3
- type IntervalDotProps = Pick<SliderProps<SliderValue>, 'max' | 'min' | 'value'> & {
3
+ export type IntervalDotProps = Pick<SliderProps<SliderValue>, 'max' | 'min' | 'value'> & {
4
4
  step: number;
5
5
  };
6
6
 
@@ -16,12 +16,6 @@ export type SwitchProps = CommonProps<'aria-label' | 'disabled' | 'name'> & {
16
16
  * @required
17
17
  */
18
18
  onChange: (checked: boolean, event: ChangeEvent<HTMLInputElement>) => void;
19
- /**
20
- * Only exists as a alias for `disabled` and to match other input properties.
21
- *
22
- * @default false
23
- */
24
- readOnly?: boolean;
25
19
  /** The value of the switch. */
26
20
  value: string;
27
21
  };
@@ -53,9 +47,7 @@ export type SwitchProps = CommonProps<'aria-label' | 'disabled' | 'name'> & {
53
47
  * @name Switch
54
48
  * @phase UXReview
55
49
  */
56
- export function Switch({ checked = false, disabled: disabledProp = false, readOnly, ...props }: SwitchProps) {
57
- const disabled = readOnly || disabledProp;
58
-
50
+ export function Switch({ checked = false, disabled = false, ...props }: SwitchProps) {
59
51
  return (
60
52
  <span data-bspk="switch">
61
53
  <input
@@ -0,0 +1,6 @@
1
+ import { SwitchProps } from '.';
2
+ import { ComponentExample } from '-/utils/demo';
3
+
4
+ export const SwitchExample: ComponentExample<SwitchProps> = {
5
+ render: ({ props, Component }) => <Component {...props} aria-label={props['aria-label'] || 'switch aria-label'} />,
6
+ };
@@ -1 +1,2 @@
1
1
  export * from './Table';
2
+ export * from './utils';
@@ -3,13 +3,13 @@ import { useArrowNavigation } from '-/hooks/useArrowNavigation';
3
3
  import { getElementById } from '-/utils/dom';
4
4
  import { handleKeyDown } from '-/utils/handleKeyDown';
5
5
 
6
- type Option = {
6
+ export type Option = {
7
7
  id: string;
8
8
  value: string;
9
9
  label: string;
10
10
  };
11
11
 
12
- type TimePickerListboxProps = {
12
+ export type TimePickerListboxProps = {
13
13
  options: Option[];
14
14
  selectedValue?: string;
15
15
  type: TimePickerType;