@bspk/ui 1.1.16 → 1.1.18

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 (136) hide show
  1. package/dist/Avatar.d.ts +44 -10
  2. package/dist/Avatar.js +32 -13
  3. package/dist/Avatar.js.map +1 -1
  4. package/dist/AvatarGroup.d.ts +49 -0
  5. package/dist/AvatarGroup.js +18 -0
  6. package/dist/AvatarGroup.js.map +1 -0
  7. package/dist/Badge.js +1 -1
  8. package/dist/Button.d.ts +14 -4
  9. package/dist/Button.js +1 -1
  10. package/dist/Button.js.map +1 -1
  11. package/dist/Checkbox.d.ts +15 -2
  12. package/dist/Checkbox.js.map +1 -1
  13. package/dist/CheckboxGroup.d.ts +6 -3
  14. package/dist/CheckboxGroup.js.map +1 -1
  15. package/dist/CheckboxOption.d.ts +8 -1
  16. package/dist/CheckboxOption.js.map +1 -1
  17. package/dist/Chip.d.ts +3 -1
  18. package/dist/Chip.js.map +1 -1
  19. package/dist/Dialog.d.ts +3 -3
  20. package/dist/Dialog.js.map +1 -1
  21. package/dist/Divider.js +1 -1
  22. package/dist/Dropdown.d.ts +26 -6
  23. package/dist/Dropdown.js +2 -2
  24. package/dist/Dropdown.js.map +1 -1
  25. package/dist/ListItem.js +1 -1
  26. package/dist/Menu.d.ts +27 -15
  27. package/dist/Menu.js +1 -1
  28. package/dist/Menu.js.map +1 -1
  29. package/dist/NumberInput.d.ts +5 -1
  30. package/dist/NumberInput.js +7 -5
  31. package/dist/NumberInput.js.map +1 -1
  32. package/dist/Portal.d.ts +5 -1
  33. package/dist/Portal.js.map +1 -1
  34. package/dist/ProgressBar.d.ts +4 -0
  35. package/dist/ProgressBar.js.map +1 -1
  36. package/dist/ProgressionStepper.d.ts +9 -2
  37. package/dist/ProgressionStepper.js +1 -1
  38. package/dist/ProgressionStepper.js.map +1 -1
  39. package/dist/ProgressionStepperBar.d.ts +6 -0
  40. package/dist/ProgressionStepperBar.js.map +1 -1
  41. package/dist/Radio.d.ts +16 -2
  42. package/dist/Radio.js +2 -2
  43. package/dist/Radio.js.map +1 -1
  44. package/dist/RadioGroup.d.ts +26 -3
  45. package/dist/RadioGroup.js +3 -3
  46. package/dist/RadioGroup.js.map +1 -1
  47. package/dist/RadioOption.d.ts +9 -1
  48. package/dist/RadioOption.js.map +1 -1
  49. package/dist/SegmentedControl.d.ts +21 -2
  50. package/dist/SegmentedControl.js +1 -1
  51. package/dist/SegmentedControl.js.map +1 -1
  52. package/dist/Switch.d.ts +1 -1
  53. package/dist/SwitchGroup.d.ts +13 -6
  54. package/dist/SwitchGroup.js +1 -1
  55. package/dist/SwitchGroup.js.map +1 -1
  56. package/dist/TabGroup.d.ts +23 -5
  57. package/dist/TabGroup.js +1 -1
  58. package/dist/TabGroup.js.map +1 -1
  59. package/dist/Tag.d.ts +5 -2
  60. package/dist/Tag.js +1 -1
  61. package/dist/Tag.js.map +1 -1
  62. package/dist/TextInput.d.ts +15 -6
  63. package/dist/TextInput.js +11 -5
  64. package/dist/TextInput.js.map +1 -1
  65. package/dist/Textarea.d.ts +3 -3
  66. package/dist/avatar-group.css +1 -0
  67. package/dist/avatar.css +1 -1
  68. package/dist/badge.css +1 -1
  69. package/dist/button.css +1 -1
  70. package/dist/demo/ExampleModalRender.d.ts +7 -0
  71. package/dist/demo/ExampleModalRender.js +16 -0
  72. package/dist/demo/ExampleModalRender.js.map +1 -0
  73. package/dist/demo/ExamplePlaceholder.d.ts +7 -0
  74. package/dist/demo/ExamplePlaceholder.js +13 -0
  75. package/dist/demo/ExamplePlaceholder.js.map +1 -0
  76. package/dist/demo/examples.d.ts +101 -0
  77. package/dist/demo/examples.js +472 -0
  78. package/dist/demo/examples.js.map +1 -0
  79. package/dist/divider.css +1 -1
  80. package/dist/hooks/useOptionIconsInvalid.d.ts +10 -1
  81. package/dist/hooks/useOptionIconsInvalid.js.map +1 -1
  82. package/dist/index.d.ts +4 -26
  83. package/dist/index.js.map +1 -1
  84. package/dist/list-item.css +1 -1
  85. package/dist/menu.css +1 -1
  86. package/dist/segmented-control.css +1 -1
  87. package/dist/tab-group.css +1 -1
  88. package/dist/tag.css +1 -1
  89. package/dist/text-input.css +1 -1
  90. package/dist/utils/children.js.map +1 -1
  91. package/meta-types.ts +2 -0
  92. package/meta.ts +76 -42
  93. package/package.json +1 -1
  94. package/src/Avatar.tsx +80 -27
  95. package/src/AvatarGroup.tsx +71 -0
  96. package/src/Button.tsx +14 -4
  97. package/src/Checkbox.tsx +25 -11
  98. package/src/CheckboxGroup.tsx +6 -3
  99. package/src/CheckboxOption.tsx +9 -2
  100. package/src/Chip.tsx +3 -1
  101. package/src/Dialog.tsx +3 -3
  102. package/src/Dropdown.tsx +30 -10
  103. package/src/Menu.tsx +30 -18
  104. package/src/NumberInput.tsx +15 -6
  105. package/src/Portal.tsx +5 -1
  106. package/src/ProgressBar.tsx +4 -0
  107. package/src/ProgressionStepper.tsx +9 -2
  108. package/src/ProgressionStepperBar.tsx +6 -0
  109. package/src/Radio.tsx +21 -4
  110. package/src/RadioGroup.tsx +34 -6
  111. package/src/RadioOption.tsx +11 -2
  112. package/src/SegmentedControl.tsx +21 -2
  113. package/src/Switch.tsx +1 -1
  114. package/src/SwitchGroup.tsx +19 -7
  115. package/src/TabGroup.tsx +23 -5
  116. package/src/Tag.tsx +5 -2
  117. package/src/TextInput.tsx +25 -15
  118. package/src/Textarea.tsx +3 -3
  119. package/src/avatar-group.scss +17 -0
  120. package/src/avatar.scss +5 -2
  121. package/src/badge.scss +1 -0
  122. package/src/button.scss +1 -0
  123. package/src/demo/ExampleModalRender.tsx +37 -0
  124. package/src/demo/ExamplePlaceholder.tsx +40 -0
  125. package/src/demo/examples.tsx +683 -0
  126. package/src/divider.scss +2 -0
  127. package/src/dropdown.scss +1 -0
  128. package/src/hooks/useOptionIconsInvalid.ts +10 -1
  129. package/src/index.ts +5 -32
  130. package/src/list-item.scss +5 -1
  131. package/src/menu.scss +1 -1
  132. package/src/segmented-control.scss +1 -0
  133. package/src/tab-group.scss +1 -0
  134. package/src/tag.scss +1 -0
  135. package/src/text-input.scss +13 -18
  136. package/src/utils/children.ts +1 -1
