@infonomic/uikit 5.44.0 → 6.0.1
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/README.md +12 -3
- package/dist/components/accordion/accordion.d.ts +9 -9
- package/dist/components/accordion/accordion.d.ts.map +1 -1
- package/dist/components/accordion/accordion.js +4 -4
- package/dist/components/accordion/accordion.module.css +6 -5
- package/dist/components/accordion/accordion_module.css +4 -4
- package/dist/components/avatar/avatar.js +2 -2
- package/dist/components/badge/badge.d.ts +5 -13
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/badge.js +12 -9
- package/dist/components/button/button-group.d.ts +9 -7
- package/dist/components/button/button-group.d.ts.map +1 -1
- package/dist/components/button/button-group.js +26 -36
- package/dist/components/button/button.d.ts +6 -13
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +19 -18
- package/dist/components/button/button.module.css +32 -54
- package/dist/components/button/button_module.css +7 -10
- package/dist/components/button/combo-button.d.ts +1 -1
- package/dist/components/button/combo-button.d.ts.map +1 -1
- package/dist/components/button/combo-button.js +13 -9
- package/dist/components/button/combo-button.module.css +16 -7
- package/dist/components/button/combo-button_module.css +22 -4
- package/dist/components/button/icon-button.d.ts +2 -3
- package/dist/components/button/icon-button.d.ts.map +1 -1
- package/dist/components/card/card.d.ts +5 -12
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/card.js +13 -9
- package/dist/components/chips/chip.d.ts +5 -11
- package/dist/components/chips/chip.d.ts.map +1 -1
- package/dist/components/chips/chip.js +36 -28
- package/dist/components/chips/chip.module.css +22 -36
- package/dist/components/chips/chip_module.css +3 -6
- package/dist/components/dropdown/dropdown.d.ts +28 -14
- package/dist/components/dropdown/dropdown.d.ts.map +1 -1
- package/dist/components/dropdown/dropdown.js +34 -20
- package/dist/components/forms/calendar.d.ts +1 -1
- package/dist/components/forms/calendar.d.ts.map +1 -1
- package/dist/components/forms/calendar.js +38 -29
- package/dist/components/forms/checkbox.astro +13 -8
- package/dist/components/forms/checkbox.d.ts +6 -2
- package/dist/components/forms/checkbox.d.ts.map +1 -1
- package/dist/components/forms/checkbox.js +11 -7
- package/dist/components/forms/checkbox.module.css +20 -20
- package/dist/components/forms/checkbox_module.css +13 -10
- package/dist/components/forms/input.module.css +10 -11
- package/dist/components/forms/input_module.css +3 -5
- package/dist/components/forms/radio-group.d.ts +6 -5
- package/dist/components/forms/radio-group.d.ts.map +1 -1
- package/dist/components/forms/radio-group.js +9 -4
- package/dist/components/forms/radio-group.module.css +13 -22
- package/dist/components/forms/radio-group_module.css +6 -24
- package/dist/components/forms/select.d.ts +4 -5
- package/dist/components/forms/select.d.ts.map +1 -1
- package/dist/components/forms/select.js +27 -29
- package/dist/components/forms/select.module.css +22 -22
- package/dist/components/forms/select.module.js +15 -15
- package/dist/components/forms/select_module.css +15 -15
- package/dist/components/notifications/@types/toast.d.ts +9 -7
- package/dist/components/notifications/@types/toast.d.ts.map +1 -1
- package/dist/components/notifications/toast.d.ts +12 -16
- package/dist/components/notifications/toast.d.ts.map +1 -1
- package/dist/components/notifications/toast.js +73 -57
- package/dist/components/notifications/toast.module.css +151 -177
- package/dist/components/notifications/toast.module.js +8 -12
- package/dist/components/notifications/toast_module.css +114 -159
- package/dist/components/pager/first-button.d.ts +2 -2
- package/dist/components/pager/first-button.d.ts.map +1 -1
- package/dist/components/pager/first-button.js +23 -16
- package/dist/components/pager/last-button.d.ts +2 -2
- package/dist/components/pager/last-button.d.ts.map +1 -1
- package/dist/components/pager/last-button.js +23 -16
- package/dist/components/pager/next-button.d.ts +2 -2
- package/dist/components/pager/next-button.d.ts.map +1 -1
- package/dist/components/pager/next-button.js +27 -20
- package/dist/components/pager/number-button.d.ts +2 -2
- package/dist/components/pager/number-button.d.ts.map +1 -1
- package/dist/components/pager/number-button.js +28 -23
- package/dist/components/pager/pagination.d.ts +8 -13
- package/dist/components/pager/pagination.d.ts.map +1 -1
- package/dist/components/pager/previous-button.d.ts +2 -2
- package/dist/components/pager/previous-button.d.ts.map +1 -1
- package/dist/components/pager/previous-button.js +25 -18
- package/dist/components/scroll-area/scroll-area.d.ts +2 -2
- package/dist/components/scroll-area/scroll-area.d.ts.map +1 -1
- package/dist/components/scroll-area/scroll-area.js +4 -2
- package/dist/components/tabs/tabs.d.ts +13 -13
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tabs/tabs.js +8 -8
- package/dist/components/tabs/tabs.module.css +8 -17
- package/dist/components/tabs/tabs_module.css +1 -1
- package/dist/components/tooltip/tooltip.d.ts +6 -8
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tooltip/tooltip.js +49 -20
- package/dist/components/tooltip/tooltip.module.css +43 -10
- package/dist/components/tooltip/tooltip.module.js +7 -1
- package/dist/components/tooltip/tooltip_module.css +36 -4
- package/dist/hooks/use-focus-trap/index.d.ts +2 -0
- package/dist/hooks/use-focus-trap/index.d.ts.map +1 -0
- package/dist/hooks/use-focus-trap/index.js +1 -0
- package/dist/hooks/use-focus-trap/scope-tab.d.ts +11 -0
- package/dist/hooks/use-focus-trap/scope-tab.d.ts.map +1 -0
- package/dist/hooks/use-focus-trap/scope-tab.js +19 -0
- package/dist/hooks/use-focus-trap/tabbable.d.ts +14 -0
- package/dist/hooks/use-focus-trap/tabbable.d.ts.map +1 -0
- package/dist/hooks/use-focus-trap/tabbable.js +36 -0
- package/dist/hooks/use-focus-trap/use-focus-trap.d.ts +11 -0
- package/dist/hooks/use-focus-trap/use-focus-trap.d.ts.map +1 -0
- package/dist/hooks/use-focus-trap/use-focus-trap.js +45 -0
- package/dist/icons/chevron-up-icon.d.ts +7 -0
- package/dist/icons/chevron-up-icon.d.ts.map +1 -0
- package/dist/icons/chevron-up-icon.js +27 -0
- package/dist/lib/ripple.d.ts +25 -0
- package/dist/lib/ripple.d.ts.map +1 -0
- package/dist/lib/ripple.js +53 -0
- package/dist/styles/components-vanilla.css +1 -1
- package/dist/widgets/datepicker/datepicker.d.ts +1 -1
- package/dist/widgets/datepicker/datepicker.d.ts.map +1 -1
- package/dist/widgets/datepicker/datepicker.js +118 -116
- package/dist/widgets/datepicker/datepicker.module.css +6 -5
- package/dist/widgets/datepicker/datepicker_module.css +4 -4
- package/dist/widgets/drawer/drawer-wrapper.d.ts.map +1 -1
- package/dist/widgets/drawer/drawer-wrapper.js +1 -1
- package/dist/widgets/modal/modal-wrapper.d.ts.map +1 -1
- package/dist/widgets/modal/modal-wrapper.js +1 -1
- package/package.json +2 -6
- package/src/components/accordion/accordion.module.css +6 -5
- package/src/components/accordion/accordion.stories.tsx +10 -13
- package/src/components/accordion/accordion.tsx +13 -13
- package/src/components/avatar/avatar.tsx +2 -2
- package/src/components/badge/badge.tsx +20 -29
- package/src/components/button/button-group.tsx +60 -44
- package/src/components/button/button.module.css +32 -54
- package/src/components/button/button.tsx +35 -47
- package/src/components/button/combo-button.module.css +16 -7
- package/src/components/button/combo-button.tsx +17 -9
- package/src/components/button/icon-button.tsx +3 -5
- package/src/components/card/card.tsx +20 -32
- package/src/components/chips/chip.module.css +22 -36
- package/src/components/chips/chip.stories.tsx +2 -2
- package/src/components/chips/chip.tsx +59 -57
- package/src/components/dropdown/dropdown.stories.tsx +2 -4
- package/src/components/dropdown/dropdown.tsx +86 -40
- package/src/components/forms/calendar.tsx +43 -33
- package/src/components/forms/checkbox-group.tsx +1 -1
- package/src/components/forms/checkbox.astro +13 -8
- package/src/components/forms/checkbox.module.css +20 -20
- package/src/components/forms/checkbox.tsx +11 -6
- package/src/components/forms/input.module.css +10 -11
- package/src/components/forms/radio-group.module.css +13 -22
- package/src/components/forms/radio-group.tsx +13 -11
- package/src/components/forms/select.module.css +22 -22
- package/src/components/forms/select.tsx +36 -33
- package/src/components/notifications/@types/toast.ts +9 -7
- package/src/components/notifications/toast.module.css +151 -177
- package/src/components/notifications/toast.stories.tsx +21 -23
- package/src/components/notifications/toast.tsx +90 -86
- package/src/components/pager/first-button.tsx +24 -26
- package/src/components/pager/last-button.tsx +24 -25
- package/src/components/pager/next-button.tsx +24 -23
- package/src/components/pager/number-button.tsx +37 -36
- package/src/components/pager/pagination.tsx +4 -11
- package/src/components/pager/previous-button.tsx +24 -24
- package/src/components/scroll-area/scroll-area.tsx +3 -3
- package/src/components/tabs/tabs.module.css +8 -17
- package/src/components/tabs/tabs.stories.tsx +5 -5
- package/src/components/tabs/tabs.tsx +17 -16
- package/src/components/tooltip/tooltip.module.css +43 -10
- package/src/components/tooltip/tooltip.stories.tsx +4 -4
- package/src/components/tooltip/tooltip.tsx +56 -28
- package/src/hooks/use-focus-trap/index.ts +1 -0
- package/src/hooks/use-focus-trap/scope-tab.ts +48 -0
- package/src/hooks/use-focus-trap/tabbable.ts +72 -0
- package/src/hooks/use-focus-trap/use-focus-trap.ts +83 -0
- package/src/icons/chevron-up-icon.tsx +37 -0
- package/src/lib/ripple.ts +95 -0
- package/src/widgets/datepicker/datepicker.module.css +6 -5
- package/src/widgets/datepicker/datepicker.tsx +137 -135
- package/src/widgets/drawer/drawer-wrapper.tsx +1 -1
- package/src/widgets/modal/modal-wrapper.tsx +1 -1
|
@@ -1,45 +1,33 @@
|
|
|
1
1
|
import type React from 'react'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useRender } from '@base-ui/react/use-render'
|
|
4
4
|
import cx from 'classnames'
|
|
5
5
|
|
|
6
6
|
import styles from './card.module.css'
|
|
7
7
|
|
|
8
|
-
type
|
|
9
|
-
asChild?: false
|
|
10
|
-
} & React.ComponentPropsWithoutRef<'div'>
|
|
11
|
-
|
|
12
|
-
interface AsSlot {
|
|
13
|
-
asChild?: true
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type CardRefType<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref']
|
|
17
|
-
|
|
18
|
-
export type CardProps<C extends React.ElementType = 'div'> = {
|
|
8
|
+
export type CardProps = useRender.ComponentProps<'div'> & {
|
|
19
9
|
children: React.ReactNode
|
|
20
10
|
className?: string
|
|
21
11
|
hover?: boolean
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} & (AsSlot | AsDiv)
|
|
25
|
-
|
|
26
|
-
const Card = <C extends React.ElementType = 'div'>({
|
|
27
|
-
className,
|
|
28
|
-
hover,
|
|
29
|
-
children,
|
|
30
|
-
asChild,
|
|
31
|
-
ref,
|
|
32
|
-
...rest
|
|
33
|
-
}: CardProps<C>) => {
|
|
34
|
-
const Comp: React.ElementType = asChild === true ? Slot : 'div'
|
|
35
|
-
const hoverClasses = hover != null && hover === true ? styles['card-hover'] : undefined
|
|
36
|
-
const classes = cx(styles.card, hoverClasses, className)
|
|
12
|
+
ref?: React.Ref<HTMLDivElement>
|
|
13
|
+
}
|
|
37
14
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
const Card = ({ className, hover, children, render, ref, ...rest }: CardProps) => {
|
|
16
|
+
const hoverClasses = hover != null && hover === true ? styles['card-hover'] : undefined
|
|
17
|
+
const classes = cx('infonomic-card', styles.card, hoverClasses, className)
|
|
18
|
+
|
|
19
|
+
const element = useRender({
|
|
20
|
+
defaultTagName: 'div',
|
|
21
|
+
render,
|
|
22
|
+
ref,
|
|
23
|
+
props: {
|
|
24
|
+
...rest,
|
|
25
|
+
className: classes,
|
|
26
|
+
children,
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
return element
|
|
43
31
|
}
|
|
44
32
|
|
|
45
33
|
Card.displayName = 'Card'
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
@layer infonomic-base,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
infonomic-functional,
|
|
3
|
+
infonomic-utilities,
|
|
4
|
+
infonomic-theme,
|
|
5
|
+
infonomic-typography,
|
|
6
|
+
infonomic-components;
|
|
7
7
|
|
|
8
8
|
@layer infonomic-components {
|
|
9
|
+
|
|
9
10
|
.chip,
|
|
10
11
|
:global(.infonomic-chip) {
|
|
11
12
|
--chip-font-size: 0.9rem;
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
--chip-icon-size: 1rem;
|
|
16
17
|
--chip-gap: var(--gap-1);
|
|
17
18
|
appearance: none;
|
|
18
|
-
outline:
|
|
19
|
+
outline: 1px solid transparent;
|
|
19
20
|
outline-offset: 2px;
|
|
20
21
|
display: inline-flex;
|
|
21
22
|
align-items: center;
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
font-size: var(--chip-font-size);
|
|
31
32
|
transition:
|
|
32
33
|
background-color var(--transition-normal),
|
|
33
|
-
|
|
34
|
+
outline-color var(--transition-normal);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
.chip:disabled,
|
|
@@ -44,10 +45,7 @@
|
|
|
44
45
|
.chip:active,
|
|
45
46
|
:global(.infonomic-chip):focus,
|
|
46
47
|
:global(.infonomic-chip):active {
|
|
47
|
-
|
|
48
|
-
--ring-offset-shadow: var(--ring-inset) 0 0 0 var(--ring-offset-width) var(--ring-offset-color);
|
|
49
|
-
--ring-shadow: var(--ring-inset) 0 0 0 calc(1px + var(--ring-offset-width)) var(--ring-color);
|
|
50
|
-
box-shadow: var(--ring-offset-shadow), var(--ring-shadow), var(--shadow, 0 0 #0000);
|
|
48
|
+
outline-color: var(--ring-color);
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
.label,
|
|
@@ -150,14 +148,10 @@
|
|
|
150
148
|
.filled[disabled],
|
|
151
149
|
:global(.infonomic-chip-filled):disabled,
|
|
152
150
|
:global(.infonomic-chip-filled)[disabled] {
|
|
153
|
-
background-color: var(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
color: var(
|
|
158
|
-
--chip-variant-filled-foreground-disabled,
|
|
159
|
-
oklch(from var(--chip-variant-filled-foreground) calc(l * 0.9) calc(c * 0.85) h)
|
|
160
|
-
);
|
|
151
|
+
background-color: var(--chip-variant-filled-disabled,
|
|
152
|
+
oklch(from var(--chip-variant-filled) calc(l * 1.1) calc(c * 0.85) h));
|
|
153
|
+
color: var(--chip-variant-filled-foreground-disabled,
|
|
154
|
+
oklch(from var(--chip-variant-filled-foreground) calc(l * 0.9) calc(c * 0.85) h));
|
|
161
155
|
}
|
|
162
156
|
|
|
163
157
|
/* -------------------------------------------------------- */
|
|
@@ -185,14 +179,10 @@
|
|
|
185
179
|
.filled-weak[disabled],
|
|
186
180
|
:global(.infonomic-chip-filled-weak):disabled,
|
|
187
181
|
:global(.infonomic-chip-filled-weak)[disabled] {
|
|
188
|
-
background-color: var(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
color: var(
|
|
193
|
-
--chip-variant-filled-weak-foreground-disabled,
|
|
194
|
-
oklch(from var(--chip-variant-filled-weak-foreground) calc(l * 0.9) calc(c * 0.85) h)
|
|
195
|
-
);
|
|
182
|
+
background-color: var(--chip-variant-filled-weak-disabled,
|
|
183
|
+
oklch(from var(--chip-variant-filled-weak) calc(l * 1.1) calc(c * 0.85) h));
|
|
184
|
+
color: var(--chip-variant-filled-weak-foreground-disabled,
|
|
185
|
+
oklch(from var(--chip-variant-filled-weak-foreground) calc(l * 0.9) calc(c * 0.85) h));
|
|
196
186
|
}
|
|
197
187
|
|
|
198
188
|
/* -------------------------------------------------------- */
|
|
@@ -209,14 +199,10 @@
|
|
|
209
199
|
.outlined[disabled],
|
|
210
200
|
:global(.infonomic-chip-outlined):disabled,
|
|
211
201
|
:global(.infonomic-chip-outlined)[disabled] {
|
|
212
|
-
border-color: var(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
color: var(
|
|
217
|
-
--chip-variant-outlined-foreground-disabled,
|
|
218
|
-
oklch(from var(--chip-variant-outlined-foreground) calc(l * 1.1) calc(c * 0.7) h)
|
|
219
|
-
);
|
|
202
|
+
border-color: var(--chip-variant-outlined-border-disabled,
|
|
203
|
+
oklch(from var(--chip-variant-outlined-border) calc(l * 1.5) calc(c * 0.8) h));
|
|
204
|
+
color: var(--chip-variant-outlined-foreground-disabled,
|
|
205
|
+
oklch(from var(--chip-variant-outlined-foreground) calc(l * 1.1) calc(c * 0.7) h));
|
|
220
206
|
}
|
|
221
207
|
|
|
222
208
|
.outlined:hover,
|
|
@@ -445,4 +431,4 @@
|
|
|
445
431
|
--chip-variant-outlined-foreground: var(--text-on-danger-outlined);
|
|
446
432
|
--chip-variant-outlined-foreground-disabled: var(--text-on-danger-outlined-disabled);
|
|
447
433
|
}
|
|
448
|
-
}
|
|
434
|
+
}
|
|
@@ -63,7 +63,7 @@ export const Variants: Story = {
|
|
|
63
63
|
selected={true}
|
|
64
64
|
>{`${capitalize(variant)} with icon`}</Chip>
|
|
65
65
|
{(variant === 'removable' || variant === 'selectable-removable') && (
|
|
66
|
-
<Chip variant={variant} onRemove={() => {}}>
|
|
66
|
+
<Chip variant={variant} onRemove={() => { }}>
|
|
67
67
|
{`${capitalize(variant)} with remove`}
|
|
68
68
|
</Chip>
|
|
69
69
|
)}
|
|
@@ -102,7 +102,7 @@ export const Removable: Story = {
|
|
|
102
102
|
<Chip
|
|
103
103
|
variant="removable"
|
|
104
104
|
intent="primary"
|
|
105
|
-
onRemove={() => {}}
|
|
105
|
+
onRemove={() => { }}
|
|
106
106
|
startIcon={<CalendarIcon height="16px" width="16px" />}
|
|
107
107
|
>
|
|
108
108
|
Removable chip
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import type React from 'react'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { mergeProps } from '@base-ui/react/merge-props'
|
|
6
|
+
import { useRender } from '@base-ui/react/use-render'
|
|
6
7
|
import cx from 'classnames'
|
|
7
8
|
|
|
8
9
|
import { CheckIcon } from '../../icons/check-icon.js'
|
|
@@ -10,18 +11,10 @@ import { CloseIcon } from '../../icons/close-icon.js'
|
|
|
10
11
|
import styles from './chip.module.css'
|
|
11
12
|
import type { ChipIntent, ChipSize, ChipVariant } from './@types/chip.js'
|
|
12
13
|
|
|
13
|
-
type AsButton = { asChild?: false } & React.ComponentPropsWithoutRef<'button'>
|
|
14
|
-
|
|
15
|
-
interface AsSlot {
|
|
16
|
-
asChild?: true
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type ChipRefType<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref']
|
|
20
|
-
|
|
21
14
|
type ToggleEvent = React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>
|
|
22
15
|
type RemoveEvent = React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>
|
|
23
16
|
|
|
24
|
-
export type ChipProps
|
|
17
|
+
export type ChipProps = Omit<useRender.ComponentProps<'button'>, 'onToggle'> & {
|
|
25
18
|
variant?: ChipVariant
|
|
26
19
|
intent?: ChipIntent
|
|
27
20
|
size?: ChipSize
|
|
@@ -34,11 +27,10 @@ export type ChipProps<C extends React.ElementType = 'button'> = {
|
|
|
34
27
|
onToggle?: (selected: boolean, event: ToggleEvent) => void
|
|
35
28
|
onRemove?: (event: RemoveEvent) => void
|
|
36
29
|
className?: string
|
|
37
|
-
ref?:
|
|
38
|
-
} &
|
|
39
|
-
Omit<React.HTMLAttributes<HTMLElement>, 'onToggle'>
|
|
30
|
+
ref?: React.Ref<HTMLButtonElement>
|
|
31
|
+
} & Omit<React.HTMLAttributes<HTMLElement>, 'onToggle'>
|
|
40
32
|
|
|
41
|
-
export const Chip =
|
|
33
|
+
export const Chip = ({
|
|
42
34
|
variant = 'assist',
|
|
43
35
|
intent = 'primary',
|
|
44
36
|
size = 'md',
|
|
@@ -52,12 +44,12 @@ export const Chip = <C extends React.ElementType = 'button'>({
|
|
|
52
44
|
onRemove,
|
|
53
45
|
className,
|
|
54
46
|
children,
|
|
55
|
-
|
|
47
|
+
render,
|
|
56
48
|
ref,
|
|
57
49
|
...rest
|
|
58
|
-
}: ChipProps
|
|
50
|
+
}: ChipProps) => {
|
|
59
51
|
const { onClick, onKeyDown, role, tabIndex, ...restProps } = rest
|
|
60
|
-
const
|
|
52
|
+
const isCustomElement = render != null
|
|
61
53
|
const isSelectable = variant === 'selectable' || variant === 'selectable-removable'
|
|
62
54
|
const isRemovable = variant === 'removable' || variant === 'selectable-removable'
|
|
63
55
|
const isSelected = Boolean(selected)
|
|
@@ -69,7 +61,7 @@ export const Chip = <C extends React.ElementType = 'button'>({
|
|
|
69
61
|
}
|
|
70
62
|
|
|
71
63
|
if (onClick) {
|
|
72
|
-
;(onClick as React.MouseEventHandler<HTMLElement>)(event)
|
|
64
|
+
; (onClick as React.MouseEventHandler<HTMLElement>)(event)
|
|
73
65
|
}
|
|
74
66
|
|
|
75
67
|
if (isSelectable && onToggle) {
|
|
@@ -82,10 +74,10 @@ export const Chip = <C extends React.ElementType = 'button'>({
|
|
|
82
74
|
return
|
|
83
75
|
}
|
|
84
76
|
|
|
85
|
-
if ((event.key === 'Enter' || event.key === ' ') &&
|
|
77
|
+
if ((event.key === 'Enter' || event.key === ' ') && isCustomElement) {
|
|
86
78
|
event.preventDefault()
|
|
87
79
|
if (onClick) {
|
|
88
|
-
;(onClick as React.MouseEventHandler<HTMLElement>)(
|
|
80
|
+
; (onClick as React.MouseEventHandler<HTMLElement>)(
|
|
89
81
|
event as unknown as React.MouseEvent<HTMLElement>
|
|
90
82
|
)
|
|
91
83
|
}
|
|
@@ -154,43 +146,53 @@ export const Chip = <C extends React.ElementType = 'button'>({
|
|
|
154
146
|
|
|
155
147
|
const appliedVariant = isSelected ? 'filled' : 'outlined'
|
|
156
148
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
149
|
+
const defaultProps: Record<string, unknown> = {
|
|
150
|
+
type: isCustomElement ? undefined : 'button',
|
|
151
|
+
role: role ?? (isCustomElement ? 'button' : undefined),
|
|
152
|
+
tabIndex: disabled ? -1 : (tabIndex ?? 0),
|
|
153
|
+
'aria-disabled': disabled || undefined,
|
|
154
|
+
'aria-pressed': isSelectable ? isSelected : undefined,
|
|
155
|
+
'aria-selected': isSelectable ? isSelected : undefined,
|
|
156
|
+
className: cx(
|
|
157
|
+
'infonomic-chip',
|
|
158
|
+
`infonomic-chip-${variant}`,
|
|
159
|
+
`infonomic-chip-${intent}`,
|
|
160
|
+
`infonomic-chip-${size}`,
|
|
161
|
+
{ selected: isSelected, disabled, removable: isRemovable },
|
|
162
|
+
styles.chip,
|
|
163
|
+
styles[appliedVariant],
|
|
164
|
+
styles[intent],
|
|
165
|
+
styles[size],
|
|
166
|
+
className
|
|
167
|
+
),
|
|
168
|
+
disabled: isCustomElement ? undefined : disabled,
|
|
169
|
+
onClick: handleClick,
|
|
170
|
+
onKeyDown: handleKeyDown,
|
|
171
|
+
children: (
|
|
172
|
+
<>
|
|
173
|
+
{leadingIcon != null && (
|
|
174
|
+
<span className={cx('infonomic-chip-icon-wrapper', styles.iconWrapper)}>
|
|
175
|
+
{leadingIcon}
|
|
176
|
+
</span>
|
|
177
|
+
)}
|
|
178
|
+
<span className={cx('infonomic-chip-label', styles.label)}>{children}</span>
|
|
179
|
+
{trailingIcon != null && (
|
|
180
|
+
<span className={cx('infonomic-chip-icon-wrapper', styles.iconWrapper)}>
|
|
181
|
+
{trailingIcon}
|
|
182
|
+
</span>
|
|
183
|
+
)}
|
|
184
|
+
</>
|
|
185
|
+
),
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const element = useRender({
|
|
189
|
+
defaultTagName: 'button',
|
|
190
|
+
render,
|
|
191
|
+
ref,
|
|
192
|
+
props: mergeProps<'button'>(defaultProps, restProps),
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
return element
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
Chip.displayName = 'Chip'
|
|
@@ -55,10 +55,8 @@ export const Dropdown: Story = {
|
|
|
55
55
|
}}
|
|
56
56
|
>
|
|
57
57
|
<DropdownComponent.Root {...args}>
|
|
58
|
-
<DropdownComponent.Trigger
|
|
59
|
-
|
|
60
|
-
+
|
|
61
|
-
</Button>
|
|
58
|
+
<DropdownComponent.Trigger render={<Button size="sm" variant="filled" />}>
|
|
59
|
+
+
|
|
62
60
|
</DropdownComponent.Trigger>
|
|
63
61
|
|
|
64
62
|
<DropdownComponent.Portal>
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import type React from 'react'
|
|
4
4
|
|
|
5
|
+
import { Menu } from '@base-ui/react/menu'
|
|
5
6
|
import cx from 'classnames'
|
|
6
|
-
import { DropdownMenu as DropdownMenuPrimitive } from 'radix-ui'
|
|
7
7
|
|
|
8
8
|
import styles from './dropdown.module.css'
|
|
9
9
|
|
|
10
|
-
function Root({
|
|
11
|
-
|
|
10
|
+
function Root({
|
|
11
|
+
children,
|
|
12
|
+
...rest
|
|
13
|
+
}: React.ComponentProps<typeof Menu.Root>): React.JSX.Element {
|
|
14
|
+
return <Menu.Root {...rest}>{children}</Menu.Root>
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
const Trigger = ({
|
|
@@ -16,17 +19,17 @@ const Trigger = ({
|
|
|
16
19
|
className,
|
|
17
20
|
children,
|
|
18
21
|
...rest
|
|
19
|
-
}:
|
|
22
|
+
}: React.ComponentProps<typeof Menu.Trigger> & {
|
|
20
23
|
ref?: React.RefObject<React.ComponentRef<'button'>>
|
|
21
24
|
}): React.JSX.Element => {
|
|
22
25
|
return (
|
|
23
|
-
<
|
|
26
|
+
<Menu.Trigger
|
|
24
27
|
className={cx('infonomic-dropdown-trigger', className)}
|
|
25
28
|
ref={ref}
|
|
26
29
|
{...rest}
|
|
27
30
|
>
|
|
28
31
|
{children}
|
|
29
|
-
</
|
|
32
|
+
</Menu.Trigger>
|
|
30
33
|
)
|
|
31
34
|
}
|
|
32
35
|
Trigger.displayName = 'Trigger'
|
|
@@ -34,26 +37,46 @@ Trigger.displayName = 'Trigger'
|
|
|
34
37
|
function Portal({
|
|
35
38
|
children,
|
|
36
39
|
...rest
|
|
37
|
-
}:
|
|
38
|
-
return <
|
|
40
|
+
}: React.ComponentProps<typeof Menu.Portal>): React.JSX.Element {
|
|
41
|
+
return <Menu.Portal {...rest}>{children}</Menu.Portal>
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
const Content = ({
|
|
42
45
|
ref,
|
|
43
46
|
className,
|
|
44
47
|
children,
|
|
48
|
+
side,
|
|
49
|
+
sideOffset,
|
|
50
|
+
align,
|
|
51
|
+
alignOffset,
|
|
52
|
+
collisionPadding,
|
|
45
53
|
...rest
|
|
46
|
-
}:
|
|
54
|
+
}: {
|
|
47
55
|
ref?: React.RefObject<React.ComponentRef<'div'>>
|
|
48
|
-
|
|
56
|
+
className?: string
|
|
57
|
+
children?: React.ReactNode
|
|
58
|
+
side?: React.ComponentProps<typeof Menu.Positioner>['side']
|
|
59
|
+
sideOffset?: React.ComponentProps<typeof Menu.Positioner>['sideOffset']
|
|
60
|
+
align?: React.ComponentProps<typeof Menu.Positioner>['align']
|
|
61
|
+
alignOffset?: React.ComponentProps<typeof Menu.Positioner>['alignOffset']
|
|
62
|
+
collisionPadding?: React.ComponentProps<typeof Menu.Positioner>['collisionPadding']
|
|
63
|
+
} & Omit<React.ComponentProps<typeof Menu.Popup>, 'className'>): React.JSX.Element => {
|
|
49
64
|
return (
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
65
|
+
<Menu.Positioner
|
|
66
|
+
side={side}
|
|
67
|
+
sideOffset={sideOffset}
|
|
68
|
+
align={align}
|
|
69
|
+
alignOffset={alignOffset}
|
|
70
|
+
collisionPadding={collisionPadding}
|
|
54
71
|
>
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
<Menu.Popup
|
|
73
|
+
ref={ref}
|
|
74
|
+
className={cx('infonomic-dropdown-content', styles['dropdown-content'], className)}
|
|
75
|
+
{...rest}
|
|
76
|
+
>
|
|
77
|
+
{children}
|
|
78
|
+
</Menu.Popup>
|
|
79
|
+
</Menu.Positioner>
|
|
57
80
|
)
|
|
58
81
|
}
|
|
59
82
|
Content.displayName = 'Content'
|
|
@@ -63,17 +86,17 @@ const Group = ({
|
|
|
63
86
|
className,
|
|
64
87
|
children,
|
|
65
88
|
...rest
|
|
66
|
-
}:
|
|
89
|
+
}: React.ComponentProps<typeof Menu.Group> & {
|
|
67
90
|
ref?: React.RefObject<React.ComponentRef<'div'>>
|
|
68
91
|
}): React.JSX.Element => {
|
|
69
92
|
return (
|
|
70
|
-
<
|
|
93
|
+
<Menu.Group
|
|
71
94
|
ref={ref}
|
|
72
95
|
className={cx('infonomic-dropdown-group', className)}
|
|
73
96
|
{...rest}
|
|
74
97
|
>
|
|
75
98
|
{children}
|
|
76
|
-
</
|
|
99
|
+
</Menu.Group>
|
|
77
100
|
)
|
|
78
101
|
}
|
|
79
102
|
Group.displayName = 'Group'
|
|
@@ -83,17 +106,17 @@ const Item = ({
|
|
|
83
106
|
className,
|
|
84
107
|
children,
|
|
85
108
|
...rest
|
|
86
|
-
}:
|
|
109
|
+
}: React.ComponentProps<typeof Menu.Item> & {
|
|
87
110
|
ref?: React.RefObject<React.ComponentRef<'div'>>
|
|
88
111
|
}): React.JSX.Element => {
|
|
89
112
|
return (
|
|
90
|
-
<
|
|
113
|
+
<Menu.Item
|
|
91
114
|
ref={ref}
|
|
92
115
|
className={cx('infonomic-dropdown-item', styles['dropdown-item'], className)}
|
|
93
116
|
{...rest}
|
|
94
117
|
>
|
|
95
118
|
{children}
|
|
96
|
-
</
|
|
119
|
+
</Menu.Item>
|
|
97
120
|
)
|
|
98
121
|
}
|
|
99
122
|
Item.displayName = 'Item'
|
|
@@ -103,17 +126,17 @@ const Label = ({
|
|
|
103
126
|
className,
|
|
104
127
|
children,
|
|
105
128
|
...rest
|
|
106
|
-
}:
|
|
129
|
+
}: React.ComponentProps<typeof Menu.GroupLabel> & {
|
|
107
130
|
ref?: React.RefObject<React.ComponentRef<'div'>>
|
|
108
131
|
}): React.JSX.Element => {
|
|
109
132
|
return (
|
|
110
|
-
<
|
|
133
|
+
<Menu.GroupLabel
|
|
111
134
|
ref={ref}
|
|
112
135
|
className={cx('infonomic-dropdown-label', className)}
|
|
113
136
|
{...rest}
|
|
114
137
|
>
|
|
115
138
|
{children}
|
|
116
|
-
</
|
|
139
|
+
</Menu.GroupLabel>
|
|
117
140
|
)
|
|
118
141
|
}
|
|
119
142
|
Label.displayName = 'Label'
|
|
@@ -122,11 +145,11 @@ const Separator = ({
|
|
|
122
145
|
ref,
|
|
123
146
|
className,
|
|
124
147
|
...props
|
|
125
|
-
}:
|
|
148
|
+
}: React.ComponentProps<typeof Menu.Separator> & {
|
|
126
149
|
ref?: React.RefObject<React.ComponentRef<'div'>>
|
|
127
150
|
}): React.JSX.Element => {
|
|
128
151
|
return (
|
|
129
|
-
<
|
|
152
|
+
<Menu.Separator
|
|
130
153
|
ref={ref}
|
|
131
154
|
className={cx('infonomic-dropdown-separator', styles['dropdown-separator'], className)}
|
|
132
155
|
{...props}
|
|
@@ -135,26 +158,49 @@ const Separator = ({
|
|
|
135
158
|
}
|
|
136
159
|
Separator.displayName = 'Separator'
|
|
137
160
|
|
|
138
|
-
function Sub({
|
|
139
|
-
|
|
161
|
+
function Sub({
|
|
162
|
+
children,
|
|
163
|
+
...rest
|
|
164
|
+
}: React.ComponentProps<typeof Menu.SubmenuRoot>): React.JSX.Element {
|
|
165
|
+
return <Menu.SubmenuRoot {...rest}>{children}</Menu.SubmenuRoot>
|
|
140
166
|
}
|
|
141
167
|
|
|
142
168
|
const SubContent = ({
|
|
143
169
|
ref,
|
|
144
170
|
className,
|
|
145
171
|
children,
|
|
172
|
+
side,
|
|
173
|
+
sideOffset,
|
|
174
|
+
align,
|
|
175
|
+
alignOffset,
|
|
176
|
+
collisionPadding,
|
|
146
177
|
...rest
|
|
147
|
-
}:
|
|
178
|
+
}: {
|
|
148
179
|
ref?: React.RefObject<React.ComponentRef<'div'>>
|
|
149
|
-
|
|
180
|
+
className?: string
|
|
181
|
+
children?: React.ReactNode
|
|
182
|
+
side?: React.ComponentProps<typeof Menu.Positioner>['side']
|
|
183
|
+
sideOffset?: React.ComponentProps<typeof Menu.Positioner>['sideOffset']
|
|
184
|
+
align?: React.ComponentProps<typeof Menu.Positioner>['align']
|
|
185
|
+
alignOffset?: React.ComponentProps<typeof Menu.Positioner>['alignOffset']
|
|
186
|
+
collisionPadding?: React.ComponentProps<typeof Menu.Positioner>['collisionPadding']
|
|
187
|
+
} & Omit<React.ComponentProps<typeof Menu.Popup>, 'className'>): React.JSX.Element => {
|
|
150
188
|
return (
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
{
|
|
189
|
+
<Menu.Positioner
|
|
190
|
+
side={side}
|
|
191
|
+
sideOffset={sideOffset}
|
|
192
|
+
align={align}
|
|
193
|
+
alignOffset={alignOffset}
|
|
194
|
+
collisionPadding={collisionPadding}
|
|
155
195
|
>
|
|
156
|
-
|
|
157
|
-
|
|
196
|
+
<Menu.Popup
|
|
197
|
+
ref={ref}
|
|
198
|
+
className={cx('infonomic-dropdown-subcontent', styles['dropdown-subcontent'], className)}
|
|
199
|
+
{...rest}
|
|
200
|
+
>
|
|
201
|
+
{children}
|
|
202
|
+
</Menu.Popup>
|
|
203
|
+
</Menu.Positioner>
|
|
158
204
|
)
|
|
159
205
|
}
|
|
160
206
|
SubContent.displayName = 'SubContent'
|
|
@@ -164,17 +210,17 @@ const SubTrigger = ({
|
|
|
164
210
|
className,
|
|
165
211
|
children,
|
|
166
212
|
...rest
|
|
167
|
-
}:
|
|
213
|
+
}: React.ComponentProps<typeof Menu.SubmenuTrigger> & {
|
|
168
214
|
ref?: React.RefObject<React.ComponentRef<'div'>>
|
|
169
215
|
}): React.JSX.Element => {
|
|
170
216
|
return (
|
|
171
|
-
<
|
|
217
|
+
<Menu.SubmenuTrigger
|
|
172
218
|
ref={ref}
|
|
173
219
|
className={cx('infonomic-dropdown-subtrigger', className)}
|
|
174
220
|
{...rest}
|
|
175
221
|
>
|
|
176
222
|
{children}
|
|
177
|
-
</
|
|
223
|
+
</Menu.SubmenuTrigger>
|
|
178
224
|
)
|
|
179
225
|
}
|
|
180
226
|
SubTrigger.displayName = 'SubTrigger'
|