@sereno-ds/ui 0.24.0
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 +107 -0
- package/dist/_internal/CharCount.d.ts +9 -0
- package/dist/_internal/CharCount.js +25 -0
- package/dist/_internal/CharCount.js.map +1 -0
- package/dist/_internal/Field.d.ts +17 -0
- package/dist/_internal/Field.js +55 -0
- package/dist/_internal/Field.js.map +1 -0
- package/dist/_internal/mask.d.ts +12 -0
- package/dist/_internal/mask.js +56 -0
- package/dist/_internal/mask.js.map +1 -0
- package/dist/_internal/style.d.ts +12 -0
- package/dist/_internal/style.js +5 -0
- package/dist/_internal/style.js.map +1 -0
- package/dist/core/Avatar.d.ts +14 -0
- package/dist/core/Avatar.js +62 -0
- package/dist/core/Avatar.js.map +1 -0
- package/dist/core/Badge.d.ts +16 -0
- package/dist/core/Badge.js +49 -0
- package/dist/core/Badge.js.map +1 -0
- package/dist/core/Brand.d.ts +18 -0
- package/dist/core/Brand.js +58 -0
- package/dist/core/Brand.js.map +1 -0
- package/dist/core/Button.d.ts +31 -0
- package/dist/core/Button.js +100 -0
- package/dist/core/Button.js.map +1 -0
- package/dist/core/Card.d.ts +15 -0
- package/dist/core/Card.js +34 -0
- package/dist/core/Card.js.map +1 -0
- package/dist/core/IconButton.d.ts +18 -0
- package/dist/core/IconButton.js +64 -0
- package/dist/core/IconButton.js.map +1 -0
- package/dist/core/Menu.d.ts +69 -0
- package/dist/core/Menu.js +278 -0
- package/dist/core/Menu.js.map +1 -0
- package/dist/core/Table.d.ts +92 -0
- package/dist/core/Table.js +162 -0
- package/dist/core/Table.js.map +1 -0
- package/dist/feedback/Alert.d.ts +27 -0
- package/dist/feedback/Alert.js +68 -0
- package/dist/feedback/Alert.js.map +1 -0
- package/dist/feedback/Dialog.d.ts +36 -0
- package/dist/feedback/Dialog.js +218 -0
- package/dist/feedback/Dialog.js.map +1 -0
- package/dist/feedback/EmptyState.d.ts +13 -0
- package/dist/feedback/EmptyState.js +70 -0
- package/dist/feedback/EmptyState.js.map +1 -0
- package/dist/feedback/Skeleton.d.ts +23 -0
- package/dist/feedback/Skeleton.js +44 -0
- package/dist/feedback/Skeleton.js.map +1 -0
- package/dist/feedback/Toast.d.ts +23 -0
- package/dist/feedback/Toast.js +85 -0
- package/dist/feedback/Toast.js.map +1 -0
- package/dist/feedback/ToastProvider.d.ts +69 -0
- package/dist/feedback/ToastProvider.js +183 -0
- package/dist/feedback/ToastProvider.js.map +1 -0
- package/dist/forms/AvatarUpload.d.ts +57 -0
- package/dist/forms/AvatarUpload.js +579 -0
- package/dist/forms/AvatarUpload.js.map +1 -0
- package/dist/forms/Checkbox.d.ts +15 -0
- package/dist/forms/Checkbox.js +57 -0
- package/dist/forms/Checkbox.js.map +1 -0
- package/dist/forms/DateTimePicker.d.ts +43 -0
- package/dist/forms/DateTimePicker.js +391 -0
- package/dist/forms/DateTimePicker.js.map +1 -0
- package/dist/forms/FileUpload.d.ts +39 -0
- package/dist/forms/FileUpload.js +376 -0
- package/dist/forms/FileUpload.js.map +1 -0
- package/dist/forms/Input.d.ts +35 -0
- package/dist/forms/Input.js +143 -0
- package/dist/forms/Input.js.map +1 -0
- package/dist/forms/Radio.d.ts +18 -0
- package/dist/forms/Radio.js +50 -0
- package/dist/forms/Radio.js.map +1 -0
- package/dist/forms/SearchInput.d.ts +23 -0
- package/dist/forms/SearchInput.js +70 -0
- package/dist/forms/SearchInput.js.map +1 -0
- package/dist/forms/Select.d.ts +40 -0
- package/dist/forms/Select.js +524 -0
- package/dist/forms/Select.js.map +1 -0
- package/dist/forms/Switch.d.ts +20 -0
- package/dist/forms/Switch.js +76 -0
- package/dist/forms/Switch.js.map +1 -0
- package/dist/forms/Textarea.d.ts +19 -0
- package/dist/forms/Textarea.js +65 -0
- package/dist/forms/Textarea.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/navigation/BottomNav.d.ts +17 -0
- package/dist/navigation/BottomNav.js +72 -0
- package/dist/navigation/BottomNav.js.map +1 -0
- package/dist/navigation/SidebarNav.d.ts +53 -0
- package/dist/navigation/SidebarNav.js +594 -0
- package/dist/navigation/SidebarNav.js.map +1 -0
- package/dist/navigation/Stepper.d.ts +33 -0
- package/dist/navigation/Stepper.js +87 -0
- package/dist/navigation/Stepper.js.map +1 -0
- package/dist/navigation/Tabs.d.ts +23 -0
- package/dist/navigation/Tabs.js +174 -0
- package/dist/navigation/Tabs.js.map +1 -0
- package/dist/navigation/TopBar.d.ts +17 -0
- package/dist/navigation/TopBar.js +65 -0
- package/dist/navigation/TopBar.js.map +1 -0
- package/dist/styles.css +258 -0
- package/dist/theme/ThemeProvider.d.ts +12 -0
- package/dist/theme/ThemeProvider.js +10 -0
- package/dist/theme/ThemeProvider.js.map +1 -0
- package/dist/theme/ThemeToggle.d.ts +14 -0
- package/dist/theme/ThemeToggle.js +25 -0
- package/dist/theme/ThemeToggle.js.map +1 -0
- package/package.json +79 -0
package/dist/styles.css
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/* ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
@sereno-ds/ui — component stylesheet.
|
|
3
|
+
|
|
4
|
+
The Sereno components are token-driven inline styles, but a handful of things
|
|
5
|
+
can't live in an inline `style`: @keyframes, pseudo-classes (:checked,
|
|
6
|
+
:focus-visible), pseudo-elements (::-webkit-scrollbar) and one narrow
|
|
7
|
+
responsive reflow. Those rules live here and MUST be loaded once, at the app
|
|
8
|
+
root, for the components to render correctly:
|
|
9
|
+
|
|
10
|
+
import '@sereno-ds/ui/styles.css'; // (today: this file, via app/globals.css)
|
|
11
|
+
|
|
12
|
+
Depends on the design tokens (custom properties) being defined — see
|
|
13
|
+
app/styles/tokens/*.css (future @sereno-ds/tokens).
|
|
14
|
+
|
|
15
|
+
Not included here (host-app concerns, not the library):
|
|
16
|
+
- the token layer itself
|
|
17
|
+
- `@media (pointer: coarse)` 16px font bump (stops iOS focus zoom)
|
|
18
|
+
- the app shell / screen classes (`.ds-*`, `.cv-*`, `.dash-*`, `.onb-*`)
|
|
19
|
+
──────────────────────────────────────────────────────────────────────────── */
|
|
20
|
+
|
|
21
|
+
/* ── Keyframes ───────────────────────────────────────────────────────────────
|
|
22
|
+
Button's spinner, Dialog/Toast entrances, Skeleton pulse, SidebarNav's rail
|
|
23
|
+
flyout + collapsed-rail tooltip, the ToastProvider stack enter/exit. */
|
|
24
|
+
@keyframes sereno-spin { to { transform: rotate(360deg); } }
|
|
25
|
+
@keyframes sereno-pop { from { opacity: 0; transform: scale(0.96); } }
|
|
26
|
+
@keyframes sereno-slide-up { from { opacity: 0; transform: translateY(10px); } }
|
|
27
|
+
@keyframes sereno-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
|
|
28
|
+
@keyframes sereno-flyout-in { from { opacity: 0; transform: translateX(-6px); } }
|
|
29
|
+
@keyframes sereno-fade-in { from { opacity: 0; } }
|
|
30
|
+
@keyframes sereno-toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
|
|
31
|
+
@keyframes sereno-toast-in-top { from { opacity: 0; transform: translateY(-12px) scale(0.98); } }
|
|
32
|
+
@keyframes sereno-toast-out { to { opacity: 0; transform: scale(0.96); } }
|
|
33
|
+
@keyframes sereno-toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
|
|
34
|
+
|
|
35
|
+
/* ── Checkbox / Radio / Switch ───────────────────────────────────────────────
|
|
36
|
+
Checkbox and Radio render bare <input>s; Switch is a role="switch" <span>.
|
|
37
|
+
All three need these host rules for their checked / focus states. */
|
|
38
|
+
.sereno-check:checked,
|
|
39
|
+
.sereno-check:indeterminate {
|
|
40
|
+
/* `background-color`, not the `background` shorthand — the shorthand would
|
|
41
|
+
reset `background-size` and the glyph would stop scaling with the box. */
|
|
42
|
+
background-color: var(--interactive-primary) !important;
|
|
43
|
+
border-color: var(--interactive-primary) !important;
|
|
44
|
+
background-size: 68%; /* scales with the box: ~14px at md (20), ~11px at sm (16) */
|
|
45
|
+
background-position: center;
|
|
46
|
+
background-repeat: no-repeat;
|
|
47
|
+
}
|
|
48
|
+
.sereno-check:checked {
|
|
49
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") !important;
|
|
50
|
+
}
|
|
51
|
+
.sereno-check:indeterminate {
|
|
52
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E") !important;
|
|
53
|
+
}
|
|
54
|
+
.sereno-radio:checked {
|
|
55
|
+
background-color: var(--interactive-primary) !important;
|
|
56
|
+
border-color: var(--interactive-primary) !important;
|
|
57
|
+
box-shadow: inset 0 0 0 3.5px var(--bg-surface) !important;
|
|
58
|
+
}
|
|
59
|
+
.sereno-radio[data-size='sm']:checked {
|
|
60
|
+
box-shadow: inset 0 0 0 3px var(--bg-surface) !important;
|
|
61
|
+
}
|
|
62
|
+
/* Switch is a role=switch <span>, not an input — give it a keyboard focus ring. */
|
|
63
|
+
.sereno-switch {
|
|
64
|
+
outline: none;
|
|
65
|
+
}
|
|
66
|
+
.sereno-switch:focus-visible {
|
|
67
|
+
box-shadow: var(--focus-ring);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ── Tabs ────────────────────────────────────────────────────────────────────
|
|
71
|
+
The strip scrolls horizontally when it overflows — hide the scrollbar
|
|
72
|
+
(the chevrons are the affordance). */
|
|
73
|
+
.sereno-tab-scroll {
|
|
74
|
+
scrollbar-width: none;
|
|
75
|
+
-ms-overflow-style: none;
|
|
76
|
+
}
|
|
77
|
+
.sereno-tab-scroll::-webkit-scrollbar {
|
|
78
|
+
display: none;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* ── SidebarNav ──────────────────────────────────────────────────────────────
|
|
82
|
+
Thin scroll area, a keyboard ring on its plain <button> rows, and — when
|
|
83
|
+
collapsed — a hidden scrollbar so a scrollbar gutter can't push the centred
|
|
84
|
+
icons off-axis from the header mark. */
|
|
85
|
+
.sereno-sidenav {
|
|
86
|
+
scrollbar-width: thin;
|
|
87
|
+
scrollbar-color: var(--border-default) transparent;
|
|
88
|
+
}
|
|
89
|
+
.sereno-sidenav::-webkit-scrollbar {
|
|
90
|
+
width: 6px;
|
|
91
|
+
}
|
|
92
|
+
.sereno-sidenav::-webkit-scrollbar-thumb {
|
|
93
|
+
background: var(--border-default);
|
|
94
|
+
border-radius: 999px;
|
|
95
|
+
}
|
|
96
|
+
.sereno-sidenav-root[data-collapsed] .sereno-sidenav {
|
|
97
|
+
scrollbar-width: none;
|
|
98
|
+
}
|
|
99
|
+
.sereno-sidenav-root[data-collapsed] .sereno-sidenav::-webkit-scrollbar {
|
|
100
|
+
display: none;
|
|
101
|
+
}
|
|
102
|
+
.sereno-sidenav-btn {
|
|
103
|
+
outline: none;
|
|
104
|
+
}
|
|
105
|
+
.sereno-sidenav-btn:focus-visible {
|
|
106
|
+
outline: 2px solid var(--border-focus);
|
|
107
|
+
outline-offset: -2px;
|
|
108
|
+
}
|
|
109
|
+
.sereno-sidenav-toggle:hover {
|
|
110
|
+
background: var(--interactive-secondary-hover);
|
|
111
|
+
color: var(--text-primary);
|
|
112
|
+
border-color: var(--border-strong);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* ── In-field affix button ───────────────────────────────────────────────────
|
|
116
|
+
A bare icon button that sits inside the field frame (Input's password reveal,
|
|
117
|
+
SearchInput's clear, FileUpload / AvatarUpload actions). NOTE: the class is
|
|
118
|
+
`ds-affix-btn` for historical reasons — rename to `sereno-affix-btn` is a
|
|
119
|
+
breaking class-contract change, deferred. */
|
|
120
|
+
.ds-affix-btn {
|
|
121
|
+
display: inline-flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
justify-content: center;
|
|
124
|
+
flex: 0 0 auto;
|
|
125
|
+
padding: 0;
|
|
126
|
+
margin: 0;
|
|
127
|
+
border: none;
|
|
128
|
+
background: transparent;
|
|
129
|
+
color: var(--text-muted);
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
border-radius: var(--radius-sm);
|
|
132
|
+
}
|
|
133
|
+
.ds-affix-btn:hover { color: var(--text-secondary); }
|
|
134
|
+
.ds-affix-btn:focus { outline: none; }
|
|
135
|
+
.ds-affix-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
|
|
136
|
+
|
|
137
|
+
/* ── Table ──────────────────────────────────────────────────────────────────
|
|
138
|
+
Ships with @sereno-ds/ui's compound <Table>. The parts stay thin — structure,
|
|
139
|
+
density, dividers, hover / focus / sticky / zebra live here, keyed off
|
|
140
|
+
data-* on the <table> root. */
|
|
141
|
+
.sereno-table { width: 100%; border-collapse: collapse; font-family: var(--font-body); }
|
|
142
|
+
/* Visually-hidden <caption>. `top/left: 0` pins it to the (position: relative)
|
|
143
|
+
scroll region — without an anchor a position:absolute caption falls back to its
|
|
144
|
+
static offset against the viewport and stretches the page's scroll height. */
|
|
145
|
+
.sereno-table caption { position: absolute; top: 0; left: 0; width: 1px; height: 1px; padding: 0; margin: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
146
|
+
.sereno-table thead tr { background: var(--bg-subtle); }
|
|
147
|
+
.sereno-table th {
|
|
148
|
+
font-size: var(--text-2xs);
|
|
149
|
+
font-weight: var(--weight-semibold);
|
|
150
|
+
letter-spacing: var(--tracking-caps);
|
|
151
|
+
text-transform: uppercase;
|
|
152
|
+
color: var(--text-secondary);
|
|
153
|
+
white-space: nowrap;
|
|
154
|
+
border-bottom: 1px solid var(--border-default);
|
|
155
|
+
}
|
|
156
|
+
.sereno-table td { font-size: var(--text-sm); color: var(--text-primary); vertical-align: middle; white-space: nowrap; }
|
|
157
|
+
.sereno-table td[data-wrap] { white-space: normal; }
|
|
158
|
+
.sereno-table tbody tr:not(:first-child) td { border-top: 1px solid var(--border-subtle); }
|
|
159
|
+
.sereno-table[data-density="comfortable"] :where(th, td) { padding: var(--space-3) var(--space-4); }
|
|
160
|
+
.sereno-table[data-density="compact"] :where(th, td) { padding: 6px var(--space-4); }
|
|
161
|
+
.sereno-table th[data-sortable] { padding: 0; }
|
|
162
|
+
.sereno-table[data-density="comfortable"] th[data-sortable] button { padding: var(--space-3) var(--space-4); }
|
|
163
|
+
.sereno-table[data-density="compact"] th[data-sortable] button { padding: 6px var(--space-4); }
|
|
164
|
+
.sereno-table[data-sticky] thead { position: sticky; top: 0; z-index: 1; }
|
|
165
|
+
.sereno-table[data-sticky] th { background: var(--bg-subtle); }
|
|
166
|
+
/* `:where()` zeroes the stripe's specificity so hover / selected below always win
|
|
167
|
+
(otherwise `:nth-child` outweighs them and states vanish on even rows). */
|
|
168
|
+
:where(.sereno-table[data-zebra] tbody tr:nth-child(even)) td { background: color-mix(in srgb, var(--bg-subtle) 40%, transparent); }
|
|
169
|
+
.sereno-table tbody tr[data-interactive] { cursor: pointer; transition: background-color var(--duration-fast) var(--ease-standard); }
|
|
170
|
+
/* Row states are a brand-tinted progression so none of them blends into the
|
|
171
|
+
neutral header (also --bg-subtle): hover < selected < selected+hover. */
|
|
172
|
+
.sereno-table tbody tr[data-selected] td { background: color-mix(in srgb, var(--interactive-primary) 26%, var(--bg-subtle)); }
|
|
173
|
+
.sereno-table tbody tr[data-interactive]:hover td { background: color-mix(in srgb, var(--interactive-primary) 14%, var(--bg-subtle)); }
|
|
174
|
+
.sereno-table tbody tr[data-interactive][data-selected]:hover td { background: color-mix(in srgb, var(--interactive-primary) 34%, var(--bg-subtle)); }
|
|
175
|
+
.sereno-table th button { transition: color var(--duration-fast) var(--ease-standard); }
|
|
176
|
+
.sereno-table th button:hover { color: var(--text-primary); }
|
|
177
|
+
/* `min-width: 0` lets the region shrink below the table's `min-width` when it's a
|
|
178
|
+
flex / grid item — without it the wide table forces its ancestors open and the
|
|
179
|
+
*page* scrolls sideways instead of this box. `position: relative` anchors the
|
|
180
|
+
visually-hidden <caption> here (see the caption rule above). */
|
|
181
|
+
.sereno-table-scroll { outline: none; position: relative; min-width: 0; max-width: 100%; }
|
|
182
|
+
.sereno-table-scroll:focus-visible,
|
|
183
|
+
.sereno-table th button:focus-visible,
|
|
184
|
+
.sereno-table tbody tr[data-interactive]:focus-visible {
|
|
185
|
+
outline: 2px solid var(--border-focus);
|
|
186
|
+
outline-offset: -2px;
|
|
187
|
+
border-radius: var(--radius-sm);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* ── Dialog ────────────────────────────────────────────────────────────────
|
|
191
|
+
Header ✕ button — hover/focus states that can't be inline. */
|
|
192
|
+
.sereno-dialog-close:hover { background: var(--interactive-ghost-hover); color: var(--text-primary); }
|
|
193
|
+
.sereno-dialog-close:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
|
|
194
|
+
|
|
195
|
+
/* ── Dismiss ✕ (Alert / Toast) ─────────────────────────────────────────────
|
|
196
|
+
Ghost icon button on a tinted surface — tint the hover from currentColor so
|
|
197
|
+
it reads on every tone. */
|
|
198
|
+
.sereno-dismiss { transition: opacity var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard); }
|
|
199
|
+
.sereno-dismiss:hover { opacity: 1; background: color-mix(in srgb, currentColor 14%, transparent); }
|
|
200
|
+
.sereno-dismiss:focus-visible { opacity: 1; outline: 2px solid currentColor; outline-offset: 1px; }
|
|
201
|
+
|
|
202
|
+
/* ── Toast viewport (ToastProvider) ────────────────────────────────────────
|
|
203
|
+
Enter/exit per stacked toast + the auto-dismiss countdown bar. Direction
|
|
204
|
+
depends on the anchored edge. The reduced-motion rule below damps all of it
|
|
205
|
+
(the JS timer still dismisses on schedule — only the visuals are stilled). */
|
|
206
|
+
.sereno-toast-item { animation: sereno-toast-in var(--duration-normal) var(--ease-out); }
|
|
207
|
+
.sereno-toast-item[data-edge='top'] { animation-name: sereno-toast-in-top; }
|
|
208
|
+
.sereno-toast-item[data-leaving='true'] { animation: sereno-toast-out var(--duration-fast) var(--ease-in) forwards; }
|
|
209
|
+
.sereno-toast-bar {
|
|
210
|
+
position: absolute;
|
|
211
|
+
left: 0;
|
|
212
|
+
bottom: 0;
|
|
213
|
+
width: 100%;
|
|
214
|
+
height: 3px;
|
|
215
|
+
transform-origin: left;
|
|
216
|
+
background: currentColor;
|
|
217
|
+
opacity: 0.32;
|
|
218
|
+
animation-name: sereno-toast-bar;
|
|
219
|
+
animation-timing-function: linear;
|
|
220
|
+
animation-fill-mode: forwards;
|
|
221
|
+
}
|
|
222
|
+
.sereno-toast-bar[data-paused='true'] { animation-play-state: paused; }
|
|
223
|
+
|
|
224
|
+
/* ── DateTimePicker ─────────────────────────────────────────────────────────
|
|
225
|
+
The month/year popover: hover + focus + current-cell states that can't be
|
|
226
|
+
inline styles. The header title button lives here too. */
|
|
227
|
+
.sereno-dtp-title:hover { background: var(--interactive-ghost-hover); }
|
|
228
|
+
.sereno-dtp-title:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
|
|
229
|
+
/* fade only — the box is centred with translateX(-50%), so no transform anim. */
|
|
230
|
+
.sereno-dtp-pop { animation: sereno-fade-in var(--duration-fast) var(--ease-standard); }
|
|
231
|
+
.sereno-dtp-grid button {
|
|
232
|
+
height: 34px;
|
|
233
|
+
border: none;
|
|
234
|
+
border-radius: var(--radius-sm);
|
|
235
|
+
background: transparent;
|
|
236
|
+
cursor: pointer;
|
|
237
|
+
font-family: var(--font-body);
|
|
238
|
+
font-size: var(--text-sm);
|
|
239
|
+
font-weight: var(--weight-medium);
|
|
240
|
+
color: var(--text-primary);
|
|
241
|
+
text-transform: capitalize;
|
|
242
|
+
transition: background-color var(--duration-fast) var(--ease-standard);
|
|
243
|
+
}
|
|
244
|
+
.sereno-dtp-grid button:hover { background: var(--interactive-ghost-hover); }
|
|
245
|
+
.sereno-dtp-grid button:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
|
|
246
|
+
.sereno-dtp-grid button[data-current] {
|
|
247
|
+
background: var(--interactive-primary);
|
|
248
|
+
color: var(--interactive-primary-fg);
|
|
249
|
+
font-weight: var(--weight-bold);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/* ── Reduced motion ──────────────────────────────────────────────────────────
|
|
253
|
+
The token layer already zeroes `--duration-*`, but Button's spinner and
|
|
254
|
+
Skeleton's pulse use fixed loop durations — damp every animation so the
|
|
255
|
+
library honours the preference on its own. */
|
|
256
|
+
@media (prefers-reduced-motion: reduce) {
|
|
257
|
+
* { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
|
|
258
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wraps next-themes so it writes `data-theme="light|dark"` on <html> — the exact
|
|
5
|
+
* hook the Sereno tokens switch on (`[data-theme="dark"]` in colors.css / elevation.css).
|
|
6
|
+
* Defaults to the OS preference; the choice is remembered in localStorage.
|
|
7
|
+
*/
|
|
8
|
+
declare function ThemeProvider({ children }: {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { ThemeProvider };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
|
4
|
+
function ThemeProvider({ children }) {
|
|
5
|
+
return /* @__PURE__ */ jsx(NextThemesProvider, { attribute: "data-theme", defaultTheme: "system", enableSystem: true, enableColorScheme: false, disableTransitionOnChange: true, children });
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
ThemeProvider
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=ThemeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ThemeProvider as NextThemesProvider } from 'next-themes';\n\n/**\n * Wraps next-themes so it writes `data-theme=\"light|dark\"` on <html> — the exact\n * hook the Sereno tokens switch on (`[data-theme=\"dark\"]` in colors.css / elevation.css).\n * Defaults to the OS preference; the choice is remembered in localStorage.\n */\nexport function ThemeProvider({ children }: { children: React.ReactNode }) {\n return (\n <NextThemesProvider attribute=\"data-theme\" defaultTheme=\"system\" enableSystem enableColorScheme={false} disableTransitionOnChange>\n {children}\n </NextThemesProvider>\n );\n}\n"],"mappings":";AAYI;AATJ,SAAS,iBAAiB,0BAA0B;AAO7C,SAAS,cAAc,EAAE,SAAS,GAAkC;AACzE,SACE,oBAAC,sBAAmB,WAAU,cAAa,cAAa,UAAS,cAAY,MAAC,mBAAmB,OAAO,2BAAyB,MAC9H,UACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IconButtonProps } from '../core/IconButton.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Light/dark switch. Resolves the active theme (accounting for `system`) and
|
|
6
|
+
* flips to the opposite. Renders a stable placeholder until mounted to avoid a
|
|
7
|
+
* hydration mismatch on the icon. `variant` defaults to the framed `secondary`;
|
|
8
|
+
* pass `ghost` for a borderless icon-only button.
|
|
9
|
+
*/
|
|
10
|
+
declare function ThemeToggle({ variant }: {
|
|
11
|
+
variant?: IconButtonProps['variant'];
|
|
12
|
+
}): React.JSX.Element;
|
|
13
|
+
|
|
14
|
+
export { ThemeToggle };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useTheme } from "next-themes";
|
|
5
|
+
import { Moon, Sun } from "lucide-react";
|
|
6
|
+
import { IconButton } from "../core/IconButton";
|
|
7
|
+
function ThemeToggle({ variant = "secondary" }) {
|
|
8
|
+
const { resolvedTheme, setTheme } = useTheme();
|
|
9
|
+
const [mounted, setMounted] = React.useState(false);
|
|
10
|
+
React.useEffect(() => setMounted(true), []);
|
|
11
|
+
const isDark = resolvedTheme === "dark";
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
IconButton,
|
|
14
|
+
{
|
|
15
|
+
variant,
|
|
16
|
+
label: mounted ? isDark ? "Mudar para tema claro" : "Mudar para tema escuro" : "Alternar tema",
|
|
17
|
+
onClick: () => setTheme(isDark ? "light" : "dark"),
|
|
18
|
+
children: mounted && isDark ? /* @__PURE__ */ jsx(Sun, { size: 18, strokeWidth: 1.75 }) : /* @__PURE__ */ jsx(Moon, { size: 18, strokeWidth: 1.75 })
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
ThemeToggle
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=ThemeToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/theme/ThemeToggle.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useTheme } from 'next-themes';\nimport { Moon, Sun } from 'lucide-react';\nimport { IconButton, type IconButtonProps } from '../core/IconButton';\n\n/**\n * Light/dark switch. Resolves the active theme (accounting for `system`) and\n * flips to the opposite. Renders a stable placeholder until mounted to avoid a\n * hydration mismatch on the icon. `variant` defaults to the framed `secondary`;\n * pass `ghost` for a borderless icon-only button.\n */\nexport function ThemeToggle({ variant = 'secondary' }: { variant?: IconButtonProps['variant'] }) {\n const { resolvedTheme, setTheme } = useTheme();\n const [mounted, setMounted] = React.useState(false);\n // Standard next-themes hydration guard: the resolved theme is only known on the client.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n React.useEffect(() => setMounted(true), []);\n\n const isDark = resolvedTheme === 'dark';\n return (\n <IconButton\n variant={variant}\n label={mounted ? (isDark ? 'Mudar para tema claro' : 'Mudar para tema escuro') : 'Alternar tema'}\n onClick={() => setTheme(isDark ? 'light' : 'dark')}\n >\n {mounted && isDark ? <Sun size={18} strokeWidth={1.75} /> : <Moon size={18} strokeWidth={1.75} />}\n </IconButton>\n );\n}\n"],"mappings":";AA2B2B;AAzB3B,YAAY,WAAW;AACvB,SAAS,gBAAgB;AACzB,SAAS,MAAM,WAAW;AAC1B,SAAS,kBAAwC;AAQ1C,SAAS,YAAY,EAAE,UAAU,YAAY,GAA6C;AAC/F,QAAM,EAAE,eAAe,SAAS,IAAI,SAAS;AAC7C,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAS,KAAK;AAGlD,QAAM,UAAU,MAAM,WAAW,IAAI,GAAG,CAAC,CAAC;AAE1C,QAAM,SAAS,kBAAkB;AACjC,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO,UAAW,SAAS,0BAA0B,2BAA4B;AAAA,MACjF,SAAS,MAAM,SAAS,SAAS,UAAU,MAAM;AAAA,MAEhD,qBAAW,SAAS,oBAAC,OAAI,MAAM,IAAI,aAAa,MAAM,IAAK,oBAAC,QAAK,MAAM,IAAI,aAAa,MAAM;AAAA;AAAA,EACjG;AAEJ;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sereno-ds/ui",
|
|
3
|
+
"version": "0.24.0",
|
|
4
|
+
"description": "Sereno Design System — React primitives (token-driven, inline styles, no UI base lib).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Sereno",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/GabrielGomesBarbosa/sereno-ds.git",
|
|
10
|
+
"directory": "packages/ui"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/GabrielGomesBarbosa/sereno-ds/tree/main/packages/ui#readme",
|
|
13
|
+
"bugs": "https://github.com/GabrielGomesBarbosa/sereno-ds/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"design-system",
|
|
16
|
+
"react",
|
|
17
|
+
"components",
|
|
18
|
+
"ui",
|
|
19
|
+
"tokens",
|
|
20
|
+
"sereno"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"**/*.css"
|
|
25
|
+
],
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./styles.css": "./dist/styles.css",
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"main": "./dist/index.js",
|
|
35
|
+
"module": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsup",
|
|
44
|
+
"dev": "tsup --watch",
|
|
45
|
+
"lint": "eslint .",
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:watch": "vitest",
|
|
49
|
+
"prepack": "npm run build"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"next-themes": "^0.4.6"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@sereno-ds/tokens": "*",
|
|
56
|
+
"lucide-react": ">=1",
|
|
57
|
+
"react": ">=18",
|
|
58
|
+
"react-dom": ">=18"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
62
|
+
"@testing-library/react": "^16.3.3",
|
|
63
|
+
"@testing-library/user-event": "^14.6.7",
|
|
64
|
+
"@types/react": "^19",
|
|
65
|
+
"@types/react-dom": "^19",
|
|
66
|
+
"@vitest/coverage-v8": "^2.1.9",
|
|
67
|
+
"jsdom": "^25.0.1",
|
|
68
|
+
"lucide-react": "^1.34.0",
|
|
69
|
+
"react": "19.2.8",
|
|
70
|
+
"react-dom": "19.2.8",
|
|
71
|
+
"tsup": "^8.5.1",
|
|
72
|
+
"typescript": "^5",
|
|
73
|
+
"vitest": "^2.1.9"
|
|
74
|
+
},
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"access": "public",
|
|
77
|
+
"provenance": true
|
|
78
|
+
}
|
|
79
|
+
}
|