@bspk/ui 1.1.21 → 1.1.23

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 (224) hide show
  1. package/dist/Avatar.d.ts +18 -2
  2. package/dist/Avatar.js +18 -2
  3. package/dist/Avatar.js.map +1 -1
  4. package/dist/AvatarGroup.d.ts +14 -0
  5. package/dist/AvatarGroup.js +14 -0
  6. package/dist/AvatarGroup.js.map +1 -1
  7. package/dist/Badge.d.ts +32 -2
  8. package/dist/Badge.js +29 -4
  9. package/dist/Badge.js.map +1 -1
  10. package/dist/BannerAlert.d.ts +17 -0
  11. package/dist/BannerAlert.js +17 -0
  12. package/dist/BannerAlert.js.map +1 -1
  13. package/dist/Button.d.ts +16 -0
  14. package/dist/Button.js +16 -0
  15. package/dist/Button.js.map +1 -1
  16. package/dist/Card.d.ts +12 -0
  17. package/dist/Card.js +12 -0
  18. package/dist/Card.js.map +1 -1
  19. package/dist/Checkbox.d.ts +21 -0
  20. package/dist/Checkbox.js +21 -0
  21. package/dist/Checkbox.js.map +1 -1
  22. package/dist/CheckboxGroup.d.ts +30 -0
  23. package/dist/CheckboxGroup.js +23 -0
  24. package/dist/CheckboxGroup.js.map +1 -1
  25. package/dist/CheckboxOption.d.ts +23 -1
  26. package/dist/CheckboxOption.js +25 -2
  27. package/dist/CheckboxOption.js.map +1 -1
  28. package/dist/Chip.d.ts +11 -0
  29. package/dist/Chip.js +11 -0
  30. package/dist/Chip.js.map +1 -1
  31. package/dist/Dialog.d.ts +19 -0
  32. package/dist/Dialog.js +19 -0
  33. package/dist/Dialog.js.map +1 -1
  34. package/dist/Divider.d.ts +13 -0
  35. package/dist/Divider.js +13 -0
  36. package/dist/Divider.js.map +1 -1
  37. package/dist/Dropdown.d.ts +30 -0
  38. package/dist/Dropdown.js +30 -0
  39. package/dist/Dropdown.js.map +1 -1
  40. package/dist/DropdownField.d.ts +22 -0
  41. package/dist/DropdownField.js +22 -0
  42. package/dist/DropdownField.js.map +1 -1
  43. package/dist/EmptyState.d.ts +11 -0
  44. package/dist/EmptyState.js +11 -0
  45. package/dist/EmptyState.js.map +1 -1
  46. package/dist/Fab.d.ts +8 -0
  47. package/dist/Fab.js +8 -0
  48. package/dist/Fab.js.map +1 -1
  49. package/dist/FormField.d.ts +25 -0
  50. package/dist/FormField.js +25 -0
  51. package/dist/FormField.js.map +1 -1
  52. package/dist/Img.d.ts +7 -0
  53. package/dist/Img.js +7 -0
  54. package/dist/Img.js.map +1 -1
  55. package/dist/InlineAlert.d.ts +7 -0
  56. package/dist/InlineAlert.js +7 -0
  57. package/dist/InlineAlert.js.map +1 -1
  58. package/dist/Layout.d.ts +7 -0
  59. package/dist/Layout.js +7 -0
  60. package/dist/Layout.js.map +1 -1
  61. package/dist/Link.d.ts +25 -4
  62. package/dist/Link.js +9 -2
  63. package/dist/Link.js.map +1 -1
  64. package/dist/ListItem.d.ts +15 -0
  65. package/dist/ListItem.js +15 -0
  66. package/dist/ListItem.js.map +1 -1
  67. package/dist/Menu.d.ts +28 -0
  68. package/dist/Menu.js +29 -1
  69. package/dist/Menu.js.map +1 -1
  70. package/dist/MenuButton.d.ts +7 -0
  71. package/dist/MenuButton.js +7 -0
  72. package/dist/MenuButton.js.map +1 -1
  73. package/dist/Modal.d.ts +23 -1
  74. package/dist/Modal.js +23 -1
  75. package/dist/Modal.js.map +1 -1
  76. package/dist/NumberField.d.ts +19 -0
  77. package/dist/NumberField.js +19 -0
  78. package/dist/NumberField.js.map +1 -1
  79. package/dist/NumberInput.d.ts +16 -0
  80. package/dist/NumberInput.js +16 -0
  81. package/dist/NumberInput.js.map +1 -1
  82. package/dist/Popover.d.ts +29 -2
  83. package/dist/Popover.js +30 -3
  84. package/dist/Popover.js.map +1 -1
  85. package/dist/ProgressBar.d.ts +8 -0
  86. package/dist/ProgressBar.js +9 -1
  87. package/dist/ProgressBar.js.map +1 -1
  88. package/dist/ProgressCircle.d.ts +8 -0
  89. package/dist/ProgressCircle.js +8 -0
  90. package/dist/ProgressCircle.js.map +1 -1
  91. package/dist/ProgressionStepper.d.ts +12 -0
  92. package/dist/ProgressionStepper.js +12 -0
  93. package/dist/ProgressionStepper.js.map +1 -1
  94. package/dist/RadioGroup.d.ts +38 -6
  95. package/dist/RadioGroup.js +34 -5
  96. package/dist/RadioGroup.js.map +1 -1
  97. package/dist/RadioOption.d.ts +3 -1
  98. package/dist/RadioOption.js +5 -2
  99. package/dist/RadioOption.js.map +1 -1
  100. package/dist/SearchBar.d.ts +34 -0
  101. package/dist/SearchBar.js +34 -0
  102. package/dist/SearchBar.js.map +1 -1
  103. package/dist/SegmentedControl.d.ts +35 -8
  104. package/dist/SegmentedControl.js +24 -2
  105. package/dist/SegmentedControl.js.map +1 -1
  106. package/dist/Skeleton.d.ts +3 -1
  107. package/dist/Skeleton.js +3 -1
  108. package/dist/Skeleton.js.map +1 -1
  109. package/dist/StylesProviderAnywhere.js +1 -1
  110. package/dist/StylesProviderBetterHomesGardens.js +1 -1
  111. package/dist/StylesProviderCartus.js +1 -1
  112. package/dist/StylesProviderCentury21.js +1 -1
  113. package/dist/StylesProviderColdwellBanker.js +1 -1
  114. package/dist/StylesProviderCorcoran.js +1 -1
  115. package/dist/StylesProviderDenaliBoss.js +1 -1
  116. package/dist/StylesProviderEra.js +1 -1
  117. package/dist/StylesProviderSothebys.js +1 -1
  118. package/dist/Switch.d.ts +18 -1
  119. package/dist/Switch.js +18 -1
  120. package/dist/Switch.js.map +1 -1
  121. package/dist/SwitchOption.d.ts +4 -2
  122. package/dist/SwitchOption.js +5 -2
  123. package/dist/SwitchOption.js.map +1 -1
  124. package/dist/TabGroup.d.ts +26 -5
  125. package/dist/TabGroup.js +20 -0
  126. package/dist/TabGroup.js.map +1 -1
  127. package/dist/Tag.d.ts +13 -1
  128. package/dist/Tag.js +13 -1
  129. package/dist/Tag.js.map +1 -1
  130. package/dist/TextField.d.ts +21 -2
  131. package/dist/TextField.js +22 -2
  132. package/dist/TextField.js.map +1 -1
  133. package/dist/TextInput.d.ts +22 -3
  134. package/dist/TextInput.js +20 -2
  135. package/dist/TextInput.js.map +1 -1
  136. package/dist/Textarea.d.ts +23 -4
  137. package/dist/Textarea.js +27 -7
  138. package/dist/Textarea.js.map +1 -1
  139. package/dist/TextareaField.d.ts +21 -1
  140. package/dist/TextareaField.js +24 -2
  141. package/dist/TextareaField.js.map +1 -1
  142. package/dist/ToggleOption.d.ts +8 -5
  143. package/dist/ToggleOption.js +3 -3
  144. package/dist/ToggleOption.js.map +1 -1
  145. package/dist/Tooltip.d.ts +15 -3
  146. package/dist/Tooltip.js +21 -7
  147. package/dist/Tooltip.js.map +1 -1
  148. package/dist/Txt.d.ts +9 -1
  149. package/dist/Txt.js +9 -1
  150. package/dist/Txt.js.map +1 -1
  151. package/dist/badge.css +1 -1
  152. package/dist/base.css +1 -1
  153. package/dist/demo/examples.js +22 -1
  154. package/dist/demo/examples.js.map +1 -1
  155. package/dist/progress-bar.css +1 -1
  156. package/dist/radio-group.css +1 -0
  157. package/dist/textarea.css +1 -1
  158. package/dist/toggle-option.css +1 -1
  159. package/dist/tooltip.css +1 -1
  160. package/meta.ts +8 -6
  161. package/package.json +1 -1
  162. package/src/Avatar.tsx +18 -2
  163. package/src/AvatarGroup.tsx +14 -0
  164. package/src/Badge.tsx +61 -8
  165. package/src/BannerAlert.tsx +17 -0
  166. package/src/Button.tsx +16 -0
  167. package/src/Card.tsx +12 -0
  168. package/src/Checkbox.tsx +21 -0
  169. package/src/CheckboxGroup.tsx +30 -0
  170. package/src/CheckboxOption.tsx +29 -4
  171. package/src/Chip.tsx +11 -0
  172. package/src/Dialog.tsx +19 -0
  173. package/src/Divider.tsx +13 -0
  174. package/src/Dropdown.tsx +30 -0
  175. package/src/DropdownField.tsx +22 -0
  176. package/src/EmptyState.tsx +11 -0
  177. package/src/Fab.tsx +8 -0
  178. package/src/FormField.tsx +25 -0
  179. package/src/Img.tsx +7 -0
  180. package/src/InlineAlert.tsx +7 -0
  181. package/src/Layout.tsx +7 -0
  182. package/src/Link.tsx +49 -30
  183. package/src/ListItem.tsx +15 -0
  184. package/src/Menu.tsx +29 -0
  185. package/src/MenuButton.tsx +7 -0
  186. package/src/Modal.tsx +23 -1
  187. package/src/NumberField.tsx +19 -0
  188. package/src/NumberInput.tsx +16 -0
  189. package/src/Popover.tsx +53 -5
  190. package/src/ProgressBar.tsx +8 -0
  191. package/src/ProgressCircle.tsx +8 -0
  192. package/src/ProgressionStepper.tsx +12 -0
  193. package/src/RadioGroup.tsx +68 -25
  194. package/src/RadioOption.tsx +9 -4
  195. package/src/SearchBar.tsx +47 -3
  196. package/src/SegmentedControl.tsx +57 -14
  197. package/src/Skeleton.tsx +3 -1
  198. package/src/Switch.tsx +18 -1
  199. package/src/SwitchOption.tsx +11 -6
  200. package/src/TabGroup.tsx +30 -6
  201. package/src/Tag.tsx +13 -1
  202. package/src/TextField.tsx +37 -6
  203. package/src/TextInput.tsx +36 -5
  204. package/src/Textarea.tsx +41 -9
  205. package/src/TextareaField.tsx +33 -4
  206. package/src/ToggleOption.tsx +9 -6
  207. package/src/Tooltip.tsx +29 -9
  208. package/src/Txt.tsx +14 -2
  209. package/src/badge.scss +36 -7
  210. package/src/base.scss +14 -2
  211. package/src/demo/examples.tsx +28 -0
  212. package/src/progress-bar.scss +0 -2
  213. package/src/radio-group.scss +5 -0
  214. package/src/textarea.scss +4 -0
  215. package/src/toggle-option.scss +1 -20
  216. package/src/tooltip.scss +4 -4
  217. package/dist/SwitchGroup.d.ts +0 -42
  218. package/dist/SwitchGroup.js +0 -16
  219. package/dist/SwitchGroup.js.map +0 -1
  220. package/dist/hooks/useSwitchGroupState.d.ts +0 -37
  221. package/dist/hooks/useSwitchGroupState.js +0 -57
  222. package/dist/hooks/useSwitchGroupState.js.map +0 -1
  223. package/src/SwitchGroup.tsx +0 -72
  224. package/src/hooks/useSwitchGroupState.ts +0 -75
