@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.
- package/dist/Avatar.d.ts +44 -10
- package/dist/Avatar.js +32 -13
- package/dist/Avatar.js.map +1 -1
- package/dist/AvatarGroup.d.ts +49 -0
- package/dist/AvatarGroup.js +18 -0
- package/dist/AvatarGroup.js.map +1 -0
- package/dist/Badge.js +1 -1
- package/dist/Button.d.ts +14 -4
- package/dist/Button.js +1 -1
- package/dist/Button.js.map +1 -1
- package/dist/Checkbox.d.ts +15 -2
- package/dist/Checkbox.js.map +1 -1
- package/dist/CheckboxGroup.d.ts +6 -3
- package/dist/CheckboxGroup.js.map +1 -1
- package/dist/CheckboxOption.d.ts +8 -1
- package/dist/CheckboxOption.js.map +1 -1
- package/dist/Chip.d.ts +3 -1
- package/dist/Chip.js.map +1 -1
- package/dist/Dialog.d.ts +3 -3
- package/dist/Dialog.js.map +1 -1
- package/dist/Divider.js +1 -1
- package/dist/Dropdown.d.ts +26 -6
- package/dist/Dropdown.js +2 -2
- package/dist/Dropdown.js.map +1 -1
- package/dist/ListItem.js +1 -1
- package/dist/Menu.d.ts +27 -15
- package/dist/Menu.js +1 -1
- package/dist/Menu.js.map +1 -1
- package/dist/NumberInput.d.ts +5 -1
- package/dist/NumberInput.js +7 -5
- package/dist/NumberInput.js.map +1 -1
- package/dist/Portal.d.ts +5 -1
- package/dist/Portal.js.map +1 -1
- package/dist/ProgressBar.d.ts +4 -0
- package/dist/ProgressBar.js.map +1 -1
- package/dist/ProgressionStepper.d.ts +9 -2
- package/dist/ProgressionStepper.js +1 -1
- package/dist/ProgressionStepper.js.map +1 -1
- package/dist/ProgressionStepperBar.d.ts +6 -0
- package/dist/ProgressionStepperBar.js.map +1 -1
- package/dist/Radio.d.ts +16 -2
- package/dist/Radio.js +2 -2
- package/dist/Radio.js.map +1 -1
- package/dist/RadioGroup.d.ts +26 -3
- package/dist/RadioGroup.js +3 -3
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioOption.d.ts +9 -1
- package/dist/RadioOption.js.map +1 -1
- package/dist/SegmentedControl.d.ts +21 -2
- package/dist/SegmentedControl.js +1 -1
- package/dist/SegmentedControl.js.map +1 -1
- package/dist/Switch.d.ts +1 -1
- package/dist/SwitchGroup.d.ts +13 -6
- package/dist/SwitchGroup.js +1 -1
- package/dist/SwitchGroup.js.map +1 -1
- package/dist/TabGroup.d.ts +23 -5
- package/dist/TabGroup.js +1 -1
- package/dist/TabGroup.js.map +1 -1
- package/dist/Tag.d.ts +5 -2
- package/dist/Tag.js +1 -1
- package/dist/Tag.js.map +1 -1
- package/dist/TextInput.d.ts +15 -6
- package/dist/TextInput.js +11 -5
- package/dist/TextInput.js.map +1 -1
- package/dist/Textarea.d.ts +3 -3
- package/dist/avatar-group.css +1 -0
- package/dist/avatar.css +1 -1
- package/dist/badge.css +1 -1
- package/dist/button.css +1 -1
- package/dist/demo/ExampleModalRender.d.ts +7 -0
- package/dist/demo/ExampleModalRender.js +16 -0
- package/dist/demo/ExampleModalRender.js.map +1 -0
- package/dist/demo/ExamplePlaceholder.d.ts +7 -0
- package/dist/demo/ExamplePlaceholder.js +13 -0
- package/dist/demo/ExamplePlaceholder.js.map +1 -0
- package/dist/demo/examples.d.ts +101 -0
- package/dist/demo/examples.js +472 -0
- package/dist/demo/examples.js.map +1 -0
- package/dist/divider.css +1 -1
- package/dist/hooks/useOptionIconsInvalid.d.ts +10 -1
- package/dist/hooks/useOptionIconsInvalid.js.map +1 -1
- package/dist/index.d.ts +4 -26
- package/dist/index.js.map +1 -1
- package/dist/list-item.css +1 -1
- package/dist/menu.css +1 -1
- package/dist/segmented-control.css +1 -1
- package/dist/tab-group.css +1 -1
- package/dist/tag.css +1 -1
- package/dist/text-input.css +1 -1
- package/dist/utils/children.js.map +1 -1
- package/meta-types.ts +2 -0
- package/meta.ts +76 -42
- package/package.json +1 -1
- package/src/Avatar.tsx +80 -27
- package/src/AvatarGroup.tsx +71 -0
- package/src/Button.tsx +14 -4
- package/src/Checkbox.tsx +25 -11
- package/src/CheckboxGroup.tsx +6 -3
- package/src/CheckboxOption.tsx +9 -2
- package/src/Chip.tsx +3 -1
- package/src/Dialog.tsx +3 -3
- package/src/Dropdown.tsx +30 -10
- package/src/Menu.tsx +30 -18
- package/src/NumberInput.tsx +15 -6
- package/src/Portal.tsx +5 -1
- package/src/ProgressBar.tsx +4 -0
- package/src/ProgressionStepper.tsx +9 -2
- package/src/ProgressionStepperBar.tsx +6 -0
- package/src/Radio.tsx +21 -4
- package/src/RadioGroup.tsx +34 -6
- package/src/RadioOption.tsx +11 -2
- package/src/SegmentedControl.tsx +21 -2
- package/src/Switch.tsx +1 -1
- package/src/SwitchGroup.tsx +19 -7
- package/src/TabGroup.tsx +23 -5
- package/src/Tag.tsx +5 -2
- package/src/TextInput.tsx +25 -15
- package/src/Textarea.tsx +3 -3
- package/src/avatar-group.scss +17 -0
- package/src/avatar.scss +5 -2
- package/src/badge.scss +1 -0
- package/src/button.scss +1 -0
- package/src/demo/ExampleModalRender.tsx +37 -0
- package/src/demo/ExamplePlaceholder.tsx +40 -0
- package/src/demo/examples.tsx +683 -0
- package/src/divider.scss +2 -0
- package/src/dropdown.scss +1 -0
- package/src/hooks/useOptionIconsInvalid.ts +10 -1
- package/src/index.ts +5 -32
- package/src/list-item.scss +5 -1
- package/src/menu.scss +1 -1
- package/src/segmented-control.scss +1 -0
- package/src/tab-group.scss +1 -0
- package/src/tag.scss +1 -0
- package/src/text-input.scss +13 -18
- package/src/utils/children.ts +1 -1
package/src/Tag.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import './tag.scss';
|
|
2
1
|
import { ElementType, ReactNode } from 'react';
|
|
3
2
|
|
|
4
3
|
import { ColorVariant } from './utils/colorVariants';
|
|
5
4
|
|
|
6
5
|
import { ElementProps } from './';
|
|
6
|
+
import './tag.scss';
|
|
7
7
|
|
|
8
8
|
export type TagProps<As extends ElementType = 'span'> = {
|
|
9
9
|
/**
|
|
@@ -16,6 +16,9 @@ export type TagProps<As extends ElementType = 'span'> = {
|
|
|
16
16
|
/**
|
|
17
17
|
* The content of the tag.
|
|
18
18
|
*
|
|
19
|
+
* @example
|
|
20
|
+
* New;
|
|
21
|
+
*
|
|
19
22
|
* @required
|
|
20
23
|
*/
|
|
21
24
|
children: ReactNode;
|
|
@@ -28,7 +31,7 @@ export type TagProps<As extends ElementType = 'span'> = {
|
|
|
28
31
|
/**
|
|
29
32
|
* The color of the tag.
|
|
30
33
|
*
|
|
31
|
-
* @default
|
|
34
|
+
* @default grey
|
|
32
35
|
*/
|
|
33
36
|
color?: ColorVariant;
|
|
34
37
|
/**
|
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?:
|
|
28
|
+
containerRef?: SetRef<HTMLDivElement>;
|
|
22
29
|
/** The ref of the input. */
|
|
23
|
-
inputRef?:
|
|
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
|
-
/**
|
|
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 =
|
|
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 =
|
|
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
|
-
{
|
|
106
|
-
<
|
|
107
|
-
|
|
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
|
|
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?:
|
|
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
|
-
|
|
5
|
-
|
|
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
package/src/button.scss
CHANGED
|
@@ -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>×</Txt>
|
|
35
|
+
<Txt variant="labels-large">{dimension(height)}</Txt>
|
|
36
|
+
</>
|
|
37
|
+
)}
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|