@bspk/ui 1.1.26 → 1.1.28

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 (115) hide show
  1. package/dist/Avatar.d.ts +2 -1
  2. package/dist/Avatar.js.map +1 -1
  3. package/dist/Button.js +1 -1
  4. package/dist/Button.js.map +1 -1
  5. package/dist/FormField.d.ts +2 -2
  6. package/dist/FormField.js +1 -1
  7. package/dist/Popover.d.ts +2 -3
  8. package/dist/Popover.js +3 -4
  9. package/dist/Popover.js.map +1 -1
  10. package/dist/ProgressBar.d.ts +6 -7
  11. package/dist/ProgressBar.js +6 -7
  12. package/dist/ProgressBar.js.map +1 -1
  13. package/dist/ProgressCircle.d.ts +6 -7
  14. package/dist/ProgressCircle.js +6 -7
  15. package/dist/ProgressCircle.js.map +1 -1
  16. package/dist/ProgressionStepper.d.ts +3 -8
  17. package/dist/ProgressionStepper.js +3 -8
  18. package/dist/ProgressionStepper.js.map +1 -1
  19. package/dist/RadioGroup.d.ts +9 -2
  20. package/dist/RadioGroup.js.map +1 -1
  21. package/dist/SearchBar.d.ts +1 -2
  22. package/dist/SearchBar.js +5 -6
  23. package/dist/SearchBar.js.map +1 -1
  24. package/dist/SegmentedControl.d.ts +8 -15
  25. package/dist/SegmentedControl.js +2 -4
  26. package/dist/SegmentedControl.js.map +1 -1
  27. package/dist/{Dropdown.d.ts → Select.d.ts} +15 -15
  28. package/dist/Select.js +67 -0
  29. package/dist/Select.js.map +1 -0
  30. package/dist/{DropdownField.d.ts → SelectField.d.ts} +9 -9
  31. package/dist/SelectField.js +39 -0
  32. package/dist/SelectField.js.map +1 -0
  33. package/dist/StylesProviderAnywhere.js +1 -1
  34. package/dist/StylesProviderBetterHomesGardens.js +1 -1
  35. package/dist/StylesProviderCartus.js +1 -1
  36. package/dist/StylesProviderCentury21.js +1 -1
  37. package/dist/StylesProviderColdwellBanker.js +1 -1
  38. package/dist/StylesProviderCorcoran.js +1 -1
  39. package/dist/StylesProviderDenaliBoss.js +1 -1
  40. package/dist/StylesProviderEra.js +1 -1
  41. package/dist/StylesProviderSothebys.js +1 -1
  42. package/dist/TabGroup.d.ts +5 -6
  43. package/dist/TabGroup.js.map +1 -1
  44. package/dist/Tag.d.ts +1 -2
  45. package/dist/Tag.js +1 -2
  46. package/dist/Tag.js.map +1 -1
  47. package/dist/TextField.d.ts +2 -3
  48. package/dist/TextField.js +2 -4
  49. package/dist/TextField.js.map +1 -1
  50. package/dist/TextInput.d.ts +4 -13
  51. package/dist/TextInput.js +3 -11
  52. package/dist/TextInput.js.map +1 -1
  53. package/dist/Textarea.d.ts +5 -14
  54. package/dist/Textarea.js +6 -16
  55. package/dist/Textarea.js.map +1 -1
  56. package/dist/TextareaField.d.ts +1 -2
  57. package/dist/TextareaField.js +1 -2
  58. package/dist/TextareaField.js.map +1 -1
  59. package/dist/Txt.d.ts +1 -2
  60. package/dist/Txt.js +1 -2
  61. package/dist/Txt.js.map +1 -1
  62. package/dist/base.css +1 -1
  63. package/dist/demo/ExamplePlaceholder.js.map +1 -1
  64. package/dist/demo/examples.js +84 -15
  65. package/dist/demo/examples.js.map +1 -1
  66. package/dist/hooks/useCombobox.d.ts +45 -0
  67. package/dist/hooks/{useFloatingMenu.js → useCombobox.js} +17 -8
  68. package/dist/hooks/useCombobox.js.map +1 -0
  69. package/dist/hooks/useFloating.d.ts +39 -8
  70. package/dist/hooks/useFloating.js +2 -13
  71. package/dist/hooks/useFloating.js.map +1 -1
  72. package/dist/hooks/useKeyboardNavigation.d.ts +1 -1
  73. package/dist/hooks/useKeyboardNavigation.js +1 -1
  74. package/dist/hooks/useOutsideClick.d.ts +2 -2
  75. package/dist/hooks/useOutsideClick.js +2 -2
  76. package/dist/index.d.ts +3 -1
  77. package/dist/index.js +3 -1
  78. package/dist/index.js.map +1 -1
  79. package/dist/select.css +1 -0
  80. package/package.json +3 -2
  81. package/src/Avatar.tsx +2 -1
  82. package/src/Button.tsx +2 -2
  83. package/src/FormField.tsx +2 -2
  84. package/src/Popover.tsx +5 -27
  85. package/src/ProgressBar.tsx +6 -7
  86. package/src/ProgressCircle.tsx +6 -7
  87. package/src/ProgressionStepper.tsx +3 -8
  88. package/src/RadioGroup.tsx +9 -2
  89. package/src/SearchBar.tsx +8 -20
  90. package/src/SegmentedControl.tsx +14 -37
  91. package/src/{Dropdown.tsx → Select.tsx} +30 -32
  92. package/src/{DropdownField.tsx → SelectField.tsx} +15 -15
  93. package/src/TabGroup.tsx +6 -10
  94. package/src/Tag.tsx +1 -2
  95. package/src/TextField.tsx +6 -19
  96. package/src/TextInput.tsx +6 -27
  97. package/src/Textarea.tsx +10 -31
  98. package/src/TextareaField.tsx +3 -8
  99. package/src/Txt.tsx +2 -7
  100. package/src/base.scss +53 -70
  101. package/src/demo/ExamplePlaceholder.tsx +6 -1
  102. package/src/demo/examples.tsx +99 -21
  103. package/src/hooks/{useFloatingMenu.ts → useCombobox.ts} +28 -40
  104. package/src/hooks/useFloating.ts +45 -24
  105. package/src/hooks/useKeyboardNavigation.ts +1 -1
  106. package/src/hooks/useOutsideClick.ts +2 -2
  107. package/src/index.ts +3 -1
  108. package/src/{dropdown.scss → select.scss} +36 -36
  109. package/dist/Dropdown.js +0 -68
  110. package/dist/Dropdown.js.map +0 -1
  111. package/dist/DropdownField.js +0 -39
  112. package/dist/DropdownField.js.map +0 -1
  113. package/dist/dropdown.css +0 -1
  114. package/dist/hooks/useFloatingMenu.d.ts +0 -36
  115. package/dist/hooks/useFloatingMenu.js.map +0 -1
