@a-type/ui 4.1.2 → 4.1.4
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/cjs/components/collapsible/Collapsible.js +1 -1
- package/dist/cjs/components/collapsible/Collapsible.js.map +1 -1
- package/dist/cjs/components/contextMenu/contextMenu.js +2 -2
- package/dist/cjs/components/contextMenu/contextMenu.js.map +1 -1
- package/dist/cjs/components/dialog/Dialog.js +3 -3
- package/dist/cjs/components/dialog/Dialog.js.map +1 -1
- package/dist/cjs/components/quickAction/QuickAction.d.ts +9 -6
- package/dist/cjs/components/quickAction/QuickAction.js +45 -25
- package/dist/cjs/components/quickAction/QuickAction.js.map +1 -1
- package/dist/cjs/components/select/Select.js +3 -3
- package/dist/cjs/components/tooltip/Tooltip.js +1 -1
- package/dist/cjs/components/tooltip/Tooltip.js.map +1 -1
- package/dist/cjs/systems/ValueMonitor.d.ts +8 -0
- package/dist/cjs/systems/ValueMonitor.js +40 -0
- package/dist/cjs/systems/ValueMonitor.js.map +1 -0
- package/dist/cjs/uno/rules/clipPath.d.ts +2 -0
- package/dist/cjs/uno/rules/clipPath.js +49 -0
- package/dist/cjs/uno/rules/clipPath.js.map +1 -0
- package/dist/cjs/uno/rules/index.js +2 -0
- package/dist/cjs/uno/rules/index.js.map +1 -1
- package/dist/cjs/uno/variants/baseUi.d.ts +2 -0
- package/dist/cjs/uno/variants/baseUi.js +16 -0
- package/dist/cjs/uno/variants/baseUi.js.map +1 -0
- package/dist/cjs/uno/variants/index.js +2 -0
- package/dist/cjs/uno/variants/index.js.map +1 -1
- package/dist/css/main.css +5 -5
- package/dist/esm/components/collapsible/Collapsible.js +1 -1
- package/dist/esm/components/collapsible/Collapsible.js.map +1 -1
- package/dist/esm/components/contextMenu/contextMenu.js +2 -2
- package/dist/esm/components/contextMenu/contextMenu.js.map +1 -1
- package/dist/esm/components/dialog/Dialog.js +3 -3
- package/dist/esm/components/dialog/Dialog.js.map +1 -1
- package/dist/esm/components/quickAction/QuickAction.d.ts +9 -6
- package/dist/esm/components/quickAction/QuickAction.js +41 -21
- package/dist/esm/components/quickAction/QuickAction.js.map +1 -1
- package/dist/esm/components/select/Select.js +3 -3
- package/dist/esm/components/tooltip/Tooltip.js +1 -1
- package/dist/esm/components/tooltip/Tooltip.js.map +1 -1
- package/dist/esm/systems/ValueMonitor.d.ts +8 -0
- package/dist/esm/systems/ValueMonitor.js +34 -0
- package/dist/esm/systems/ValueMonitor.js.map +1 -0
- package/dist/esm/uno/rules/clipPath.d.ts +2 -0
- package/dist/esm/uno/rules/clipPath.js +46 -0
- package/dist/esm/uno/rules/clipPath.js.map +1 -0
- package/dist/esm/uno/rules/index.js +2 -0
- package/dist/esm/uno/rules/index.js.map +1 -1
- package/dist/esm/uno/variants/baseUi.d.ts +2 -0
- package/dist/esm/uno/variants/baseUi.js +13 -0
- package/dist/esm/uno/variants/baseUi.js.map +1 -0
- package/dist/esm/uno/variants/index.js +2 -0
- package/dist/esm/uno/variants/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/collapsible/Collapsible.tsx +71 -74
- package/src/components/contextMenu/contextMenu.tsx +66 -67
- package/src/components/dialog/Dialog.tsx +3 -6
- package/src/components/quickAction/QuickAction.tsx +77 -42
- package/src/components/select/Select.tsx +241 -241
- package/src/components/tooltip/Tooltip.tsx +134 -135
- package/src/systems/ValueMonitor.ts +41 -0
- package/src/uno/rules/clipPath.ts +44 -0
- package/src/uno/rules/index.ts +2 -0
- package/src/uno/variants/baseUi.ts +13 -0
- package/src/uno/variants/index.ts +3 -0
|
@@ -1,135 +1,134 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TooltipPopupProps,
|
|
3
|
-
TooltipPositionerProps,
|
|
4
|
-
Tooltip as TooltipPrimitive,
|
|
5
|
-
TooltipTriggerProps,
|
|
6
|
-
} from '@base-ui/react/tooltip';
|
|
7
|
-
import classNames from 'clsx';
|
|
8
|
-
import { ReactElement, ReactNode } from 'react';
|
|
9
|
-
import { GroupScaleReset } from '../../systems/GroupScale.js';
|
|
10
|
-
import { ArrowSvg } from '../utility/ArrowSvg.js';
|
|
11
|
-
|
|
12
|
-
export type * from '@base-ui/react/tooltip';
|
|
13
|
-
|
|
14
|
-
export interface TooltipContentProps
|
|
15
|
-
extends TooltipPopupProps,
|
|
16
|
-
Omit<TooltipPositionerProps, 'className' | 'style' | 'render'> {
|
|
17
|
-
color?: 'contrast' | 'white' | 'neutral' | 'attention';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function Content({
|
|
21
|
-
children,
|
|
22
|
-
className,
|
|
23
|
-
color = 'contrast',
|
|
24
|
-
render,
|
|
25
|
-
side,
|
|
26
|
-
sideOffset,
|
|
27
|
-
align,
|
|
28
|
-
alignOffset,
|
|
29
|
-
anchor,
|
|
30
|
-
disableAnchorTracking,
|
|
31
|
-
sticky,
|
|
32
|
-
arrowPadding,
|
|
33
|
-
collisionAvoidance,
|
|
34
|
-
collisionBoundary,
|
|
35
|
-
collisionPadding,
|
|
36
|
-
positionMethod,
|
|
37
|
-
...props
|
|
38
|
-
}: TooltipContentProps) {
|
|
39
|
-
return (
|
|
40
|
-
<TooltipPrimitive.Portal>
|
|
41
|
-
<GroupScaleReset>
|
|
42
|
-
<TooltipPrimitive.Positioner
|
|
43
|
-
side={side}
|
|
44
|
-
sideOffset={sideOffset}
|
|
45
|
-
align={align}
|
|
46
|
-
alignOffset={alignOffset}
|
|
47
|
-
anchor={anchor}
|
|
48
|
-
disableAnchorTracking={disableAnchorTracking}
|
|
49
|
-
sticky={sticky}
|
|
50
|
-
arrowPadding={arrowPadding}
|
|
51
|
-
collisionAvoidance={collisionAvoidance}
|
|
52
|
-
collisionBoundary={collisionBoundary}
|
|
53
|
-
collisionPadding={collisionPadding}
|
|
54
|
-
positionMethod={positionMethod}
|
|
55
|
-
>
|
|
56
|
-
<TooltipPrimitive.Popup
|
|
57
|
-
render={render}
|
|
58
|
-
className={classNames(
|
|
59
|
-
'layer-components:(relative flex select-none rounded-sm px-sm py-xs text-sm leading-tight shadow-sm transition)',
|
|
60
|
-
'layer-components:data-[instant]:transition-none',
|
|
61
|
-
'layer-components:
|
|
62
|
-
'layer-components:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
'layer-variants:(color-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
);
|
|
1
|
+
import {
|
|
2
|
+
TooltipPopupProps,
|
|
3
|
+
TooltipPositionerProps,
|
|
4
|
+
Tooltip as TooltipPrimitive,
|
|
5
|
+
TooltipTriggerProps,
|
|
6
|
+
} from '@base-ui/react/tooltip';
|
|
7
|
+
import classNames from 'clsx';
|
|
8
|
+
import { ReactElement, ReactNode } from 'react';
|
|
9
|
+
import { GroupScaleReset } from '../../systems/GroupScale.js';
|
|
10
|
+
import { ArrowSvg } from '../utility/ArrowSvg.js';
|
|
11
|
+
|
|
12
|
+
export type * from '@base-ui/react/tooltip';
|
|
13
|
+
|
|
14
|
+
export interface TooltipContentProps
|
|
15
|
+
extends TooltipPopupProps,
|
|
16
|
+
Omit<TooltipPositionerProps, 'className' | 'style' | 'render'> {
|
|
17
|
+
color?: 'contrast' | 'white' | 'neutral' | 'attention';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function Content({
|
|
21
|
+
children,
|
|
22
|
+
className,
|
|
23
|
+
color = 'contrast',
|
|
24
|
+
render,
|
|
25
|
+
side,
|
|
26
|
+
sideOffset,
|
|
27
|
+
align,
|
|
28
|
+
alignOffset,
|
|
29
|
+
anchor,
|
|
30
|
+
disableAnchorTracking,
|
|
31
|
+
sticky,
|
|
32
|
+
arrowPadding,
|
|
33
|
+
collisionAvoidance,
|
|
34
|
+
collisionBoundary,
|
|
35
|
+
collisionPadding,
|
|
36
|
+
positionMethod,
|
|
37
|
+
...props
|
|
38
|
+
}: TooltipContentProps) {
|
|
39
|
+
return (
|
|
40
|
+
<TooltipPrimitive.Portal>
|
|
41
|
+
<GroupScaleReset>
|
|
42
|
+
<TooltipPrimitive.Positioner
|
|
43
|
+
side={side}
|
|
44
|
+
sideOffset={sideOffset}
|
|
45
|
+
align={align}
|
|
46
|
+
alignOffset={alignOffset}
|
|
47
|
+
anchor={anchor}
|
|
48
|
+
disableAnchorTracking={disableAnchorTracking}
|
|
49
|
+
sticky={sticky}
|
|
50
|
+
arrowPadding={arrowPadding}
|
|
51
|
+
collisionAvoidance={collisionAvoidance}
|
|
52
|
+
collisionBoundary={collisionBoundary}
|
|
53
|
+
collisionPadding={collisionPadding}
|
|
54
|
+
positionMethod={positionMethod}
|
|
55
|
+
>
|
|
56
|
+
<TooltipPrimitive.Popup
|
|
57
|
+
render={render}
|
|
58
|
+
className={classNames(
|
|
59
|
+
'layer-components:(relative flex select-none rounded-sm px-sm py-xs text-sm leading-tight shadow-sm transition)',
|
|
60
|
+
'layer-components:data-[instant]:transition-none',
|
|
61
|
+
'layer-components:start-end:(scale-95 opacity-0)',
|
|
62
|
+
'layer-components:transform-origin-[var(--transform-origin)]',
|
|
63
|
+
{
|
|
64
|
+
'layer-variants:(color-white bg-black)': color === 'contrast',
|
|
65
|
+
'layer-variants:(border color-black bg-white border-gray)':
|
|
66
|
+
color === 'white' || color === 'neutral',
|
|
67
|
+
'layer-variants:(color-white bg-attention-ink)':
|
|
68
|
+
color === 'attention',
|
|
69
|
+
},
|
|
70
|
+
className,
|
|
71
|
+
)}
|
|
72
|
+
{...props}
|
|
73
|
+
>
|
|
74
|
+
{children}
|
|
75
|
+
<TooltipPrimitive.Arrow className="layer-components:arrow">
|
|
76
|
+
<ArrowSvg />
|
|
77
|
+
</TooltipPrimitive.Arrow>
|
|
78
|
+
</TooltipPrimitive.Popup>
|
|
79
|
+
</TooltipPrimitive.Positioner>
|
|
80
|
+
</GroupScaleReset>
|
|
81
|
+
</TooltipPrimitive.Portal>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const TooltipProvider = TooltipPrimitive.Provider;
|
|
86
|
+
|
|
87
|
+
export interface TooltipProps
|
|
88
|
+
extends Omit<TooltipTriggerProps, 'content' | 'children'>,
|
|
89
|
+
Pick<TooltipContentProps, 'side' | 'sideOffset' | 'color'> {
|
|
90
|
+
content: ReactNode;
|
|
91
|
+
children?: ReactElement;
|
|
92
|
+
open?: boolean;
|
|
93
|
+
disabled?: boolean;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const Tooltip = Object.assign(
|
|
97
|
+
function Tooltip({
|
|
98
|
+
ref,
|
|
99
|
+
content,
|
|
100
|
+
children,
|
|
101
|
+
open,
|
|
102
|
+
disabled,
|
|
103
|
+
className,
|
|
104
|
+
sideOffset = 12,
|
|
105
|
+
side,
|
|
106
|
+
color,
|
|
107
|
+
...rest
|
|
108
|
+
}: TooltipProps & {
|
|
109
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
110
|
+
}) {
|
|
111
|
+
return (
|
|
112
|
+
<TooltipPrimitive.Root open={open}>
|
|
113
|
+
{disabled ? (
|
|
114
|
+
children
|
|
115
|
+
) : (
|
|
116
|
+
<TooltipPrimitive.Trigger ref={ref} {...rest} render={children} />
|
|
117
|
+
)}
|
|
118
|
+
<Content
|
|
119
|
+
color={color}
|
|
120
|
+
side={side}
|
|
121
|
+
sideOffset={sideOffset}
|
|
122
|
+
className={className}
|
|
123
|
+
>
|
|
124
|
+
{content}
|
|
125
|
+
</Content>
|
|
126
|
+
</TooltipPrimitive.Root>
|
|
127
|
+
);
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
Trigger: TooltipPrimitive.Trigger,
|
|
131
|
+
Content,
|
|
132
|
+
createHandle: TooltipPrimitive.createHandle,
|
|
133
|
+
},
|
|
134
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export class ValueMonitor<T> extends EventTarget {
|
|
4
|
+
private current: T;
|
|
5
|
+
constructor(initialValue: T) {
|
|
6
|
+
super();
|
|
7
|
+
this.current = initialValue;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
set(value: T) {
|
|
11
|
+
if (this.current !== value) {
|
|
12
|
+
this.current = value;
|
|
13
|
+
this.dispatchEvent(new Event('change'));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get() {
|
|
18
|
+
return this.current;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function useValueMonitor<T>(initialValue: T) {
|
|
23
|
+
const monitor = useState(() => new ValueMonitor<T>(initialValue))[0];
|
|
24
|
+
return monitor;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function useMonitor<T>(
|
|
28
|
+
monitor: ValueMonitor<T>,
|
|
29
|
+
onChange: (value: T) => void,
|
|
30
|
+
) {
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const handleChange = () => {
|
|
33
|
+
onChange(monitor.get());
|
|
34
|
+
};
|
|
35
|
+
monitor.addEventListener('change', handleChange);
|
|
36
|
+
onChange(monitor.get());
|
|
37
|
+
return () => {
|
|
38
|
+
monitor.removeEventListener('change', handleChange);
|
|
39
|
+
};
|
|
40
|
+
}, [monitor, onChange]);
|
|
41
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Rule } from 'unocss';
|
|
2
|
+
|
|
3
|
+
export const clipPathRules: Rule[] = [
|
|
4
|
+
[
|
|
5
|
+
/^clip-(:?path-)?(.+)$/,
|
|
6
|
+
([, path]) => ({
|
|
7
|
+
'clip-path': `url(#${path})`,
|
|
8
|
+
}),
|
|
9
|
+
],
|
|
10
|
+
[
|
|
11
|
+
/^clip-(:?path-)?none$/,
|
|
12
|
+
() => ({
|
|
13
|
+
'clip-path': 'none',
|
|
14
|
+
}),
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
/^clip-(:?path-)?inset-(.+)$/,
|
|
18
|
+
([, value, value2]) => {
|
|
19
|
+
const parts = (value2 || value).split(']-[');
|
|
20
|
+
const unbracketed = parts
|
|
21
|
+
.map((part) => part.trim())
|
|
22
|
+
.map((part) => {
|
|
23
|
+
if (part.startsWith('[') && part.endsWith(']')) {
|
|
24
|
+
return part.slice(1, -1);
|
|
25
|
+
} else if (part.startsWith('[')) {
|
|
26
|
+
return part.slice(1);
|
|
27
|
+
} else if (part.endsWith(']')) {
|
|
28
|
+
return part.slice(0, -1);
|
|
29
|
+
}
|
|
30
|
+
return part;
|
|
31
|
+
})
|
|
32
|
+
.map((part) => part.replace(/_/g, ' '));
|
|
33
|
+
return {
|
|
34
|
+
'clip-path': `inset(${unbracketed.join(' ')})`,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
/^clip-(:?path-)?circle-(.+)$/,
|
|
40
|
+
([, value]) => ({
|
|
41
|
+
'clip-path': `circle(${value})`,
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
];
|
package/src/uno/rules/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { anchorRules } from './anchor.js';
|
|
2
|
+
import { clipPathRules } from './clipPath.js';
|
|
2
3
|
import { colorRules } from './color.js';
|
|
3
4
|
import { overflowRules } from './overflow.js';
|
|
4
5
|
import { shadowRules } from './shadow.js';
|
|
@@ -10,4 +11,5 @@ export const rules = [
|
|
|
10
11
|
...overflowRules,
|
|
11
12
|
...shadowRules,
|
|
12
13
|
...utilRules,
|
|
14
|
+
...clipPathRules,
|
|
13
15
|
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Variant } from 'unocss';
|
|
2
|
+
|
|
3
|
+
export const baseUIVariants: Variant[] = [
|
|
4
|
+
// apply same styles to [data-starting-style] as [data-ending-style]
|
|
5
|
+
(matcher) => {
|
|
6
|
+
if (matcher.startsWith('start-end:')) {
|
|
7
|
+
return {
|
|
8
|
+
matcher: matcher.replace('start-end:', ''),
|
|
9
|
+
selector: (s) => `${s}[data-starting-style], ${s}[data-ending-style]`,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Variant } from 'unocss';
|
|
2
|
+
import { baseUIVariants } from './baseUi.js';
|
|
2
3
|
|
|
3
4
|
export const variants: Variant[] = [
|
|
4
5
|
/** Selects &+&, good for top borders */
|
|
@@ -9,4 +10,6 @@ export const variants: Variant[] = [
|
|
|
9
10
|
selector: (s) => `${s} + ${s}`,
|
|
10
11
|
};
|
|
11
12
|
},
|
|
13
|
+
|
|
14
|
+
...baseUIVariants,
|
|
12
15
|
];
|