@bspk/ui 1.1.17 → 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 +17 -6
  2. package/dist/Avatar.js +15 -6
  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 +35 -8
  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
package/src/TextInput.tsx CHANGED
@@ -1,10 +1,18 @@
1
1
  import { SvgCancel } from '@bspk/icons/Cancel';
2
- import './text-input.scss';
3
2
  import { ChangeEvent, HTMLInputAutoCompleteAttribute, HTMLInputTypeAttribute, ReactNode } from 'react';
4
3
 
5
4
  import { useId } from './hooks/useId';
6
5
 
7
- import { ElementProps, CommonProps, InvalidPropsLibrary } from '.';
6
+ import { ElementProps, CommonProps, InvalidPropsLibrary, SetRef } from '.';
7
+
8
+ import './text-input.scss';
9
+
10
+ export const DEFAULT = {
11
+ size: 'medium',
12
+ value: '',
13
+ type: 'text' as Extract<HTMLInputTypeAttribute, 'number' | 'text'>,
14
+ autoComplete: 'off',
15
+ } as const;
8
16
 
9
17
  export type TextInputProps = CommonProps<
10
18
  'aria-label' | 'disabled' | 'id' | 'name' | 'readOnly' | 'required' | 'size' | 'value'
@@ -13,21 +21,24 @@ export type TextInputProps = CommonProps<
13
21
  /**
14
22
  * Callback when the value of the field changes.
15
23
  *
16
- * @type (next: String, Event) => void
17
24
  * @required
18
25
  */
19
26
  onChange: (next: string, event?: ChangeEvent<HTMLInputElement>) => void;
20
27
  /** The ref of the container. */
21
- containerRef?: (node: HTMLElement | null) => void;
28
+ containerRef?: SetRef<HTMLDivElement>;
22
29
  /** The ref of the input. */
23
- inputRef?: (node: HTMLElement | null) => void;
30
+ inputRef?: SetRef<HTMLInputElement>;
24
31
  /** The trailing element to display in the field. */
25
32
  trailing?: ReactNode;
26
33
  /** The leading element to display in the field. */
27
34
  leading?: ReactNode;
28
35
  /** The placeholder of the field. */
29
36
  placeholder?: string;
30
- /** The type of the input. */
37
+ /**
38
+ * The type of the input.
39
+ *
40
+ * @default text
41
+ */
31
42
  type?: Extract<HTMLInputTypeAttribute, 'number' | 'text'>;
32
43
  /**
33
44
  * Specifies if user agent has any permission to provide automated assistance in filling out form field values.
@@ -49,8 +60,8 @@ export type TextInputProps = CommonProps<
49
60
  function TextInput({
50
61
  invalid: invalidProp,
51
62
  onChange,
52
- size = 'medium',
53
- value = '',
63
+ size = DEFAULT.size,
64
+ value = DEFAULT.value,
54
65
  name,
55
66
  'aria-label': ariaLabel,
56
67
  inputRef,
@@ -59,10 +70,10 @@ function TextInput({
59
70
  id: idProp,
60
71
  leading,
61
72
  trailing,
62
- type,
73
+ type = DEFAULT.type,
63
74
  readOnly,
64
75
  disabled,
65
- autoComplete = 'off',
76
+ autoComplete = DEFAULT.autoComplete,
66
77
  containerRef,
67
78
  errorMessage,
68
79
  ...otherProps
@@ -75,6 +86,7 @@ function TextInput({
75
86
  <div
76
87
  data-bspk="text-input"
77
88
  data-disabled={disabled || undefined}
89
+ data-empty={!value.toString().length || undefined}
78
90
  data-invalid={invalid || undefined}
79
91
  data-readonly={readOnly || undefined}
80
92
  data-required={required || undefined}
@@ -102,11 +114,9 @@ function TextInput({
102
114
  value={value}
103
115
  />
104
116
  {trailing && <span data-trailing>{trailing}</span>}
105
- {value?.toString().length > 0 && !readOnly && !disabled && (
106
- <button aria-label="clear" data-clear onClick={() => onChange('')}>
107
- <SvgCancel />
108
- </button>
109
- )}
117
+ <button aria-label="clear" data-clear onClick={() => onChange('')}>
118
+ <SvgCancel />
119
+ </button>
110
120
  </div>
111
121
  );
112
122
  }
package/src/Textarea.tsx CHANGED
@@ -1,9 +1,9 @@
1
1
  import './textarea.scss';
2
- import { ChangeEvent, CSSProperties, Ref } from 'react';
2
+ import { ChangeEvent, CSSProperties } from 'react';
3
3
 
4
4
  import { useId } from './hooks/useId';
5
5
 
6
- import { CommonProps, InvalidPropsLibrary } from './';
6
+ import { CommonProps, InvalidPropsLibrary, SetRef } from './';
7
7
 
8
8
  const DEFAULT = {
9
9
  minRows: 3,
@@ -39,7 +39,7 @@ export type TextareaProps = CommonProps<'aria-label' | 'disabled' | 'id' | 'read
39
39
  */