@@ -12,20 +12,51 @@
12
12
  */
13
13
  import { Placement, Strategy, MiddlewareData, OffsetOptions } from '@floating-ui/dom';
14
14
  export type { Placement, Strategy };
15
+ export type UseFloatingProps = {
16
+ /**
17
+ * The preferred placement of the floating element.
18
+ *
19
+ * This determines where the floating element will be positioned relative to the reference element.
20
+ *
21
+ * @default bottom
22
+ */
23
+ placement: Placement;
24
+ /** A ref object for the arrow element. */
25
+ arrowRef?: React.MutableRefObject<HTMLElement | null>;
26
+ /**
27
+ * The positioning strategy ('absolute' or 'fixed').
28
+ *
29
+ * When set to 'fixed', the floating element will be positioned relative to the viewport.
30
+ *
31
+ * When set to 'absolute', the floating element will be positioned relative to the nearest positioned ancestor.
32
+ *
33
+ * @default fixed
34
+ */
35
+ strategy?: Strategy;
36
+ /**
37
+ * The offset options for the floating element.
38
+ *
39
+ * @default 0
40
+ */
41
+ offsetOptions?: OffsetOptions;
42
+ /**
43
+ * When set to true, the width of the floating element will match the width of the reference element.
44
+ *
45
+ * When set to an HTMLElement, the width of the floating element will match the width of that HTMLElement.
46
+ *
47
+ * @default true
48
+ */
49
+ refWidth?: HTMLElement | boolean;
50
+ /** Whether to hide the floating element. */
51
+ hide?: boolean;
52
+ };
15
53
  /**
16
54
  *
17
55
  *
18
56
  * @param param0
19
57
  * @returns
20
58
  */