@@ -41,8 +41,17 @@ export type NavOption = {
41
41
  disabled?: boolean;
42
42
  /** The value of the option. If not provided, the label will be used as the value. */
43
43
  value?: string;
44
- /** The the icon to display before the label. */
44
+ /**
45
+ * The the icon to display before the label.
46
+ *
47
+ * @type BspkIcon
48
+ */
45
49
  icon?: React.ReactNode;
50
+ /**
51
+ * The icon to display before the label when the option is active.
52
+ *
53
+ * @type BspkIcon
54
+ */
46
55
  iconActive?: React.ReactNode;
47
56
  };
48
57
 
package/src/index.ts CHANGED
@@ -4,10 +4,12 @@
4
4
  * Components should be imported directly like "import { Txt } from @bspk/ui/Txt".
5
5
  */
6
6
 
7
- import { ChangeEvent, MouseEvent as ReactMouseEvent, ComponentProps, JSXElementConstructor, ReactNode } from 'react';
7
+ import { ComponentProps, JSXElementConstructor, ReactNode } from 'react';
8
8
 
9
9
  export type AlertVariant = 'error' | 'informational' | 'success' | 'warning';
10
10
 
11
+ export type SetRef<T> = (instance: T | null) => void;
12
+
11
13
  export type ElementProps<
