@alulore/kumiko 0.0.0-stage → 0.14.2
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/LICENSE +21 -0
- package/README.md +31 -2
- package/dist/badge/badge.css +287 -0
- package/dist/badge/badge.d.ts +40 -0
- package/dist/badge/badge.js +51 -0
- package/dist/badge/index.d.ts +1 -0
- package/dist/badge/index.js +1 -0
- package/dist/board/board-api.d.ts +147 -0
- package/dist/board/board-api.js +139 -0
- package/dist/board/board-card-menu.d.ts +17 -0
- package/dist/board/board-card-menu.js +53 -0
- package/dist/board/board-drag-events.d.ts +12 -0
- package/dist/board/board-drag-events.js +86 -0
- package/dist/board/board-fold.d.ts +10 -0
- package/dist/board/board-fold.js +30 -0
- package/dist/board/board-group.d.ts +10 -0
- package/dist/board/board-group.js +28 -0
- package/dist/board/board-keys.d.ts +16 -0
- package/dist/board/board-keys.js +65 -0
- package/dist/board/board-locked-rows.d.ts +23 -0
- package/dist/board/board-locked-rows.js +77 -0
- package/dist/board/board-motion.d.ts +7 -0
- package/dist/board/board-motion.js +102 -0
- package/dist/board/board-primitive.d.ts +53 -0
- package/dist/board/board-primitive.js +66 -0
- package/dist/board/board-pull.d.ts +6 -0
- package/dist/board/board-pull.js +94 -0
- package/dist/board/board-selection.d.ts +42 -0
- package/dist/board/board-selection.js +130 -0
- package/dist/board/board-slots.d.ts +1003 -0
- package/dist/board/board-slots.js +250 -0
- package/dist/board/board-types.d.ts +99 -0
- package/dist/board/board-types.js +1 -0
- package/dist/board/board.css +343 -0
- package/dist/board/board.d.ts +290 -0
- package/dist/board/board.js +23 -0
- package/dist/board/card-menu.d.ts +21 -0
- package/dist/board/card-menu.js +79 -0
- package/dist/board/cell-key.d.ts +6 -0
- package/dist/board/cell-key.js +16 -0
- package/dist/board/index.d.ts +6 -0
- package/dist/board/index.js +5 -0
- package/dist/board/interactive.d.ts +18 -0
- package/dist/board/interactive.js +51 -0
- package/dist/board/keep-capture.d.ts +16 -0
- package/dist/board/keep-capture.js +57 -0
- package/dist/board/landing.d.ts +5 -0
- package/dist/board/landing.js +10 -0
- package/dist/board/press-to-drop.d.ts +9 -0
- package/dist/board/press-to-drop.js +28 -0
- package/dist/board/refused-home.d.ts +16 -0
- package/dist/board/refused-home.js +50 -0
- package/dist/board/repeat-gate.d.ts +4 -0
- package/dist/board/repeat-gate.js +12 -0
- package/dist/board/scrollbar-gutter.d.ts +1 -0
- package/dist/board/scrollbar-gutter.js +27 -0
- package/dist/board/touch-hold.d.ts +19 -0
- package/dist/board/touch-hold.js +103 -0
- package/dist/button/button.css +576 -0
- package/dist/button/button.d.ts +50 -0
- package/dist/button/button.js +70 -0
- package/dist/button/index.d.ts +2 -0
- package/dist/button/index.js +1 -0
- package/dist/checkbox/checkbox-mark.d.ts +8 -0
- package/dist/checkbox/checkbox-mark.js +17 -0
- package/dist/checkbox/checkbox-marks.d.ts +33 -0
- package/dist/checkbox/checkbox-marks.js +30 -0
- package/dist/checkbox/checkbox.css +201 -0
- package/dist/checkbox/checkbox.d.ts +26 -0
- package/dist/checkbox/checkbox.js +11 -0
- package/dist/checkbox/index.d.ts +3 -0
- package/dist/checkbox/index.js +3 -0
- package/dist/chip/chip.css +251 -0
- package/dist/chip/chip.d.ts +39 -0
- package/dist/chip/chip.js +25 -0
- package/dist/chip/index.d.ts +1 -0
- package/dist/chip/index.js +1 -0
- package/dist/dialog/dialog.css +247 -0
- package/dist/dialog/index.d.ts +3 -0
- package/dist/dialog/index.js +3 -0
- package/dist/hover-card/hover-card.css +149 -0
- package/dist/hover-card/hover-card.d.ts +3 -0
- package/dist/hover-card/hover-card.js +8 -0
- package/dist/hover-card/index.d.ts +2 -0
- package/dist/hover-card/index.js +2 -0
- package/dist/input/index.d.ts +5 -0
- package/dist/input/index.js +5 -0
- package/dist/input/input-attributes.d.ts +12 -0
- package/dist/input/input-attributes.js +9 -0
- package/dist/input/input.css +752 -0
- package/dist/input/input.d.ts +28 -0
- package/dist/input/input.js +9 -0
- package/dist/input/search-input.d.ts +41 -0
- package/dist/input/search-input.js +47 -0
- package/dist/kbd/index.d.ts +1 -0
- package/dist/kbd/index.js +1 -0
- package/dist/kbd/kbd.css +77 -0
- package/dist/kbd/kbd.d.ts +21 -0
- package/dist/kbd/kbd.js +37 -0
- package/dist/label/index.d.ts +1 -0
- package/dist/label/index.js +1 -0
- package/dist/label/label.css +37 -0
- package/dist/label/label.d.ts +13 -0
- package/dist/label/label.js +10 -0
- package/dist/menu/index.d.ts +3 -0
- package/dist/menu/index.js +3 -0
- package/dist/menu/menu.css +349 -0
- package/dist/menu/menu.d.ts +11 -0
- package/dist/menu/menu.js +86 -0
- package/dist/menu/point-menu.d.ts +26 -0
- package/dist/menu/point-menu.js +51 -0
- package/dist/motion/flip-math.d.ts +19 -0
- package/dist/motion/flip-math.js +33 -0
- package/dist/motion/flip.d.ts +40 -0
- package/dist/motion/flip.js +203 -0
- package/dist/motion/index.d.ts +2 -0
- package/dist/motion/index.js +2 -0
- package/dist/motion/motion.css +169 -0
- package/dist/popover/index.d.ts +1 -0
- package/dist/popover/index.js +1 -0
- package/dist/popover/popover.css +208 -0
- package/dist/progress/index.d.ts +2 -0
- package/dist/progress/index.js +2 -0
- package/dist/progress/progress.css +390 -0
- package/dist/progress/progress.d.ts +36 -0
- package/dist/progress/progress.js +107 -0
- package/dist/select/index.d.ts +3 -0
- package/dist/select/index.js +2 -0
- package/dist/select/select-labels.d.ts +6 -0
- package/dist/select/select-labels.js +64 -0
- package/dist/select/select-search.d.ts +18 -0
- package/dist/select/select-search.js +10 -0
- package/dist/select/select.css +470 -0
- package/dist/select/select.d.ts +44 -0
- package/dist/select/select.js +92 -0
- package/dist/separator/index.d.ts +2 -0
- package/dist/separator/index.js +1 -0
- package/dist/separator/separator.css +32 -0
- package/dist/separator/separator.d.ts +17 -0
- package/dist/separator/separator.js +10 -0
- package/dist/slider/index.d.ts +2 -0
- package/dist/slider/index.js +2 -0
- package/dist/slider/slider-bubble.css +203 -0
- package/dist/slider/slider-feel.d.ts +33 -0
- package/dist/slider/slider-feel.js +153 -0
- package/dist/slider/slider-format.d.ts +13 -0
- package/dist/slider/slider-format.js +15 -0
- package/dist/slider/slider-marks.d.ts +16 -0
- package/dist/slider/slider-marks.js +32 -0
- package/dist/slider/slider.css +335 -0
- package/dist/slider/slider.d.ts +34 -0
- package/dist/slider/slider.js +94 -0
- package/dist/smooth-caret/caret-box.d.ts +7 -0
- package/dist/smooth-caret/caret-box.js +8 -0
- package/dist/smooth-caret/caret-controller.d.ts +7 -0
- package/dist/smooth-caret/caret-controller.js +222 -0
- package/dist/smooth-caret/caret-geometry.d.ts +11 -0
- package/dist/smooth-caret/caret-geometry.js +230 -0
- package/dist/smooth-caret/caret-glide.d.ts +13 -0
- package/dist/smooth-caret/caret-glide.js +76 -0
- package/dist/smooth-caret/caret-host.d.ts +5 -0
- package/dist/smooth-caret/caret-host.js +40 -0
- package/dist/smooth-caret/index.d.ts +7 -0
- package/dist/smooth-caret/index.js +7 -0
- package/dist/smooth-caret/remote-carets.d.ts +40 -0
- package/dist/smooth-caret/remote-carets.js +130 -0
- package/dist/smooth-caret/smooth-caret.css +157 -0
- package/dist/smooth-caret/smooth-caret.d.ts +5 -0
- package/dist/smooth-caret/smooth-caret.js +9 -0
- package/dist/smooth-caret/use-smooth-caret.d.ts +5 -0
- package/dist/smooth-caret/use-smooth-caret.js +9 -0
- package/dist/switch/index.d.ts +2 -0
- package/dist/switch/index.js +2 -0
- package/dist/switch/switch-drag.d.ts +21 -0
- package/dist/switch/switch-drag.js +23 -0
- package/dist/switch/switch-gesture.d.ts +28 -0
- package/dist/switch/switch-gesture.js +131 -0
- package/dist/switch/switch.css +189 -0
- package/dist/switch/switch.d.ts +15 -0
- package/dist/switch/switch.js +24 -0
- package/dist/textarea/index.d.ts +2 -0
- package/dist/textarea/index.js +2 -0
- package/dist/textarea/textarea.css +37 -0
- package/dist/textarea/textarea.d.ts +35 -0
- package/dist/textarea/textarea.js +11 -0
- package/dist/toast/index.d.ts +2 -0
- package/dist/toast/index.js +2 -0
- package/dist/toast/toast.css +293 -0
- package/dist/tooltip/index.d.ts +2 -0
- package/dist/tooltip/index.js +2 -0
- package/dist/tooltip/tooltip.css +143 -0
- package/dist/tooltip/tooltip.d.ts +14 -0
- package/dist/tooltip/tooltip.js +13 -0
- package/package.json +243 -5
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
@import "../motion/motion.css";
|
|
2
|
+
|
|
3
|
+
@layer kumiko {
|
|
4
|
+
:where(:root) {
|
|
5
|
+
--kumiko-touch-target: 2.75rem;
|
|
6
|
+
--kumiko-button-radius: 999px;
|
|
7
|
+
--kumiko-button-border-width: 1px;
|
|
8
|
+
--kumiko-button-font-family: inherit;
|
|
9
|
+
--kumiko-button-font-weight: 500;
|
|
10
|
+
--kumiko-button-font-size-xs: 0.75rem;
|
|
11
|
+
--kumiko-button-font-size: 0.875rem;
|
|
12
|
+
--kumiko-button-font-size-lg: 1rem;
|
|
13
|
+
--kumiko-button-height-xs: 1.5rem;
|
|
14
|
+
--kumiko-button-height-sm: 2rem;
|
|
15
|
+
--kumiko-button-height: 2.25rem;
|
|
16
|
+
--kumiko-button-height-lg: 2.5rem;
|
|
17
|
+
--kumiko-button-padding-x-xs: 0.5rem;
|
|
18
|
+
--kumiko-button-padding-x-sm: 0.75rem;
|
|
19
|
+
--kumiko-button-padding-x: 1rem;
|
|
20
|
+
--kumiko-button-padding-x-lg: 1.5rem;
|
|
21
|
+
--kumiko-button-padding-x-touch: 1.5rem;
|
|
22
|
+
--kumiko-button-gap: 0.5rem;
|
|
23
|
+
--kumiko-button-icon-size: 1rem;
|
|
24
|
+
--kumiko-button-icon-size-xs: 0.75rem;
|
|
25
|
+
--kumiko-button-focus-ring: Highlight;
|
|
26
|
+
--kumiko-button-focus-ring-width: 2px;
|
|
27
|
+
--kumiko-button-focus-ring-offset: 2px;
|
|
28
|
+
--kumiko-button-disabled-opacity: 0.5;
|
|
29
|
+
--kumiko-button-solid-bg: Highlight;
|
|
30
|
+
--kumiko-button-solid-fg: HighlightText;
|
|
31
|
+
--kumiko-button-secondary-bg: color-mix(in oklab, CanvasText 10%, Canvas);
|
|
32
|
+
--kumiko-button-secondary-fg: CanvasText;
|
|
33
|
+
--kumiko-button-outline-border: color-mix(in oklab, CanvasText 30%, transparent);
|
|
34
|
+
--kumiko-button-outline-fg: CanvasText;
|
|
35
|
+
--kumiko-button-ghost-fg: CanvasText;
|
|
36
|
+
--kumiko-button-tint: color-mix(in oklab, CanvasText 10%, transparent);
|
|
37
|
+
--kumiko-button-danger: #c62828;
|
|
38
|
+
--kumiko-button-danger-fg: #fff;
|
|
39
|
+
--kumiko-button-link-fg: LinkText;
|
|
40
|
+
--kumiko-button-success: #1f9d55;
|
|
41
|
+
--kumiko-button-success-fg: #fff;
|
|
42
|
+
--kumiko-button-error-ring-width: 1px;
|
|
43
|
+
--kumiko-button-sweep-ease: linear;
|
|
44
|
+
--kumiko-button-pulse-ease: ease-in-out;
|
|
45
|
+
--kumiko-button-dot-stagger: 120ms;
|
|
46
|
+
--kumiko-button-dot-size: 5px;
|
|
47
|
+
--kumiko-button-dot-gap: 4px;
|
|
48
|
+
--kumiko-button-dot-lift: 4px;
|
|
49
|
+
--kumiko-button-dots-duration: 800ms;
|
|
50
|
+
--kumiko-button-dots-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
51
|
+
--kumiko-button-spinner-size: 1em;
|
|
52
|
+
--kumiko-button-spin-duration: 700ms;
|
|
53
|
+
--kumiko-button-shimmer-duration: 1.4s;
|
|
54
|
+
--kumiko-button-shimmer-color: color-mix(in oklab, currentColor 28%, transparent);
|
|
55
|
+
--kumiko-button-loading-dim: 0.75;
|
|
56
|
+
--kumiko-button-orbit-duration: 1.4s;
|
|
57
|
+
--kumiko-button-orbit-width: 2px;
|
|
58
|
+
--kumiko-button-orbit-color: currentColor;
|
|
59
|
+
--kumiko-button-orbit-length: 28%;
|
|
60
|
+
--kumiko-button-breathe-duration: 1.6s;
|
|
61
|
+
--kumiko-button-breathe-min: 0.62;
|
|
62
|
+
--kumiko-button-reduced-duration: 1.6s;
|
|
63
|
+
--kumiko-button-nudge: 3px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* The angle the orbit segment sits at. Without @property support the segment stays put instead of travelling. */
|
|
67
|
+
@property --kumiko-button-angle {
|
|
68
|
+
syntax: "<angle>";
|
|
69
|
+
inherits: false;
|
|
70
|
+
initial-value: 0deg;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[data-slot="button"] {
|
|
74
|
+
--_height: var(--kumiko-button-height);
|
|
75
|
+
--_px: var(--kumiko-button-padding-x);
|
|
76
|
+
--_font: var(--kumiko-button-font-size);
|
|
77
|
+
--_icon: var(--kumiko-button-icon-size);
|
|
78
|
+
--_gap: var(--kumiko-button-gap);
|
|
79
|
+
--_bg: transparent;
|
|
80
|
+
--_hover-bg: var(--kumiko-button-tint);
|
|
81
|
+
--_fg: var(--kumiko-button-ghost-fg);
|
|
82
|
+
--_border: transparent;
|
|
83
|
+
--_shadow: 0 0 0 0 transparent;
|
|
84
|
+
--_danger-ink: var(
|
|
85
|
+
--kumiko-button-danger-ink,
|
|
86
|
+
color-mix(in oklab, var(--kumiko-button-danger) 75%, CanvasText)
|
|
87
|
+
);
|
|
88
|
+
--_danger-tint: var(
|
|
89
|
+
--kumiko-button-danger-tint,
|
|
90
|
+
color-mix(in oklab, var(--kumiko-button-danger) 14%, transparent)
|
|
91
|
+
);
|
|
92
|
+
--_error-bg: var(
|
|
93
|
+
--kumiko-button-error-bg,
|
|
94
|
+
color-mix(in oklab, var(--kumiko-button-danger) 12%, Canvas)
|
|
95
|
+
);
|
|
96
|
+
--_dot-animation: kumiko-button-dot var(--kumiko-button-dots-duration)
|
|
97
|
+
var(--kumiko-button-dots-ease) infinite;
|
|
98
|
+
--_spin-animation: kumiko-button-spin var(--kumiko-button-spin-duration)
|
|
99
|
+
var(--kumiko-button-sweep-ease) infinite;
|
|
100
|
+
--_spinner-enter: kumiko-button-spinner-in var(--kumiko-fade-duration)
|
|
101
|
+
var(--kumiko-fade-ease) backwards;
|
|
102
|
+
--_shimmer-animation: kumiko-button-shimmer var(--kumiko-button-shimmer-duration)
|
|
103
|
+
var(--kumiko-button-sweep-ease) infinite;
|
|
104
|
+
--_shimmer-image: linear-gradient(
|
|
105
|
+
100deg,
|
|
106
|
+
transparent 35%,
|
|
107
|
+
var(--kumiko-button-shimmer-color) 50%,
|
|
108
|
+
transparent 65%
|
|
109
|
+
);
|
|
110
|
+
--_shimmer-size: 250% 100%;
|
|
111
|
+
--_orbit-animation: kumiko-button-orbit var(--kumiko-button-orbit-duration)
|
|
112
|
+
var(--kumiko-button-sweep-ease) infinite;
|
|
113
|
+
--_breathe-animation: kumiko-button-breathe var(--kumiko-button-breathe-duration)
|
|
114
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
115
|
+
--_tick-animation: kumiko-button-tick var(--kumiko-settle-duration)
|
|
116
|
+
var(--kumiko-settle-ease) both;
|
|
117
|
+
--_nudge-animation: kumiko-button-nudge calc(var(--kumiko-settle-duration) * 1.2)
|
|
118
|
+
var(--kumiko-fade-ease);
|
|
119
|
+
|
|
120
|
+
position: relative;
|
|
121
|
+
display: inline-flex;
|
|
122
|
+
box-sizing: border-box;
|
|
123
|
+
flex: none;
|
|
124
|
+
align-items: center;
|
|
125
|
+
justify-content: center;
|
|
126
|
+
gap: var(--_gap);
|
|
127
|
+
block-size: var(--_height);
|
|
128
|
+
padding: 0 var(--_px);
|
|
129
|
+
border: var(--kumiko-button-border-width) solid var(--_border);
|
|
130
|
+
border-radius: var(--kumiko-button-radius);
|
|
131
|
+
background: var(--_bg);
|
|
132
|
+
box-shadow: var(--_shadow);
|
|
133
|
+
color: var(--_fg);
|
|
134
|
+
font-family: var(--kumiko-button-font-family);
|
|
135
|
+
font-size: var(--_font);
|
|
136
|
+
font-weight: var(--kumiko-button-font-weight);
|
|
137
|
+
line-height: 1;
|
|
138
|
+
text-decoration: none;
|
|
139
|
+
white-space: nowrap;
|
|
140
|
+
cursor: var(--kumiko-press-cursor, pointer);
|
|
141
|
+
user-select: none;
|
|
142
|
+
transition:
|
|
143
|
+
background-color var(--kumiko-fade-duration) var(--kumiko-fade-ease),
|
|
144
|
+
color var(--kumiko-fade-duration) var(--kumiko-fade-ease),
|
|
145
|
+
border-color var(--kumiko-fade-duration) var(--kumiko-fade-ease),
|
|
146
|
+
box-shadow var(--kumiko-fade-duration) var(--kumiko-fade-ease),
|
|
147
|
+
scale var(--kumiko-lift-duration) var(--kumiko-lift-ease);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
[data-slot="button"][data-size="xs"] {
|
|
151
|
+
--_height: var(--kumiko-button-height-xs);
|
|
152
|
+
--_px: var(--kumiko-button-padding-x-xs);
|
|
153
|
+
--_font: var(--kumiko-button-font-size-xs);
|
|
154
|
+
--_icon: var(--kumiko-button-icon-size-xs);
|
|
155
|
+
--_gap: calc(var(--kumiko-button-gap) / 2);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
[data-slot="button"][data-size="sm"] {
|
|
159
|
+
--_height: var(--kumiko-button-height-sm);
|
|
160
|
+
--_px: var(--kumiko-button-padding-x-sm);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
[data-slot="button"][data-size="lg"] {
|
|
164
|
+
--_height: var(--kumiko-button-height-lg);
|
|
165
|
+
--_px: var(--kumiko-button-padding-x-lg);
|
|
166
|
+
--_font: var(--kumiko-button-font-size-lg);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[data-slot="button"][data-size="touch"] {
|
|
170
|
+
--_height: max(var(--kumiko-touch-target), 44px);
|
|
171
|
+
--_px: var(--kumiko-button-padding-x-touch);
|
|
172
|
+
--_font: var(--kumiko-button-font-size-lg);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* Icon-only: a square at the size. The label is the icon, so there is no side padding. */
|
|
176
|
+
[data-slot="button"][data-icon] {
|
|
177
|
+
inline-size: var(--_height);
|
|
178
|
+
padding: 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
[data-slot="button"] svg {
|
|
182
|
+
inline-size: var(--_icon);
|
|
183
|
+
block-size: var(--_icon);
|
|
184
|
+
flex: none;
|
|
185
|
+
pointer-events: none;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
[data-slot="button-label"] {
|
|
189
|
+
display: inline-flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
justify-content: center;
|
|
192
|
+
gap: var(--_gap);
|
|
193
|
+
transition: opacity var(--kumiko-fade-duration) var(--kumiko-fade-ease);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
[data-slot="button"][data-variant="solid"] {
|
|
197
|
+
--_bg: var(--kumiko-button-solid-bg);
|
|
198
|
+
--_fg: var(--kumiko-button-solid-fg);
|
|
199
|
+
--_hover-bg: var(
|
|
200
|
+
--kumiko-button-solid-hover-bg,
|
|
201
|
+
color-mix(in oklab, var(--kumiko-button-solid-bg) 85%, CanvasText)
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
[data-slot="button"][data-variant="secondary"] {
|
|
206
|
+
--_bg: var(--kumiko-button-secondary-bg);
|
|
207
|
+
--_fg: var(--kumiko-button-secondary-fg);
|
|
208
|
+
--_hover-bg: var(
|
|
209
|
+
--kumiko-button-secondary-hover-bg,
|
|
210
|
+
color-mix(in oklab, var(--kumiko-button-secondary-bg) 88%, CanvasText)
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
[data-slot="button"][data-variant="outline"] {
|
|
215
|
+
--_border: var(--kumiko-button-outline-border);
|
|
216
|
+
--_fg: var(--kumiko-button-outline-fg);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
[data-slot="button"][data-variant="ghost"] {
|
|
220
|
+
--_fg: var(--kumiko-button-ghost-fg);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
[data-slot="button"][data-variant="destructive"] {
|
|
224
|
+
--_bg: var(--kumiko-button-danger);
|
|
225
|
+
--_fg: var(--kumiko-button-danger-fg);
|
|
226
|
+
--_hover-bg: var(
|
|
227
|
+
--kumiko-button-danger-hover-bg,
|
|
228
|
+
color-mix(in oklab, var(--kumiko-button-danger) 85%, CanvasText)
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
[data-slot="button"][data-variant="destructive-ghost"] {
|
|
233
|
+
--_fg: var(--_danger-ink);
|
|
234
|
+
--_hover-bg: var(--_danger-tint);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
[data-slot="button"][data-variant="link"] {
|
|
238
|
+
--_fg: var(--kumiko-button-link-fg);
|
|
239
|
+
text-underline-offset: 0.25em;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
[data-slot="button"]:focus-visible {
|
|
243
|
+
outline: var(--kumiko-button-focus-ring-width) solid var(--kumiko-button-focus-ring);
|
|
244
|
+
outline-offset: var(--kumiko-button-focus-ring-offset);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* Done takes the success colours, error a danger ink on a faint danger fill with a ring. */
|
|
248
|
+
[data-slot="button"][data-status="done"] {
|
|
249
|
+
--_bg: var(--kumiko-button-success);
|
|
250
|
+
--_hover-bg: var(--kumiko-button-success);
|
|
251
|
+
--_fg: var(--kumiko-button-success-fg);
|
|
252
|
+
--_border: transparent;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
[data-slot="button"][data-status="error"] {
|
|
256
|
+
--_bg: var(--_error-bg);
|
|
257
|
+
--_hover-bg: var(--_error-bg);
|
|
258
|
+
--_fg: var(--_danger-ink);
|
|
259
|
+
--_shadow: inset 0 0 0 var(--kumiko-button-error-ring-width) var(--kumiko-button-danger);
|
|
260
|
+
animation: var(--_nudge-animation);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* Disabled is dimmed and inert. A button that is only loading is busy, not unavailable. */
|
|
264
|
+
[data-slot="button"][data-disabled]:not([data-status="loading"]) {
|
|
265
|
+
opacity: var(--kumiko-button-disabled-opacity);
|
|
266
|
+
cursor: not-allowed;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
[data-slot="button"][data-status="loading"] {
|
|
270
|
+
cursor: progress;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
[data-slot="button"]:not([data-disabled], [data-status="loading"]):active {
|
|
274
|
+
scale: var(--kumiko-press-scale);
|
|
275
|
+
transition-duration:
|
|
276
|
+
var(--kumiko-fade-duration), var(--kumiko-fade-duration), var(--kumiko-fade-duration),
|
|
277
|
+
var(--kumiko-fade-duration), var(--kumiko-press-duration);
|
|
278
|
+
transition-timing-function:
|
|
279
|
+
var(--kumiko-fade-ease), var(--kumiko-fade-ease), var(--kumiko-fade-ease),
|
|
280
|
+
var(--kumiko-fade-ease), var(--kumiko-press-ease);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* Every variant grows a little on hover, and the quiet ones tint. A button never tilts. */
|
|
284
|
+
@media (hover: hover) and (pointer: fine) {
|
|
285
|
+
[data-slot="button"]:not([data-disabled], [data-status="loading"]):hover {
|
|
286
|
+
background: var(--_hover-bg);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
[data-slot="button"][data-variant="link"]:not(
|
|
290
|
+
[data-disabled],
|
|
291
|
+
[data-status="loading"]
|
|
292
|
+
):hover {
|
|
293
|
+
text-decoration: underline;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
[data-slot="button"]:not([data-disabled], [data-status="loading"]):hover:not(:active) {
|
|
297
|
+
scale: var(--kumiko-hover-scale);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/* The ghost-tint word, on any container, turns the grow off for the quiet variants: they only tint. */
|
|
301
|
+
:is(
|
|
302
|
+
[data-kumiko-button~="ghost-tint"] [data-slot="button"],
|
|
303
|
+
[data-slot="button"][data-kumiko-button~="ghost-tint"]
|
|
304
|
+
):is(
|
|
305
|
+
[data-variant="ghost"],
|
|
306
|
+
[data-variant="destructive-ghost"],
|
|
307
|
+
[data-variant="link"]
|
|
308
|
+
):not([data-disabled], [data-status="loading"]):hover:not(:active) {
|
|
309
|
+
scale: none;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* Loading: dots hide the label with opacity so its name stays, and show bouncing dots over it. */
|
|
314
|
+
[data-slot="button"][data-status="loading"][data-loading-style="dots"]
|
|
315
|
+
> [data-slot="button-label"] {
|
|
316
|
+
opacity: 0;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
[data-slot="button-dots"] {
|
|
320
|
+
position: absolute;
|
|
321
|
+
inset: 0;
|
|
322
|
+
display: flex;
|
|
323
|
+
align-items: center;
|
|
324
|
+
justify-content: center;
|
|
325
|
+
gap: var(--kumiko-button-dot-gap);
|
|
326
|
+
pointer-events: none;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
[data-slot="button-dots"] > i {
|
|
330
|
+
inline-size: var(--kumiko-button-dot-size);
|
|
331
|
+
block-size: var(--kumiko-button-dot-size);
|
|
332
|
+
border-radius: 50%;
|
|
333
|
+
background: currentColor;
|
|
334
|
+
animation: var(--_dot-animation);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
[data-slot="button-dots"] > i:nth-child(2) {
|
|
338
|
+
animation-delay: var(--kumiko-button-dot-stagger);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
[data-slot="button-dots"] > i:nth-child(3) {
|
|
342
|
+
animation-delay: calc(var(--kumiko-button-dot-stagger) * 2);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/* Spinner: the space opens beside the label as the arc fades in, so the width glides instead of jumping. */
|
|
346
|
+
[data-slot="button-spinner"] {
|
|
347
|
+
display: inline-grid;
|
|
348
|
+
flex: none;
|
|
349
|
+
place-items: center;
|
|
350
|
+
inline-size: var(--kumiko-button-spinner-size);
|
|
351
|
+
block-size: var(--kumiko-button-spinner-size);
|
|
352
|
+
animation: var(--_spinner-enter);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
[data-slot="button-spinner"] > svg {
|
|
356
|
+
inline-size: 100%;
|
|
357
|
+
block-size: 100%;
|
|
358
|
+
animation: var(--_spin-animation);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/* Shimmer: a soft band sweeps across the face, and the label is a little dimmer. */
|
|
362
|
+
[data-slot="button"][data-status="loading"][data-loading-style="shimmer"]
|
|
363
|
+
> [data-slot="button-label"] {
|
|
364
|
+
opacity: var(--kumiko-button-loading-dim);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
[data-slot="button"][data-status="loading"][data-loading-style="shimmer"]::after {
|
|
368
|
+
content: "";
|
|
369
|
+
position: absolute;
|
|
370
|
+
inset: calc(var(--kumiko-button-border-width) * -1);
|
|
371
|
+
border-radius: inherit;
|
|
372
|
+
background: var(--_shimmer-image) 100% 0 / var(--_shimmer-size) no-repeat;
|
|
373
|
+
pointer-events: none;
|
|
374
|
+
animation: var(--_shimmer-animation);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/* Orbit: a short bright segment travels around the border, drawn as a conic gradient seen through a ring mask. */
|
|
378
|
+
[data-slot="button"][data-status="loading"][data-loading-style="orbit"]::before {
|
|
379
|
+
content: "";
|
|
380
|
+
position: absolute;
|
|
381
|
+
inset: calc(var(--kumiko-button-border-width) * -1);
|
|
382
|
+
padding: var(--kumiko-button-orbit-width);
|
|
383
|
+
border-radius: inherit;
|
|
384
|
+
background: conic-gradient(
|
|
385
|
+
from var(--kumiko-button-angle),
|
|
386
|
+
transparent calc(100% - var(--kumiko-button-orbit-length)),
|
|
387
|
+
var(--kumiko-button-orbit-color)
|
|
388
|
+
);
|
|
389
|
+
mask:
|
|
390
|
+
linear-gradient(#000 0 0) content-box,
|
|
391
|
+
linear-gradient(#000 0 0);
|
|
392
|
+
mask-composite: exclude;
|
|
393
|
+
pointer-events: none;
|
|
394
|
+
animation: var(--_orbit-animation);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/* Breathe: the whole button pulses its opacity. */
|
|
398
|
+
[data-slot="button"][data-status="loading"][data-loading-style="breathe"] {
|
|
399
|
+
animation: var(--_breathe-animation);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/* Done: the tick drops in at the start of the label. */
|
|
403
|
+
[data-slot="button-tick"] {
|
|
404
|
+
animation: var(--_tick-animation);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/* An icon-only button has no room beside the icon, so a tick or spinner takes its place. */
|
|
408
|
+
[data-slot="button"][data-icon] > :is([data-slot="button-tick"], [data-slot="button-spinner"]) {
|
|
409
|
+
position: absolute;
|
|
410
|
+
inset: 0;
|
|
411
|
+
margin: auto;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/* The spinner of an icon button takes the icon's place, so there is no width to open. */
|
|
415
|
+
[data-slot="button"][data-icon] > [data-slot="button-spinner"] {
|
|
416
|
+
animation: none;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
[data-slot="button"][data-icon]:is(
|
|
420
|
+
[data-status="done"],
|
|
421
|
+
[data-status="loading"][data-loading-style="spinner"]
|
|
422
|
+
)
|
|
423
|
+
> [data-slot="button-label"] {
|
|
424
|
+
opacity: 0;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
@keyframes kumiko-button-dot {
|
|
428
|
+
0%,
|
|
429
|
+
60%,
|
|
430
|
+
100% {
|
|
431
|
+
translate: 0 0;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
30% {
|
|
435
|
+
translate: 0 calc(var(--kumiko-button-dot-lift) * -1);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
@keyframes kumiko-button-spin {
|
|
440
|
+
to {
|
|
441
|
+
rotate: 360deg;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
@keyframes kumiko-button-spinner-in {
|
|
446
|
+
from {
|
|
447
|
+
inline-size: 0;
|
|
448
|
+
margin-inline-end: calc(var(--_gap) * -1);
|
|
449
|
+
opacity: 0;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
@keyframes kumiko-button-shimmer {
|
|
454
|
+
from {
|
|
455
|
+
background-position: 100% 0;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
to {
|
|
459
|
+
background-position: 0 0;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
@keyframes kumiko-button-orbit {
|
|
464
|
+
to {
|
|
465
|
+
--kumiko-button-angle: 360deg;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
@keyframes kumiko-button-breathe {
|
|
470
|
+
from {
|
|
471
|
+
opacity: 1;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
to {
|
|
475
|
+
opacity: var(--kumiko-button-breathe-min);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
@keyframes kumiko-button-tick {
|
|
480
|
+
from {
|
|
481
|
+
translate: 0 -1.1em;
|
|
482
|
+
opacity: 0;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
@keyframes kumiko-button-nudge {
|
|
487
|
+
0%,
|
|
488
|
+
100% {
|
|
489
|
+
translate: 0 0;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
20%,
|
|
493
|
+
60% {
|
|
494
|
+
translate: calc(var(--kumiko-button-nudge) * -1) 0;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
40%,
|
|
498
|
+
80% {
|
|
499
|
+
translate: var(--kumiko-button-nudge) 0;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
@keyframes kumiko-button-fade {
|
|
504
|
+
from {
|
|
505
|
+
opacity: 0.3;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
to {
|
|
509
|
+
opacity: 1;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/* Reduced motion and the still preset never move: loading fades slowly in place, and the tick and nudge are off. */
|
|
514
|
+
@media (prefers-reduced-motion: reduce) {
|
|
515
|
+
[data-slot="button"] {
|
|
516
|
+
--_dot-animation: kumiko-button-fade var(--kumiko-button-reduced-duration)
|
|
517
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
518
|
+
--_spin-animation: kumiko-button-fade var(--kumiko-button-reduced-duration)
|
|
519
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
520
|
+
--_spinner-enter: none;
|
|
521
|
+
--_shimmer-animation: kumiko-button-fade var(--kumiko-button-reduced-duration)
|
|
522
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
523
|
+
--_shimmer-image: linear-gradient(
|
|
524
|
+
var(--kumiko-button-shimmer-color),
|
|
525
|
+
var(--kumiko-button-shimmer-color)
|
|
526
|
+
);
|
|
527
|
+
--_shimmer-size: 100% 100%;
|
|
528
|
+
--_orbit-animation: kumiko-button-fade var(--kumiko-button-reduced-duration)
|
|
529
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
530
|
+
--_breathe-animation: kumiko-button-breathe var(--kumiko-button-reduced-duration)
|
|
531
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
532
|
+
--_tick-animation: none;
|
|
533
|
+
--_nudge-animation: none;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
[data-kumiko-motion="still"] [data-slot="button"] {
|
|
538
|
+
--_dot-animation: kumiko-button-fade var(--kumiko-button-reduced-duration)
|
|
539
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
540
|
+
--_spin-animation: kumiko-button-fade var(--kumiko-button-reduced-duration)
|
|
541
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
542
|
+
--_spinner-enter: none;
|
|
543
|
+
--_shimmer-animation: kumiko-button-fade var(--kumiko-button-reduced-duration)
|
|
544
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
545
|
+
--_shimmer-image: linear-gradient(
|
|
546
|
+
var(--kumiko-button-shimmer-color),
|
|
547
|
+
var(--kumiko-button-shimmer-color)
|
|
548
|
+
);
|
|
549
|
+
--_shimmer-size: 100% 100%;
|
|
550
|
+
--_orbit-animation: kumiko-button-fade var(--kumiko-button-reduced-duration)
|
|
551
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
552
|
+
--_breathe-animation: kumiko-button-breathe var(--kumiko-button-reduced-duration)
|
|
553
|
+
var(--kumiko-button-pulse-ease) infinite alternate;
|
|
554
|
+
--_tick-animation: none;
|
|
555
|
+
--_nudge-animation: none;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/* Forced colours replace the fills, so every button keeps a border and a ring in system colours. */
|
|
559
|
+
@media (forced-colors: active) {
|
|
560
|
+
[data-slot="button"][data-status="done"] {
|
|
561
|
+
--_border: Highlight;
|
|
562
|
+
border-width: 2px;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
[data-slot="button"][data-status="error"] {
|
|
566
|
+
border-style: dashed;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
[data-slot="button"][data-disabled]:not([data-status="loading"]) {
|
|
570
|
+
--_border: GrayText;
|
|
571
|
+
|
|
572
|
+
color: GrayText;
|
|
573
|
+
opacity: 1;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Button as SdkButton } from "@ui-sdk/react/button";
|
|
2
|
+
type SdkButtonProps = Parameters<typeof SdkButton>[0];
|
|
3
|
+
/** How a button looks: a solid fill, a quiet fill, an outline, no chrome, a warning, or a text link. */
|
|
4
|
+
export type ButtonVariant = "solid" | "secondary" | "outline" | "ghost" | "destructive" | "destructive-ghost" | "link";
|
|
5
|
+
/** How tall a button is. `touch` is at least 44px, for a finger. */
|
|
6
|
+
export type ButtonSize = "xs" | "sm" | "md" | "lg" | "touch";
|
|
7
|
+
/** What a button shows besides its label: working, worked, or failed. */
|
|
8
|
+
export type ButtonStatus = "loading" | "done" | "error";
|
|
9
|
+
/** How a button shows that it is loading: bouncing dots, a spinner, a sweeping band, an orbiting segment, or a gentle pulse. */
|
|
10
|
+
export type LoadingStyle = "dots" | "spinner" | "shimmer" | "orbit" | "breathe";
|
|
11
|
+
export type ButtonProps = Omit<SdkButtonProps, "children"> & {
|
|
12
|
+
/** What the button holds: text, icons, or both. A function of the state is not supported. */
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
/** @defaultValue "solid" */
|
|
15
|
+
variant?: ButtonVariant;
|
|
16
|
+
/** @defaultValue "md" */
|
|
17
|
+
size?: ButtonSize;
|
|
18
|
+
/** Makes the button square at its size, for an icon with no text. Give it an `aria-label`. @defaultValue false */
|
|
19
|
+
icon?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Shows a status from outside, such as `status={busy ? "loading" : undefined}`.
|
|
22
|
+
* It wins over the automatic status.
|
|
23
|
+
* While `"loading"` the button ignores presses and keeps focus.
|
|
24
|
+
*/
|
|
25
|
+
status?: ButtonStatus;
|
|
26
|
+
/** How loading looks, whichever way it started. @defaultValue "shimmer" */
|
|
27
|
+
loading?: LoadingStyle;
|
|
28
|
+
/** Shows done or error when an `onClick` Promise settles. Loading is shown either way. @defaultValue true */
|
|
29
|
+
feedback?: boolean;
|
|
30
|
+
/** How long done is held after a Promise resolves, in milliseconds. @defaultValue 1600 */
|
|
31
|
+
doneFor?: number;
|
|
32
|
+
/** How long error is held after a Promise rejects or the handler throws, in milliseconds. @defaultValue 2400 */
|
|
33
|
+
errorFor?: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The ui-sdk button with Kumiko's look and motion.
|
|
37
|
+
* `variant` and `size` pick the look, and `icon` makes it square for an icon with no text.
|
|
38
|
+
* Give an icon button an `aria-label`.
|
|
39
|
+
* It stays a native `<button>`, or a link with `render={<a href="..." />}`.
|
|
40
|
+
*
|
|
41
|
+
* Return a Promise from `onClick` and the button shows loading while it runs.
|
|
42
|
+
* Then it shows done or error, and goes back to idle after `doneFor` or `errorFor`.
|
|
43
|
+
* `status` sets the same from outside and wins.
|
|
44
|
+
* While loading the button ignores presses, says it is busy and keeps focus.
|
|
45
|
+
* `loading` picks how that looks.
|
|
46
|
+
* Put `data-kumiko-button="ghost-tint"` on any container to make ghost, destructive-ghost and link
|
|
47
|
+
* buttons tint on hover without growing.
|
|
48
|
+
*/
|
|
49
|
+
export declare function Button({ variant, size, icon, status, loading, feedback, doneFor, errorFor, onClick, disabled, focusableWhenDisabled, children, ...props }: ButtonProps): React.JSX.Element | null;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button as SdkButton } from "@ui-sdk/react/button";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
function isPromiseLike(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && "then" in value;
|
|
6
|
+
}
|
|
7
|
+
/** Holds the status an `onClick` Promise gives the button, and lets go of a held done or error after its time. */
|
|
8
|
+
function useAutomaticStatus(feedback, doneFor, errorFor) {
|
|
9
|
+
const [automatic, setAutomatic] = useState(undefined);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (automatic !== "done" && automatic !== "error") {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const timer = setTimeout(() => setAutomatic(undefined), automatic === "done" ? doneFor : errorFor);
|
|
15
|
+
return () => clearTimeout(timer);
|
|
16
|
+
}, [automatic, doneFor, errorFor]);
|
|
17
|
+
/** Runs the handler. A Promise it returns is passed on as it is, so ui-sdk still keeps the button pending. */
|
|
18
|
+
function track(run) {
|
|
19
|
+
setAutomatic(undefined);
|
|
20
|
+
let result;
|
|
21
|
+
try {
|
|
22
|
+
result = run();
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
setAutomatic(feedback ? "error" : undefined);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
if (!isPromiseLike(result)) {
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
setAutomatic("loading");
|
|
32
|
+
return result.then((value) => {
|
|
33
|
+
setAutomatic(feedback ? "done" : undefined);
|
|
34
|
+
return value;
|
|
35
|
+
}, (error) => {
|
|
36
|
+
setAutomatic(feedback ? "error" : undefined);
|
|
37
|
+
throw error;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return { automatic, track };
|
|
41
|
+
}
|
|
42
|
+
function Dots() {
|
|
43
|
+
return (_jsxs("span", { "data-slot": "button-dots", "aria-hidden": "true", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }));
|
|
44
|
+
}
|
|
45
|
+
function Spinner() {
|
|
46
|
+
return (_jsx("span", { "data-slot": "button-spinner", "aria-hidden": "true", children: _jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3.5", children: _jsx("circle", { cx: "12", cy: "12", r: "9", strokeLinecap: "round", strokeDasharray: "38 100" }) }) }));
|
|
47
|
+
}
|
|
48
|
+
function Tick() {
|
|
49
|
+
return (_jsx("svg", { "data-slot": "button-tick", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2.5", "aria-hidden": "true", children: _jsx("path", { d: "M3 8.5 6.5 12 13 4.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The ui-sdk button with Kumiko's look and motion.
|
|
53
|
+
* `variant` and `size` pick the look, and `icon` makes it square for an icon with no text.
|
|
54
|
+
* Give an icon button an `aria-label`.
|
|
55
|
+
* It stays a native `<button>`, or a link with `render={<a href="..." />}`.
|
|
56
|
+
*
|
|
57
|
+
* Return a Promise from `onClick` and the button shows loading while it runs.
|
|
58
|
+
* Then it shows done or error, and goes back to idle after `doneFor` or `errorFor`.
|
|
59
|
+
* `status` sets the same from outside and wins.
|
|
60
|
+
* While loading the button ignores presses, says it is busy and keeps focus.
|
|
61
|
+
* `loading` picks how that looks.
|
|
62
|
+
* Put `data-kumiko-button="ghost-tint"` on any container to make ghost, destructive-ghost and link
|
|
63
|
+
* buttons tint on hover without growing.
|
|
64
|
+
*/
|
|
65
|
+
export function Button({ variant = "solid", size = "md", icon = false, status, loading = "shimmer", feedback = true, doneFor = 1600, errorFor = 2400, onClick, disabled, focusableWhenDisabled, children, ...props }) {
|
|
66
|
+
const { automatic, track } = useAutomaticStatus(feedback, doneFor, errorFor);
|
|
67
|
+
const shown = status ?? automatic;
|
|
68
|
+
const lockedFromOutside = status === "loading";
|
|
69
|
+
return (_jsxs(SdkButton, { "data-variant": variant, "data-size": size, "data-icon": icon ? "" : undefined, "data-status": shown, "data-loading-style": loading, "aria-busy": shown === "loading" ? true : undefined, disabled: disabled === true || lockedFromOutside, focusableWhenDisabled: focusableWhenDisabled === true || lockedFromOutside, onClick: (event, details) => track(() => onClick?.(event, details)), ...props, children: [shown === "done" ? _jsx(Tick, {}) : null, _jsx("span", { "data-slot": "button-label", children: children }), shown === "loading" && loading === "dots" ? _jsx(Dots, {}) : null, shown === "loading" && loading === "spinner" ? _jsx(Spinner, {}) : null] }));
|
|
70
|
+
}
|