package/src/Tooltip.tsx CHANGED
@@ -4,13 +4,19 @@ import { ReactElement, cloneElement, useId, useMemo, useRef, useState } from 're
4
4
  import { Portal } from './Portal';
5
5
  import { Placement, useFloating } from './hooks/useFloating';
6
6
 
7
+ const DEFAULT = {
8
+ placement: 'top',
9
+ showTail: true,
10
+ disabled: false,
11
+ } as const;
12
+
7
13
  export type TooltipProps = {
8
14
  /**
9
15
  * The placement of the tooltip.
10
16
  *
11
17
  * @default top
12
18
  */
13
- placement?: Placement;
19
+ placement?: Extract<Placement, 'bottom' | 'left' | 'right' | 'top'>;
14
20
  /** The tooltip content. */
15
21
  label: string;
16
22
  /**
@@ -27,15 +33,33 @@ export type TooltipProps = {
27
33
  *
28
34
  * @default true
29
35
  */
30
- tail?: boolean;
36
+ showTail?: boolean;
31
37
  };
32
38
 
33
39
  /**
34
40
  * Brief message that provide additional guidance and helps users perform an action if needed.
35
41
  *
42
+ * @example
43
+ * import { Tooltip } from '@bspk/ui/Tooltip';
44
+ * import { Button } from '@bspk/ui/Button';
45
+ *
46
+ * export function Example() {
47
+ * return (
48
+ * <Tooltip label="I explain what this button does" placement="top">
49
+ * <Button>Click me</Button>
50
+ * </Tooltip>
51
+ * );
52
+ * }
53
+ *
36
54
  * @name Tooltip
37
55
  */