12
14
  P extends Record<string, unknown>,
13
15
  E extends JSXElementConstructor<unknown> | keyof JSX.IntrinsicElements,
@@ -26,7 +28,6 @@ export type CallToActionButton = {
26
28
  /**
27
29
  * The callback function for the call to action button.
28
30
  *
29
- * @type () => void
30
31
  * @required
31
32
  */
32
33
  onClick: () => void;
@@ -34,28 +35,7 @@ export type CallToActionButton = {
34
35
  size?: ButtonSize;
35
36
  };
36
37
 
37
- export type ToggleControlProps<T extends HTMLElement> = CommonProps<'aria-label' | 'disabled' | 'name', T> &
38
- InvalidPropsLibrary &
39
- Required<CommonProps<'value'>> & {
40
- /**
41
- * Marks the control as checked.
42
- *
43
- * @default false
44
- */
45
- checked?: boolean;
46
- /**
47
- * The function to call when the control is checked or unchecked.
48
- *
49
- * @type (checked, Event) => void
50
- * @required
51
- */
52
- onChange: (checked: boolean, event: ChangeEvent<T>) => void;
53
- };
54
-
55
- export type CommonProps<K extends keyof CommonPropsLibrary, T extends HTMLElement = HTMLElement> = Pick<
56
- CommonPropsLibrary<T>,
57
- K
58
- >;
38
+ export type CommonProps<K extends keyof CommonPropsLibrary> = Pick<CommonPropsLibrary, K>;
59
39
 
60
40
  /**
61
41
  * The props that are common to input elements.
@@ -79,7 +59,7 @@ export type InvalidPropsLibrary = {
79
59
  errorMessage?: string;
80
60
  };
81
61
 
82
- export type CommonPropsLibrary<T extends HTMLElement = HTMLElement> = {
62
+ export type CommonPropsLibrary = {
83
63
  /** The id of the element. If not provided one will be generated. */
84
64
  id?: string;
85
65
  /**
@@ -136,13 +116,6 @@ export type CommonPropsLibrary<T extends HTMLElement = HTMLElement> = {
136
116
  * @required
137
117
  */
138
118
  'aria-label': string;
139
- /**
140
- * The function to call when the element is clicked.
141
- *
142
- * @param event - The mouse event.
143
- * @returns Void
144
- */
145
- onClick?: (event: ReactMouseEvent<T, MouseEvent>) => void;
146
119
  };
147
120
 
148
121
  export type Brand =
@@ -44,7 +44,7 @@
44
44
  }
45
45
  }
46
46
 