40
40
  name: string;
41
41
  /** The ref of the field. */
42
- innerRef?: Ref<HTMLTextAreaElement>;
42
+ innerRef?: SetRef<HTMLTextAreaElement>;
43
43
  /** The placeholder of the field. */
44
44
  placeholder?: string;
45
45
  /**
@@ -0,0 +1,17 @@
1
+ [data-bspk='avatar-group'] {
2
+ width: 100%;
3
+
4
+ [data-wrap] {
5
+ width: 100%;
6
+ display: flex;
7
+ flex-direction: row;
8
+ align-items: end;
9
+ justify-content: end;
10
+ gap: var(--spacing-sizing-02);
11
+ overflow: hidden;
12
+
13
+ & > * + * {
14
+ // margin-left: calc(var(--spacing-sizing-01) * -1);
15
+ }
16
+ }
17
+ }
package/src/avatar.scss CHANGED
@@ -1,8 +1,11 @@
1
1
  [data-bspk='avatar'] {
2
2
  --height: var(--spacing-sizing-10);
3
3
  --font: var(--labels-base);
4
- --foreground: var(--foreground-neutral-on-surface);
5
- --background: var(--surface-neutral-t3-low);
4
+
5
+ &:not([data-color]) {
6
+ --foreground: var(--foreground-neutral-on-surface);
7
+ --background: var(--surface-neutral-t3-low);
8
+ }
6
9
 
7
10
  display: flex;
8
11
  flex-direction: column;
package/src/badge.scss CHANGED
@@ -6,6 +6,7 @@
6
6
  justify-content: center;
7
7
  border-radius: var(--radius-circular);
8
8
  height: var(--size);
9
+ width: fit-content;
9
10
  min-width: var(--size);
10
11
  padding: 0 var(--spacing-sizing-02);
11
12
 
package/src/button.scss CHANGED
@@ -10,6 +10,7 @@
10
10
  background: transparent;
11
11
  text-decoration: none;
12
12
  width: fit-content;
13
+ font-family: var(--typeface);
13
14
  position: relative;
14
15
 
15
16
  [data-touch-target] {
@@ -0,0 +1,37 @@
1
+ import { useId } from 'react';
2
+
3
+ import { Button } from '../Button';
4
+ import { ModalProps, Modal } from '../Modal';
5
+ import { useModalState } from '../hooks/useModalState';
6
+
7
+ import { Preset, DemoSetState } from './examples';
8
+
9
+ export function ExampleModalRender({
10
+ props,
11
+ preset,
12
+ setState,
13
+ }: {
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ props: ModalProps & Record<string, any>;
16
+ preset?: Preset<ModalProps>;
17
+ setState: DemoSetState;
18
+ }) {
19
+ let label = 'Open Modal';
20
+
21
+ const dialogId = useId();
22
+ const openKey = `${dialogId}-open`;
23
+
24
+ const { open, onClose, onOpen } = useModalState(!!props[openKey], (next) => setState({ [openKey]: next }));
25
+
26
+ const presetState: Partial<ModalProps> = preset?.state || {};
27
+ if (presetState?.placement) label += ` (${presetState?.placement})`;
28
+
29
+ return (
30
+ <>
31
+ <Button label={label} onClick={() => onOpen()} />
32
+ <Modal data-example-component id="exampleId" {...props} onClose={onClose} open={open}>
33
+ <pre>{JSON.stringify(props, null, '\t')}</pre>
34
+ </Modal>
35
+ </>
36
+ );
37
+ }
@@ -0,0 +1,40 @@
1
+ import { useRef } from 'react';
2
+
3
+ import { ElementProps } from '..';
4
+ import { Txt } from '../Txt';
5
+
6
+ const dimension = (value: number | string) => (typeof value === 'number' ? `${value}px` : `${value}`);
7
+
8
+ export function ExamplePlaceholder({
9
+ hideSize = false,
10
+ height = 100,
11
+ width = '100%',
12
+ direction = 'row',
13
+ ...props
14
+ }: ElementProps<
15
+ { hideSize?: boolean; height?: number | string; width?: number | string; direction?: 'column' | 'row' },
16
+ 'div'
17
+ >) {
18
+ const ref = useRef<HTMLDivElement | null>(null);
19
+
20
+ return (
21
+ <div
22
+ {...props}
23
+ data-example-placeholder
24
+ ref={ref}
25
+ style={{
26
+ width: dimension(width),
27
+ height: dimension(height),
28
+ flexDirection: direction,
29
+ }}
30
+ >
31
+ {!hideSize && (
32
+ <>
33
+ <Txt variant="labels-large">{dimension(width)}</Txt>
34
+ <Txt>&times;</Txt>
35
+ <Txt variant="labels-large">{dimension(height)}</Txt>
36
+ </>
37
+ )}
38
+ </div>
39
+ );
40
+ }