@sito/ui 0.3.3 → 0.4.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 +72 -2
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +2 -0
- package/dist/components/ContextMenu/ContextMenuItem.d.ts +2 -0
- package/dist/components/ContextMenu/ContextMenuSeparator.d.ts +2 -0
- package/dist/components/ContextMenu/constants.d.ts +2 -0
- package/dist/components/ContextMenu/index.d.ts +4 -0
- package/dist/components/ContextMenu/types.d.ts +24 -0
- package/dist/components/Dialog/index.d.ts +1 -0
- package/dist/components/IconButton/index.d.ts +1 -0
- package/dist/components/Spinner/Spinner.d.ts +3 -0
- package/dist/components/Spinner/index.d.ts +3 -0
- package/dist/components/Spinner/types.d.ts +4 -0
- package/dist/components/index.d.ts +7 -3
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useContextMenu/index.d.ts +2 -0
- package/dist/hooks/useContextMenu/types.d.ts +8 -0
- package/dist/hooks/useContextMenu/useContextMenu.d.ts +2 -0
- package/dist/main.d.ts +4 -4
- package/dist/styles.css +121 -24
- package/dist/theme.css +21 -4
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +207 -85
- package/package.json +25 -22
package/README.md
CHANGED
|
@@ -20,12 +20,82 @@ import "@sito/ui/theme.css";
|
|
|
20
20
|
## Public API
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
Button,
|
|
25
|
+
BUTTON_COLOR_VARIANTS,
|
|
26
|
+
BUTTON_SIZES,
|
|
27
|
+
BUTTON_VARIANTS,
|
|
28
|
+
ContextMenu,
|
|
29
|
+
ContextMenuItem,
|
|
30
|
+
ContextMenuSeparator,
|
|
31
|
+
Dialog,
|
|
32
|
+
DialogActions,
|
|
33
|
+
DIALOG_INITIAL_FOCUS,
|
|
34
|
+
IconButton,
|
|
35
|
+
ICON_BUTTON_SIZES,
|
|
36
|
+
Spinner,
|
|
37
|
+
useContextMenu,
|
|
38
|
+
useDialog,
|
|
39
|
+
} from "@sito/ui";
|
|
24
40
|
```
|
|
25
41
|
|
|
42
|
+
The runtime constants `BUTTON_COLOR_VARIANTS`, `BUTTON_VARIANTS`,
|
|
43
|
+
`BUTTON_SIZES`, `ICON_BUTTON_SIZES`, and `DIALOG_INITIAL_FOCUS` expose the
|
|
44
|
+
supported values for public component contracts.
|
|
45
|
+
|
|
26
46
|
Exported types include `ButtonProps`, `ButtonSize`, `IconButtonProps`,
|
|
27
47
|
`DialogProps`, `DialogActionsProps`, `DialogState`, `IconButtonSize`, and
|
|
28
|
-
`UseDialogReturn
|
|
48
|
+
`SpinnerProps`, `UseDialogReturn`, plus the corresponding context-menu props and hook return
|
|
49
|
+
types.
|
|
50
|
+
|
|
51
|
+
## Spinner
|
|
52
|
+
|
|
53
|
+
`Spinner` is the shared indeterminate-progress primitive used by `Button`
|
|
54
|
+
loading states and standalone feedback. Provide `label` when the spinner owns
|
|
55
|
+
the accessible loading announcement; omit it when surrounding content already
|
|
56
|
+
provides that context.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
<Spinner label="Loading messages" />
|
|
60
|
+
<Spinner />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Context Menu
|
|
64
|
+
|
|
65
|
+
`ContextMenu` owns viewport clamping, focus restoration, outside dismissal and
|
|
66
|
+
keyboard navigation. Consumers own the menu's actions and wording:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
const menu = useContextMenu<string>();
|
|
70
|
+
|
|
71
|
+
<button
|
|
72
|
+
type="button"
|
|
73
|
+
onContextMenu={(event) => {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
menu.openAt(event.clientX, event.clientY, "item-id");
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
Item
|
|
79
|
+
</button>
|
|
80
|
+
|
|
81
|
+
<ContextMenu
|
|
82
|
+
open={menu.open}
|
|
83
|
+
position={menu.position}
|
|
84
|
+
onClose={menu.close}
|
|
85
|
+
ariaLabel="Item actions"
|
|
86
|
+
>
|
|
87
|
+
<ContextMenuItem onClick={menu.close}>Open</ContextMenuItem>
|
|
88
|
+
<ContextMenuSeparator />
|
|
89
|
+
<ContextMenuItem disabled>Delete</ContextMenuItem>
|
|
90
|
+
</ContextMenu>;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Apps with an existing overlay or hotkey scope can keep dismissal in that layer
|
|
94
|
+
with `closeOnEscape={false}`, `closeOnTab={false}` and
|
|
95
|
+
`closeOnPointerDownOutside={false}`. The component forwards its menu element ref
|
|
96
|
+
for adapters that need compatible positioning or containment checks. Those
|
|
97
|
+
adapters may also use `clampToViewport={false}` when their existing state layer
|
|
98
|
+
already owns clamping.
|
|
29
99
|
|
|
30
100
|
## Button Sizes
|
|
31
101
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ContextMenu } from './ContextMenu';
|
|
2
|
+
export { ContextMenuItem } from './ContextMenuItem';
|
|
3
|
+
export { ContextMenuSeparator } from './ContextMenuSeparator';
|
|
4
|
+
export type { ContextMenuItemProps, ContextMenuPosition, ContextMenuProps, ContextMenuSeparatorProps, } from './types';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type ContextMenuPosition = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
export type ContextMenuProps = {
|
|
7
|
+
open: boolean;
|
|
8
|
+
position: ContextMenuPosition;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
ariaLabel: string;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
portalContainer?: Element | DocumentFragment | null;
|
|
14
|
+
viewportPadding?: number;
|
|
15
|
+
closeOnEscape?: boolean;
|
|
16
|
+
closeOnTab?: boolean;
|
|
17
|
+
closeOnPointerDownOutside?: boolean;
|
|
18
|
+
clampToViewport?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export interface ContextMenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type"> {
|
|
21
|
+
leading?: ReactNode;
|
|
22
|
+
shortcut?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export type ContextMenuSeparatorProps = HTMLAttributes<HTMLDivElement>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { Dialog } from './Dialog';
|
|
2
2
|
export { DialogActions } from './DialogActions';
|
|
3
|
+
export { DIALOG_INITIAL_FOCUS } from './types';
|
|
3
4
|
export type { DialogActionButtonProps, DialogActionsProps, DialogInitialFocus, DialogProps, DialogState, DialogSubmitHandler, } from './types';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export type { ButtonBaseProps, ButtonColor, ButtonProps, ButtonSize, ButtonVariant, } from './Button';
|
|
2
|
-
export { Button } from './Button';
|
|
2
|
+
export { Button, BUTTON_COLOR_VARIANTS, BUTTON_SIZES, BUTTON_VARIANTS, } from './Button';
|
|
3
|
+
export type { ContextMenuItemProps, ContextMenuPosition, ContextMenuProps, ContextMenuSeparatorProps, } from './ContextMenu';
|
|
4
|
+
export { ContextMenu, ContextMenuItem, ContextMenuSeparator, } from './ContextMenu';
|
|
3
5
|
export type { DialogActionButtonProps, DialogActionsProps, DialogInitialFocus, DialogProps, DialogState, DialogSubmitHandler, } from './Dialog';
|
|
4
|
-
export { Dialog, DialogActions } from './Dialog';
|
|
6
|
+
export { Dialog, DialogActions, DIALOG_INITIAL_FOCUS } from './Dialog';
|
|
5
7
|
export type { IconButtonProps, IconButtonSize } from './IconButton';
|
|
6
|
-
export { IconButton } from './IconButton';
|
|
8
|
+
export { IconButton, ICON_BUTTON_SIZES } from './IconButton';
|
|
9
|
+
export type { SpinnerProps } from './Spinner';
|
|
10
|
+
export { Spinner } from './Spinner';
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { ButtonBaseProps, ButtonColor, ButtonProps, ButtonSize, ButtonVariant, DialogActionButtonProps, DialogActionsProps, DialogInitialFocus, DialogProps, DialogState, DialogSubmitHandler, IconButtonProps, IconButtonSize, } from './components';
|
|
2
|
-
export { Button, Dialog, DialogActions, IconButton } from './components';
|
|
3
|
-
export type { UseDialogReturn } from './hooks';
|
|
4
|
-
export { useDialog } from './hooks';
|
|
1
|
+
export type { ButtonBaseProps, ButtonColor, ButtonProps, ButtonSize, ButtonVariant, ContextMenuItemProps, ContextMenuPosition, ContextMenuProps, ContextMenuSeparatorProps, DialogActionButtonProps, DialogActionsProps, DialogInitialFocus, DialogProps, DialogState, DialogSubmitHandler, IconButtonProps, IconButtonSize, SpinnerProps, } from './components';
|
|
2
|
+
export { Button, BUTTON_COLOR_VARIANTS, BUTTON_SIZES, BUTTON_VARIANTS, ContextMenu, ContextMenuItem, ContextMenuSeparator, Dialog, DialogActions, DIALOG_INITIAL_FOCUS, IconButton, ICON_BUTTON_SIZES, Spinner, } from './components';
|
|
3
|
+
export type { UseContextMenuReturn, UseDialogReturn } from './hooks';
|
|
4
|
+
export { useContextMenu, useDialog } from './hooks';
|
package/dist/styles.css
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--sito-ui-color-text: #101010;
|
|
3
|
+
--sito-ui-color-text-muted: #667085;
|
|
3
4
|
--sito-ui-color-surface: #ffffff;
|
|
4
5
|
--sito-ui-color-border: #d9dde4;
|
|
5
6
|
|
|
@@ -56,35 +57,75 @@
|
|
|
56
57
|
--sito-ui-size-icon-button-icon-md: 1.25rem;
|
|
57
58
|
--sito-ui-size-icon-button-icon-lg: 1.5rem;
|
|
58
59
|
--sito-ui-size-icon-button-icon: var(--sito-ui-size-icon-button-icon-md);
|
|
59
|
-
--sito-ui-size-
|
|
60
|
+
--sito-ui-size-spinner: 1em;
|
|
61
|
+
--sito-ui-size-button-spinner: var(--sito-ui-size-spinner);
|
|
62
|
+
--sito-ui-size-context-menu-min-width: 12rem;
|
|
63
|
+
--sito-ui-size-context-menu-max-width: 20rem;
|
|
64
|
+
--sito-ui-size-context-menu-item: 2rem;
|
|
65
|
+
--sito-ui-size-context-menu-leading: 1rem;
|
|
60
66
|
|
|
61
67
|
--sito-ui-radius-pill: 1.5rem;
|
|
62
68
|
--sito-ui-radius-round: 100%;
|
|
63
69
|
--sito-ui-radius-dialog: 1rem;
|
|
70
|
+
--sito-ui-radius-context-menu: 0.5rem;
|
|
71
|
+
--sito-ui-radius-context-menu-item: 0.25rem;
|
|
64
72
|
|
|
65
73
|
--sito-ui-border-width-thin: 1px;
|
|
66
|
-
--sito-ui-
|
|
74
|
+
--sito-ui-spinner-border-width: 2px;
|
|
75
|
+
--sito-ui-button-spinner-border-width: var(--sito-ui-spinner-border-width);
|
|
67
76
|
|
|
68
77
|
--sito-ui-font-weight-semibold: 600;
|
|
69
78
|
--sito-ui-font-size-button: 0.875rem;
|
|
70
79
|
--sito-ui-font-size-dialog-title: 1.25rem;
|
|
80
|
+
--sito-ui-font-size-context-menu-shortcut: 0.75rem;
|
|
71
81
|
--sito-ui-line-height-button: 1.25rem;
|
|
72
82
|
--sito-ui-line-height-dialog-title: 1.75rem;
|
|
73
83
|
|
|
74
84
|
--sito-ui-motion-duration-normal: 300ms;
|
|
75
|
-
--sito-ui-motion-duration-
|
|
76
|
-
--sito-ui-motion-duration-
|
|
85
|
+
--sito-ui-motion-duration-spinner: 600ms;
|
|
86
|
+
--sito-ui-motion-duration-spinner-reduced: 1500ms;
|
|
87
|
+
--sito-ui-motion-duration-spin: var(--sito-ui-motion-duration-spinner);
|
|
88
|
+
--sito-ui-motion-duration-spin-reduced: var(
|
|
89
|
+
--sito-ui-motion-duration-spinner-reduced
|
|
90
|
+
);
|
|
77
91
|
--sito-ui-motion-easing-standard: cubic-bezier(0.4, 0, 0.2, 1);
|
|
78
92
|
|
|
79
93
|
--sito-ui-shadow-dialog: 0 1rem 3rem rgb(16 24 40 / 18%);
|
|
94
|
+
--sito-ui-shadow-context-menu: 0 0.75rem 2rem rgb(16 24 40 / 24%);
|
|
80
95
|
--sito-ui-z-index-dialog: 50;
|
|
96
|
+
--sito-ui-z-index-context-menu: 60;
|
|
81
97
|
|
|
82
98
|
--sito-ui-button-disabled-opacity: 0.6;
|
|
99
|
+
--sito-ui-context-menu-disabled-opacity: 0.5;
|
|
83
100
|
--sito-ui-button-active-scale: 0.97;
|
|
84
101
|
--sito-ui-dialog-backdrop-background: rgb(16 24 40 / 20%);
|
|
85
102
|
--sito-ui-dialog-backdrop-filter: blur(1rem);
|
|
86
103
|
}
|
|
87
104
|
|
|
105
|
+
.sito-ui-spinner {
|
|
106
|
+
display: inline-block;
|
|
107
|
+
width: var(--sito-ui-size-spinner);
|
|
108
|
+
height: var(--sito-ui-size-spinner);
|
|
109
|
+
flex: 0 0 auto;
|
|
110
|
+
border: var(--sito-ui-spinner-border-width) solid currentColor;
|
|
111
|
+
border-right-color: transparent;
|
|
112
|
+
border-radius: var(--sito-ui-radius-round);
|
|
113
|
+
animation: sito-ui-spinner-spin var(--sito-ui-motion-duration-spinner) linear
|
|
114
|
+
infinite;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@media (prefers-reduced-motion: reduce) {
|
|
118
|
+
.sito-ui-spinner {
|
|
119
|
+
animation-duration: var(--sito-ui-motion-duration-spinner-reduced);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@keyframes sito-ui-spinner-spin {
|
|
124
|
+
to {
|
|
125
|
+
transform: rotate(360deg);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
88
129
|
.sito-ui-button {
|
|
89
130
|
--sito-ui-button-text: var(--sito-ui-color-default-text);
|
|
90
131
|
--sito-ui-button-light: var(--sito-ui-color-default-light);
|
|
@@ -236,14 +277,12 @@
|
|
|
236
277
|
}
|
|
237
278
|
|
|
238
279
|
.sito-ui-button__spinner {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
animation: sito-ui-button-spin var(--sito-ui-motion-duration-spin) linear
|
|
246
|
-
infinite;
|
|
280
|
+
--sito-ui-size-spinner: var(--sito-ui-size-button-spinner);
|
|
281
|
+
--sito-ui-spinner-border-width: var(--sito-ui-button-spinner-border-width);
|
|
282
|
+
--sito-ui-motion-duration-spinner: var(--sito-ui-motion-duration-spin);
|
|
283
|
+
--sito-ui-motion-duration-spinner-reduced: var(
|
|
284
|
+
--sito-ui-motion-duration-spin-reduced
|
|
285
|
+
);
|
|
247
286
|
}
|
|
248
287
|
|
|
249
288
|
.sito-ui-button__loading-label {
|
|
@@ -261,18 +300,6 @@
|
|
|
261
300
|
opacity: var(--sito-ui-button-disabled-opacity);
|
|
262
301
|
}
|
|
263
302
|
|
|
264
|
-
@media (prefers-reduced-motion: reduce) {
|
|
265
|
-
.sito-ui-button__spinner {
|
|
266
|
-
animation-duration: var(--sito-ui-motion-duration-spin-reduced);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
@keyframes sito-ui-button-spin {
|
|
271
|
-
to {
|
|
272
|
-
transform: rotate(360deg);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
303
|
.sito-ui-icon-button {
|
|
277
304
|
--sito-ui-icon-button-container-size: var(--sito-ui-size-icon-button-md);
|
|
278
305
|
--sito-ui-icon-button-icon-size: var(--sito-ui-size-icon-button-icon);
|
|
@@ -402,3 +429,73 @@
|
|
|
402
429
|
}
|
|
403
430
|
}
|
|
404
431
|
|
|
432
|
+
.sito-ui-context-menu {
|
|
433
|
+
position: fixed;
|
|
434
|
+
z-index: var(--sito-ui-z-index-context-menu);
|
|
435
|
+
display: grid;
|
|
436
|
+
min-width: var(--sito-ui-size-context-menu-min-width);
|
|
437
|
+
max-width: var(--sito-ui-size-context-menu-max-width);
|
|
438
|
+
max-height: calc(100vh - var(--sito-ui-space-4));
|
|
439
|
+
overflow: auto;
|
|
440
|
+
padding: var(--sito-ui-space-1);
|
|
441
|
+
border: var(--sito-ui-border-width-thin) solid var(--sito-ui-color-border);
|
|
442
|
+
border-radius: var(--sito-ui-radius-context-menu);
|
|
443
|
+
color: var(--sito-ui-color-text);
|
|
444
|
+
background: var(--sito-ui-color-surface);
|
|
445
|
+
box-shadow: var(--sito-ui-shadow-context-menu);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.sito-ui-context-menu__item {
|
|
449
|
+
display: grid;
|
|
450
|
+
grid-template-columns:
|
|
451
|
+
var(--sito-ui-size-context-menu-leading)
|
|
452
|
+
minmax(0, 1fr)
|
|
453
|
+
auto;
|
|
454
|
+
align-items: center;
|
|
455
|
+
gap: var(--sito-ui-space-2);
|
|
456
|
+
width: 100%;
|
|
457
|
+
min-height: var(--sito-ui-size-context-menu-item);
|
|
458
|
+
padding: var(--sito-ui-space-1) var(--sito-ui-space-2);
|
|
459
|
+
border: 0;
|
|
460
|
+
border-radius: var(--sito-ui-radius-context-menu-item);
|
|
461
|
+
color: inherit;
|
|
462
|
+
background: transparent;
|
|
463
|
+
font: inherit;
|
|
464
|
+
text-align: left;
|
|
465
|
+
cursor: default;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.sito-ui-context-menu__item:hover:not(:disabled),
|
|
469
|
+
.sito-ui-context-menu__item:focus-visible {
|
|
470
|
+
outline: none;
|
|
471
|
+
background: var(--sito-ui-color-primary-light);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
.sito-ui-context-menu__item:disabled {
|
|
475
|
+
opacity: var(--sito-ui-context-menu-disabled-opacity);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
.sito-ui-context-menu__leading {
|
|
479
|
+
display: grid;
|
|
480
|
+
place-items: center;
|
|
481
|
+
color: var(--sito-ui-color-text);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.sito-ui-context-menu__label {
|
|
485
|
+
overflow: hidden;
|
|
486
|
+
text-overflow: ellipsis;
|
|
487
|
+
white-space: nowrap;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
.sito-ui-context-menu__shortcut {
|
|
491
|
+
color: var(--sito-ui-color-text-muted);
|
|
492
|
+
font-size: var(--sito-ui-font-size-context-menu-shortcut);
|
|
493
|
+
white-space: nowrap;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.sito-ui-context-menu__separator {
|
|
497
|
+
height: var(--sito-ui-border-width-thin);
|
|
498
|
+
margin: var(--sito-ui-space-1);
|
|
499
|
+
background: var(--sito-ui-color-border);
|
|
500
|
+
}
|
|
501
|
+
|
package/dist/theme.css
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--sito-ui-color-text: #101010;
|
|
3
|
+
--sito-ui-color-text-muted: #667085;
|
|
3
4
|
--sito-ui-color-surface: #ffffff;
|
|
4
5
|
--sito-ui-color-border: #d9dde4;
|
|
5
6
|
|
|
@@ -56,30 +57,46 @@
|
|
|
56
57
|
--sito-ui-size-icon-button-icon-md: 1.25rem;
|
|
57
58
|
--sito-ui-size-icon-button-icon-lg: 1.5rem;
|
|
58
59
|
--sito-ui-size-icon-button-icon: var(--sito-ui-size-icon-button-icon-md);
|
|
59
|
-
--sito-ui-size-
|
|
60
|
+
--sito-ui-size-spinner: 1em;
|
|
61
|
+
--sito-ui-size-button-spinner: var(--sito-ui-size-spinner);
|
|
62
|
+
--sito-ui-size-context-menu-min-width: 12rem;
|
|
63
|
+
--sito-ui-size-context-menu-max-width: 20rem;
|
|
64
|
+
--sito-ui-size-context-menu-item: 2rem;
|
|
65
|
+
--sito-ui-size-context-menu-leading: 1rem;
|
|
60
66
|
|
|
61
67
|
--sito-ui-radius-pill: 1.5rem;
|
|
62
68
|
--sito-ui-radius-round: 100%;
|
|
63
69
|
--sito-ui-radius-dialog: 1rem;
|
|
70
|
+
--sito-ui-radius-context-menu: 0.5rem;
|
|
71
|
+
--sito-ui-radius-context-menu-item: 0.25rem;
|
|
64
72
|
|
|
65
73
|
--sito-ui-border-width-thin: 1px;
|
|
66
|
-
--sito-ui-
|
|
74
|
+
--sito-ui-spinner-border-width: 2px;
|
|
75
|
+
--sito-ui-button-spinner-border-width: var(--sito-ui-spinner-border-width);
|
|
67
76
|
|
|
68
77
|
--sito-ui-font-weight-semibold: 600;
|
|
69
78
|
--sito-ui-font-size-button: 0.875rem;
|
|
70
79
|
--sito-ui-font-size-dialog-title: 1.25rem;
|
|
80
|
+
--sito-ui-font-size-context-menu-shortcut: 0.75rem;
|
|
71
81
|
--sito-ui-line-height-button: 1.25rem;
|
|
72
82
|
--sito-ui-line-height-dialog-title: 1.75rem;
|
|
73
83
|
|
|
74
84
|
--sito-ui-motion-duration-normal: 300ms;
|
|
75
|
-
--sito-ui-motion-duration-
|
|
76
|
-
--sito-ui-motion-duration-
|
|
85
|
+
--sito-ui-motion-duration-spinner: 600ms;
|
|
86
|
+
--sito-ui-motion-duration-spinner-reduced: 1500ms;
|
|
87
|
+
--sito-ui-motion-duration-spin: var(--sito-ui-motion-duration-spinner);
|
|
88
|
+
--sito-ui-motion-duration-spin-reduced: var(
|
|
89
|
+
--sito-ui-motion-duration-spinner-reduced
|
|
90
|
+
);
|
|
77
91
|
--sito-ui-motion-easing-standard: cubic-bezier(0.4, 0, 0.2, 1);
|
|
78
92
|
|
|
79
93
|
--sito-ui-shadow-dialog: 0 1rem 3rem rgb(16 24 40 / 18%);
|
|
94
|
+
--sito-ui-shadow-context-menu: 0 0.75rem 2rem rgb(16 24 40 / 24%);
|
|
80
95
|
--sito-ui-z-index-dialog: 50;
|
|
96
|
+
--sito-ui-z-index-context-menu: 60;
|
|
81
97
|
|
|
82
98
|
--sito-ui-button-disabled-opacity: 0.6;
|
|
99
|
+
--sito-ui-context-menu-disabled-opacity: 0.5;
|
|
83
100
|
--sito-ui-button-active-scale: 0.97;
|
|
84
101
|
--sito-ui-dialog-backdrop-background: rgb(16 24 40 / 20%);
|
|
85
102
|
--sito-ui-dialog-backdrop-filter: blur(1rem);
|
package/dist/ui.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react/jsx-runtime"),n=require("react-dom");var r=(...e)=>e.filter(Boolean).join(` `),i={DEFAULT:`default`,PRIMARY:`primary`,SECONDARY:`secondary`,ERROR:`error`,WARNING:`warning`,SUCCESS:`success`,INFO:`info`},a={TEXT:`text`,SUBMIT:`submit`,OUTLINED:`outlined`},o={SM:`sm`,MD:`md`,LG:`lg`},s=(0,e.forwardRef)(function(e,n){let{color:s=i.DEFAULT,size:c=o.MD,type:l=`button`,variant:u=a.TEXT,loading:d=!1,loadingIndicator:f,loadingLabel:p=`Loading`,disabled:m,className:h,children:g,..._}=e,v=r(`sito-ui-button`,`sito-ui-button--${u}`,`sito-ui-button--${s}`,`sito-ui-button--${c}`,d&&`sito-ui-button--loading`,h),y=f===void 0?(0,t.jsx)(`span`,{className:`sito-ui-button__spinner`,"aria-hidden":`true`,"data-sito-ui":`button-spinner`}):f;return(0,t.jsxs)(`button`,{"data-sito-ui":`button`,..._,type:l,ref:n,disabled:m||d,"aria-busy":d||_[`aria-busy`],className:v,children:[d?(0,t.jsxs)(t.Fragment,{children:[y,(0,t.jsx)(`span`,{className:`sito-ui-button__loading-label`,children:p})]}):null,g]})}),c={SM:`sm`,MD:`md`,LG:`lg`},l=e=>{if(e!==void 0)return typeof e==`number`?`${e}px`:e},u=(0,e.forwardRef)(function(e,n){let{children:i,icon:a,iconClassName:o,type:u=`button`,variant:d=`text`,color:f=`default`,loading:p=!1,size:m=c.MD,iconSize:h,className:g,style:_,...v}=e,y=i!=null&&typeof i!=`boolean`,b=l(h),x=b===void 0?_:{..._,"--sito-ui-icon-button-icon-size":b},S=r(`sito-ui-icon-button`,`sito-ui-icon-button--${m}`,y&&`sito-ui-icon-button--with-content`,g);return(0,t.jsxs)(s,{...v,ref:n,type:u,variant:d,color:f,size:m,loading:p,"data-sito-ui":`icon-button`,className:S,style:x,children:[p?null:(0,t.jsx)(`span`,{className:r(`sito-ui-icon-button__icon`,o),"aria-hidden":`true`,children:a}),i]})}),d=`input:not([type="hidden"]):not([disabled]), textarea:not([disabled]), select:not([disabled])`,f=`button[type="submit"]:not([disabled]), input[type="submit"]:not([disabled])`,p=[`a[href]`,`button:not([disabled])`,`textarea:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`),m=0,h=null,g=[],_=()=>typeof document<`u`&&!!document.body,v=()=>{_()&&(m===0&&(h=document.body.style.overflow,document.body.style.overflow=`hidden`),m+=1)},y=()=>{!_()||m===0||(--m,m===0&&(document.body.style.overflow=h??``,h=null))},b=e=>Array.from(e.querySelectorAll(p)).filter(e=>e.getAttribute(`aria-disabled`)!==`true`),x=()=>typeof document>`u`?null:document.activeElement instanceof HTMLElement?document.activeElement:null,S=e=>{let t=g.indexOf(e);t>=0&&g.splice(t,1),g.push(e)},ee=e=>{let t=g.indexOf(e);t>=0&&g.splice(t,1)},C=e=>g[g.length-1]===e,w=typeof window>`u`?e.useEffect:e.useLayoutEffect,T=i=>{let a=(0,e.useId)(),o=(0,e.useRef)(Symbol(`sito-ui-dialog`)),s=(0,e.useRef)(null),c=(0,e.useRef)(null),l=(0,e.useRef)(null),p=(0,e.useRef)(void 0),{dialogId:m,title:h,ariaLabel:g,children:_,onClose:T,initialFocus:E=`none`,closeOnBackdropClick:D=!1,closeOnEscape:O=!0,lockBodyScroll:k=!0,onSubmit:A,open:j=!1,mobileFullScreen:M=!1,containerClassName:N,className:P,headerClassName:F,titleClassName:I,closeButtonClassName:L,closeLabel:R=`Close dialog`,closeIcon:z=`x`,showCloseButton:B=!0,portalContainer:te,exitDurationMs:V=0,onExitComplete:H}=i,[U,W]=(0,e.useState)(j),[G,K]=(0,e.useState)(!1),q=h?`${m??a}-title`:void 0,J=G?`closing`:`open`,Y=j&&!G,X=o.current;(0,e.useEffect)(()=>{p.current=H},[H]);let Z=(0,e.useCallback)(()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},[]),Q=(0,e.useCallback)(()=>{W(!1),K(!1),p.current?.(),l.current=null},[]);w(()=>{if(j){Z(),W(!0),K(!1);return}if(!U)return;let e=Math.max(0,V);if(e===0){Z(),Q();return}K(!0),Z(),l.current=window.setTimeout(Q,e)},[Z,V,Q,j,U]),(0,e.useEffect)(()=>()=>{Z()},[Z]);let $=(0,e.useCallback)(e=>{if(!C(X))return;if(e.key===`Escape`&&Y&&O){T();return}if(e.key!==`Tab`||!Y)return;let t=s.current;if(!t)return;let n=b(t);if(n.length===0){e.preventDefault(),t.focus();return}let r=n[0],i=n[n.length-1],a=x(),o=!a||!t.contains(a);if(e.shiftKey&&(o||a===r)){e.preventDefault(),i.focus();return}!e.shiftKey&&(o||a===i)&&(e.preventDefault(),r.focus())},[O,X,Y,T]);(0,e.useEffect)(()=>{if(!(!Y||typeof window>`u`))return window.addEventListener(`keydown`,$),()=>{window.removeEventListener(`keydown`,$)}},[$,Y]),w(()=>{if(j)return c.current=x(),S(X),()=>{let e=C(X);ee(X),e&&c.current?.isConnected&&c.current.focus(),c.current=null}},[X,j]),w(()=>{if(!j)return;let e=s.current;if(e){if(E===`first-input`){let t=e.querySelector(d);if(t){t.focus();return}}if(E===`submit`){let t=e.querySelector(f);if(t){t.focus();return}}e.focus()}},[E,j]),(0,e.useEffect)(()=>{if(!(!U||!k))return v(),()=>{y()}},[k,U]);let ne=(0,e.useCallback)(e=>{C(X)&&Y&&D&&e.target===e.currentTarget&&T()},[D,X,Y,T]),re=(0,e.useCallback)(e=>{e.preventDefault(),A?.(e)},[A]);if(!U||typeof document>`u`)return null;let ie=A?(0,t.jsx)(`form`,{onSubmit:re,children:_}):_,ae=typeof z==`string`?(0,t.jsx)(`span`,{"aria-hidden":`true`,children:z}):z;return(0,n.createPortal)((0,t.jsx)(`div`,{id:m?`backdrop-${m}`:void 0,"data-sito-ui":`dialog-backdrop`,"data-state":J,onClick:ne,className:r(`sito-ui-dialog-backdrop`,`sito-ui-dialog-backdrop--${J}`,N),children:(0,t.jsxs)(`div`,{id:m,ref:s,role:`dialog`,"aria-modal":`true`,"aria-label":h?void 0:g,"aria-labelledby":q,tabIndex:-1,"data-sito-ui":`dialog`,"data-state":J,className:r(`sito-ui-dialog`,`sito-ui-dialog--${J}`,M&&`sito-ui-dialog--mobile-full-screen`,P),children:[(0,t.jsxs)(`div`,{className:r(`sito-ui-dialog__header`,F),children:[h?(0,t.jsx)(`h3`,{id:q,className:r(`sito-ui-dialog__title`,I),children:h}):null,B?(0,t.jsx)(u,{icon:ae,disabled:!Y,"aria-disabled":!Y,onClick:T,variant:`text`,color:`error`,className:r(`sito-ui-dialog__close`,L),"aria-label":R}):null]}),ie]})}),te??document.body)},E=e=>{let{primaryText:n,cancelText:i,onPrimaryClick:a,onCancel:o,isLoading:c=!1,loadingIndicator:l,disabled:u=!1,primaryType:d=`submit`,containerClassName:f,primaryClassName:p,cancelClassName:m,alignEnd:h=!1,primaryName:g,primaryAriaLabel:_,cancelName:v,cancelAriaLabel:y,extraActions:b=[]}=e;return(0,t.jsxs)(`div`,{"data-sito-ui":`dialog-actions`,className:r(`sito-ui-dialog-actions`,h&&`sito-ui-dialog-actions--end`,f),children:[(0,t.jsx)(s,{type:d,color:`primary`,variant:`submit`,className:p,disabled:u,loading:c,loadingIndicator:l,onClick:a,name:g,"aria-label":_,children:n}),b.map(({id:e,...n})=>(0,t.jsx)(s,{...n},e)),(0,t.jsx)(s,{type:`button`,variant:`outlined`,className:m,disabled:u||c,onClick:o,name:v,"aria-label":y,children:i})]})},D=(t=!1)=>{let[n,r]=(0,e.useState)(t);return{open:n,setOpen:r,handleClose:()=>r(!1),handleOpen:()=>r(!0)}};exports.Button=s,exports.Dialog=T,exports.DialogActions=E,exports.IconButton=u,exports.useDialog=D;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react/jsx-runtime"),n=require("react-dom");var r=(...e)=>e.filter(Boolean).join(` `),i=(0,e.forwardRef)(function(e,n){let{className:i,label:a,...o}=e,s=a!==void 0;return(0,t.jsx)(`span`,{"data-sito-ui":`spinner`,...o,ref:n,"aria-hidden":!s||void 0,"aria-label":a,role:s?`status`:void 0,className:r(`sito-ui-spinner`,i)})}),a={DEFAULT:`default`,PRIMARY:`primary`,SECONDARY:`secondary`,ERROR:`error`,WARNING:`warning`,SUCCESS:`success`,INFO:`info`},o={TEXT:`text`,SUBMIT:`submit`,OUTLINED:`outlined`},s={SM:`sm`,MD:`md`,LG:`lg`},c=(0,e.forwardRef)(function(e,n){let{color:c=a.DEFAULT,size:l=s.MD,type:u=`button`,variant:d=o.TEXT,loading:f=!1,loadingIndicator:p,loadingLabel:m=`Loading`,disabled:h,className:g,children:_,...v}=e,y=r(`sito-ui-button`,`sito-ui-button--${d}`,`sito-ui-button--${c}`,`sito-ui-button--${l}`,f&&`sito-ui-button--loading`,g),b=p===void 0?(0,t.jsx)(i,{className:`sito-ui-button__spinner`,"data-sito-ui":`button-spinner`}):p;return(0,t.jsxs)(`button`,{"data-sito-ui":`button`,...v,type:u,ref:n,disabled:h||f,"aria-busy":f||v[`aria-busy`],className:y,children:[f?(0,t.jsxs)(t.Fragment,{children:[b,(0,t.jsx)(`span`,{className:`sito-ui-button__loading-label`,children:m})]}):null,_]})}),l=typeof window>`u`?e.useEffect:e.useLayoutEffect,u=(0,e.forwardRef)(function({open:i,position:a,onClose:o,ariaLabel:s,children:c,className:u,portalContainer:d,viewportPadding:f=8,closeOnEscape:p=!0,closeOnTab:m=!0,closeOnPointerDownOutside:h=!0,clampToViewport:g=!0},_){let v=(0,e.useRef)(null),y=(0,e.useRef)(null),b=(0,e.useCallback)(e=>{v.current=e,typeof _==`function`?_(e):_&&(_.current=e)},[_]);return l(()=>{if(i)return y.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(v.current?.querySelector(`[role="menuitem"]:not([disabled])`)??v.current)?.focus(),()=>{y.current?.isConnected&&y.current.focus(),y.current=null}},[i]),l(()=>{let e=v.current;if(!i||!e||!g)return;let t=window.innerWidth-e.offsetWidth-f,n=window.innerHeight-e.offsetHeight-f,r=Math.max(f,Math.min(a.x,t)),o=Math.max(f,Math.min(a.y,n));e.style.left=`${r}px`,e.style.top=`${o}px`},[g,i,a.x,a.y,f]),(0,e.useEffect)(()=>{if(!i||!h)return;let e=e=>{let t=e.target;(!(t instanceof Node)||!v.current?.contains(t))&&o()};return document.addEventListener(`pointerdown`,e),()=>{document.removeEventListener(`pointerdown`,e)}},[h,o,i]),!i||typeof document>`u`?null:(0,n.createPortal)((0,t.jsx)(`div`,{ref:b,role:`menu`,tabIndex:-1,"aria-label":s,"aria-orientation":`vertical`,"data-sito-ui":`context-menu`,"data-state":`open`,className:r(`sito-ui-context-menu`,u),style:{left:a.x,top:a.y},onContextMenu:e=>e.preventDefault(),onKeyDown:e=>{let t=e.key===`Escape`&&p,n=e.key===`Tab`&&m;if(t||n){e.preventDefault(),e.stopPropagation(),o();return}let r=Array.from(v.current?.querySelectorAll(`[role="menuitem"]:not([disabled])`)??[]);if(r.length===0)return;let i=document.activeElement,a=i instanceof HTMLElement?r.indexOf(i):-1,s=null;e.key===`ArrowDown`?s=(a+1+r.length)%r.length:e.key===`ArrowUp`?s=(a-1+r.length)%r.length:e.key===`Home`?s=0:e.key===`End`&&(s=r.length-1),s!==null&&(e.preventDefault(),r[s]?.focus())},children:c}),d??document.body)}),d=(0,e.forwardRef)(function({leading:e,shortcut:n,children:i,className:a,disabled:o,...s},c){return(0,t.jsxs)(`button`,{...s,ref:c,type:`button`,role:`menuitem`,tabIndex:-1,disabled:o,"data-sito-ui":`context-menu-item`,className:r(`sito-ui-context-menu__item`,a),children:[(0,t.jsx)(`span`,{className:`sito-ui-context-menu__leading`,"aria-hidden":`true`,children:e}),(0,t.jsx)(`span`,{className:`sito-ui-context-menu__label`,children:i}),n?(0,t.jsx)(`span`,{className:`sito-ui-context-menu__shortcut`,"aria-hidden":`true`,children:n}):null]})}),f=({className:e,...n})=>(0,t.jsx)(`div`,{...n,role:`separator`,"data-sito-ui":`context-menu-separator`,className:r(`sito-ui-context-menu__separator`,e)}),p={SM:`sm`,MD:`md`,LG:`lg`},m=e=>{if(e!==void 0)return typeof e==`number`?`${e}px`:e},h=(0,e.forwardRef)(function(e,n){let{children:i,icon:a,iconClassName:o,type:s=`button`,variant:l=`text`,color:u=`default`,loading:d=!1,size:f=p.MD,iconSize:h,className:g,style:_,...v}=e,y=i!=null&&typeof i!=`boolean`,b=m(h),x=b===void 0?_:{..._,"--sito-ui-icon-button-icon-size":b},S=r(`sito-ui-icon-button`,`sito-ui-icon-button--${f}`,y&&`sito-ui-icon-button--with-content`,g);return(0,t.jsxs)(c,{...v,ref:n,type:s,variant:l,color:u,size:f,loading:d,"data-sito-ui":`icon-button`,className:S,style:x,children:[d?null:(0,t.jsx)(`span`,{className:r(`sito-ui-icon-button__icon`,o),"aria-hidden":`true`,children:a}),i]})}),g=`input:not([type="hidden"]):not([disabled]), textarea:not([disabled]), select:not([disabled])`,_=`button[type="submit"]:not([disabled]), input[type="submit"]:not([disabled])`,v=[`a[href]`,`button:not([disabled])`,`textarea:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`),y=0,b=null,x=[],S=()=>typeof document<`u`&&!!document.body,C=()=>{S()&&(y===0&&(b=document.body.style.overflow,document.body.style.overflow=`hidden`),y+=1)},ee=()=>{!S()||y===0||(--y,y===0&&(document.body.style.overflow=b??``,b=null))},te=e=>Array.from(e.querySelectorAll(v)).filter(e=>e.getAttribute(`aria-disabled`)!==`true`),w=()=>typeof document>`u`?null:document.activeElement instanceof HTMLElement?document.activeElement:null,T=e=>{let t=x.indexOf(e);t>=0&&x.splice(t,1),x.push(e)},E=e=>{let t=x.indexOf(e);t>=0&&x.splice(t,1)},D=e=>x[x.length-1]===e,O=typeof window>`u`?e.useEffect:e.useLayoutEffect,k=i=>{let a=(0,e.useId)(),o=(0,e.useRef)(Symbol(`sito-ui-dialog`)),s=(0,e.useRef)(null),c=(0,e.useRef)(null),l=(0,e.useRef)(null),u=(0,e.useRef)(void 0),{dialogId:d,title:f,ariaLabel:p,children:m,onClose:v,initialFocus:y=`none`,closeOnBackdropClick:b=!1,closeOnEscape:x=!0,lockBodyScroll:S=!0,onSubmit:k,open:A=!1,mobileFullScreen:j=!1,containerClassName:M,className:N,headerClassName:P,titleClassName:F,closeButtonClassName:I,closeLabel:L=`Close dialog`,closeIcon:R=`x`,showCloseButton:z=!0,portalContainer:B,exitDurationMs:V=0,onExitComplete:H}=i,[U,W]=(0,e.useState)(A),[G,K]=(0,e.useState)(!1),q=f?`${d??a}-title`:void 0,J=G?`closing`:`open`,Y=A&&!G,X=o.current;(0,e.useEffect)(()=>{u.current=H},[H]);let Z=(0,e.useCallback)(()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},[]),Q=(0,e.useCallback)(()=>{W(!1),K(!1),u.current?.(),l.current=null},[]);O(()=>{if(A){Z(),W(!0),K(!1);return}if(!U)return;let e=Math.max(0,V);if(e===0){Z(),Q();return}K(!0),Z(),l.current=window.setTimeout(Q,e)},[Z,V,Q,A,U]),(0,e.useEffect)(()=>()=>{Z()},[Z]);let $=(0,e.useCallback)(e=>{if(!D(X))return;if(e.key===`Escape`&&Y&&x){v();return}if(e.key!==`Tab`||!Y)return;let t=s.current;if(!t)return;let n=te(t);if(n.length===0){e.preventDefault(),t.focus();return}let r=n[0],i=n[n.length-1],a=w(),o=!a||!t.contains(a);if(e.shiftKey&&(o||a===r)){e.preventDefault(),i.focus();return}!e.shiftKey&&(o||a===i)&&(e.preventDefault(),r.focus())},[x,X,Y,v]);(0,e.useEffect)(()=>{if(!(!Y||typeof window>`u`))return window.addEventListener(`keydown`,$),()=>{window.removeEventListener(`keydown`,$)}},[$,Y]),O(()=>{if(A)return c.current=w(),T(X),()=>{let e=D(X);E(X),e&&c.current?.isConnected&&c.current.focus(),c.current=null}},[X,A]),O(()=>{if(!A)return;let e=s.current;if(e){if(y===`first-input`){let t=e.querySelector(g);if(t){t.focus();return}}if(y===`submit`){let t=e.querySelector(_);if(t){t.focus();return}}e.focus()}},[y,A]),(0,e.useEffect)(()=>{if(!(!U||!S))return C(),()=>{ee()}},[S,U]);let ne=(0,e.useCallback)(e=>{D(X)&&Y&&b&&e.target===e.currentTarget&&v()},[b,X,Y,v]),re=(0,e.useCallback)(e=>{e.preventDefault(),k?.(e)},[k]);if(!U||typeof document>`u`)return null;let ie=k?(0,t.jsx)(`form`,{onSubmit:re,children:m}):m,ae=typeof R==`string`?(0,t.jsx)(`span`,{"aria-hidden":`true`,children:R}):R;return(0,n.createPortal)((0,t.jsx)(`div`,{id:d?`backdrop-${d}`:void 0,"data-sito-ui":`dialog-backdrop`,"data-state":J,onClick:ne,className:r(`sito-ui-dialog-backdrop`,`sito-ui-dialog-backdrop--${J}`,M),children:(0,t.jsxs)(`div`,{id:d,ref:s,role:`dialog`,"aria-modal":`true`,"aria-label":f?void 0:p,"aria-labelledby":q,tabIndex:-1,"data-sito-ui":`dialog`,"data-state":J,className:r(`sito-ui-dialog`,`sito-ui-dialog--${J}`,j&&`sito-ui-dialog--mobile-full-screen`,N),children:[(0,t.jsxs)(`div`,{className:r(`sito-ui-dialog__header`,P),children:[f?(0,t.jsx)(`h3`,{id:q,className:r(`sito-ui-dialog__title`,F),children:f}):null,z?(0,t.jsx)(h,{icon:ae,disabled:!Y,"aria-disabled":!Y,onClick:v,variant:`text`,color:`error`,className:r(`sito-ui-dialog__close`,I),"aria-label":L}):null]}),ie]})}),B??document.body)},A=e=>{let{primaryText:n,cancelText:i,onPrimaryClick:a,onCancel:o,isLoading:s=!1,loadingIndicator:l,disabled:u=!1,primaryType:d=`submit`,containerClassName:f,primaryClassName:p,cancelClassName:m,alignEnd:h=!1,primaryName:g,primaryAriaLabel:_,cancelName:v,cancelAriaLabel:y,extraActions:b=[]}=e;return(0,t.jsxs)(`div`,{"data-sito-ui":`dialog-actions`,className:r(`sito-ui-dialog-actions`,h&&`sito-ui-dialog-actions--end`,f),children:[(0,t.jsx)(c,{type:d,color:`primary`,variant:`submit`,className:p,disabled:u,loading:s,loadingIndicator:l,onClick:a,name:g,"aria-label":_,children:n}),b.map(({id:e,...n})=>(0,t.jsx)(c,{...n},e)),(0,t.jsx)(c,{type:`button`,variant:`outlined`,className:m,disabled:u||s,onClick:o,name:v,"aria-label":y,children:i})]})},j={NONE:`none`,FIRST_INPUT:`first-input`,SUBMIT:`submit`},M=(t=!1)=>{let[n,r]=(0,e.useState)(t);return{open:n,setOpen:r,handleClose:()=>r(!1),handleOpen:()=>r(!0)}},N={x:0,y:0},P=()=>{let[t,n]=(0,e.useState)(!1),[r,i]=(0,e.useState)(null),[a,o]=(0,e.useState)(N);return{open:t,payload:r,position:a,openAt:(0,e.useCallback)((e,t,r)=>{i(r),o({x:e,y:t}),n(!0)},[]),close:(0,e.useCallback)(()=>n(!1),[])}};exports.BUTTON_COLOR_VARIANTS=a,exports.BUTTON_SIZES=s,exports.BUTTON_VARIANTS=o,exports.Button=c,exports.ContextMenu=u,exports.ContextMenuItem=d,exports.ContextMenuSeparator=f,exports.DIALOG_INITIAL_FOCUS=j,exports.Dialog=k,exports.DialogActions=A,exports.ICON_BUTTON_SIZES=p,exports.IconButton=h,exports.Spinner=i,exports.useContextMenu=P,exports.useDialog=M;
|
package/dist/ui.js
CHANGED
|
@@ -2,7 +2,18 @@ import { forwardRef as e, useCallback as t, useEffect as n, useId as r, useLayou
|
|
|
2
2
|
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
3
3
|
import { createPortal as u } from "react-dom";
|
|
4
4
|
//#region src/utils/classNames.ts
|
|
5
|
-
var d = (...e) => e.filter(Boolean).join(" "), f = {
|
|
5
|
+
var d = (...e) => e.filter(Boolean).join(" "), f = e(function(e, t) {
|
|
6
|
+
let { className: n, label: r, ...i } = e, a = r !== void 0;
|
|
7
|
+
return /* @__PURE__ */ c("span", {
|
|
8
|
+
"data-sito-ui": "spinner",
|
|
9
|
+
...i,
|
|
10
|
+
ref: t,
|
|
11
|
+
"aria-hidden": !a || void 0,
|
|
12
|
+
"aria-label": r,
|
|
13
|
+
role: a ? "status" : void 0,
|
|
14
|
+
className: d("sito-ui-spinner", n)
|
|
15
|
+
});
|
|
16
|
+
}), p = {
|
|
6
17
|
DEFAULT: "default",
|
|
7
18
|
PRIMARY: "primary",
|
|
8
19
|
SECONDARY: "secondary",
|
|
@@ -10,46 +21,136 @@ var d = (...e) => e.filter(Boolean).join(" "), f = {
|
|
|
10
21
|
WARNING: "warning",
|
|
11
22
|
SUCCESS: "success",
|
|
12
23
|
INFO: "info"
|
|
13
|
-
},
|
|
24
|
+
}, m = {
|
|
14
25
|
TEXT: "text",
|
|
15
26
|
SUBMIT: "submit",
|
|
16
27
|
OUTLINED: "outlined"
|
|
17
|
-
},
|
|
28
|
+
}, h = {
|
|
18
29
|
SM: "sm",
|
|
19
30
|
MD: "md",
|
|
20
31
|
LG: "lg"
|
|
21
|
-
},
|
|
22
|
-
let { color: n =
|
|
32
|
+
}, g = e(function(e, t) {
|
|
33
|
+
let { color: n = p.DEFAULT, size: r = h.MD, type: i = "button", variant: a = m.TEXT, loading: o = !1, loadingIndicator: u, loadingLabel: g = "Loading", disabled: _, className: v, children: y, ...b } = e, x = d("sito-ui-button", `sito-ui-button--${a}`, `sito-ui-button--${n}`, `sito-ui-button--${r}`, o && "sito-ui-button--loading", v), S = u === void 0 ? /* @__PURE__ */ c(f, {
|
|
23
34
|
className: "sito-ui-button__spinner",
|
|
24
|
-
"aria-hidden": "true",
|
|
25
35
|
"data-sito-ui": "button-spinner"
|
|
26
36
|
}) : u;
|
|
27
37
|
return /* @__PURE__ */ l("button", {
|
|
28
38
|
"data-sito-ui": "button",
|
|
29
|
-
...
|
|
39
|
+
...b,
|
|
30
40
|
type: i,
|
|
31
41
|
ref: t,
|
|
32
|
-
disabled:
|
|
33
|
-
"aria-busy": o ||
|
|
34
|
-
className:
|
|
35
|
-
children: [o ? /* @__PURE__ */ l(s, { children: [
|
|
42
|
+
disabled: _ || o,
|
|
43
|
+
"aria-busy": o || b["aria-busy"],
|
|
44
|
+
className: x,
|
|
45
|
+
children: [o ? /* @__PURE__ */ l(s, { children: [S, /* @__PURE__ */ c("span", {
|
|
36
46
|
className: "sito-ui-button__loading-label",
|
|
37
|
-
children:
|
|
38
|
-
})] }) : null,
|
|
47
|
+
children: g
|
|
48
|
+
})] }) : null, y]
|
|
39
49
|
});
|
|
40
|
-
}), g = {
|
|
50
|
+
}), _ = typeof window > "u" ? n : i, v = e(function({ open: e, position: r, onClose: i, ariaLabel: o, children: s, className: l, portalContainer: f, viewportPadding: p = 8, closeOnEscape: m = !0, closeOnTab: h = !0, closeOnPointerDownOutside: g = !0, clampToViewport: v = !0 }, y) {
|
|
51
|
+
let b = a(null), x = a(null), S = t((e) => {
|
|
52
|
+
b.current = e, typeof y == "function" ? y(e) : y && (y.current = e);
|
|
53
|
+
}, [y]);
|
|
54
|
+
return _(() => {
|
|
55
|
+
if (e) return x.current = document.activeElement instanceof HTMLElement ? document.activeElement : null, (b.current?.querySelector("[role=\"menuitem\"]:not([disabled])") ?? b.current)?.focus(), () => {
|
|
56
|
+
x.current?.isConnected && x.current.focus(), x.current = null;
|
|
57
|
+
};
|
|
58
|
+
}, [e]), _(() => {
|
|
59
|
+
let t = b.current;
|
|
60
|
+
if (!e || !t || !v) return;
|
|
61
|
+
let n = window.innerWidth - t.offsetWidth - p, i = window.innerHeight - t.offsetHeight - p, a = Math.max(p, Math.min(r.x, n)), o = Math.max(p, Math.min(r.y, i));
|
|
62
|
+
t.style.left = `${a}px`, t.style.top = `${o}px`;
|
|
63
|
+
}, [
|
|
64
|
+
v,
|
|
65
|
+
e,
|
|
66
|
+
r.x,
|
|
67
|
+
r.y,
|
|
68
|
+
p
|
|
69
|
+
]), n(() => {
|
|
70
|
+
if (!e || !g) return;
|
|
71
|
+
let t = (e) => {
|
|
72
|
+
let t = e.target;
|
|
73
|
+
(!(t instanceof Node) || !b.current?.contains(t)) && i();
|
|
74
|
+
};
|
|
75
|
+
return document.addEventListener("pointerdown", t), () => {
|
|
76
|
+
document.removeEventListener("pointerdown", t);
|
|
77
|
+
};
|
|
78
|
+
}, [
|
|
79
|
+
g,
|
|
80
|
+
i,
|
|
81
|
+
e
|
|
82
|
+
]), !e || typeof document > "u" ? null : u(/* @__PURE__ */ c("div", {
|
|
83
|
+
ref: S,
|
|
84
|
+
role: "menu",
|
|
85
|
+
tabIndex: -1,
|
|
86
|
+
"aria-label": o,
|
|
87
|
+
"aria-orientation": "vertical",
|
|
88
|
+
"data-sito-ui": "context-menu",
|
|
89
|
+
"data-state": "open",
|
|
90
|
+
className: d("sito-ui-context-menu", l),
|
|
91
|
+
style: {
|
|
92
|
+
left: r.x,
|
|
93
|
+
top: r.y
|
|
94
|
+
},
|
|
95
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
96
|
+
onKeyDown: (e) => {
|
|
97
|
+
let t = e.key === "Escape" && m, n = e.key === "Tab" && h;
|
|
98
|
+
if (t || n) {
|
|
99
|
+
e.preventDefault(), e.stopPropagation(), i();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
let r = Array.from(b.current?.querySelectorAll("[role=\"menuitem\"]:not([disabled])") ?? []);
|
|
103
|
+
if (r.length === 0) return;
|
|
104
|
+
let a = document.activeElement, o = a instanceof HTMLElement ? r.indexOf(a) : -1, s = null;
|
|
105
|
+
e.key === "ArrowDown" ? s = (o + 1 + r.length) % r.length : e.key === "ArrowUp" ? s = (o - 1 + r.length) % r.length : e.key === "Home" ? s = 0 : e.key === "End" && (s = r.length - 1), s !== null && (e.preventDefault(), r[s]?.focus());
|
|
106
|
+
},
|
|
107
|
+
children: s
|
|
108
|
+
}), f ?? document.body);
|
|
109
|
+
}), y = e(function({ leading: e, shortcut: t, children: n, className: r, disabled: i, ...a }, o) {
|
|
110
|
+
return /* @__PURE__ */ l("button", {
|
|
111
|
+
...a,
|
|
112
|
+
ref: o,
|
|
113
|
+
type: "button",
|
|
114
|
+
role: "menuitem",
|
|
115
|
+
tabIndex: -1,
|
|
116
|
+
disabled: i,
|
|
117
|
+
"data-sito-ui": "context-menu-item",
|
|
118
|
+
className: d("sito-ui-context-menu__item", r),
|
|
119
|
+
children: [
|
|
120
|
+
/* @__PURE__ */ c("span", {
|
|
121
|
+
className: "sito-ui-context-menu__leading",
|
|
122
|
+
"aria-hidden": "true",
|
|
123
|
+
children: e
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ c("span", {
|
|
126
|
+
className: "sito-ui-context-menu__label",
|
|
127
|
+
children: n
|
|
128
|
+
}),
|
|
129
|
+
t ? /* @__PURE__ */ c("span", {
|
|
130
|
+
className: "sito-ui-context-menu__shortcut",
|
|
131
|
+
"aria-hidden": "true",
|
|
132
|
+
children: t
|
|
133
|
+
}) : null
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
}), b = ({ className: e, ...t }) => /* @__PURE__ */ c("div", {
|
|
137
|
+
...t,
|
|
138
|
+
role: "separator",
|
|
139
|
+
"data-sito-ui": "context-menu-separator",
|
|
140
|
+
className: d("sito-ui-context-menu__separator", e)
|
|
141
|
+
}), x = {
|
|
41
142
|
SM: "sm",
|
|
42
143
|
MD: "md",
|
|
43
144
|
LG: "lg"
|
|
44
|
-
},
|
|
145
|
+
}, S = (e) => {
|
|
45
146
|
if (e !== void 0) return typeof e == "number" ? `${e}px` : e;
|
|
46
|
-
},
|
|
47
|
-
let { children: n, icon: r, iconClassName: i, type: a = "button", variant: o = "text", color: s = "default", loading: u = !1, size: f =
|
|
48
|
-
...
|
|
49
|
-
"--sito-ui-icon-button-icon-size":
|
|
50
|
-
}, C = d("sito-ui-icon-button", `sito-ui-icon-button--${f}`,
|
|
51
|
-
return /* @__PURE__ */ l(
|
|
52
|
-
...
|
|
147
|
+
}, C = e(function(e, t) {
|
|
148
|
+
let { children: n, icon: r, iconClassName: i, type: a = "button", variant: o = "text", color: s = "default", loading: u = !1, size: f = x.MD, iconSize: p, className: m, style: h, ..._ } = e, v = n != null && typeof n != "boolean", y = S(p), b = y === void 0 ? h : {
|
|
149
|
+
...h,
|
|
150
|
+
"--sito-ui-icon-button-icon-size": y
|
|
151
|
+
}, C = d("sito-ui-icon-button", `sito-ui-icon-button--${f}`, v && "sito-ui-icon-button--with-content", m);
|
|
152
|
+
return /* @__PURE__ */ l(g, {
|
|
153
|
+
..._,
|
|
53
154
|
ref: t,
|
|
54
155
|
type: a,
|
|
55
156
|
variant: o,
|
|
@@ -58,32 +159,32 @@ var d = (...e) => e.filter(Boolean).join(" "), f = {
|
|
|
58
159
|
loading: u,
|
|
59
160
|
"data-sito-ui": "icon-button",
|
|
60
161
|
className: C,
|
|
61
|
-
style:
|
|
162
|
+
style: b,
|
|
62
163
|
children: [u ? null : /* @__PURE__ */ c("span", {
|
|
63
164
|
className: d("sito-ui-icon-button__icon", i),
|
|
64
165
|
"aria-hidden": "true",
|
|
65
166
|
children: r
|
|
66
167
|
}), n]
|
|
67
168
|
});
|
|
68
|
-
}),
|
|
169
|
+
}), ee = "input:not([type=\"hidden\"]):not([disabled]), textarea:not([disabled]), select:not([disabled])", te = "button[type=\"submit\"]:not([disabled]), input[type=\"submit\"]:not([disabled])", w = [
|
|
69
170
|
"a[href]",
|
|
70
171
|
"button:not([disabled])",
|
|
71
172
|
"textarea:not([disabled])",
|
|
72
173
|
"input:not([disabled])",
|
|
73
174
|
"select:not([disabled])",
|
|
74
175
|
"[tabindex]:not([tabindex=\"-1\"])"
|
|
75
|
-
].join(","),
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
!
|
|
79
|
-
},
|
|
80
|
-
let t =
|
|
81
|
-
t >= 0 &&
|
|
82
|
-
},
|
|
83
|
-
let t =
|
|
84
|
-
t >= 0 &&
|
|
85
|
-
},
|
|
86
|
-
let i = r(), s = a(Symbol("sito-ui-dialog")), f = a(null), p = a(null), m = a(null), h = a(void 0), { dialogId: g, title: _, ariaLabel:
|
|
176
|
+
].join(","), T = 0, E = null, D = [], O = () => typeof document < "u" && !!document.body, k = () => {
|
|
177
|
+
O() && (T === 0 && (E = document.body.style.overflow, document.body.style.overflow = "hidden"), T += 1);
|
|
178
|
+
}, ne = () => {
|
|
179
|
+
!O() || T === 0 || (--T, T === 0 && (document.body.style.overflow = E ?? "", E = null));
|
|
180
|
+
}, A = (e) => Array.from(e.querySelectorAll(w)).filter((e) => e.getAttribute("aria-disabled") !== "true"), j = () => typeof document > "u" ? null : document.activeElement instanceof HTMLElement ? document.activeElement : null, re = (e) => {
|
|
181
|
+
let t = D.indexOf(e);
|
|
182
|
+
t >= 0 && D.splice(t, 1), D.push(e);
|
|
183
|
+
}, ie = (e) => {
|
|
184
|
+
let t = D.indexOf(e);
|
|
185
|
+
t >= 0 && D.splice(t, 1);
|
|
186
|
+
}, M = (e) => D[D.length - 1] === e, N = typeof window > "u" ? n : i, P = (e) => {
|
|
187
|
+
let i = r(), s = a(Symbol("sito-ui-dialog")), f = a(null), p = a(null), m = a(null), h = a(void 0), { dialogId: g, title: _, ariaLabel: v, children: y, onClose: b, initialFocus: x = "none", closeOnBackdropClick: S = !1, closeOnEscape: w = !0, lockBodyScroll: T = !0, onSubmit: E, open: D = !1, mobileFullScreen: O = !1, containerClassName: P, className: F, headerClassName: I, titleClassName: L, closeButtonClassName: R, closeLabel: z = "Close dialog", closeIcon: B = "x", showCloseButton: ae = !0, portalContainer: oe, exitDurationMs: V = 0, onExitComplete: H } = e, [U, W] = o(D), [G, K] = o(!1), q = _ ? `${g ?? i}-title` : void 0, J = G ? "closing" : "open", Y = D && !G, X = s.current;
|
|
87
188
|
n(() => {
|
|
88
189
|
h.current = H;
|
|
89
190
|
}, [H]);
|
|
@@ -92,8 +193,8 @@ var d = (...e) => e.filter(Boolean).join(" "), f = {
|
|
|
92
193
|
}, []), Q = t(() => {
|
|
93
194
|
W(!1), K(!1), h.current?.(), m.current = null;
|
|
94
195
|
}, []);
|
|
95
|
-
|
|
96
|
-
if (
|
|
196
|
+
N(() => {
|
|
197
|
+
if (D) {
|
|
97
198
|
Z(), W(!0), K(!1);
|
|
98
199
|
return;
|
|
99
200
|
}
|
|
@@ -108,59 +209,59 @@ var d = (...e) => e.filter(Boolean).join(" "), f = {
|
|
|
108
209
|
Z,
|
|
109
210
|
V,
|
|
110
211
|
Q,
|
|
111
|
-
|
|
212
|
+
D,
|
|
112
213
|
U
|
|
113
214
|
]), n(() => () => {
|
|
114
215
|
Z();
|
|
115
216
|
}, [Z]);
|
|
116
217
|
let $ = t((e) => {
|
|
117
|
-
if (!
|
|
118
|
-
if (e.key === "Escape" && Y &&
|
|
119
|
-
|
|
218
|
+
if (!M(X)) return;
|
|
219
|
+
if (e.key === "Escape" && Y && w) {
|
|
220
|
+
b();
|
|
120
221
|
return;
|
|
121
222
|
}
|
|
122
223
|
if (e.key !== "Tab" || !Y) return;
|
|
123
224
|
let t = f.current;
|
|
124
225
|
if (!t) return;
|
|
125
|
-
let n =
|
|
226
|
+
let n = A(t);
|
|
126
227
|
if (n.length === 0) {
|
|
127
228
|
e.preventDefault(), t.focus();
|
|
128
229
|
return;
|
|
129
230
|
}
|
|
130
|
-
let r = n[0], i = n[n.length - 1], a =
|
|
231
|
+
let r = n[0], i = n[n.length - 1], a = j(), o = !a || !t.contains(a);
|
|
131
232
|
if (e.shiftKey && (o || a === r)) {
|
|
132
233
|
e.preventDefault(), i.focus();
|
|
133
234
|
return;
|
|
134
235
|
}
|
|
135
236
|
!e.shiftKey && (o || a === i) && (e.preventDefault(), r.focus());
|
|
136
237
|
}, [
|
|
137
|
-
|
|
238
|
+
w,
|
|
138
239
|
X,
|
|
139
240
|
Y,
|
|
140
|
-
|
|
241
|
+
b
|
|
141
242
|
]);
|
|
142
243
|
n(() => {
|
|
143
244
|
if (!(!Y || typeof window > "u")) return window.addEventListener("keydown", $), () => {
|
|
144
245
|
window.removeEventListener("keydown", $);
|
|
145
246
|
};
|
|
146
|
-
}, [$, Y]),
|
|
147
|
-
if (
|
|
148
|
-
let e =
|
|
149
|
-
|
|
247
|
+
}, [$, Y]), N(() => {
|
|
248
|
+
if (D) return p.current = j(), re(X), () => {
|
|
249
|
+
let e = M(X);
|
|
250
|
+
ie(X), e && p.current?.isConnected && p.current.focus(), p.current = null;
|
|
150
251
|
};
|
|
151
|
-
}, [X,
|
|
152
|
-
if (!
|
|
252
|
+
}, [X, D]), N(() => {
|
|
253
|
+
if (!D) return;
|
|
153
254
|
let e = f.current;
|
|
154
255
|
if (e) {
|
|
155
|
-
if (
|
|
156
|
-
let t = e.querySelector(
|
|
256
|
+
if (x === "first-input") {
|
|
257
|
+
let t = e.querySelector(ee);
|
|
157
258
|
if (t) {
|
|
158
259
|
t.focus();
|
|
159
260
|
return;
|
|
160
261
|
}
|
|
161
262
|
}
|
|
162
|
-
if (
|
|
163
|
-
let t = e.querySelector(
|
|
263
|
+
if (x === "submit") {
|
|
264
|
+
let t = e.querySelector(te);
|
|
164
265
|
if (t) {
|
|
165
266
|
t.focus();
|
|
166
267
|
return;
|
|
@@ -168,26 +269,26 @@ var d = (...e) => e.filter(Boolean).join(" "), f = {
|
|
|
168
269
|
}
|
|
169
270
|
e.focus();
|
|
170
271
|
}
|
|
171
|
-
}, [
|
|
172
|
-
if (!(!U || !
|
|
173
|
-
|
|
272
|
+
}, [x, D]), n(() => {
|
|
273
|
+
if (!(!U || !T)) return k(), () => {
|
|
274
|
+
ne();
|
|
174
275
|
};
|
|
175
|
-
}, [
|
|
276
|
+
}, [T, U]);
|
|
176
277
|
let se = t((e) => {
|
|
177
|
-
|
|
278
|
+
M(X) && Y && S && e.target === e.currentTarget && b();
|
|
178
279
|
}, [
|
|
179
|
-
|
|
280
|
+
S,
|
|
180
281
|
X,
|
|
181
282
|
Y,
|
|
182
|
-
|
|
283
|
+
b
|
|
183
284
|
]), ce = t((e) => {
|
|
184
|
-
e.preventDefault(),
|
|
185
|
-
}, [
|
|
285
|
+
e.preventDefault(), E?.(e);
|
|
286
|
+
}, [E]);
|
|
186
287
|
if (!U || typeof document > "u") return null;
|
|
187
|
-
let le =
|
|
288
|
+
let le = E ? /* @__PURE__ */ c("form", {
|
|
188
289
|
onSubmit: ce,
|
|
189
|
-
children:
|
|
190
|
-
}) :
|
|
290
|
+
children: y
|
|
291
|
+
}) : y, ue = typeof B == "string" ? /* @__PURE__ */ c("span", {
|
|
191
292
|
"aria-hidden": "true",
|
|
192
293
|
children: B
|
|
193
294
|
}) : B;
|
|
@@ -196,44 +297,44 @@ var d = (...e) => e.filter(Boolean).join(" "), f = {
|
|
|
196
297
|
"data-sito-ui": "dialog-backdrop",
|
|
197
298
|
"data-state": J,
|
|
198
299
|
onClick: se,
|
|
199
|
-
className: d("sito-ui-dialog-backdrop", `sito-ui-dialog-backdrop--${J}`,
|
|
300
|
+
className: d("sito-ui-dialog-backdrop", `sito-ui-dialog-backdrop--${J}`, P),
|
|
200
301
|
children: /* @__PURE__ */ l("div", {
|
|
201
302
|
id: g,
|
|
202
303
|
ref: f,
|
|
203
304
|
role: "dialog",
|
|
204
305
|
"aria-modal": "true",
|
|
205
|
-
"aria-label": _ ? void 0 :
|
|
306
|
+
"aria-label": _ ? void 0 : v,
|
|
206
307
|
"aria-labelledby": q,
|
|
207
308
|
tabIndex: -1,
|
|
208
309
|
"data-sito-ui": "dialog",
|
|
209
310
|
"data-state": J,
|
|
210
|
-
className: d("sito-ui-dialog", `sito-ui-dialog--${J}`,
|
|
311
|
+
className: d("sito-ui-dialog", `sito-ui-dialog--${J}`, O && "sito-ui-dialog--mobile-full-screen", F),
|
|
211
312
|
children: [/* @__PURE__ */ l("div", {
|
|
212
|
-
className: d("sito-ui-dialog__header",
|
|
313
|
+
className: d("sito-ui-dialog__header", I),
|
|
213
314
|
children: [_ ? /* @__PURE__ */ c("h3", {
|
|
214
315
|
id: q,
|
|
215
|
-
className: d("sito-ui-dialog__title",
|
|
316
|
+
className: d("sito-ui-dialog__title", L),
|
|
216
317
|
children: _
|
|
217
|
-
}) : null, ae ? /* @__PURE__ */ c(
|
|
318
|
+
}) : null, ae ? /* @__PURE__ */ c(C, {
|
|
218
319
|
icon: ue,
|
|
219
320
|
disabled: !Y,
|
|
220
321
|
"aria-disabled": !Y,
|
|
221
|
-
onClick:
|
|
322
|
+
onClick: b,
|
|
222
323
|
variant: "text",
|
|
223
324
|
color: "error",
|
|
224
|
-
className: d("sito-ui-dialog__close",
|
|
225
|
-
"aria-label":
|
|
325
|
+
className: d("sito-ui-dialog__close", R),
|
|
326
|
+
"aria-label": z
|
|
226
327
|
}) : null]
|
|
227
328
|
}), le]
|
|
228
329
|
})
|
|
229
330
|
}), oe ?? document.body);
|
|
230
|
-
},
|
|
231
|
-
let { primaryText: t, cancelText: n, onPrimaryClick: r, onCancel: i, isLoading: a = !1, loadingIndicator: o, disabled: s = !1, primaryType: u = "submit", containerClassName: f, primaryClassName: p, cancelClassName: m, alignEnd:
|
|
331
|
+
}, F = (e) => {
|
|
332
|
+
let { primaryText: t, cancelText: n, onPrimaryClick: r, onCancel: i, isLoading: a = !1, loadingIndicator: o, disabled: s = !1, primaryType: u = "submit", containerClassName: f, primaryClassName: p, cancelClassName: m, alignEnd: h = !1, primaryName: _, primaryAriaLabel: v, cancelName: y, cancelAriaLabel: b, extraActions: x = [] } = e;
|
|
232
333
|
return /* @__PURE__ */ l("div", {
|
|
233
334
|
"data-sito-ui": "dialog-actions",
|
|
234
|
-
className: d("sito-ui-dialog-actions",
|
|
335
|
+
className: d("sito-ui-dialog-actions", h && "sito-ui-dialog-actions--end", f),
|
|
235
336
|
children: [
|
|
236
|
-
/* @__PURE__ */ c(
|
|
337
|
+
/* @__PURE__ */ c(g, {
|
|
237
338
|
type: u,
|
|
238
339
|
color: "primary",
|
|
239
340
|
variant: "submit",
|
|
@@ -246,8 +347,8 @@ var d = (...e) => e.filter(Boolean).join(" "), f = {
|
|
|
246
347
|
"aria-label": v,
|
|
247
348
|
children: t
|
|
248
349
|
}),
|
|
249
|
-
x.map(({ id: e, ...t }) => /* @__PURE__ */ c(
|
|
250
|
-
/* @__PURE__ */ c(
|
|
350
|
+
x.map(({ id: e, ...t }) => /* @__PURE__ */ c(g, { ...t }, e)),
|
|
351
|
+
/* @__PURE__ */ c(g, {
|
|
251
352
|
type: "button",
|
|
252
353
|
variant: "outlined",
|
|
253
354
|
className: m,
|
|
@@ -259,7 +360,11 @@ var d = (...e) => e.filter(Boolean).join(" "), f = {
|
|
|
259
360
|
})
|
|
260
361
|
]
|
|
261
362
|
});
|
|
262
|
-
},
|
|
363
|
+
}, I = {
|
|
364
|
+
NONE: "none",
|
|
365
|
+
FIRST_INPUT: "first-input",
|
|
366
|
+
SUBMIT: "submit"
|
|
367
|
+
}, L = (e = !1) => {
|
|
263
368
|
let [t, n] = o(e);
|
|
264
369
|
return {
|
|
265
370
|
open: t,
|
|
@@ -267,6 +372,23 @@ var d = (...e) => e.filter(Boolean).join(" "), f = {
|
|
|
267
372
|
handleClose: () => n(!1),
|
|
268
373
|
handleOpen: () => n(!0)
|
|
269
374
|
};
|
|
375
|
+
}, R = {
|
|
376
|
+
x: 0,
|
|
377
|
+
y: 0
|
|
378
|
+
}, z = () => {
|
|
379
|
+
let [e, n] = o(!1), [r, i] = o(null), [a, s] = o(R);
|
|
380
|
+
return {
|
|
381
|
+
open: e,
|
|
382
|
+
payload: r,
|
|
383
|
+
position: a,
|
|
384
|
+
openAt: t((e, t, r) => {
|
|
385
|
+
i(r), s({
|
|
386
|
+
x: e,
|
|
387
|
+
y: t
|
|
388
|
+
}), n(!0);
|
|
389
|
+
}, []),
|
|
390
|
+
close: t(() => n(!1), [])
|
|
391
|
+
};
|
|
270
392
|
};
|
|
271
393
|
//#endregion
|
|
272
|
-
export { h as Button,
|
|
394
|
+
export { p as BUTTON_COLOR_VARIANTS, h as BUTTON_SIZES, m as BUTTON_VARIANTS, g as Button, v as ContextMenu, y as ContextMenuItem, b as ContextMenuSeparator, I as DIALOG_INITIAL_FOCUS, P as Dialog, F as DialogActions, x as ICON_BUTTON_SIZES, C as IconButton, f as Spinner, z as useContextMenu, L as useDialog };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sito/ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@10.34.4",
|
|
7
7
|
"files": [
|
|
@@ -65,30 +65,33 @@
|
|
|
65
65
|
"lodash": "4.18.1",
|
|
66
66
|
"minimatch": "3.1.5",
|
|
67
67
|
"validator": "13.15.35"
|
|
68
|
-
}
|
|
68
|
+
},
|
|
69
|
+
"ignoredBuiltDependencies": [
|
|
70
|
+
"esbuild"
|
|
71
|
+
]
|
|
69
72
|
},
|
|
70
73
|
"devDependencies": {
|
|
71
|
-
"@storybook/addon-docs": "10.
|
|
72
|
-
"@storybook/react-vite": "10.
|
|
73
|
-
"@testing-library/jest-dom": "
|
|
74
|
-
"@testing-library/react": "16.3.
|
|
75
|
-
"@testing-library/user-event": "14.6.
|
|
76
|
-
"@types/node": "26.
|
|
77
|
-
"@types/react": "19.2.
|
|
78
|
-
"@types/react-dom": "19.2.
|
|
74
|
+
"@storybook/addon-docs": "10.6.0",
|
|
75
|
+
"@storybook/react-vite": "10.6.0",
|
|
76
|
+
"@testing-library/jest-dom": "7.0.1",
|
|
77
|
+
"@testing-library/react": "16.3.3",
|
|
78
|
+
"@testing-library/user-event": "14.6.7",
|
|
79
|
+
"@types/node": "26.5.0",
|
|
80
|
+
"@types/react": "19.2.18",
|
|
81
|
+
"@types/react-dom": "19.2.7",
|
|
79
82
|
"@typescript/typescript6": "^6.0.2",
|
|
80
|
-
"@vitejs/plugin-react": "6.
|
|
81
|
-
"autoprefixer": "10.5.
|
|
82
|
-
"jsdom": "
|
|
83
|
-
"oxlint": "1.
|
|
84
|
-
"oxlint-tsgolint": "0.
|
|
85
|
-
"prettier": "3.9.
|
|
86
|
-
"react": "19.2.
|
|
87
|
-
"react-dom": "19.2.
|
|
88
|
-
"storybook": "10.
|
|
83
|
+
"@vitejs/plugin-react": "6.1.1",
|
|
84
|
+
"autoprefixer": "10.5.5",
|
|
85
|
+
"jsdom": "30.0.1",
|
|
86
|
+
"oxlint": "1.82.0",
|
|
87
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
88
|
+
"prettier": "3.9.6",
|
|
89
|
+
"react": "19.2.8",
|
|
90
|
+
"react-dom": "19.2.8",
|
|
91
|
+
"storybook": "10.6.0",
|
|
89
92
|
"typescript": "7.0.2",
|
|
90
|
-
"vite": "8.
|
|
91
|
-
"vite-plugin-dts": "5.0
|
|
92
|
-
"vitest": "
|
|
93
|
+
"vite": "8.2.2",
|
|
94
|
+
"vite-plugin-dts": "5.1.0",
|
|
95
|
+
"vitest": "5.0.0"
|
|
93
96
|
}
|
|
94
97
|
}
|