47
- /* &:has(+ [data-list-item]) {
47
+ /* &:has(+ [data-bspk="list-item"]) {
48
48
  [data-inner] {
49
49
  border-bottom: 1px solid var(--stroke-neutral-low);
50
50
  }
@@ -74,6 +74,10 @@
74
74
  }
75
75
  }
76
76
 
77
+ [data-trailing]:has(input) {
78
+ pointer-events: none;
79
+ }
80
+
77
81
  [data-component='Img'] > img {
78
82
  height: 36px;
79
83
  width: 36px;
package/src/menu.scss CHANGED
@@ -27,7 +27,7 @@
27
27
  gap: var(--spacing-sizing-03);
28
28
  }
29
29
 
30
- [data-list-item] {
30
+ [data-bspk='list-item'] {
31
31
  min-height: var(--item-size);
32
32
  height: var(--item-size);
33
33
  }
@@ -42,6 +42,7 @@
42
42
  height: var(--spacing-sizing-12);
43
43
  background: transparent;
44
44
  position: relative;
45
+ white-space: nowrap;
45
46
 
46
47
  [data-focus-ring] {
47
48
  display: none;
@@ -34,6 +34,7 @@
34
34
  background: none;
35
35
  flex-grow: var(--btn-flex-grow);
36
36
  font: var(--font);
37
+ white-space: nowrap;
37
38
 
38
39
  &:hover {
39
40
  background: var(--interactions-neutral-hover-opacity);
package/src/tag.scss CHANGED
@@ -11,6 +11,7 @@
11
11
  font: unset;
12
12
  text-decoration: unset;
13
13
  white-space: nowrap;
14
+ pointer-events: none;
14
15
 
15
16
  &[data-wrap] {
16
17
  height: auto;
@@ -7,7 +7,7 @@
7
7
  border: solid 1px var(--border-color);
8
8
  height: var(--field-height);
9
9
  border-radius: var(--radius-small);
10
- padding: 0 var(--field-padding);
10
+ padding: 0 0 0 var(--field-padding);
11
11
  gap: var(--spacing-sizing-01);
12
12
  width: 100%;
13
13
 
@@ -22,17 +22,13 @@
22
22
  }
23
23
 
24
24
  &:hover:not(:focus-within) {
25
- background:
26
- // multiple colors
27
-
25
+ background:
28
26
  linear-gradient(var(--interactions-hover-opacity), var(--interactions-hover-opacity)),
29
27
  linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
30
28
  }
31
29
 
32
30
  &:active:not(:focus-within) {
33
- background:
34
- // multiple colors
35
-
31
+ background:
36
32
  linear-gradient(var(--interactions-press-opacity), var(--interactions-press-opacity)),
37
33
  linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
38
34
  }
@@ -40,9 +36,7 @@
40
36
  &[data-readonly] {
41
37
  --border-color: var(--stroke-neutral-disabled-light);
42
38
 
43
- background:
44
- // multiple colors
45
-
39
+ background:
46
40
  linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),
47
41
  linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
48
42
  }
@@ -51,8 +45,6 @@
51
45
  --border-color: var(--stroke-neutral-disabled-light);
52
46
 
53
47
  background:
54
- // multiple colors
55
-
56
48
  linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),
57
49
  linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base));
58
50
 
@@ -117,7 +109,7 @@
117
109
  }
118
110
 
119
111
  button[data-clear] {
120
- display: none;
112
+ display: flex;
121
113
  border: none;
122
114
  background: none;
123
115
  padding: 0;
@@ -132,16 +124,19 @@
132
124
  }
133
125
  }
134
126
 
135
- &:focus-within {
136
- --border-color: var(--stroke-brand-primary);
127
+ &:not(:focus-within),
128
+ &[data-empty],
129
+ &[data-readonly],
130
+ &[data-disabled] {
131
+ padding-right: var(--field-padding);
137
132
 
138
133
  button[data-clear] {
139
- display: flex;
134
+ display: none;
140
135
  }
141
136
  }
142
137
 
143
- &:has(button[data-clear]) {
144
- padding-right: 0;
138
+ &:focus-within {
139
+ --border-color: var(--stroke-brand-primary);
145
140
  }
146
141
  }
147
142
 
@@ -1,4 +1,4 @@
1
- import { ReactNode , Children, Fragment, isValidElement } from 'react';
1
+ import { ReactNode, Children, Fragment, isValidElement } from 'react';
2
2
 
3
3
  export function isValidIcon(child: unknown) {
4
4
  return isChildNamed(child, 'Icon');