38
- function Tooltip({ placement = 'top', label, children, disabled = false, tail = true }: TooltipProps) {
56
+ function Tooltip({
57
+ placement = DEFAULT.placement,
58
+ label,
59
+ children,
60
+ disabled = DEFAULT.disabled,
61
+ showTail = DEFAULT.showTail,
62
+ }: TooltipProps) {
39
63
  const id = useId();
40
64
  const [show, setShow] = useState(false);
41
65
 
@@ -56,7 +80,7 @@ function Tooltip({ placement = 'top', label, children, disabled = false, tail =
56
80
  const { floatingStyles, middlewareData, elements } = useFloating({
57
81
  placement: placement,
58
82
  strategy: 'fixed',
59
- offsetOptions: 8,
83
+ offsetOptions: showTail ? 8 : 4,
60
84
  arrowRef,
61
85
  hide: !show,
62
86
  });
@@ -80,17 +104,13 @@ function Tooltip({ placement = 'top', label, children, disabled = false, tail =
80
104
  style={floatingStyles}
81
105
  >
82
106
  <span data-text>{label}</span>
83
- {tail !== false && (
107
+ {showTail !== false && (
84
108
  <span
85
109
  aria-hidden
86
110
  data-arrow
87
111
  ref={(node) => {
88
112
  arrowRef.current = node;
89
113
  }}
90
- style={{
91
- left: `${middlewareData?.arrow?.x}px`,
92
- top: `${middlewareData?.arrow?.y}px`,
93
- }}
94
114
  />
95
115
  )}
96
116
  </div>
package/src/Txt.tsx CHANGED
@@ -30,7 +30,15 @@ export type TxtProps<As extends ElementType = 'span'> = {
30
30
  };
31
31
 
32
32
  /**
33
- * A text component that applies the correct font styles based on the variant and size. variant
33
+ * A text component that applies the correct font styles based on the variant
34
+ * and size. variant
35
+ *
36
+ * @example
37
+ * import { Txt } from '@bspk/ui/Txt';
38
+ *
39
+ * export function Example() {
40
+ * return <Txt>Example Txt</Txt>;
41
+ * }
34
42
  *
35
43
  * @name Txt
36
44
  */
@@ -48,7 +56,11 @@ function Txt<As extends ElementType = 'span'>({
48
56
  const As: ElementType = as || 'span';
49
57
 
50
58
  return (
51
- <As {...containerProps} data-bspk="txt" style={{ ...styleProp, font: `var(--${variant})` }}>
59
+ <As
60
+ {...containerProps}
61
+ data-bspk="txt"
62
+ style={{ ...styleProp, font: `var(--${variant})` }}
63
+ >
52
64
  {content}
53
65
  </As>
54
66
  );
package/src/badge.scss CHANGED
@@ -1,5 +1,8 @@
1
1
  [data-bspk='badge'] {
2
2
  --size: var(--spacing-sizing-06);
3
+ --padding-x: var(--spacing-sizing-02);
4
+ --padding-y: 0;
5
+ --border-width: 0;
3
6
 
4
7
  display: flex;
5
8
  align-items: center;
@@ -8,22 +11,48 @@
8
11
  height: var(--size);
9
12
  width: fit-content;
10
13
  min-width: var(--size);
11
- padding: 0 var(--spacing-sizing-02);
14
+ font: var(--labels-x-small);
15
+ color: var(--foreground-brand-on-primary);
16
+ background: var(--surface-brand-primary);
17
+
18
+ // clip padding based on border width
19
+ padding: calc(var(--padding-y) - var(--border-width)) calc(var(--padding-x) - var(--border-width));
12
20
 
13
21
  &[data-size='x-small'] {
14
22
  --size: var(--spacing-sizing-05);
15
-
16
- padding: 2px var(--spacing-sizing-01);
23
+ --padding-x: 2px;
24
+ --padding-y: var(--spacing-sizing-01);
17
25
  }
18
26
 
19
- font: var(--labels-x-small);
20
- color: var(--foreground-brand-on-primary);
21
- background: var(--surface-brand-primary);
22
-
23
27
  &[data-variant='secondary'] {
24
28
  color: var(--foreground-brand-on-secondary);
25
29
  background: var(--surface-brand-secondary);
26
30
  }
31
+
32
+ &[data-surface-border] {
33
+ --border-width: 2px;
34
+
35
+ border: 2px solid var(--surface-neutral-t1-base);
36
+ }
37
+ }
38
+
39
+ [data-bspk='badge-wrapper'] {
40
+ display: inline-flex;
41
+ align-items: center;
42
+ justify-content: center;
43
+ position: relative;
44
+ width: fit-content;
45
+ height: fit-content;
46
+ flex-shrink: 0;
47
+
48
+ [data-bspk='badge'] {
49
+ position: absolute;
50
+ top: 0;
51
+ right: 0;
52
+ transform: scale(1) translate(50%, -50%);
53
+ transform-origin: 100% 0%;
54
+ z-index: 2;
55
+ }
27
56
  }
28
57
 
29
58
  /** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
package/src/base.scss CHANGED
@@ -67,26 +67,38 @@ a {
67
67
  }
68
68
 
69
69
  a[data-subtle] {
70
+ text-decoration: none;
70
71
  color: var(--foreground-neutral-on-surface);
71
72
 
72
73
  &:hover {
74
+ text-decoration: underline;
73
75
  color: var(--foreground-link-text-subtle-hovered);
74
76
  }
75
77
 
76
- &:disabled {
78
+ &:active {
79
+ text-decoration: underline;
80
+ }
81
+
82
+ &[disabled] {
77
83
  pointer-events: none;
78
84
  color: var(--foreground-link-text-subtle-disabled);
79
85
  }
80
86
  }
81
87
 
82
88
  a[data-subtle-inverse] {
89
+ text-decoration: none;
83
90
  color: var(--foreground-neutral-inverse-on-surface);
84
91
 
85
92
  &:hover {
93
+ text-decoration: underline;
86
94
  color: var(--foreground-link-text-subtle-inverse-hovered);
87
95
  }
88
96
 
89
- &:disabled {
97
+ &:active {
98
+ text-decoration: underline;
99
+ }
100
+
101
+ &[disabled] {
90
102
  pointer-events: none;
91
103
  color: var(--foreground-link-text-subtle-inversed-disabled);
92
104
  }
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @cspell/spellchecker */
1
2
  import { SvgCircle } from '@bspk/icons/Circle';
2
3
  import { SvgContentCopy } from '@bspk/icons/ContentCopy';
3
4
  import { SvgDiamond } from '@bspk/icons/Diamond';
@@ -7,6 +8,7 @@ import { SvgSquareFill } from '@bspk/icons/SquareFill';
7
8
  import { CSSProperties } from 'react';
8
9
 
9
10
  import { Avatar, AvatarProps } from '../Avatar';
11
+ import { BadgeProps } from '../Badge';
10
12
  import { BannerAlertProps } from '../BannerAlert';
11
13
  import { Button, ButtonProps } from '../Button';
12
14
  import { Checkbox } from '../Checkbox';
@@ -219,6 +221,29 @@ export const examples: (setState: DemoSetState, action: DemoAction) => Record<st
219
221
  },
220
222
  ]),
221
223
  },
224
+ Badge: {
225
+ containerStyle: { width: '100%' },
226
+ render: ({ props, Component, preset }) => {
227
+ if (preset?.label === 'With Context') {
228
+ return (
229
+ <>
230
+ <Component {...props} style={{ width: 'fit-content' }}>
231
+ <Avatar image="/profile.jpg" name="Bob Boberson" />
232
+ </Component>
233
+ </>
234
+ );
235
+ }
236
+ return <Component {...props} />;
237
+ },
238
+ presets: setPresets<BadgeProps>([
239
+ {
240
+ label: 'With Context',
241
+ state: {
242
+ surfaceBorder: true,
243
+ },
244
+ },
245
+ ]),
246
+ },
222
247
  Button: {
223
248
  presets: buttonExamplePresets,
224
249
  },
@@ -478,6 +503,9 @@ export const examples: (setState: DemoSetState, action: DemoAction) => Record<st
478
503
  );
479
504
  },
480
505
  },
506
+ ProgressBar: {
507
+ containerStyle: { width: '80%' },
508
+ },
481
509
  ProgressionStepper: {
482
510
  presets: setPresets<ProgressionStepperProps>([
483
511
  {
@@ -29,8 +29,6 @@
29
29
  }
30
30
 
31
31
  &[data-size='small'] {
32
- max-width: 248px;
33
-
34
32
  [data-bar] {
35
33
  height: var(--spacing-sizing-01);
36
34
  }
@@ -0,0 +1,5 @@
1
+ [data-bspk='radio-group'] {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: var(--spacing-sizing-01);
5
+ }
package/src/textarea.scss CHANGED
@@ -27,6 +27,7 @@
27
27
  [data-replicated-value] {
28
28
  white-space: pre-wrap;
29
29
  visibility: hidden;
30
+ overflow-y: hidden;
30
31
  }
31
32
 
32
33
  textarea,
@@ -38,11 +39,14 @@
38
39
  grid-area: 1 / 1 / 2 / 2;
39
40
  min-height: calc((var(--line-height) * var(--min-rows)) + (var(--padding) * 2));
40
41
  max-height: calc((var(--line-height) * var(--max-rows)) + (var(--padding) * 2));
42
+ max-width: 100%;
41
43
  }
42
44
 
43
45
  textarea {
44
46
  --border-color: var(--stroke-neutral-base);
45
47
 
48
+ text-wrap: break-word;
49
+
46
50
  &::placeholder {
47
51
  color: var(--foreground-neutral-on-surface-variant-03);
48
52
  }
@@ -16,6 +16,7 @@
16
16
  align-items: unset;
17
17
  }
18
18
 
19
+ // this media query targets touch devices
19
20
  @media (any-pointer: coarse) {
20
21
  min-height: var(--spacing-sizing-12);
21
22
  }
@@ -36,26 +37,6 @@
36
37
  color: var(--foreground-neutral-on-surface-variant-01);
37
38
  }
38
39
 
39
- &[data-size='small'] {
40
- [data-label] {
41
- font: var(--labels-small);
42
- }
43
-
44
- [data-description] {
45
- font: var(--body-x-small);
46
- }
47
- }
48
-
49
- &[data-size='large'] {
50
- [data-label] {
51
- font: var(--labels-large);
52
- }
53
-
54
- [data-description] {
55
- font: var(--body-base);
56
- }
57
- }
58
-
59
40
  &:not(:has(:disabled)) {
60
41
  [data-pseudo='focus'] &,
61
42
  &:focus-visible,
package/src/tooltip.scss CHANGED
@@ -32,27 +32,27 @@
32
32
  border-color: transparent;
33
33
  }
34
34
 
35
- &[data-placement^='bottom'] {
35
+ &[data-placement='bottom'] {
36
36
  [data-arrow] {
37
37
  top: var(--arrow-offset);
38
38
  border-bottom-color: var(--surface-neutral-inverse);
39
39
  }
40
40
  }
41
41
 
42
- &[data-placement^='top'] {
42
+ &[data-placement='top'] {
43
43
  [data-arrow] {
44
44
  border-top-color: var(--surface-neutral-inverse);
45
45
  }
46
46
  }
47
47
 
48
- &[data-placement^='right'] {
48
+ &[data-placement='right'] {
49
49
  [data-arrow] {
50
50
  margin-left: var(--arrow-offset);
51
51
  border-right-color: var(--surface-neutral-inverse);
52
52
  }
53
53
  }
54
54
 
55
- &[data-placement^='left'] {
55
+ &[data-placement='left'] {
56
56
  [data-arrow] {
57
57
  right: var(--arrow-offset);
58
58
  border-left-color: var(--surface-neutral-inverse);
@@ -1,42 +0,0 @@
1
- import { ToggleOptionProps } from './ToggleOption';
2
- import { ElementProps, CommonProps } from './';
3
- export type SwitchGroupOption = Pick<ToggleOptionProps, 'description' | 'label'> & Required<CommonProps<'value'>>;
4
- export type SwitchGroupProps = CommonProps<'aria-label' | 'name'> & {
5
- /**
6
- * The function to call when the switches are changed.
7
- *
8
- * @required
9
- */
10
- onChange: (value: string[]) => void;
11
- /**
12
- * The options for the switches.
13
- *
14
- * @example
15
- * [
16
- * { value: '1', label: 'Option 1' },
17
- * { value: '2', label: 'Option 2' },
18
- * { value: '3', label: 'Option 3' },
19
- * ];
20
- *
21
- * @type Array<SwitchGroupOption>
22
- * @required
23
- */
24
- options: SwitchGroupOption[];
25
- /**
26
- * The values of the switches in the on state.
27
- *
28
- * @type Array<string>
29
- */
30
- value?: SwitchGroupProps['options'][number]['value'][];
31
- };
32
- /**
33
- * A group of switches that allows users to choose one or more items from a list or turn an feature on or off.
34
- *
35
- * @name SwitchGroup
36
- */
37
- declare function SwitchGroup({ onChange, options, name, value: values, ...props }: ElementProps<SwitchGroupProps, 'div'>): import("react/jsx-runtime").JSX.Element;
38
- declare namespace SwitchGroup {
39
- var bspkName: string;
40
- }
41
- export { SwitchGroup };
42
- /** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
@@ -1,16 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Switch } from './Switch';
3
- import { ToggleOption } from './ToggleOption';
4
- /**
5
- * A group of switches that allows users to choose one or more items from a list or turn an feature on or off.
6
- *
7
- * @name SwitchGroup
8
- */
9
- function SwitchGroup({ onChange, options = [], name, value: values = [], ...props }) {
10
- return (_jsx("div", { ...props, "data-bspk": "switch-group", role: "group", children: options.map(({ label, description, value }) => (_jsx(ToggleOption, { description: description, label: label, children: _jsx(Switch, { "aria-label": label, checked: values.includes(value), name: name, onChange: (checked) => {
11
- onChange(checked ? [...values, value] : values.filter((v) => v !== value));
12
- }, value: value }) }, value))) }));
13
- }
14
- SwitchGroup.bspkName = 'SwitchGroup';
15
- export { SwitchGroup };
16
- //# sourceMappingURL=SwitchGroup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SwitchGroup.js","sourceRoot":"","sources":["../src/SwitchGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAqB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAmCjE;;;;GAIG;AACH,SAAS,WAAW,CAAC,EACjB,QAAQ,EACR,OAAO,GAAG,EAAE,EACZ,IAAI,EACJ,KAAK,EAAE,MAAM,GAAG,EAAE,EAClB,GAAG,KAAK,EAC4B;IACpC,OAAO,CACH,iBAAS,KAAK,eAAY,cAAc,EAAC,IAAI,EAAC,OAAO,YAChD,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAC5C,KAAC,YAAY,IAAC,WAAW,EAAE,WAAW,EAAc,KAAK,EAAE,KAAK,YAC5D,KAAC,MAAM,kBACS,KAAK,EACjB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAC/B,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE;oBAClB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;gBAC/E,CAAC,EACD,KAAK,EAAE,KAAK,GACd,IATuC,KAAK,CAUnC,CAClB,CAAC,GACA,CACT,CAAC;AACN,CAAC;AAED,WAAW,CAAC,QAAQ,GAAG,aAAa,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,37 +0,0 @@
1
- import { SwitchProps } from '../Switch';
2
- /**
3
- * A hook to manage the state of a group of switches. Used alongside the SwitchGroup component.
4
- *
5
- * @example
6
- * import { Switch } from '@bspk/ui/Switch';
7
- * import { useSwitchGroupState } from '@bspk/ui/hooks/useSwitchGroupState';
8
- *
9
- * export function Example() {
10
- * const allValues = ['Red', 'Orange', 'Yellow', 'Green'];
11
- *
12
- * const { allSwitchProps, switchProps, values } = useSwitchGroupState(allValues, 'fruits');
13
- *
14
- * return (
15
- * <>
16
- * <pre>Selected Values: {values.join(', ')}</pre>
17
- * <Switch aria-label="All" {...allSwitchProps} />
18
- * {allValues.map((value) => (
19
- * <Switch key={value} aria-label={value} {...switchProps(value)} />
20
- * ))}
21
- * </>
22
- * );
23
- * }
24
- *
25
- * @param allValues - The values of the switches.
26
- * @param name - The name of the switches.
27
- * @param externalState - The externally managed state of the switches.
28
- * @returns Properties to pass to the switch, other helper functions, and the state of the switch.
29
- */
30
- export declare function useSwitchGroupState(allValues: string[], name: string, externalState?: [values: string[], setValues: (next: string[]) => void]): {
31
- toggleValue: (itemValue: string, checked: boolean) => void;
32
- allSwitchProps: Pick<SwitchProps, "name" | "value" | "onChange" | "checked">;
33
- switchProps: (value: string) => Pick<SwitchProps, "checked" | "name" | "onChange" | "value">;
34
- values: string[];
35
- setValues: import("react").Dispatch<import("react").SetStateAction<string[]>>;
36
- };
37
- /** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
@@ -1,57 +0,0 @@
1
- import { useCallback, useMemo, useState } from 'react';
2
- /**
3
- * A hook to manage the state of a group of switches. Used alongside the SwitchGroup component.
4
- *
5
- * @example
6
- * import { Switch } from '@bspk/ui/Switch';
7
- * import { useSwitchGroupState } from '@bspk/ui/hooks/useSwitchGroupState';
8
- *
9
- * export function Example() {
10
- * const allValues = ['Red', 'Orange', 'Yellow', 'Green'];
11
- *
12
- * const { allSwitchProps, switchProps, values } = useSwitchGroupState(allValues, 'fruits');
13
- *
14
- * return (
15
- * <>
16
- * <pre>Selected Values: {values.join(', ')}</pre>
17
- * <Switch aria-label="All" {...allSwitchProps} />
18
- * {allValues.map((value) => (
19
- * <Switch key={value} aria-label={value} {...switchProps(value)} />
20
- * ))}
21
- * </>
22
- * );
23
- * }
24
- *
25
- * @param allValues - The values of the switches.
26
- * @param name - The name of the switches.
27
- * @param externalState - The externally managed state of the switches.
28
- * @returns Properties to pass to the switch, other helper functions, and the state of the switch.
29
- */
30
- export function useSwitchGroupState(allValues, name, externalState) {
31
- const localState = useState([]);
32
- const [values, setValues] = externalState || localState;
33
- const toggleValue = useCallback((itemValue, checked) => {
34
- setValues(allValues.flatMap((value) => {
35
- if (value === itemValue)
36
- return checked ? value : [];
37
- return values.includes(value) ? value : [];
38
- }));
39
- }, [allValues, setValues, values]);
40
- const switchProps = useCallback((value) => ({
41
- checked: values.includes(value),
42
- name,
43
- onChange: (checked) => toggleValue(value, checked),
44
- value,
45
- }), [values, name, toggleValue]);
46
- const allSwitchProps = useMemo(() => {
47
- return {
48
- checked: allValues.length === values.length,
49
- name,
50
- onChange: () => setValues(allValues.length === values.length ? [] : allValues),
51
- value: 'all',
52
- };
53
- }, [allValues, values.length, name, setValues]);
54
- return { toggleValue, allSwitchProps, switchProps, values, setValues };
55
- }
56
- /** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
57
- //# sourceMappingURL=useSwitchGroupState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSwitchGroupState.js","sourceRoot":"","sources":["../../src/hooks/useSwitchGroupState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,mBAAmB,CAC/B,SAAmB,EACnB,IAAY,EACZ,aAAuE;IAEvE,MAAM,UAAU,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAC;IAC1C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,aAAa,IAAI,UAAU,CAAC;IAExD,MAAM,WAAW,GAAG,WAAW,CAC3B,CAAC,SAAiB,EAAE,OAAgB,EAAE,EAAE;QACpC,SAAS,CACL,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACxB,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACrD,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,CAAC,CAAC,CACL,CAAC;IACN,CAAC,EACD,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CACjC,CAAC;IAEF,MAAM,WAAW,GAAG,WAAW,CAC3B,CAAC,KAAa,EAAgE,EAAE,CAAC,CAAC;QAC9E,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC/B,IAAI;QACJ,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC;QAClD,KAAK;KACR,CAAC,EACF,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAC9B,CAAC;IAEF,MAAM,cAAc,GAAG,OAAO,CAAC,GAAiE,EAAE;QAC9F,OAAO;YACH,OAAO,EAAE,SAAS,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;YAC3C,IAAI;YACJ,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YAC9E,KAAK,EAAE,KAAK;SACf,CAAC;IACN,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;IAEhD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC3E,CAAC;AAED,sDAAsD"}
@@ -1,72 +0,0 @@
1
- import { Switch } from './Switch';
2
- import { ToggleOptionProps, ToggleOption } from './ToggleOption';
3
-
4
- import { ElementProps, CommonProps } from './';
5
-
6
- export type SwitchGroupOption = Pick<ToggleOptionProps, 'description' | 'label'> & Required<CommonProps<'value'>>;
7
-
8
- export type SwitchGroupProps = CommonProps<'aria-label' | 'name'> & {
9
- /**
10
- * The function to call when the switches are changed.
11
- *
12
- * @required
13
- */
14
- onChange: (value: string[]) => void;
15
- /**
16
- * The options for the switches.
17
- *
18
- * @example
19
- * [
20
- * { value: '1', label: 'Option 1' },
21
- * { value: '2', label: 'Option 2' },
22
- * { value: '3', label: 'Option 3' },
23
- * ];
24
- *
25
- * @type Array<SwitchGroupOption>
26
- * @required
27
- */
28
- options: SwitchGroupOption[];
29
- /**
30
- * The values of the switches in the on state.
31
- *
32
- * @type Array<string>
33
- */
34
- value?: SwitchGroupProps['options'][number]['value'][];
35
- };
36
-
37
- /**
38
- * A group of switches that allows users to choose one or more items from a list or turn an feature on or off.
39
- *
40
- * @name SwitchGroup
41
- */
42
- function SwitchGroup({
43
- onChange,
44
- options = [],
45
- name,
46
- value: values = [],
47
- ...props
48
- }: ElementProps<SwitchGroupProps, 'div'>) {
49
- return (
50
- <div {...props} data-bspk="switch-group" role="group">
51
- {options.map(({ label, description, value }) => (
52
- <ToggleOption description={description} key={value} label={label}>
53
- <Switch
54
- aria-label={label}
55
- checked={values.includes(value)}
56
- name={name}
57
- onChange={(checked) => {
58
- onChange(checked ? [...values, value] : values.filter((v) => v !== value));
59
- }}
60
- value={value}
61
- />
62
- </ToggleOption>
63
- ))}
64
- </div>
65
- );
66
- }
67
-
68
- SwitchGroup.bspkName = 'SwitchGroup';
69
-
70
- export { SwitchGroup };
71
-
72
- /** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */