@motor-hero/ui-kit 0.40.0 → 0.43.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/dist/components/date-picker.d.ts +4 -2
- package/dist/components/date-picker.d.ts.map +1 -1
- package/dist/components/highlight-pill.d.ts +18 -0
- package/dist/components/highlight-pill.d.ts.map +1 -0
- package/dist/index.cjs +177 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +130 -103
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/date-picker.tsx +8 -5
- package/src/components/highlight-pill.tsx +43 -0
- package/src/index.ts +2 -0
package/package.json
CHANGED
|
@@ -16,10 +16,13 @@ const MASK_REPLACEMENT = { _: /\d/ }
|
|
|
16
16
|
const DATE_FORMAT = "dd/MM/yyyy"
|
|
17
17
|
const TIME_FORMAT = "HH:mm"
|
|
18
18
|
const DATE_VALUE_FORMAT = "yyyy-MM-dd"
|
|
19
|
+
const DATETIME_VALUE_FORMAT = "yyyy-MM-dd'T'HH:mm"
|
|
19
20
|
|
|
20
21
|
export interface DatePickerProps {
|
|
21
|
-
/** `DatePicker`: data pura `"yyyy-MM-dd"
|
|
22
|
-
*
|
|
22
|
+
/** `DatePicker`: data pura `"yyyy-MM-dd"`. `DateTimePicker`: hora de parede
|
|
23
|
+
* `"yyyy-MM-ddTHH:mm"` — os dígitos digitados, tal qual. Nenhum dos dois
|
|
24
|
+
* passa por conversão de fuso: o significado (Brasília, local, UTC) é
|
|
25
|
+
* decisão do consumidor. `""`/`undefined` = sem valor. */
|
|
23
26
|
value?: string
|
|
24
27
|
onChange: (value: string) => void
|
|
25
28
|
placeholder?: string
|
|
@@ -60,8 +63,8 @@ function dateOnlyToDate(value: string | undefined): Date | undefined {
|
|
|
60
63
|
|
|
61
64
|
function dateTimeToDate(value: string | undefined): Date | undefined {
|
|
62
65
|
if (!value) return undefined
|
|
63
|
-
const parsed = new Date(
|
|
64
|
-
return
|
|
66
|
+
const parsed = parse(value, DATETIME_VALUE_FORMAT, new Date())
|
|
67
|
+
return isValid(parsed) ? parsed : undefined
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
function displayFor(value: string | undefined, withTime: boolean): string {
|
|
@@ -196,7 +199,7 @@ function DatePickerImpl({
|
|
|
196
199
|
if (!time) return
|
|
197
200
|
const combined = new Date(date)
|
|
198
201
|
combined.setHours(time.getHours(), time.getMinutes(), 0, 0)
|
|
199
|
-
onChange(combined
|
|
202
|
+
onChange(format(combined, DATETIME_VALUE_FORMAT))
|
|
200
203
|
setOpen(false)
|
|
201
204
|
}
|
|
202
205
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react"
|
|
2
|
+
import { cn } from "../lib/utils"
|
|
3
|
+
|
|
4
|
+
export interface HighlightPillProps {
|
|
5
|
+
/** Pill background. Falls back to the neutral/muted status token when omitted. */
|
|
6
|
+
backgroundColor?: string
|
|
7
|
+
/** Pill text color. Falls back to the neutral/muted status token when omitted. */
|
|
8
|
+
textColor?: string
|
|
9
|
+
className?: string
|
|
10
|
+
children: ReactNode
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Pílula de cor livre — `backgroundColor`/`textColor` vêm do consumidor, ao
|
|
15
|
+
* invés de um enum fechado de variantes como o `StatusBadge`. Sem eles, cai
|
|
16
|
+
* no mesmo tom neutro do `StatusBadge` (`--status-neutral-*`), servindo como
|
|
17
|
+
* o "default muted" de qualquer feature que atribua cor por entidade (ex.:
|
|
18
|
+
* cor de destaque por usuário admin, ADR 0081 do workspace IMMA).
|
|
19
|
+
*/
|
|
20
|
+
export function HighlightPill({
|
|
21
|
+
backgroundColor,
|
|
22
|
+
textColor,
|
|
23
|
+
className,
|
|
24
|
+
children,
|
|
25
|
+
}: HighlightPillProps) {
|
|
26
|
+
const style: CSSProperties = {
|
|
27
|
+
backgroundColor:
|
|
28
|
+
backgroundColor ?? "var(--status-neutral-surface, #f3f4f6)",
|
|
29
|
+
color: textColor ?? "var(--status-neutral-text, #374151)",
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<span
|
|
34
|
+
style={style}
|
|
35
|
+
className={cn(
|
|
36
|
+
"inline-flex items-center rounded-md px-2 py-0.5 text-xs font-medium",
|
|
37
|
+
className,
|
|
38
|
+
)}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</span>
|
|
42
|
+
)
|
|
43
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -31,6 +31,8 @@ export {
|
|
|
31
31
|
export type { FormDialogProps, FormDialogSize } from "./components/form-dialog";
|
|
32
32
|
export { FormDialog, FormDialogLayout } from "./components/form-dialog";
|
|
33
33
|
export { FormField } from "./components/form-field";
|
|
34
|
+
export type { HighlightPillProps } from "./components/highlight-pill";
|
|
35
|
+
export { HighlightPill } from "./components/highlight-pill";
|
|
34
36
|
export { MobileCardList } from "./components/mobile-card-list";
|
|
35
37
|
// Components
|
|
36
38
|
export { ModeToggle } from "./components/mode-toggle";
|