21
- export declare function useFloating<TriggerElementType extends HTMLElement>({ placement, arrowRef, strategy, offsetOptions, refWidth, hide, }: {
22
- placement: Placement;
23
- arrowRef?: React.MutableRefObject<HTMLElement | null>;
24
- strategy?: Strategy;
25
- offsetOptions?: OffsetOptions;
26
- refWidth?: boolean;
27
- hide?: boolean;
28
- }): {
59
+ export declare function useFloating<TriggerElementType extends HTMLElement>({ placement, arrowRef, strategy, offsetOptions, refWidth, hide, }: UseFloatingProps): {
29
60
  elements: {
30
61
  trigger: TriggerElementType | null;
31
62
  floating: HTMLElement | null;
@@ -20,7 +20,7 @@ const TRANSITION_DELAY = 250;
20
20
  * @param param0
21
21
  * @returns
22
22
  */
23
- export function useFloating({ placement, arrowRef, strategy, offsetOptions = 0, refWidth, hide = false, }) {
23
+ export function useFloating({ placement = 'bottom', arrowRef, strategy = 'fixed', offsetOptions = 0, refWidth = true, hide = false, }) {
24
24
  const [floatingStyles, setFloatingStylesState] = useState({
25
25
  opacity: 0,
26
26
  pointerEvents: 'none',
@@ -35,17 +35,6 @@ export function useFloating({ placement, arrowRef, strategy, offsetOptions = 0,
35
35
  const [middlewareData, setMiddlewareData] = useState({});
36
36
  const [triggerElement, setTriggerElement] = useState(null);
37
37
  const [floatingElement, setFloatingElement] = useState(null);
38
- // const elements: {
39
- // trigger: HTMLElement | null;
40
- // floating: HTMLElement | null;
41
- // setReference: (node: TriggerElementType | null) => void;
42
- // setFloating: (node: HTMLElement | null) => void;
43
- // } = {
44
- // trigger: triggerElement,
45
- // floating: floatingElement,
46
- // setReference: setTriggerElement,
47
- // setFloating: setFloatingElement,
48
- // };
49
38
  const computeDebounce = useTimeout();
50
39
  const transitionDelay = useTimeout();
51
40
  const compute = useCallback(() => {
@@ -86,7 +75,7 @@ export function useFloating({ placement, arrowRef, strategy, offsetOptions = 0,
86
75
  size({
87
76
  apply({ rects, elements }) {
88
77
  Object.assign(elements.floating.style, {
89
- width: `${rects.reference.width}px`,
78
+ width: refWidth === true ? `${rects.reference.width}px` : `${refWidth.offsetWidth}px`,
90
79
  });
91
80
  },
92
81
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"useFloating.js","sourceRoot":"","sources":["../../src/hooks/useFloating.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAOH,eAAe,EACf,KAAK,EACL,MAAM,EACN,IAAI,EACJ,UAAU,EACV,IAAI,GACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAyC,EAChE,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,aAAa,GAAG,CAAC,EACjB,QAAQ,EACR,IAAI,GAAG,KAAK,GAQf;IACG,MAAM,CAAC,cAAc,EAAE,sBAAsB,CAAC,GAAG,QAAQ,CAAsB;QAC3E,OAAO,EAAE,CAAC;QACV,aAAa,EAAE,MAAM;QACrB,OAAO,EAAE,MAA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KAAK,EAAE,CAAC;QAC5B,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC;IAEtD,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,IAAI,IAAI,cAAc,KAAK,IAAI,IAAI,eAAe,KAAK,IAAI;YAAE,OAAO;QAExE,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QAErE,OAAO,GAAG,EAAE;YACR,OAAO,EAAE,CAAC;QACd,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC;IAErD,OAAO;QACH,QAAQ,EAAE;YACN,OAAO,EAAE,cAAc;YACvB,QAAQ,EAAE,eAAe;YACzB,UAAU,EAAE,iBAAiB;YAC7B,WAAW,EAAE,kBAAkB;SAClC;QACD,cAAc;QACd,cAAc;KACjB,CAAC;AACN,CAAC;AAED,sDAAsD"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * This hook provides keyboard navigation for a list of elements. Used inside the Dropdown component.
2
+ * This hook provides keyboard navigation for a list of elements. Used inside the Select component.
3
3
  *
4
4
  * @example
5
5
  * import { useRef } from 'react';
@@ -2,7 +2,7 @@ import { useState } from 'react';
2
2
  import { EVENT_KEY } from '../utils/keyboard';
3
3
  import { scrollElementIntoView } from '../utils/scrollElementIntoView';
4
4
  /**
5
- * This hook provides keyboard navigation for a list of elements. Used inside the Dropdown component.
5
+ * This hook provides keyboard navigation for a list of elements. Used inside the Select component.
6
6
  *
7
7
  * @example
8
8
  * import { useRef } from 'react';
@@ -1,12 +1,12 @@
1
1
  /**
2
- * A hook which calls a method when a click occurs outside of the provided ref. Used inside the Dropdown and Modal
2
+ * A hook which calls a method when a click occurs outside of the provided ref. Used inside the DropDown and Modal
3
3
  * components.
4
4
  *
5
5
  * @example
6
6
  * import { useOutsideClick } from '@bspk/ui/hooks/useOutsideClick';
7
7
  * import React, { useRef, useState } from 'react';
8
8
  *
9
- * export function Dropdown() {
9
+ * export function Example() {
10
10
  * const [isOpen, setIsOpen] = useState(false);
11
11
  * const containerRef = useRef<HTMLDivElement>(null);
12
12
  *
@@ -1,13 +1,13 @@
1
1
  import { useEffect } from 'react';
2
2
  /**
3
- * A hook which calls a method when a click occurs outside of the provided ref. Used inside the Dropdown and Modal
3
+ * A hook which calls a method when a click occurs outside of the provided ref. Used inside the DropDown and Modal
4
4
  * components.
5
5
  *
6
6
  * @example
7
7
  * import { useOutsideClick } from '@bspk/ui/hooks/useOutsideClick';
8
8
  * import React, { useRef, useState } from 'react';
9
9
  *
10
- * export function Dropdown() {
10
+ * export function Example() {
11
11
  * const [isOpen, setIsOpen] = useState(false);
12
12
  * const containerRef = useRef<HTMLDivElement>(null);
13
13
  *
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * There are no barrel files for this repository.
3
3
  *
4
- * Components should be imported directly like "import { Txt } from @bspk/ui/Txt".
4
+ * Components should be imported directly like "import { Txt } from
5
+ *
6
+ * @bspk/ui/Txt".
5
7
  */
6
8
  import { ComponentProps, JSXElementConstructor, ReactNode } from 'react';
7
9
  export type AlertVariant = 'error' | 'informational' | 'success' | 'warning';
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * There are no barrel files for this repository.
3
3
  *
4
- * Components should be imported directly like "import { Txt } from @bspk/ui/Txt".
4
+ * Components should be imported directly like "import { Txt } from
5
+ *
6
+ * @bspk/ui/Txt".
5
7
  */
6
8
  export const BRANDS = [
7
9
  { title: 'Anywhere', slug: 'anywhere' },
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+HH,MAAM,CAAC,MAAM,MAAM,GAAqC;IACpD,EAAE,KAAK,EAAE,UAAU,EAAE,IA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C;AAEX,sDAAsD"}
@@ -0,0 +1 @@
1
+ [data-bspk=select]{--select-background: var(--surface-neutral-t1-base);--select-border-color: var(--stroke-neutral-base);--select-text-color: var(--foreground-neutral-on-surface);--select-height: var(--spacing-sizing-10);--select-font: var(--body-base);--select-clear-height: var(--spacing-sizing-05);--select-padding: var(--spacing-sizing-03);--select-icon-width: var(--spacing-sizing-05);position:relative;width:100%;max-width:280px;outline:unset;min-height:var(--select-height);max-height:var(--select-height);display:flex;flex-direction:row;gap:var(--spacing-sizing-02);flex-grow:0;flex-shrink:0;text-align:left;font:var(--select-font);border:1px solid var(--select-border-color);border-radius:var(--radius-small);background:var(--select-background);padding:0 var(--select-padding)}[data-bspk=select] [data-placeholder]{display:block;max-width:100%;text-overflow:ellipsis;overflow:hidden;padding:0}[data-bspk=select] [data-placeholder] [data-inner]{min-height:auto;padding:0}[data-bspk=select] [data-placeholder] [data-item-label] [data-text]{color:var(--select-text-color)}[data-bspk=select] [data-icon]{display:flex;flex-direction:column;justify-content:center}[data-bspk=select] [data-icon] svg{transform:rotate(90deg);width:var(--select-icon-width)}[data-bspk=select] [data-bspk=list-item][data-selected]{background:var(--surface-brand-primary-highlight)}[data-bspk=select][data-size=small]{--select-height: var(--spacing-sizing-08);--select-font: var(--body-small);--select-clear-height: var(--spacing-sizing-05);--select-padding: var(--spacing-sizing-02);--select-icon-width: var(--spacing-sizing-05)}[data-bspk=select][data-size=large]{--select-height: var(--spacing-sizing-12);--select-font: var(--body-large);--select-clear-height: var(--spacing-sizing-06);--select-icon-width: var(--spacing-sizing-06)}[data-bspk=select]:disabled{--select-text-color: var(--foreground-neutral-disabled-on-surface);--select-border-color: var(--stroke-neutral-disabled-light);--select-background: linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)), linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=select]:disabled[aria-readonly]:not([data-empty]){--select-text-color: var(--foreground-neutral-on-surface)}[data-bspk=select]:not(:disabled):focus{--select-border-color: var(--stroke-brand-primary)}[data-bspk=select]:not(:disabled):hover{--select-background: linear-gradient(var(--interactions-neutral-hover-opacity), var(--interactions-neutral-hover-opacity)), linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=select]:not(:disabled):active{--select-background: linear-gradient(var(--interactions-neutral-press-opacity), var(--interactions-neutral-press-opacity)), linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=select][data-invalid]{--select-border-color: var(--status-error)}[data-bspk=select][data-empty]{--select-text-color: var(--foreground-neutral-on-surface-variant-03)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bspk/ui",
3
- "version": "1.1.26",
3
+ "version": "1.1.28",
4
4
  "license": "CC-BY-4.0",
5
5
  "type": "module",
6
6
  "files": [
@@ -26,7 +26,8 @@
26
26
  "prepare": "husky",
27
27
  "pre:commit": "tsx .scripts/pre-commit.ts",
28
28
  "tsc": "tsc",
29
- "meta": "tsx meta.ts"
29
+ "meta": "tsx meta.ts",
30
+ "pretty": "npx prettier --write src/"
30
31
  },
31
32
  "publishConfig": {
32
33
  "access": "public"
package/src/Avatar.tsx CHANGED
@@ -54,12 +54,13 @@ export type AvatarProps = {
54
54
  */
55
55
  initials?: string;
56
56
  /**
57
- * The icon to display in the avatar. This needs to be an icon from the @bspk/icons library.
57
+ * The icon to display in the avatar. This needs to be an icon from the
58
58
  *
59
59
  * @example
60
60
  * <SvgPerson />;
61
61
  *
62
62
  * @type BspkIcon
63
+ * @bspk/icons library.
63
64
  */
64
65
  icon?: ReactNode;
65
66
  /**
package/src/Button.tsx CHANGED
@@ -103,7 +103,7 @@ function Button<As extends ElementType = 'button'>(props: ElementProps<ButtonPro
103
103
  label: labelProp,
104
104
  icon,
105
105
  // showLabel: showLabelProp = true,
106
- showLabel= true,
106
+ showLabel = true,
107
107
  toolTip: toolTipProp,
108
108
  children,
109
109
  ...containerProps
@@ -111,7 +111,7 @@ function Button<As extends ElementType = 'button'>(props: ElementProps<ButtonPro
111
111
  const label = typeof children === 'string' ? children : labelProp || '';
112
112
 
113
113
  // ignore showLabel=false if there is no icon
114
- const hideLabel = (showLabel === false) && icon;
114
+ const hideLabel = showLabel === false && icon;
115
115
  const toolTip = toolTipProp || (hideLabel ? label : undefined);
116
116
  const { logError } = useErrorLogger();
117
117
  logError(!!icon && !isValidIcon(icon), 'Button - The icon prop must be a valid icon element.');
package/src/FormField.tsx CHANGED
@@ -29,7 +29,7 @@ export type FormFieldProps = CommonProps<'required'> &
29
29
  /** The id of the control. */
30
30
  controlId: string;
31
31
  /**
32
- * The children of the form field. This should be a control such as TextInput, Dropdown, DatePicker, or
32
+ * The children of the form field. This should be a control such as TextInput, Select, DatePicker, or
33
33
  * TimePicker.
34
34
  *
35
35
  * @type (childProps: FieldControlProps) => JSX.Element
@@ -45,7 +45,7 @@ export type FormFieldProps = CommonProps<'required'> &
45
45
  /**
46
46
  * Wrapper component for form controls.
47
47
  *
48
- * Children may be one of the following: TextInput, Dropdown, DatePicker, or TimePicker.
48
+ * Children may be one of the following: TextInput, Select, DatePicker, or TimePicker.
49
49
  *
50
50
  * @example
51
51
  * import { TextInput } from '@bspk/ui/TextInput';
package/src/Popover.tsx CHANGED
@@ -1,13 +1,6 @@
1
1
  import { SvgClose } from '@bspk/icons/Close';
2
2
  import './popover.scss';
3
- import {
4
- ReactElement,
5
- cloneElement,
6
- useId,
7
- useMemo,
8
- useRef,
9
- useState,
10
- } from 'react';
3
+ import { ReactElement, cloneElement, useId, useMemo, useRef, useState } from 'react';
11
4
 
12
5
  import { Button } from './Button';
13
6
  import { Portal } from './Portal';
@@ -48,8 +41,7 @@ export type PopoverProps = CommonProps<'disabled'> & {
48
41
  };
49
42
 
50
43
  /**
51
- * Brief message that provide additional guidance and helps users perform an
52
- * action if needed.
44
+ * Brief message that provide additional guidance and helps users perform an action if needed.
53
45
  *
54
46
  * @example
55
47
  * import { useState } from 'react';
@@ -79,14 +71,7 @@ export type PopoverProps = CommonProps<'disabled'> & {
79
71
  *
80
72
  * @name Popover
81
73
  */
82
- function Popover({
83
- placement = 'top',
84
- header,
85
- content,
86
- callToAction,
87
- children,
88
- disabled = false,
89
- }: PopoverProps) {
74
+ function Popover({ placement = 'top', header, content, callToAction, children, disabled = false }: PopoverProps) {
90
75
  const id = useId();
91
76
  const [show, setShow] = useState(false);
92
77
  const arrowRef = useRef<HTMLElement | null>(null);
@@ -124,20 +109,13 @@ function Popover({
124
109
  id={id}
125
110
  ref={(node) => {
126
111
  elements.setFloating(node);
127
- elements.setTrigger(
128
- document.querySelector<HTMLElement>(
129
- `[aria-describedby="${id}"]`,
130
- ),
131
- );
112
+ elements.setTrigger(document.querySelector<HTMLElement>(`[aria-describedby="${id}"]`));
132
113
  }}
133
114
  style={floatingStyles}
134
115
  >
135
116
  <header>
136
117
  <Txt variant="heading-h6">{header}</Txt>
137
- <button
138
- aria-label="Close"
139
- onClick={() => setShow(false)}
140
- >
118
+ <button aria-label="Close" onClick={() => setShow(false)}>
141
119
  <SvgClose />
142
120
  </button>
143
121
  </header>
@@ -35,15 +35,14 @@ export type ProgressBarProps = {
35
35
  * A progress bar is a horizontal visual indicator that let’s the user know the progression of a task or operation
36
36
  * occurring in the background.
37
37
  *
38
- * @name ProgressBar
39
38
  * @example
40
- * import { ProgressBar } from '@bspk/ui/ProgressBar';
39
+ * import { ProgressBar } from '@bspk/ui/ProgressBar';
40
+ *
41
+ * export function Example() {
42
+ * return <ProgressBar label="Example label" completion={50} />;
43
+ * }
41
44
  *
42
- * export function Example() {
43
- * return (
44
- * <ProgressBar label="Example label" completion={50} />
45
- * );
46
- * }
45
+ * @name ProgressBar
47
46
  */
48
47
  function ProgressBar({ size = 'large', completion = 0, align = 'center', label }: ProgressBarProps) {
49
48
  const id = useId();
@@ -26,15 +26,14 @@ export type ProgressCircleProps = {
26
26
  /**
27
27
  * Rotating circle or pill that indicates the status or state of completion for a process that’s part of a user flow.
28
28
  *
29
- * @name ProgressCircle
30
29
  * @example
31
- * import { ProgressCircle } from '@bspk/ui/ProgressCircle';
30
+ * import { ProgressCircle } from '@bspk/ui/ProgressCircle';
31
+ *
32
+ * export function Example() {
33
+ * return <ProgressCircle label="Example label" />;
34
+ * }
32
35
  *
33
- * export function Example() {
34
- * return (
35
- * <ProgressCircle label="Example label"/>
36
- * );
37
- * }
36
+ * @name ProgressCircle
38
37
  */
39
38
  function ProgressCircle({ label, labelPosition, size = 'medium' }: ProgressCircleProps) {
40
39
  let variant: TxtVariant = 'labels-base';
@@ -65,19 +65,14 @@ export type ProgressionStepperProps = {
65
65
  /**
66
66
  * A progress stepper is a horizontal visual indicator that let’s the user know the progression of the current process.
67
67
  *
68
- * @name ProgressionStepper
69
68
  * @example
70
69
  * import { ProgressionStepper } from '@bspk/ui/ProgressionStepper';
71
70
  *
72
71
  * export function Example() {
73
- * return (
74
- * <ProgressionStepper steps={[
75
- * { name: 'Step 1' },
76
- * { name: 'Step 2' },
77
- * { name: 'Step 3' },
78
- * ]} />
79
- * );
72
+ * return <ProgressionStepper steps={[{ name: 'Step 1' }, { name: 'Step 2' }, { name: 'Step 3' }]} />;
80
73
  * }
74
+ *
75
+ * @name ProgressionStepper
81
76
  */
82
77
  function ProgressionStepper({
83
78
  steps = [],
@@ -33,8 +33,15 @@ export type RadioGroupProps = CommonProps<'name'> & {
33
33
  *
34
34
  * @example
35
35
  * [
36
- * { value: '1', label: 'Option 1' },
37
- * { value: '2', label: 'Option 2', description: 'Description here' },
36
+ * {
37
+ * value: '1',
38
+ * label: 'Option 1',
39
+ * },
40
+ * {
41
+ * value: '2',
42
+ * label: 'Option 2',
43
+ * description: 'Description here',
44
+ * },
38
45
  * { value: '3', label: 'Option 3' },
39
46
  * ];
40
47
  *
package/src/SearchBar.tsx CHANGED
@@ -6,14 +6,10 @@ import { MenuItem, MenuProps, Menu } from './Menu';
6
6
  import { Portal } from './Portal';
7
7
  import { TextInputProps, TextInput } from './TextInput';
8
8
  import { Txt } from './Txt';
9
- import { useFloatingMenu } from './hooks/useFloatingMenu';
9
+ import { useCombobox } from './hooks/useCombobox';
10
10
  import { useId } from './hooks/useId';
11
- //import { useFloatingMenu } from './hooks/useFloatingMenu';
12
11
 
13
- export type SearchBarProps<T extends MenuItem = MenuItem> = Pick<
14
- MenuProps<T>,
15
- 'itemCount' | 'noResultsMessage'
16
- > &
12
+ export type SearchBarProps<T extends MenuItem = MenuItem> = Pick<MenuProps<T>, 'itemCount' | 'noResultsMessage'> &
17
13
  Pick<TextInputProps, 'aria-label' | 'id' | 'inputRef' | 'name' | 'size'> & {
18
14
  /** The current value of the search bar. */
19
15
  value?: string;
@@ -83,8 +79,7 @@ export type SearchBarProps<T extends MenuItem = MenuItem> = Pick<
83
79
  * export function Example() {
84
80
  * const [searchText, setSearchText] = useState<string>('');
85
81
  *
86
- * const handleItemSelect = (item) =>
87
- * console.log('Selected item:', item);
82
+ * const handleItemSelect = (item) => console.log('Selected item:', item);
88
83
  *
89
84
  * return (
90
85
  * <SearchBar
@@ -129,15 +124,10 @@ function SearchBar({
129
124
  }: SearchBarProps) {
130
125
  const id = useId(idProp);
131
126
  const {
132
- triggerProps: {
133
- ref: triggerRef,
134
- onClick,
135
- onKeyDownCapture,
136
- ...triggerProps
137
- },
127
+ toggleProps: { ref: triggerRef, onClick, onKeyDownCapture, ...triggerProps },
138
128
  menuProps,
139
129
  closeMenu,
140
- } = useFloatingMenu({
130
+ } = useCombobox({
141
131
  placement: 'bottom-start',
142
132
  });
143
133
 
@@ -162,8 +152,8 @@ function SearchBar({
162
152
  size={size}
163
153
  value={value}
164
154
  {...triggerProps}
165
- onClick={(event) => {
166
- if (items?.length) onClick(event);
155
+ onClick={() => {
156
+ if (items?.length) onClick();
167
157
  }}
168
158
  onKeyDownCapture={(event) => {
169
159
  const handled = onKeyDownCapture(event);
@@ -196,9 +186,7 @@ function SearchBar({
196
186
  }
197
187
  onChange={(selectedValues, event) => {
198
188
  event?.preventDefault();
199
- const item = items?.find(
200
- (i) => i.value === selectedValues[0],
201
- );
189
+ const item = items?.find((i) => i.value === selectedValues[0]);
202
190
  onSelect?.(item);
203
191
  onChange(item?.label || '');
204
192
  closeMenu();
@@ -8,23 +8,18 @@ import { ElementProps } from './';
8
8
 
9
9
  export type SegmentedControlOption = {
10
10
  /**
11
- * The label of the option. This is the text that will be displayed on the
12
- * option.
11
+ * The label of the option. This is the text that will be displayed on the option.
13
12
  *
14
13
  * @required
15
14
  */
16
15
  label: string;
17
16
  /**
18
- * Determines if the element is
19
- * [disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled).
17
+ * Determines if the element is [disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled).
20
18
  *
21
19
  * @default false
22
20
  */
23
21
  disabled?: boolean;
24
- /**
25
- * The value of the option. If not provided, the label will be used as the
26
- * value.
27
- */
22
+ /** The value of the option. If not provided, the label will be used as the value. */
28
23
  value?: string;
29
24
  /**
30
25
  * The the icon to display before the label.
@@ -42,8 +37,7 @@ export type SegmentedControlOption = {
42
37
 
43
38
  export type SegmentedControlProps = {
44
39
  /**
45
- * The options to display. Each option has a label and an optional leading
46
- * icon.
40
+ * The options to display. Each option has a label and an optional leading icon.
47
41
  *
48
42
  * @example
49
43
  * [
@@ -78,16 +72,15 @@ export type SegmentedControlProps = {
78
72
  */
79
73
  size?: 'medium' | 'small';
80
74
  /**
81
- * The width of the options. If set to 'fill', the options will fill the
82
- * width of the container. If set to 'hug', the options will be as wide as
83
- * their content.
75
+ * The width of the options. If set to 'fill', the options will fill the width of the container. If set to 'hug',
76
+ * the options will be as wide as their content.
84
77
  *
85
78
  * @default hug
86
79
  */
87
80
  width?: 'fill' | 'hug';
88
81
  /**
89
- * Determines if the labels of the options should be displayed. If icons are
90
- * not provided for every option this is ignored and labels are shown.
82
+ * Determines if the labels of the options should be displayed. If icons are not provided for every option this is
83
+ * ignored and labels are shown.
91
84
  *
92
85
  * @default true
93
86
  */
@@ -131,42 +124,26 @@ function SegmentedControl({
131
124
  const options = Array.isArray(optionsProp) ? optionsProp : [];
132
125
  useOptionIconsInvalid(options);
133
126
 
134
- const hideLabels =
135
- showLabelsProp === false &&
136
- options.every((item) => item.icon && item.label);
127
+ const hideLabels = showLabelsProp === false && options.every((item) => item.icon && item.label);
137
128
 
138
129
  return (
139
- <div
140
- {...containerProps}
141
- data-bspk="segmented-control"
142
- data-size={size}
143
- data-width={width}
144
- >
130
+ <div {...containerProps} data-bspk="segmented-control" data-size={size} data-width={width}>
145
131
  {options.map((item, index) => {
146
132
  const isActive = item.value === value;
147
133
  return (
148
134
  <Fragment key={item.value}>
149
- <Tooltip
150
- disabled={!hideLabels}
151
- label={item.label}
152
- placement="top"
153
- >
135
+ <Tooltip disabled={!hideLabels} label={item.label} placement="top">
154
136
  <button
155
137
  aria-label={item.label}
156
138
  data-first={index === 0 || undefined}
157
- data-last={
158
- index === options.length - 1 || undefined
159
- }
139
+ data-last={index === options.length - 1 || undefined}
160
140
  data-selected={isActive || undefined}
161
141
  disabled={item.disabled || undefined}
162
- onClick={() =>
163
- onChange(item.value || item.label)
164
- }
142
+ onClick={() => onChange(item.value || item.label)}
165
143
  >
166
144
  <span data-outer>
167
145
  <span data-inner>
168
- {(isActive && item.iconActive) ||
169
- item.icon}
146
+ {(isActive && item.iconActive) || item.icon}
170
147
  {!hideLabels && item.label}
171
148
  </span>
172
149
  </span>